From 24107049810558949154e9d5c05d6554406bd1a4 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Wed, 12 Jun 2024 19:49:51 +0200 Subject: [PATCH] [Python] Drop deprecated discovery APIs (#33882) This change removes the deprecated discovery APIs from the Python controller. The APIs that are removed are: - DiscoverCommissionableNodesLongDiscriminator - DiscoverCommissionableNodesShortDiscriminator - DiscoverCommissionableNodesVendor - DiscoverCommissionableNodesDeviceType - DiscoverCommissionableNodesCommissioningEnabled - PrintDiscoveredDevices - DiscoverAllCommissioning All these APIs can be replaced with the DiscoverCommissionableNodes and the appropriate filter flags. --- docs/testing/ChipDeviceCtrlAPI.md | 77 --------------- .../python/ChipDeviceController-Discovery.cpp | 60 ----------- .../ChipDeviceController-ScriptBinding.cpp | 53 ---------- src/controller/python/chip/ChipDeviceCtrl.py | 99 ------------------- 4 files changed, 289 deletions(-) diff --git a/docs/testing/ChipDeviceCtrlAPI.md b/docs/testing/ChipDeviceCtrlAPI.md index 944c787d647207..b1111aada5772f 100644 --- a/docs/testing/ChipDeviceCtrlAPI.md +++ b/docs/testing/ChipDeviceCtrlAPI.md @@ -10,13 +10,6 @@ - [ShutdownAll](#shutdownall) - [ExpireSessions](#expiresessions) - [DiscoverCommissionableNodes](#discovercommissionablenodes) - - [DiscoverCommissionableNodesLongDiscriminator](#discovercommissionablenodeslongdiscriminator) - - [DiscoverCommissionableNodesShortDiscriminator](#discovercommissionablenodesshortdiscriminator) - - [DiscoverCommissionableNodesVendor](#discovercommissionablenodesvendor) - - [DiscoverCommissionableNodesDeviceType](#discovercommissionablenodesdevicetype) - - [DiscoverCommissionableNodesCommissioningEnabled](#discovercommissionablenodescommissioningenabled) - - [PrintDiscoveredDevices](#printdiscovereddevices) - - [DiscoverAllCommissioning](#discoverallcommissioning) - [OpenCommissioningWindow](#opencommissioningwindow) - [GetFabricIdInternal](#getfabricidinternal) - [GetNodeIdInternal](#getnodeidinternal) @@ -174,76 +167,6 @@ This function will always return a list of CommissionableDevice. When stopOnFirst is set, this function will return when at least one device is discovered or on timeout. - - -#### DiscoverCommissionableNodesLongDiscriminator - -```python -def DiscoverCommissionableNodesLongDiscriminator(long_discriminator) -``` - -Deprecated, use DiscoverCommissionableNodes - - - -#### DiscoverCommissionableNodesShortDiscriminator - -```python -def DiscoverCommissionableNodesShortDiscriminator(short_discriminator) -``` - -Deprecated, use DiscoverCommissionableNodes - - - -#### DiscoverCommissionableNodesVendor - -```python -def DiscoverCommissionableNodesVendor(vendor) -``` - -Deprecated, use DiscoverCommissionableNodes - - - -#### DiscoverCommissionableNodesDeviceType - -```python -def DiscoverCommissionableNodesDeviceType(device_type) -``` - -Deprecated, use DiscoverCommissionableNodes - - - -#### DiscoverCommissionableNodesCommissioningEnabled - -```python -def DiscoverCommissionableNodesCommissioningEnabled() -``` - -Deprecated, use DiscoverCommissionableNodes - - - -#### PrintDiscoveredDevices - -```python -def PrintDiscoveredDevices() -``` - -Deprecated, use GetCommissionableNodes - - - -#### DiscoverAllCommissioning - -```python -def DiscoverAllCommissioning() -``` - -Deprecated, use DiscoverCommissionableNodes - #### OpenCommissioningWindow diff --git a/src/controller/python/ChipDeviceController-Discovery.cpp b/src/controller/python/ChipDeviceController-Discovery.cpp index 4ad6db56bf6739..46f0729d61243c 100644 --- a/src/controller/python/ChipDeviceController-Discovery.cpp +++ b/src/controller/python/ChipDeviceController-Discovery.cpp @@ -169,66 +169,6 @@ void pychip_DeviceController_IterateDiscoveredCommissionableNodes(Controller::De } } -void pychip_DeviceController_PrintDiscoveredDevices(Controller::DeviceCommissioner * devCtrl) -{ - for (int i = 0; i < devCtrl->GetMaxCommissionableNodesSupported(); ++i) - { - const Dnssd::CommissionNodeData * dnsSdInfo = devCtrl->GetDiscoveredDevice(i); - if (dnsSdInfo == nullptr) - { - continue; - } - char rotatingId[Dnssd::kMaxRotatingIdLen * 2 + 1] = ""; - Encoding::BytesToUppercaseHexString(dnsSdInfo->rotatingId, dnsSdInfo->rotatingIdLen, rotatingId, sizeof(rotatingId)); - - ChipLogProgress(Discovery, "Commissionable Node %d", i); - ChipLogProgress(Discovery, "\tInstance name:\t\t%s", dnsSdInfo->instanceName); - ChipLogProgress(Discovery, "\tHost name:\t\t%s", dnsSdInfo->hostName); - ChipLogProgress(Discovery, "\tPort:\t\t\t%u", dnsSdInfo->port); - ChipLogProgress(Discovery, "\tLong discriminator:\t%u", dnsSdInfo->longDiscriminator); - ChipLogProgress(Discovery, "\tVendor ID:\t\t%u", dnsSdInfo->vendorId); - ChipLogProgress(Discovery, "\tProduct ID:\t\t%u", dnsSdInfo->productId); - ChipLogProgress(Discovery, "\tCommissioning Mode\t%u", dnsSdInfo->commissioningMode); - ChipLogProgress(Discovery, "\tDevice Type\t\t%u", dnsSdInfo->deviceType); - ChipLogProgress(Discovery, "\tDevice Name\t\t%s", dnsSdInfo->deviceName); - ChipLogProgress(Discovery, "\tRotating Id\t\t%s", rotatingId); - ChipLogProgress(Discovery, "\tPairing Instruction\t%s", dnsSdInfo->pairingInstruction); - ChipLogProgress(Discovery, "\tPairing Hint\t\t%u", dnsSdInfo->pairingHint); - - auto idleInterval = dnsSdInfo->GetMrpRetryIntervalIdle(); - if (idleInterval.has_value()) - { - ChipLogProgress(Discovery, "\tMrp Interval idle\t%u", idleInterval->count()); - } - else - { - ChipLogProgress(Discovery, "\tMrp Interval idle\tNot present"); - } - - auto activeInterval = dnsSdInfo->GetMrpRetryIntervalActive(); - if (activeInterval.has_value()) - { - ChipLogProgress(Discovery, "\tMrp Interval active\t%u", activeInterval->count()); - } - else - { - ChipLogProgress(Discovery, "\tMrp Interval active\tNot present"); - } - - ChipLogProgress(Discovery, "\tSupports TCP\t\t%d", dnsSdInfo->supportsTcp); - if (dnsSdInfo->isICDOperatingAsLIT.has_value()) - { - ChipLogProgress(Discovery, "\tICD is operating as a\t%s", *(dnsSdInfo->isICDOperatingAsLIT) ? "LIT" : "SIT"); - } - for (unsigned j = 0; j < dnsSdInfo->numIPs; ++j) - { - char buf[Inet::IPAddress::kMaxStringLength]; - dnsSdInfo->ipAddress[j].ToString(buf); - ChipLogProgress(Discovery, "\tAddress %d:\t\t%s", j, buf); - } - } -} - bool pychip_DeviceController_GetIPForDiscoveredDevice(Controller::DeviceCommissioner * devCtrl, int idx, char * addrStr, uint32_t len) { diff --git a/src/controller/python/ChipDeviceController-ScriptBinding.cpp b/src/controller/python/ChipDeviceController-ScriptBinding.cpp index 821b2a34e03b60..2086b50dc7fea5 100644 --- a/src/controller/python/ChipDeviceController-ScriptBinding.cpp +++ b/src/controller/python/ChipDeviceController-ScriptBinding.cpp @@ -166,18 +166,6 @@ PyChipError pychip_DeviceController_EstablishPASESession(chip::Controller::Devic chip::NodeId nodeid); PyChipError pychip_DeviceController_Commission(chip::Controller::DeviceCommissioner * devCtrl, chip::NodeId nodeid); -PyChipError pychip_DeviceController_DiscoverCommissionableNodesLongDiscriminator(chip::Controller::DeviceCommissioner * devCtrl, - uint16_t long_discriminator); -PyChipError pychip_DeviceController_DiscoverAllCommissionableNodes(chip::Controller::DeviceCommissioner * devCtrl); - -PyChipError pychip_DeviceController_DiscoverCommissionableNodesShortDiscriminator(chip::Controller::DeviceCommissioner * devCtrl, - uint16_t short_discriminator); -PyChipError pychip_DeviceController_DiscoverCommissionableNodesVendor(chip::Controller::DeviceCommissioner * devCtrl, - uint16_t vendor); -PyChipError pychip_DeviceController_DiscoverCommissionableNodesDeviceType(chip::Controller::DeviceCommissioner * devCtrl, - uint16_t device_type); -PyChipError pychip_DeviceController_DiscoverCommissionableNodesCommissioningEnabled(chip::Controller::DeviceCommissioner * devCtrl); - PyChipError pychip_DeviceController_OnNetworkCommission(chip::Controller::DeviceCommissioner * devCtrl, chip::Controller::ScriptDevicePairingDelegate * pairingDelegate, uint64_t nodeId, uint32_t setupPasscode, const uint8_t filterType, @@ -190,7 +178,6 @@ PyChipError pychip_DeviceController_OpenCommissioningWindow(chip::Controller::De chip::NodeId nodeid, uint16_t timeout, uint32_t iteration, uint16_t discriminator, uint8_t optionInt); -void pychip_DeviceController_PrintDiscoveredDevices(chip::Controller::DeviceCommissioner * devCtrl); bool pychip_DeviceController_GetIPForDiscoveredDevice(chip::Controller::DeviceCommissioner * devCtrl, int idx, char * addrStr, uint32_t len); @@ -696,46 +683,6 @@ PyChipError pychip_DeviceController_Commission(chip::Controller::DeviceCommissio return ToPyChipError(devCtrl->Commission(nodeid, params)); } -PyChipError pychip_DeviceController_DiscoverAllCommissionableNodes(chip::Controller::DeviceCommissioner * devCtrl) -{ - Dnssd::DiscoveryFilter filter(Dnssd::DiscoveryFilterType::kNone, static_cast(0)); - return ToPyChipError(devCtrl->DiscoverCommissionableNodes(filter)); -} - -PyChipError pychip_DeviceController_DiscoverCommissionableNodesLongDiscriminator(chip::Controller::DeviceCommissioner * devCtrl, - uint16_t long_discriminator) -{ - Dnssd::DiscoveryFilter filter(Dnssd::DiscoveryFilterType::kLongDiscriminator, long_discriminator); - return ToPyChipError(devCtrl->DiscoverCommissionableNodes(filter)); -} - -PyChipError pychip_DeviceController_DiscoverCommissionableNodesShortDiscriminator(chip::Controller::DeviceCommissioner * devCtrl, - uint16_t short_discriminator) -{ - Dnssd::DiscoveryFilter filter(Dnssd::DiscoveryFilterType::kShortDiscriminator, short_discriminator); - return ToPyChipError(devCtrl->DiscoverCommissionableNodes(filter)); -} - -PyChipError pychip_DeviceController_DiscoverCommissionableNodesVendor(chip::Controller::DeviceCommissioner * devCtrl, - uint16_t vendor) -{ - Dnssd::DiscoveryFilter filter(Dnssd::DiscoveryFilterType::kVendorId, vendor); - return ToPyChipError(devCtrl->DiscoverCommissionableNodes(filter)); -} - -PyChipError pychip_DeviceController_DiscoverCommissionableNodesDeviceType(chip::Controller::DeviceCommissioner * devCtrl, - uint16_t device_type) -{ - Dnssd::DiscoveryFilter filter(Dnssd::DiscoveryFilterType::kDeviceType, device_type); - return ToPyChipError(devCtrl->DiscoverCommissionableNodes(filter)); -} - -PyChipError pychip_DeviceController_DiscoverCommissionableNodesCommissioningEnabled(chip::Controller::DeviceCommissioner * devCtrl) -{ - Dnssd::DiscoveryFilter filter(Dnssd::DiscoveryFilterType::kCommissioningMode); - return ToPyChipError(devCtrl->DiscoverCommissionableNodes(filter)); -} - PyChipError pychip_ScriptDevicePairingDelegate_SetOpenWindowCompleteCallback( chip::Controller::ScriptDevicePairingDelegate * pairingDelegate, chip::Controller::DevicePairingDelegate_OnWindowOpenCompleteFunct callback) diff --git a/src/controller/python/chip/ChipDeviceCtrl.py b/src/controller/python/chip/ChipDeviceCtrl.py index aca971e5d392f1..e9ff7280d9a31d 100644 --- a/src/controller/python/chip/ChipDeviceCtrl.py +++ b/src/controller/python/chip/ChipDeviceCtrl.py @@ -709,66 +709,6 @@ def DiscoverCommissionableNodes(self, filterType: discovery.FilterType = discove return self.GetDiscoveredDevices() - def DiscoverCommissionableNodesLongDiscriminator(self, long_discriminator): - ''' Deprecated, use DiscoverCommissionableNodes - ''' - self.CheckIsActive() - - self._ChipStack.Call( - lambda: self._dmLib.pychip_DeviceController_DiscoverCommissionableNodesLongDiscriminator( - self.devCtrl, long_discriminator) - ).raise_on_error() - - def DiscoverCommissionableNodesShortDiscriminator(self, short_discriminator): - ''' Deprecated, use DiscoverCommissionableNodes - ''' - self.CheckIsActive() - - self._ChipStack.Call( - lambda: self._dmLib.pychip_DeviceController_DiscoverCommissionableNodesShortDiscriminator( - self.devCtrl, short_discriminator) - ).raise_on_error() - - def DiscoverCommissionableNodesVendor(self, vendor): - ''' Deprecated, use DiscoverCommissionableNodes - ''' - self.CheckIsActive() - - self._ChipStack.Call( - lambda: self._dmLib.pychip_DeviceController_DiscoverCommissionableNodesVendor( - self.devCtrl, vendor) - ).raise_on_error() - - def DiscoverCommissionableNodesDeviceType(self, device_type): - ''' Deprecated, use DiscoverCommissionableNodes - ''' - self.CheckIsActive() - - self._ChipStack.Call( - lambda: self._dmLib.pychip_DeviceController_DiscoverCommissionableNodesDeviceType( - self.devCtrl, device_type) - ).raise_on_error() - - def DiscoverCommissionableNodesCommissioningEnabled(self): - ''' Deprecated, use DiscoverCommissionableNodes - ''' - self.CheckIsActive() - - self._ChipStack.Call( - lambda: self._dmLib.pychip_DeviceController_DiscoverCommissionableNodesCommissioningEnabled( - self.devCtrl) - ).raise_on_error() - - def PrintDiscoveredDevices(self): - ''' Deprecated, use GetCommissionableNodes - ''' - self.CheckIsActive() - - self._ChipStack.Call( - lambda: self._dmLib.pychip_DeviceController_PrintDiscoveredDevices( - self.devCtrl) - ) - def GetDiscoveredDevices(self): def GetDevices(devCtrl): devices = [] @@ -793,16 +733,6 @@ def GetIPForDiscoveredDevice(self, idx, addrStr, length): self.devCtrl, idx, addrStr, length) ) - def DiscoverAllCommissioning(self): - ''' Deprecated, use DiscoverCommissionableNodes - ''' - self.CheckIsActive() - - self._ChipStack.Call( - lambda: self._dmLib.pychip_DeviceController_DiscoverAllCommissionableNodes( - self.devCtrl) - ).raise_on_error() - class CommissioningWindowPasscode(enum.IntEnum): kOriginalSetupCode = 0, kTokenWithRandomPin = 1, @@ -1669,26 +1599,6 @@ def _InitLib(self): 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 - - self._dmLib.pychip_DeviceController_DiscoverCommissionableNodesShortDiscriminator.argtypes = [ - c_void_p, c_uint16] - self._dmLib.pychip_DeviceController_DiscoverCommissionableNodesShortDiscriminator.restype = PyChipError - - self._dmLib.pychip_DeviceController_DiscoverCommissionableNodesVendor.argtypes = [ - c_void_p, c_uint16] - self._dmLib.pychip_DeviceController_DiscoverCommissionableNodesVendor.restype = PyChipError - - self._dmLib.pychip_DeviceController_DiscoverCommissionableNodesDeviceType.argtypes = [ - c_void_p, c_uint16] - self._dmLib.pychip_DeviceController_DiscoverCommissionableNodesDeviceType.restype = PyChipError - - self._dmLib.pychip_DeviceController_DiscoverCommissionableNodesCommissioningEnabled.argtypes = [ - c_void_p] - self._dmLib.pychip_DeviceController_DiscoverCommissionableNodesCommissioningEnabled.restype = PyChipError - self._dmLib.pychip_DeviceController_EstablishPASESessionIP.argtypes = [ c_void_p, c_char_p, c_uint32, c_uint64, c_uint16] self._dmLib.pychip_DeviceController_EstablishPASESessionIP.restype = PyChipError @@ -1701,15 +1611,6 @@ def _InitLib(self): c_void_p, c_char_p, c_uint64] self._dmLib.pychip_DeviceController_EstablishPASESession.restype = PyChipError - self._dmLib.pychip_DeviceController_DiscoverAllCommissionableNodes.argtypes = [ - c_void_p] - self._dmLib.pychip_DeviceController_DiscoverAllCommissionableNodes.restype = PyChipError - - self._dmLib.pychip_DeviceController_PrintDiscoveredDevices.argtypes = [ - c_void_p] - self._dmLib.pychip_DeviceController_PrintDiscoveredDevices.argtypes = [ - c_void_p, _ChipDeviceController_IterateDiscoveredCommissionableNodesFunct] - self._dmLib.pychip_DeviceController_HasDiscoveredCommissionableNode.argtypes = [c_void_p] self._dmLib.pychip_DeviceController_HasDiscoveredCommissionableNode.restype = c_bool