Skip to content

Commit

Permalink
Increase discover timeout for connect on controller (project-chip#8486)
Browse files Browse the repository at this point in the history
* Increase discover timeout for connect on controller

Normally the connect timeout is sufficient, but it looks like the
platform mdns impl changed. Increasing the timeout and just using
the wait function that discover uses.

* Update src/controller/python/chip-device-ctrl.py

Co-authored-by: Damian Królik <[email protected]>

Co-authored-by: Damian Królik <[email protected]>
  • Loading branch information
2 people authored and Nikita committed Sep 23, 2021
1 parent 773c427 commit 5668f2b
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/controller/python/chip-device-ctrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,18 +448,10 @@ def ConnectFromSetupPayload(self, setupPayload, nodeid):
print("Waiting for device responses...")
strlen = 100;
addrStrStorage = ctypes.create_string_buffer(strlen)
count = 0
# If this device is on the network and we're looking specifically for 1 device,
# expect a quick response.
maxWaitTime = 1
ok = False
while count < maxWaitTime:
ok = self.devCtrl.GetIPForDiscoveredDevice(0, addrStrStorage, strlen)
if ok:
break
time.sleep(0.2)
count = count + 0.2
if ok:
if self.wait_for_one_discovered_device():
self.devCtrl.GetIPForDiscoveredDevice(0, addrStrStorage, strlen)
addrStr = addrStrStorage.value.decode('utf-8')
print("Connecting to device at " + addrStr)
pincode = ctypes.c_uint32(int(setupPayload.attributes['SetUpPINCode']))
Expand Down Expand Up @@ -578,6 +570,7 @@ def wait_for_one_discovered_device(self):
while (not self.devCtrl.GetIPForDiscoveredDevice(0, addrStrStorage, strlen) and count < maxWaitTime):
time.sleep(0.2)
count = count + 0.2
return count < maxWaitTime

def wait_for_many_discovered_devices(self):
# Discovery happens through mdns, which means we need to wait for responses to come back.
Expand Down

0 comments on commit 5668f2b

Please sign in to comment.