mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 09:01:55 +01:00
Bangle.js: Support sending activity type from Bangle (#4323)
This commit is contained in:
parent
6c7649264f
commit
9a962bd495
@ -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
|
||||
|
@ -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
|
||||
|
@ -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");
|
||||
String actName = json.optString("act","").toUpperCase();
|
||||
activity = ActivityKind.valueOf(actName);
|
||||
} catch (final Exception e) {
|
||||
LOG.warn("JSON activity not known", e);
|
||||
activity = ActivityKind.UNKNOWN;
|
||||
}
|
||||
} catch (NoSuchFieldException e) {
|
||||
LOG.info("JSON activity '"+actName+"' not found");
|
||||
}
|
||||
}*/
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user