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


    1 Attachment

    • microbit-broadcast.png
About

Avatar for don @don started