public final class GlucoseMeasurement
- Object
- GlucoseMeasurement
A decoded Glucose Measurement, characteristic 0x2A18.
Wire format
A flags byte, a uint16 sequence number, a 7-byte base time, then the
optional fields the flags select:
| Bit | Meaning |
|---|---|
| 0 | time offset present (sint16 minutes) |
| 1 | concentration, type and location present |
| 2 | concentration units: 0 = kg/L, 1 = mol/L |
| 3 | sensor status annunciation present |
| 4 | context information will follow on 0x2A34 |
The units bit selects a different quantity, not a different scale
A meter reporting kg/L transmits a mass concentration; one reporting
mol/L transmits a molar concentration. Converting between them divides
by the molar mass of glucose, 18.0182 – it is not a generic unit
conversion, and applying it to any other analyte would be wrong. This
parser normalizes to mmol/L, the SI clinical unit, and exposes
getMilligramsPerDeciliter() for the convention used in the United
States.
Sequence numbers and stored records
Meters store readings and upload them in a burst, so the sequence
number rather than the arrival order is what identifies a measurement.
Retrieving stored records means driving the Record Access Control Point
– see GlucoseRecordFilter and
SensorSession.requestStoredRecords(GlucoseRecordFilter).
Fields
public static final int SAMPLE_LOCATION_UNKNOWN = 0 | The sample came from somewhere this profile does not name. |
public static final int SAMPLE_LOCATION_FINGER = 1 | Fingertip. |
public static final int SAMPLE_LOCATION_ALTERNATE_SITE = 2 | Alternate site test, such as the forearm. |
public static final int SAMPLE_LOCATION_EARLOBE = 3 | Earlobe. |
public static final int SAMPLE_LOCATION_CONTROL_SOLUTION = 4 | Control solution rather than blood – a calibration check, and not a reading to store as the user’s glucose. |
public static final int TYPE_CONTROL_SOLUTION = 10 | The fluid-type code the profile assigns to control solution. |
Methods
public static GlucoseMeasurement parse(byte[] value) | Decodes a 0x2A18 value. |
public int getSequenceNumber() | The meter’s sequence number for this reading. |
public long getTimestampMillis() | When the reading was taken, epoch millis, or -1 when the meter’s clock was unset. |
public double getMillimolesPerLiter() | The concentration in mmol/L, or Double.NaN when this record carried none. |
public double getMilligramsPerDeciliter() | The concentration in mg/dL, the unit used clinically in the United States, or Double.NaN when absent. |
public boolean hasConcentration() | true when this record carried a concentration. |
public int getSampleLocation() | Where the sample was taken, as a SAMPLE_LOCATION_ constant. |
public int getSampleType() | The fluid type code the meter reported – capillary whole blood, venous plasma, interstitial fluid and so on. |
public boolean isContextFollowing() | true when the meter will follow this record with a context notification on 0x2A34 carrying meal, exercise and medication annotations. |
public boolean isControlSolution() | true when this reading came from control solution rather than blood and must not be stored as a glucose measurement. |
public String toString() | Returns a string representation of the object. |
Inherited methods
Field details
SAMPLE_LOCATION_UNKNOWN
public static final int SAMPLE_LOCATION_UNKNOWN = 0SAMPLE_LOCATION_FINGER
public static final int SAMPLE_LOCATION_FINGER = 1SAMPLE_LOCATION_ALTERNATE_SITE
public static final int SAMPLE_LOCATION_ALTERNATE_SITE = 2SAMPLE_LOCATION_EARLOBE
public static final int SAMPLE_LOCATION_EARLOBE = 3SAMPLE_LOCATION_CONTROL_SOLUTION
public static final int SAMPLE_LOCATION_CONTROL_SOLUTION = 4TYPE_CONTROL_SOLUTION
public static final int TYPE_CONTROL_SOLUTION = 10The fluid-type code the profile assigns to control solution.
A meter can say “this is not blood” through either nibble of the type-and-location byte, and they are independent: some report the type and leave the location unknown.
Method details
parse
public static GlucoseMeasurement parse(byte[] value)0x2A18 value. Returns null for a malformed or
truncated payload; never throws.getSequenceNumber
public int getSequenceNumber()getTimestampMillis
public long getTimestampMillis()-1 when the meter’s
clock was unset. Prefer this over the time of receipt – stored
records arrive long after the fact.getMillimolesPerLiter
public double getMillimolesPerLiter()Double.NaN when this record
carried none.getMilligramsPerDeciliter
public double getMilligramsPerDeciliter()Double.NaN when absent.hasConcentration
public boolean hasConcentration()true when this record carried a concentration. A record without
one is a placeholder the meter kept for a failed test.getSampleLocation
public int getSampleLocation()Where the sample was taken, as a SAMPLE_LOCATION_ constant.
Check for SAMPLE_LOCATION_CONTROL_SOLUTION before storing a
reading as the user’s glucose: that value means the meter was being
calibrated against a test fluid, and recording it as a blood
measurement puts a fictitious reading into their medical history.
getSampleType
public int getSampleType()isContextFollowing
public boolean isContextFollowing()true when the meter will follow this record with a context
notification on 0x2A34 carrying meal, exercise and medication
annotations.isControlSolution
public boolean isControlSolution()true when this reading came from control solution rather than
blood and must not be stored as a glucose measurement.
Either nibble settles it. The profile carries control solution as a fluid type and as a sample location, and they are independent – a meter that reports type 10 while leaving the location unknown is stating plainly that this is calibration fluid, and reading only the location published it as the user’s blood glucose.
toString
public String toString()