If a puck disconnects from my browser due to the connection dropping out (e.g. it moves out of range) is there a way to detect this on the web front end? I can see that puck.js creates the following console log: Disconnected (gattserverdisconnected)
I’m using the following code snippet to create a 2-way connection as per one of your site tutorials. This includes the part about resetting the puck on disconnection, which seems to work fine on the puck - I just want to be able to reset the browser too.
Puck.connect(function(connection) {
connection.on("data", function(d) {
// handle receiving data
}
connection.write("reset();\n", function() {
setTimeout(function(){
// do various stuff here
// reset on disconnect
connection.write("NRF.on('disconnect',function(){ reset(); });\n",function(){});
},1500);
});
// I'm hoping there's a way to detect disconnection here
// e.g. connection.on("disconnect", function(){});
});
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.
If a puck disconnects from my browser due to the connection dropping out (e.g. it moves out of range) is there a way to detect this on the web front end? I can see that puck.js creates the following console log:
Disconnected (gattserverdisconnected)
I’m using the following code snippet to create a 2-way connection as per one of your site tutorials. This includes the part about resetting the puck on disconnection, which seems to work fine on the puck - I just want to be able to reset the browser too.
Thanks!