mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-11 01:21:56 +01:00
Bangle.js:actTrk:try at packet counting
... might not be necessary. Since I got the fetching to work with intervals on the the Bangle.js side it's been stable. Didn't manage to make packet counting work yet.
This commit is contained in:
parent
ddc2d7a34a
commit
8338b03b3b
@ -103,7 +103,28 @@ public class BangleJSActivityTrack extends BangleJSDeviceSupport {
|
|||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static JSONArray handleActTrk(JSONObject json, JSONArray tracksList, GBDevice device, Context context) throws JSONException {
|
private void stopFunc() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JSONArray handleActTrk(JSONObject json, JSONArray tracksList, int prevPacketCount, GBDevice device, Context context) throws JSONException {
|
||||||
|
JSONArray returnArray;
|
||||||
|
|
||||||
|
JSONObject stopObj = new JSONObject().put("t","fetchRec").put("id","stop");
|
||||||
|
int currPacketCount;
|
||||||
|
if (json.has("cnt")) {
|
||||||
|
currPacketCount = json.getInt("cnt");
|
||||||
|
} else {
|
||||||
|
currPacketCount = 0;
|
||||||
|
}
|
||||||
|
if (false && currPacketCount != prevPacketCount+1) {
|
||||||
|
LOG.error("Activity Track Packets came out of order - aborting.");
|
||||||
|
returnArray = new JSONArray().put(stopObj).put(tracksList).put(prevPacketCount);
|
||||||
|
device.unsetBusyTask();
|
||||||
|
GB.updateTransferNotification(context.getString(R.string.busy_task_fetch_activity_data), "", false, 100, context);
|
||||||
|
return returnArray;
|
||||||
|
}
|
||||||
|
|
||||||
LOG.info("actTrk says hi!");
|
LOG.info("actTrk says hi!");
|
||||||
//GB.toast(context, "actTrk says hi!", Toast.LENGTH_LONG, GB.INFO);
|
//GB.toast(context, "actTrk says hi!", Toast.LENGTH_LONG, GB.INFO);
|
||||||
String log = json.getString("log");
|
String log = json.getString("log");
|
||||||
@ -112,7 +133,7 @@ public class BangleJSActivityTrack extends BangleJSDeviceSupport {
|
|||||||
try {
|
try {
|
||||||
dir = FileUtils.getExternalFilesDir();
|
dir = FileUtils.getExternalFilesDir();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
JSONArray returnArray = new JSONArray().put(null).put(tracksList);
|
returnArray = new JSONArray().put(null).put(tracksList).put(currPacketCount);
|
||||||
return returnArray;
|
return returnArray;
|
||||||
}
|
}
|
||||||
String filename = "recorder.log" + log + ".csv";
|
String filename = "recorder.log" + log + ".csv";
|
||||||
@ -122,10 +143,12 @@ public class BangleJSActivityTrack extends BangleJSDeviceSupport {
|
|||||||
if (tracksList.length()==0) {
|
if (tracksList.length()==0) {
|
||||||
device.unsetBusyTask();
|
device.unsetBusyTask();
|
||||||
GB.updateTransferNotification(context.getString(R.string.busy_task_fetch_activity_data), "", false, 100, context);
|
GB.updateTransferNotification(context.getString(R.string.busy_task_fetch_activity_data), "", false, 100, context);
|
||||||
|
returnArray = new JSONArray().put(null).put(tracksList).put(-1);
|
||||||
|
return returnArray;
|
||||||
} 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);
|
||||||
JSONArray returnArray = new JSONArray().put(requestTrackObj).put(tracksList);
|
returnArray = new JSONArray().put(requestTrackObj).put(tracksList).put(currPacketCount);
|
||||||
return returnArray;
|
return returnArray;
|
||||||
}
|
}
|
||||||
} else { // We received a lines of the csv, now we append it to the file in storage.
|
} else { // We received a lines of the csv, now we append it to the file in storage.
|
||||||
@ -153,7 +176,7 @@ public class BangleJSActivityTrack extends BangleJSDeviceSupport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONArray returnArray = new JSONArray().put(null).put(tracksList);
|
returnArray = new JSONArray().put(null).put(tracksList).put(currPacketCount);
|
||||||
return returnArray;
|
return returnArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -515,6 +515,7 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
JSONArray tracksList;
|
JSONArray tracksList;
|
||||||
|
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,12 +571,15 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
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);
|
||||||
tracksList.remove(0);
|
tracksList.remove(0);
|
||||||
|
packetCount = -1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "actTrk":
|
case "actTrk":
|
||||||
JSONArray returnArray = BangleJSActivityTrack.handleActTrk(json, tracksList, 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);
|
||||||
break;
|
break;
|
||||||
case "http":
|
case "http":
|
||||||
handleHttp(json);
|
handleHttp(json);
|
||||||
|
Loading…
Reference in New Issue
Block a user