Skip to content

Commit 9d64ff8

Browse files
committed
req_acl
1 parent f190b60 commit 9d64ff8

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

src/meshcore/binary_commands.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
logger = logging.getLogger("meshcore")
1111

1212
class BinaryReqType(Enum):
13-
TELEMETRY = 3
14-
MMA = 4
13+
TELEMETRY = 0x03
14+
MMA = 0x04
15+
ACL = 0x05
1516

1617
def lpp_parse(buf):
1718
"""Parse a given byte string and return as a LppFrame object."""
@@ -48,6 +49,17 @@ def lpp_parse_mma (buf):
4849
})
4950
return res
5051

52+
def parse_acl (buf):
53+
i = 0
54+
res = []
55+
while i + 7 <= len(buf):
56+
key = buf[i:i+6].hex()
57+
perm = buf[i+6]
58+
if (key != "000000000000"):
59+
res.append({"key": key, "perm": perm})
60+
i = i + 7
61+
return res
62+
5163
class BinaryCommandHandler :
5264
""" Helper functions to handle binary requests through binary commands """
5365
def __init__ (self, c):
@@ -93,3 +105,12 @@ async def req_mma (self, contact, start, end) :
93105
return None
94106
else:
95107
return lpp_parse_mma(bytes.fromhex(res["data"])[4:])
108+
109+
async def req_acl (self, contact) :
110+
code = BinaryReqType.ACL.value
111+
req = code.to_bytes(1, 'little', signed=False) + b"\0\0"
112+
res = await self.req_binary(contact, req)
113+
if (res is None) :
114+
return None
115+
else:
116+
return parse_acl(bytes.fromhex(res['data']))

0 commit comments

Comments
 (0)