From d07dc1de6fe9948edd0418c69352200f28d07f6a Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Thu, 12 Mar 2020 16:46:39 +0000 Subject: [PATCH] Stop users calling save() (fix #125) If Debug info is set to 'show' don't move to Terminal if connected! --- apps.json | 2 +- apps/boot/ChangeLog | 2 ++ apps/boot/boot0.js | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/apps.json b/apps.json index f2d655f9f..350dc7a72 100644 --- a/apps.json +++ b/apps.json @@ -2,7 +2,7 @@ { "id": "boot", "name": "Bootloader", "icon": "bootloader.png", - "version":"0.09", + "version":"0.10", "description": "This is needed by Bangle.js to automatically load the clock, menu, widgets and settings", "tags": "tool,system", "type":"bootloader", diff --git a/apps/boot/ChangeLog b/apps/boot/ChangeLog index 8cd322022..093f017b2 100644 --- a/apps/boot/ChangeLog +++ b/apps/boot/ChangeLog @@ -6,3 +6,5 @@ 0.07: Fix issues with alarm scheduling 0.08: Fix issues if BLE=off, 'Make Connectable' is chosen, and the loader resets Bangle.js (fix #108) 0.09: Only check GPS for time after a fresh boot +0.10: Stop users calling save() (fix #125) + If Debug info is set to 'show' don't move to Terminal if connected! diff --git a/apps/boot/boot0.js b/apps/boot/boot0.js index db2533400..cb8d49ba0 100644 --- a/apps/boot/boot0.js +++ b/apps/boot/boot0.js @@ -12,7 +12,7 @@ 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 } else { - if (s.log) Terminal.setConsole(); // if showing debug, put REPL on terminal (until connection) + 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 } // we just reset, so BLE should be on. @@ -25,6 +25,8 @@ Bangle.setLCDTimeout(s.timeout); if (!s.timeout) Bangle.setLCDPower(1); E.setTimeZone(s.timezone); delete s; +// stop users doing bad things! +global.save = function() { throw new Error("You can't use save() on Bangle.js without overwriting the bootloader!"); } // check for alarms var alarms = require('Storage').readJSON('alarm.json',1)||[]; var time = new Date();