initial support for telemetry to see if things come in

This commit is contained in:
Florent 2025-05-03 17:52:16 +02:00
parent 6a3da79af2
commit aef1801446
5 changed files with 25 additions and 2 deletions

View file

@ -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" },

View file

@ -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')

View file

@ -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"

View file

@ -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

View file

@ -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}")