Merge branch 'master' of github.com:espruino/BangleApps

master
Gordon Williams 2022-11-17 19:25:05 +00:00
commit 65cc432af3
5 changed files with 27 additions and 6 deletions

View File

@ -37,3 +37,6 @@
0.15: Fix recording internal sensor
Handle fallback to internal sensor consistently if BT bpm is 0
Power internal sensor down if not needed for fallback
0.16: Set powerdownRequested correctly on BTHRM power on
Additional logging on errors
Add debug option for disabling active scanning

View File

@ -17,5 +17,6 @@
"gracePeriodConnect": 0,
"gracePeriodService": 0,
"gracePeriodRequest": 0,
"bonding": false
"bonding": false,
"active": true
}

View File

@ -387,8 +387,14 @@ exports.enable = () => {
return;
}
log("Requesting device with filters", filters);
promise = NRF.requestDevice({ filters: filters, active: true });
try {
promise = NRF.requestDevice({ filters: filters, active: settings.active });
} catch (e){
log("Error during initial request:", e);
onDisconnect(e);
return;
}
if (settings.gracePeriodRequest){
log("Add " + settings.gracePeriodRequest + "ms grace period after request");
}
@ -454,7 +460,7 @@ exports.enable = () => {
} else {
log("Start bonding");
return gatt.startBonding()
.then(() => console.log(gatt.getSecurityStatus()));
.then(() => log("Security status" + gatt.getSecurityStatus()));
}
});
}
@ -520,6 +526,7 @@ exports.enable = () => {
isOn = Bangle._PWR.BTHRM.length;
// so now we know if we're really on
if (isOn) {
powerdownRequested = false;
switchFallback();
if (!Bangle.isBTHRMConnected()) initBt();
} else { // not on
@ -638,7 +645,11 @@ exports.enable = () => {
E.on("kill", ()=>{
if (gatt && gatt.connected){
log("Got killed, trying to disconnect");
gatt.disconnect().then(()=>log("Disconnected on kill")).catch((e)=>log("Error during disconnnect on kill", e));
try {
gatt.disconnect().then(()=>log("Disconnected on kill")).catch((e)=>log("Error during disconnnect promise on kill", e));
} catch (e) {
log("Error during disconnnect on kill", e)
}
}
});
}

View File

@ -2,7 +2,7 @@
"id": "bthrm",
"name": "Bluetooth Heart Rate Monitor",
"shortName": "BT HRM",
"version": "0.15",
"version": "0.16",
"description": "Overrides Bangle.js's build in heart rate monitor with an external Bluetooth one.",
"icon": "app.png",
"type": "app",

View File

@ -102,6 +102,12 @@
writeSettings("bonding",v);
}
},
'Use active scanning': {
value: !!settings.active,
onchange: v => {
writeSettings("active",v);
}
},
'Grace periods': function() { E.showMenu(submenu_grace); }
};