mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-04-20 22:13:49 +00:00
override timeout for contact
This commit is contained in:
parent
9d64ff8278
commit
837ff3af89
2 changed files with 9 additions and 9 deletions
|
|
@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "meshcore"
|
name = "meshcore"
|
||||||
version = "1.9.15"
|
version = "1.9.16"
|
||||||
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" },
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ class BinaryCommandHandler :
|
||||||
def dispatcher(self):
|
def dispatcher(self):
|
||||||
return self.commands.dispatcher
|
return self.commands.dispatcher
|
||||||
|
|
||||||
async def req_binary (self, contact, request) :
|
async def req_binary (self, contact, request, timeout_override=0) :
|
||||||
res = await self.commands.send_binary_req(contact, request)
|
res = await self.commands.send_binary_req(contact, request)
|
||||||
logger.debug(res)
|
logger.debug(res)
|
||||||
if res.type == EventType.ERROR:
|
if res.type == EventType.ERROR:
|
||||||
|
|
@ -77,7 +77,7 @@ class BinaryCommandHandler :
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
exp_tag = res.payload["expected_ack"].hex()
|
exp_tag = res.payload["expected_ack"].hex()
|
||||||
timeout = res.payload["suggested_timeout"] / 1000
|
timeout = res.payload["suggested_timeout"]/800 if timeout_override == 0 else timeout_override
|
||||||
res2 = await self.dispatcher.wait_for_event(EventType.BINARY_RESPONSE, attribute_filters={"tag": exp_tag}, timeout=timeout)
|
res2 = await self.dispatcher.wait_for_event(EventType.BINARY_RESPONSE, attribute_filters={"tag": exp_tag}, timeout=timeout)
|
||||||
logger.debug(res2)
|
logger.debug(res2)
|
||||||
if res2 is None :
|
if res2 is None :
|
||||||
|
|
@ -85,31 +85,31 @@ class BinaryCommandHandler :
|
||||||
else:
|
else:
|
||||||
return res2.payload
|
return res2.payload
|
||||||
|
|
||||||
async def req_telemetry (self, contact) :
|
async def req_telemetry (self, contact, timeout_override=0) :
|
||||||
code = BinaryReqType.TELEMETRY.value
|
code = BinaryReqType.TELEMETRY.value
|
||||||
req = code.to_bytes(1, 'little', signed=False)
|
req = code.to_bytes(1, 'little', signed=False)
|
||||||
res = await self.req_binary(contact, req)
|
res = await self.req_binary(contact, req, timeout_override)
|
||||||
if (res is None) :
|
if (res is None) :
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
return lpp_parse(bytes.fromhex(res["data"]))
|
return lpp_parse(bytes.fromhex(res["data"]))
|
||||||
|
|
||||||
async def req_mma (self, contact, start, end) :
|
async def req_mma (self, contact, start, end, timeout_override=0) :
|
||||||
code = BinaryReqType.MMA.value
|
code = BinaryReqType.MMA.value
|
||||||
req = code.to_bytes(1, 'little', signed=False)\
|
req = code.to_bytes(1, 'little', signed=False)\
|
||||||
+ start.to_bytes(4, 'little', signed = False)\
|
+ start.to_bytes(4, 'little', signed = False)\
|
||||||
+ end.to_bytes(4, 'little', signed=False)\
|
+ end.to_bytes(4, 'little', signed=False)\
|
||||||
+ b"\0\0"
|
+ b"\0\0"
|
||||||
res = await self.req_binary(contact, req)
|
res = await self.req_binary(contact, req, timeout_override)
|
||||||
if (res is None) :
|
if (res is None) :
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
return lpp_parse_mma(bytes.fromhex(res["data"])[4:])
|
return lpp_parse_mma(bytes.fromhex(res["data"])[4:])
|
||||||
|
|
||||||
async def req_acl (self, contact) :
|
async def req_acl (self, contact, timeout_override=0) :
|
||||||
code = BinaryReqType.ACL.value
|
code = BinaryReqType.ACL.value
|
||||||
req = code.to_bytes(1, 'little', signed=False) + b"\0\0"
|
req = code.to_bytes(1, 'little', signed=False) + b"\0\0"
|
||||||
res = await self.req_binary(contact, req)
|
res = await self.req_binary(contact, req, timeout_override)
|
||||||
if (res is None) :
|
if (res is None) :
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue