diff --git a/apps.json b/apps.json index ed230f86b..0c8c86191 100644 --- a/apps.json +++ b/apps.json @@ -152,7 +152,7 @@ { "id": "setting", "name": "Settings", "icon": "settings.png", - "version":"0.20", + "version":"0.21", "description": "A menu for setting up Bangle.js", "tags": "tool,system", "readme": "README.md", diff --git a/apps/setting/ChangeLog b/apps/setting/ChangeLog index dfa8b79f7..6a5b1dd76 100644 --- a/apps/setting/ChangeLog +++ b/apps/setting/ChangeLog @@ -22,3 +22,5 @@ 0.18: Don't overwrite existing settings on app update 0.19: Allow BLE HID settings, add README.md 0.20: Fix set time menu, allow dates to roll over +0.21: Add passkey pairing option (BETA) + Add whitelist option (fix #78) diff --git a/apps/setting/README.md b/apps/setting/README.md index 4052da0ff..32f84a6aa 100644 --- a/apps/setting/README.md +++ b/apps/setting/README.md @@ -4,8 +4,7 @@ This is Bangle.js's settings menu * **Make Connectable** regardless of the current Bluetooth settings, makes Bangle.js so you can connect to it (while the window is up) * **App/Widget Settings** settings specific to installed applications -* **BLE** is Bluetooth LE enabled and the watch connectable? -* **Programmable** if BLE is on, can the watch be connected to in order to program/upload apps? +* **BLE** Bluetooth Settings menu - see below. * **Debug Info** should debug info be shown on the watch's screen or not? * **Beep** most Bangle.js do not have a speaker inside, but they can use the vibration motor to beep in different pitches. You can change the behaviour here to use a Piezo speaker if one is connected * **Vibration** enable/disable the vibration motor @@ -13,6 +12,20 @@ This is Bangle.js's settings menu * **Select Clock** if you have more than one clock face, select the default one * **HID** When Bluetooth is enabled, Bangle.js can appear as a Bluetooth Keyboard/Joystick/etc to send keypresses to a connected device. **Note:** on some platforms enabling HID can cause you problems when trying to connect to Bangle.js to upload apps. * **Set Time** Configure the current time - Note that this can be done much more easily by choosing 'Set Time' from the App Loader -* **LCD** Configure settings about the screen. How long it stays on, how bright it is, and when it turns on. +* **LCD** Configure settings about the screen. How long it stays on, how bright it is, and when it turns on - see below. * **Reset Settings** Reset the settings to defaults * **Turn Off** Turn Bangle.js off + +## BLE - Bluetooth Settings + +* **BLE** is Bluetooth LE enabled and the watch connectable? +* **Programmable** if BLE is on, can the watch be connected to in order to program/upload apps? As long as your watch firmware is up to date, Gadgetbridge will work even with `Programmable` set to `Off`. +* **Passkey BETA** allows you to set a passkey that is required to connect and pair to Bangle.js. **Note:** This is Beta and you will almost certainly encounter issues connecting with Web Bluetooth using this option. +* **Whitelist** allows you to specify only specific devices that you will let connect to your Bangle.js. Simply choose the menu item, then `Add Device`, and then connect to Bangle.js with the device you want to add. If you are already connected you will have to disconnect first. Changes will take effect when you exit the `Settings` app. + +## LCD + +* **LCD Brightness** set how bright the LCD is. Due to hardware limitations in the LCD backlight, you may notice flicker if the LCD is not at 100% brightness. +* **LCD Timeout** how long should the LCD stay on for if no activity is detected. 0=stay on forever +* **Wake on X** should the given activity wake up the Bangle.js LCD? +* **Twist X** these options adjust the sensitivity of `Wake on Twist` to ensure Bangle.js wakes up with just the right amount of wrist movement. diff --git a/apps/setting/boot.js b/apps/setting/boot.js index aee4f6de4..5b556a25f 100644 --- a/apps/setting/boot.js +++ b/apps/setting/boot.js @@ -4,4 +4,6 @@ if (settings.options) Bangle.setOptions(settings.options); if (settings.brightness && settings.brightness!=1) Bangle.setLCDBrightness(settings.brightness); if (settings.passkey!==undefined && settings.passkey.length==6) NRF.setSecurity({passkey:settings.passkey, mitm:1, display:1}); + if (settings.whitelist) NRF.on('connect', function(addr) { if (!settings.whitelist.includes(addr)) NRF.disconnect(); }); + delete settings; })() diff --git a/apps/setting/settings.js b/apps/setting/settings.js index c993ee470..8fa919535 100644 --- a/apps/setting/settings.js +++ b/apps/setting/settings.js @@ -137,10 +137,14 @@ function showBLEMenu() { updateSettings(); } }, - 'Passkey': { + 'Passkey BETA': { value: settings.passkey?settings.passkey:"none", onchange: () => setTimeout(showPasskeyMenu) // graphical_menu redraws after the call }, + 'Whitelist': { + value: settings.whitelist?(settings.whitelist.length+" devs"):"off", + onchange: () => setTimeout(showWhitelistMenu) // graphical_menu redraws after the call + }, '< Back': ()=>showMainMenu() }); } @@ -171,6 +175,43 @@ function showPasskeyMenu() { E.showMenu(menu); } +function showWhitelistMenu() { + var menu = { + "Disable" : () => { + settings.whitelist = undefined; + updateSettings(); + showBLEMenu(); + } + }; + if (settings.whitelist) settings.whitelist.forEach(function(d){ + menu[d.substr(0,17)] = function() { + E.showPrompt('Remove\n'+d).then((v) => { + if (v) { + settings.whitelist.splice(settings.whitelist.indexOf(d),1); + updateSettings(); + } + setTimeout(showWhitelistMenu, 50); + }); + } + }); + menu['Add Device']=function() { + E.showAlert("Connect device\nto add to\nwhitelist","Whitelist").then(function() { + NRF.removeAllListeners('connect'); + showWhitelistMenu(); + }); + NRF.removeAllListeners('connect'); + NRF.on('connect', function(addr) { + if (!settings.whitelist) settings.whitelist=[]; + settings.whitelist.push(addr); + updateSettings(); + NRF.removeAllListeners('connect'); + showWhitelistMenu(); + }); + }; + menu['< Back']=()=>showBLEMenu(); + E.showMenu(menu); +} + function showLCDMenu() { const lcdMenu = { '': { 'title': 'LCD' },