Fix direction LPP values being encoded as lists

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
johnterickson
2026-09-22 15:29:04 +00:00
co-authored by Copilot
parent b32d8203ae
commit 8161c0f675
2 changed files with 18 additions and 1 deletions
+17
View File
@@ -37,3 +37,20 @@ class TestLppCurrentParsing:
lpp = json.loads(json.dumps(LppFrame([lppdata]), default=lpp_json_encoder))
assert lpp[0]['value'] == 0.5
class TestLppDirectionParsing:
"""Tests to verify LPP direction values are encoded as scalars."""
def test_direction_value_is_scalar(self):
"""A direction value should not be serialized as a one-item list."""
from meshcore.lpp_json_encoder import lpp_json_encoder
# Channel 2, Type 132 (direction), 90 degrees = 0x00 0x5A.
raw_bytes = bytes([2, 132, 0x00, 0x5A])
lppdata = LppData.from_bytes(raw_bytes)
lpp = json.loads(json.dumps(LppFrame([lppdata]), default=lpp_json_encoder))
assert lpp[0]['type'] == 'direction'
assert lpp[0]['value'] == 90.0