|
107 | 107 | return; |
108 | 108 | } |
109 | 109 | if (!dev.advertisement) return; |
| 110 | + var path = dev.address || dev.uuid; |
110 | 111 | 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; |
113 | 114 | var hasUartService = dev.advertisement.serviceUuids && |
114 | 115 | dev.advertisement.serviceUuids.map(s => s.replaceAll('-', '')).indexOf(NORDIC_SERVICE)>=0; |
115 | 116 | if (hasUartService || |
116 | 117 | 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); |
121 | 122 | }); |
122 | 123 |
|
123 | 124 | // if we didn't initialise for whatever reason, keep going anyway |
|
0 commit comments