100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Sort scanned mesh proxies by RSSI
Rainer Hitz82503abc3e27
diff --git a/agent/src/main/java/org/openremote/agent/protocol/bluetooth/mesh/BluetoothMeshNetwork.java b/agent/src/main/java/org/openremote/agent/protocol/bluetooth/mesh/BluetoothMeshNetwork.javaindex 5f91b4a33..e8029bbef 100644--- a/agent/src/main/java/org/openremote/agent/protocol/bluetooth/mesh/BluetoothMeshNetwork.java+++ b/agent/src/main/java/org/openremote/agent/protocol/bluetooth/mesh/BluetoothMeshNetwork.java@@ -466,7 +466,6 @@ public class BluetoothMeshNetwork extends BluetoothCentralManagerCallback implem}if (meshProxies.size() > 0) {synchronized (BluetoothMeshNetwork.this) {- // TODO: consider rssi and choose proxy in close proximityBluetoothMeshNetwork.this.bluetoothMeshProxy = meshProxies.get(0);BluetoothMeshNetwork.this.bluetoothMeshProxy.setRxDataCallback(BluetoothMeshNetwork.this);BluetoothMeshNetwork.this.bluetoothMeshProxy.connect(statusConsumer, new BluetoothMeshProxyConnectCallback() {diff --git a/agent/src/main/java/org/openremote/agent/protocol/bluetooth/mesh/BluetoothMeshProxyScanner.java b/agent/src/main/java/org/openremote/agent/protocol/bluetooth/mesh/BluetoothMeshProxyScanner.javaindex 530a8f67f..95c72c115 100644--- a/agent/src/main/java/org/openremote/agent/protocol/bluetooth/mesh/BluetoothMeshProxyScanner.java+++ b/agent/src/main/java/org/openremote/agent/protocol/bluetooth/mesh/BluetoothMeshProxyScanner.java@@ -30,6 +30,7 @@ import java.nio.ByteBuffer;import java.nio.ByteOrder;import java.util.ArrayList;import java.util.Arrays;+import java.util.Comparator;import java.util.HashMap;import java.util.List;import java.util.Map;@@ -38,6 +39,7 @@ import java.util.concurrent.ScheduledExecutorService;import java.util.concurrent.ScheduledFuture;import java.util.concurrent.TimeUnit;import java.util.logging.Logger;+import java.util.stream.Collectors;public class BluetoothMeshProxyScanner extends BluetoothCentralManagerCallback {@@ -94,13 +96,11 @@ public class BluetoothMeshProxyScanner extends BluetoothCentralManagerCallback {public void run() {synchronized (BluetoothMeshProxyScanner.this) {if (isStarted && callback != null) {- final List<BluetoothMeshProxy> proxies = new ArrayList<>(meshProxyMap.values());- executorService.schedule(new Runnable() {- @Override- public void run() {- callback.onMeshProxiesScanned(proxies, null);- }- }, 0, TimeUnit.MILLISECONDS);+ final List<BluetoothMeshProxy> proxies = meshProxyMap.values()+ .stream()+ .sorted(Comparator.comparingInt(BluetoothMeshProxy::getRssi).reversed())+ .collect(Collectors.toList());+ executorService.execute(() -> callback.onMeshProxiesScanned(proxies, null));}timeoutFuture = null;stop();