public final class GlucoseMeasurement

  1. Object
  2. 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:

BitMeaning
0time offset present (sint16 minutes)
1concentration, type and location present
2concentration units: 0 = kg/L, 1 = mol/L
3sensor status annunciation present
4context 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 = 0The sample came from somewhere this profile does not name.
public static final int SAMPLE_LOCATION_FINGER = 1Fingertip.
public static final int SAMPLE_LOCATION_ALTERNATE_SITE = 2Alternate site test, such as the forearm.
public static final int SAMPLE_LOCATION_EARLOBE = 3Earlobe.
public static final int SAMPLE_LOCATION_CONTROL_SOLUTION = 4Control 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 = 10The 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 = 0
The sample came from somewhere this profile does not name.

SAMPLE_LOCATION_FINGER

public static final int SAMPLE_LOCATION_FINGER = 1
Fingertip.

SAMPLE_LOCATION_ALTERNATE_SITE

public static final int SAMPLE_LOCATION_ALTERNATE_SITE = 2
Alternate site test, such as the forearm.

SAMPLE_LOCATION_EARLOBE

public static final int SAMPLE_LOCATION_EARLOBE = 3
Earlobe.

SAMPLE_LOCATION_CONTROL_SOLUTION

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.

TYPE_CONTROL_SOLUTION

public static final int TYPE_CONTROL_SOLUTION = 10

The 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)
Decodes a 0x2A18 value. Returns null for a malformed or truncated payload; never throws.

getSequenceNumber

public int getSequenceNumber()
The meter’s sequence number for this reading. Stable across re-transmission, and the right key for de-duplicating a burst of stored records.

getTimestampMillis

public long getTimestampMillis()
When the reading was taken, epoch millis, or -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()
The concentration in mmol/L, or Double.NaN when this record carried none.

getMilligramsPerDeciliter

public double getMilligramsPerDeciliter()
The concentration in mg/dL, the unit used clinically in the United States, or 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()
The fluid type code the meter reported – capillary whole blood, venous plasma, interstitial fluid and so on.

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()
Returns a string representation of the object. In general, the toString method returns a string that “textually represents” this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method. The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@’, and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: getClass().getName() + ‘@’ + Integer.toHexString(hashCode())