Skip to content

Commit ff787ba

Browse files
Merge branch 'master' into fix/917_ncp_init
2 parents 15f3212 + 36f81cd commit ff787ba

File tree

9 files changed

+69
-95
lines changed

9 files changed

+69
-95
lines changed

src/app/icd/client/CheckInDelegate.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ class DLL_EXPORT CheckInDelegate
7070
* @brief Callback used to let the application know that the re-registration process is done. This callback will be called for
7171
* both success and failure cases. On failure, the callee should take appropriate corrective action based on the error.
7272
*
73-
* @param[in] refreshKeySender - pointer to the RefreshKeySender object that was used for the key refresh process. The caller
74-
* will NOT use this pointer any more.
73+
* @param[in] refreshKeySender - pointer to the RefreshKeySender object that was used for the key refresh process. It will NOT
74+
* be null regardless the key refresh status. The caller will NOT use this pointer any more.
7575
* @param[in] error - CHIP_NO_ERROR indicates successful re-registration using the new key
7676
* Other errors indicate the failure reason.
7777
*/

src/app/icd/client/DefaultCheckInDelegate.cpp

+13-7
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,26 @@ RefreshKeySender * DefaultCheckInDelegate::OnKeyRefreshNeeded(ICDClientInfo & cl
6666

6767
void DefaultCheckInDelegate::OnKeyRefreshDone(RefreshKeySender * refreshKeySender, CHIP_ERROR error)
6868
{
69+
if (refreshKeySender == nullptr)
70+
{
71+
ChipLogError(ICD, "RefreshKeySender is null");
72+
return;
73+
}
74+
auto icdClientInfo = refreshKeySender->GetICDClientInfo();
75+
Platform::Delete(refreshKeySender);
76+
refreshKeySender = nullptr;
6977
if (error == CHIP_NO_ERROR)
7078
{
71-
ChipLogProgress(ICD, "Re-registration with new key completed successfully");
79+
ChipLogProgress(ICD, "Re-registration with new key completed successfully for peer node " ChipLogFormatScopedNodeId,
80+
ChipLogValueScopedNodeId(icdClientInfo.peer_node));
7281
}
7382
else
7483
{
75-
ChipLogError(ICD, "Re-registration with new key failed with error : %" CHIP_ERROR_FORMAT, error.Format());
84+
ChipLogError(
85+
ICD, "Re-registration with new key failed with error %" CHIP_ERROR_FORMAT " for peer node " ChipLogFormatScopedNodeId,
86+
error.Format(), ChipLogValueScopedNodeId(icdClientInfo.peer_node));
7687
// The callee can take corrective action based on the error received.
7788
}
78-
if (refreshKeySender != nullptr)
79-
{
80-
Platform::Delete(refreshKeySender);
81-
refreshKeySender = nullptr;
82-
}
8389
}
8490
} // namespace app
8591
} // namespace chip

src/app/icd/client/RefreshKeySender.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ RefreshKeySender::RefreshKeySender(CheckInDelegate * checkInDelegate, const ICDC
3636
mOnConnectedCallback(HandleDeviceConnected, this), mOnConnectionFailureCallback(HandleDeviceConnectionFailure, this)
3737
{}
3838

39+
const ICDClientInfo & RefreshKeySender::GetICDClientInfo()
40+
{
41+
return mICDClientInfo;
42+
}
43+
3944
CHIP_ERROR RefreshKeySender::RegisterClientWithNewKey(Messaging::ExchangeManager & exchangeMgr, const SessionHandle & sessionHandle)
4045
{
4146
auto onSuccess = [&](const ConcreteCommandPath & commandPath, const StatusIB & status, const auto & dataResponse) {

src/app/icd/client/RefreshKeySender.h

+8
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ class RefreshKeySender
5252
*/
5353
CHIP_ERROR EstablishSessionToPeer();
5454

55+
/**
56+
* @brief Used to retrieve ICDClientInfo from RefreshKeySender.
57+
*
58+
* @return ICDClientInfo - ICDClientInfo object representing the state associated with the
59+
node that requested a key refresh.
60+
*/
61+
const ICDClientInfo & GetICDClientInfo();
62+
5563
private:
5664
// CASE session callbacks
5765
/**

src/python_testing/TC_DGSW_2_1.py

-25
Original file line numberDiff line numberDiff line change
@@ -37,35 +37,10 @@
3737

3838
import chip.clusters as Clusters
3939
from chip.testing.matter_testing import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
40-
from mobly import asserts
4140

4241

4342
class TC_DGSW_2_1(MatterBaseTest):
4443

45-
@staticmethod
46-
def is_valid_uint64_value(value):
47-
return isinstance(value, int) and 0 <= value <= 0xFFFFFFFFFFFFFFFF
48-
49-
@staticmethod
50-
def is_valid_uint32_value(value):
51-
return isinstance(value, int) and 0 <= value <= 0xFFFFFFFF
52-
53-
@staticmethod
54-
def is_valid_str_value(value):
55-
return isinstance(value, str) and len(value) > 0
56-
57-
def assert_valid_uint64(self, value, field_name):
58-
"""Asserts that the value is a valid uint64."""
59-
asserts.assert_true(self.is_valid_uint64_value(value), f"{field_name} field should be a uint64 type")
60-
61-
def assert_valid_uint32(self, value, field_name):
62-
"""Asserts that the value is a valid uint32."""
63-
asserts.assert_true(self.is_valid_uint32_value(value), f"{field_name} field should be a uint32 type")
64-
65-
def assert_valid_str(self, value, field_name):
66-
"""Asserts that the value is a non-empty string."""
67-
asserts.assert_true(self.is_valid_str_value(value), f"{field_name} field should be a non-empty string")
68-
6944
async def read_dgsw_attribute_expect_success(self, endpoint, attribute):
7045
cluster = Clusters.Objects.SoftwareDiagnostics
7146
return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute)

src/python_testing/TC_DGSW_2_2.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@
4848

4949
class TC_DGSW_2_2(MatterBaseTest):
5050

51-
@staticmethod
52-
def is_valid_uint64_value(value):
53-
return isinstance(value, int) and 0 <= value <= 0xFFFFFFFFFFFFFFFF
54-
5551
@staticmethod
5652
def is_valid_octet_string(value):
5753
return isinstance(value, (bytes, bytearray))
@@ -71,7 +67,7 @@ def validate_soft_fault_event_data(self, event_data):
7167

7268
# Validate 'Id' field: Ensure it is a uint64 type
7369
asserts.assert_true(
74-
self.is_valid_uint64_value(event_data.id),
70+
self.is_valid_uint_value(event_data.id, bit_count=64),
7571
"The 'Id' field must be a uint64 type"
7672
)
7773

src/python_testing/TC_DGSW_2_3.py

-24
Original file line numberDiff line numberDiff line change
@@ -44,30 +44,6 @@
4444

4545
class TC_DGSW_2_3(MatterBaseTest):
4646

47-
@staticmethod
48-
def is_valid_uint64_value(value):
49-
return isinstance(value, int) and 0 <= value <= 0xFFFFFFFFFFFFFFFF
50-
51-
@staticmethod
52-
def is_valid_uint32_value(value):
53-
return isinstance(value, int) and 0 <= value <= 0xFFFFFFFF
54-
55-
@staticmethod
56-
def is_valid_str_value(value):
57-
return isinstance(value, str) and len(value) > 0
58-
59-
def assert_valid_uint64(self, value, field_name):
60-
"""Asserts that the value is a valid uint64."""
61-
asserts.assert_true(self.is_valid_uint64_value(value), f"{field_name} field should be a uint64 type")
62-
63-
def assert_valid_uint32(self, value, field_name):
64-
"""Asserts that the value is a valid uint32."""
65-
asserts.assert_true(self.is_valid_uint32_value(value), f"{field_name} field should be a uint32 type")
66-
67-
def assert_valid_str(self, value, field_name):
68-
"""Asserts that the value is a non-empty string."""
69-
asserts.assert_true(self.is_valid_str_value(value), f"{field_name} field should be a non-empty string")
70-
7147
async def read_dgsw_attribute_expect_success(self, endpoint, attribute):
7248
cluster = Clusters.Objects.SoftwareDiagnostics
7349
return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute)

src/python_testing/TC_DGWIFI_2_1.py

-32
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,6 @@ def is_valid_bssid(bssid) -> bool:
6363

6464
return False
6565

66-
@staticmethod
67-
def is_valid_uint_value(value, bit_count=64):
68-
"""
69-
Checks if 'value' is a non-negative integer fitting into 'bit_count' bits.
70-
For example, bit_count=32 => must fit within 0 <= value <= 0xFFFFFFFF
71-
"""
72-
if not isinstance(value, int):
73-
return False
74-
if value < 0:
75-
return False
76-
return value < 2**bit_count
77-
7866
def assert_valid_bssid(self, value, field_name):
7967
"""Asserts that the value is a valid BSSID (MAC address), None, or NullValue."""
8068
if isinstance(value, Nullable):
@@ -86,26 +74,6 @@ def assert_valid_bssid(self, value, field_name):
8674
asserts.assert_true(self.is_valid_bssid(value),
8775
f"{field_name} should be a valid BSSID string (e.g., '00:11:22:33:44:55') or None/NullValue.")
8876

89-
def assert_valid_uint64(self, value, field_name):
90-
"""Asserts that the value is a valid uint64 or None (if attribute can return NULL)."""
91-
asserts.assert_true(value is None or self.is_valid_uint_value(value, bit_count=64),
92-
f"{field_name} should be a uint64 or NULL.")
93-
94-
def assert_valid_uint32(self, value, field_name):
95-
"""Asserts that the value is a valid uint32 or None (if attribute can return NULL)."""
96-
asserts.assert_true(value is None or self.is_valid_uint_value(value, bit_count=32),
97-
f"{field_name} should be a uint32 or NULL.")
98-
99-
def assert_valid_uint16(self, value, field_name):
100-
"""Asserts that the value is a valid uint16 or None (if attribute can return NULL)."""
101-
asserts.assert_true(value is None or self.is_valid_uint_value(value, bit_count=16),
102-
f"{field_name} should be a uint16 or NULL.")
103-
104-
def assert_valid_uint8(self, value, field_name):
105-
"""Asserts that the value is a valid uint16 or None (if attribute can return NULL)."""
106-
asserts.assert_true(value is None or self.is_valid_uint_value(value, bit_count=8),
107-
f"{field_name} should be a uint8 or NULL.")
108-
10977
async def read_dgwifi_attribute_expect_success(self, endpoint, attribute):
11078
cluster = Clusters.Objects.WiFiNetworkDiagnostics
11179
return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute)

src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py

+40
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,46 @@ def __init__(self, *args):
972972
# The named pipe name must be set in the derived classes
973973
self.app_pipe = None
974974

975+
@staticmethod
976+
def is_valid_uint_value(value, bit_count=64):
977+
"""
978+
Checks if 'value' is a non-negative integer fitting into 'bit_count' bits.
979+
For example, bit_count=32 => must fit within 0 <= value <= 0xFFFFFFFF
980+
"""
981+
if not isinstance(value, int):
982+
return False
983+
if value < 0:
984+
return False
985+
return value < 2**bit_count
986+
987+
@staticmethod
988+
def is_valid_str_value(value):
989+
return isinstance(value, str) and len(value) > 0
990+
991+
def assert_valid_uint64(self, value, field_name):
992+
"""Asserts that the value is a valid uint64."""
993+
asserts.assert_true(self.is_valid_uint_value(value, bit_count=64),
994+
f"{field_name} should be a uint64 or NULL.")
995+
996+
def assert_valid_uint32(self, value, field_name):
997+
"""Asserts that the value is a valid uint32."""
998+
asserts.assert_true(self.is_valid_uint_value(value, bit_count=32),
999+
f"{field_name} should be a uint32 or NULL.")
1000+
1001+
def assert_valid_uint16(self, value, field_name):
1002+
"""Asserts that the value is a valid uint16."""
1003+
asserts.assert_true(self.is_valid_uint_value(value, bit_count=16),
1004+
f"{field_name} should be a uint16 or NULL.")
1005+
1006+
def assert_valid_uint8(self, value, field_name):
1007+
"""Asserts that the value is a valid uint16."""
1008+
asserts.assert_true(self.is_valid_uint_value(value, bit_count=8),
1009+
f"{field_name} should be a uint8 or NULL.")
1010+
1011+
def assert_valid_str(self, value, field_name):
1012+
"""Asserts that the value is a non-empty string."""
1013+
asserts.assert_true(self.is_valid_str_value(value), f"{field_name} field should be a non-empty string")
1014+
9751015
def get_test_steps(self, test: str) -> list[TestStep]:
9761016
''' Retrieves the test step list for the given test
9771017

0 commit comments

Comments
 (0)