diff --git a/examples/chef/common/chef-rvc-mode-delegate.cpp b/examples/chef/common/chef-rvc-mode-delegate.cpp index f6c10412812dea..b275d08e21d474 100644 --- a/examples/chef/common/chef-rvc-mode-delegate.cpp +++ b/examples/chef/common/chef-rvc-mode-delegate.cpp @@ -29,11 +29,21 @@ using ModeTagStructType = chip::app::Clusters::detail::Structs::ModeTagStruct::T #ifdef MATTER_DM_PLUGIN_RVC_RUN_MODE_SERVER #include + +#ifdef MATTER_DM_PLUGIN_RVC_OPERATIONAL_STATE_SERVER +#include +#endif // MATTER_DM_PLUGIN_RVC_OPERATIONAL_STATE_SERVER + using namespace chip::app::Clusters::RvcRunMode; static std::unique_ptr gRvcRunModeDelegate; static std::unique_ptr gRvcRunModeInstance; +chip::app::Clusters::ModeBase::Instance * getRvcRunModeInstance() +{ + return gRvcRunModeInstance.get(); +} + CHIP_ERROR RvcRunModeDelegate::Init() { return CHIP_NO_ERROR; @@ -51,7 +61,35 @@ void RvcRunModeDelegate::HandleChangeToMode(uint8_t NewMode, ModeBase::Commands: return; } +#ifdef MATTER_DM_PLUGIN_RVC_OPERATIONAL_STATE_SERVER + OperationalState::GenericOperationalError err(to_underlying(OperationalState::ErrorStateEnum::kNoError)); + if (NewMode == RvcRunMode::ModeIdle) + { + if (currentMode != RvcRunMode::ModeIdle) + { // Stop existing cycle when going from cleaning/mapping to idle. + ChipLogProgress(DeviceLayer, "Stopping RVC cycle: %d", currentMode); + getRvcOperationalStateDelegate()->HandleStopStateCallback(err); + } + } + else + { + if (currentMode == RvcRunMode::ModeIdle) + { // Start a new cycle when going from idle to clening/mapping. + ChipLogProgress(DeviceLayer, "Starting new RVC cycle: %d", NewMode); + getRvcOperationalStateDelegate()->HandleStartStateCallback(err); + } + } + if (err.IsEqual(OperationalState::GenericOperationalError(to_underlying(OperationalState::ErrorStateEnum::kNoError)))) + { + response.status = to_underlying(ModeBase::StatusCode::kSuccess); + } + else + { + response.status = to_underlying(ModeBase::StatusCode::kGenericFailure); + } +#else response.status = to_underlying(ModeBase::StatusCode::kSuccess); +#endif // MATTER_DM_PLUGIN_RVC_OPERATIONAL_STATE_SERVER } CHIP_ERROR RvcRunModeDelegate::GetModeLabelByIndex(uint8_t modeIndex, chip::MutableCharSpan & label) diff --git a/examples/chef/common/chef-rvc-mode-delegate.h b/examples/chef/common/chef-rvc-mode-delegate.h index 359c90c5a08162..f5b155cd718b79 100644 --- a/examples/chef/common/chef-rvc-mode-delegate.h +++ b/examples/chef/common/chef-rvc-mode-delegate.h @@ -42,6 +42,7 @@ class RvcRunModeDelegate : public ModeBase::Delegate using ModeTagStructType = detail::Structs::ModeTagStruct::Type; ModeTagStructType ModeTagsIdle[1] = { { .value = to_underlying(ModeTag::kIdle) } }; ModeTagStructType ModeTagsCleaning[1] = { { .value = to_underlying(ModeTag::kCleaning) } }; + ModeTagStructType ModeTagsMapping[1] = { { .value = to_underlying(ModeTag::kMapping) } }; const detail::Structs::ModeOptionStruct::Type kModeOptions[3] = { detail::Structs::ModeOptionStruct::Type{ .label = CharSpan::fromCharString("Idle"), @@ -52,7 +53,7 @@ class RvcRunModeDelegate : public ModeBase::Delegate .modeTags = DataModel::List(ModeTagsCleaning) }, detail::Structs::ModeOptionStruct::Type{ .label = CharSpan::fromCharString("Mapping"), .mode = ModeMapping, - .modeTags = DataModel::List(ModeTagsIdle) }, + .modeTags = DataModel::List(ModeTagsMapping) }, }; CHIP_ERROR Init() override; @@ -122,6 +123,8 @@ void Shutdown(); } // namespace chip #ifdef MATTER_DM_PLUGIN_RVC_RUN_MODE_SERVER +chip::app::Clusters::ModeBase::Instance * getRvcRunModeInstance(); + chip::Protocols::InteractionModel::Status chefRvcRunModeWriteCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer); diff --git a/examples/chef/common/chef-rvc-operational-state-delegate.cpp b/examples/chef/common/chef-rvc-operational-state-delegate.cpp index 9b4118732ee165..1a1cf0696c2074 100644 --- a/examples/chef/common/chef-rvc-operational-state-delegate.cpp +++ b/examples/chef/common/chef-rvc-operational-state-delegate.cpp @@ -28,9 +28,18 @@ using namespace chip::app::Clusters::OperationalState; using namespace chip::app::Clusters::RvcOperationalState; using chip::Protocols::InteractionModel::Status; +#ifdef MATTER_DM_PLUGIN_RVC_RUN_MODE_SERVER +#include +#endif // MATTER_DM_PLUGIN_RVC_RUN_MODE_SERVER + static std::unique_ptr gRvcOperationalStateDelegate; static std::unique_ptr gRvcOperationalStateInstance; +RvcOperationalStateDelegate * getRvcOperationalStateDelegate() +{ + return gRvcOperationalStateDelegate.get(); +} + static void onOperationalStateTimerTick(System::Layer * systemLayer, void * data); DataModel::Nullable RvcOperationalStateDelegate::GetCountdownTime() @@ -176,6 +185,11 @@ static void onOperationalStateTimerTick(System::Layer * systemLayer, void * data OperationalState::OperationalStateEnum state = static_cast(instance->GetCurrentOperationalState()); + if (state == OperationalState::OperationalStateEnum::kStopped) // Do not continue the timer when RVC has stopped. + { + return; + } + if (gRvcOperationalStateDelegate->mCountdownTime.IsNull()) { if (state == OperationalState::OperationalStateEnum::kRunning) @@ -223,6 +237,10 @@ static void onOperationalStateTimerTick(System::Layer * systemLayer, void * data gRvcOperationalStateDelegate->mRunningTime = 0; gRvcOperationalStateDelegate->mPausedTime = 0; gRvcOperationalStateDelegate->mCountdownTime.SetNull(); + +#ifdef MATTER_DM_PLUGIN_RVC_RUN_MODE_SERVER + getRvcRunModeInstance()->UpdateCurrentMode(RvcRunMode::ModeIdle); +#endif // MATTER_DM_PLUGIN_RVC_RUN_MODE_SERVER } } } diff --git a/examples/chef/common/chef-rvc-operational-state-delegate.h b/examples/chef/common/chef-rvc-operational-state-delegate.h index f56b7979f3c1c3..d551182787dc36 100644 --- a/examples/chef/common/chef-rvc-operational-state-delegate.h +++ b/examples/chef/common/chef-rvc-operational-state-delegate.h @@ -122,6 +122,8 @@ void Shutdown(); } // namespace app } // namespace chip +chip::app::Clusters::RvcOperationalState::RvcOperationalStateDelegate * getRvcOperationalStateDelegate(); + chip::Protocols::InteractionModel::Status chefRvcOperationalStateWriteCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer); diff --git a/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.matter b/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.matter index 642406f5552c1f..465ab9f083cc96 100644 --- a/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.matter +++ b/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.matter @@ -622,82 +622,21 @@ cluster OtaSoftwareUpdateProvider = 41 { command NotifyUpdateApplied(NotifyUpdateAppliedRequest): DefaultSuccess = 4; } -/** Provides an interface for downloading and applying OTA software updates */ -cluster OtaSoftwareUpdateRequestor = 42 { +/** Nodes should be expected to be deployed to any and all regions of the world. These global regions + may have differing common languages, units of measurements, and numerical formatting + standards. As such, Nodes that visually or audibly convey information need a mechanism by which + they can be configured to use a user’s preferred language, units, etc */ +cluster LocalizationConfiguration = 43 { revision 1; // NOTE: Default/not specifically set - enum AnnouncementReasonEnum : enum8 { - kSimpleAnnouncement = 0; - kUpdateAvailable = 1; - kUrgentUpdateAvailable = 2; - } - - enum ChangeReasonEnum : enum8 { - kUnknown = 0; - kSuccess = 1; - kFailure = 2; - kTimeOut = 3; - kDelayByProvider = 4; - } - - enum UpdateStateEnum : enum8 { - kUnknown = 0; - kIdle = 1; - kQuerying = 2; - kDelayedOnQuery = 3; - kDownloading = 4; - kApplying = 5; - kDelayedOnApply = 6; - kRollingBack = 7; - kDelayedOnUserConsent = 8; - } - - fabric_scoped struct ProviderLocation { - node_id providerNodeID = 1; - endpoint_no endpoint = 2; - fabric_idx fabricIndex = 254; - } - - info event StateTransition = 0 { - UpdateStateEnum previousState = 0; - UpdateStateEnum newState = 1; - ChangeReasonEnum reason = 2; - nullable int32u targetSoftwareVersion = 3; - } - - critical event VersionApplied = 1 { - int32u softwareVersion = 0; - int16u productID = 1; - } - - info event DownloadError = 2 { - int32u softwareVersion = 0; - int64u bytesDownloaded = 1; - nullable int8u progressPercent = 2; - nullable int64s platformCode = 3; - } - - attribute access(write: administer) ProviderLocation defaultOTAProviders[] = 0; - readonly attribute boolean updatePossible = 1; - readonly attribute UpdateStateEnum updateState = 2; - readonly attribute nullable int8u updateStateProgress = 3; + attribute access(write: manage) char_string<35> activeLocale = 0; + readonly attribute char_string supportedLocales[] = 1; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; readonly attribute attrib_id attributeList[] = 65531; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; - - request struct AnnounceOTAProviderRequest { - node_id providerNodeID = 0; - vendor_id vendorID = 1; - AnnouncementReasonEnum announcementReason = 2; - optional octet_string<512> metadataForNode = 3; - endpoint_no endpoint = 4; - } - - /** Announce the presence of an OTA Provider */ - command AnnounceOTAProvider(AnnounceOTAProviderRequest): DefaultSuccess = 0; } /** Nodes should be expected to be deployed to any and all regions of the world. These global regions @@ -726,6 +665,265 @@ cluster UnitLocalization = 45 { readonly attribute int16u clusterRevision = 65533; } +/** This cluster is used to describe the configuration and capabilities of a physical power source that provides power to the Node. */ +cluster PowerSource = 47 { + revision 1; // NOTE: Default/not specifically set + + enum BatApprovedChemistryEnum : enum16 { + kUnspecified = 0; + kAlkaline = 1; + kLithiumCarbonFluoride = 2; + kLithiumChromiumOxide = 3; + kLithiumCopperOxide = 4; + kLithiumIronDisulfide = 5; + kLithiumManganeseDioxide = 6; + kLithiumThionylChloride = 7; + kMagnesium = 8; + kMercuryOxide = 9; + kNickelOxyhydride = 10; + kSilverOxide = 11; + kZincAir = 12; + kZincCarbon = 13; + kZincChloride = 14; + kZincManganeseDioxide = 15; + kLeadAcid = 16; + kLithiumCobaltOxide = 17; + kLithiumIon = 18; + kLithiumIonPolymer = 19; + kLithiumIronPhosphate = 20; + kLithiumSulfur = 21; + kLithiumTitanate = 22; + kNickelCadmium = 23; + kNickelHydrogen = 24; + kNickelIron = 25; + kNickelMetalHydride = 26; + kNickelZinc = 27; + kSilverZinc = 28; + kSodiumIon = 29; + kSodiumSulfur = 30; + kZincBromide = 31; + kZincCerium = 32; + } + + enum BatChargeFaultEnum : enum8 { + kUnspecified = 0; + kAmbientTooHot = 1; + kAmbientTooCold = 2; + kBatteryTooHot = 3; + kBatteryTooCold = 4; + kBatteryAbsent = 5; + kBatteryOverVoltage = 6; + kBatteryUnderVoltage = 7; + kChargerOverVoltage = 8; + kChargerUnderVoltage = 9; + kSafetyTimeout = 10; + } + + enum BatChargeLevelEnum : enum8 { + kOK = 0; + kWarning = 1; + kCritical = 2; + } + + enum BatChargeStateEnum : enum8 { + kUnknown = 0; + kIsCharging = 1; + kIsAtFullCharge = 2; + kIsNotCharging = 3; + } + + enum BatCommonDesignationEnum : enum16 { + kUnspecified = 0; + kAAA = 1; + kAA = 2; + kC = 3; + kD = 4; + k4v5 = 5; + k6v0 = 6; + k9v0 = 7; + k12AA = 8; + kAAAA = 9; + kA = 10; + kB = 11; + kF = 12; + kN = 13; + kNo6 = 14; + kSubC = 15; + kA23 = 16; + kA27 = 17; + kBA5800 = 18; + kDuplex = 19; + k4SR44 = 20; + k523 = 21; + k531 = 22; + k15v0 = 23; + k22v5 = 24; + k30v0 = 25; + k45v0 = 26; + k67v5 = 27; + kJ = 28; + kCR123A = 29; + kCR2 = 30; + k2CR5 = 31; + kCRP2 = 32; + kCRV3 = 33; + kSR41 = 34; + kSR43 = 35; + kSR44 = 36; + kSR45 = 37; + kSR48 = 38; + kSR54 = 39; + kSR55 = 40; + kSR57 = 41; + kSR58 = 42; + kSR59 = 43; + kSR60 = 44; + kSR63 = 45; + kSR64 = 46; + kSR65 = 47; + kSR66 = 48; + kSR67 = 49; + kSR68 = 50; + kSR69 = 51; + kSR516 = 52; + kSR731 = 53; + kSR712 = 54; + kLR932 = 55; + kA5 = 56; + kA10 = 57; + kA13 = 58; + kA312 = 59; + kA675 = 60; + kAC41E = 61; + k10180 = 62; + k10280 = 63; + k10440 = 64; + k14250 = 65; + k14430 = 66; + k14500 = 67; + k14650 = 68; + k15270 = 69; + k16340 = 70; + kRCR123A = 71; + k17500 = 72; + k17670 = 73; + k18350 = 74; + k18500 = 75; + k18650 = 76; + k19670 = 77; + k25500 = 78; + k26650 = 79; + k32600 = 80; + } + + enum BatFaultEnum : enum8 { + kUnspecified = 0; + kOverTemp = 1; + kUnderTemp = 2; + } + + enum BatReplaceabilityEnum : enum8 { + kUnspecified = 0; + kNotReplaceable = 1; + kUserReplaceable = 2; + kFactoryReplaceable = 3; + } + + enum PowerSourceStatusEnum : enum8 { + kUnspecified = 0; + kActive = 1; + kStandby = 2; + kUnavailable = 3; + } + + enum WiredCurrentTypeEnum : enum8 { + kAC = 0; + kDC = 1; + } + + enum WiredFaultEnum : enum8 { + kUnspecified = 0; + kOverVoltage = 1; + kUnderVoltage = 2; + } + + bitmap Feature : bitmap32 { + kWired = 0x1; + kBattery = 0x2; + kRechargeable = 0x4; + kReplaceable = 0x8; + } + + struct BatChargeFaultChangeType { + BatChargeFaultEnum current[] = 0; + BatChargeFaultEnum previous[] = 1; + } + + struct BatFaultChangeType { + BatFaultEnum current[] = 0; + BatFaultEnum previous[] = 1; + } + + struct WiredFaultChangeType { + WiredFaultEnum current[] = 0; + WiredFaultEnum previous[] = 1; + } + + info event WiredFaultChange = 0 { + WiredFaultEnum current[] = 0; + WiredFaultEnum previous[] = 1; + } + + info event BatFaultChange = 1 { + BatFaultEnum current[] = 0; + BatFaultEnum previous[] = 1; + } + + info event BatChargeFaultChange = 2 { + BatChargeFaultEnum current[] = 0; + BatChargeFaultEnum previous[] = 1; + } + + readonly attribute PowerSourceStatusEnum status = 0; + readonly attribute int8u order = 1; + readonly attribute char_string<60> description = 2; + readonly attribute optional nullable int32u wiredAssessedInputVoltage = 3; + readonly attribute optional nullable int16u wiredAssessedInputFrequency = 4; + readonly attribute optional WiredCurrentTypeEnum wiredCurrentType = 5; + readonly attribute optional nullable int32u wiredAssessedCurrent = 6; + readonly attribute optional int32u wiredNominalVoltage = 7; + readonly attribute optional int32u wiredMaximumCurrent = 8; + readonly attribute optional boolean wiredPresent = 9; + readonly attribute optional WiredFaultEnum activeWiredFaults[] = 10; + readonly attribute optional nullable int32u batVoltage = 11; + readonly attribute optional nullable int8u batPercentRemaining = 12; + readonly attribute optional nullable int32u batTimeRemaining = 13; + readonly attribute optional BatChargeLevelEnum batChargeLevel = 14; + readonly attribute optional boolean batReplacementNeeded = 15; + readonly attribute optional BatReplaceabilityEnum batReplaceability = 16; + readonly attribute optional boolean batPresent = 17; + readonly attribute optional BatFaultEnum activeBatFaults[] = 18; + readonly attribute optional char_string<60> batReplacementDescription = 19; + readonly attribute optional BatCommonDesignationEnum batCommonDesignation = 20; + readonly attribute optional char_string<20> batANSIDesignation = 21; + readonly attribute optional char_string<20> batIECDesignation = 22; + readonly attribute optional BatApprovedChemistryEnum batApprovedChemistry = 23; + readonly attribute optional int32u batCapacity = 24; + readonly attribute optional int8u batQuantity = 25; + readonly attribute optional BatChargeStateEnum batChargeState = 26; + readonly attribute optional nullable int32u batTimeToFullCharge = 27; + readonly attribute optional boolean batFunctionalWhileCharging = 28; + readonly attribute optional nullable int32u batChargingCurrent = 29; + readonly attribute optional BatChargeFaultEnum activeBatChargeFaults[] = 30; + readonly attribute endpoint_no endpointList[] = 31; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; +} + /** This cluster is used to manage global aspects of the Commissioning flow. */ cluster GeneralCommissioning = 48 { revision 1; // NOTE: Default/not specifically set @@ -1844,7 +2042,7 @@ cluster IcdManagement = 70 { } endpoint 0 { - device type ma_rootdevice = 22, version 1; + device type ma_rootdevice = 22, version 3; device type ma_powersource = 17, version 1; binding cluster OtaSoftwareUpdateProvider; @@ -1864,7 +2062,6 @@ endpoint 0 { server cluster AccessControl { emits event AccessControlEntryChanged; callback attribute acl; - callback attribute extension; callback attribute subjectsPerAccessControlEntry; callback attribute targetsPerAccessControlEntry; callback attribute accessControlEntriesPerFabric; @@ -1896,21 +2093,17 @@ endpoint 0 { callback attribute acceptedCommandList; callback attribute attributeList; ram attribute featureMap default = 0; - ram attribute clusterRevision default = 3; + ram attribute clusterRevision default = 4; } - server cluster OtaSoftwareUpdateRequestor { - emits event StateTransition; - emits event VersionApplied; - emits event DownloadError; - callback attribute defaultOTAProviders; - ram attribute updatePossible default = 1; - ram attribute updateState default = 0; - ram attribute updateStateProgress default = 0; + server cluster LocalizationConfiguration { + ram attribute activeLocale; + callback attribute supportedLocales; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute attributeList; ram attribute featureMap default = 0; ram attribute clusterRevision default = 1; - - handle command AnnounceOTAProvider; } server cluster UnitLocalization { @@ -1921,6 +2114,21 @@ endpoint 0 { ram attribute clusterRevision default = 1; } + server cluster PowerSource { + ram attribute status; + ram attribute order; + ram attribute description; + ram attribute batChargeLevel; + ram attribute batReplacementNeeded; + ram attribute batReplaceability; + callback attribute endpointList; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute attributeList; + ram attribute featureMap default = 2; + ram attribute clusterRevision default = 3; + } + server cluster GeneralCommissioning { ram attribute breadcrumb default = 0x0000000000000000; callback attribute basicCommissioningInfo; @@ -1931,7 +2139,7 @@ endpoint 0 { callback attribute acceptedCommandList; callback attribute attributeList; ram attribute featureMap default = 0; - ram attribute clusterRevision default = 1; + ram attribute clusterRevision default = 2; handle command ArmFailSafe; handle command ArmFailSafeResponse; @@ -2002,7 +2210,7 @@ endpoint 0 { callback attribute operationalDatasetComponents; callback attribute activeNetworkFaultsList; ram attribute featureMap default = 0; - ram attribute clusterRevision default = 2; + ram attribute clusterRevision default = 3; } server cluster WiFiNetworkDiagnostics { @@ -2128,7 +2336,7 @@ endpoint 0 { } } endpoint 1 { - device type ma_contactsensor = 21, version 1; + device type ma_contactsensor = 21, version 2; server cluster Identify { @@ -2138,7 +2346,7 @@ endpoint 1 { callback attribute acceptedCommandList; callback attribute attributeList; ram attribute featureMap default = 0; - ram attribute clusterRevision default = 4; + ram attribute clusterRevision default = 5; handle command Identify; handle command TriggerEffect; diff --git a/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.zap b/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.zap index db31e23cda9236..3eafdc4d2d0c7b 100644 --- a/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.zap +++ b/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.zap @@ -19,18 +19,18 @@ "package": [ { "pathRelativity": "relativeToZap", - "path": "../../../src/app/zap-templates/zcl/zcl.json", - "type": "zcl-properties", + "path": "../../../src/app/zap-templates/app-templates.json", + "type": "gen-templates-json", "category": "matter", - "version": 1, - "description": "Matter SDK ZCL data" + "version": "chip-v1" }, { "pathRelativity": "relativeToZap", - "path": "../../../src/app/zap-templates/app-templates.json", - "type": "gen-templates-json", + "path": "../../../src/app/zap-templates/zcl/zcl.json", + "type": "zcl-properties", "category": "matter", - "version": "chip-v1" + "version": 1, + "description": "Matter SDK ZCL data" } ], "endpointTypes": [ @@ -62,7 +62,7 @@ ], "deviceVersions": [ 1, - 1 + 3 ], "deviceIdentifiers": [ 17, @@ -250,22 +250,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "Extension", - "code": 1, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 0, - "maxInterval": 65534, - "reportableChange": 0 - }, { "name": "SubjectsPerAccessControlEntry", "code": 2, @@ -727,7 +711,7 @@ "storageOption": "RAM", "singleton": 1, "bounded": 0, - "defaultValue": "3", + "defaultValue": "4", "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -760,6 +744,14 @@ "isIncoming": 0, "isEnabled": 1 }, + { + "name": "QueryImageResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "isIncoming": 1, + "isEnabled": 1 + }, { "name": "ApplyUpdateRequest", "code": 2, @@ -787,26 +779,32 @@ ] }, { - "name": "OTA Software Update Requestor", - "code": 42, + "name": "Localization Configuration", + "code": 43, "mfgCode": null, - "define": "OTA_SOFTWARE_UPDATE_REQUESTOR_CLUSTER", + "define": "LOCALIZATION_CONFIGURATION_CLUSTER", "side": "server", "enabled": 1, - "commands": [ + "attributes": [ { - "name": "AnnounceOTAProvider", + "name": "ActiveLocale", "code": 0, "mfgCode": null, - "source": "client", - "isIncoming": 1, - "isEnabled": 1 - } - ], - "attributes": [ + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { - "name": "DefaultOTAProviders", - "code": 0, + "name": "SupportedLocales", + "code": 1, "mfgCode": null, "side": "server", "type": "array", @@ -821,48 +819,48 @@ "reportableChange": 0 }, { - "name": "UpdatePossible", - "code": 1, + "name": "GeneratedCommandList", + "code": 65528, "mfgCode": null, "side": "server", - "type": "boolean", + "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "1", + "defaultValue": null, "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "UpdateState", - "code": 2, + "name": "AcceptedCommandList", + "code": 65529, "mfgCode": null, "side": "server", - "type": "UpdateStateEnum", + "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": null, "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "UpdateStateProgress", - "code": 3, + "name": "AttributeList", + "code": 65531, "mfgCode": null, "side": "server", - "type": "int8u", + "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -896,43 +894,222 @@ "bounded": 0, "defaultValue": "1", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 } - ], - "events": [ + ] + }, + { + "name": "Unit Localization", + "code": 45, + "mfgCode": null, + "define": "UNIT_LOCALIZATION_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ { - "name": "StateTransition", - "code": 0, + "name": "GeneratedCommandList", + "code": 65528, "mfgCode": null, "side": "server", - "included": 1 + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 }, { - "name": "VersionApplied", - "code": 1, + "name": "AcceptedCommandList", + "code": 65529, "mfgCode": null, "side": "server", - "included": 1 + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 }, { - "name": "DownloadError", - "code": 2, + "name": "AttributeList", + "code": 65531, "mfgCode": null, "side": "server", - "included": 1 + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 } ] }, { - "name": "Unit Localization", - "code": 45, + "name": "Power Source", + "code": 47, "mfgCode": null, - "define": "UNIT_LOCALIZATION_CLUSTER", + "define": "POWER_SOURCE_CLUSTER", "side": "server", "enabled": 1, "attributes": [ + { + "name": "Status", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "PowerSourceStatusEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Order", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Description", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "BatChargeLevel", + "code": 14, + "mfgCode": null, + "side": "server", + "type": "BatChargeLevelEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "BatReplacementNeeded", + "code": 15, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "BatReplaceability", + "code": 16, + "mfgCode": null, + "side": "server", + "type": "BatReplaceabilityEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "EndpointList", + "code": 31, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "GeneratedCommandList", "code": 65528, @@ -991,7 +1168,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": "2", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1007,7 +1184,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "1", + "defaultValue": "3", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1227,7 +1404,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "1", + "defaultValue": "2", "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -2013,7 +2190,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "2", + "defaultValue": "3", "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -3413,7 +3590,7 @@ } ], "deviceVersions": [ - 1 + 2 ], "deviceIdentifiers": [ 21 @@ -3554,7 +3731,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "4", + "defaultValue": "5", "reportable": 1, "minInterval": 1, "maxInterval": 65534, diff --git a/examples/network-manager-app/network-manager-common/network-manager-app.matter b/examples/network-manager-app/network-manager-common/network-manager-app.matter index a1c362817b4e4d..849c5dd324a18f 100644 --- a/examples/network-manager-app/network-manager-common/network-manager-app.matter +++ b/examples/network-manager-app/network-manager-common/network-manager-app.matter @@ -1462,7 +1462,7 @@ cluster GroupKeyManagement = 63 { } /** Functionality to retrieve operational information about a managed Wi-Fi network. */ -provisional cluster WiFiNetworkManagement = 1105 { +cluster WiFiNetworkManagement = 1105 { revision 1; readonly attribute nullable octet_string<32> ssid = 0; @@ -1483,19 +1483,19 @@ provisional cluster WiFiNetworkManagement = 1105 { } /** Manage the Thread network of Thread Border Router */ -provisional cluster ThreadBorderRouterManagement = 1106 { +cluster ThreadBorderRouterManagement = 1106 { revision 1; bitmap Feature : bitmap32 { kPANChange = 0x1; } - provisional readonly attribute char_string<63> borderRouterName = 0; - provisional readonly attribute octet_string<254> borderAgentID = 1; - provisional readonly attribute int16u threadVersion = 2; - provisional readonly attribute boolean interfaceEnabled = 3; - provisional readonly attribute nullable int64u activeDatasetTimestamp = 4; - provisional readonly attribute nullable int64u pendingDatasetTimestamp = 5; + readonly attribute char_string<63> borderRouterName = 0; + readonly attribute octet_string<254> borderAgentID = 1; + readonly attribute int16u threadVersion = 2; + readonly attribute boolean interfaceEnabled = 3; + readonly attribute nullable int64u activeDatasetTimestamp = 4; + readonly attribute nullable int64u pendingDatasetTimestamp = 5; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -1527,7 +1527,7 @@ provisional cluster ThreadBorderRouterManagement = 1106 { } /** Manages the names and credentials of Thread networks visible to the user. */ -provisional cluster ThreadNetworkDirectory = 1107 { +cluster ThreadNetworkDirectory = 1107 { revision 1; struct ThreadNetworkStruct { diff --git a/examples/placeholder/linux/apps/app1/config.matter b/examples/placeholder/linux/apps/app1/config.matter index 7286c5fd41f83d..5925f477fa182e 100644 --- a/examples/placeholder/linux/apps/app1/config.matter +++ b/examples/placeholder/linux/apps/app1/config.matter @@ -6770,19 +6770,19 @@ cluster OccupancySensing = 1030 { } /** Manage the Thread network of Thread Border Router */ -provisional cluster ThreadBorderRouterManagement = 1106 { +cluster ThreadBorderRouterManagement = 1106 { revision 1; bitmap Feature : bitmap32 { kPANChange = 0x1; } - provisional readonly attribute char_string<63> borderRouterName = 0; - provisional readonly attribute octet_string<254> borderAgentID = 1; - provisional readonly attribute int16u threadVersion = 2; - provisional readonly attribute boolean interfaceEnabled = 3; - provisional readonly attribute nullable int64u activeDatasetTimestamp = 4; - provisional readonly attribute nullable int64u pendingDatasetTimestamp = 5; + readonly attribute char_string<63> borderRouterName = 0; + readonly attribute octet_string<254> borderAgentID = 1; + readonly attribute int16u threadVersion = 2; + readonly attribute boolean interfaceEnabled = 3; + readonly attribute nullable int64u activeDatasetTimestamp = 4; + readonly attribute nullable int64u pendingDatasetTimestamp = 5; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; diff --git a/examples/platform/infineon/cyw30739/BUILD.gn b/examples/platform/infineon/cyw30739/BUILD.gn index 8ec7003633cd40..eacde3a87c912e 100644 --- a/examples/platform/infineon/cyw30739/BUILD.gn +++ b/examples/platform/infineon/cyw30739/BUILD.gn @@ -29,7 +29,10 @@ static_library("platform") { public_configs = [ ":${target_name}-config" ] - deps = [ app_data_model ] + deps = [ + "${chip_root}/src/app:generic-test-event-trigger-handler", + app_data_model, + ] } config("platform-config") { diff --git a/examples/rvc-app/rvc-common/rvc-app.matter b/examples/rvc-app/rvc-common/rvc-app.matter index 45a047db96da5b..80b69915da1f4c 100644 --- a/examples/rvc-app/rvc-common/rvc-app.matter +++ b/examples/rvc-app/rvc-common/rvc-app.matter @@ -546,6 +546,23 @@ cluster BasicInformation = 40 { command MfgSpecificPing(): DefaultSuccess = 0; } +/** Nodes should be expected to be deployed to any and all regions of the world. These global regions + may have differing common languages, units of measurements, and numerical formatting + standards. As such, Nodes that visually or audibly convey information need a mechanism by which + they can be configured to use a user’s preferred language, units, etc */ +cluster LocalizationConfiguration = 43 { + revision 1; // NOTE: Default/not specifically set + + attribute access(write: manage) char_string<35> activeLocale = 0; + readonly attribute char_string supportedLocales[] = 1; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; +} + /** This cluster is used to manage global aspects of the Commissioning flow. */ cluster GeneralCommissioning = 48 { revision 1; // NOTE: Default/not specifically set @@ -1576,7 +1593,7 @@ provisional cluster ServiceArea = 336 { } endpoint 0 { - device type ma_rootdevice = 22, version 1; + device type ma_rootdevice = 22, version 3; server cluster Descriptor { @@ -1592,7 +1609,6 @@ endpoint 0 { emits event AccessControlEntryChanged; emits event AccessControlExtensionChanged; callback attribute acl; - callback attribute extension; callback attribute subjectsPerAccessControlEntry; callback attribute targetsPerAccessControlEntry; callback attribute accessControlEntriesPerFabric; @@ -1627,7 +1643,17 @@ endpoint 0 { callback attribute specificationVersion; callback attribute maxPathsPerInvoke; ram attribute featureMap default = 0; - ram attribute clusterRevision default = 3; + ram attribute clusterRevision default = 4; + } + + server cluster LocalizationConfiguration { + ram attribute activeLocale; + callback attribute supportedLocales; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute attributeList; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 1; } server cluster GeneralCommissioning { @@ -1637,7 +1663,7 @@ endpoint 0 { callback attribute locationCapability; callback attribute supportsConcurrentConnection; ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0001; + ram attribute clusterRevision default = 0x0002; handle command ArmFailSafe; handle command ArmFailSafeResponse; @@ -1650,8 +1676,6 @@ endpoint 0 { server cluster NetworkCommissioning { ram attribute maxNetworks; callback attribute networks; - ram attribute scanMaxTimeSeconds; - ram attribute connectMaxTimeSeconds; ram attribute interfaceEnabled; ram attribute lastNetworkingStatus; ram attribute lastNetworkID; @@ -1675,6 +1699,7 @@ endpoint 0 { ram attribute clusterRevision default = 1; handle command RetrieveLogsRequest; + handle command RetrieveLogsResponse; } server cluster GeneralDiagnostics { @@ -1751,7 +1776,7 @@ endpoint 0 { } } endpoint 1 { - device type ma_robotic_vacuum_cleaner = 116, version 1; + device type ma_robotic_vacuum_cleaner = 116, version 3; server cluster Identify { @@ -1761,7 +1786,7 @@ endpoint 1 { callback attribute acceptedCommandList; callback attribute attributeList; ram attribute featureMap default = 0; - ram attribute clusterRevision default = 4; + ram attribute clusterRevision default = 5; handle command Identify; handle command TriggerEffect; @@ -1817,7 +1842,7 @@ endpoint 1 { callback attribute acceptedCommandList; callback attribute attributeList; ram attribute featureMap default = 0; - ram attribute clusterRevision default = 1; + ram attribute clusterRevision default = 2; handle command Pause; handle command Resume; diff --git a/examples/rvc-app/rvc-common/rvc-app.zap b/examples/rvc-app/rvc-common/rvc-app.zap index 4e4425222fc925..a7dd9b7ec8d8d2 100644 --- a/examples/rvc-app/rvc-common/rvc-app.zap +++ b/examples/rvc-app/rvc-common/rvc-app.zap @@ -54,7 +54,7 @@ } ], "deviceVersions": [ - 1 + 3 ], "deviceIdentifiers": [ 22 @@ -193,22 +193,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "Extension", - "code": 1, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, { "name": "SubjectsPerAccessControlEntry", "code": 2, @@ -693,7 +677,7 @@ "storageOption": "RAM", "singleton": 1, "bounded": 0, - "defaultValue": "3", + "defaultValue": "4", "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -724,6 +708,128 @@ } ] }, + { + "name": "Localization Configuration", + "code": 43, + "mfgCode": null, + "define": "LOCALIZATION_CONFIGURATION_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "ActiveLocale", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SupportedLocales", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, { "name": "General Commissioning", "code": 48, @@ -888,7 +994,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x0001", + "defaultValue": "0x0002", "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -1010,38 +1116,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "ScanMaxTimeSeconds", - "code": 2, - "mfgCode": null, - "side": "server", - "type": "int8u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "ConnectMaxTimeSeconds", - "code": 3, - "mfgCode": null, - "side": "server", - "type": "int8u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, { "name": "InterfaceEnabled", "code": 4, @@ -1155,6 +1229,14 @@ "source": "client", "isIncoming": 1, "isEnabled": 1 + }, + { + "name": "RetrieveLogsResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 } ], "attributes": [ @@ -1983,7 +2065,7 @@ } ], "deviceVersions": [ - 1 + 3 ], "deviceIdentifiers": [ 116 @@ -2124,7 +2206,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "4", + "defaultValue": "5", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2762,7 +2844,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "1", + "defaultValue": "2", "reportable": 1, "minInterval": 1, "maxInterval": 65534, diff --git a/examples/thermostat/nxp/zap/thermostat_matter_br.matter b/examples/thermostat/nxp/zap/thermostat_matter_br.matter index df6179a33c3813..ba5f578b175c32 100644 --- a/examples/thermostat/nxp/zap/thermostat_matter_br.matter +++ b/examples/thermostat/nxp/zap/thermostat_matter_br.matter @@ -2100,19 +2100,19 @@ cluster Thermostat = 513 { } /** Manage the Thread network of Thread Border Router */ -provisional cluster ThreadBorderRouterManagement = 1106 { +cluster ThreadBorderRouterManagement = 1106 { revision 1; bitmap Feature : bitmap32 { kPANChange = 0x1; } - provisional readonly attribute char_string<63> borderRouterName = 0; - provisional readonly attribute octet_string<254> borderAgentID = 1; - provisional readonly attribute int16u threadVersion = 2; - provisional readonly attribute boolean interfaceEnabled = 3; - provisional readonly attribute nullable int64u activeDatasetTimestamp = 4; - provisional readonly attribute nullable int64u pendingDatasetTimestamp = 5; + readonly attribute char_string<63> borderRouterName = 0; + readonly attribute octet_string<254> borderAgentID = 1; + readonly attribute int16u threadVersion = 2; + readonly attribute boolean interfaceEnabled = 3; + readonly attribute nullable int64u activeDatasetTimestamp = 4; + readonly attribute nullable int64u pendingDatasetTimestamp = 5; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; diff --git a/examples/thread-br-app/thread-br-common/thread-br-app.matter b/examples/thread-br-app/thread-br-common/thread-br-app.matter index 1c692284df0d74..b3828664f65d19 100644 --- a/examples/thread-br-app/thread-br-common/thread-br-app.matter +++ b/examples/thread-br-app/thread-br-common/thread-br-app.matter @@ -1380,19 +1380,19 @@ cluster UserLabel = 65 { } /** Manage the Thread network of Thread Border Router */ -provisional cluster ThreadBorderRouterManagement = 1106 { +cluster ThreadBorderRouterManagement = 1106 { revision 1; bitmap Feature : bitmap32 { kPANChange = 0x1; } - provisional readonly attribute char_string<63> borderRouterName = 0; - provisional readonly attribute octet_string<254> borderAgentID = 1; - provisional readonly attribute int16u threadVersion = 2; - provisional readonly attribute boolean interfaceEnabled = 3; - provisional readonly attribute nullable int64u activeDatasetTimestamp = 4; - provisional readonly attribute nullable int64u pendingDatasetTimestamp = 5; + readonly attribute char_string<63> borderRouterName = 0; + readonly attribute octet_string<254> borderAgentID = 1; + readonly attribute int16u threadVersion = 2; + readonly attribute boolean interfaceEnabled = 3; + readonly attribute nullable int64u activeDatasetTimestamp = 4; + readonly attribute nullable int64u pendingDatasetTimestamp = 5; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; diff --git a/scripts/setup/constraints.txt b/scripts/setup/constraints.txt index 874d46f6f1a526..a97c9f0cf3f924 100644 --- a/scripts/setup/constraints.txt +++ b/scripts/setup/constraints.txt @@ -163,7 +163,7 @@ portpicker==1.5.2 # mobly prompt-toolkit==3.0.43 # via ipython -protobuf==4.24.4 +protobuf==5.28.3 # via # -r requirements.all.txt # mypy-protobuf @@ -253,7 +253,7 @@ traitlets==5.9.0 # via # ipython # matplotlib-inline -types-protobuf==4.24.0.2 +types-protobuf==5.29.1.20250208 # via # -r requirements.all.txt # mypy-protobuf diff --git a/scripts/setup/requirements.all.txt b/scripts/setup/requirements.all.txt index 4a7672a08f639d..22d64e34874ce8 100644 --- a/scripts/setup/requirements.all.txt +++ b/scripts/setup/requirements.all.txt @@ -40,8 +40,8 @@ watchdog build==0.8.0 mypy==1.10.1 mypy-protobuf==3.5.0 -protobuf==4.24.4 -types-protobuf==4.24.0.2 +protobuf==5.28.3 +types-protobuf==5.29.1.20250208 cffi==1.15.0; python_version < "3.13" cffi==1.17.1; python_version >= "3.13" diff --git a/scripts/tools/file_size_from_nm.py b/scripts/tools/file_size_from_nm.py index 2b13936a546e85..74912bc185effb 100755 --- a/scripts/tools/file_size_from_nm.py +++ b/scripts/tools/file_size_from_nm.py @@ -94,6 +94,35 @@ class Symbol: size: int tree_path: list[str] +# These expressions are callbacks defined in +# callbacks.zapt +# - void emberAf{{asUpperCamelCase label}}ClusterInitCallback(chip::EndpointId endpoint); +# - void emberAf{{asUpperCamelCase label}}ClusterServerInitCallback(chip::EndpointId endpoint); +# - void Matter{{asUpperCamelCase label}}ClusterServerShutdownCallback(chip::EndpointId endpoint); +# - void emberAf{{asUpperCamelCase label}}ClusterClientInitCallback(chip::EndpointId endpoint); +# - void Matter{{asUpperCamelCase label}}ClusterServerAttributeChangedCallback(const chip::app::ConcreteAttributePath & attributePath); +# - chip::Protocols::InteractionModel::Status Matter{{asUpperCamelCase label}}ClusterServerPreAttributeChangedCallback(const chip::app::ConcreteAttributePath & attributePath, EmberAfAttributeType attributeType, uint16_t size, uint8_t * value); +# - void emberAf{{asUpperCamelCase label}}ClusterServerTickCallback(chip::EndpointId endpoint); +# +# and for commands: +# - bool emberAf{{asUpperCamelCase parent.label}}Cluster{{asUpperCamelCase name}}Callback + + +_CLUSTER_EXPRESSIONS = [ + re.compile(r'emberAf(?P.+)ClusterClientInitCallback\('), + re.compile(r'emberAf(?P.+)ClusterInitCallback\('), + re.compile(r'emberAf(?P.+)ClusterServerInitCallback\('), + + + + re.compile(r'emberAf(?P.+)ClusterServerTickCallback\('), + re.compile(r'Matter(?P.+)ClusterServerAttributeChangedCallback\('), + re.compile(r'Matter(?P.+)ClusterServerPreAttributeChangedCallback\('), + re.compile(r'Matter(?P.+)ClusterServerShutdownCallback\('), + # commands + re.compile(r'emberAf(?P.+)Cluster(?P.+)Callback\('), +] + def tree_display_name(name: str) -> list[str]: """ @@ -110,11 +139,61 @@ def tree_display_name(name: str) -> list[str]: if name.startswith("vtable for "): name = name[11:] - # These are C-style methods really, we have no top-level namespaces named - # like this but still want to see these differently - for special_prefix in {"emberAf", "Matter"}: - if name.startswith(special_prefix): - return [special_prefix, name] + # Known variables for ember: + for variable_name in ['::generatedAttributes', '::generatedClusters', '::generatedEmberAfEndpointTypes', '::fixedDeviceTypeList', '::generatedCommands']: + if variable_name in name: + return ["EMBER", "METADATA", name] + + # to abvoid treating '(anonymous namespace)::' as special because of space, + # replace it with something that looks similar + name = name.replace('(anonymous namespace)::', 'ANONYMOUS_NAMESPACE::') + + # Ember methods are generally c-style that are in a particular format: + # - emAf* are INTERNAL ember functions + # - emberAf* are PUBLIC (from an ember perspective) functions + # - Several callbacks: + # - MatterClusterServerInitCallback + # - emberAfClusterInitCallback + # - MatterserverShutdownCallback + # - MatterPreAttributeChangedCallback + # - MatterPreAttributeChangedCallback + # - emberAfPluginLevelControlCoupledColorTempChangeCallback + # The code below splits the above an "ember" namespace + + # First consider the cluster functions. + # These are technically ember, however place them in `::chip::app::Clusters::::` + # so that they are grouped with AAI/CHI + for expr in _CLUSTER_EXPRESSIONS: + m = expr.match(name) + if not m: + continue + d = m.groupdict() + logging.debug("Ember callback found: %s -> %r", name, d) + if 'command' in d: + return ["chip", "app", "Clusters", d['cluster'], "EMBER", d['command'], name] + else: + return ["chip", "app", "Clusters", d['cluster'], "EMBER", name] + + if 'MatterPreAttributeChangeCallback' in name: + return ["EMBER", "CALLBACKS", name] + + if name.startswith("emberAfPlugin"): + # these methods are callbacks defined by some clusters to call into application code. + # They look like: + # - emberAfPluginTimeFormatLocalizationOnCalendarTypeChange + # - emberAfPluginOnOffClusterServerPostInitCallback + # - emberAfPluginDoorLockGetFaceCredentialLengthConstraints + # - emberAfPluginDoorLockOnOperatingModeChange + # - emberAfPluginColorControlServerXyTransitionEventHandler + # + # They are generally quite free form and seem to be used instead of "delegates" as + # application hook points. + return ["EMBER", "CALLBACKS", "PLUGIN", name] + + # We also capture '(anonymous namespace)::emAfWriteAttribute or similar + if name.startswith("emAf") or name.startswith("emberAf") or ("::emAf" in name) or ('::emberAf' in name): + # Place this as ::EMBER::API (these are internal and public functions from ember) + return ["EMBER", "API", name] # If the first element contains a space, it is either within `<>` for templates or it means it is a # separator of the type. Try to find the type separator @@ -194,18 +273,32 @@ def tree_display_name(name: str) -> list[str]: if len(result) == 1: if result[0].startswith("ot"): # Show openthread methods a bit grouped - result = ["ot"] + result + return ["ot", "C"] + result return ["C"] + result - return result + return [r.replace('ANONYMOUS_NAMESPACE', '(anonymous namespace)') for r in result] # TO run the test, install pytest and do # pytest file_size_from_nm.py def test_tree_display_name(): assert tree_display_name("fooBar") == ["C", "fooBar"] - assert tree_display_name("emberAfTest") == ["emberAf", "emberAfTest"] - assert tree_display_name("MatterSomeCall") == ["Matter", "MatterSomeCall"] + assert tree_display_name("emberAfTest") == ["EMBER", "API", "emberAfTest"] + assert tree_display_name("MatterSomeCall") == ["C", "MatterSomeCall"] + + assert tree_display_name("emberAfFooBarClusterServerInitCallback()") == [ + "chip", "app", "Clusters", "FooBar", "EMBER", "emberAfFooBarClusterServerInitCallback()" + ] + assert tree_display_name("emberAfFooBarClusterInitCallback()") == [ + "chip", "app", "Clusters", "FooBar", "EMBER", "emberAfFooBarClusterInitCallback()" + ] + assert tree_display_name("MatterFooBarClusterServerShutdownCallback()") == [ + "chip", "app", "Clusters", "FooBar", "EMBER", "MatterFooBarClusterServerShutdownCallback()" + ] + assert tree_display_name("emberAfFooBarClusterSomeCommandCallback()") == [ + "chip", "app", "Clusters", "FooBar", "EMBER", "SomeCommand", "emberAfFooBarClusterSomeCommandCallback()" + ] + assert tree_display_name("chip::Some::Constructor()") == [ "chip", "Some", @@ -261,6 +354,10 @@ def test_tree_display_name(): "void foo::bar::method(my::arg name, other::arg::type)" ) == ["foo", "bar", "void method(my::arg name, other::arg::type)"] + assert tree_display_name( + "(anonymous namespace)::AccessControlAttribute::Read(args)" + ) == ["(anonymous namespace)", "AccessControlAttribute", "Read(args)"] + def build_treemap( name: str, diff --git a/src/app/AttributePathExpandIterator.h b/src/app/AttributePathExpandIterator.h index e5d1f961434eb2..de63b87b01d242 100644 --- a/src/app/AttributePathExpandIterator.h +++ b/src/app/AttributePathExpandIterator.h @@ -25,6 +25,7 @@ #include #include #include +#include #include diff --git a/src/app/BUILD.gn b/src/app/BUILD.gn index 4acdf915d53639..2c1f9a0b0b49f8 100644 --- a/src/app/BUILD.gn +++ b/src/app/BUILD.gn @@ -362,10 +362,25 @@ source_set("status-response") { ] } -source_set("command-handler-interface") { +source_set("command-handler") { sources = [ "CommandHandler.cpp", "CommandHandler.h", + ] + + public_deps = [ + ":paths", + "${chip_root}/src/access:types", + "${chip_root}/src/app/data-model", + "${chip_root}/src/lib/core", + "${chip_root}/src/lib/support", + "${chip_root}/src/messaging", + "${chip_root}/src/protocols/interaction_model", + ] +} + +source_set("command-handler-interface") { + sources = [ "CommandHandlerExchangeInterface.h", "CommandHandlerInterface.h", "CommandHandlerInterfaceRegistry.cpp", @@ -373,9 +388,11 @@ source_set("command-handler-interface") { ] public_deps = [ + ":command-handler", ":paths", "${chip_root}/src/access:types", "${chip_root}/src/app/data-model", + "${chip_root}/src/app/data-model-provider", "${chip_root}/src/lib/core", "${chip_root}/src/lib/support", "${chip_root}/src/messaging", @@ -449,6 +466,18 @@ source_set("attribute-persistence") { ] } +source_set("generic-test-event-trigger-handler") { + sources = [ + "GenericEventManagementTestEventTriggerHandler.cpp", + "GenericEventManagementTestEventTriggerHandler.h", + ] + + public_deps = [ + ":test-event-trigger", + "${chip_root}/src/platform", + ] +} + # Note to developpers, instead of continuously adding files in the app librabry, it is recommand to create smaller source_sets that app can depend on. # This way, we can have a better understanding of dependencies and other componenets can depend on the different source_sets without needing to depend on the entire app library. static_library("app") { @@ -464,8 +493,6 @@ static_library("app") { "EventManagement.h", "FailSafeContext.cpp", "FailSafeContext.h", - "GenericEventManagementTestEventTriggerHandler.cpp", - "GenericEventManagementTestEventTriggerHandler.h", "OTAUserConsentCommon.h", "ReadHandler.cpp", "TimerDelegates.cpp", @@ -488,7 +515,6 @@ static_library("app") { ":global-attributes", ":interaction-model", ":path-expansion", - ":test-event-trigger", "${chip_root}/src/app/data-model", "${chip_root}/src/app/data-model-provider", "${chip_root}/src/app/icd/server:icd-server-config", diff --git a/src/app/CommandHandler.h b/src/app/CommandHandler.h index 4771a45d38f493..0d19254aa99471 100644 --- a/src/app/CommandHandler.h +++ b/src/app/CommandHandler.h @@ -17,7 +17,7 @@ */ #pragma once -#include +#include #include #include #include @@ -25,6 +25,7 @@ #include #include #include +#include #include namespace chip { diff --git a/src/app/CommandHandlerImpl.h b/src/app/CommandHandlerImpl.h index 2603b96f223c7e..ec4b9f3ad049a9 100644 --- a/src/app/CommandHandlerImpl.h +++ b/src/app/CommandHandlerImpl.h @@ -18,6 +18,8 @@ #include +#include +#include #include #include #include diff --git a/src/app/InteractionModelEngine.cpp b/src/app/InteractionModelEngine.cpp index 6a96afcf29429d..fe7105846c8892 100644 --- a/src/app/InteractionModelEngine.cpp +++ b/src/app/InteractionModelEngine.cpp @@ -2155,5 +2155,15 @@ void InteractionModelEngine::DecrementNumSubscriptionsToResume() } #endif // CHIP_CONFIG_PERSIST_SUBSCRIPTIONS +#if CHIP_CONFIG_PERSIST_SUBSCRIPTIONS && CHIP_CONFIG_SUBSCRIPTION_TIMEOUT_RESUMPTION +void InteractionModelEngine::ResetNumSubscriptionsRetries() +{ + // Check if there are any subscriptions to resume, if not the retry counter can be reset. + if (!HasSubscriptionsToResume()) + { + mNumSubscriptionResumptionRetries = 0; + } +} +#endif // CHIP_CONFIG_PERSIST_SUBSCRIPTIONS && CHIP_CONFIG_SUBSCRIPTION_TIMEOUT_RESUMPTION } // namespace app } // namespace chip diff --git a/src/app/InteractionModelEngine.h b/src/app/InteractionModelEngine.h index eb66f3eb5a4ed1..1f286f7dce2974 100644 --- a/src/app/InteractionModelEngine.h +++ b/src/app/InteractionModelEngine.h @@ -324,6 +324,14 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler, * was successful or not. */ void DecrementNumSubscriptionsToResume(); +#if CHIP_CONFIG_SUBSCRIPTION_TIMEOUT_RESUMPTION + /** + * @brief Function resets the number of retries of subscriptions resumption - mNumSubscriptionResumptionRetries. + * This should be called after we have completed a re-subscribe attempt successfully on a persisted subscription, + * or when the subscription resumption gets terminated. + */ + void ResetNumSubscriptionsRetries(); +#endif // CHIP_CONFIG_SUBSCRIPTION_TIMEOUT_RESUMPTION #endif // CHIP_CONFIG_PERSIST_SUBSCRIPTIONS #if CONFIG_BUILD_FOR_HOST_UNIT_TEST diff --git a/src/app/SubscriptionResumptionSessionEstablisher.cpp b/src/app/SubscriptionResumptionSessionEstablisher.cpp index 6e016684410fc8..ff9e4bb7522402 100644 --- a/src/app/SubscriptionResumptionSessionEstablisher.cpp +++ b/src/app/SubscriptionResumptionSessionEstablisher.cpp @@ -113,7 +113,8 @@ void SubscriptionResumptionSessionEstablisher::HandleDeviceConnected(void * cont readHandler->OnSubscriptionResumed(sessionHandle, *establisher); #if CHIP_CONFIG_SUBSCRIPTION_TIMEOUT_RESUMPTION // Reset the resumption retries to 0 if subscription is resumed - subscriptionInfo.mResumptionRetries = 0; + subscriptionInfo.mResumptionRetries = 0; + imEngine->ResetNumSubscriptionsRetries(); auto * subscriptionResumptionStorage = InteractionModelEngine::GetInstance()->GetSubscriptionResumptionStorage(); if (subscriptionResumptionStorage) { @@ -157,6 +158,9 @@ void SubscriptionResumptionSessionEstablisher::HandleDeviceConnectionFailure(voi // Clean up the persistent subscription information storage. subscriptionResumptionStorage->Delete(subscriptionInfo.mNodeId, subscriptionInfo.mFabricIndex, subscriptionInfo.mSubscriptionId); +#if CHIP_CONFIG_SUBSCRIPTION_TIMEOUT_RESUMPTION + imEngine->ResetNumSubscriptionsRetries(); +#endif // CHIP_CONFIG_SUBSCRIPTION_TIMEOUT_RESUMPTION } } diff --git a/src/app/data-model-provider/BUILD.gn b/src/app/data-model-provider/BUILD.gn index a57e7d11fbde5d..da60a3433e2a10 100644 --- a/src/app/data-model-provider/BUILD.gn +++ b/src/app/data-model-provider/BUILD.gn @@ -45,7 +45,7 @@ source_set("data-model-provider") { public_deps = [ ":metadata", "${chip_root}/src/app:attribute-access", - "${chip_root}/src/app:command-handler-interface", + "${chip_root}/src/app:command-handler", "${chip_root}/src/app:events", "${chip_root}/src/app:paths", "${chip_root}/src/app/MessageDef", diff --git a/src/app/tests/suites/certification/Test_TC_CC_3_1.yaml b/src/app/tests/suites/certification/Test_TC_CC_3_1.yaml index ed4cf48f1dea58..30dc9840186ab0 100644 --- a/src/app/tests/suites/certification/Test_TC_CC_3_1.yaml +++ b/src/app/tests/suites/certification/Test_TC_CC_3_1.yaml @@ -39,7 +39,7 @@ tests: arguments: value: 0 - - label: "Step 1b: H sends On command to DUT" + - label: "Step 1b: TH sends On command to DUT" PICS: OO.S.C01.Rsp cluster: "On/Off" command: "On" @@ -98,14 +98,15 @@ tests: - name: "ms" value: 10000 + # In 10s, the value will have changed by (120-60)*10/30 = 20. A 15% tolerance is 3, so value must be in range 80+/-3 => [77, 83] - label: "Step 2c: TH reads CurrentHue attribute from DUT" PICS: CC.S.F00 && CC.S.A0000 command: "readAttribute" attribute: "CurrentHue" response: constraints: - minValue: 68 - maxValue: 92 + minValue: 77 + maxValue: 83 - label: "Wait 10s" PICS: CC.S.F00 @@ -116,14 +117,15 @@ tests: - name: "ms" value: 10000 + # In 20s, the value will have changed by (120-60)*20/30 = 40. A 15% tolerance is 6, so value must be in range 100+/-6 => [94, 106] - label: "Step 2d: TH reads CurrentHue attribute from DUT" PICS: CC.S.F00 && CC.S.A0000 command: "readAttribute" attribute: "CurrentHue" response: constraints: - minValue: 85 - maxValue: 115 + minValue: 94 + maxValue: 106 - label: "Wait 10s" PICS: CC.S.F00 @@ -134,14 +136,15 @@ tests: - name: "ms" value: 10000 + # In 30s, the value will have changed by (120-60)*30/30 = 60. A 15% tolerance is 9, so value must be in range 120+/-9 => [111, 129] - label: "Step 2e: TH reads CurrentHue attribute from DUT" PICS: CC.S.F00 && CC.S.A0000 command: "readAttribute" attribute: "CurrentHue" response: constraints: - minValue: 102 - maxValue: 138 + minValue: 111 + maxValue: 129 - label: "Wait 5s" PICS: CC.S.F00 @@ -158,8 +161,8 @@ tests: attribute: "CurrentHue" response: constraints: - minValue: 102 - maxValue: 138 + minValue: 111 + maxValue: 129 - label: "Step 3a: TH sends MoveToHue command to DUT with Hue=60, @@ -206,61 +209,45 @@ tests: - name: "OptionsOverride" value: 0 - - label: "Wait 10s" + - label: "Wait 5s" PICS: CC.S.F00 cluster: "DelayCommands" command: "WaitForMs" arguments: values: - name: "ms" - value: 10000 + value: 5000 - #https://github.com/CHIP-Specifications/chip-test-scripts/issues/416#issuecomment-1228072461 + # In 30s, the value will have changed by 180 (total change) + # In 5s, the value will have changed by 180*5/30 = 30. A 15% tolerance is 4.5, so ~5, and value must be in range 30+/-5 => [25, 35] - label: "Step 3c: TH reads CurrentHue attribute from DUT" - PICS: CC.S.F00 && CC.S.A0000 && PICS_SKIP_SAMPLE_APP - verification: | - ./chip-tool colorcontrol read current-hue 1 1 - Verify response contains a CurrentHue value in TH(chip-tool) Logs: - - [1649661849.854961][8307:8312] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0300 Attribute 0x0000_0000 DataVersion: 4087274517 - [1649661849.855019][8307:8312] CHIP:TOO: current hue: 0 (value can vary) - [1649661849.855097][8307:8312] CHIP:EM: Sending Standalone Ack for MessageCounter:13414799 on exchange 39735i - cluster: "LogCommands" - command: "UserPrompt" - arguments: - values: - - name: "message" - value: "Enter 'y' after success" - - name: "expectedValue" - value: "y" + PICS: CC.S.F00 && CC.S.A0000 + command: "readAttribute" + attribute: "CurrentHue" + response: + constraints: + minValue: 25 + maxValue: 35 - - label: "Wait 10s" + - label: "Wait 15s" PICS: CC.S.F00 cluster: "DelayCommands" command: "WaitForMs" arguments: values: - name: "ms" - value: 10000 + value: 15000 - #https://github.com/CHIP-Specifications/chip-test-scripts/issues/493#issuecomment-1422075950 + # In 20s, the value will have changed by 180*20/30 = 120. A 15% tolerance is 18, so value must be in range + # 60-120 = 255-60 = 195+/-18 => [177, 213] - label: "Step 3d: TH reads CurrentHue attribute from DUT" - PICS: CC.S.F00 && CC.S.A0000 && PICS_SKIP_SAMPLE_APP - verification: | - ./chip-tool colorcontrol read current-hue 1 1 - - After another 10 seconds , Verify that CurrentHue value as 195 On TH(chip-tool) Logs: - [1649661821.298198][8292:8297] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0300 Attribute 0x0000_0000 DataVersion: 4087274517 - [1649661821.298271][8292:8297] CHIP:TOO: current hue: 195 (value can vary) - [1649661821.298374][8292:8297] CHIP:EM: Sending Standalone Ack for MessageCounter:13643708 on exchange 28536i - cluster: "LogCommands" - command: "UserPrompt" - arguments: - values: - - name: "message" - value: "Enter 'y' after success" - - name: "expectedValue" - value: "y" + PICS: CC.S.F00 && CC.S.A0000 + command: "readAttribute" + attribute: "CurrentHue" + response: + constraints: + minValue: 177 + maxValue: 213 - label: "Wait 10s" PICS: CC.S.F00 @@ -271,24 +258,16 @@ tests: - name: "ms" value: 10000 - #https://github.com/CHIP-Specifications/chip-test-scripts/issues/493#issuecomment-1422075950 + # In 30s, the value will have changed by 180*30/30 = 180. A 15% tolerance is 27, so value must be in range + # 60-180 = 255-120 = 135+/-27 => [108, 162] - label: "Step 3e: TH reads CurrentHue attribute from DUT" - PICS: CC.S.F00 && CC.S.A0000 && PICS_SKIP_SAMPLE_APP - verification: | - ./chip-tool colorcontrol read current-hue 1 1 - After another 10 seconds , Verify that CurrentHue value as 135 On TH(chip-tool) Logs: - - [1649661821.298198][8292:8297] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0300 Attribute 0x0000_0000 DataVersion: 4087274517 - [1649661821.298271][8292:8297] CHIP:TOO: current hue: 135 - [1649661821.298374][8292:8297] CHIP:EM: Sending Standalone Ack for MessageCounter:13643708 on exchange 28536i" - cluster: "LogCommands" - command: "UserPrompt" - arguments: - values: - - name: "message" - value: "Enter 'y' after success" - - name: "expectedValue" - value: "y" + PICS: CC.S.F00 && CC.S.A0000 + command: "readAttribute" + attribute: "CurrentHue" + response: + constraints: + minValue: 108 + maxValue: 162 - label: "Wait 5s" PICS: CC.S.F00 @@ -305,8 +284,8 @@ tests: attribute: "CurrentHue" response: constraints: - minValue: 115 - maxValue: 155 + minValue: 108 + maxValue: 162 - label: "Step 4a: TH sends MoveToHue command to DUT with Hue=60, @@ -362,14 +341,15 @@ tests: - name: "ms" value: 10000 + # In 10s, the value will have changed by (120-60)*10/30 = 20. A 15% tolerance is 3, so value must be in range 80+/-3 => [77, 83] - label: "Step 4c: TH reads CurrentHue attribute from DUT" PICS: CC.S.F00 && CC.S.A0000 command: "readAttribute" attribute: "CurrentHue" response: constraints: - minValue: 68 - maxValue: 92 + minValue: 77 + maxValue: 83 - label: "Wait 10s" PICS: CC.S.F00 @@ -380,14 +360,15 @@ tests: - name: "ms" value: 10000 + # In 20s, the value will have changed by (120-60)*20/30 = 40. A 15% tolerance is 6, so value must be in range 100+/-6 => [94, 106] - label: "Step 4d: TH reads CurrentHue attribute from DUT" PICS: CC.S.F00 && CC.S.A0000 command: "readAttribute" attribute: "CurrentHue" response: constraints: - minValue: 85 - maxValue: 115 + minValue: 94 + maxValue: 106 - label: "Wait 10s" PICS: CC.S.F00 @@ -398,14 +379,15 @@ tests: - name: "ms" value: 10000 + # In 30s, the value will have changed by (120-60)*30/30 = 60. A 15% tolerance is 9, so value must be in range 120+/-9 => [111, 129] - label: "Step 4e: TH reads CurrentHue attribute from DUT" PICS: CC.S.F00 && CC.S.A0000 command: "readAttribute" attribute: "CurrentHue" response: constraints: - minValue: 102 - maxValue: 138 + minValue: 111 + maxValue: 129 - label: "Wait 5s" PICS: CC.S.F00 @@ -422,8 +404,8 @@ tests: attribute: "CurrentHue" response: constraints: - minValue: 102 - maxValue: 138 + minValue: 111 + maxValue: 129 - label: "Step 5a: TH sends MoveToHue command to DUT with Hue=120, @@ -479,14 +461,15 @@ tests: - name: "ms" value: 10000 + # In 10s, the value will have changed by (120-60)*10/30 = 20. A 15% tolerance is 3, so value must be in range 100+/-3 => [97, 103] - label: "Step 5c: TH reads CurrentHue attribute from DUT" PICS: CC.S.F00 && CC.S.A0000 command: "readAttribute" attribute: "CurrentHue" response: constraints: - minValue: 85 - maxValue: 115 + minValue: 97 + maxValue: 103 - label: "Wait 10s" PICS: CC.S.F00 @@ -497,14 +480,15 @@ tests: - name: "ms" value: 10000 + # In 20s, the value will have changed by (120-60)*20/30 = 40. A 15% tolerance is 6, so value must be in range 80+/-6 => [74, 86] - label: "Step 5d: TH reads CurrentHue attribute from DUT" PICS: CC.S.F00 && CC.S.A0000 command: "readAttribute" attribute: "CurrentHue" response: constraints: - minValue: 68 - maxValue: 92 + minValue: 74 + maxValue: 86 - label: "Wait 10s" PICS: CC.S.F00 @@ -515,6 +499,7 @@ tests: - name: "ms" value: 10000 + # In 30s, the value will have changed by (120-60)*30/30 = 60. A 15% tolerance is 9, so value must be in range 60+/-9 => [51, 69] - label: "Step 5e: TH reads CurrentHue attribute from DUT" PICS: CC.S.F00 && CC.S.A0000 command: "readAttribute" diff --git a/src/app/zap-templates/zcl/data-model/chip/matter-devices.xml b/src/app/zap-templates/zcl/data-model/chip/matter-devices.xml index dcd0d18c99b139..b44126b7fa1650 100644 --- a/src/app/zap-templates/zcl/data-model/chip/matter-devices.xml +++ b/src/app/zap-templates/zcl/data-model/chip/matter-devices.xml @@ -1289,7 +1289,7 @@ limitations under the License. Capacity OperationMode - + diff --git a/src/app/zap-templates/zcl/data-model/chip/push-av-stream-transport-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/push-av-stream-transport-cluster.xml index f7123811868a06..59646c8cc6ee09 100644 --- a/src/app/zap-templates/zcl/data-model/chip/push-av-stream-transport-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/push-av-stream-transport-cluster.xml @@ -18,7 +18,7 @@ limitations under the License. XML generated by Alchemy; DO NOT EDIT. Source: src/app_clusters/PushAVStreamTransport.adoc Parameters: in-progress -Git: 1.4-534-g3214b3502 +Git: 0.7-summer-2025-177-gd33ec772f --> @@ -145,7 +145,7 @@ Git: 1.4-534-g3214b3502 - + Cameras Push AV Stream Transport 0x0555 PUSH_AV_STREAM_TRANSPORT_CLUSTER @@ -164,11 +164,13 @@ Git: 1.4-534-g3214b3502 This command SHALL allocate a transport and return a PushTransportConnectionID. + This command SHALL be generated in response to an AllocatePushTransport command. + @@ -203,11 +205,13 @@ Git: 1.4-534-g3214b3502 This command SHALL return the Stream Options Configuration for the specified push transport. + This command SHALL be generated in response to a FindTransport command. + diff --git a/src/app/zap-templates/zcl/data-model/chip/thread-border-router-management-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/thread-border-router-management-cluster.xml index 38612b5eb6d117..e789eca96efbb6 100644 --- a/src/app/zap-templates/zcl/data-model/chip/thread-border-router-management-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/thread-border-router-management-cluster.xml @@ -22,7 +22,7 @@ limitations under the License. - + Network Infrastructure Thread Border Router Management 0x0452 @@ -33,49 +33,49 @@ limitations under the License. - + - + - + - + - + - + - + Command to request the active operational dataset of the Thread network to which the border router is connected. This command must be sent over a valid CASE session - + Command to request the pending dataset of the Thread network to which the border router is connected. This command must be sent over a valid CASE session - + Generated response to GetActiveDatasetRequest or GetPendingDatasetRequest commands. - + Command to set or update the active Dataset of the Thread network to which the Border Router is connected. @@ -83,7 +83,7 @@ limitations under the License. - + Command set or update the pending Dataset of the Thread network to which the Border Router is connected. diff --git a/src/app/zap-templates/zcl/data-model/chip/thread-network-directory-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/thread-network-directory-cluster.xml index 2b00af31024a29..0f264414aac547 100644 --- a/src/app/zap-templates/zcl/data-model/chip/thread-network-directory-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/thread-network-directory-cluster.xml @@ -17,7 +17,7 @@ limitations under the License. - + @@ -25,7 +25,7 @@ limitations under the License. - + Network Infrastructure Thread Network Directory 0x0453 diff --git a/src/app/zap-templates/zcl/data-model/chip/wifi-network-management-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/wifi-network-management-cluster.xml index 1c14050fc24451..215fd668754211 100644 --- a/src/app/zap-templates/zcl/data-model/chip/wifi-network-management-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/wifi-network-management-cluster.xml @@ -17,7 +17,7 @@ limitations under the License. - + Network Infrastructure Wi-Fi Network Management 0x0451 diff --git a/src/controller/data_model/controller-clusters.matter b/src/controller/data_model/controller-clusters.matter index 0a7fc02e8215d5..a707dee5fe7f9b 100644 --- a/src/controller/data_model/controller-clusters.matter +++ b/src/controller/data_model/controller-clusters.matter @@ -8426,7 +8426,7 @@ cluster RadonConcentrationMeasurement = 1071 { } /** Functionality to retrieve operational information about a managed Wi-Fi network. */ -provisional cluster WiFiNetworkManagement = 1105 { +cluster WiFiNetworkManagement = 1105 { revision 1; readonly attribute nullable octet_string<32> ssid = 0; @@ -8447,19 +8447,19 @@ provisional cluster WiFiNetworkManagement = 1105 { } /** Manage the Thread network of Thread Border Router */ -provisional cluster ThreadBorderRouterManagement = 1106 { +cluster ThreadBorderRouterManagement = 1106 { revision 1; bitmap Feature : bitmap32 { kPANChange = 0x1; } - provisional readonly attribute char_string<63> borderRouterName = 0; - provisional readonly attribute octet_string<254> borderAgentID = 1; - provisional readonly attribute int16u threadVersion = 2; - provisional readonly attribute boolean interfaceEnabled = 3; - provisional readonly attribute nullable int64u activeDatasetTimestamp = 4; - provisional readonly attribute nullable int64u pendingDatasetTimestamp = 5; + readonly attribute char_string<63> borderRouterName = 0; + readonly attribute octet_string<254> borderAgentID = 1; + readonly attribute int16u threadVersion = 2; + readonly attribute boolean interfaceEnabled = 3; + readonly attribute nullable int64u activeDatasetTimestamp = 4; + readonly attribute nullable int64u pendingDatasetTimestamp = 5; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -8491,7 +8491,7 @@ provisional cluster ThreadBorderRouterManagement = 1106 { } /** Manages the names and credentials of Thread networks visible to the user. */ -provisional cluster ThreadNetworkDirectory = 1107 { +cluster ThreadNetworkDirectory = 1107 { revision 1; struct ThreadNetworkStruct { diff --git a/src/darwin/Framework/CHIP/MTRDeviceControllerFactory.mm b/src/darwin/Framework/CHIP/MTRDeviceControllerFactory.mm index 3c38c7cfd65f5c..07345f81bb7d11 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceControllerFactory.mm +++ b/src/darwin/Framework/CHIP/MTRDeviceControllerFactory.mm @@ -1200,6 +1200,10 @@ - (void)setMessageReliabilityProtocolIdleRetransmitMs:(nullable NSNumber *)idleR additionalRetransmitDelayMs:(nullable NSNumber *)additionalRetransmitDelayMs { [self _assertCurrentQueueIsNotMatterQueue]; + + MTR_LOG("%@ setting MRP params: idle %@ active %@ threshold %@ additional retransmit delay %@", + self, idleRetransmitMs, activeRetransmitMs, activeThresholdMs, additionalRetransmitDelayMs); + dispatch_async(_chipWorkQueue, ^{ bool resetAdvertising; if (idleRetransmitMs == nil && activeRetransmitMs == nil && activeThresholdMs == nil && additionalRetransmitDelayMs == nil) { diff --git a/src/lib/support/Span.h b/src/lib/support/Span.h index 18b077659be047..f3c412e9ccc403 100644 --- a/src/lib/support/Span.h +++ b/src/lib/support/Span.h @@ -206,7 +206,7 @@ class Span inline namespace literals { -inline constexpr Span operator"" _span(const char * literal, size_t size) +inline constexpr Span operator""_span(const char * literal, size_t size) { return Span(Unchecked, literal, size); } diff --git a/src/platform/BUILD.gn b/src/platform/BUILD.gn index cbde538bf22aa9..2d48c57404e19e 100644 --- a/src/platform/BUILD.gn +++ b/src/platform/BUILD.gn @@ -472,6 +472,7 @@ if (chip_device_platform != "none") { "../include/platform/ConnectivityManager.h", "../include/platform/DeviceControlServer.h", "../include/platform/DeviceInstanceInfoProvider.h", + "../include/platform/GeneralFaults.h", "../include/platform/GeneralUtils.h", "../include/platform/KeyValueStoreManager.h", "../include/platform/KvsPersistentStorageDelegate.h", diff --git a/src/platform/silabs/ConfigurationManagerImpl.cpp b/src/platform/silabs/ConfigurationManagerImpl.cpp index 8df78e4342a9d3..aba5d077cbb550 100644 --- a/src/platform/silabs/ConfigurationManagerImpl.cpp +++ b/src/platform/silabs/ConfigurationManagerImpl.cpp @@ -297,7 +297,7 @@ void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg) } ChipLogProgress(DeviceLayer, "Clearing WiFi provision"); - wfx_clear_wifi_provision(); + ClearWifiCredentials(); #endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION // Restart the system. diff --git a/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp b/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp index a5394f4d122207..5ea8ddb44ca643 100644 --- a/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp +++ b/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp @@ -143,12 +143,7 @@ ConnectivityManager::WiFiStationMode ConnectivityManagerImpl::_GetWiFiStationMod bool ConnectivityManagerImpl::_IsWiFiStationProvisioned(void) { - wfx_wifi_provision_t wifiConfig; - if (wfx_get_wifi_provision(&wifiConfig)) - { - return (wifiConfig.ssid[0] != 0); - } - return false; + return IsWifiProvisioned(); } bool ConnectivityManagerImpl::_IsWiFiStationEnabled(void) @@ -181,7 +176,7 @@ void ConnectivityManagerImpl::_ClearWiFiStationProvision(void) { if (mWiFiStationMode != kWiFiStationMode_ApplicationControlled) { - wfx_clear_wifi_provision(); + ClearWifiCredentials(); DeviceLayer::SystemLayer().ScheduleWork(DriveStationState, NULL); } @@ -304,14 +299,7 @@ void ConnectivityManagerImpl::DriveStationState() if (mWiFiStationState != kWiFiStationState_Connecting) { ChipLogProgress(DeviceLayer, "Attempting to connect WiFi"); - - sl_status_t status = wfx_connect_to_ap(); - if (status != SL_STATUS_OK) - { - ChipLogError(DeviceLayer, "wfx_connect_to_ap() failed: %" PRId32, status); - // TODO: Clean the function up to remove the usage of goto - goto exit; - } + SuccessOrExitAction(ConnectToAccessPoint(), ChipLogError(DeviceLayer, "ConnectToAccessPoint() failed")); ChangeWiFiStationState(kWiFiStationState_Connecting); } @@ -388,9 +376,9 @@ void ConnectivityManagerImpl::UpdateInternetConnectivityState(void) if (mWiFiStationState == kWiFiStationState_Connected) { #if CHIP_DEVICE_CONFIG_ENABLE_IPV4 - haveIPv4Conn = wfx_have_ipv4_addr(SL_WFX_STA_INTERFACE); + haveIPv4Conn = HasAnIPv4Address(); #endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */ - haveIPv6Conn = wfx_have_ipv6_addr(SL_WFX_STA_INTERFACE); + haveIPv6Conn = HasAnIPv6Address(); } // If the internet connectivity state has changed... diff --git a/src/platform/silabs/NetworkCommissioningWiFiDriver.cpp b/src/platform/silabs/NetworkCommissioningWiFiDriver.cpp index 1390668b842565..3d036867fc373c 100644 --- a/src/platform/silabs/NetworkCommissioningWiFiDriver.cpp +++ b/src/platform/silabs/NetworkCommissioningWiFiDriver.cpp @@ -144,22 +144,22 @@ CHIP_ERROR SlWiFiDriver::ConnectWiFiNetwork(const char * ssid, uint8_t ssidLen, ReturnErrorOnFailure(ConnectivityMgr().SetWiFiStationMode(ConnectivityManager::kWiFiStationMode_Disabled)); // Set the wifi configuration - wfx_wifi_provision_t wifiConfig; - memset(&wifiConfig, 0, sizeof(wifiConfig)); + WifiCredentials wifiConfig; + wifiConfig.Clear(); VerifyOrReturnError(ssidLen <= WFX_MAX_SSID_LENGTH, CHIP_ERROR_BUFFER_TOO_SMALL); memcpy(wifiConfig.ssid, ssid, ssidLen); - wifiConfig.ssid_length = ssidLen; + wifiConfig.ssidLength = ssidLen; VerifyOrReturnError(keyLen < WFX_MAX_PASSKEY_LENGTH, CHIP_ERROR_BUFFER_TOO_SMALL); memcpy(wifiConfig.passkey, key, keyLen); - wifiConfig.passkey_length = keyLen; + wifiConfig.passkeyLength = keyLen; wifiConfig.security = WFX_SEC_WPA2; ChipLogProgress(NetworkProvisioning, "Setting up connection for WiFi SSID: %.*s", static_cast(ssidLen), ssid); // Configure the WFX WiFi interface. - wfx_set_wifi_provision(&wifiConfig); + SetWifiCredentials(wifiConfig); ReturnErrorOnFailure(ConnectivityMgr().SetWiFiStationMode(ConnectivityManager::kWiFiStationMode_Disabled)); ReturnErrorOnFailure(ConnectivityMgr().SetWiFiStationMode(ConnectivityManager::kWiFiStationMode_Enabled)); return CHIP_NO_ERROR; @@ -326,17 +326,22 @@ void SlWiFiDriver::ScanNetworks(ByteSpan ssid, WiFiDriver::ScanCallback * callba CHIP_ERROR GetConnectedNetwork(Network & network) { - wfx_wifi_provision_t wifiConfig; + WifiCredentials wifiConfig; network.networkIDLen = 0; network.connected = false; + // we are able to fetch the wifi provision data and STA should be connected - VerifyOrReturnError(wfx_get_wifi_provision(&wifiConfig), CHIP_ERROR_UNINITIALIZED); VerifyOrReturnError(IsStationConnected(), CHIP_ERROR_NOT_CONNECTED); + ReturnErrorOnFailure(GetWifiCredentials(wifiConfig)); + VerifyOrReturnError(wifiConfig.ssidLength < NetworkCommissioning::kMaxNetworkIDLen, CHIP_ERROR_BUFFER_TOO_SMALL); + network.connected = true; - uint8_t length = strnlen(wifiConfig.ssid, DeviceLayer::Internal::kMaxWiFiSSIDLength); - VerifyOrReturnError(length < sizeof(network.networkID), CHIP_ERROR_BUFFER_TOO_SMALL); - memcpy(network.networkID, wifiConfig.ssid, length); - network.networkIDLen = length; + + ByteSpan ssidSpan(wifiConfig.ssid, wifiConfig.ssidLength); + MutableByteSpan networkIdSpan(network.networkID, NetworkCommissioning::kMaxNetworkIDLen); + + ReturnErrorOnFailure(CopySpanToMutableSpan(ssidSpan, networkIdSpan)); + network.networkIDLen = networkIdSpan.size(); return CHIP_NO_ERROR; } diff --git a/src/platform/silabs/wifi/SiWx/WifiInterfaceImpl.cpp b/src/platform/silabs/wifi/SiWx/WifiInterfaceImpl.cpp index 1ac23dbf83d0fa..b4a1f7efb00d70 100644 --- a/src/platform/silabs/wifi/SiWx/WifiInterfaceImpl.cpp +++ b/src/platform/silabs/wifi/SiWx/WifiInterfaceImpl.cpp @@ -346,16 +346,16 @@ sl_status_t ScanCallback(sl_wifi_event_t event, sl_wifi_scan_result_t * scan_res sl_status_t InitiateScan() { - sl_status_t status = SL_STATUS_OK; - - sl_wifi_ssid_t ssid = { 0 }; - + sl_status_t status = SL_STATUS_OK; + sl_wifi_ssid_t ssid = { 0 }; sl_wifi_scan_configuration_t wifi_scan_configuration = default_wifi_scan_configuration; - ssid.length = wfx_rsi.sec.ssid_length; + ssid.length = wfx_rsi.credentials.ssidLength; + + chip::ByteSpan requestedSsidSpan(wfx_rsi.credentials.ssid, wfx_rsi.credentials.ssidLength); + chip::MutableByteSpan ssidSpan(ssid.value, ssid.length); + chip::CopySpanToMutableSpan(requestedSsidSpan, ssidSpan); - // TODO: workaround because the string management with the null termination is flawed - chip::Platform::CopyString((char *) &ssid.value[0], ssid.length + 1, wfx_rsi.sec.ssid); sl_wifi_set_scan_callback(ScanCallback, NULL); osSemaphoreAcquire(sScanInProgressSemaphore, osWaitForever); @@ -394,10 +394,10 @@ sl_status_t SetWifiConfigurations() VerifyOrReturnError(status == SL_STATUS_OK, status); #endif // CHIP_CONFIG_ENABLE_ICD_SERVER - if (wfx_rsi.sec.passkey_length != 0) + if (wfx_rsi.credentials.passkeyLength != 0) { - status = sl_net_set_credential(SL_NET_DEFAULT_WIFI_CLIENT_CREDENTIAL_ID, SL_NET_WIFI_PSK, &wfx_rsi.sec.passkey[0], - wfx_rsi.sec.passkey_length); + status = sl_net_set_credential(SL_NET_DEFAULT_WIFI_CLIENT_CREDENTIAL_ID, SL_NET_WIFI_PSK, &wfx_rsi.credentials.passkey[0], + wfx_rsi.credentials.passkeyLength); VerifyOrReturnError(status == SL_STATUS_OK, status, ChipLogError(DeviceLayer, "sl_net_set_credential failed: 0x%lx", status)); } @@ -405,8 +405,9 @@ sl_status_t SetWifiConfigurations() sl_net_wifi_client_profile_t profile = { .config = { .ssid = { + .value = { 0 }, //static cast because the types dont match - .length = static_cast(wfx_rsi.sec.ssid_length), + .length = static_cast(wfx_rsi.credentials.ssidLength), }, .channel = { .channel = SL_WIFI_AUTO_CHANNEL, @@ -427,10 +428,12 @@ sl_status_t SetWifiConfigurations() .ip = {{{0}}}, } }; - // TODO: memcpy for now since the types dont match - memcpy((char *) &profile.config.ssid.value, wfx_rsi.sec.ssid, wfx_rsi.sec.ssid_length); - status = sl_net_set_profile((sl_net_interface_t) SL_NET_WIFI_CLIENT_INTERFACE, SL_NET_DEFAULT_WIFI_CLIENT_PROFILE_ID, &profile); + chip::MutableByteSpan output(profile.config.ssid.value, WFX_MAX_SSID_LENGTH); + chip::ByteSpan input(wfx_rsi.credentials.ssid, wfx_rsi.credentials.ssidLength); + chip::CopySpanToMutableSpan(input, output); + + status = sl_net_set_profile(SL_NET_WIFI_CLIENT_INTERFACE, SL_NET_DEFAULT_WIFI_CLIENT_PROFILE_ID, &profile); VerifyOrReturnError(status == SL_STATUS_OK, status, ChipLogError(DeviceLayer, "sl_net_set_profile failed: 0x%lx", status)); return status; @@ -460,7 +463,7 @@ sl_status_t JoinCallback(sl_wifi_event_t event, char * result, uint32_t resultLe status = *reinterpret_cast(result); ChipLogError(DeviceLayer, "JoinCallback: failed: 0x%lx", status); wfx_rsi.dev_state.Clear(WifiState::kStationConnected); - wfx_retry_connection(++wfx_rsi.join_retries); + ScheduleConnectionAttempt(); } return status; @@ -486,7 +489,7 @@ sl_status_t JoinWifiNetwork(void) chip::DeviceLayer::Silabs::WifiSleepManager::GetInstance().RequestHighPerformance(); #endif // CHIP_CONFIG_ENABLE_ICD_SERVER - status = sl_net_up((sl_net_interface_t) SL_NET_WIFI_CLIENT_INTERFACE, SL_NET_DEFAULT_WIFI_CLIENT_PROFILE_ID); + status = sl_net_up(SL_NET_WIFI_CLIENT_INTERFACE, SL_NET_DEFAULT_WIFI_CLIENT_PROFILE_ID); if (status == SL_STATUS_OK || status == SL_STATUS_IN_PROGRESS) { @@ -504,9 +507,7 @@ sl_status_t JoinWifiNetwork(void) ChipLogError(DeviceLayer, "sl_wifi_connect failed: 0x%lx", static_cast(status)); wfx_rsi.dev_state.Clear(WifiState::kStationConnecting).Clear(WifiState::kStationConnected); - - ChipLogProgress(DeviceLayer, "Connection retry attempt %d", wfx_rsi.join_retries); - wfx_retry_connection(++wfx_rsi.join_retries); + ScheduleConnectionAttempt(); return status; } @@ -515,19 +516,18 @@ sl_status_t JoinWifiNetwork(void) sl_status_t TriggerPlatformWifiDisconnection() { - return sl_net_down((sl_net_interface_t) SL_NET_WIFI_CLIENT_INTERFACE); + return sl_net_down(SL_NET_WIFI_CLIENT_INTERFACE); } CHIP_ERROR GetAccessPointInfo(wfx_wifi_scan_result_t & info) { // TODO: Convert this to a int8 int32_t rssi = 0; - info.security = wfx_rsi.sec.security; + info.security = wfx_rsi.credentials.security; info.chan = wfx_rsi.ap_chan; chip::MutableByteSpan output(info.ssid, WFX_MAX_SSID_LENGTH); - // Cast is a workaround until the wfx_rsi structure is refactored - chip::ByteSpan ssid(reinterpret_cast(wfx_rsi.sec.ssid), wfx_rsi.sec.ssid_length); + chip::ByteSpan ssid(wfx_rsi.credentials.ssid, wfx_rsi.credentials.ssidLength); chip::CopySpanToMutableSpan(ssid, output); info.ssid_length = output.size(); @@ -582,7 +582,7 @@ CHIP_ERROR InitWiFiStack(void) { sl_status_t status = SL_STATUS_OK; - status = sl_net_init((sl_net_interface_t) SL_NET_WIFI_CLIENT_INTERFACE, &config, &wifi_client_context, nullptr); + status = sl_net_init(SL_NET_WIFI_CLIENT_INTERFACE, &config, &wifi_client_context, nullptr); VerifyOrReturnError(status == SL_STATUS_OK, CHIP_ERROR_INTERNAL, ChipLogError(DeviceLayer, "sl_net_init failed: %lx", status)); // Create Sempaphore for scan completion @@ -793,7 +793,7 @@ void MatterWifiTask(void * arg) VerifyOrReturn(status == SL_STATUS_OK, ChipLogError(DeviceLayer, "MatterWifiTask: sl_wifi_siwx917_init failed: 0x%lx", static_cast(status))); - sl_matter_wifi_task_started(); + NotifyWifiTaskInitialized(); ChipLogDetail(DeviceLayer, "MatterWifiTask: starting event loop"); for (;;) diff --git a/src/platform/silabs/wifi/WifiInterface.cpp b/src/platform/silabs/wifi/WifiInterface.cpp index 13d803836fcd5c..14cacad8e576fe 100644 --- a/src/platform/silabs/wifi/WifiInterface.cpp +++ b/src/platform/silabs/wifi/WifiInterface.cpp @@ -56,16 +56,14 @@ bool hasNotifiedIPV4 = false; */ void RetryConnectionTimerHandler(void * arg) { - if (wfx_connect_to_ap() != SL_STATUS_OK) + if (ConnectToAccessPoint() != CHIP_NO_ERROR) { - ChipLogError(DeviceLayer, "wfx_connect_to_ap() failed."); + ChipLogError(DeviceLayer, "ConnectToAccessPoint() failed."); } } } // namespace -/* Updated functions */ - void NotifyIPv6Change(bool gotIPv6Addr) { hasNotifiedIPV6 = gotIPv6Addr; @@ -132,19 +130,12 @@ void ResetIPNotificationStates() hasNotifiedIPV4 = false; #endif // CHIP_DEVICE_CONFIG_ENABLE_IPV4 } -/* Function to update */ - -/*********************************************************************************** - * @fn sl_matter_wifi_task_started(void) - * @brief - * Wifi device started notification - * @param[in]: None - * @return None - *************************************************************************************/ -void sl_matter_wifi_task_started(void) + +void NotifyWifiTaskInitialized(void) { sl_wfx_startup_ind_t evt = {}; + // TODO: We should move this to the init function and not the notification function // Creating a timer which will be used to retry connection with AP sRetryTimer = osTimerNew(RetryConnectionTimerHandler, osTimerOnce, NULL, NULL); VerifyOrReturn(sRetryTimer != NULL); @@ -166,16 +157,8 @@ void sl_matter_wifi_task_started(void) HandleWFXSystemEvent((sl_wfx_generic_message_t *) &evt); } -/************************************************************************************** - * @fn void wfx_retry_connection(uint16_t retryAttempt) - * @brief - * During commissioning, we retry to join the network MAX_JOIN_RETRIES_COUNT times. - * If DUT is disconnected from the AP or device is power cycled, then retry connection - * with AP continously after a certain time interval. - * @param[in] retryAttempt - * @return None - *************************************************************************************/ -void wfx_retry_connection(uint16_t retryAttempt) +// TODO: The retry stategy needs to be re-worked +void ScheduleConnectionAttempt() { if (retryInterval > kWlanMaxRetryIntervalsInSec) { @@ -185,9 +168,9 @@ void wfx_retry_connection(uint16_t retryAttempt) { ChipLogProgress(DeviceLayer, "Failed to start retry timer"); // Sending the join command if retry timer failed to start - if (wfx_connect_to_ap() != SL_STATUS_OK) + if (ConnectToAccessPoint() != CHIP_NO_ERROR) { - ChipLogError(DeviceLayer, "wfx_connect_to_ap() failed."); + ChipLogError(DeviceLayer, "ConnectToAccessPoint() failed."); } #if CHIP_CONFIG_ENABLE_ICD_SERVER @@ -201,6 +184,6 @@ void wfx_retry_connection(uint16_t retryAttempt) Silabs::WifiSleepManager::GetInstance().RemoveHighPerformanceRequest(); #endif // CHIP_CONFIG_ENABLE_ICD_SERVER - ChipLogProgress(DeviceLayer, "wfx_retry_connection : Next attempt after %d Seconds", retryInterval); + ChipLogProgress(DeviceLayer, "ScheduleConnectionAttempt : Next attempt after %d Seconds", retryInterval); retryInterval += retryInterval; } diff --git a/src/platform/silabs/wifi/WifiInterface.h b/src/platform/silabs/wifi/WifiInterface.h index 0ed969a9325fea..aff1baf4eb599c 100644 --- a/src/platform/silabs/wifi/WifiInterface.h +++ b/src/platform/silabs/wifi/WifiInterface.h @@ -17,6 +17,7 @@ #pragma once #include +#include #include #include #include @@ -105,15 +106,6 @@ typedef enum WFX_SEC_WPA_WPA2_MIXED = 6, } wfx_sec_t; -typedef struct -{ - char ssid[WFX_MAX_SSID_LENGTH + 1]; - size_t ssid_length; - char passkey[WFX_MAX_PASSKEY_LENGTH + 1]; - size_t passkey_length; - wfx_sec_t security; -} wfx_wifi_provision_t; - typedef struct wfx_wifi_scan_result { uint8_t ssid[WFX_MAX_SSID_LENGTH]; // excludes null-character @@ -148,11 +140,43 @@ typedef enum } sl_wfx_interface_t; #endif +// TODO: Figure out if we need this structure. We have different strcutures for the same use +struct WifiCredentials +{ + uint8_t ssid[WFX_MAX_SSID_LENGTH] = { 0 }; + size_t ssidLength = 0; + uint8_t passkey[WFX_MAX_PASSKEY_LENGTH] = { 0 }; + size_t passkeyLength = 0; + wfx_sec_t security = WFX_SEC_UNSPECIFIED; + + WifiCredentials & operator=(const WifiCredentials & other) + { + if (this != &other) + { + memcpy(ssid, other.ssid, WFX_MAX_SSID_LENGTH); + ssidLength = other.ssidLength; + memcpy(passkey, other.passkey, WFX_MAX_PASSKEY_LENGTH); + passkeyLength = other.passkeyLength; + security = other.security; + } + return *this; + } + + void Clear() + { + memset(ssid, 0, WFX_MAX_SSID_LENGTH); + ssidLength = 0; + memset(passkey, 0, WFX_MAX_PASSKEY_LENGTH); + passkeyLength = 0; + security = WFX_SEC_UNSPECIFIED; + } +}; + typedef struct wfx_rsi_s { chip::BitFlags dev_state; uint16_t ap_chan; /* The chan our STA is using */ - wfx_wifi_provision_t sec; + WifiCredentials credentials; ScanCallback scan_cb; uint8_t * scan_ssid; /* Which one are we scanning for */ size_t scan_ssid_length; @@ -162,7 +186,6 @@ typedef struct wfx_rsi_s MacAddress sta_mac; MacAddress ap_mac; /* To which our STA is connected */ MacAddress ap_bssid; /* To which our STA is connected */ - uint16_t join_retries; uint8_t ip4_addr[4]; /* Not sure if this is enough */ } WfxRsi_t; @@ -361,6 +384,55 @@ CHIP_ERROR ResetCounters(); */ CHIP_ERROR ConfigureBroadcastFilter(bool enableBroadcastFilter); +/** + * @brief Clears the stored Wi-Fi crendetials stored in RAM only + */ +void ClearWifiCredentials(); + +/** + * @brief Stores the Wi-Fi credentials + * + * @note Function does not validate if the device already has Wi-Fi credentials. + * It is the responsibility of the caller to ensuret that. + * The function will overwrite any existing Wi-Fi credentials. + * + * @param[in] credentials + */ +void SetWifiCredentials(const WifiCredentials & credentials); + +/** + * @brief Returns the configured Wi-Fi credentials + * + * @param[out] credentials stored wifi crendetials + * + * @return CHIP_ERROR CHIP_ERROR_INCORRECT_STATE, if the device does not have any set credentials + * CHIP_NO_ERROR, otherwise + */ +CHIP_ERROR GetWifiCredentials(WifiCredentials & credentials); + +/** + * @brief Returns the state of the Wi-Fi network provisionning + * Does the device has Wi-Fi credentials or not + * + * @return true, the device has Wi-Fi credentials + * false, otherwise + */ +bool IsWifiProvisioned(); + +/** + * @brief Triggers a connection attempt the Access Point who's crendetials match the ones store with the SetWifiCredentials API. + * The function triggers an async connection attempt. The upper layers are notified trought a platform event if the + * connection attempt was successful or not. + * + * The returned error code only indicates if the connection attempt was triggered or not. + * + * @return CHIP_ERROR CHIP_NO_ERROR, the connection attempt was succesfully triggered + * CHIP_ERROR_INCORRECT_STATE, the Wi-Fi station does not have any Wi-Fi credentials + * CHIP_ERROR_INVALID_ARGUMENT, the provisionned crendetials do not match the Wi-Fi station requirements + * CHIP_ERROR_INTERNAL, otherwise + */ +CHIP_ERROR ConnectToAccessPoint(void); + /* Function to update */ // TODO: Harmonize the Power Save function inputs for all platforms @@ -373,21 +445,42 @@ CHIP_ERROR ConfigurePowerSave(); #endif /* (SLI_SI91X_MCU_INTERFACE | EXP_BOARD) */ #endif // CHIP_CONFIG_ENABLE_ICD_SERVER -void wfx_set_wifi_provision(wfx_wifi_provision_t * wifiConfig); -bool wfx_get_wifi_provision(wfx_wifi_provision_t * wifiConfig); -void wfx_clear_wifi_provision(void); -sl_status_t wfx_connect_to_ap(void); - #if CHIP_DEVICE_CONFIG_ENABLE_IPV4 -bool wfx_have_ipv4_addr(sl_wfx_interface_t); +/** + * @brief Returns IP assignment status + * + + * @return true, Wi-Fi station has an IPv4 address + * false, otherwise + */ +bool HasAnIPv4Address(); #endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */ -bool wfx_have_ipv6_addr(sl_wfx_interface_t); -void wfx_cancel_scan(void); +/** + * @brief Returns IP assignment status + * + + * @return true, Wi-Fi station has an IPv6 address + * false, otherwise + */ +bool HasAnIPv6Address(); -/* - * Call backs into the Matter Platform code +/** + * @brief Cancels the on-going network scan operation. + * If one isn't in-progress, function doesn't do anything */ -void sl_matter_wifi_task_started(void); +void CancelScanNetworks(); -void wfx_retry_connection(uint16_t retryAttempt); +/** + * @brief Notifies upper-layers that Wi-Fi initialization has succesfully completed + */ +void NotifyWifiTaskInitialized(void); + +/** + * @brief Function schedules a reconnection attempt with the Access Point + * + * @note The retry interval increases exponentially with each attempt, starting from a minimum value and doubling each time, + * up to a maximum value. For example, if the initial retry interval is 1 second, the subsequent intervals will be 2 seconds, + * 4 seconds, 8 seconds, and so on, until the maximum retry interval is reached. + */ +void ScheduleConnectionAttempt(); diff --git a/src/platform/silabs/wifi/icd/WifiSleepManager.cpp b/src/platform/silabs/wifi/icd/WifiSleepManager.cpp index 702ee38203697f..72de8a0290d4f3 100644 --- a/src/platform/silabs/wifi/icd/WifiSleepManager.cpp +++ b/src/platform/silabs/wifi/icd/WifiSleepManager.cpp @@ -148,11 +148,7 @@ CHIP_ERROR WifiSleepManager::VerifyAndTransitionToLowPowerMode(PowerEvent event) return CHIP_NO_ERROR; } - // TODO: Clean this up when the Wi-Fi interface re-work is finished - wfx_wifi_provision_t wifiConfig; - wfx_get_wifi_provision(&wifiConfig); - - if (!(wifiConfig.ssid[0] != 0)) + if (!IsWifiProvisioned()) { return ConfigureDeepSleep(); } diff --git a/src/platform/silabs/wifi/rs911x/WifiInterfaceImpl.cpp b/src/platform/silabs/wifi/rs911x/WifiInterfaceImpl.cpp index d31e384b330ec1..d7615dbed9695b 100644 --- a/src/platform/silabs/wifi/rs911x/WifiInterfaceImpl.cpp +++ b/src/platform/silabs/wifi/rs911x/WifiInterfaceImpl.cpp @@ -90,7 +90,7 @@ CHIP_ERROR GetAccessPointInfo(wfx_wifi_scan_result_t & info) int32_t status = RSI_SUCCESS; uint8_t rssi = 0; - info.security = wfx_rsi.sec.security; + info.security = wfx_rsi.credentials.security; info.chan = wfx_rsi.ap_chan; memcpy(&(info.bssid[0]), wfx_rsi.ap_mac.data(), kWifiMacAddressLength); @@ -192,11 +192,7 @@ static void wfx_rsi_join_cb(uint16_t status, const uint8_t * buf, const uint16_t wfx_rsi.dev_state.Clear(WifiState::kStationConnecting); if (status != RSI_SUCCESS) { - /* - * We should enable retry.. (Need config variable for this) - */ - ChipLogProgress(DeviceLayer, "wfx_rsi_join_cb: failed. retry: %d", wfx_rsi.join_retries); - wfx_retry_connection(++wfx_rsi.join_retries); + ScheduleConnectionAttempt(); return; } @@ -207,7 +203,6 @@ static void wfx_rsi_join_cb(uint16_t status, const uint8_t * buf, const uint16_t memset(&temp_reset, 0, sizeof(wfx_wifi_scan_ext_t)); WifiPlatformEvent event = WifiPlatformEvent::kStationConnect; PostWifiPlatformEvent(event); - wfx_rsi.join_retries = 0; } /****************************************************************** @@ -223,7 +218,6 @@ static void wfx_rsi_join_cb(uint16_t status, const uint8_t * buf, const uint16_t static void wfx_rsi_join_fail_cb(uint16_t status, uint8_t * buf, uint32_t len) { ChipLogError(DeviceLayer, "wfx_rsi_join_fail_cb: status: %d", status); - wfx_rsi.join_retries += 1; wfx_rsi.dev_state.Clear(WifiState::kStationConnecting).Clear(WifiState::kStationConnected); @@ -369,59 +363,59 @@ static void wfx_rsi_save_ap_info(void) // translation int32_t status; rsi_rsp_scan_t rsp; - status = - rsi_wlan_scan_with_bitmap_options((int8_t *) &wfx_rsi.sec.ssid[0], AP_CHANNEL_NO_0, &rsp, sizeof(rsp), SCAN_BITMAP_OPTN_1); + status = rsi_wlan_scan_with_bitmap_options((int8_t *) &wfx_rsi.credentials.ssid[0], AP_CHANNEL_NO_0, &rsp, sizeof(rsp), + SCAN_BITMAP_OPTN_1); if (status != RSI_SUCCESS) { /* * Scan is done - failed */ #if WIFI_ENABLE_SECURITY_WPA3_TRANSITION - wfx_rsi.sec.security = WFX_SEC_WPA3; + wfx_rsi.credentials.security = WFX_SEC_WPA3; #else /* !WIFI_ENABLE_SECURITY_WPA3_TRANSITION */ - wfx_rsi.sec.security = WFX_SEC_WPA2; + wfx_rsi.credentials.security = WFX_SEC_WPA2; #endif /* WIFI_ENABLE_SECURITY_WPA3_TRANSITION */ ChipLogProgress(DeviceLayer, "warn: scan failed: %ld", status); return; } - wfx_rsi.sec.security = WFX_SEC_UNSPECIFIED; - wfx_rsi.ap_chan = rsp.scan_info->rf_channel; + wfx_rsi.credentials.security = WFX_SEC_UNSPECIFIED; + wfx_rsi.ap_chan = rsp.scan_info->rf_channel; memcpy(wfx_rsi.ap_mac.data(), &rsp.scan_info->bssid[0], kWifiMacAddressLength); switch (rsp.scan_info->security_mode) { case SME_OPEN: - wfx_rsi.sec.security = WFX_SEC_NONE; + wfx_rsi.credentials.security = WFX_SEC_NONE; break; case SME_WPA: case SME_WPA_ENTERPRISE: - wfx_rsi.sec.security = WFX_SEC_WPA; + wfx_rsi.credentials.security = WFX_SEC_WPA; break; case SME_WPA2: case SME_WPA2_ENTERPRISE: - wfx_rsi.sec.security = WFX_SEC_WPA2; + wfx_rsi.credentials.security = WFX_SEC_WPA2; break; case SME_WPA_WPA2_MIXED_MODE: - wfx_rsi.sec.security = WFX_SEC_WPA_WPA2_MIXED; + wfx_rsi.credentials.security = WFX_SEC_WPA_WPA2_MIXED; break; case SME_WEP: - wfx_rsi.sec.security = WFX_SEC_WEP; + wfx_rsi.credentials.security = WFX_SEC_WEP; break; case SME_WPA3_PERSONAL_TRANSITION: #if WIFI_ENABLE_SECURITY_WPA3_TRANSITION case SME_WPA3_PERSONAL: - wfx_rsi.sec.security = WFX_SEC_WPA3; + wfx_rsi.credentials.security = WFX_SEC_WPA3; #else - wfx_rsi.sec.security = WFX_SEC_WPA2; + wfx_rsi.credentials.security = WFX_SEC_WPA2; #endif /* WIFI_ENABLE_SECURITY_WPA3_TRANSITION */ break; default: - wfx_rsi.sec.security = WFX_SEC_UNSPECIFIED; + wfx_rsi.credentials.security = WFX_SEC_UNSPECIFIED; break; } - ChipLogProgress(DeviceLayer, "wfx_rsi_save_ap_info: connecting to %s, sec=%d, status=%ld", &wfx_rsi.sec.ssid[0], - wfx_rsi.sec.security, status); + ChipLogProgress(DeviceLayer, "wfx_rsi_save_ap_info: connecting to %s, sec=%d, status=%ld", &wfx_rsi.credentials.ssid[0], + wfx_rsi.credentials.security, status); } /******************************************************************************************** @@ -438,7 +432,7 @@ static void sl_wifi_platform_join_network(void) VerifyOrReturn(!wfx_rsi.dev_state.HasAny(WifiState::kStationConnecting, WifiState::kStationConnected)); - switch (wfx_rsi.sec.security) + switch (wfx_rsi.credentials.security) { case WFX_SEC_WEP: connect_security_mode = RSI_WEP; @@ -461,8 +455,8 @@ static void sl_wifi_platform_join_network(void) return; } - ChipLogProgress(DeviceLayer, "sl_wifi_platform_join_network: connecting to %s, sec=%d", &wfx_rsi.sec.ssid[0], - wfx_rsi.sec.security); + ChipLogProgress(DeviceLayer, "sl_wifi_platform_join_network: connecting to %s, sec=%d", &wfx_rsi.credentials.ssid[0], + wfx_rsi.credentials.security); /* * Join the network @@ -480,13 +474,11 @@ static void sl_wifi_platform_join_network(void) /* Try to connect Wifi with given Credentials * until there is a success or maximum number of tries allowed */ - if ((status = rsi_wlan_connect_async((int8_t *) &wfx_rsi.sec.ssid[0], connect_security_mode, &wfx_rsi.sec.passkey[0], - wfx_rsi_join_cb)) != RSI_SUCCESS) + if ((status = rsi_wlan_connect_async((int8_t *) &wfx_rsi.credentials.ssid[0], connect_security_mode, + &wfx_rsi.credentials.passkey[0], wfx_rsi_join_cb)) != RSI_SUCCESS) { wfx_rsi.dev_state.Clear(WifiState::kStationConnecting); - ChipLogProgress(DeviceLayer, "sl_wifi_platform_join_network: rsi_wlan_connect_async failed: %ld on try %d", status, - wfx_rsi.join_retries); - wfx_retry_connection(++wfx_rsi.join_retries); + ScheduleConnectionAttempt(); } } @@ -675,7 +667,7 @@ void MatterWifiTask(void * arg) (void) arg; WifiPlatformEvent event; chip::DeviceLayer::Silabs::Lwip::InitializeLwip(); - sl_matter_wifi_task_started(); + NotifyWifiTaskInitialized(); ChipLogProgress(DeviceLayer, "MatterWifiTask: starting event loop"); for (;;) diff --git a/src/platform/silabs/wifi/wf200/WifiInterfaceImpl.cpp b/src/platform/silabs/wifi/wf200/WifiInterfaceImpl.cpp index e15b24dddf11da..d14c9d649e6425 100644 --- a/src/platform/silabs/wifi/wf200/WifiInterfaceImpl.cpp +++ b/src/platform/silabs/wifi/wf200/WifiInterfaceImpl.cpp @@ -104,12 +104,10 @@ uint8_t softap_channel = SOFTAP_CHANNEL_DEFAULT; /* station network interface structures */ struct netif * sta_netif; -wfx_wifi_provision_t wifi_provision; +WifiCredentials wifi_provision; #define PUT_COUNTER(name) ChipLogDetail(DeviceLayer, "%-24s %lu", #name, (unsigned long) counters->body.count_##name); bool hasNotifiedWifiConnectivity = false; -static uint8_t retryJoin = 0; -bool retryInProgress = false; static struct scan_result_holder { @@ -484,6 +482,107 @@ CHIP_ERROR ConfigureBroadcastFilter(bool enableBroadcastFilter) } #endif // CHIP_CONFIG_ENABLE_ICD_SERVER +CHIP_ERROR ResetCounters() +{ + // TODO: Implement the function + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +void ClearWifiCredentials() +{ + wifi_provision.Clear(); +} + +CHIP_ERROR GetWifiCredentials(WifiCredentials & credentials) +{ + VerifyOrReturnError(IsWifiProvisioned(), CHIP_ERROR_INCORRECT_STATE); + credentials = wifi_provision; + + return CHIP_NO_ERROR; +} + +bool IsWifiProvisioned() +{ + // TODO: We need a better way of checking if we are provisioned or not + return wifi_provision.ssid[0] != 0; +} + +void SetWifiCredentials(const WifiCredentials & credentials) +{ + wifi_provision = credentials; +} + +CHIP_ERROR ConnectToAccessPoint(void) +{ + sl_wfx_security_mode_t connect_security_mode; + + VerifyOrReturnError(IsWifiProvisioned(), CHIP_ERROR_INCORRECT_STATE); + ChipLogDetail(DeviceLayer, "WIFI:JOIN to %s", wifi_provision.ssid); + + ChipLogDetail(DeviceLayer, + "WIFI Scan Paramter set to Active channel time %d, Passive Channel " + "Time: %d, Number of prob: %d", + ACTIVE_CHANNEL_TIME, PASSIVE_CHANNEL_TIME, NUM_PROBE_REQUEST); + (void) sl_wfx_set_scan_parameters(ACTIVE_CHANNEL_TIME, PASSIVE_CHANNEL_TIME, NUM_PROBE_REQUEST); + switch (wifi_provision.security) + { + case WFX_SEC_WEP: + connect_security_mode = sl_wfx_security_mode_e::WFM_SECURITY_MODE_WEP; + break; + case WFX_SEC_WPA: + case WFX_SEC_WPA2: + connect_security_mode = sl_wfx_security_mode_e::WFM_SECURITY_MODE_WPA2_WPA1_PSK; + break; + case WFX_SEC_WPA3: + connect_security_mode = sl_wfx_security_mode_e::WFM_SECURITY_MODE_WPA3_SAE; + break; + case WFX_SEC_NONE: + connect_security_mode = sl_wfx_security_mode_e::WFM_SECURITY_MODE_OPEN; + break; + default: + ChipLogError(DeviceLayer, "error: unknown security type."); + return CHIP_ERROR_INVALID_ARGUMENT; + } + + VerifyOrReturnError(sl_wfx_send_join_command(wifi_provision.ssid, wifi_provision.ssidLength, NULL, CHANNEL_0, + connect_security_mode, PREVENT_ROAMING, DISABLE_PMF_MODE, wifi_provision.passkey, + wifi_provision.passkeyLength, NULL, IE_DATA_LENGTH) == SL_STATUS_OK, + CHIP_ERROR_INTERNAL); + + return CHIP_NO_ERROR; +} + +bool HasAnIPv4Address() +{ + return (sta_ip == STA_IP_FAIL) ? false : true; +} + +bool HasAnIPv6Address() +{ + return IsStationConnected(); +} + +void CancelScanNetworks() +{ + struct scan_result_holder *hp, *next; + /* Not possible */ + VerifyOrReturn(scan_cb != nullptr); + sl_wfx_send_stop_scan_command(); + for (hp = scan_save; hp; hp = next) + { + next = hp->next; + chip::Platform::MemoryFree(hp); + } + scan_save = (struct scan_result_holder *) 0; + scan_count = 0; + if (scan_ssid) + { + chip::Platform::MemoryFree(scan_ssid); + scan_ssid = nullptr; + } + scan_cb = nullptr; +} + /*************************************************************************** * @brief * Creates WFX events processing task. @@ -737,11 +836,7 @@ static void sl_wfx_connect_callback(sl_wfx_connect_ind_body_t connect_indication if (status != WFM_STATUS_SUCCESS) { - retryJoin += 1; - retryInProgress = false; - ChipLogProgress(DeviceLayer, "Retry to connect to network count: %d", retryJoin); - - wfx_retry_connection(retryJoin); + ScheduleConnectionAttempt(); } } @@ -757,8 +852,7 @@ static void sl_wfx_disconnect_callback(uint8_t * mac, uint16_t reason) ChipLogProgress(DeviceLayer, "Disconnected %d", reason); wifi_extra.Clear(WifiState::kStationConnected); - retryInProgress = false; - wfx_retry_connection(retryJoin); + ScheduleConnectionAttempt(); } #ifdef SL_WFX_CONFIG_SOFTAP @@ -860,7 +954,7 @@ static void wfx_events_task(void * p_arg) if (flags & SL_WFX_RETRY_CONNECT) { ChipLogProgress(DeviceLayer, "sending the connect command"); - wfx_connect_to_ap(); + ConnectToAccessPoint(); } if (wifi_extra.Has(WifiState::kStationConnected)) @@ -907,7 +1001,6 @@ static void wfx_events_task(void * p_arg) hasNotifiedWifiConnectivity = false; ChipLogProgress(DeviceLayer, "connected to AP"); wifi_extra.Set(WifiState::kStationConnected); - retryJoin = 0; chip::DeviceLayer::Silabs::Lwip::SetLwipStationLinkUp(); #if CHIP_CONFIG_ENABLE_ICD_SERVER if (!(wifi_extra.Has(WifiState::kAPReady))) @@ -1064,7 +1157,7 @@ static sl_status_t wfx_wifi_hw_start(void) /* Initialize the LwIP stack */ ChipLogDetail(DeviceLayer, "WF200:Start LWIP"); chip::DeviceLayer::Silabs::Lwip::InitializeLwip(); - sl_matter_wifi_task_started(); + NotifyWifiTaskInitialized(); ChipLogDetail(DeviceLayer, "WF200:ready."); wifi_extra.Set(WifiState::kStationStarted); @@ -1072,146 +1165,6 @@ static sl_status_t wfx_wifi_hw_start(void) return SL_STATUS_OK; } -CHIP_ERROR ResetCounters() -{ - // TODO: Implement the function - return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; -} - -/**************************************************************************** - * @brief - * set the wifi provision - * @param[in] wifiConfig: configuration of wifi - *****************************************************************************/ -void wfx_set_wifi_provision(wfx_wifi_provision_t * wifiConfig) -{ - Platform::CopyString(wifi_provision.ssid, sizeof(wifi_provision.ssid), wifiConfig->ssid); - Platform::CopyString(wifi_provision.passkey, sizeof(wifi_provision.passkey), wifiConfig->passkey); - wifi_provision.security = wifiConfig->security; - ChipLogProgress(DeviceLayer, "WIFI: Provision SSID=%s", &wifi_provision.ssid[0]); -} - -/**************************************************************************** - * @brief - * get the wifi provision - * @param[in] wifiConfig: configuration of wifi - * @return returns true if successful, - * false otherwise - *****************************************************************************/ -bool wfx_get_wifi_provision(wfx_wifi_provision_t * wifiConfig) -{ - VerifyOrReturnError(wifiConfig != nullptr, false); - memcpy(wifiConfig, &wifi_provision, sizeof(wfx_wifi_provision_t)); - return true; -} - -/**************************************************************************** - * @brief - * clear the wifi provision - * @return returns true if successful, - * false otherwise - *****************************************************************************/ -void wfx_clear_wifi_provision(void) -{ - memset(&wifi_provision, 0, sizeof(wifi_provision)); -} - -/**************************************************************************** - * @fn sl_status_t wfx_connect_to_ap(void) - * @brief - * driver connect to ap - * @return returns SL_STATUS_NOT_AVAILABLE - *****************************************************************************/ -sl_status_t wfx_connect_to_ap(void) -{ - sl_status_t result; - sl_wfx_security_mode_t connect_security_mode; - - VerifyOrReturnError(wifi_provision.ssid[0], SL_STATUS_NOT_AVAILABLE); - ChipLogDetail(DeviceLayer, "WIFI:JOIN to %s", &wifi_provision.ssid[0]); - - ChipLogDetail(DeviceLayer, - "WIFI Scan Paramter set to Active channel time %d, Passive Channel " - "Time: %d, Number of prob: %d", - ACTIVE_CHANNEL_TIME, PASSIVE_CHANNEL_TIME, NUM_PROBE_REQUEST); - (void) sl_wfx_set_scan_parameters(ACTIVE_CHANNEL_TIME, PASSIVE_CHANNEL_TIME, NUM_PROBE_REQUEST); - switch (wifi_provision.security) - { - case WFX_SEC_WEP: - connect_security_mode = sl_wfx_security_mode_e::WFM_SECURITY_MODE_WEP; - break; - case WFX_SEC_WPA: - case WFX_SEC_WPA2: - connect_security_mode = sl_wfx_security_mode_e::WFM_SECURITY_MODE_WPA2_WPA1_PSK; - break; - case WFX_SEC_WPA3: - connect_security_mode = sl_wfx_security_mode_e::WFM_SECURITY_MODE_WPA3_SAE; - break; - case WFX_SEC_NONE: - connect_security_mode = sl_wfx_security_mode_e::WFM_SECURITY_MODE_OPEN; - break; - default: - ChipLogError(DeviceLayer, "error: unknown security type."); - return SL_STATUS_INVALID_STATE; - } - result = sl_wfx_send_join_command((uint8_t *) wifi_provision.ssid, strlen(wifi_provision.ssid), NULL, CHANNEL_0, - connect_security_mode, PREVENT_ROAMING, DISABLE_PMF_MODE, (uint8_t *) wifi_provision.passkey, - strlen(wifi_provision.passkey), NULL, IE_DATA_LENGTH); - - return result; -} - -/**************************************************************************** - * @brief - * function called when driver have ipv4 address - * @param[in] which_if: - * @return returns false if sucessful, - * true otherwise - *****************************************************************************/ -bool wfx_have_ipv4_addr(sl_wfx_interface_t which_if) -{ - VerifyOrReturnError(which_if == SL_WFX_STA_INTERFACE, false); - return (sta_ip == STA_IP_FAIL) ? false : true; -} - -/**************************************************************************** - * @brief - * function called when driver have ipv6 address - * @param[in] which_if: - * @return returns false if sucessful, - * true otherwise - *****************************************************************************/ -bool wfx_have_ipv6_addr(sl_wfx_interface_t which_if) -{ - VerifyOrReturnError(which_if == SL_WFX_STA_INTERFACE, false); - return IsStationConnected(); -} - -/**************************************************************************** - * @brief - * driver scan cancelation - *****************************************************************************/ -void wfx_cancel_scan(void) -{ - struct scan_result_holder *hp, *next; - /* Not possible */ - VerifyOrReturn(scan_cb != nullptr); - sl_wfx_send_stop_scan_command(); - for (hp = scan_save; hp; hp = next) - { - next = hp->next; - chip::Platform::MemoryFree(hp); - } - scan_save = (struct scan_result_holder *) 0; - scan_count = 0; - if (scan_ssid) - { - chip::Platform::MemoryFree(scan_ssid); - scan_ssid = nullptr; - } - scan_cb = nullptr; -} - CHIP_ERROR InitWiFiStack(void) { // TODO: This function should include sl_wfx_hw_init() and sl_wfx_init() functions. Only done now to make MatterConfig platform diff --git a/src/platform/silabs/wifi/wiseconnect-interface/WiseconnectWifiInterface.cpp b/src/platform/silabs/wifi/wiseconnect-interface/WiseconnectWifiInterface.cpp index 4d240a66cbfb2e..f366331ce0207c 100644 --- a/src/platform/silabs/wifi/wiseconnect-interface/WiseconnectWifiInterface.cpp +++ b/src/platform/silabs/wifi/wiseconnect-interface/WiseconnectWifiInterface.cpp @@ -199,111 +199,64 @@ void GotIPv4Address(uint32_t ip) } #endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */ -/********************************************************************* - * @fn void wfx_set_wifi_provision(wfx_wifi_provision_t *cfg) - * @brief - * Driver set the wifi provision - * @param[in] cfg: wifi configuration - * @return - * None - ***********************************************************************/ -void wfx_set_wifi_provision(wfx_wifi_provision_t * cfg) +void ClearWifiCredentials() { - VerifyOrReturn(cfg != nullptr); - wfx_rsi.sec = *cfg; - wfx_rsi.dev_state.Set(WifiState::kStationProvisioned); + ChipLogProgress(DeviceLayer, "Clear WiFi Provision"); + + wfx_rsi.credentials.Clear(); + wfx_rsi.dev_state.Clear(WifiState::kStationProvisioned); } -/********************************************************************* - * @fn bool wfx_get_wifi_provision(wfx_wifi_provision_t *wifiConfig) - * @brief - * Driver get the wifi provision - * @param[in] wifiConfig: wifi configuration - * @return return false if successful, - * true otherwise - ***********************************************************************/ -bool wfx_get_wifi_provision(wfx_wifi_provision_t * wifiConfig) +CHIP_ERROR GetWifiCredentials(WifiCredentials & credentials) { - VerifyOrReturnError(wifiConfig != nullptr, false); - VerifyOrReturnError(wfx_rsi.dev_state.Has(WifiState::kStationProvisioned), false); - *wifiConfig = wfx_rsi.sec; - return true; + VerifyOrReturnError(wfx_rsi.dev_state.Has(WifiState::kStationProvisioned), CHIP_ERROR_INCORRECT_STATE); + credentials = wfx_rsi.credentials; + + return CHIP_NO_ERROR; } -/********************************************************************* - * @fn void wfx_clear_wifi_provision(void) - * @brief - * Driver is clear the wifi provision - * @param[in] None - * @return None - ***********************************************************************/ -void wfx_clear_wifi_provision(void) +bool IsWifiProvisioned() { - memset(&wfx_rsi.sec, 0, sizeof(wfx_rsi.sec)); - wfx_rsi.dev_state.Clear(WifiState::kStationProvisioned); - ChipLogProgress(DeviceLayer, "Clear WiFi Provision"); + return wfx_rsi.dev_state.Has(WifiState::kStationProvisioned); } -/************************************************************************* - * @fn sl_status_t wfx_connect_to_ap(void) - * @brief - * Start a JOIN command to the AP - Done by the wfx_rsi task - * @param[in] None - * @return returns SL_STATUS_OK if successful - ****************************************************************************/ -sl_status_t wfx_connect_to_ap(void) +void SetWifiCredentials(const WifiCredentials & credentials) { - VerifyOrReturnError(wfx_rsi.dev_state.Has(WifiState::kStationProvisioned), SL_STATUS_INVALID_CONFIGURATION); - VerifyOrReturnError(wfx_rsi.sec.ssid_length, SL_STATUS_INVALID_CREDENTIALS); - VerifyOrReturnError(wfx_rsi.sec.ssid_length <= WFX_MAX_SSID_LENGTH, SL_STATUS_HAS_OVERFLOWED); - ChipLogProgress(DeviceLayer, "connect to access point: %s", wfx_rsi.sec.ssid); + wfx_rsi.credentials = credentials; + wfx_rsi.dev_state.Set(WifiState::kStationProvisioned); +} + +CHIP_ERROR ConnectToAccessPoint() +{ + VerifyOrReturnError(IsWifiProvisioned(), CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturnError(wfx_rsi.credentials.ssidLength, CHIP_ERROR_INCORRECT_STATE); + + // TODO: We should move this validation to where we set the credentials. It is too late here. + VerifyOrReturnError(wfx_rsi.credentials.ssidLength <= WFX_MAX_SSID_LENGTH, CHIP_ERROR_INVALID_ARGUMENT); + + ChipLogProgress(DeviceLayer, "connect to access point: %s", wfx_rsi.credentials.ssid); WifiPlatformEvent event = WifiPlatformEvent::kStationStartJoin; PostWifiPlatformEvent(event); - return SL_STATUS_OK; + + return CHIP_NO_ERROR; } #if CHIP_DEVICE_CONFIG_ENABLE_IPV4 -/********************************************************************* - * @fn bool wfx_have_ipv4_addr(sl_wfx_interface_t which_if) - * @brief - * called fuction when driver have ipv4 address - * @param[in] which_if: - * @return returns ture if successful, - * false otherwise - ***********************************************************************/ -bool wfx_have_ipv4_addr(sl_wfx_interface_t which_if) +bool HasAnIPv4Address() { - VerifyOrReturnError(which_if == SL_WFX_STA_INTERFACE, false); return wfx_rsi.dev_state.Has(WifiState::kStationDhcpDone); } #endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */ -/********************************************************************* - * @fn bool wfx_have_ipv6_addr(sl_wfx_interface_t which_if) - * @brief - * called fuction when driver have ipv6 address - * @param[in] which_if: - * @return returns ture if successful, - * false otherwise - ***********************************************************************/ -bool wfx_have_ipv6_addr(sl_wfx_interface_t which_if) +bool HasAnIPv6Address() { - VerifyOrReturnError(which_if == SL_WFX_STA_INTERFACE, false); // TODO: WifiState::kStationConnected does not guarantee SLAAC IPv6 LLA, maybe use a different FLAG + // Once connect is sync instead of async, this should be fine return wfx_rsi.dev_state.Has(WifiState::kStationConnected); } -/*************************************************************************** - * @fn void wfx_cancel_scan(void) - * @brief - * called function when driver cancel scaning - * @param[in] None - * @return - * None - *****************************************************************************/ -void wfx_cancel_scan(void) +void CancelScanNetworks() { - /* Not possible */ - ChipLogError(DeviceLayer, "cannot cancel scan"); + // TODO: Implement cancel scan } diff --git a/src/python_testing/matter_testing_infrastructure/BUILD.gn b/src/python_testing/matter_testing_infrastructure/BUILD.gn index cc803ca9a44d60..7128dd6e9fe133 100644 --- a/src/python_testing/matter_testing_infrastructure/BUILD.gn +++ b/src/python_testing/matter_testing_infrastructure/BUILD.gn @@ -38,6 +38,7 @@ pw_python_package("chip-testing-module") { "chip/testing/apps.py", "chip/testing/basic_composition.py", "chip/testing/choice_conformance.py", + "chip/testing/commissioning.py", "chip/testing/conformance.py", "chip/testing/conversions.py", "chip/testing/global_attribute_ids.py", diff --git a/src/python_testing/matter_testing_infrastructure/chip/testing/commissioning.py b/src/python_testing/matter_testing_infrastructure/chip/testing/commissioning.py new file mode 100644 index 00000000000000..1a5db8cfcda27f --- /dev/null +++ b/src/python_testing/matter_testing_infrastructure/chip/testing/commissioning.py @@ -0,0 +1,209 @@ +# +# Copyright (c) 2022-2025 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +""" +This module contains classes and functions designed to handle the commissioning process of Matter devices. +""" + +import logging +from dataclasses import dataclass +from typing import List, Optional + +from chip import ChipDeviceCtrl, discovery +from chip.ChipDeviceCtrl import CommissioningParameters +from chip.clusters import ClusterObjects as ClusterObjects +from chip.exceptions import ChipStackError + +logger = logging.getLogger("matter.python_testing") +logger.setLevel(logging.INFO) + +DiscoveryFilterType = ChipDeviceCtrl.DiscoveryFilterType + + +@dataclass +class SetupPayloadInfo: + """ + Represents information required to set up a payload during commissioning. + + Attributes: + filter_type (discovery.FilterType): The type of filter used for discrimination. Default is `FilterType.LONG_DISCRIMINATOR`. + filter_value (int): The value associated with the filter type. Default is `0`. + passcode (int): A unique code or password required for setup. Default is `0`. + """ + filter_type: discovery.FilterType = discovery.FilterType.LONG_DISCRIMINATOR + filter_value: int = 0 + passcode: int = 0 + + +@dataclass +class CommissioningInfo: + """ + Represents the information required for commissioning a device. + + Attributes: + commissionee_ip_address_just_for_testing (Optional[str]): + The IP address of the commissionee used only for testing purposes. + + commissioning_method (Optional[str]): + The method by which the device is being commissioned. + + thread_operational_dataset (Optional[str]): + The Thread operational dataset if applicable during commissioning. + + wifi_passphrase (Optional[str]): + The passphrase to connect to a Wi-Fi network, if required. + + wifi_ssid (Optional[str]): + The name of the Wi-Fi network to which the device should connect. + + tc_version_to_simulate (Optional[int]): + The version of the Terms and Conditions to simulate during testing. + This is used when accepting terms and conditions in a simulated environment. + + tc_user_response_to_simulate (Optional[int]): + The user response to simulate for the Terms and Conditions, if applicable. + """ + commissionee_ip_address_just_for_testing: Optional[str] = None + commissioning_method: Optional[str] = None + thread_operational_dataset: Optional[str] = None + wifi_passphrase: Optional[str] = None + wifi_ssid: Optional[str] = None + tc_version_to_simulate: Optional[int] = None + tc_user_response_to_simulate: Optional[int] = None + + +@dataclass +class CustomCommissioningParameters: + """ + A custom data class that encapsulates commissioning parameters with an additional random discriminator. + + Attributes: + commissioningParameters (CommissioningParameters): The underlying commissioning parameters. + randomDiscriminator (int): A randomly generated value used to uniquely identify or distinguish instances during commissioning processes. + """ + commissioningParameters: CommissioningParameters + randomDiscriminator: int + + +async def commission_device( + dev_ctrl: ChipDeviceCtrl.ChipDeviceController, node_id: int, info: SetupPayloadInfo, commissioning_info: CommissioningInfo +) -> bool: + """ + Starts the commissioning process of a chip device. + + This function handles different commissioning methods based on the specified method. + It supports various commissioning techniques such as "on-network", "ble-wifi", and "ble-thread". + + Parameters: + dev_ctrl: The chip device controller instance. + node_id: Unique identifier for the chip node. + info: Contains setup information including passcode, filter_type, and filter_value. + commissioning_info: Specifies the type of commissioning method to use. + + Returns: + True if the commissioning process completes successfully. False otherwise, + except in case of an error which logs the exception details. + + Note: + The "on-network-ip" method is deprecated as it's not supported in long-term + environments. + """ + + if commissioning_info.tc_version_to_simulate is not None and commissioning_info.tc_user_response_to_simulate is not None: + logging.debug( + f"Setting TC Acknowledgements to version {commissioning_info.tc_version_to_simulate} with user response {commissioning_info.tc_user_response_to_simulate}." + ) + dev_ctrl.SetTCAcknowledgements(commissioning_info.tc_version_to_simulate, commissioning_info.tc_user_response_to_simulate) + + if commissioning_info.commissioning_method == "on-network": + try: + await dev_ctrl.CommissionOnNetwork( + nodeId=node_id, setupPinCode=info.passcode, filterType=info.filter_type, filter=info.filter_value + ) + return True + except ChipStackError as e: + logging.error("Commissioning failed: %s" % e) + return False + elif commissioning_info.commissioning_method == "ble-wifi": + try: + await dev_ctrl.CommissionWiFi( + info.filter_value, + info.passcode, + node_id, + commissioning_info.wifi_ssid, + commissioning_info.wifi_passphrase, + isShortDiscriminator=(info.filter_type == DiscoveryFilterType.SHORT_DISCRIMINATOR), + ) + return True + except ChipStackError as e: + logging.error("Commissioning failed: %s" % e) + return False + elif commissioning_info.commissioning_method == "ble-thread": + try: + await dev_ctrl.CommissionThread( + info.filter_value, + info.passcode, + node_id, + commissioning_info.thread_operational_dataset, + isShortDiscriminator=(info.filter_type == DiscoveryFilterType.SHORT_DISCRIMINATOR), + ) + return True + except ChipStackError as e: + logging.error("Commissioning failed: %s" % e) + return False + elif commissioning_info.commissioning_method == "on-network-ip": + try: + logging.warning("==== USING A DIRECT IP COMMISSIONING METHOD NOT SUPPORTED IN THE LONG TERM ====") + await dev_ctrl.CommissionIP( + ipaddr=commissioning_info.commissionee_ip_address_just_for_testing, + setupPinCode=info.passcode, + nodeid=node_id, + ) + return True + except ChipStackError as e: + logging.error("Commissioning failed: %s" % e) + return False + else: + raise ValueError("Invalid commissioning method %s!" % commissioning_info.commissioning_method) + + +async def commission_devices( + dev_ctrl: ChipDeviceCtrl.ChipDeviceController, + dut_node_ids: List[int], + setup_payloads: List[SetupPayloadInfo], + commissioning_info: CommissioningInfo, +) -> bool: + """ + Attempt to commission all specified device nodes with their respective setup payloads. + + Args: + dev_ctrl: The chip device controller being used. + dut_node_ids: List of node IDs that need to be commissioned. + setup_payloads: List of SetupPayloadInfo objects containing configuration data + for each node to be set up and commissioned. + commissioning_info: Information about the commissioning process, including method, + parameters, etc. + + Returns: + bool: True if all devices were successfully commissioned; False otherwise. + """ + commissioned = [] + for node_id, setup_payload in zip(dut_node_ids, setup_payloads): + logging.info(f"Commissioning method: {commissioning_info.commissioning_method}") + commissioned.append(await commission_device(dev_ctrl, node_id, setup_payload, commissioning_info)) + + return all(commissioned) diff --git a/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py b/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py index 4625f9ca3b32b3..f6dddc9610a1f1 100644 --- a/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py +++ b/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py @@ -51,7 +51,6 @@ from chip import ChipDeviceCtrl # Needed before chip.FabricAdmin import chip.FabricAdmin # Needed before chip.CertificateAuthority import chip.CertificateAuthority -from chip.ChipDeviceCtrl import CommissioningParameters # isort: on from time import sleep @@ -68,6 +67,7 @@ from chip.interaction_model import InteractionModelError, Status from chip.setup_payload import SetupPayload from chip.storage import PersistentStorage +from chip.testing.commissioning import CommissioningInfo, CustomCommissioningParameters, SetupPayloadInfo, commission_devices from chip.testing.global_attribute_ids import GlobalAttributeIds from chip.testing.pics import read_pics_from_file from chip.tracing import TracingContext @@ -152,100 +152,6 @@ def get_default_paa_trust_store(root_path: pathlib.Path) -> pathlib.Path: return pathlib.Path.cwd() -@dataclass -class SetupPayloadInfo: - filter_type: discovery.FilterType = discovery.FilterType.LONG_DISCRIMINATOR - filter_value: int = 0 - passcode: int = 0 - - -@dataclass -class CommissioningInfo: - commissionee_ip_address_just_for_testing: Optional[str] = None - commissioning_method: Optional[str] = None - thread_operational_dataset: Optional[str] = None - wifi_passphrase: Optional[str] = None - wifi_ssid: Optional[str] = None - # Accepted Terms and Conditions if used - tc_version_to_simulate: int = None - tc_user_response_to_simulate: int = None - - -async def commission_device( - dev_ctrl: ChipDeviceCtrl.ChipDeviceController, node_id: int, info: SetupPayloadInfo, commissioning_info: CommissioningInfo -) -> bool: - if commissioning_info.tc_version_to_simulate is not None and commissioning_info.tc_user_response_to_simulate is not None: - logging.debug( - f"Setting TC Acknowledgements to version {commissioning_info.tc_version_to_simulate} with user response {commissioning_info.tc_user_response_to_simulate}." - ) - dev_ctrl.SetTCAcknowledgements(commissioning_info.tc_version_to_simulate, commissioning_info.tc_user_response_to_simulate) - - if commissioning_info.commissioning_method == "on-network": - try: - await dev_ctrl.CommissionOnNetwork( - nodeId=node_id, setupPinCode=info.passcode, filterType=info.filter_type, filter=info.filter_value - ) - return True - except ChipStackError as e: - logging.error("Commissioning failed: %s" % e) - return False - elif commissioning_info.commissioning_method == "ble-wifi": - try: - await dev_ctrl.CommissionWiFi( - info.filter_value, - info.passcode, - node_id, - commissioning_info.wifi_ssid, - commissioning_info.wifi_passphrase, - isShortDiscriminator=(info.filter_type == DiscoveryFilterType.SHORT_DISCRIMINATOR), - ) - return True - except ChipStackError as e: - logging.error("Commissioning failed: %s" % e) - return False - elif commissioning_info.commissioning_method == "ble-thread": - try: - await dev_ctrl.CommissionThread( - info.filter_value, - info.passcode, - node_id, - commissioning_info.thread_operational_dataset, - isShortDiscriminator=(info.filter_type == DiscoveryFilterType.SHORT_DISCRIMINATOR), - ) - return True - except ChipStackError as e: - logging.error("Commissioning failed: %s" % e) - return False - elif commissioning_info.commissioning_method == "on-network-ip": - try: - logging.warning("==== USING A DIRECT IP COMMISSIONING METHOD NOT SUPPORTED IN THE LONG TERM ====") - await dev_ctrl.CommissionIP( - ipaddr=commissioning_info.commissionee_ip_address_just_for_testing, - setupPinCode=info.passcode, - nodeid=node_id, - ) - return True - except ChipStackError as e: - logging.error("Commissioning failed: %s" % e) - return False - else: - raise ValueError("Invalid commissioning method %s!" % commissioning_info.commissioning_method) - - -async def commission_devices( - dev_ctrl: ChipDeviceCtrl.ChipDeviceController, - dut_node_ids: List[int], - setup_payloads: List[SetupPayloadInfo], - commissioning_info: CommissioningInfo, -) -> bool: - commissioned = [] - for node_id, setup_payload in zip(dut_node_ids, setup_payloads): - logging.info(f"Commissioning method: {commissioning_info.commissioning_method}") - commissioned.append(await commission_device(dev_ctrl, node_id, setup_payload, commissioning_info)) - - return all(commissioned) - - class SimpleEventCallback: def __init__(self, name: str, expected_cluster_id: int, expected_event_id: int, output_queue: queue.SimpleQueue): self._name = name @@ -735,12 +641,6 @@ def get_attribute_string(self, cluster_id: int, attribute_id) -> str: return f"Attribute {attribute_name} ({attribute_id}, 0x{attribute_id:04X})" -@dataclass -class CustomCommissioningParameters: - commissioningParameters: CommissioningParameters - randomDiscriminator: int - - @dataclass class ClusterPathLocation: endpoint_id: int diff --git a/third_party/pigweed/repo b/third_party/pigweed/repo index ce0e3e2d1b7eec..c12c17d8a25f0b 160000 --- a/third_party/pigweed/repo +++ b/third_party/pigweed/repo @@ -1 +1 @@ -Subproject commit ce0e3e2d1b7eec7cdf59fbb2ceed2b1cb3edd1ec +Subproject commit c12c17d8a25f0b4e4522dd75094e5c995b0ced2e diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp index 5e37f5c1688bda..5c3c082e5f4d9a 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp @@ -37432,6 +37432,26 @@ bool CommandHasLargePayload(ClusterId aCluster, CommandId aCommand) { return true; } + if ((aCluster == Clusters::PushAvStreamTransport::Id) && + (aCommand == Clusters::PushAvStreamTransport::Commands::AllocatePushTransport::Id)) + { + return true; + } + if ((aCluster == Clusters::PushAvStreamTransport::Id) && + (aCommand == Clusters::PushAvStreamTransport::Commands::AllocatePushTransportResponse::Id)) + { + return true; + } + if ((aCluster == Clusters::PushAvStreamTransport::Id) && + (aCommand == Clusters::PushAvStreamTransport::Commands::FindTransport::Id)) + { + return true; + } + if ((aCluster == Clusters::PushAvStreamTransport::Id) && + (aCommand == Clusters::PushAvStreamTransport::Commands::FindTransportResponse::Id)) + { + return true; + } return false; }