• Hi,

    I'd look at this: https://github.com/Microsoft/Windows-uni­versal-samples/tree/master/Samples/Bluet­oothAdvertisement

    Specifically the Advertisement 'watcher'.

    The question then is how you advertise your information for the 'watcher' to see. To start, on your Puck you can run:

    setInterval(function() {
      NRF.setAdvertising({
        0x1809 : [Math.round(E.getTemperature())]
      });
    }, 30000);
    

    Once you disconnect from it, the Puck will start advertising the temperature - which you should be able to read with your app.

    You're quite limited by the amount of data you can send in advertising packets, so I'd consider packing it all together. For example if you upload this:

    var alarm = 0;
    
    
    function updateAdvertising() {
      NRF.setAdvertising({
        0xFFFF : [Math.round(E.getTemperature()), // first byte is temp
                  alarm] // second byte is whether an alarm or not
      });
    }
    
    setWatch(function(e) {
      var t = e.time - e.lastTime;
      if (t>5) {
        // >5 seconds - turn LED off
        LED1.reset();
        digitalPulse(LED2,1,500); // blink green LED to say all ok
        alarm = 0;
      } else {
        // flash red LED
        analogWrite(LED1, 0.01, { freq:0.5, forceSoft:true });
        alarm = 1; 
      }
      updateAdvertising();
    }, BTN, { debounce: 50, edge:"falling", repeat:true});
    
    
    setInterval(function() {
      // update temperature every 30 seconds
      updateAdvertising();
    }, 30000);
    

    Then it'll advertise 2 bytes - the temperature and the 'alarm' - with Bluetooth UUID 0xFFFF.

    When you press the button the alarm will turn to 1 and the red LED will start blinking, or if you hold it for >5 seconds and release the alarm will turn off.

About

Avatar for Gordon @Gordon started