discover_path

This commit is contained in:
Florent 2025-07-31 22:10:03 +02:00
parent fbb6e74b15
commit 206321bd6b
5 changed files with 26 additions and 1 deletions

View file

@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project]
name = "meshcore"
version = "2.0.2"
version = "2.0.3"
authors = [
{ name="Florent de Lamotte", email="florent@frizoncorrea.fr" },
{ name="Alex Wolden", email="awolden@gmail.com" },

View file

@ -399,6 +399,12 @@ class CommandHandler:
logger.debug(f"Binary request to {dst_bytes.hex()}")
data = b"\x32" + dst_bytes + bin_data
return await self.send(data, [EventType.MSG_SENT, EventType.ERROR])
async def send_path_discovery(self, dst: DestinationType) -> Event :
dst_bytes = _validate_destination(dst, prefix_length=32)
logger.debug(f"Path discovery request for {dst_bytes.hex()}")
data = b"\x34\x00" + dst_bytes
return await self.send(data, [EventType.MSG_SENT, EventType.ERROR])
async def get_self_telemetry(self) -> Event :
logger.debug(f"Getting self telemetry")

View file

@ -37,6 +37,7 @@ class EventType(Enum):
BINARY_RESPONSE = "binary_response"
CUSTOM_VARS = "custom_vars"
CHANNEL_INFO = "channel_info"
PATH_RESPONSE = "path_response"
# Command response types
OK = "command_ok"

View file

@ -41,3 +41,4 @@ class PacketType(Enum):
PUSH_CODE_NEW_ADVERT = 0x8A
TELEMETRY_RESPONSE = 0x8B
BINARY_RESPONSE = 0x8C
PATH_DISCOVERY_RESPONSE = 0x8D

View file

@ -461,6 +461,23 @@ class MessageReader:
await self.dispatcher.dispatch(Event(EventType.BINARY_RESPONSE, res, attributes))
elif packet_type_value == PacketType.PATH_DISCOVERY_RESPONSE.value:
logger.debug(f"Received path discovery response: {data.hex()}")
res = {}
res["pubkey_pre"] = data[2:8].hex()
opl = data[8]
res["out_path_len"] = opl
res["out_path"] = data[9:9+opl].hex()
ipl = data[9+opl]
res["in_path_len"] = ipl
res["in_path"] = data[10+opl:10+opl+ipl].hex()
attributes = {
"pubkey_pre" : res["pubkey_pre"]
}
await self.dispatcher.dispatch(Event(EventType.PATH_RESPONSE, res, attributes))
else:
logger.debug(f"Unhandled data received {data}")
logger.debug(f"Unhandled packet type: {packet_type_value}")