Skip to content

Commit

Permalink
Merge branch 'master' into camera-webrtc-server
Browse files Browse the repository at this point in the history
  • Loading branch information
gmarcosb authored Jan 22, 2025
2 parents 3a49dbe + c530e45 commit d3f5a3b
Show file tree
Hide file tree
Showing 12 changed files with 86 additions and 98 deletions.
14 changes: 14 additions & 0 deletions data_model/1.4/clusters/EcosystemInformationCluster.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,18 @@ Davis, CA 95616, USA
<access fabricScoped="true"/>
</struct>
</dataTypes>
<attributes>
<attribute id="0x0000" name="DeviceDirectory" type="list">
<entry type="EcosystemDeviceStruct"/>
<access read="true" readPrivilege="manage" fabricScoped="true"/>
<quality changeOmitted="false" nullable="false" scene="false" persistence="nonVolatile" reportable="false" sourceAttribution="false" quieterReporting="false"/>
<mandatoryConform/>
</attribute>
<attribute id="0x0001" name="LocationDirectory" type="list">
<entry type="EcosystemLocationStruct"/>
<access read="true" readPrivilege="manage" fabricScoped="true"/>
<quality changeOmitted="false" nullable="false" scene="false" persistence="nonVolatile" reportable="false" sourceAttribution="false" quieterReporting="false"/>
<mandatoryConform/>
</attribute>
</attributes>
</cluster>
2 changes: 1 addition & 1 deletion data_model/1.4/spec_sha
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3d8fc9ae05045a53fdaffd7e3593f92a48b10e30
21812107312887c416632ed6dd2399af1f077548
4 changes: 2 additions & 2 deletions scripts/dm_xml_ci_change_enforcement.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ def check_dm_directory(dir):

def check_dir(dir):
cmd = f'git diff HEAD^..HEAD --name-only -- {dir}'
output = subprocess.check_output(cmd, shell=True).decode().splitlines()
output = subprocess.check_output(cmd, shell=True).decode()
if output and 'spec_sha' not in output and 'scraper_version' not in output:
print(f'Data model directory {dir} had changes to the following files without a corresponding update to the spec SHA')
print(output)
print("Note that the data_model directory files are automatically updated by a spec scraper and should not be manually updated.")
return 1
return 0

ret = check_dir(clusters) + check_dir(device_types)
ret = check_dir(dir)
sys.exit(ret)


Expand Down
4 changes: 2 additions & 2 deletions src/app/icd/client/CheckInDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ class DLL_EXPORT CheckInDelegate
* @brief Callback used to let the application know that the re-registration process is done. This callback will be called for
* both success and failure cases. On failure, the callee should take appropriate corrective action based on the error.
*
* @param[in] refreshKeySender - pointer to the RefreshKeySender object that was used for the key refresh process. The caller
* will NOT use this pointer any more.
* @param[in] refreshKeySender - pointer to the RefreshKeySender object that was used for the key refresh process. It will NOT
* be null regardless the key refresh status. The caller will NOT use this pointer any more.
* @param[in] error - CHIP_NO_ERROR indicates successful re-registration using the new key
* Other errors indicate the failure reason.
*/
Expand Down
20 changes: 13 additions & 7 deletions src/app/icd/client/DefaultCheckInDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,26 @@ RefreshKeySender * DefaultCheckInDelegate::OnKeyRefreshNeeded(ICDClientInfo & cl

void DefaultCheckInDelegate::OnKeyRefreshDone(RefreshKeySender * refreshKeySender, CHIP_ERROR error)
{
if (refreshKeySender == nullptr)
{
ChipLogError(ICD, "RefreshKeySender is null");
return;
}
auto icdClientInfo = refreshKeySender->GetICDClientInfo();
Platform::Delete(refreshKeySender);
refreshKeySender = nullptr;
if (error == CHIP_NO_ERROR)
{
ChipLogProgress(ICD, "Re-registration with new key completed successfully");
ChipLogProgress(ICD, "Re-registration with new key completed successfully for peer node " ChipLogFormatScopedNodeId,
ChipLogValueScopedNodeId(icdClientInfo.peer_node));
}
else
{
ChipLogError(ICD, "Re-registration with new key failed with error : %" CHIP_ERROR_FORMAT, error.Format());
ChipLogError(
ICD, "Re-registration with new key failed with error %" CHIP_ERROR_FORMAT " for peer node " ChipLogFormatScopedNodeId,
error.Format(), ChipLogValueScopedNodeId(icdClientInfo.peer_node));
// The callee can take corrective action based on the error received.
}
if (refreshKeySender != nullptr)
{
Platform::Delete(refreshKeySender);
refreshKeySender = nullptr;
}
}
} // namespace app
} // namespace chip
5 changes: 5 additions & 0 deletions src/app/icd/client/RefreshKeySender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ RefreshKeySender::RefreshKeySender(CheckInDelegate * checkInDelegate, const ICDC
mOnConnectedCallback(HandleDeviceConnected, this), mOnConnectionFailureCallback(HandleDeviceConnectionFailure, this)
{}

const ICDClientInfo & RefreshKeySender::GetICDClientInfo()
{
return mICDClientInfo;
}

CHIP_ERROR RefreshKeySender::RegisterClientWithNewKey(Messaging::ExchangeManager & exchangeMgr, const SessionHandle & sessionHandle)
{
auto onSuccess = [&](const ConcreteCommandPath & commandPath, const StatusIB & status, const auto & dataResponse) {
Expand Down
8 changes: 8 additions & 0 deletions src/app/icd/client/RefreshKeySender.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ class RefreshKeySender
*/
CHIP_ERROR EstablishSessionToPeer();

/**
* @brief Used to retrieve ICDClientInfo from RefreshKeySender.
*
* @return ICDClientInfo - ICDClientInfo object representing the state associated with the
node that requested a key refresh.
*/
const ICDClientInfo & GetICDClientInfo();

private:
// CASE session callbacks
/**
Expand Down
25 changes: 0 additions & 25 deletions src/python_testing/TC_DGSW_2_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,35 +37,10 @@

import chip.clusters as Clusters
from chip.testing.matter_testing import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
from mobly import asserts


class TC_DGSW_2_1(MatterBaseTest):

@staticmethod
def is_valid_uint64_value(value):
return isinstance(value, int) and 0 <= value <= 0xFFFFFFFFFFFFFFFF

@staticmethod
def is_valid_uint32_value(value):
return isinstance(value, int) and 0 <= value <= 0xFFFFFFFF

@staticmethod
def is_valid_str_value(value):
return isinstance(value, str) and len(value) > 0

def assert_valid_uint64(self, value, field_name):
"""Asserts that the value is a valid uint64."""
asserts.assert_true(self.is_valid_uint64_value(value), f"{field_name} field should be a uint64 type")

def assert_valid_uint32(self, value, field_name):
"""Asserts that the value is a valid uint32."""
asserts.assert_true(self.is_valid_uint32_value(value), f"{field_name} field should be a uint32 type")

def assert_valid_str(self, value, field_name):
"""Asserts that the value is a non-empty string."""
asserts.assert_true(self.is_valid_str_value(value), f"{field_name} field should be a non-empty string")

async def read_dgsw_attribute_expect_success(self, endpoint, attribute):
cluster = Clusters.Objects.SoftwareDiagnostics
return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute)
Expand Down
6 changes: 1 addition & 5 deletions src/python_testing/TC_DGSW_2_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@

class TC_DGSW_2_2(MatterBaseTest):

@staticmethod
def is_valid_uint64_value(value):
return isinstance(value, int) and 0 <= value <= 0xFFFFFFFFFFFFFFFF

@staticmethod
def is_valid_octet_string(value):
return isinstance(value, (bytes, bytearray))
Expand All @@ -71,7 +67,7 @@ def validate_soft_fault_event_data(self, event_data):

# Validate 'Id' field: Ensure it is a uint64 type
asserts.assert_true(
self.is_valid_uint64_value(event_data.id),
self.is_valid_uint_value(event_data.id, bit_count=64),
"The 'Id' field must be a uint64 type"
)

Expand Down
24 changes: 0 additions & 24 deletions src/python_testing/TC_DGSW_2_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,30 +44,6 @@

class TC_DGSW_2_3(MatterBaseTest):

@staticmethod
def is_valid_uint64_value(value):
return isinstance(value, int) and 0 <= value <= 0xFFFFFFFFFFFFFFFF

@staticmethod
def is_valid_uint32_value(value):
return isinstance(value, int) and 0 <= value <= 0xFFFFFFFF

@staticmethod
def is_valid_str_value(value):
return isinstance(value, str) and len(value) > 0

def assert_valid_uint64(self, value, field_name):
"""Asserts that the value is a valid uint64."""
asserts.assert_true(self.is_valid_uint64_value(value), f"{field_name} field should be a uint64 type")

def assert_valid_uint32(self, value, field_name):
"""Asserts that the value is a valid uint32."""
asserts.assert_true(self.is_valid_uint32_value(value), f"{field_name} field should be a uint32 type")

def assert_valid_str(self, value, field_name):
"""Asserts that the value is a non-empty string."""
asserts.assert_true(self.is_valid_str_value(value), f"{field_name} field should be a non-empty string")

async def read_dgsw_attribute_expect_success(self, endpoint, attribute):
cluster = Clusters.Objects.SoftwareDiagnostics
return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute)
Expand Down
32 changes: 0 additions & 32 deletions src/python_testing/TC_DGWIFI_2_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,6 @@ def is_valid_bssid(bssid) -> bool:

return False

@staticmethod
def is_valid_uint_value(value, bit_count=64):
"""
Checks if 'value' is a non-negative integer fitting into 'bit_count' bits.
For example, bit_count=32 => must fit within 0 <= value <= 0xFFFFFFFF
"""
if not isinstance(value, int):
return False
if value < 0:
return False
return value < 2**bit_count

def assert_valid_bssid(self, value, field_name):
"""Asserts that the value is a valid BSSID (MAC address), None, or NullValue."""
if isinstance(value, Nullable):
Expand All @@ -86,26 +74,6 @@ def assert_valid_bssid(self, value, field_name):
asserts.assert_true(self.is_valid_bssid(value),
f"{field_name} should be a valid BSSID string (e.g., '00:11:22:33:44:55') or None/NullValue.")

def assert_valid_uint64(self, value, field_name):
"""Asserts that the value is a valid uint64 or None (if attribute can return NULL)."""
asserts.assert_true(value is None or self.is_valid_uint_value(value, bit_count=64),
f"{field_name} should be a uint64 or NULL.")

def assert_valid_uint32(self, value, field_name):
"""Asserts that the value is a valid uint32 or None (if attribute can return NULL)."""
asserts.assert_true(value is None or self.is_valid_uint_value(value, bit_count=32),
f"{field_name} should be a uint32 or NULL.")

def assert_valid_uint16(self, value, field_name):
"""Asserts that the value is a valid uint16 or None (if attribute can return NULL)."""
asserts.assert_true(value is None or self.is_valid_uint_value(value, bit_count=16),
f"{field_name} should be a uint16 or NULL.")

def assert_valid_uint8(self, value, field_name):
"""Asserts that the value is a valid uint16 or None (if attribute can return NULL)."""
asserts.assert_true(value is None or self.is_valid_uint_value(value, bit_count=8),
f"{field_name} should be a uint8 or NULL.")

async def read_dgwifi_attribute_expect_success(self, endpoint, attribute):
cluster = Clusters.Objects.WiFiNetworkDiagnostics
return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,46 @@ def __init__(self, *args):
# The named pipe name must be set in the derived classes
self.app_pipe = None

@staticmethod
def is_valid_uint_value(value, bit_count=64):
"""
Checks if 'value' is a non-negative integer fitting into 'bit_count' bits.
For example, bit_count=32 => must fit within 0 <= value <= 0xFFFFFFFF
"""
if not isinstance(value, int):
return False
if value < 0:
return False
return value < 2**bit_count

@staticmethod
def is_valid_str_value(value):
return isinstance(value, str) and len(value) > 0

def assert_valid_uint64(self, value, field_name):
"""Asserts that the value is a valid uint64."""
asserts.assert_true(self.is_valid_uint_value(value, bit_count=64),
f"{field_name} should be a uint64 or NULL.")

def assert_valid_uint32(self, value, field_name):
"""Asserts that the value is a valid uint32."""
asserts.assert_true(self.is_valid_uint_value(value, bit_count=32),
f"{field_name} should be a uint32 or NULL.")

def assert_valid_uint16(self, value, field_name):
"""Asserts that the value is a valid uint16."""
asserts.assert_true(self.is_valid_uint_value(value, bit_count=16),
f"{field_name} should be a uint16 or NULL.")

def assert_valid_uint8(self, value, field_name):
"""Asserts that the value is a valid uint16."""
asserts.assert_true(self.is_valid_uint_value(value, bit_count=8),
f"{field_name} should be a uint8 or NULL.")

def assert_valid_str(self, value, field_name):
"""Asserts that the value is a non-empty string."""
asserts.assert_true(self.is_valid_str_value(value), f"{field_name} field should be a non-empty string")

def get_test_steps(self, test: str) -> list[TestStep]:
''' Retrieves the test step list for the given test
Expand Down

0 comments on commit d3f5a3b

Please sign in to comment.