mirror of https://github.com/espruino/BangleApps
bthrm - Convert old cache to new settings if found
parent
7e0792409c
commit
8363f9aa39
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue