-
• #2
connection.on('close', function() { ... });
doesn't do the trick? -
• #3
I think you might want
gattserverdisconnected
: https://www.espruino.com/Reference#l_BluetoothDevice_gattserverdisconnectedIt's an odd name, but for some reason it's what they chose for the Web Bluetooth spec.
-
• #4
Thank you both,
this works great it seems:
gatt.device.on('gattserverdisconnected', function(reason) {console.log("gattserverdisconnected, Grund: "+ reason+" Zeit: " + (getTime() -t) + " sec"); disconnect(reason);} );
with variable t being set earlier upon successful connect.
with reason 8 triggered when the BLE server (my sensor) goes out of reach (loss of reception) and reason (int) 19 gets triggered when the sensor shuts down due to inactivity.
Thanks again,
Joost
Hi everybody,
I'm wondering if there is a callback of some sort if/when the espruino device loses connection to a BLE sensor, when subscribed to it's notifications?
Otherwise I would reset a timer upon reception of every notification, and check say every 15 seconds if the timer was reset (meaning notifications were still received), and disconnect if not.
What do you think?
Thanks, Joost