I am trying to do something that should be easy, but can't make it work consistently as I intend. I just need to advertise a state (simple numbers 0-10) from one Puck and scan it with the other Puck (using advertising and scanning, without connections). I need to read this state every second or so. What I do now is something like thiss
on one Puck (call this same line multiple time in different places and time depending on the value of state, not too quick though, manually every 5 seconds or so, is that ok?) and
NRF.setScan(function scanFn(d) {
if (d.id !== "xx:xx:xx:xx:xx:xx random") {
return;
}
if (d.manufacturerData) {
var temp = d.manufacturerData[0];
print("state = " + temp);
// do stuff accordingly to state value
The problem is that it can takes a long time (like 3-5 seconds) for scan to pick up the changes and things will hung up sometimes, although that can be my codes fault.
Can NRF.requestDevice read advertising data (the state) from the other Puck? I am using the latest travis firmware btw (24 august I think).
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.
I am trying to do something that should be easy, but can't make it work consistently as I intend. I just need to advertise a state (simple numbers 0-10) from one Puck and scan it with the other Puck (using advertising and scanning, without connections). I need to read this state every second or so. What I do now is something like thiss
on one Puck (call this same line multiple time in different places and time depending on the value of state, not too quick though, manually every 5 seconds or so, is that ok?) and
The problem is that it can takes a long time (like 3-5 seconds) for scan to pick up the changes and things will hung up sometimes, although that can be my codes fault.
Can NRF.requestDevice read advertising data (the state) from the other Puck? I am using the latest travis firmware btw (24 august I think).