HELP - const gattServer = await device.gatt()- don't work :/
See original GitHub issue
1. const { createBluetooth } = require('node-ble')
2. const { TEST_DEVICE, TEST_SERVICE, TEST_CHARACTERISTIC, TEST_NOTIFY_SERVICE, TEST_NOTIFY_CHARACTERISTIC } = process.env
3.
4. async function main () {
5. const { bluetooth, destroy } = createBluetooth()
6.
7. // get bluetooth adapter
8. const adapter = await bluetooth.defaultAdapter()
9. await adapter.startDiscovery()
10. console.log('discovering')
11.
12. // get device and connect
13. const device = await adapter.waitDevice(TEST_DEVICE)
14. console.log('got device', await device.getAddress(), await device.getName())
15. await device.connect()
16. console.log('connected')
17. // console.log(device)
18. console.log(await device.getRSSI())
19. const gattServer = await device.gatt()
20. console.log(gattServer)
21. // read write characteristic
22. const service1 = await gattServer.getPrimaryService("0000180f-0000-1000-8000-00805f9b34fb")
23. // console.log(service1)
24. const characteristic1 = await service1.getCharacteristic("00002a19-0000-1000-8000-00805f9b34fb")
25. // await characteristic1.writeValue(Buffer.from('Hello world'))
26. const buffer = await characteristic1.readValue()
27. console.log('read', buffer, buffer.toString())
28.
29. destroy()
30. }
31.
32. main()
33. .then(console.log)
34. .catch(console.error)
35.
out:
discovering
got device EC:21:E5:43:94:CA BLESmart_00000044EC21E54394CA
connected
-43
I have trying to connect my blood pressure monitor to extract the data, but in line 19 - (const gattServer = await device.gatt()) doesn’t seem to work. The code stay in line 19 and never get the service in line 22. May some one help me? please!
Issue Analytics
- State:
- Created 3 years ago
- Comments:8
Top Results From Across the Web
when connected and receive data from BLE device I get DOM ...
I believe what you're experiencing is not Web Bluetooth related, but a GATT Protocol error as described in the Bluetooth Core Specification ...
Read more >Can't discover service, and then 'org.bluez.Error.Failed' after a ...
I can discover the device, but not the service. ... const gattServer = await device.gatt() // read write characteristic const service1 = await...
Read more >pi 4 - Trouble connecting to bluetooth device
How these two types of Bluetooth work is very different. ... waitDevice(deviceGUID); await device.connect(); const gattServer = await ...
Read more >GattServer - API references and tutorials - Mbed
Application code can add a GattService object to the server with the help of the function addService() . That function registers all the...
Read more >node-ble - npm
Use an adapter to get a remote Bluetooth device, then connect to it and bind to the GATT (Generic Attribute Profile) server. const...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@mathbozzi thanks for your reply. I just noticed, that the device immediately gets disconnected after the device.connect() call. That’s the reason in my case why the device.gatt() call does not return. I need to further investigate on this.
@rzumbuehl I was curious if you had discovered why the device was closing the connection immediately. I am observing the same behavior.