Add detection for BangleDumpLocation

master
RKBoss6 2025-07-31 11:23:41 -04:00 committed by GitHub
parent 7675484149
commit 6059f55876
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 35 additions and 1 deletions

View File

@ -191,7 +191,7 @@ E.on('notify',msg=>{
wind: d.wind,
wdir: d.wdir,
loc: d.loc
}
};
// Convert string fields to numbers for iOS weather shortcut
const numFields = ['code', 'wdir', 'temp','feels', 'hi', 'lo', 'hum', 'wind', 'uv', 'rain'];
numFields.forEach(field => {
@ -201,6 +201,40 @@ E.on('notify',msg=>{
NRF.ancsAction(msg.uid, false);
return;
}
if (msg.title === "BangleDumpLocation") {
const d = JSON.parse(msg.message);
/* Example:
{"lat":"2912.0744", "lon":"2333.332", "city":"Chicago"}*/
let locationJson = {
t: "location",
lat:d.lat,
lon:d.lon,
city:d.city
};
// Convert string fields to numbers
const numFields = ['lat', 'lon'];
numFields.forEach(field => {
if (locationJson[field] != null) locationJson[field] = +locationJson[field];
});
//load mylocation file
let myLocationJson = Object.assign({
lat: d.lat,
lon: d.lon,
location:d.city
}, require("Storage").readJSON("mylocation.json", true) || {});
myLocationJson.lon=locationJson.lon;
myLocationJson.lat=locationJson.lat;
myLocationJson.location=locationJson.city;
require("Storage").write("mylocation.json",myLocationJson);
NRF.ancsAction(msg.uid, false);
return;
}
require("messages").pushMessage({
t : msg.event,