mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-06-11 11:56:18 +00:00
discover_path
This commit is contained in:
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "meshcore"
|
name = "meshcore"
|
||||||
version = "2.0.2"
|
version = "2.0.3"
|
||||||
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" },
|
||||||
|
|||||||
@@ -399,6 +399,12 @@ class CommandHandler:
|
|||||||
logger.debug(f"Binary request to {dst_bytes.hex()}")
|
logger.debug(f"Binary request to {dst_bytes.hex()}")
|
||||||
data = b"\x32" + dst_bytes + bin_data
|
data = b"\x32" + dst_bytes + bin_data
|
||||||
return await self.send(data, [EventType.MSG_SENT, EventType.ERROR])
|
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 :
|
async def get_self_telemetry(self) -> Event :
|
||||||
logger.debug(f"Getting self telemetry")
|
logger.debug(f"Getting self telemetry")
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ class EventType(Enum):
|
|||||||
BINARY_RESPONSE = "binary_response"
|
BINARY_RESPONSE = "binary_response"
|
||||||
CUSTOM_VARS = "custom_vars"
|
CUSTOM_VARS = "custom_vars"
|
||||||
CHANNEL_INFO = "channel_info"
|
CHANNEL_INFO = "channel_info"
|
||||||
|
PATH_RESPONSE = "path_response"
|
||||||
|
|
||||||
# Command response types
|
# Command response types
|
||||||
OK = "command_ok"
|
OK = "command_ok"
|
||||||
|
|||||||
@@ -41,3 +41,4 @@ class PacketType(Enum):
|
|||||||
PUSH_CODE_NEW_ADVERT = 0x8A
|
PUSH_CODE_NEW_ADVERT = 0x8A
|
||||||
TELEMETRY_RESPONSE = 0x8B
|
TELEMETRY_RESPONSE = 0x8B
|
||||||
BINARY_RESPONSE = 0x8C
|
BINARY_RESPONSE = 0x8C
|
||||||
|
PATH_DISCOVERY_RESPONSE = 0x8D
|
||||||
|
|||||||
@@ -461,6 +461,23 @@ class MessageReader:
|
|||||||
|
|
||||||
await self.dispatcher.dispatch(Event(EventType.BINARY_RESPONSE, res, attributes))
|
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:
|
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