public final class WeightMeasurement
- Object
- WeightMeasurement
A decoded Weight Measurement, characteristic 0x2A9D.
Wire format
Byte 0 is a flags field:
| Bit | Meaning |
|---|---|
| 0 | units: 0 = SI (kg), 1 = Imperial (lb) |
| 1 | timestamp present |
| 2 | user id present |
| 3 | BMI 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)0x2A9D value. Returns null for a malformed or
truncated payload; never throws.getWeightKg
public double getWeightKg()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()Double.NaN when absent.getBmi
public double getBmi()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()-1 when absent. Family scales
use it to attribute a reading.getTimestampMillis
public long getTimestampMillis()-1 when absent.toString
public String toString()