Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync csa branch with main #283

Merged
merged 6 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: test_dcl_server",
"type": "debugpy",
"request": "launch",
"program": "/workspace/connectedhomeip/examples/chip-tool/commands/dcl/test_dcl_server.py",
"args": [],
"console": "integratedTerminal"
},
{
"name": "Attach to running process",
"type": "lldb",
Expand Down
32 changes: 19 additions & 13 deletions examples/chip-tool/commands/dcl/test_dcl_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,19 +211,25 @@ def handle_tc_request(self, vendor_id, product_id):


def run_https_server(cert_file="cert.pem", key_file="key.pem"):
httpd = http.server.HTTPServer(
(DEFAULT_HOSTNAME, DEFAULT_PORT), RESTRequestHandler)

httpd.socket = ssl.wrap_socket(
httpd.socket,
server_side=True,
certfile=cert_file,
keyfile=key_file,
ssl_version=ssl.PROTOCOL_TLS,
)

print(f"Serving on https://{DEFAULT_HOSTNAME}:{DEFAULT_PORT}")
httpd.serve_forever()
# Creates a basic HTTP server instance that listens on DEFAULT_HOSTNAME and DEFAULT_PORT
# RESTRequestHandler handles incoming HTTP requests
httpd = http.server.HTTPServer((DEFAULT_HOSTNAME, DEFAULT_PORT), RESTRequestHandler)

# Creates an SSL context using TLS protocol for secure communications
context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)

# Loads the SSL certificate and private key for the server
# cert_file: contains the server's public certificate
# key_file: contains the server's private key
context.load_cert_chain(certfile=cert_file, keyfile=key_file)

# Uses a context manager (with statement) to wrap the HTTP server's socket with SSL
# server_side=True indicates this is a server socket
# The wrapped socket is automatically closed when exiting the with block
with context.wrap_socket(httpd.socket, server_side=True) as httpd.socket:
print(f"Serving on https://{DEFAULT_HOSTNAME}:{DEFAULT_PORT}")
# Starts the server and runs indefinitely, handling incoming HTTPS requests
httpd.serve_forever()


# Generate self-signed certificates if needed
Expand Down
23 changes: 0 additions & 23 deletions examples/platform/silabs/provision/ProvisionStorageDefault.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <nvm3_default.h>
#include <nvm3_hal_flash.h>
#include <platform/CHIPDeviceConfig.h>
#include <platform/silabs/MigrationManager.h>
#include <platform/silabs/SilabsConfig.h>
#include <platform/silabs/platformAbstraction/SilabsPlatform.h>
#include <silabs_creds.h>
Expand Down Expand Up @@ -708,28 +707,6 @@ CHIP_ERROR Storage::GetTestEventTriggerKey(MutableByteSpan & keySpan)
}

} // namespace Provision

void MigrateDacProvider(void)
{
constexpr uint32_t kOldKey_Creds_KeyId = SilabsConfigKey(SilabsConfig::kMatterConfig_KeyBase, 0x21);
constexpr uint32_t kOldKey_Creds_Base_Addr = SilabsConfigKey(SilabsConfig::kMatterConfig_KeyBase, 0x22);
constexpr uint32_t kOldKey_Creds_DAC_Offset = SilabsConfigKey(SilabsConfig::kMatterConfig_KeyBase, 0x23);
constexpr uint32_t kOldKey_Creds_DAC_Size = SilabsConfigKey(SilabsConfig::kMatterConfig_KeyBase, 0x24);
constexpr uint32_t kOldKey_Creds_PAI_Size = SilabsConfigKey(SilabsConfig::kMatterConfig_KeyBase, 0x26);
constexpr uint32_t kOldKey_Creds_PAI_Offset = SilabsConfigKey(SilabsConfig::kMatterConfig_KeyBase, 0x25);
constexpr uint32_t kOldKey_Creds_CD_Offset = SilabsConfigKey(SilabsConfig::kMatterConfig_KeyBase, 0x27);
constexpr uint32_t kOldKey_Creds_CD_Size = SilabsConfigKey(SilabsConfig::kMatterConfig_KeyBase, 0x28);

MigrationManager::MigrateUint32(kOldKey_Creds_KeyId, SilabsConfig::kConfigKey_Creds_KeyId);
MigrationManager::MigrateUint32(kOldKey_Creds_Base_Addr, SilabsConfig::kConfigKey_Creds_Base_Addr);
MigrationManager::MigrateUint32(kOldKey_Creds_DAC_Offset, SilabsConfig::kConfigKey_Creds_DAC_Offset);
MigrationManager::MigrateUint32(kOldKey_Creds_DAC_Size, SilabsConfig::kConfigKey_Creds_DAC_Size);
MigrationManager::MigrateUint32(kOldKey_Creds_PAI_Offset, SilabsConfig::kConfigKey_Creds_PAI_Offset);
MigrationManager::MigrateUint32(kOldKey_Creds_PAI_Size, SilabsConfig::kConfigKey_Creds_PAI_Size);
MigrationManager::MigrateUint32(kOldKey_Creds_CD_Offset, SilabsConfig::kConfigKey_Creds_CD_Offset);
MigrationManager::MigrateUint32(kOldKey_Creds_CD_Size, SilabsConfig::kConfigKey_Creds_CD_Size);
}

} // namespace Silabs
} // namespace DeviceLayer
} // namespace chip
Original file line number Diff line number Diff line change
Expand Up @@ -738,9 +738,6 @@ CHIP_ERROR Storage::GetTestEventTriggerKey(MutableByteSpan & keySpan)
}

} // namespace Provision

void MigrateDacProvider(void) {}

} // namespace Silabs
} // namespace DeviceLayer
} // namespace chip
3 changes: 0 additions & 3 deletions src/app/InteractionModelEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@

#pragma once

// TODO(#32628): Remove the CHIPCore.h header when the esp32 build is correctly fixed
#include <lib/core/CHIPCore.h>

#include <access/AccessControl.h>
#include <app/AppConfig.h>
#include <app/AttributePathParams.h>
Expand Down
3 changes: 0 additions & 3 deletions src/app/reporting/ReportScheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@

#pragma once

// TODO(#32628): Remove the CHIPCore.h header when the esp32 build is correctly fixed
#include <lib/core/CHIPCore.h>

#include <app/ReadHandler.h>
#include <app/icd/server/ICDStateObserver.h>
#include <lib/core/CHIPError.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,7 @@ CHIP_ERROR GenericPlatformManagerImpl_FreeRTOS<ImplClass>::_InitChipStack(void)

vTaskSetTimeOutState(&mNextTimerBaseTime);
mNextTimerDurationTicks = 0;
// TODO: This nulling out of mEventLoopTask should happen when we shut down
// the task, not here!
mEventLoopTask = NULL;
#if defined(CHIP_DEVICE_CONFIG_ENABLE_BG_EVENT_PROCESSING) && CHIP_DEVICE_CONFIG_ENABLE_BG_EVENT_PROCESSING
mBackgroundEventLoopTask = NULL;
#endif
mChipTimerActive = false;

// We support calling Shutdown followed by InitChipStack, because some tests
// do that. To keep things simple for existing consumers, we keep not
// destroying our lock and queue in shutdown, but rather check whether they
// already exist here before trying to create them.
mChipTimerActive = false;

if (mChipStackLock == NULL)
{
Expand Down Expand Up @@ -277,10 +266,11 @@ template <class ImplClass>
void GenericPlatformManagerImpl_FreeRTOS<ImplClass>::EventLoopTaskMain(void * arg)
{
ChipLogDetail(DeviceLayer, "CHIP event task running");
static_cast<GenericPlatformManagerImpl_FreeRTOS<ImplClass> *>(arg)->Impl()->RunEventLoop();
// TODO: At this point, should we not
// vTaskDelete(static_cast<GenericPlatformManagerImpl_FreeRTOS<ImplClass> *>(arg)->mEventLoopTask)?
// Or somehow get our caller to do it once this thread is joined?
GenericPlatformManagerImpl_FreeRTOS<ImplClass> * platformManager =
static_cast<GenericPlatformManagerImpl_FreeRTOS<ImplClass> *>(arg);
platformManager->Impl()->RunEventLoop();
vTaskDelete(NULL);
platformManager->mEventLoopTask = NULL;
}

template <class ImplClass>
Expand Down Expand Up @@ -376,7 +366,11 @@ template <class ImplClass>
void GenericPlatformManagerImpl_FreeRTOS<ImplClass>::BackgroundEventLoopTaskMain(void * arg)
{
ChipLogDetail(DeviceLayer, "CHIP background task running");
static_cast<GenericPlatformManagerImpl_FreeRTOS<ImplClass> *>(arg)->Impl()->RunBackgroundEventLoop();
GenericPlatformManagerImpl_FreeRTOS<ImplClass> * platformManager =
static_cast<GenericPlatformManagerImpl_FreeRTOS<ImplClass> *>(arg);
platformManager->Impl()->RunBackgroundEventLoop();
vTaskDelete(NULL);
platformManager->mBackgroundEventLoopTask = NULL;
}
#endif

Expand Down Expand Up @@ -416,6 +410,20 @@ void GenericPlatformManagerImpl_FreeRTOS<ImplClass>::PostEventFromISR(const Chip
template <class ImplClass>
void GenericPlatformManagerImpl_FreeRTOS<ImplClass>::_Shutdown(void)
{
if (mChipEventQueue)
{
vQueueDelete(mChipEventQueue);
mChipEventQueue = NULL;
}
#if defined(CHIP_DEVICE_CONFIG_ENABLE_BG_EVENT_PROCESSING) && CHIP_DEVICE_CONFIG_ENABLE_BG_EVENT_PROCESSING
if (mBackgroundEventQueue)
{
vQueueDelete(mBackgroundEventQueue);
mBackgroundEventQueue = NULL;
}
#endif
vSemaphoreDelete(mChipStackLock);
mChipStackLock = NULL;
GenericPlatformManagerImpl<ImplClass>::_Shutdown();
}

Expand Down
42 changes: 42 additions & 0 deletions src/platform/silabs/MigrationManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ static migrationData_t migrationTable[] = {
{ .migrationGroup = 1, .migrationFunc = MigrateKvsMap },
{ .migrationGroup = 2, .migrationFunc = MigrateDacProvider },
{ .migrationGroup = 3, .migrationFunc = MigrateCounterConfigs },
{ .migrationGroup = 4, .migrationFunc = MigrateHardwareVersion },
// add any additional migration neccesary. migrationGroup should stay equal if done in the same commit or increment by 1 for
// each new entry.
};
Expand All @@ -62,6 +63,20 @@ void MigrationManager::applyMigrations()
}
SilabsConfig::WriteConfigValue(SilabsConfig::kConfigKey_MigrationCounter, completedMigrationGroup);
}

void MigrationManager::MigrateUint16(uint32_t old_key, uint32_t new_key)
{
uint16_t value = 0;
if (SilabsConfig::ConfigValueExists(old_key) && (CHIP_NO_ERROR == SilabsConfig::ReadConfigValue(old_key, value)))
{
if (CHIP_NO_ERROR == SilabsConfig::WriteConfigValue(new_key, value))
{
// Free memory of old key location
SilabsConfig::ClearConfigValue(old_key);
}
}
}

void MigrationManager::MigrateUint32(uint32_t old_key, uint32_t new_key)
{
uint32_t value = 0;
Expand Down Expand Up @@ -90,6 +105,33 @@ MigrationManager & MigrationManager::GetMigrationInstance()
return sMigrationManager;
}

void MigrateDacProvider(void)
{
constexpr uint32_t kOldKey_Creds_KeyId = SilabsConfigKey(SilabsConfig::kMatterConfig_KeyBase, 0x21);
constexpr uint32_t kOldKey_Creds_Base_Addr = SilabsConfigKey(SilabsConfig::kMatterConfig_KeyBase, 0x22);
constexpr uint32_t kOldKey_Creds_DAC_Offset = SilabsConfigKey(SilabsConfig::kMatterConfig_KeyBase, 0x23);
constexpr uint32_t kOldKey_Creds_DAC_Size = SilabsConfigKey(SilabsConfig::kMatterConfig_KeyBase, 0x24);
constexpr uint32_t kOldKey_Creds_PAI_Size = SilabsConfigKey(SilabsConfig::kMatterConfig_KeyBase, 0x26);
constexpr uint32_t kOldKey_Creds_PAI_Offset = SilabsConfigKey(SilabsConfig::kMatterConfig_KeyBase, 0x25);
constexpr uint32_t kOldKey_Creds_CD_Offset = SilabsConfigKey(SilabsConfig::kMatterConfig_KeyBase, 0x27);
constexpr uint32_t kOldKey_Creds_CD_Size = SilabsConfigKey(SilabsConfig::kMatterConfig_KeyBase, 0x28);

MigrationManager::MigrateUint32(kOldKey_Creds_KeyId, SilabsConfig::kConfigKey_Creds_KeyId);
MigrationManager::MigrateUint32(kOldKey_Creds_Base_Addr, SilabsConfig::kConfigKey_Creds_Base_Addr);
MigrationManager::MigrateUint32(kOldKey_Creds_DAC_Offset, SilabsConfig::kConfigKey_Creds_DAC_Offset);
MigrationManager::MigrateUint32(kOldKey_Creds_DAC_Size, SilabsConfig::kConfigKey_Creds_DAC_Size);
MigrationManager::MigrateUint32(kOldKey_Creds_PAI_Offset, SilabsConfig::kConfigKey_Creds_PAI_Offset);
MigrationManager::MigrateUint32(kOldKey_Creds_PAI_Size, SilabsConfig::kConfigKey_Creds_PAI_Size);
MigrationManager::MigrateUint32(kOldKey_Creds_CD_Offset, SilabsConfig::kConfigKey_Creds_CD_Offset);
MigrationManager::MigrateUint32(kOldKey_Creds_CD_Size, SilabsConfig::kConfigKey_Creds_CD_Size);
}

void MigrateHardwareVersion(void)
{
constexpr uint32_t kOldKey_HardwareVersion = SilabsConfigKey(SilabsConfig::kMatterConfig_KeyBase, 0x08);
MigrationManager::MigrateUint16(kOldKey_HardwareVersion, SilabsConfig::kConfigKey_HardwareVersion);
}

} // namespace Silabs
} // namespace DeviceLayer
} // namespace chip
2 changes: 2 additions & 0 deletions src/platform/silabs/MigrationManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class MigrationManager
*/
static MigrationManager & GetMigrationInstance();
static void applyMigrations();
static void MigrateUint16(uint32_t old_key, uint32_t new_key);
static void MigrateUint32(uint32_t old_key, uint32_t new_key);

private:
Expand All @@ -45,6 +46,7 @@ class MigrationManager
void MigrateKvsMap(void);
void MigrateDacProvider(void);
void MigrateCounterConfigs(void);
void MigrateHardwareVersion(void);

} // namespace Silabs
} // namespace DeviceLayer
Expand Down
2 changes: 1 addition & 1 deletion src/platform/silabs/SilabsConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class SilabsConfig
static constexpr Key kConfigKey_hostname = SilabsConfigKey(kMatterFactory_KeyBase, 0x15);
static constexpr Key kConfigKey_clientid = SilabsConfigKey(kMatterFactory_KeyBase, 0x16);
static constexpr Key kConfigKey_Test_Event_Trigger_Key = SilabsConfigKey(kMatterFactory_KeyBase, 0x17);
static constexpr Key kConfigKey_HardwareVersion = SilabsConfigKey(kMatterFactory_KeyBase, 0x18);
// kConfigKey_PersistentUniqueId is the inputkey in the generating of the Rotating Device ID
// SHALL NOT be the same as the UniqueID attribute exposed in the Basic Information cluster.
static constexpr Key kConfigKey_PersistentUniqueId = SilabsConfigKey(kMatterFactory_KeyBase, 0x1F);
Expand All @@ -142,7 +143,6 @@ class SilabsConfig
static constexpr Key kConfigKey_LastUsedEpochKeyId = SilabsConfigKey(kMatterConfig_KeyBase, 0x05);
static constexpr Key kConfigKey_FailSafeArmed = SilabsConfigKey(kMatterConfig_KeyBase, 0x06);
static constexpr Key kConfigKey_GroupKey = SilabsConfigKey(kMatterConfig_KeyBase, 0x07);
static constexpr Key kConfigKey_HardwareVersion = SilabsConfigKey(kMatterConfig_KeyBase, 0x08);
static constexpr Key kConfigKey_RegulatoryLocation = SilabsConfigKey(kMatterConfig_KeyBase, 0x09);
static constexpr Key kConfigKey_CountryCode = SilabsConfigKey(kMatterConfig_KeyBase, 0x0A);
static constexpr Key kConfigKey_WiFiSSID = SilabsConfigKey(kMatterConfig_KeyBase, 0x0C);
Expand Down
4 changes: 1 addition & 3 deletions src/python_testing/TC_CGEN_2_10.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ def pics_TC_CGEN_2_10(self) -> list[str]:

def steps_TC_CGEN_2_10(self) -> list[TestStep]:
return [
TestStep(0, description="", expectation="", is_commissioning=False),
TestStep(1, "TH reads from the DUT the attribute TCAcceptedVersion. Store the value as acceptedVersion."),
TestStep(1, "TH reads from the DUT the attribute TCAcceptedVersion. Store the value as acceptedVersion.", is_commissioning=False),
TestStep(2, "TH reads from the DUT the attribute TCAcknowledgements. Store the value as userAcknowledgements."),
TestStep(3, "TH Sends the SetTCAcknowledgements command to the DUT with the fields set as follows:\n* TCVersion: 0\n* TCUserResponse: 65535"),
TestStep(4, "TH reads from the DUT the attribute TCAcceptedVersion."),
Expand All @@ -67,7 +66,6 @@ def steps_TC_CGEN_2_10(self) -> list[TestStep]:
async def test_TC_CGEN_2_10(self):
commissioner: ChipDeviceCtrl.ChipDeviceController = self.default_controller

self.step(0)
if not self.check_pics("CGEN.S.F00"):
asserts.skip('Root endpoint does not support the [commissioning] feature under test')
return
Expand Down
4 changes: 1 addition & 3 deletions src/python_testing/TC_CGEN_2_11.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ def pics_TC_CGEN_2_11(self) -> list[str]:

def steps_TC_CGEN_2_11(self) -> list[TestStep]:
return [
TestStep(0, description="", expectation="", is_commissioning=False),
TestStep(1, "TH begins commissioning the DUT and performs the following steps in order:\n* Security setup using PASE\n* Setup fail-safe timer, with ExpiryLengthSeconds field set to PIXIT.CGEN.FailsafeExpiryLengthSeconds and the Breadcrumb value as 1\n* Configure information- UTC time, regulatory, etc."),
TestStep(1, "TH begins commissioning the DUT and performs the following steps in order:\n* Security setup using PASE\n* Setup fail-safe timer, with ExpiryLengthSeconds field set to PIXIT.CGEN.FailsafeExpiryLengthSeconds and the Breadcrumb value as 1\n* Configure information- UTC time, regulatory, etc.", is_commissioning=False),
TestStep(2, "TH sends SetTCAcknowledgements to DUT with the following values:\n* TCVersion: PIXIT.CGEN.TCRevision\n* TCUserResponse: PIXIT.CGEN.RequiredTCAcknowledgements"),
TestStep(3, "TH sends CommissioningComplete to DUT."),
TestStep(4, "TH Sends the SetTCAcknowledgements command to the DUT with the fields set as follows:\n* TCVersion: PIXIT.CGEN.TCRevision + 1\n* TCUserResponse: PIXIT.CGEN.RequiredTCAcknowledgements"),
Expand All @@ -70,7 +69,6 @@ async def test_TC_CGEN_2_11(self):
tc_version_to_simulate = self.matter_test_config.global_test_params['PIXIT.CGEN.TCRevision']
tc_user_response_to_simulate = self.matter_test_config.global_test_params['PIXIT.CGEN.RequiredTCAcknowledgements']

self.step(0)
if not self.check_pics("CGEN.S.F00"):
asserts.skip('Root endpoint does not support the [commissioning] feature under test')
return
Expand Down
4 changes: 1 addition & 3 deletions src/python_testing/TC_CGEN_2_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ def pics_TC_CGEN_2_5(self) -> list[str]:

def steps_TC_CGEN_2_5(self) -> list[TestStep]:
return [
TestStep(0, description="", expectation="", is_commissioning=False),
TestStep(1, "TH begins commissioning the DUT and performs the following steps in order:\n* Security setup using PASE\n* Setup fail-safe timer, with ExpiryLengthSeconds field set to PIXIT.CGEN.FailsafeExpiryLengthSeconds and the Breadcrumb value as 1\n* Configure information- UTC time, regulatory, etc."),
TestStep(1, "TH begins commissioning the DUT and performs the following steps in order:\n* Security setup using PASE\n* Setup fail-safe timer, with ExpiryLengthSeconds field set to PIXIT.CGEN.FailsafeExpiryLengthSeconds and the Breadcrumb value as 1\n* Configure information- UTC time, regulatory, etc.", is_commissioning=False),
TestStep(2, "TH reads TCAcknowledgementsRequired attribute from the DUT"),
TestStep(3, "TH reads TCUpdateDeadline attribute from the DUT"),
TestStep(4, "TH reads the FeatureMap from the General Commissioning Cluster."),
Expand All @@ -78,7 +77,6 @@ async def test_TC_CGEN_2_5(self):
tc_version_to_simulate = self.matter_test_config.global_test_params['PIXIT.CGEN.TCRevision']
tc_user_response_to_simulate = self.matter_test_config.global_test_params['PIXIT.CGEN.RequiredTCAcknowledgements']

self.step(0)
if not self.check_pics("CGEN.S.F00"):
asserts.skip('Root endpoint does not support the [commissioning] feature under test')
return
Expand Down
4 changes: 1 addition & 3 deletions src/python_testing/TC_CGEN_2_6.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,14 @@ def pics_TC_CGEN_2_6(self) -> list[str]:

def steps_TC_CGEN_2_6(self) -> list[TestStep]:
return [
TestStep(0, description="", expectation="", is_commissioning=False),
TestStep(1, "TH starts commissioning the DUT. It performs all commissioning steps from 'Device discovery and establish commissioning channel' to 'Security setup using CASE', except for TC configuration with SetTCAcknowledgements."),
TestStep(1, "TH starts commissioning the DUT. It performs all commissioning steps from 'Device discovery and establish commissioning channel' to 'Security setup using CASE', except for TC configuration with SetTCAcknowledgements.", is_commissioning=False),
TestStep(2, "TH sends CommissioningComplete to DUT."),
]

@async_test_body
async def test_TC_CGEN_2_6(self):
commissioner: ChipDeviceCtrl.ChipDeviceController = self.default_controller

self.step(0)
if not self.check_pics("CGEN.S.F00"):
asserts.skip('Root endpoint does not support the [commissioning] feature under test')
return
Expand Down
Loading
Loading