Skip to content

Commit

Permalink
Set 5sec. timeout when using CoAP
Browse files Browse the repository at this point in the history
Issue: #60
  • Loading branch information
rgerganov committed Sep 28, 2020
1 parent 5c303e2 commit da12c0d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pyairctrl/coap_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@ def _create_coap_client(self, host, port):

def _sync(self):
self.syncrequest = binascii.hexlify(os.urandom(4)).decode("utf8").upper()
self.client_key = self.client.post("/sys/dev/sync", self.syncrequest).payload
resp = self.client.post("/sys/dev/sync", self.syncrequest, timeout=5)
if resp:
self.client_key = resp.payload
else:
self.client.stop()
raise Exception("sync timeout")

def _decrypt_payload(self, encrypted_payload):
encoded_counter = encrypted_payload[0:8]
Expand Down

0 comments on commit da12c0d

Please sign in to comment.