You are reading a single comment by @user93564 and its replies. Click here to read the full conversation.
  • 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

    NRF.setAdvertising({},{interval:100, manufacturer: 0x0590, manufacturerData:[state]});
    

    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).

About

Avatar for user93564 @user93564 started