mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-06-11 11:56:18 +00:00
support only_prefix flag on discover node
This commit is contained in:
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "meshcore"
|
name = "meshcore"
|
||||||
version = "2.1.21"
|
version = "2.1.22"
|
||||||
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" },
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ logger = logging.getLogger("meshcore")
|
|||||||
class ControlDataCommandHandler(CommandHandlerBase):
|
class ControlDataCommandHandler(CommandHandlerBase):
|
||||||
"""Helper functions to handle binary requests through binary commands"""
|
"""Helper functions to handle binary requests through binary commands"""
|
||||||
|
|
||||||
async def send_control_data (self, control_type: ControlType, payload: bytes) -> Event:
|
async def send_control_data (self, control_type: int, payload: bytes) -> Event:
|
||||||
data = bytearray([PacketType.SEND_CONTROL_DATA.value])
|
data = bytearray([PacketType.SEND_CONTROL_DATA.value])
|
||||||
data.extend(control_type.value.to_bytes(1, "little", signed = False))
|
data.extend(control_type.to_bytes(1, "little", signed = False))
|
||||||
data.extend(payload)
|
data.extend(payload)
|
||||||
|
|
||||||
result = await self.send(data, [EventType.OK, EventType.ERROR])
|
result = await self.send(data, [EventType.OK, EventType.ERROR])
|
||||||
@@ -21,6 +21,7 @@ class ControlDataCommandHandler(CommandHandlerBase):
|
|||||||
async def send_node_discover_req (
|
async def send_node_discover_req (
|
||||||
self,
|
self,
|
||||||
filter: int,
|
filter: int,
|
||||||
|
prefix_only: bool=True,
|
||||||
tag: int=None,
|
tag: int=None,
|
||||||
since: int=None
|
since: int=None
|
||||||
) -> Event:
|
) -> Event:
|
||||||
@@ -36,7 +37,11 @@ class ControlDataCommandHandler(CommandHandlerBase):
|
|||||||
|
|
||||||
logger.debug(f"sending node discover req {data.hex()}")
|
logger.debug(f"sending node discover req {data.hex()}")
|
||||||
|
|
||||||
res = await self.send_control_data(ControlType.NODE_DISCOVER_REQ, data)
|
flags = 0
|
||||||
|
flags = flags | 1 if prefix_only else flags
|
||||||
|
|
||||||
|
res = await self.send_control_data(
|
||||||
|
ControlType.NODE_DISCOVER_REQ.value|flags, data)
|
||||||
|
|
||||||
if res is None:
|
if res is None:
|
||||||
return None
|
return None
|
||||||
|
|||||||
@@ -618,7 +618,14 @@ class MessageReader:
|
|||||||
ndr["node_type"] = payload_type & 0x0F
|
ndr["node_type"] = payload_type & 0x0F
|
||||||
ndr["SNR_in"] = int.from_bytes(pbuf.read(1), byteorder="little", signed=True)/4
|
ndr["SNR_in"] = int.from_bytes(pbuf.read(1), byteorder="little", signed=True)/4
|
||||||
ndr["tag"] = pbuf.read(4).hex()
|
ndr["tag"] = pbuf.read(4).hex()
|
||||||
ndr["pubkey"] = pbuf.read(32).hex()
|
|
||||||
|
pubkey = pbuf.read()
|
||||||
|
if len(pubkey) < 32:
|
||||||
|
pubkey = pubkey[0:8]
|
||||||
|
else:
|
||||||
|
pubkey = pubkey[0:32]
|
||||||
|
|
||||||
|
ndr["pubkey"] = pubkey.hex()
|
||||||
|
|
||||||
attributes = {
|
attributes = {
|
||||||
"node_type" : ndr["node_type"],
|
"node_type" : ndr["node_type"],
|
||||||
|
|||||||
Reference in New Issue
Block a user