The following program logs "connect" and "disconnect" BLE events, while writing a dummy message in a loop.
This is tested with a Bangle2 and an Android phone ("BLE Scanner" and also "nRF Connect").
The "disconnect" event is properly detected, but not the "connect" one. However, the connection seems to be effective because "BLE Scanner" is able to read strings from the Bangle2.
Also, when connected, the writing loop is not called. Why, please ?
var counter = 0;
// No display when connected. Pending lines are logged after disconnection.
setInterval(
function()
{
console.log("counter=", counter);
counter++;
},
1000);
// Just logs "-> Bluetooth". The custom message is not visible.
NRF.on('connect', function(addr) {
// Not called.
console.log("Connection. addr=", addr); // Not displayed/
});
// Also logs "<- Bluetooth", as expected.
NRF.on('disconnect', function(reason) {
// This displays: "reason=19" which looks fine.
console.log("reason=", reason);
});
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
The following program logs "connect" and "disconnect" BLE events, while writing a dummy message in a loop.
This is tested with a Bangle2 and an Android phone ("BLE Scanner" and also "nRF Connect").
The "disconnect" event is properly detected, but not the "connect" one. However, the connection seems to be effective because "BLE Scanner" is able to read strings from the Bangle2.
Also, when connected, the writing loop is not called. Why, please ?