diff --git a/witmotion/protocol.py b/witmotion/protocol.py index cf2aba7..6c75ccc 100644 --- a/witmotion/protocol.py +++ b/witmotion/protocol.py @@ -1,11 +1,12 @@ import struct from datetime import datetime, timezone from enum import Enum +import math G = 9.8 -class ReceiveMessage: +class ReceiveMessage(object): payload_length = 8 @classmethod @@ -160,6 +161,89 @@ def parse(cls, body): ) +class PressureMessage(ReceiveMessage): + code = 0x56 + + def __init__(self, pressure_pa, height_cm): + self.pressure_pa = pressure_pa + self.height_m = height_cm / 100.0 + + def __str__(self): + return "pressure message - pressure_pa:%d pressure_alt_m:%.2f" % ( + self.pressure_pa, + self.height_m, + ) + + @classmethod + def parse(cls, body): + pressure_pa, height_cm = struct.unpack("