Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions core/serial_noble.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,18 @@
return;
}
if (!dev.advertisement) return;
var path = dev.address || dev.uuid;
for (var i in newDevices)
if (newDevices[i].path == dev.address) return; // already seen it
var name = dev.advertisement.localName || dev.address;
if (newDevices[i].path == path) return; // already seen it
var name = dev.advertisement.localName || path;
var hasUartService = dev.advertisement.serviceUuids &&
dev.advertisement.serviceUuids.map(s => s.replaceAll('-', '')).indexOf(NORDIC_SERVICE)>=0;
if (hasUartService ||
Espruino.Core.Utils.isRecognisedBluetoothDevice(name, dev.address)) {
console.log("Noble: Found UART device:", name, dev.address);
newDevices.push({ path: dev.address, description: name, type: "bluetooth", rssi: dev.rssi });
btDevices[dev.address] = dev;
} else console.log("Noble: Found device:", name, dev.address);
console.log("Noble: Found UART device:", name, path);
newDevices.push({ path: path, description: name, type: "bluetooth", rssi: dev.rssi });
btDevices[path] = dev;
} else console.log("Noble: Found device:", name, path);
});

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