Detect when a puck.js disconnects from a browser form #3857
Replies: 1 comment
-
Posted at 2021-09-08 by Robin Wed 2021.09.08 Hi @jeff One idea might be to have the Puck regularly signal the web page, and have the web page continually look for that 'ping'. Within a try/catch block, when the ping doesn't arrive timely, throw and trap an exception within the web page itself. Example bi-directional comm examples here:
Posted at 2021-09-12 by Jeff Thanks for the information Robin. I will look into a try/catch block. Rather than looking for an error is could I query the BLE and make use of the following information the puck sends? Sorry if this is total newby question. puck.js:406 Connected Posted at 2021-09-12 by Robin Sun 2021.09.12 Hi @jeff as I indicated 'One idea might be to have the Puck regularly signal' and you now have yet another. I steered away from that solution as I wasn't able to find a suitable example/tutorial and there had been a recent post on how to wire the rejected 'Promise' into existing code.
Anyone suggest/provide a simple example code block, other than the API reference? Posted at 2021-09-14 by @gfwilliams Hi - those errors actually come from the I think the easiest way to check for connection is to use The Puck library isn't that well documented externally, but there are a bunch of comments inside it that might help: https://github.com/espruino/EspruinoWebTools/blob/master/puck.js#L446 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2021-09-08 by Jeff
Hello all,
I am a newbie and appreciate any help. I have tried generating a solution but have lost much hair trying!
I connect to the puck from a Windows browser using the following javascript function and query the accelerometer with a timer using the subsequent function. How can I detect if the puck.js disconnects?
Thanks in advance,
Jeff
Beta Was this translation helpful? Give feedback.
All reactions