diff --git a/apps/android/boot.js b/apps/android/boot.js index c70fe459e5..02836c9e01 100644 --- a/apps/android/boot.js +++ b/apps/android/boot.js @@ -20,6 +20,8 @@ // feed a copy to other handlers if there were any if (_GB) setTimeout(_GB,0,Object.assign({},event)); + let fetchRecInterval; + /* TODO: Call handling, fitness */ var HANDLERS = { // {t:"notify",id:int, src,title,subject,body,sender,tel:string} add @@ -244,26 +246,29 @@ "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 = "init";// = log.readLine(); + let lines = "init";// = log.readLine(); gbSend({t:"actTrk", log:event.id, line:""}); // Empty line will prompt Gadgetbridge to erase the contents of a already fetched log so we can rewrite it without keeping lines from the previous (probably failed) fetch. - while (line) { - line = log.readLine(); - gbSend({t:"actTrk", log:event.id, line:line}); - } - //// Alternate way to send line, to try and avoid getting malformated JSON lines to Gadgetbridge. - //// My thinking is maybe the Bangle.js bt send que (??) get too full sometimes, this was an attempt to mitigate that. - //// Initial tests rendered new problems. Might come back to this. - //let sendLine = ()=>{ + //while (line) { // line = log.readLine(); // gbSend({t:"actTrk", log:event.id, line:line}); - // if (!line && fetchRecInterval) { - // clearInterval(fetchRecInterval); - // delete fetchRecInterval; - // } //} - //fetchRecInterval = setInterval(sendLine, 100) + + // Alternate way to send lines, to try and avoid getting malformated JSON lines to Gadgetbridge. + // My thinking is maybe the Bangle.js bt send que (??) get too full sometimes, this was an attempt to mitigate that. + // Initial tests rendered new problems. Might come back to this. + let pkgcnt = -1 + let sendlines = ()=>{ + lines = log.readline()+log.readline()+log.readline()+log.readline(); + pkgcnt++; + gbSend({t:"actTrk", log:event.id, cnt:pkgcnt, lines:lines}); + if (!lines && fetchRecInterval) { + clearInterval(fetchRecInterval); + delete fetchRecInterval; + } + } + fetchRecInterval = setInterval(sendlines, 100) },