Allow Gadgetbridge to work even with programmable:off

pull/543/head
Gordon Williams 2020-07-30 09:04:06 +01:00
parent 35cce62dd4
commit aa48f5038f
3 changed files with 14 additions and 1 deletions

View File

@ -2,7 +2,7 @@
{ "id": "boot",
"name": "Bootloader",
"icon": "bootloader.png",
"version":"0.19",
"version":"0.20",
"description": "This is needed by Bangle.js to automatically load the clock, menu, widgets and settings",
"tags": "tool,system",
"type":"bootloader",

View File

@ -18,3 +18,4 @@
0.17: Don't modify beep/buzz behaviour if firmware does it automatically
0.18: Fix 'GPS time' checks for western hemisphere
0.19: Tweaks to simplify code and lower memory usage
0.20: Allow Gadgetbridge to work even with programmable:off

View File

@ -13,6 +13,18 @@ if (s.ble!==false) {
if (s.blerepl===false) { // If not programmable, force terminal off Bluetooth
if (s.log) Terminal.setConsole(true); // if showing debug, force REPL onto terminal
else E.setConsole(null,{force:true}); // on new (2v05+) firmware we have E.setConsole which allows a 'null' console
/* If not programmable add our own handler for Bluetooth data
to allow Gadgetbridge commands to be received*/
Bluetooth.line="";
Bluetooth.on('data',function(d) {
var l = (Bluetooth.line + d).split("\n");
Bluetooth.line = l.pop();
l.forEach(n=>Bluetooth.emit("line",n));
});
Bluetooth.on('line',function(l) {
if (l.startsWith('GB({') && l.endsWith('})') && global.GB)
try { global.GB(JSON.parse(l.slice(3,-1))); } catch(e) {}
});
} else {
if (s.log && !NRF.getSecurityStatus().connected) Terminal.setConsole(); // if showing debug, put REPL on terminal (until connection)
else Bluetooth.setConsole(true); // else if no debug, force REPL to Bluetooth