2024-06-26 17:53:59 +00:00
|
|
|
var btHomeBatterySequence = 0;
|
|
|
|
|
|
|
|
function advertiseBTHomeBattery() {
|
2024-06-26 18:30:14 +00:00
|
|
|
var advert = [0x40, 0x00, btHomeBatterySequence, 0x01, E.getBattery()];
|
2024-06-26 17:53:59 +00:00
|
|
|
|
|
|
|
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;
|
2024-06-26 17:01:18 +00:00
|
|
|
}
|
2024-06-26 17:53:59 +00:00
|
|
|
NRF.setAdvertising(Bangle.bleAdvert);
|
|
|
|
btHomeBatterySequence = (btHomeBatterySequence + 1) & 255;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Bangle.bleAdvert) Bangle.bleAdvert = {};
|
|
|
|
setInterval(function() {
|
|
|
|
advertiseBTHomeBattery();
|
|
|
|
}, 300000); // update every 5 min
|
2024-06-26 17:01:18 +00:00
|
|
|
|
2024-06-26 17:53:59 +00:00
|
|
|
advertiseBTHomeBattery();
|