Skip to content

Commit 60e78bb

Browse files
authored
Merge pull request #198 from xabbu42/handle-empty-address
Handle multiple devices with empty address by falling back on uuid
2 parents f4e9be4 + 237e6b0 commit 60e78bb

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

core/serial_noble.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,18 @@
107107
return;
108108
}
109109
if (!dev.advertisement) return;
110+
var path = dev.address || dev.uuid;
110111
for (var i in newDevices)
111-
if (newDevices[i].path == dev.address) return; // already seen it
112-
var name = dev.advertisement.localName || dev.address;
112+
if (newDevices[i].path == path) return; // already seen it
113+
var name = dev.advertisement.localName || path;
113114
var hasUartService = dev.advertisement.serviceUuids &&
114115
dev.advertisement.serviceUuids.map(s => s.replaceAll('-', '')).indexOf(NORDIC_SERVICE)>=0;
115116
if (hasUartService ||
116117
Espruino.Core.Utils.isRecognisedBluetoothDevice(name, dev.address)) {
117-
console.log("Noble: Found UART device:", name, dev.address);
118-
newDevices.push({ path: dev.address, description: name, type: "bluetooth", rssi: dev.rssi });
119-
btDevices[dev.address] = dev;
120-
} else console.log("Noble: Found device:", name, dev.address);
118+
console.log("Noble: Found UART device:", name, path);
119+
newDevices.push({ path: path, description: name, type: "bluetooth", rssi: dev.rssi });
120+
btDevices[path] = dev;
121+
} else console.log("Noble: Found device:", name, path);
121122
});
122123

123124
// if we didn't initialise for whatever reason, keep going anyway

0 commit comments

Comments
 (0)