Closed TIB28 closed 3 years ago
Here is my code where the gatt.services() function returns nothing:
gatt.services()
const connectDevice = async (deviceName) => { const adapter = await bluetooth.defaultAdapter() if (! await adapter.isDiscovering()) await adapter.startDiscovery() var devices = await adapter.devices() for (deviceMac of devices) { const device = await adapter.waitDevice(deviceMac) const name = await device.getAlias() if (name == deviceName) { console.log(deviceName + " found !!") // the device is found const gatt = await device.gatt() var services = await gatt.services(); console.log(services) // give me nothing here } else { device.disconnect() } } } connectDevice("myDevice")
Also i'm running that on a raspberry pi 4 with sudo and nodeJS v10.21.0 from apt if ever that matters.
I just figure out that i never connect to the device. So just adding await device.connect()fix it.
await device.connect()
Here is my code where the
gatt.services()
function returns nothing:Also i'm running that on a raspberry pi 4 with sudo and nodeJS v10.21.0 from apt if ever that matters.