diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusDataRecord.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusDataRecord.java index 7e854d68..d2c96471 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusDataRecord.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusDataRecord.java @@ -11,7 +11,14 @@ public class HPlusDataRecord { public final static int TYPE_SLEEP = 1; public int activityKind = ActivityKind.TYPE_UNKNOWN; + /** + * Time of this record in seconds + */ public int timestamp; + + /** + * Raw data as sent from the device + */ public byte[] rawData; public HPlusDataRecord(byte[] data){ @@ -24,8 +31,19 @@ public class HPlusDataRecord { } public class RecordInterval { + /** + * Start time of this interval in seconds + */ public int timestampFrom; + + /** + * End time of this interval in seconds + */ public int timestampTo; + + /** + * Type of activity {@link ActivityKind} + */ public int activityKind; RecordInterval(int timestampFrom, int timestampTo, int activityKind) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusDataRecordDay.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusDataRecordDaySlot.java similarity index 59% rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusDataRecordDay.java rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusDataRecordDaySlot.java index c6a8603f..3e3b9ad1 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusDataRecordDay.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusDataRecordDaySlot.java @@ -9,13 +9,31 @@ import java.util.GregorianCalendar; import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind; -public class HPlusDataRecordDay extends HPlusDataRecord { +public class HPlusDataRecordDaySlot extends HPlusDataRecord { + + /** + * The device reports data aggregated in slots. + * There are 144 slots in a given day, summarizing 10 minutes of data + * Integer with the slot number from 0 to 143 + */ public int slot; + + /** + * Number of steps + */ public int steps; + + /** + * Number of seconds without activity (TBC) + */ public int secondsInactive; + + /** + * Average Heart Rate in Beats Per Minute + */ public int heartRate; - public HPlusDataRecordDay(byte[] data) { + public HPlusDataRecordDaySlot(byte[] data) { super(data); int a = (data[4] & 0xFF) * 256 + (data[5] & 0xFF); @@ -23,13 +41,13 @@ public class HPlusDataRecordDay extends HPlusDataRecord { throw new IllegalArgumentException("Invalid Slot Number"); } - slot = a; // 10 minute slots as an offset from 0:00 AM - heartRate = data[1] & 0xFF; //Average Heart Rate ? + slot = a; + heartRate = data[1] & 0xFF; if(heartRate == 255) heartRate = ActivityKind.TYPE_NOT_MEASURED; - steps = (data[2] & 0xFF) * 256 + data[3] & 0xFF; // Steps in this period + steps = (data[2] & 0xFF) * 256 + data[3] & 0xFF; //?? data[6]; secondsInactive = data[7] & 0xFF; // ? diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusDataRecordRealtime.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusDataRecordRealtime.java index 8a3750ec..d827976d 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusDataRecordRealtime.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusDataRecordRealtime.java @@ -12,11 +12,36 @@ import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind; class HPlusDataRecordRealtime extends HPlusDataRecord { + + /** + * Distance accumulated during the day in meters + */ public int distance; + + /** + * Calories consumed during the day in KCalories + */ public int calories; + + /** + * Instantaneous Heart Rate measured in Beats Per Minute + */ public int heartRate; + + /** + * Battery level from 0 to 100 + */ public byte battery; + + /** + * Time active (To be determined how it works) + */ public int activeTime; + + /** + * Computing intensity + * To be calculated appropriately + */ public int intensity; public HPlusDataRecordRealtime(byte[] data) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusDataRecordSleep.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusDataRecordSleep.java index b7dbdd42..97ea0294 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusDataRecordSleep.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusDataRecordSleep.java @@ -14,14 +14,56 @@ import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind; public class HPlusDataRecordSleep extends HPlusDataRecord { + /** + * Time which the device determined to be the bed time in seconds + */ public int bedTimeStart; + + /** + * Time which the device determined to be the end of this sleep period in seconds + */ public int bedTimeEnd; + + /** + * Number of minutes in Deep Sleep + */ public int deepSleepMinutes; + + /** + * Number of minutes in Light Sleep + * This is considered as Light Sleep + + */ public int lightSleepMinutes; + + /** + * Number of minutes to start sleeping (??) + * This is considered as Light Sleep + */ public int enterSleepMinutes; + + /** + * Number of minutes with Sleep Spindles (??) + * This is considered as Light Sleep + */ public int spindleMinutes; + + /** + * Number of minutes in REM sleep + * This is considered as Light Sleep + + */ public int remSleepMinutes; + + /** + * Number of wake up minutes during the sleep period + * This is not considered as a sleep activity + */ public int wakeupMinutes; + + /** + * Number of times the user woke up + */ public int wakeupCount; public HPlusDataRecordSleep(byte[] data) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusDataRecordSteps.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusDataRecordSteps.java index 997a09ed..0d8e6c34 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusDataRecordSteps.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusDataRecordSteps.java @@ -11,16 +11,52 @@ import java.util.Locale; class HPlusDataRecordSteps extends HPlusDataRecord{ + + /** + * Year of the record reported by the device + * Sometimes the device will report a low number (e.g, 116) which will be "corrected" + * by adding 1900 + */ public int year; + + /** + * Month of the record reported by the device from 1 to 12 + */ public int month; + + /** + * Day of the record reported by the device + */ public int day; + /** + * Number of steps accumulated in the day reported + */ public int steps; + + /** + * Distance in meters accumulated in the day reported + */ public int distance; + /** + * Amount of time active in the day (Units are To Be Determined) + */ public int activeTime; + + /** + * Max Heart Rate recorded in Beats Per Minute + */ public int maxHeartRate; + + /** + * Min Heart Rate recorded in Beats Per Minute + */ public int minHeartRate; + + /** + * Amount of estimated calories consumed during the day in KCalories + */ public int calories; HPlusDataRecordSteps(byte[] data) { @@ -31,6 +67,7 @@ class HPlusDataRecordSteps extends HPlusDataRecord{ day = data[12] & 0xFF; //Recover from bug in firmware where year is corrupted + //data[10] will be set to 0, effectively offsetting values by minus 1900 years if(year < 1900) year += 1900; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusHandlerThread.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusHandlerThread.java index fcb7f6a4..5f960392 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusHandlerThread.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusHandlerThread.java @@ -156,9 +156,9 @@ class HPlusHandlerThread extends GBDeviceIoThread { public boolean processIncomingDaySlotData(byte[] data) { - HPlusDataRecordDay record; + HPlusDataRecordDaySlot record; try{ - record = new HPlusDataRecordDay(data); + record = new HPlusDataRecordDaySlot(data); } catch(IllegalArgumentException e){ LOG.debug((e.getMessage())); return true;