mirror of https://github.com/espruino/BangleApps
settings app: preserve whitelist when disabled
parent
769c4c2793
commit
774372dfa9
|
@ -79,7 +79,7 @@ if (global.save) boot += `global.save = function() { throw new Error("You can't
|
|||
if (s.options) boot+=`Bangle.setOptions(${E.toJS(s.options)});\n`;
|
||||
if (s.brightness && s.brightness!=1) boot+=`Bangle.setLCDBrightness(${s.brightness});\n`;
|
||||
if (s.passkey!==undefined && s.passkey.length==6) boot+=`NRF.setSecurity({passkey:${E.toJS(s.passkey.toString())}, mitm:1, display:1});\n`;
|
||||
if (s.whitelist) boot+=`NRF.on('connect', function(addr) { if (!(require('Storage').readJSON('setting.json',1)||{}).whitelist.includes(addr)) NRF.disconnect(); });\n`;
|
||||
if (s.whitelist && !s.whitelist.disabled) boot+=`NRF.on('connect', function(addr) { if (!(require('Storage').readJSON('setting.json',1)||{}).whitelist.macs.includes(addr)) NRF.disconnect(); });\n`;
|
||||
if (s.rotate) boot+=`g.setRotation(${s.rotate&3},${s.rotate>>2});\n` // screen rotation
|
||||
// ================================================== FIXING OLDER FIRMWARES
|
||||
if (FWVERSION<215.068) // 2v15.68 and before had compass heading inverted.
|
||||
|
|
|
@ -64,3 +64,4 @@
|
|||
of 'Select Clock'
|
||||
0.57: Settings.log = 0,1,2,3 for off,display,log,both
|
||||
0.58: On/Off settings items now use checkboxes
|
||||
0.59: Preserve BLE whitelist even when disabled
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "setting",
|
||||
"name": "Settings",
|
||||
"version": "0.58",
|
||||
"version": "0.59",
|
||||
"description": "A menu for setting up Bangle.js",
|
||||
"icon": "settings.png",
|
||||
"tags": "tool,system",
|
||||
|
|
|
@ -43,6 +43,10 @@ function resetSettings() {
|
|||
"12hour" : false, // 12 or 24 hour clock?
|
||||
firstDayOfWeek: 0, // 0 -> Sunday (default), 1 -> Monday
|
||||
brightness: 1, // LCD brightness from 0 to 1
|
||||
whitelist: { // Bluetooth whitelist
|
||||
macs: [],
|
||||
disabled: true,
|
||||
},
|
||||
// welcomed : undefined/true (whether welcome app should show)
|
||||
options: {
|
||||
wakeOnBTN1: true,
|
||||
|
@ -191,7 +195,14 @@ function showBLEMenu() {
|
|||
onchange: () => setTimeout(showPasskeyMenu) // graphical_menu redraws after the call
|
||||
},
|
||||
/*LANG*/'Whitelist': {
|
||||
value: settings.whitelist?(settings.whitelist.length+/*LANG*/" devs"):/*LANG*/"off",
|
||||
value:
|
||||
(
|
||||
settings.whitelist.disabled ? /*LANG*/"off" : /*LANG*/"on"
|
||||
) + (
|
||||
settings.whitelist.macs
|
||||
? " (" + settings.whitelist.macs.length + ")"
|
||||
: ""
|
||||
),
|
||||
onchange: () => setTimeout(showWhitelistMenu) // graphical_menu redraws after the call
|
||||
}
|
||||
});
|
||||
|
@ -341,17 +352,26 @@ function showPasskeyMenu() {
|
|||
function showWhitelistMenu() {
|
||||
var menu = {
|
||||
"< Back" : ()=>showBLEMenu(),
|
||||
/*LANG*/"Disable" : () => {
|
||||
settings.whitelist = undefined;
|
||||
};
|
||||
if (settings.whitelist.disabled) {
|
||||
menu[/*LANG*/"Enable"] = () => {
|
||||
delete settings.whitelist.disabled;
|
||||
updateSettings();
|
||||
showBLEMenu();
|
||||
}
|
||||
};
|
||||
if (settings.whitelist) settings.whitelist.forEach(function(d){
|
||||
} else {
|
||||
menu[/*LANG*/"Disable"] = () => {
|
||||
settings.whitelist.disabled = true;
|
||||
updateSettings();
|
||||
showBLEMenu();
|
||||
};
|
||||
}
|
||||
|
||||
if (settings.whitelist.macs) settings.whitelist.macs.forEach(function(d){
|
||||
menu[d.substr(0,17)] = function() {
|
||||
E.showPrompt(/*LANG*/'Remove\n'+d).then((v) => {
|
||||
if (v) {
|
||||
settings.whitelist.splice(settings.whitelist.indexOf(d),1);
|
||||
settings.whitelist.macs.splice(settings.whitelist.macs.indexOf(d),1);
|
||||
updateSettings();
|
||||
}
|
||||
setTimeout(showWhitelistMenu, 50);
|
||||
|
@ -365,8 +385,7 @@ function showWhitelistMenu() {
|
|||
});
|
||||
NRF.removeAllListeners('connect');
|
||||
NRF.on('connect', function(addr) {
|
||||
if (!settings.whitelist) settings.whitelist=[];
|
||||
settings.whitelist.push(addr);
|
||||
settings.whitelist.macs.push(addr);
|
||||
updateSettings();
|
||||
NRF.removeAllListeners('connect');
|
||||
showWhitelistMenu();
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"ble":true,"blerepl":true,"log":false,"timeout":10,"vibrate":true,"beep":"vib","timezone":0,"HID":false,"clock":null,"12hour":false,"brightness":1,"options":{"wakeOnBTN1":true,"wakeOnBTN2":true,"wakeOnBTN3":true,"wakeOnFaceUp":false,"wakeOnTouch":false,"wakeOnTwist":true,"twistThreshold":819.2,"twistMaxY":-800,"twistTimeout":1000}}
|
||||
{"ble":true,"blerepl":true,"log":false,"timeout":10,"vibrate":true,"beep":"vib","timezone":0,"HID":false,"clock":null,"12hour":false,"brightness":1,"options":{"wakeOnBTN1":true,"wakeOnBTN2":true,"wakeOnBTN3":true,"wakeOnFaceUp":false,"wakeOnTouch":false,"wakeOnTwist":true,"twistThreshold":819.2,"twistMaxY":-800,"twistTimeout":1000},"whitelist":{"disabled":true}}
|
||||
|
|
Loading…
Reference in New Issue