Class BloodPressureMeasurement

java.lang.Object
com.codename1.health.sensors.BloodPressureMeasurement

public final class BloodPressureMeasurement extends Object

A decoded Blood Pressure Measurement, characteristic 0x2A35, or the Intermediate Cuff Pressure, 0x2A36, which shares the same layout.

Wire format

Byte 0 is a flags field:

Bit Meaning
0 units: 0 = mmHg, 1 = kPa
1 timestamp present
2 pulse rate present
3 user id present
4 measurement status present

It is followed by three 16-bit IEEE-11073 SFLOAT values -- systolic, diastolic and mean arterial pressure -- then the optional fields.

Two traps

This characteristic is indicated, not notified. Its client configuration descriptor takes 0x0002. The Bluetooth layer handles that automatically, but a hand-rolled GATT client that writes 0x0001 will subscribe successfully and then never receive anything.

A cuff that fails to get a reading sends a reserved SFLOAT. Those decode to Double.NaN here, and [#parse(byte[])] returns null when the systolic or diastolic value is one, so a failed measurement can never reach your UI as 2047 mmHg.

  • Method Details

    • parse

      public static BloodPressureMeasurement parse(byte[] value)

      Decodes a 0x2A35 or 0x2A36 value.

      Returns null for a malformed or truncated payload, and also when the device signalled a failed measurement through a reserved SFLOAT. Never throws.

    • getSystolicMmHg

      public double getSystolicMmHg()
      Systolic pressure in mmHg, converted from kPa when the device reported those.
    • getDiastolicMmHg

      public double getDiastolicMmHg()
      Diastolic pressure in mmHg.
    • getMeanArterialMmHg

      public double getMeanArterialMmHg()
      Mean arterial pressure in mmHg, or Double.NaN when the device did not compute one.
    • getPulseBpm

      public double getPulseBpm()
      Pulse in beats per minute, or Double.NaN when absent.
    • hasPulse

      public boolean hasPulse()
      true when this reading carried a pulse.
    • getUserId

      public int getUserId()
      The device's user-profile index, or -1 when absent. Cuffs shared by a household use it to attribute a reading.
    • getTimestampMillis

      public long getTimestampMillis()

      The device's own timestamp for this reading in epoch millis, or -1 when absent.

      Worth preferring over the time of receipt: cuffs store readings and upload them in a burst when they next connect, so several measurements taken hours apart can arrive within a second.

    • toString

      public String toString()
      Description copied from class: Object
      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())
      Overrides:
      toString in class Object