bthrm - Optionally use bonding for BLE sensor

master
Martin Boonk 2022-11-06 15:52:14 +01:00
parent 0f9a117149
commit 0a1226ad1e
3 changed files with 22 additions and 13 deletions

View File

@ -16,5 +16,6 @@
"gracePeriodNotification": 0,
"gracePeriodConnect": 0,
"gracePeriodService": 0,
"gracePeriodRequest": 0
"gracePeriodRequest": 0,
"bonding": false
}

View File

@ -439,18 +439,20 @@ exports.enable = () => {
return Promise.resolve();
}
});
/* promise = promise.then(() => {
log(JSON.stringify(gatt.getSecurityStatus()));
if (gatt.getSecurityStatus()['bonded']) {
log("Already bonded");
return Promise.resolve();
} else {
log("Start bonding");
return gatt.startBonding()
.then(() => console.log(gatt.getSecurityStatus()));
}
});*/
if (settings.bonding){
promise = promise.then(() => {
log(JSON.stringify(gatt.getSecurityStatus()));
if (gatt.getSecurityStatus()['bonded']) {
log("Already bonded");
return Promise.resolve();
} else {
log("Start bonding");
return gatt.startBonding()
.then(() => console.log(gatt.getSecurityStatus()));
}
});
}
promise = promise.then(()=>{
if (!characteristics || characteristics.length === 0){

View File

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