Avatar for user93564

user93564

Member since Aug 2018 • Last active Oct 2018
  • 1 conversations
  • 5 comments

Most recent activity

  • in Puck.js, Pixl.js and MDBT42
    Avatar for user93564

    That looks exactly what I need, thanks a lot Gordon, will try cutting edge as soon as I can :)

  • in Puck.js, Pixl.js and MDBT42
    Avatar for user93564

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

  • in Puck.js, Pixl.js and MDBT42
    Avatar for user93564

    Thanks Gordon, that works. The only problem I still get with scanning is that the Puck that does it will get unresponsive after a while, not totally, I still can connect to it, but if I write commands in the console of the ide, they are laggish, and most of the time uploading code with get stuck somewhere in the middle, I have to take out the battery. Doing

    reset()
    NRF.setScan()
    

    on the console doesn't fix the problem. Any idea what's wrong? Would setInterval with NRF.findDevices be a better approach to periodically scanning and get data (number) from another Puck?

  • in Puck.js, Pixl.js and MDBT42
    Avatar for user93564

    I mean that after setState() is called, NRF.setScan will stop scanning. Actually I check

    d.manufacturerData[0]
    

    so setState() is not called if there is no change in there, and since I change it manually, I do after some seconds, so don't think that's the problem. If for example I put these:

    function setState() {
    print("working");
    }
    

    then it works, scanning will continue normally. Sorry if what I'm saying doesn't make sense, I can post all the code if needed. Thanks.

  • in Puck.js, Pixl.js and MDBT42
    Avatar for user93564

    Hi. I am having a problem when calling a function inside NRF.setScan():

    NRF.setScan(function(d) {
        if (d.id === "xxxx") { 
              //do some stuff here
              setState([0xCC, 0x24, 0x33]); }
    }
    

    When I call setState(), it doesn't return to NRF.setScan:

    function setState(arg) {
        var gatt;  
        NRF.connect(addr).then(function(g) {
          gatt = g;
          return gatt.getPrimaryService("0000ffe5-0000-10­00-8000-00805f9b34fb");
        }).then(function(service) {
          return service.getCharacteristic("0000ffe9-0000­-1000-8000-00805f9b34fb");
        }).then(function(c) {
          characteristic = c;
          return characteristic.writeValue(arg);
        }).then(function() {
          gatt.disconnect();
        });
      }
    

    Any idea why? Other functions return properly, something to do with NRF.connect maybe?

Actions