Skip to content

Commit

Permalink
Using the ble_advert module
Browse files Browse the repository at this point in the history
  • Loading branch information
deirdreobyrne authored and bobrippling committed Jun 26, 2024
1 parent 29c6e38 commit e48d253
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions apps/bootbthomebatt/boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,10 @@ var btHomeBatterySequence = 0;
function advertiseBTHomeBattery() {
var advert = [0x40, 0x00, btHomeBatterySequence, 0x01, E.getBattery()];

if(Array.isArray(Bangle.bleAdvert)){
var found = false;
for(var ad in Bangle.bleAdvert){
if(ad[0xFCD2]){
ad[0xFCD2] = advert;
found = true;
break;
}
}
if(!found)
Bangle.bleAdvert.push({ 0xFCD2: advert });
} else {
Bangle.bleAdvert[0xFCD2] = advert;
}
NRF.setAdvertising(Bangle.bleAdvert);
require("ble_advert").set(0xFCD2, advert);
btHomeBatterySequence = (btHomeBatterySequence + 1) & 255;
}

if (!Bangle.bleAdvert) Bangle.bleAdvert = {};
setInterval(function() {
advertiseBTHomeBattery();
}, 300000); // update every 5 min
Expand Down

0 comments on commit e48d253

Please sign in to comment.