Skip to content

Commit

Permalink
[Python] call StopDiscovery after DiscoveryNodes
Browse files Browse the repository at this point in the history
  • Loading branch information
tianfeng-yang committed Jan 26, 2024
1 parent 32da87c commit f349a72
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/controller/python/ChipDeviceController-Discovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ PyChipError pychip_DeviceController_DiscoverCommissionableNodes(Controller::Devi
return ToPyChipError(devCtrl->DiscoverCommissionableNodes(filter));
}

PyChipError pychip_DeviceController_StopCommissionableDiscovery(Controller::DeviceCommissioner * devCtrl)
{
return ToPyChipError(devCtrl->StopCommissionableDiscovery());
}

void pychip_DeviceController_IterateDiscoveredCommissionableNodes(Controller::DeviceCommissioner * devCtrl,
IterateDiscoveredCommissionableNodesFunct cb)
{
Expand Down
7 changes: 7 additions & 0 deletions src/controller/python/chip/ChipDeviceCtrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,9 @@ def DiscoverCommissionableNodes(self, filterType: discovery.FilterType = discove
else:
time.sleep(timeoutSecond)

self._ChipStack.Call(
lambda: self._dmLib.pychip_DeviceController_StopCommissionableDiscovery(self.devCtrl)).raise_on_error()

return self.GetDiscoveredDevices()

def DiscoverCommissionableNodesLongDiscriminator(self, long_discriminator):
Expand Down Expand Up @@ -1567,6 +1570,10 @@ def _InitLib(self):
c_void_p, c_uint8, c_char_p]
self._dmLib.pychip_DeviceController_DiscoverCommissionableNodes.restype = PyChipError

self._dmLib.pychip_DeviceController_StopCommissionableDiscovery.argtypes = [
c_void_p]
self._dmLib.pychip_DeviceController_StopCommissionableDiscovery.restype = PyChipError

self._dmLib.pychip_DeviceController_DiscoverCommissionableNodesLongDiscriminator.argtypes = [
c_void_p, c_uint16]
self._dmLib.pychip_DeviceController_DiscoverCommissionableNodesLongDiscriminator.restype = PyChipError
Expand Down

0 comments on commit f349a72

Please sign in to comment.