You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • but get a "Uncaught Storage Updated" when I try to save it to a file in storage on the watch.

    That's fine I think. All it means is you changed the boot code (I guess you wrote it to xyz.boot.js?) and so Bangle.js had to rewrite the .boot0 file with your new code. If you do load() on the left-hand side or just long-press the button, the bangle should load up and everything will work ok.

    For the bleAdvert form, it's best to use https://github.com/espruino/BangleApps/t­ree/master/apps/bootgattbat as an example.

    **BUT ** the issue is that iBeacon can't be used in the same advertising packet as other data. It has to have a packet all to itself.

    All I can suggest is:

    (() => {
      function advertiseBeacon() {
        NRF.setAdvertising([
          Bangle.bleAdvert,
          require("ble_ibeacon").get({
            uuid : [0xb1, 0xae, 0x51, 0x2b, 0x97, 0x03, 0x4a, 0xe2, 0xb9, 0xc3, 0x9e, 0x26, 0x0c, 0xa7, 0xb3, 0x99],
            rssi : -60
          })
        ]);
      }
      if (!Bangle.bleAdvert) Bangle.bleAdvert = {};
      setInterval(advertiseBeacon, 60 * 1000);
      advertiseBeacon();
    })();
    

    Which will 'rotate' the advertisements - so you get one Bangle.js advert and one iBeacon one. However the next time another app like bootgattbat updates, it'll effectively disable iBeacon until your app updates it again.

    I don't see there's an easy way around that, apart from maybe overwriting setAdvertising:

    var myiBeacon = require("ble_ibeacon").get({
            uuid : [0xb1, 0xae, 0x51, 0x2b, 0x97, 0x03, 0x4a, 0xe2, 0xb9, 0xc3, 0x9e, 0x26, 0x0c, 0xa7, 0xb3, 0x99],
            rssi : -60
          });
    var _setAdvertising = NRF.setAdvertising;
    NRF.setAdvertising = function(a,b) {
      if (Array.isArray(typeof a)) a = [a,myiBeacon];
      _setAdvertising(a,b);
    };
    
      function advertiseBeacon() {
        NRF.setAdvertising(Bangle.bleAdvert);
      }
      if (!Bangle.bleAdvert) Bangle.bleAdvert = {};
      setInterval(advertiseBeacon, 60 * 1000);
      advertiseBeacon();
    
    
    
About

Avatar for Gordon @Gordon started