Skip to content

Commit

Permalink
Add rotating ID to python discovery logic and support it in tests (pr…
Browse files Browse the repository at this point in the history
  • Loading branch information
andy31415 authored Feb 6, 2023
1 parent 2ec13fb commit e5842df
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 21 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 @@ -139,6 +139,11 @@ void pychip_DeviceController_IterateDiscoveredCommissionableNodes(Controller::De
}
jsonVal["addresses"] = addresses;
}
if (dnsSdInfo->commissionData.rotatingIdLen > 0)
{
jsonVal["rotatingId"] = std::string(reinterpret_cast<const char *>(dnsSdInfo->commissionData.rotatingId),
dnsSdInfo->commissionData.rotatingIdLen);
}

{
auto str = jsonVal.toStyledString();
Expand Down
3 changes: 2 additions & 1 deletion src/controller/python/chip/discovery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import threading
import time
from dataclasses import dataclass
from typing import Callable, List, Set
from typing import Callable, List, Optional, Set

from chip.discovery.library_handle import _GetDiscoveryLibraryHandle
from chip.discovery.types import DiscoverFailureCallback_t, DiscoverSuccessCallback_t
Expand Down Expand Up @@ -87,6 +87,7 @@ class CommissionableNode():
mrpRetryIntervalActive: int = None
supportsTcp: bool = None
addresses: List[str] = None
rotatingId: Optional[str] = None


# Milliseconds to wait for additional results onece a single result has
Expand Down
22 changes: 2 additions & 20 deletions src/controller/python/chip/yaml/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,23 +754,6 @@ def decode(self, result: _ActionResult):
return decoded_response

if isinstance(response, chip.discovery.CommissionableNode):
# CommissionableNode(
# instanceName='04DD55352DD2AC53',
# hostName='E6A32C6DBA8D0000',
# port=5540,
# longDiscriminator=3840,
# vendorId=65521,
# productId=32769,
# commissioningMode=1,
# deviceType=0,
# deviceName='',
# pairingInstruction='',
# pairingHint=36,
# mrpRetryIntervalIdle=None,
# mrpRetryIntervalActive=None,
# supportsTcp=True,
# addresses=['fd00:0:1:1::3', '10.10.10.1']
# ), ...
decoded_response['value'] = {
'instanceName': response.instanceName,
'hostName': response.hostName,
Expand All @@ -787,11 +770,10 @@ def decode(self, result: _ActionResult):
'mrpRetryIntervalActive': response.mrpRetryIntervalActive,
'supportsTcp': response.supportsTcp,
'addresses': response.addresses,

# TODO: NOT AVAILABLE
'rotatingIdLen': 0,
'rotatingId': response.rotatingId,

# derived values
'rotatingIdLen': 0 if not response.rotatingId else len(response.rotatingId),
'numIPs': len(response.addresses),

}
Expand Down

0 comments on commit e5842df

Please sign in to comment.