Avatar for don

don

Member since Feb 2018 • Last active Feb 2018
  • 2 conversations
  • 4 comments

Most recent activity

    • 3 comments
    • 75 views
  • in Puck.js
    Avatar for don

    @Gordon I like your nRF API. It's really easy to set the Service Data. This works great.

    // Demonstrate broadcasting a characteristic value
    // Use nRF Connect to see the counter value without connecting
    
    let count = 0;
    
    NRF.setServices({
        0xEEE0 : {
          0xEEE1 : {
            value: [0, 0],
            readable: true,
            notify: true,
            broadcast: true,
            description: 'Count'
          }
        }
      }, { advertise: [ 'EEE0' ] });
    
    function notify() {
      const buffer = new Uint16Array([count]).buffer;
      NRF.updateServices({
        0xEEE0 : {
          0xEEE1 : {
            value: buffer,
            broadcast: true,
            notify: true
          }
        }
      });
      // Set the service data 0x16 to the count value
      NRF.setAdvertising({
        0xEEE0: buffer
      });
    }
    
    setInterval(() => {
      count++;
      if (count > 0xFFFF) {
        count = 0;
      }
      notify();
    }, 1000);
    
  • in Other Boards
    Avatar for don

    The polarity swap in 1v95.176 is a welcome change. Setting the pinMode worked well in 1v95.

    @Gordon thanks for fixing this so quickly

  • in Puck.js
    Avatar for don

    I'd like to broadcast a characteristic value so it can be read from the advertising information without connecting.

    Here's an Arduino example increments a counter and broadcasts the value - BroadcastCount.ino. Using nRF Connect, I can see the characteristic value. (See attached image.)

    According to the docs, it looks NRF.setServices broadcast property might do this, but I can't get it to work on the Puck.js.

    // Demonstrate broadcasting a characteristic value
    // Use nRF Connect to see the counter value without connecting
    
    let count = 0;
    
    NRF.setServices({
        0xEEE0 : {
          0xEEE1 : {
            value: count,
            readable: true,
            notify: true,
            broadcast: true,
            description: 'Count'
          }
        }
      }, { advertise: [ 'EEE0' ] });
    
    function notify() {
      NRF.updateServices({
        0xEEE0 : {
          0xEEE1 : {
            value: count,
            broadcast: true,
            notify: true
          }
        }
      });
    }
    
    setInterval(function() {
      count++;
      notify();
    }, 1000);
    

    Should broadcast update the service info or do I need to manually build this into the advertising data?

  • in Other Boards
    Avatar for don

    With v1.95 on the BBC micro:bit the button watch only fires 1 time.

    setWatch(function(e) {
      if (e.state) console.log("Released");
      else console.log("Pressed");
    }, BTN1, {repeat:true, debounce:20, edge:"both"});
    

    Reverting back to v1.94 this works as expected on the micro:bit.

    This code work OK on Puck.js with v1.95

Actions