Avatar for user101905

user101905

Member since Jul 2019 • Last active Jul 2019
  • 1 conversations
  • 2 comments

Most recent activity

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

    Update:

    Im done with second characteristic and it works. But with notify it stocks.

    Here is the Code:

    NRF.setServices({
      "b0d0cdff-56fa-4bee-b611-874c82f0c313": {
       "9ed52c1b-73e4-47a9-b335-8e12cfa22fdc": {
          value : 0,
          writable : false,
          notify:true
        }
      }
    }, { uart : false });
    

    And the update code:

    NRF.updateServices({
      "b0d0cdff-56fa-4bee-b611-874c82f0c313" : {
        "9ed52c1b-73e4-47a9-b335-8e12cfa22fdc" : {
          value : 1,
          notify: true
        }
      }
    });
    

    The state switch and I can set Notify into the BLE App but no notification received.

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

    Hi,

    im totally new with Puck.js and Javascript at all but I'm trying to advertise a own private Characteristic with 2 Services.

    One service to controll the LEDs from the Puck from a external device and the other service for button state from Puck.

    First Service is writable from external device, the second one is just readable but with notifications.

    
    var timeout;
    function flag() {
      if (timeout) clearTimeout();
      LED1.set();
      timeout = setTimeout(function() {
        timeout = undefined;
        LED2.set();
      },2000);
    }
    
    //setWatch(flag, BTN, {repeat:true});
    
    // New code to define services
    NRF.setServices({
      "3e440001-f5bb-357d-719d-179272e4d4d9": {
        "3e440002-f5bb-357d-719d-179272e4d4d9": {
          value : [0],
          maxLen : 1,
          writable : true,
          onWrite : function(evt) {
            // When the characteristic is written, raise flag
            flag();
          }
        }
      }
    }, { uart : false });
    // Change the name that's advertised
    NRF.setAdvertising({}, {name:"BTN"});
    console.log("CONTROL BUTTON");
    

    That code works, if I'm writing into the service the LED1 rises. But i want to check what value is transmitted. But I cant find any documentation about NRF.setServices so I dont know how to read out the value.

    How do I make the second service with button state?

    A bit off topic question: As I saw the Puck only can connect with one device at once, thats ok but later I want that the code is execute during boot, is it still possible to access from Espruino IDE then?

    EDIT: Okay, I found that code:
    digitalWrite([LED3,LED2,LED1], evt.data[0]); which reads the value and works fine. But how to do the second task?

    Also: I need to restart iPhone (use BLE Scanner) after changing the Services. Otherwise it will not displayed. Very irritating. Is there a workaround?

Actions