Skip to content

Commit

Permalink
android: boot.js: put actfetch before listrecs
Browse files Browse the repository at this point in the history
  • Loading branch information
thyttan committed Aug 9, 2023
1 parent 989ded8 commit 8c49e73
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions apps/android/boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,33 +197,6 @@
lastSteps = steps;
}, event.int*1000);
},


"listRecs": function() { // GB({t:"listRecs", id:"20230616a"})
let recs = require("Storage").list(/^recorder\.log.*\.csv$/,{sf:true}).map(s => s.slice(12, 21));
if (event.id.length > 2) { // Handle if there was no id supplied. Then we send a list all available recorder logs back.
recs = recs.slice(recs.indexOf(event.id)); // FIXME: Currently does not handle if the last fetched log was deleted on the watch, so that there won't be any entry corresponding to `event.id`
recs.shift();
}
Bluetooth.println("");
Bluetooth.println(JSON.stringify({t:"trksList", list: recs})); // TODO: split up in multiple transmissions?
},

"fetchRec": function() { // GB({t:"fetchRec", id:"20230616a"})
// TODO: Decide on what names keys should have.
let log = require("Storage").open("recorder.log"+event.id+".csv","r");
let line = log.readLine();
while (line) {
Bluetooth.println("");
Bluetooth.println(JSON.stringify({t:"actTrk", log:event.id, line:line, last:"false"}));
line = log.readLine();
if (!line) {
Bluetooth.println(JSON.stringify({t:"actTrk", log:event.id, line:"end of recorder log", last:event.last}));
}
}
},


// {t:"actfetch", ts:long}
"actfetch": function() {
gbSend({t: "actfetch", state: "start"});
Expand Down Expand Up @@ -251,6 +224,33 @@
}
gbSend({t: "actfetch", state: "end", count: actCount});
},


"listRecs": function() { // GB({t:"listRecs", id:"20230616a"})
let recs = require("Storage").list(/^recorder\.log.*\.csv$/,{sf:true}).map(s => s.slice(12, 21));
if (event.id.length > 2) { // Handle if there was no id supplied. Then we send a list all available recorder logs back.
recs = recs.slice(recs.indexOf(event.id)); // FIXME: Currently does not handle if the last fetched log was deleted on the watch, so that there won't be any entry corresponding to `event.id`
recs.shift();
}
Bluetooth.println("");
Bluetooth.println(JSON.stringify({t:"trksList", list: recs})); // TODO: split up in multiple transmissions?
},

"fetchRec": function() { // GB({t:"fetchRec", id:"20230616a"})
// TODO: Decide on what names keys should have.
let log = require("Storage").open("recorder.log"+event.id+".csv","r");
let line = log.readLine();
while (line) {
Bluetooth.println("");
Bluetooth.println(JSON.stringify({t:"actTrk", log:event.id, line:line, last:"false"}));
line = log.readLine();
if (!line) {
Bluetooth.println(JSON.stringify({t:"actTrk", log:event.id, line:"end of recorder log", last:event.last}));
}
}
},


"nav": function() {
event.id="nav";
if (event.instr) {
Expand Down

0 comments on commit 8c49e73

Please sign in to comment.