Setting to turn Bluetooth on and off
parent
4d3bcd94a3
commit
75f8f7b86a
|
|
@ -1,8 +1,9 @@
|
||||||
{
|
{
|
||||||
|
ble: false, // Bluetooth disabled by default
|
||||||
timeout: 10, // Default LCD timeout in seconds
|
timeout: 10, // Default LCD timeout in seconds
|
||||||
vibrate: true, // Vibration enabled by default. App must support
|
vibrate: true, // Vibration enabled by default. App must support
|
||||||
beep: true, // Beep enabled by default. App must support
|
beep: true, // Beep enabled by default. App must support
|
||||||
timezone: 0, // Set the timezone for the device
|
timezone: 0, // Set the timezone for the device
|
||||||
HID : false, // BLE HID mode, off by default
|
HID: false, // BLE HID mode, off by default
|
||||||
debug: false, // Debug mode disabled by default. App must support
|
debug: false, // Debug mode disabled by default. App must support
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
(function() {
|
(function() {
|
||||||
var s = require('Storage').readJSON('@setting');
|
var s = require('Storage').readJSON('@setting');
|
||||||
|
if (s.ble) {
|
||||||
var adv = { uart: true };
|
var adv = { uart: true };
|
||||||
if (s.HID) {
|
if (s.HID) {
|
||||||
// Report from https://notes.iopush.net/custom-usb-hid-device-descriptor-media-keyboard/
|
// Report from https://notes.iopush.net/custom-usb-hid-device-descriptor-media-keyboard/
|
||||||
|
|
@ -75,6 +76,12 @@
|
||||||
adv.hid = Bangle.HID;
|
adv.hid = Bangle.HID;
|
||||||
}
|
}
|
||||||
NRF.setServices(undefined, adv);
|
NRF.setServices(undefined, adv);
|
||||||
|
try {
|
||||||
|
NRF.wake();
|
||||||
|
} catch (e) {}
|
||||||
|
} else {
|
||||||
|
NRF.sleep();
|
||||||
|
}
|
||||||
|
|
||||||
if (!s.vibrate) Bangle.buzz=()=>Promise.resolve();
|
if (!s.vibrate) Bangle.buzz=()=>Promise.resolve();
|
||||||
if (!s.beep) Bangle.beep=()=>Promise.resolve();
|
if (!s.beep) Bangle.beep=()=>Promise.resolve();
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ function updateSettings() {
|
||||||
|
|
||||||
function resetSettings() {
|
function resetSettings() {
|
||||||
settings = {
|
settings = {
|
||||||
|
ble: false,
|
||||||
timeout: 10,
|
timeout: 10,
|
||||||
vibrate: true,
|
vibrate: true,
|
||||||
beep: true,
|
beep: true,
|
||||||
|
|
@ -39,6 +40,14 @@ const boolFormat = (v) => v ? "On" : "Off";
|
||||||
function showMainMenu() {
|
function showMainMenu() {
|
||||||
const mainmenu = {
|
const mainmenu = {
|
||||||
'': { 'title': 'Settings' },
|
'': { 'title': 'Settings' },
|
||||||
|
'BLE': {
|
||||||
|
value: settings.ble,
|
||||||
|
format: boolFormat,
|
||||||
|
onchange: () => {
|
||||||
|
settings.ble = !settings.ble;
|
||||||
|
updateSettings();
|
||||||
|
}
|
||||||
|
},
|
||||||
'LCD Timeout': {
|
'LCD Timeout': {
|
||||||
value: settings.timeout,
|
value: settings.timeout,
|
||||||
min: 0,
|
min: 0,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue