src.bluetooth_sig.gatt.characteristics.fitness_machine_common¶
Shared parsing/encoding utilities for Fitness Machine Service characteristics.
All six Fitness Machine data characteristics (treadmill, indoor bike, cross trainer, rower, stair climber, step climber) share the same trailing optional field blocks: energy triplet, heart rate, metabolic equivalent, elapsed time, and remaining time. This module provides reusable helpers so each characteristic only has to implement its own unique fields.
References
Bluetooth SIG Fitness Machine Service 1.0 org.bluetooth.characteristic.{treadmill,indoor_bike,cross_trainer,
rower,stair_climber,step_climber}_data YAML specs in GSS submodule
Attributes¶
Name | Description |
|---|---|
Functions¶
Name | Description |
|---|---|
|
Decode the shared Elapsed Time field (uint16, seconds). |
|
Decode the shared Energy triplet (Total + Per Hour + Per Minute). |
|
Decode the shared Heart Rate field (uint8, bpm). |
|
Decode the shared Metabolic Equivalent field (uint8, M=1 d=-1 b=0). |
|
Decode the shared Remaining Time field (uint16, seconds). |
|
Encode the shared Elapsed Time field (uint16, seconds). |
|
Encode the shared Energy triplet (Total + Per Hour + Per Minute). |
|
Encode the shared Heart Rate field (uint8, bpm). |
|
Encode the shared Metabolic Equivalent field (uint8, M=1 d=-1 b=0). |
|
Encode the shared Remaining Time field (uint16, seconds). |
Module Contents¶
- src.bluetooth_sig.gatt.characteristics.fitness_machine_common.decode_elapsed_time(data: bytearray, offset: int) tuple[int | None, int]¶
Decode the shared Elapsed Time field (uint16, seconds).
- Parameters:
data – Raw BLE bytes.
offset – Current read position.
- Returns:
(elapsed_time, new_offset)
- src.bluetooth_sig.gatt.characteristics.fitness_machine_common.decode_energy_triplet(data: bytearray, offset: int) tuple[int | None, int | None, int | None, int]¶
Decode the shared Energy triplet (Total + Per Hour + Per Minute).
Wire format: uint16 + uint16 + uint8 = 5 bytes, all gated by a single flag bit.
- Parameters:
data – Raw BLE bytes.
offset – Current read position.
- Returns:
(total_energy, energy_per_hour, energy_per_minute, new_offset)
- src.bluetooth_sig.gatt.characteristics.fitness_machine_common.decode_heart_rate(data: bytearray, offset: int) tuple[int | None, int]¶
Decode the shared Heart Rate field (uint8, bpm).
- Parameters:
data – Raw BLE bytes.
offset – Current read position.
- Returns:
(heart_rate, new_offset)
- src.bluetooth_sig.gatt.characteristics.fitness_machine_common.decode_metabolic_equivalent(data: bytearray, offset: int) tuple[float | None, int]¶
Decode the shared Metabolic Equivalent field (uint8, M=1 d=-1 b=0).
- Parameters:
data – Raw BLE bytes.
offset – Current read position.
- Returns:
(metabolic_equivalent, new_offset)
- src.bluetooth_sig.gatt.characteristics.fitness_machine_common.decode_remaining_time(data: bytearray, offset: int) tuple[int | None, int]¶
Decode the shared Remaining Time field (uint16, seconds).
- Parameters:
data – Raw BLE bytes.
offset – Current read position.
- Returns:
(remaining_time, new_offset)
- src.bluetooth_sig.gatt.characteristics.fitness_machine_common.encode_elapsed_time(elapsed_time: int) bytearray¶
Encode the shared Elapsed Time field (uint16, seconds).
- Parameters:
elapsed_time – Elapsed time in seconds (uint16).
- Returns:
2-byte bytearray.
- src.bluetooth_sig.gatt.characteristics.fitness_machine_common.encode_energy_triplet(total_energy: int | None, energy_per_hour: int | None, energy_per_minute: int | None) bytearray¶
Encode the shared Energy triplet (Total + Per Hour + Per Minute).
- Parameters:
total_energy – Total energy in kcal (uint16).
energy_per_hour – Energy per hour in kcal (uint16).
energy_per_minute – Energy per minute in kcal (uint8).
- Returns:
5-byte bytearray (uint16 + uint16 + uint8).
- src.bluetooth_sig.gatt.characteristics.fitness_machine_common.encode_heart_rate(heart_rate: int) bytearray¶
Encode the shared Heart Rate field (uint8, bpm).
- Parameters:
heart_rate – Heart rate in bpm (uint8).
- Returns:
1-byte bytearray.
- src.bluetooth_sig.gatt.characteristics.fitness_machine_common.encode_metabolic_equivalent(metabolic_equivalent: float) bytearray¶
Encode the shared Metabolic Equivalent field (uint8, M=1 d=-1 b=0).
- Parameters:
metabolic_equivalent – Metabolic equivalent value (real).
- Returns:
1-byte bytearray.
- src.bluetooth_sig.gatt.characteristics.fitness_machine_common.encode_remaining_time(remaining_time: int) bytearray¶
Encode the shared Remaining Time field (uint16, seconds).
- Parameters:
remaining_time – Remaining time in seconds (uint16).
- Returns:
2-byte bytearray.
- src.bluetooth_sig.gatt.characteristics.fitness_machine_common.MET_RESOLUTION = 10.0¶