• I am still a bit confused about the differences between setadvertising interval vs setinterval vs timeout.
    Is my understanding of each of these examples correct?

    A: This will send out a single, one shot blast of BLE advertisement of the battery, lasting only of 375 ms

    NRF.setAdvertising({
      0x180F : E.getBattery()
    },{interval: 375 });
    

    B: This will continuously send out a BLE advertisement of the battery once a minute, forever or until the Interval is cleared

    setInterval(function () {
      NRF.setAdvertising({
        0x180F : E.getBattery()
      }) 
    }, 1 * 60 * 1000);
    

    C. This, with the press of BTN1, this will send out 5 sets of BLE battery advertising once a minute. Each of those five sets of BLE advertising blasts will last 375 ms. In this case I am not sure if I need XX and YY (see code). This is where I get confused.

    setWatch(function() {
      updateBLE();
    }, BTN1, { repeat:true, edge:"rising", debounce: 25 });
    
    function updateBLE(presses) {
      let x = 0;  
      const intervalID = setInterval(() => {  
        if (++x === 5) {  
          global.clearInterval(intervalID);  
        }  
        
        NRF.setAdvertising({
          0x180F : E.getBattery()
       },{interval: 375 });   //XX
    }, 1 * 60 * 1000);        //YY
    }
    

    Thanks

About

Avatar for kab @kab started