mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-06-11 11:56:18 +00:00
telemetry ok
This commit is contained in:
@@ -41,7 +41,8 @@ async def main():
|
|||||||
|
|
||||||
# Wait for status response
|
# Wait for status response
|
||||||
telemetry_event = await mc.wait_for_event(EventType.TELEMETRY_RESPONSE, timeout=args.timeout)
|
telemetry_event = await mc.wait_for_event(EventType.TELEMETRY_RESPONSE, timeout=args.timeout)
|
||||||
print(telemetry_event)
|
print(telemetry_event.payload["lpp"])
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("Login failed or timed out")
|
print("Login failed or timed out")
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
import asyncio
|
import asyncio
|
||||||
from cayennelpp import LppFrame
|
import json
|
||||||
|
from cayennelpp import LppFrame, LppData, LppUtil
|
||||||
from typing import Any, Optional, Dict
|
from typing import Any, Optional, Dict
|
||||||
from .events import Event, EventType, EventDispatcher
|
from .events import Event, EventType, EventDispatcher
|
||||||
from .packets import PacketType
|
from .packets import PacketType
|
||||||
@@ -380,12 +381,23 @@ class MessageReader:
|
|||||||
res = {}
|
res = {}
|
||||||
|
|
||||||
res["pubkey_pre"] = data[2:8].hex()
|
res["pubkey_pre"] = data[2:8].hex()
|
||||||
buf = data[8:-8]
|
buf = data[8:]
|
||||||
res["data"] = buf.hex()
|
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 = {
|
attributes = {
|
||||||
"data" : res["data"],
|
"raw" : buf.hex(),
|
||||||
}
|
}
|
||||||
|
|
||||||
await self.dispatcher.dispatch(Event(EventType.TELEMETRY_RESPONSE, res, attributes))
|
await self.dispatcher.dispatch(Event(EventType.TELEMETRY_RESPONSE, res, attributes))
|
||||||
|
|||||||
Reference in New Issue
Block a user