bootgattbat: handle bleAdvert array
parent
614c003eca
commit
b86d2bd841
|
|
@ -1 +1,2 @@
|
||||||
0.01: Initial release.
|
0.01: Initial release.
|
||||||
|
0.02: Handle the case where other apps have set bleAdvert to an array
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,22 @@
|
||||||
(() => {
|
(() => {
|
||||||
function advertiseBattery() {
|
function advertiseBattery() {
|
||||||
|
if(Array.isArray(Bangle.bleAdvert)){
|
||||||
|
// ensure we're in the cycle
|
||||||
|
var found = false;
|
||||||
|
for(var ad in Bangle.bleAdvert){
|
||||||
|
if(ad[0x180F]){
|
||||||
|
ad[0x180F] = [E.getBattery()];
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!found)
|
||||||
|
Bangle.bleAdvert.push({ 0x180F: [E.getBattery()] });
|
||||||
|
}else{
|
||||||
|
// simple object
|
||||||
Bangle.bleAdvert[0x180F] = [E.getBattery()];
|
Bangle.bleAdvert[0x180F] = [E.getBattery()];
|
||||||
|
}
|
||||||
|
|
||||||
NRF.setAdvertising(Bangle.bleAdvert);
|
NRF.setAdvertising(Bangle.bleAdvert);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
"id": "bootgattbat",
|
"id": "bootgattbat",
|
||||||
"name": "BLE GATT Battery Service",
|
"name": "BLE GATT Battery Service",
|
||||||
"shortName": "BLE Battery Service",
|
"shortName": "BLE Battery Service",
|
||||||
"version": "0.01",
|
"version": "0.02",
|
||||||
"description": "Adds the GATT Battery Service to advertise the percentage of battery currently remaining over Bluetooth.\n",
|
"description": "Adds the GATT Battery Service to advertise the percentage of battery currently remaining over Bluetooth.\n",
|
||||||
"icon": "bluetooth.png",
|
"icon": "bluetooth.png",
|
||||||
"type": "bootloader",
|
"type": "bootloader",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue