mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-04-20 22:13:49 +00:00
req_acl
This commit is contained in:
parent
f190b60426
commit
9d64ff8278
1 changed files with 23 additions and 2 deletions
|
|
@ -10,8 +10,9 @@ from meshcore.lpp_json_encoder import lpp_json_encoder, my_lpp_types, lpp_format
|
|||
logger = logging.getLogger("meshcore")
|
||||
|
||||
class BinaryReqType(Enum):
|
||||
TELEMETRY = 3
|
||||
MMA = 4
|
||||
TELEMETRY = 0x03
|
||||
MMA = 0x04
|
||||
ACL = 0x05
|
||||
|
||||
def lpp_parse(buf):
|
||||
"""Parse a given byte string and return as a LppFrame object."""
|
||||
|
|
@ -48,6 +49,17 @@ def lpp_parse_mma (buf):
|
|||
})
|
||||
return res
|
||||
|
||||
def parse_acl (buf):
|
||||
i = 0
|
||||
res = []
|
||||
while i + 7 <= len(buf):
|
||||
key = buf[i:i+6].hex()
|
||||
perm = buf[i+6]
|
||||
if (key != "000000000000"):
|
||||
res.append({"key": key, "perm": perm})
|
||||
i = i + 7
|
||||
return res
|
||||
|
||||
class BinaryCommandHandler :
|
||||
""" Helper functions to handle binary requests through binary commands """
|
||||
def __init__ (self, c):
|
||||
|
|
@ -93,3 +105,12 @@ class BinaryCommandHandler :
|
|||
return None
|
||||
else:
|
||||
return lpp_parse_mma(bytes.fromhex(res["data"])[4:])
|
||||
|
||||
async def req_acl (self, contact) :
|
||||
code = BinaryReqType.ACL.value
|
||||
req = code.to_bytes(1, 'little', signed=False) + b"\0\0"
|
||||
res = await self.req_binary(contact, req)
|
||||
if (res is None) :
|
||||
return None
|
||||
else:
|
||||
return parse_acl(bytes.fromhex(res['data']))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue