diff --git a/src/main/java/com/serotonin/bacnet4j/LocalDevice.java b/src/main/java/com/serotonin/bacnet4j/LocalDevice.java index 42d5e50c..d37a629c 100644 --- a/src/main/java/com/serotonin/bacnet4j/LocalDevice.java +++ b/src/main/java/com/serotonin/bacnet4j/LocalDevice.java @@ -480,6 +480,13 @@ public LocalDevice withNumberOfApduRetries(final UnsignedInteger numberOfApduRet return this; } + /** + * Returns the currently configured timeout in ms within the transport. + */ + public int getTransportTimeout() { + return transport.getTimeout(); + } + //////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////// // Local object management diff --git a/src/main/java/com/serotonin/bacnet4j/util/PropertyUtils.java b/src/main/java/com/serotonin/bacnet4j/util/PropertyUtils.java index 6120b5f2..3c61e1c9 100644 --- a/src/main/java/com/serotonin/bacnet4j/util/PropertyUtils.java +++ b/src/main/java/com/serotonin/bacnet4j/util/PropertyUtils.java @@ -84,6 +84,13 @@ public static DeviceObjectPropertyValues readProperties(final LocalDevice localD */ public static DeviceObjectPropertyValues readProperties(final LocalDevice localDevice, final DeviceObjectPropertyReferences refs, final ReadListener callback, final long deviceTimeout) { + final long timeoutToUse; + if (deviceTimeout <= 0) { + timeoutToUse = localDevice.getTransportTimeout(); + } else { + timeoutToUse = deviceTimeout; + } + final DeviceObjectPropertyValues result = new DeviceObjectPropertyValues(); final Map properties = refs.getProperties(); @@ -156,7 +163,7 @@ public static DeviceObjectPropertyValues readProperties(final LocalDevice localD if (rd == null) { // Initiate a device lookup runnable = () -> { - requestPropertiesFromDevice(localDevice, deviceId, deviceTimeout, propRefs, callback, result, + requestPropertiesFromDevice(localDevice, deviceId, timeoutToUse, propRefs, callback, result, completedProperties, totalProperties); }; } else { @@ -169,7 +176,7 @@ public static DeviceObjectPropertyValues readProperties(final LocalDevice localD // The cached device appears to be offline. Remove it from the cache, and try discovering it // again in case its address changed. localDevice.removeCachedRemoteDevice(deviceId); - requestPropertiesFromDevice(localDevice, deviceId, deviceTimeout, propRefs, callback, result, + requestPropertiesFromDevice(localDevice, deviceId, timeoutToUse, propRefs, callback, result, completedProperties, totalProperties); } };