mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-26 10:35:50 +01:00
Revert "Bangle.js:actTrk:fetch all logs, then parse them"
This reverts commit 6b941f9277f70d642cfaa430d3d917ba6b559d17.
This commit is contained in:
parent
6936053734
commit
7734fbe4b0
@ -58,15 +58,6 @@ class BangleJSActivityTrack extends BangleJSDeviceSupport {
|
|||||||
GB.toast(context.getString(R.string.activity_detail_end_label) + " : " + context.getString(R.string.busy_task_fetch_sports_details), Toast.LENGTH_SHORT, GB.INFO);
|
GB.toast(context.getString(R.string.activity_detail_end_label) + " : " + context.getString(R.string.busy_task_fetch_sports_details), Toast.LENGTH_SHORT, GB.INFO);
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSONArray makeDeepCopyOfJSONArray(JSONArray tracksList) throws JSONException {
|
|
||||||
JSONArray tracksListIntact = new JSONArray();
|
|
||||||
String[] tmpTracksList = tracksList.join(",").replace("\"","").split(","); // Hacky way to get a sort of deep copy.
|
|
||||||
for (int i = 0; i<tmpTracksList.length; i++) {
|
|
||||||
tracksListIntact.put(tmpTracksList[i]);
|
|
||||||
}
|
|
||||||
return tracksListIntact;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Timer timeout;
|
private static Timer timeout;
|
||||||
private static TimerTask timeoutTask;
|
private static TimerTask timeoutTask;
|
||||||
|
|
||||||
@ -195,7 +186,7 @@ class BangleJSActivityTrack extends BangleJSDeviceSupport {
|
|||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSONArray handleActTrk(JSONObject json, JSONArray tracksList, JSONArray tracksListIntact, int prevPacketCount, GBDevice device, Context context) throws JSONException {
|
static JSONArray handleActTrk(JSONObject json, JSONArray tracksList, int prevPacketCount, GBDevice device, Context context) throws JSONException {
|
||||||
stopAndRestartTimeout(device, context);
|
stopAndRestartTimeout(device, context);
|
||||||
|
|
||||||
JSONArray returnArray;
|
JSONArray returnArray;
|
||||||
@ -230,14 +221,8 @@ class BangleJSActivityTrack extends BangleJSDeviceSupport {
|
|||||||
|
|
||||||
if (!json.has("lines")) { // if no lines were sent with this json object, it signifies that the whole recorder log has been transmitted.
|
if (!json.has("lines")) { // if no lines were sent with this json object, it signifies that the whole recorder log has been transmitted.
|
||||||
setLatestFetchedRecorderLog(dir, log);
|
setLatestFetchedRecorderLog(dir, log);
|
||||||
if (tracksList.length()==0) { // All data from all Recorder logs have been fetched.
|
parseFetchedRecorderCSV(dir, filename, log, device, context); // TODO: Parsing could be done after we fetched all recorder logs instead, making the fetching quicker and maybe less prone to user errors.
|
||||||
LOG.warn("tracksListIntact:\n" + tracksListIntact);
|
if (tracksList.length()==0) {
|
||||||
for (int i = 0; i<tracksListIntact.length(); i++){
|
|
||||||
String currLog = tracksListIntact.getString(i);
|
|
||||||
LOG.info("currLog: " + currLog);
|
|
||||||
String currFilename = "recorder.log" + currLog + ".csv";
|
|
||||||
parseFetchedRecorderCSV(dir, currFilename, currLog, device, context);
|
|
||||||
}
|
|
||||||
signalFetchingEnded(device, context);
|
signalFetchingEnded(device, context);
|
||||||
int resetPacketCount = -1;
|
int resetPacketCount = -1;
|
||||||
LOG.info("packetCount reset1: " + resetPacketCount);
|
LOG.info("packetCount reset1: " + resetPacketCount);
|
||||||
@ -245,7 +230,6 @@ class BangleJSActivityTrack extends BangleJSDeviceSupport {
|
|||||||
} else {
|
} else {
|
||||||
JSONObject requestTrackObj = BangleJSActivityTrack.compileTrackRequest(tracksList.getString(0), 1==tracksList.length());
|
JSONObject requestTrackObj = BangleJSActivityTrack.compileTrackRequest(tracksList.getString(0), 1==tracksList.length());
|
||||||
tracksList.remove(0);
|
tracksList.remove(0);
|
||||||
LOG.warn("tracksListIntact2:\n" + tracksListIntact);
|
|
||||||
int resetPacketCount = -1;
|
int resetPacketCount = -1;
|
||||||
LOG.info("packetCount reset2: " + resetPacketCount);
|
LOG.info("packetCount reset2: " + resetPacketCount);
|
||||||
returnArray = new JSONArray().put(requestTrackObj).put(tracksList).put(resetPacketCount);
|
returnArray = new JSONArray().put(requestTrackObj).put(tracksList).put(resetPacketCount);
|
||||||
|
@ -514,9 +514,8 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private JSONArray tracksList;
|
JSONArray tracksList;
|
||||||
private JSONArray tracksListIntact;
|
int packetCount;
|
||||||
private int packetCount;
|
|
||||||
private void handleUartRxJSON(JSONObject json) throws JSONException {
|
private void handleUartRxJSON(JSONObject json) throws JSONException {
|
||||||
String packetType = json.getString("t");
|
String packetType = json.getString("t");
|
||||||
switch (packetType) {
|
switch (packetType) {
|
||||||
@ -570,14 +569,13 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
if (tracksList!=null) {
|
if (tracksList!=null) {
|
||||||
JSONObject requestTrackObj = BangleJSActivityTrack.compileTrackRequest(tracksList.getString(0), 1==tracksList.length());
|
JSONObject requestTrackObj = BangleJSActivityTrack.compileTrackRequest(tracksList.getString(0), 1==tracksList.length());
|
||||||
uartTxJSON("requestActivityTrackLog", requestTrackObj);
|
uartTxJSON("requestActivityTrackLog", requestTrackObj);
|
||||||
tracksListIntact = BangleJSActivityTrack.makeDeepCopyOfJSONArray(tracksList);
|
|
||||||
tracksList.remove(0);
|
tracksList.remove(0);
|
||||||
packetCount = -1;
|
packetCount = -1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "actTrk":
|
case "actTrk":
|
||||||
LOG.info("packetCount1: " + packetCount);
|
LOG.info("packetCount1: " + packetCount);
|
||||||
JSONArray returnArray = BangleJSActivityTrack.handleActTrk(json, tracksList, tracksListIntact, packetCount, getDevice(), getContext());
|
JSONArray returnArray = BangleJSActivityTrack.handleActTrk(json, tracksList, packetCount, getDevice(), getContext());
|
||||||
if (!returnArray.isNull(0)) uartTxJSON("requestActivityTrackLog", returnArray.getJSONObject(0));
|
if (!returnArray.isNull(0)) uartTxJSON("requestActivityTrackLog", returnArray.getJSONObject(0));
|
||||||
tracksList = returnArray.getJSONArray(1);
|
tracksList = returnArray.getJSONArray(1);
|
||||||
packetCount = returnArray.getInt(2);
|
packetCount = returnArray.getInt(2);
|
||||||
|
Loading…
Reference in New Issue
Block a user