mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-04-20 22:13:49 +00:00
telemetry ok
This commit is contained in:
parent
9ecc98bdc0
commit
6bf788ad82
2 changed files with 18 additions and 5 deletions
|
|
@ -41,7 +41,8 @@ async def main():
|
|||
|
||||
# Wait for status response
|
||||
telemetry_event = await mc.wait_for_event(EventType.TELEMETRY_RESPONSE, timeout=args.timeout)
|
||||
print(telemetry_event)
|
||||
print(telemetry_event.payload["lpp"])
|
||||
|
||||
|
||||
else:
|
||||
print("Login failed or timed out")
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import sys
|
||||
import logging
|
||||
import asyncio
|
||||
from cayennelpp import LppFrame
|
||||
import json
|
||||
from cayennelpp import LppFrame, LppData, LppUtil
|
||||
from typing import Any, Optional, Dict
|
||||
from .events import Event, EventType, EventDispatcher
|
||||
from .packets import PacketType
|
||||
|
|
@ -380,12 +381,23 @@ class MessageReader:
|
|||
res = {}
|
||||
|
||||
res["pubkey_pre"] = data[2:8].hex()
|
||||
buf = data[8:-8]
|
||||
buf = data[8:]
|
||||
res["data"] = buf.hex()
|
||||
res["lpp"] = LppFrame().from_bytes(buf)
|
||||
|
||||
"""Parse a given byte string and return as a LppFrame object."""
|
||||
i = 0
|
||||
data = []
|
||||
while i < len(buf) and buf[i] != 0:
|
||||
lppdata = LppData.from_bytes(buf[i:])
|
||||
data.append(lppdata)
|
||||
i = i + len(lppdata)
|
||||
|
||||
lpp = json.loads(json.dumps(LppFrame(data), default=LppUtil.json_encode_type_str))
|
||||
|
||||
res["lpp"] = lpp
|
||||
|
||||
attributes = {
|
||||
"data" : res["data"],
|
||||
"raw" : buf.hex(),
|
||||
}
|
||||
|
||||
await self.dispatcher.dispatch(Event(EventType.TELEMETRY_RESPONSE, res, attributes))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue