public final class WeightMeasurement

  1. Object
  2. WeightMeasurement

A decoded Weight Measurement, characteristic 0x2A9D.

Wire format

Byte 0 is a flags field:

BitMeaning
0units: 0 = SI (kg), 1 = Imperial (lb)
1timestamp present
2user id present
3BMI and height present

followed by a uint16 weight and the optional fields.

The resolution depends on the unit

The raw uint16 is scaled by 0.005 kg in SI mode and 0.01 lb in Imperial mode – not the same multiplier, and not a simple unit conversion applied afterwards. Getting this wrong yields a weight that is wrong by a factor of about two, which is exactly close enough to look plausible. Height carries the same split: 0.001 m against 0.1 in.

Like all characteristics here this one is indicated, not notified.

Methods

public static WeightMeasurement parse(byte[] value)Decodes a 0x2A9D value.
public double getWeightKg()The weight in kilograms, converted from pounds when the scale reported Imperial units.
public boolean isImperial()true when the scale transmitted Imperial units.
public double getHeightMeters()The height in metres, or Double.NaN when absent.
public double getBmi()The body mass index the scale computed, or Double.NaN when absent.
public boolean hasBmiAndHeight()true when this reading carried BMI and height.
public int getUserId()The scale’s user-profile index, or -1 when absent.
public long getTimestampMillis()The scale’s own timestamp in epoch millis, or -1 when absent.
public String toString()Returns a string representation of the object.

Inherited methods

Method details

parse

public static WeightMeasurement parse(byte[] value)
Decodes a 0x2A9D value. Returns null for a malformed or truncated payload; never throws.

getWeightKg

public double getWeightKg()
The weight in kilograms, converted from pounds when the scale reported Imperial units.

isImperial

public boolean isImperial()
true when the scale transmitted Imperial units. Useful for matching the user’s own display preference; the value returned by getWeightKg() is already normalized either way.

getHeightMeters

public double getHeightMeters()
The height in metres, or Double.NaN when absent.

getBmi

public double getBmi()
The body mass index the scale computed, or Double.NaN when absent.

hasBmiAndHeight

public boolean hasBmiAndHeight()

true when this reading carried BMI and height.

Both, as the name says. The two fields are optional independently – each carries its own 0xFFFF unavailable value and a scale that measured one but not the other sends both – so testing only the BMI let a caller that gated on this go on to use a height of NaN.

getUserId

public int getUserId()
The scale’s user-profile index, or -1 when absent. Family scales use it to attribute a reading.

getTimestampMillis

public long getTimestampMillis()
The scale’s own timestamp in epoch millis, or -1 when absent.

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())