mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-01-12 18:57:36 +01:00
fixed issue with sleep data(wrong order of reading bits). removed rest useless methods from band classes.
This commit is contained in:
parent
06a12300a1
commit
78ec2a4a14
@ -28,9 +28,11 @@ public class SonySWR12DeviceCoordinator extends AbstractDeviceCoordinator {
|
|||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
|
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
|
||||||
String name = candidate.getDevice().getName();
|
try {
|
||||||
if (!name.isEmpty() && name.toLowerCase().contains("swr12"))
|
String name = candidate.getDevice().getName();
|
||||||
return getDeviceType();
|
if (name != null && !name.isEmpty() && name.toLowerCase().contains("swr12"))
|
||||||
|
return getDeviceType();
|
||||||
|
} catch (Exception exc){}
|
||||||
return DeviceType.UNKNOWN;
|
return DeviceType.UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.sonyswr12.entities.activity;
|
package nodomain.freeyourgadget.gadgetbridge.service.devices.sonyswr12.entities.activity;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.sonyswr12.util.UIntBitWriter;
|
|
||||||
|
|
||||||
public abstract class ActivityBase {
|
public abstract class ActivityBase {
|
||||||
protected final ActivityType type;
|
protected final ActivityType type;
|
||||||
protected final int timeOffsetMin;
|
|
||||||
private final long timeStampSec;
|
private final long timeStampSec;
|
||||||
|
|
||||||
public ActivityBase(ActivityType type, int timeOffsetMin, long timeStampSec) {
|
public ActivityBase(ActivityType type, int timeOffsetMin, long timeStampSec) {
|
||||||
@ -12,8 +9,7 @@ public abstract class ActivityBase {
|
|||||||
throw new IllegalArgumentException("activity time offset out of range: " + timeOffsetMin);
|
throw new IllegalArgumentException("activity time offset out of range: " + timeOffsetMin);
|
||||||
}
|
}
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.timeOffsetMin = timeOffsetMin;
|
this.timeStampSec = timeStampSec + timeOffsetMin * 60;
|
||||||
this.timeStampSec = timeStampSec + this.timeOffsetMin * 60;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int getTimeStampSec() {
|
public final int getTimeStampSec() {
|
||||||
@ -23,13 +19,4 @@ public abstract class ActivityBase {
|
|||||||
public final ActivityType getType() {
|
public final ActivityType getType() {
|
||||||
return this.type;
|
return this.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final UIntBitWriter getWriterWithTypeAndOffset() {
|
|
||||||
UIntBitWriter uIntBitWriter = new UIntBitWriter(32);
|
|
||||||
uIntBitWriter.append(4, this.type.value);
|
|
||||||
uIntBitWriter.append(12, this.timeOffsetMin);
|
|
||||||
return uIntBitWriter;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract long toLong();
|
|
||||||
}
|
}
|
@ -1,7 +1,5 @@
|
|||||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.sonyswr12.entities.activity;
|
package nodomain.freeyourgadget.gadgetbridge.service.devices.sonyswr12.entities.activity;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.sonyswr12.util.UIntBitWriter;
|
|
||||||
|
|
||||||
public class ActivityHeartRate extends ActivityBase {
|
public class ActivityHeartRate extends ActivityBase {
|
||||||
public final int bpm;
|
public final int bpm;
|
||||||
|
|
||||||
@ -12,11 +10,4 @@ public class ActivityHeartRate extends ActivityBase {
|
|||||||
}
|
}
|
||||||
this.bpm = bpm;
|
this.bpm = bpm;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public long toLong() {
|
|
||||||
UIntBitWriter writerWithTypeAndOffset = this.getWriterWithTypeAndOffset();
|
|
||||||
writerWithTypeAndOffset.append(16, this.bpm);
|
|
||||||
return writerWithTypeAndOffset.getValue();
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,7 +1,5 @@
|
|||||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.sonyswr12.entities.activity;
|
package nodomain.freeyourgadget.gadgetbridge.service.devices.sonyswr12.entities.activity;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.sonyswr12.util.UIntBitWriter;
|
|
||||||
|
|
||||||
public class ActivitySleep extends ActivityBase {
|
public class ActivitySleep extends ActivityBase {
|
||||||
public final SleepLevel sleepLevel;
|
public final SleepLevel sleepLevel;
|
||||||
public final int durationMin;
|
public final int durationMin;
|
||||||
@ -11,12 +9,4 @@ public class ActivitySleep extends ActivityBase {
|
|||||||
this.durationMin = durationMin;
|
this.durationMin = durationMin;
|
||||||
this.sleepLevel = sleepLevel;
|
this.sleepLevel = sleepLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public long toLong() {
|
|
||||||
UIntBitWriter writerWithTypeAndOffset = this.getWriterWithTypeAndOffset();
|
|
||||||
writerWithTypeAndOffset.append(14, this.durationMin);
|
|
||||||
writerWithTypeAndOffset.append(2, this.sleepLevel.value);
|
|
||||||
return writerWithTypeAndOffset.getValue();
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,7 +1,5 @@
|
|||||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.sonyswr12.entities.activity;
|
package nodomain.freeyourgadget.gadgetbridge.service.devices.sonyswr12.entities.activity;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.sonyswr12.util.UIntBitWriter;
|
|
||||||
|
|
||||||
public class ActivityWithData extends ActivityBase {
|
public class ActivityWithData extends ActivityBase {
|
||||||
public final int data;
|
public final int data;
|
||||||
|
|
||||||
@ -12,11 +10,4 @@ public class ActivityWithData extends ActivityBase {
|
|||||||
}
|
}
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public long toLong() {
|
|
||||||
UIntBitWriter writerWithTypeAndOffset = this.getWriterWithTypeAndOffset();
|
|
||||||
writerWithTypeAndOffset.append(16, this.data);
|
|
||||||
return writerWithTypeAndOffset.getValue();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.sonyswr12.SonySWR12U
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.sonyswr12.util.IntFormat;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.sonyswr12.util.IntFormat;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.sonyswr12.util.UIntBitReader;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.sonyswr12.util.UIntBitReader;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.sonyswr12.util.ByteArrayReader;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.sonyswr12.util.ByteArrayReader;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.sonyswr12.util.ByteArrayWriter;
|
|
||||||
|
|
||||||
public class EventWithActivity extends EventBase {
|
public class EventWithActivity extends EventBase {
|
||||||
public final long timeStampSec;
|
public final long timeStampSec;
|
||||||
@ -30,8 +29,8 @@ public class EventWithActivity extends EventBase {
|
|||||||
ActivityBase activityPayload;
|
ActivityBase activityPayload;
|
||||||
switch (activityType) {
|
switch (activityType) {
|
||||||
case SLEEP: {
|
case SLEEP: {
|
||||||
SleepLevel sleepLevel = SleepLevel.fromInt(uIntBitReader.read(2));
|
|
||||||
int duration = uIntBitReader.read(14);
|
int duration = uIntBitReader.read(14);
|
||||||
|
SleepLevel sleepLevel = SleepLevel.fromInt(uIntBitReader.read(2));
|
||||||
activityPayload = new ActivitySleep(offsetMin, duration, sleepLevel, timeStampSec);
|
activityPayload = new ActivitySleep(offsetMin, duration, sleepLevel, timeStampSec);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -50,13 +49,4 @@ public class EventWithActivity extends EventBase {
|
|||||||
}
|
}
|
||||||
return new EventWithActivity(timeStampSec, activities);
|
return new EventWithActivity(timeStampSec, activities);
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] toByteArray() {
|
|
||||||
ByteArrayWriter byteArrayWriter = this.getValueWriter();
|
|
||||||
byteArrayWriter.appendUint32(this.timeStampSec);
|
|
||||||
for (ActivityBase activity : activityList){
|
|
||||||
byteArrayWriter.appendUint32(activity.toLong());
|
|
||||||
}
|
|
||||||
return byteArrayWriter.getByteArray();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user