From d7975fb287e2ec3515d479c4ce6b7952fb6d7ba8 Mon Sep 17 00:00:00 2001 From: Harrison Caudill Date: Wed, 4 Jan 2023 11:13:37 -0800 Subject: [PATCH 1/2] Add lat/lon, speed, accuracy, and pressure messages --- witmotion/protocol.py | 118 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 117 insertions(+), 1 deletion(-) diff --git a/witmotion/protocol.py b/witmotion/protocol.py index cf2aba7..e2da1b2 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(" Date: Thu, 5 Jan 2023 10:54:57 -0800 Subject: [PATCH 2/2] lat/lon were reversed --- witmotion/protocol.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/witmotion/protocol.py b/witmotion/protocol.py index e2da1b2..6c75ccc 100644 --- a/witmotion/protocol.py +++ b/witmotion/protocol.py @@ -202,7 +202,7 @@ def __str__(self): @classmethod def parse(cls, body): - lat_i, lon_i = struct.unpack("