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
* Zepp OS: Add sleep respiratory rate chart
* Zepp OS: Send notification pictures
* Bangle.js: Support sending activity type from Bangle
#### 0.82.1
* Huawei: Improve activity parsing

View File

@ -40,8 +40,6 @@ public class BangleJSSampleProvider extends AbstractSampleProvider<BangleJSActiv
super(device, session);
}
public static final int TYPE_ACTIVITY = 0;
@Override
public AbstractDao<BangleJSActivitySample, ?> getSampleDao() {
return getSession().getBangleJSActivitySampleDao();
@ -67,17 +65,12 @@ public class BangleJSSampleProvider extends AbstractSampleProvider<BangleJSActiv
@Override
public ActivityKind normalizeType(int rawType) {
switch (rawType) {
case TYPE_ACTIVITY:
return ActivityKind.ACTIVITY;
default: // fall through
return ActivityKind.UNKNOWN;
}
return ActivityKind.fromCode(rawType);
}
@Override
public int toRawActivityKind(ActivityKind activityKind) {
return TYPE_ACTIVITY;
return activityKind.getCode();
}
@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.sleepasandroid.SleepAsAndroidAction;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind;
import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample;
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
import nodomain.freeyourgadget.gadgetbridge.model.BatteryState;
@ -821,25 +822,21 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport {
int steps = json.optInt("stp", 0);
int intensity = json.optInt("mov", ActivitySample.NOT_MEASURED);
boolean realtime = json.optInt("rt", 0) == 1;
int activity = BangleJSSampleProvider.TYPE_ACTIVITY;
/*if (json.has("act")) {
String actName = "TYPE_" + json.getString("act").toUpperCase();
ActivityKind activity = ActivityKind.ACTIVITY;
if (json.has("act")) {
try {
Field f = ActivityKind.class.getField(actName);
try {
activity = f.getInt(null);
} catch (IllegalAccessException e) {
LOG.info("JSON activity '"+actName+"' not readable");
}
} catch (NoSuchFieldException e) {
LOG.info("JSON activity '"+actName+"' not found");
String actName = json.optString("act","").toUpperCase();
activity = ActivityKind.valueOf(actName);
} catch (final Exception e) {
LOG.warn("JSON activity not known", e);
activity = ActivityKind.UNKNOWN;
}
}*/
}
if(hrm>0) {
sleepAsAndroidSender.onHrChanged(hrm, 0);
}
sample.setTimestamp(timestamp);
sample.setRawKind(activity);
sample.setRawKind(activity.getCode());
sample.setHeartRate(hrm);
sample.setSteps(steps);
sample.setRawIntensity(intensity);