Closed ghost closed 6 years ago
Hi,
Thank you!
For the notifications, did you remember to call the startNotifications()
method?
Then, for reading, can you please debug the background page of the extension and show the logs that you get there? Also, check if you get any output on the devtools console of your web page.
Hi Urish, I'm not trying to use notifications. I'm just reading a characteristic value.
The debug logs show that the read result is being received. I'm just not getting a callback to the handler function onModelNumberStringChanged.
Sent native message: {device: "BluetoothLE#BluetoothLE7c:7a:91:db:f3:43-b8:27:eb:c5:e9:31", service: "{0000180a-0000-1000-8000-00805f9b34fb}", characteristic: "{00002a24-0000-1000-8000-00805f9b34fb}", cmd: "read", _id: 130}
background.js:24 Received native message:
By the way, I'm using notifications with a different characteristic and that is working fine. It's just the use of characteristic.readValue which is not working.
I see, currently the event listener is only invoked if you use notifications. I will check what the spec says about this - currently, the way it works with reading would be to wait for the promise to resolve:
model_number_string.readValue().then(value => {
// do something with value
});
I see that according to the spec, readValue()
should indeed fire a characteristicvaluechanged
event. I will add it
Great, thank you. I'm preparing a series of tutorials for bluetooth.com. I'll mention your polyfill :-)
Nice, and nice to meet you by the way! Are you also on Twitter?
Likewise :-)
@bluetooth_mdw
Very interested in seeing Web Bluetooth adopted across all the browsers!
awesome!
Then perhaps you can chime in this discussion: https://twitter.com/Espruino/status/923555356835504128
Can you check if the fix does the trick for you?
a) Works a treat - thanks for the rapid service!
b) I changed to the resolved promise pattern anyway since this is clearly more in keeping with the normal use of the API.
Marvellous!
You are welcome :)
not related - do you know if there is some ongoing process for a standard UART BLE service?
I don't think there is. It's a common request though.
Okay, thanks!
Hi, I'm trying to use this polyfill for the first time. Nice work btw!
writeValue is working fine but readValue is not. I have a protocol analyzer and can see that the expected attribute protocol messages are exchanged with my peripheral and the expected characteristic value is being returned. But I don't get a callback to the registered function.
The same web page works fine from Chrome on Android and on Mac OS.
During service discovery I do this:
The callback function looks like this:
And I request the read of the characteristic with:
Any ideas?