forked from FOSS/BangleApps
bthrm - Convert old cache to new settings if found
parent
7e0792409c
commit
8363f9aa39
|
@ -16,6 +16,14 @@ exports.enable = () => {
|
||||||
|
|
||||||
log("Settings: ", settings);
|
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){
|
if (settings.enabled && settings.cache){
|
||||||
|
|
||||||
log("Start");
|
log("Start");
|
||||||
|
|
|
@ -129,11 +129,9 @@
|
||||||
"0x2a19", // Battery
|
"0x2a19", // Battery
|
||||||
];
|
];
|
||||||
|
|
||||||
var characteristicsToCache = function(characteristics, deviceId) {
|
var characteristicsToCache = function(characteristics) {
|
||||||
log("Cache characteristics");
|
log("Cache characteristics");
|
||||||
let cache = {
|
let cache = {};
|
||||||
id: deviceId
|
|
||||||
};
|
|
||||||
if (!cache.characteristics) cache.characteristics = {};
|
if (!cache.characteristics) cache.characteristics = {};
|
||||||
for (var c of characteristics){
|
for (var c of characteristics){
|
||||||
//"handle_value":16,"handle_decl":15
|
//"handle_value":16,"handle_decl":15
|
||||||
|
@ -240,7 +238,7 @@
|
||||||
|
|
||||||
return promise.then(()=>{
|
return promise.then(()=>{
|
||||||
log("Connection established, saving cache");
|
log("Connection established, saving cache");
|
||||||
characteristicsToCache(characteristics, deviceId);
|
characteristicsToCache(characteristics);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue