diff --git a/apps/bthrm/lib.js b/apps/bthrm/lib.js index 7f60d2624..d4cb7412c 100644 --- a/apps/bthrm/lib.js +++ b/apps/bthrm/lib.js @@ -16,6 +16,14 @@ exports.enable = () => { log("Settings: ", settings); + //this is for compatibility with 0.18 and older + let oldCache = require('Storage').readJSON("bthrm.cache.json", true); + if(oldCache){ + settings.cache = oldCache; + require('Storage').writeJSON("bthrm.json", settings); + require('Storage').erase("bthrm.cache.json"); + } + if (settings.enabled && settings.cache){ log("Start"); diff --git a/apps/bthrm/settings.js b/apps/bthrm/settings.js index 5609fe215..4f52683ff 100644 --- a/apps/bthrm/settings.js +++ b/apps/bthrm/settings.js @@ -129,11 +129,9 @@ "0x2a19", // Battery ]; - var characteristicsToCache = function(characteristics, deviceId) { + var characteristicsToCache = function(characteristics) { log("Cache characteristics"); - let cache = { - id: deviceId - }; + let cache = {}; if (!cache.characteristics) cache.characteristics = {}; for (var c of characteristics){ //"handle_value":16,"handle_decl":15 @@ -240,7 +238,7 @@ return promise.then(()=>{ log("Connection established, saving cache"); - characteristicsToCache(characteristics, deviceId); + characteristicsToCache(characteristics); }); }