BLE connection timeout on startNotifications() #7823
-
I'm writing my first BLE app and would be grateful for any help anybody can provide. Basically, I'd like my Bangle to receive notifications from a BLE peripheral device. Using the code below, my Bangle is able to successfully connect to the peripheral, get its service, and the service's characteristic. But after calling characteristic.startNotifications(), nothing happens for several seconds and my Bangle disconnects from the device without ever getting a 'characteristicvaluechanged' event. I've used the NRF Connect app and verified that when it subscribes to notifications from the device it does receive data as expected, though it can take up to 10 seconds before the device sends any data. I've searched but couldn't find/understand enough info to understand what's going on at the BLE level, so if anybody can offer any suggestions about what to try next I would appreciate it. In particular, is there a notification timeout that may be causing my app to disconnect before it has received any data? If so, is there way to override such a timeout? Also, what is going on on the Bangle side after calling characteristic.startNotifications()? Does it send any data notifying the peripheral of its intent to subscribe (and disconnect if it doesn't receive an acknowledgement), or does it simply wait until it receives data from the peripheral? Well, here's the code I'm using. Thanks for taking a look and offering any ideas you might have!
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 10 replies
-
Hi - the code you've got there looks good. Only thing I can think of is are you sure that
No, there shouldn't be. There's a timeout if the peripheral device doesn't respond to a certain number of polling intervals, but that's pretty standard as it should really always respond to keep a connection going. When the device disconnects I see you have
Yes, that's exactly right. It tries to find the device's characteristic descriptor (CCCD) and then writes a value to it to enable notifications. IIRC if those fail startNotifications should fail - it shouldn't automatically trigger a disconnect. It's why it might be handy to see what the disconnect reason was. Is your Bangle firmware up to date? I know we did have an issue when the CCCD was in a non-standard place (as in Adafruit Bluefruit modules) but I fixed that a year or more ago now, so any semi-recent firmware should be ok. |
Beta Was this translation helpful? Give feedback.
NRF.connect("68:5E:1C:2B:5F:00 public",{minInterval:7.5, maxInterval:15}).then(function(ga) {
maybe also try connection intervals like so