-
Mon 2021.10.04
reply to post #6
'how I can send a bTN press to the website and be detected'
As I'm not aware of your level of coding expertise, forgive if this is a bit too basic.
Beneath heading: Reading from Puck.js halfway down the page
Puck.eval("BTN.read()",function(x) { console.log(x); })
Is the example that you are after. Now, that said, how it functions is a bit trickier. Having a foundation and background with the request/response model along with a solid understanding of callbacks and promises will be required, along with GATT familiarity.
Here is my go to source along with a 'Try It' window:
https://www.w3schools.com/jsref/jsref_eval.asp
https://www.w3schools.com/js/js_callback.asp
https://www.w3schools.com/js/js_promise.aspThe easiest way is to take a peek at the source, follow the inclusion to the .js source
<script src="https://www.puck-js.com/puck.js" script>
and load that file in the browser from: https://www.puck-js.com/puck.js
go the the end of that file and search backwards for:
eval : function(expr, cb)
and study the relationships between the example send event and the code file receive/decode event.If I were doing this and as a suggestion, create a new page and embed that code source into that page to make easier debug breakpoint setting and step through several times to see the sequence in action.
Remember this must be served from an https: server such as deployed at github.
Practical usage will be more beneficial in the long run, than trying to explain what to do.
I was able to send text to the banglejs, but I'm still searching how I can send a bTN press to the website and be detected. The web should be polling the watch endlessly to detect a press?