From 8c49e73be7b73f99f21f467f2e04900172c817eb Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.comā©> Date: Thu, 10 Aug 2023 00:10:43 +0200 Subject: [PATCH] android: boot.js: put actfetch before listrecs --- apps/android/boot.js | 54 ++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/apps/android/boot.js b/apps/android/boot.js index 64a8664969..a2dca8376d 100644 --- a/apps/android/boot.js +++ b/apps/android/boot.js @@ -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"}); @@ -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) {