1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2025-01-11 18:35:49 +01:00

Bangle.js: Support sending activity type from Bangle (#4323)

This commit is contained in:
Gordon Williams 2024-11-15 10:21:00 +00:00
parent 6c7649264f
commit 9a962bd495
3 changed files with 13 additions and 22 deletions

View File

@ -47,6 +47,7 @@
* Xiaomi-protobuf: Improve workout parsing * Xiaomi-protobuf: Improve workout parsing
* Zepp OS: Add sleep respiratory rate chart * Zepp OS: Add sleep respiratory rate chart
* Zepp OS: Send notification pictures * Zepp OS: Send notification pictures
* Bangle.js: Support sending activity type from Bangle
#### 0.82.1 #### 0.82.1
* Huawei: Improve activity parsing * Huawei: Improve activity parsing

View File

@ -40,8 +40,6 @@ public class BangleJSSampleProvider extends AbstractSampleProvider<BangleJSActiv
super(device, session); super(device, session);
} }
public static final int TYPE_ACTIVITY = 0;
@Override @Override
public AbstractDao<BangleJSActivitySample, ?> getSampleDao() { public AbstractDao<BangleJSActivitySample, ?> getSampleDao() {
return getSession().getBangleJSActivitySampleDao(); return getSession().getBangleJSActivitySampleDao();
@ -67,17 +65,12 @@ public class BangleJSSampleProvider extends AbstractSampleProvider<BangleJSActiv
@Override @Override
public ActivityKind normalizeType(int rawType) { public ActivityKind normalizeType(int rawType) {
switch (rawType) { return ActivityKind.fromCode(rawType);
case TYPE_ACTIVITY:
return ActivityKind.ACTIVITY;
default: // fall through
return ActivityKind.UNKNOWN;
}
} }
@Override @Override
public int toRawActivityKind(ActivityKind activityKind) { public int toRawActivityKind(ActivityKind activityKind) {
return TYPE_ACTIVITY; return activityKind.getCode();
} }
@Override @Override

View File

@ -126,6 +126,7 @@ import nodomain.freeyourgadget.gadgetbridge.externalevents.gps.GBLocationProvide
import nodomain.freeyourgadget.gadgetbridge.externalevents.gps.GBLocationService; import nodomain.freeyourgadget.gadgetbridge.externalevents.gps.GBLocationService;
import nodomain.freeyourgadget.gadgetbridge.externalevents.sleepasandroid.SleepAsAndroidAction; import nodomain.freeyourgadget.gadgetbridge.externalevents.sleepasandroid.SleepAsAndroidAction;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind;
import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample; import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample;
import nodomain.freeyourgadget.gadgetbridge.model.Alarm; import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
import nodomain.freeyourgadget.gadgetbridge.model.BatteryState; import nodomain.freeyourgadget.gadgetbridge.model.BatteryState;
@ -821,25 +822,21 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport {
int steps = json.optInt("stp", 0); int steps = json.optInt("stp", 0);
int intensity = json.optInt("mov", ActivitySample.NOT_MEASURED); int intensity = json.optInt("mov", ActivitySample.NOT_MEASURED);
boolean realtime = json.optInt("rt", 0) == 1; boolean realtime = json.optInt("rt", 0) == 1;
int activity = BangleJSSampleProvider.TYPE_ACTIVITY; ActivityKind activity = ActivityKind.ACTIVITY;
/*if (json.has("act")) { if (json.has("act")) {
String actName = "TYPE_" + json.getString("act").toUpperCase();
try { try {
Field f = ActivityKind.class.getField(actName); String actName = json.optString("act","").toUpperCase();
try { activity = ActivityKind.valueOf(actName);
activity = f.getInt(null); } catch (final Exception e) {
} catch (IllegalAccessException e) { LOG.warn("JSON activity not known", e);
LOG.info("JSON activity '"+actName+"' not readable"); activity = ActivityKind.UNKNOWN;
} }
} catch (NoSuchFieldException e) {
LOG.info("JSON activity '"+actName+"' not found");
} }
}*/
if(hrm>0) { if(hrm>0) {
sleepAsAndroidSender.onHrChanged(hrm, 0); sleepAsAndroidSender.onHrChanged(hrm, 0);
} }
sample.setTimestamp(timestamp); sample.setTimestamp(timestamp);
sample.setRawKind(activity); sample.setRawKind(activity.getCode());
sample.setHeartRate(hrm); sample.setHeartRate(hrm);
sample.setSteps(steps); sample.setSteps(steps);
sample.setRawIntensity(intensity); sample.setRawIntensity(intensity);