mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-06-11 11:56:18 +00:00
initial support for telemetry to see if things come in
This commit is contained in:
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "meshcore"
|
name = "meshcore"
|
||||||
version = "1.9.7"
|
version = "1.9.8.dev1"
|
||||||
authors = [
|
authors = [
|
||||||
{ name="Florent de Lamotte", email="florent@frizoncorrea.fr" },
|
{ name="Florent de Lamotte", email="florent@frizoncorrea.fr" },
|
||||||
{ name="Alex Wolden", email="awolden@gmail.com" },
|
{ 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")
|
data = b"\x03\x00" + chan.to_bytes(1, 'little') + timestamp + msg.encode("utf-8")
|
||||||
return await self.send(data, [EventType.OK, EventType.ERROR])
|
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:
|
async def send_cli(self, cmd) -> Event:
|
||||||
logger.debug(f"Sending CLI command: {cmd}")
|
logger.debug(f"Sending CLI command: {cmd}")
|
||||||
data = b"\x32" + cmd.encode('utf-8')
|
data = b"\x32" + cmd.encode('utf-8')
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ class EventType(Enum):
|
|||||||
LOG_DATA = "log_data"
|
LOG_DATA = "log_data"
|
||||||
TRACE_DATA = "trace_data"
|
TRACE_DATA = "trace_data"
|
||||||
RX_LOG_DATA = "rx_log_data"
|
RX_LOG_DATA = "rx_log_data"
|
||||||
|
TELEMETRY_RESPONSE = "telemetry_response"
|
||||||
|
|
||||||
# Command response types
|
# Command response types
|
||||||
OK = "command_ok"
|
OK = "command_ok"
|
||||||
|
|||||||
@@ -29,3 +29,5 @@ class PacketType(Enum):
|
|||||||
STATUS_RESPONSE = 0x87
|
STATUS_RESPONSE = 0x87
|
||||||
LOG_DATA = 0x88
|
LOG_DATA = 0x88
|
||||||
TRACE_DATA = 0x89
|
TRACE_DATA = 0x89
|
||||||
|
PUSH_CODE_NEW_ADVERT = 0x8A
|
||||||
|
TELEMETRY_RESPONSE = 0x8B
|
||||||
@@ -359,6 +359,19 @@ class MessageReader:
|
|||||||
|
|
||||||
await self.dispatcher.dispatch(Event(EventType.TRACE_DATA, res, attributes))
|
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:
|
else:
|
||||||
logger.debug(f"Unhandled data received {data}")
|
logger.debug(f"Unhandled data received {data}")
|
||||||
logger.debug(f"Unhandled packet type: {packet_type_value}")
|
logger.debug(f"Unhandled packet type: {packet_type_value}")
|
||||||
Reference in New Issue
Block a user