Skip to content

Commit

Permalink
[Python] Drop deprecated discovery APIs (#33882)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
agners authored Jun 12, 2024
1 parent 2d97cda commit 61a2561
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 289 deletions.
77 changes: 0 additions & 77 deletions docs/testing/ChipDeviceCtrlAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.

<a id="chip.ChipDeviceCtrl.ChipDeviceControllerBase.DiscoverCommissionableNodesLongDiscriminator"></a>

#### DiscoverCommissionableNodesLongDiscriminator

```python
def DiscoverCommissionableNodesLongDiscriminator(long_discriminator)
```

Deprecated, use DiscoverCommissionableNodes

<a id="chip.ChipDeviceCtrl.ChipDeviceControllerBase.DiscoverCommissionableNodesShortDiscriminator"></a>

#### DiscoverCommissionableNodesShortDiscriminator

```python
def DiscoverCommissionableNodesShortDiscriminator(short_discriminator)
```

Deprecated, use DiscoverCommissionableNodes

<a id="chip.ChipDeviceCtrl.ChipDeviceControllerBase.DiscoverCommissionableNodesVendor"></a>

#### DiscoverCommissionableNodesVendor

```python
def DiscoverCommissionableNodesVendor(vendor)
```

Deprecated, use DiscoverCommissionableNodes

<a id="chip.ChipDeviceCtrl.ChipDeviceControllerBase.DiscoverCommissionableNodesDeviceType"></a>

#### DiscoverCommissionableNodesDeviceType

```python
def DiscoverCommissionableNodesDeviceType(device_type)
```

Deprecated, use DiscoverCommissionableNodes

<a id="chip.ChipDeviceCtrl.ChipDeviceControllerBase.DiscoverCommissionableNodesCommissioningEnabled"></a>

#### DiscoverCommissionableNodesCommissioningEnabled

```python
def DiscoverCommissionableNodesCommissioningEnabled()
```

Deprecated, use DiscoverCommissionableNodes

<a id="chip.ChipDeviceCtrl.ChipDeviceControllerBase.PrintDiscoveredDevices"></a>

#### PrintDiscoveredDevices

```python
def PrintDiscoveredDevices()
```

Deprecated, use GetCommissionableNodes

<a id="chip.ChipDeviceCtrl.ChipDeviceControllerBase.DiscoverAllCommissioning"></a>

#### DiscoverAllCommissioning

```python
def DiscoverAllCommissioning()
```

Deprecated, use DiscoverCommissionableNodes

<a id="chip.ChipDeviceCtrl.ChipDeviceControllerBase.OpenCommissioningWindow"></a>

#### OpenCommissioningWindow
Expand Down
60 changes: 0 additions & 60 deletions src/controller/python/ChipDeviceController-Discovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
53 changes: 0 additions & 53 deletions src/controller/python/ChipDeviceController-ScriptBinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);

Expand Down Expand Up @@ -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<uint64_t>(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)
Expand Down
99 changes: 0 additions & 99 deletions src/controller/python/chip/ChipDeviceCtrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit 61a2561

Please sign in to comment.