Skip to content

Commit 6059f55

Browse files
authored
Add detection for BangleDumpLocation
1 parent 7675484 commit 6059f55

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

apps/ios/boot.js

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ E.on('notify',msg=>{
191191
wind: d.wind,
192192
wdir: d.wdir,
193193
loc: d.loc
194-
}
194+
};
195195
// Convert string fields to numbers for iOS weather shortcut
196196
const numFields = ['code', 'wdir', 'temp','feels', 'hi', 'lo', 'hum', 'wind', 'uv', 'rain'];
197197
numFields.forEach(field => {
@@ -201,6 +201,40 @@ E.on('notify',msg=>{
201201
NRF.ancsAction(msg.uid, false);
202202
return;
203203
}
204+
205+
if (msg.title === "BangleDumpLocation") {
206+
207+
const d = JSON.parse(msg.message);
208+
209+
/* Example:
210+
{"lat":"2912.0744", "lon":"2333.332", "city":"Chicago"}*/
211+
let locationJson = {
212+
t: "location",
213+
lat:d.lat,
214+
lon:d.lon,
215+
city:d.city
216+
217+
};
218+
// Convert string fields to numbers
219+
const numFields = ['lat', 'lon'];
220+
numFields.forEach(field => {
221+
if (locationJson[field] != null) locationJson[field] = +locationJson[field];
222+
});
223+
224+
//load mylocation file
225+
let myLocationJson = Object.assign({
226+
lat: d.lat,
227+
lon: d.lon,
228+
location:d.city
229+
}, require("Storage").readJSON("mylocation.json", true) || {});
230+
myLocationJson.lon=locationJson.lon;
231+
myLocationJson.lat=locationJson.lat;
232+
myLocationJson.location=locationJson.city;
233+
require("Storage").write("mylocation.json",myLocationJson);
234+
235+
NRF.ancsAction(msg.uid, false);
236+
return;
237+
}
204238

205239
require("messages").pushMessage({
206240
t : msg.event,

0 commit comments

Comments
 (0)