mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-04-20 22:13:49 +00:00
initial support for telemetry to see if things come in
This commit is contained in:
parent
6a3da79af2
commit
aef1801446
5 changed files with 25 additions and 2 deletions
|
|
@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|||
|
||||
[project]
|
||||
name = "meshcore"
|
||||
version = "1.9.7"
|
||||
version = "1.9.8.dev1"
|
||||
authors = [
|
||||
{ name="Florent de Lamotte", email="florent@frizoncorrea.fr" },
|
||||
{ name="Alex Wolden", email="awolden@gmail.com" },
|
||||
|
|
|
|||
|
|
@ -306,6 +306,13 @@ class CommandHandler:
|
|||
data = b"\x03\x00" + chan.to_bytes(1, 'little') + timestamp + msg.encode("utf-8")
|
||||
return await self.send(data, [EventType.OK, EventType.ERROR])
|
||||
|
||||
async def send_telemetry_req(self, dst: DestinationType) -> Event :
|
||||
dst_bytes = _validate_destination(dst, prefix_length=32)
|
||||
logger.debug(f"Asking telemetry to {dst_bytes.hex()}")
|
||||
|
||||
data = b"\x27\x00\x00\x00" + dst_bytes
|
||||
return await self.send(data, [EventType.MSG_SENT, EventType.ERROR])
|
||||
|
||||
async def send_cli(self, cmd) -> Event:
|
||||
logger.debug(f"Sending CLI command: {cmd}")
|
||||
data = b"\x32" + cmd.encode('utf-8')
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ class EventType(Enum):
|
|||
LOG_DATA = "log_data"
|
||||
TRACE_DATA = "trace_data"
|
||||
RX_LOG_DATA = "rx_log_data"
|
||||
TELEMETRY_RESPONSE = "telemetry_response"
|
||||
|
||||
# Command response types
|
||||
OK = "command_ok"
|
||||
|
|
|
|||
|
|
@ -28,4 +28,6 @@ class PacketType(Enum):
|
|||
LOGIN_FAILED = 0x86
|
||||
STATUS_RESPONSE = 0x87
|
||||
LOG_DATA = 0x88
|
||||
TRACE_DATA = 0x89
|
||||
TRACE_DATA = 0x89
|
||||
PUSH_CODE_NEW_ADVERT = 0x8A
|
||||
TELEMETRY_RESPONSE = 0x8B
|
||||
|
|
@ -358,7 +358,20 @@ class MessageReader:
|
|||
}
|
||||
|
||||
await self.dispatcher.dispatch(Event(EventType.TRACE_DATA, res, attributes))
|
||||
|
||||
elif packet_type_value == PacketType.TELEMETRY_RESPONSE.value:
|
||||
logger.debug(f"Received telemetry data: {data.hex()}")
|
||||
res = {}
|
||||
|
||||
res["pubkey_pre"] = data[2:8].hex()
|
||||
res["data"] = data[8:12].hex()
|
||||
|
||||
attributes = {
|
||||
"data" : res["data"],
|
||||
}
|
||||
|
||||
await self.dispatcher.dispatch(Event(EventType.TELEMETRY_RESPONSE, res, attributes))
|
||||
|
||||
else:
|
||||
logger.debug(f"Unhandled data received {data}")
|
||||
logger.debug(f"Unhandled packet type: {packet_type_value}")
|
||||
Loading…
Add table
Add a link
Reference in a new issue