-
• #2
What you're doing there looks ok, but BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION isn't defined, so you'd have to define it as a number somewhere.
To make debugging this easier, I'd suggest adding a USB-TTL converter if you have one handy: http://www.espruino.com/MDBT42Q#serial-console (and then do
Serial1.setConsole(1)
for force the console on serial even when Bluetooth is connected).You can then interact with the REPL at the same time as trying out Bluetooth stuff, which should help no end!
-
• #3
Thanks, that's great ! What do you mean by defining it as a number ? the reason has to not match that specific number right.
Isn't that constant already defined ?
define BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION 0x13 /**< Remote User Terminated Connection. */
Do you mean that i should define it as 0x13 ? -
• #4
I'm afraid those constants aren't defined in JS - they just come from the Nordic Softdevice.
Doing
var BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION = 0x13
as you suggest would really help I reckon.Of course I guess you could also do:
var reasons = []; NRF.on('disconnect', function (reason) { reasons.push(reason); });
And then check out what was in
reasons
when you reconnect? -
• #5
Alright, then i misunderstood. Ah yeah that's great, thanks Gordon.
Hey i'm trying to to do different things depending on what reason the ble disconnect says. Hard to view this live and debug.
Got a MDBT42Q module hooked up the bangle. I wish to differentiate the gatt.device.disconnect() (user terminated disconnection) event and the event when range is reason to disconnect. Is this possible ? and what events might those be ? and how do i check them.
Currently i do this with no luck, it seems that the same event is fired for both types of disconnection.
Standard buzz never happends.