From 5668f2baa94d77efdd3f7dace205dc70fc7a9e00 Mon Sep 17 00:00:00 2001 From: C Freeman Date: Wed, 21 Jul 2021 00:33:55 -0400 Subject: [PATCH] Increase discover timeout for connect on controller (#8486) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 <66667989+Damian-Nordic@users.noreply.github.com> Co-authored-by: Damian Królik <66667989+Damian-Nordic@users.noreply.github.com> --- src/controller/python/chip-device-ctrl.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/controller/python/chip-device-ctrl.py b/src/controller/python/chip-device-ctrl.py index b380f63a790635..20fdbd218c2869 100755 --- a/src/controller/python/chip-device-ctrl.py +++ b/src/controller/python/chip-device-ctrl.py @@ -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'])) @@ -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.