Skip to content

Commit

Permalink
Merge branch 'master' into dem-test-issues
Browse files Browse the repository at this point in the history
  • Loading branch information
hasty authored Aug 29, 2024
2 parents ce885c7 + cfdbba9 commit cd820e7
Show file tree
Hide file tree
Showing 79 changed files with 1,600 additions and 862 deletions.
2 changes: 1 addition & 1 deletion docs/guides/fabric_synchronization_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ fabricsync add-local-bridge 1
Pair the Ecosystem 2 bridge to Ecosystem 1 with node ID 2:

```
fabricsync add-bridge 2 <e2-fabric-bridge-ip>
fabricsync add-bridge 2 <setup-pin-code> <e2-fabric-bridge-ip> <e2-fabric-bridge-port>
```

This command will initiate the reverse commissioning process. After a few
Expand Down
10 changes: 10 additions & 0 deletions docs/testing/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -635,9 +635,19 @@ markers must be present.

- `test-runner-run/<run_identifier>/script-args`: Specifies the arguments to
be passed to the test script.

- Example:
`--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto`

- `test-runner-run/<run_identifier>/script-start-delay`: Specifies the number
of seconds to wait before starting the test script. This parameter can be
used to allow the application to initialize itself properly before the test
script will try to commission it (e.g. in case if the application needs to
be commissioned to some other controller first). By default, the delay is 0
seconds.

- Example: `10`

This structured format ensures that all necessary configurations are clearly
defined and easily understood, allowing for consistent and reliable test
execution.
Original file line number Diff line number Diff line change
Expand Up @@ -3235,7 +3235,7 @@ cluster LaundryWasherControls = 83 {

/** Attributes and commands for selecting a mode from a list of supported options. */
cluster RvcRunMode = 84 {
revision 2;
revision 3;

enum ModeTag : enum16 {
kIdle = 16384;
Expand All @@ -3255,7 +3255,7 @@ cluster RvcRunMode = 84 {
}

bitmap Feature : bitmap32 {
kNoFeatures = 0x0;
kDirectModeChange = 0x10000;
}

struct ModeTagStruct {
Expand Down Expand Up @@ -3294,7 +3294,7 @@ cluster RvcRunMode = 84 {

/** Attributes and commands for selecting a mode from a list of supported options. */
cluster RvcCleanMode = 85 {
revision 2;
revision 3;

enum ModeTag : enum16 {
kDeepClean = 16384;
Expand All @@ -3307,7 +3307,7 @@ cluster RvcCleanMode = 85 {
}

bitmap Feature : bitmap32 {
kNoFeatures = 0x0;
kDirectModeChange = 0x10000;
}

struct ModeTagStruct {
Expand Down Expand Up @@ -8489,7 +8489,7 @@ endpoint 1 {
callback attribute eventList;
callback attribute attributeList;
callback attribute featureMap;
ram attribute clusterRevision default = 2;
ram attribute clusterRevision default = 3;

handle command ChangeToMode;
handle command ChangeToModeResponse;
Expand All @@ -8503,7 +8503,7 @@ endpoint 1 {
callback attribute eventList;
callback attribute attributeList;
callback attribute featureMap;
ram attribute clusterRevision default = 2;
ram attribute clusterRevision default = 3;

handle command ChangeToMode;
handle command ChangeToModeResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9648,7 +9648,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "2",
"defaultValue": "3",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand Down Expand Up @@ -9804,7 +9804,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "2",
"defaultValue": "3",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand Down
39 changes: 23 additions & 16 deletions examples/all-clusters-app/all-clusters-common/src/rvc-modes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* limitations under the License.
*/
#include <app-common/zap-generated/attributes/Accessors.h>
#include <lib/support/TypeTraits.h>
#include <rvc-modes.h>
#include <rvc-operational-state-delegate-impl.h>

Expand All @@ -41,12 +42,15 @@ void RvcRunModeDelegate::HandleChangeToMode(uint8_t NewMode, ModeBase::Commands:
{
uint8_t currentMode = mInstance->GetCurrentMode();

// Our business logic states that we can only switch into a running mode from the idle state.
if (NewMode != RvcRunMode::ModeIdle && currentMode != RvcRunMode::ModeIdle)
if (!gRvcRunModeInstance->HasFeature(static_cast<ModeBase::Feature>(RvcRunMode::Feature::kDirectModeChange)))
{
response.status = to_underlying(ModeBase::StatusCode::kInvalidInMode);
response.statusText.SetValue(chip::CharSpan::fromCharString("Change to a running mode is only allowed from idle"));
return;
// Our business logic states that we can only switch into a running mode from the idle state.
if (NewMode != RvcRunMode::ModeIdle && currentMode != RvcRunMode::ModeIdle)
{
response.status = to_underlying(ModeBase::StatusCode::kInvalidInMode);
response.statusText.SetValue(chip::CharSpan::fromCharString("Change to a running mode is only allowed from idle"));
return;
}
}

auto rvcOpStateInstance = RvcOperationalState::GetRvcOperationalStateInstance();
Expand Down Expand Up @@ -123,8 +127,8 @@ void emberAfRvcRunModeClusterInitCallback(chip::EndpointId endpointId)
VerifyOrDie(endpointId == 1); // this cluster is only enabled for endpoint 1.
VerifyOrDie(gRvcRunModeDelegate == nullptr && gRvcRunModeInstance == nullptr);
gRvcRunModeDelegate = new RvcRunMode::RvcRunModeDelegate;
gRvcRunModeInstance =
new ModeBase::Instance(gRvcRunModeDelegate, 0x1, RvcRunMode::Id, chip::to_underlying(RvcRunMode::Feature::kNoFeatures));
gRvcRunModeInstance = new ModeBase::Instance(gRvcRunModeDelegate, 0x1, RvcRunMode::Id,
chip::to_underlying(RvcRunMode::Feature::kDirectModeChange));
gRvcRunModeInstance->Init();
}

Expand All @@ -139,14 +143,17 @@ CHIP_ERROR RvcCleanModeDelegate::Init()

void RvcCleanModeDelegate::HandleChangeToMode(uint8_t NewMode, ModeBase::Commands::ChangeToModeResponse::Type & response)
{
uint8_t rvcRunCurrentMode = gRvcRunModeInstance->GetCurrentMode();

if (rvcRunCurrentMode != RvcRunMode::ModeIdle)
if (!gRvcCleanModeInstance->HasFeature(static_cast<ModeBase::Feature>(RvcCleanMode::Feature::kDirectModeChange)))
{
response.status = to_underlying(ModeBase::StatusCode::kInvalidInMode);
response.statusText.SetValue(
chip::CharSpan::fromCharString("Cannot change the cleaning mode when the device is not in idle"));
return;
uint8_t rvcRunCurrentMode = gRvcRunModeInstance->GetCurrentMode();

if (rvcRunCurrentMode != RvcRunMode::ModeIdle)
{
response.status = to_underlying(ModeBase::StatusCode::kInvalidInMode);
response.statusText.SetValue(
chip::CharSpan::fromCharString("Cannot change the cleaning mode when the device is not in idle"));
return;
}
}

response.status = to_underlying(ModeBase::StatusCode::kSuccess);
Expand Down Expand Up @@ -213,7 +220,7 @@ void emberAfRvcCleanModeClusterInitCallback(chip::EndpointId endpointId)
VerifyOrDie(endpointId == 1); // this cluster is only enabled for endpoint 1.
VerifyOrDie(gRvcCleanModeDelegate == nullptr && gRvcCleanModeInstance == nullptr);
gRvcCleanModeDelegate = new RvcCleanMode::RvcCleanModeDelegate;
gRvcCleanModeInstance =
new ModeBase::Instance(gRvcCleanModeDelegate, 0x1, RvcCleanMode::Id, chip::to_underlying(RvcRunMode::Feature::kNoFeatures));
gRvcCleanModeInstance = new ModeBase::Instance(gRvcCleanModeDelegate, 0x1, RvcCleanMode::Id,
chip::to_underlying(RvcCleanMode::Feature::kDirectModeChange));
gRvcCleanModeInstance->Init();
}
99 changes: 99 additions & 0 deletions examples/all-clusters-app/linux/AllClustersCommandDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
#include "AllClustersCommandDelegate.h"

#include <app-common/zap-generated/attributes/Accessors.h>
#include <app/EventLogging.h>
#include <app/clusters/general-diagnostics-server/general-diagnostics-server.h>
#include <app/clusters/occupancy-sensor-server/occupancy-sensor-server.h>
#include <app/clusters/smoke-co-alarm-server/smoke-co-alarm-server.h>
#include <app/clusters/software-diagnostics-server/software-diagnostics-server.h>
#include <app/clusters/switch-server/switch-server.h>
Expand Down Expand Up @@ -246,6 +248,24 @@ void HandleSimulateLatchPosition(Json::Value & jsonValue)
}
}

void EmitOccupancyChangedEvent(EndpointId endpointId, uint8_t occupancyValue)
{
Clusters::OccupancySensing::Events::OccupancyChanged::Type event{};
event.occupancy = static_cast<BitMask<Clusters::OccupancySensing::OccupancyBitmap>>(occupancyValue);
EventNumber eventNumber = 0;

CHIP_ERROR err = LogEvent(event, endpointId, eventNumber);
if (err != CHIP_NO_ERROR)
{
ChipLogError(NotSpecified, "Failed to log OccupancyChanged event: %" CHIP_ERROR_FORMAT, err.Format());
}
else
{
ChipLogProgress(NotSpecified, "Logged OccupancyChanged(occupancy=%u) on Endpoint %u", static_cast<unsigned>(occupancyValue),
static_cast<unsigned>(endpointId));
}
}

} // namespace

AllClustersAppCommandHandler * AllClustersAppCommandHandler::FromJSON(const char * json)
Expand Down Expand Up @@ -407,6 +427,20 @@ void AllClustersAppCommandHandler::HandleCommand(intptr_t context)
{
HandleSimulateLatchPosition(self->mJsonValue);
}
else if (name == "SetOccupancy")
{
uint8_t occupancy = static_cast<uint8_t>(self->mJsonValue["Occupancy"].asUInt());
EndpointId endpointId = static_cast<EndpointId>(self->mJsonValue["EndpointId"].asUInt());

if (1 == occupancy || 0 == occupancy)
{
self->HandleSetOccupancyChange(endpointId, occupancy);
}
else
{
ChipLogError(NotSpecified, "Invalid Occupancy state to set.");
}
}
else
{
ChipLogError(NotSpecified, "Unhandled command '%s': this hould never happen", name.c_str());
Expand Down Expand Up @@ -769,6 +803,71 @@ void AllClustersAppCommandHandler::OnAirQualityChange(uint32_t aNewValue)
}
}

void AllClustersAppCommandHandler::HandleSetOccupancyChange(EndpointId endpointId, uint8_t newOccupancyValue)
{
BitMask<chip::app::Clusters::OccupancySensing::OccupancyBitmap> currentOccupancy;
Protocols::InteractionModel::Status status = OccupancySensing::Attributes::Occupancy::Get(endpointId, &currentOccupancy);

if (static_cast<BitMask<chip::app::Clusters::OccupancySensing::OccupancyBitmap>>(newOccupancyValue) == currentOccupancy)
{
ChipLogDetail(NotSpecified, "Skipping setting occupancy changed due to same value.");
return;
}

status = OccupancySensing::Attributes::Occupancy::Set(endpointId, newOccupancyValue);
ChipLogDetail(NotSpecified, "Set Occupancy attribute to %u", newOccupancyValue);

if (status != Protocols::InteractionModel::Status::Success)
{
ChipLogDetail(NotSpecified, "Invalid value/endpoint to set.");
return;
}

EmitOccupancyChangedEvent(endpointId, newOccupancyValue);

if (1 == newOccupancyValue)
{
uint16_t * holdTime = chip::app::Clusters::OccupancySensing::GetHoldTimeForEndpoint(endpointId);
if (holdTime != nullptr)
{
CHIP_ERROR err = chip::DeviceLayer::SystemLayer().StartTimer(
chip::System::Clock::Seconds16(*holdTime), AllClustersAppCommandHandler::OccupancyPresentTimerHandler,
reinterpret_cast<void *>(static_cast<uintptr_t>(endpointId)));
ChipLogDetail(NotSpecified, "Start HoldTime timer");
if (CHIP_NO_ERROR != err)
{
ChipLogError(NotSpecified, "Failed to start HoldTime timer.");
}
}
}
}

void AllClustersAppCommandHandler::OccupancyPresentTimerHandler(System::Layer * systemLayer, void * appState)
{
EndpointId endpointId = static_cast<EndpointId>(reinterpret_cast<uintptr_t>(appState));
chip::BitMask<Clusters::OccupancySensing::OccupancyBitmap> currentOccupancy;

Protocols::InteractionModel::Status status = OccupancySensing::Attributes::Occupancy::Get(endpointId, &currentOccupancy);
VerifyOrDie(status == Protocols::InteractionModel::Status::Success);

uint8_t clearValue = 0;
if (!currentOccupancy.Has(Clusters::OccupancySensing::OccupancyBitmap::kOccupied))
{
return;
}

status = OccupancySensing::Attributes::Occupancy::Set(endpointId, clearValue);
if (status != Protocols::InteractionModel::Status::Success)
{
ChipLogDetail(NotSpecified, "Failed to set occupancy state.");
}
else
{
ChipLogDetail(NotSpecified, "Set Occupancy attribute to clear");
EmitOccupancyChangedEvent(endpointId, clearValue);
}
}

void AllClustersCommandDelegate::OnEventCommandReceived(const char * json)
{
auto handler = AllClustersAppCommandHandler::FromJSON(json);
Expand Down
6 changes: 6 additions & 0 deletions examples/all-clusters-app/linux/AllClustersCommandDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ class AllClustersAppCommandHandler
* Should be called when it is necessary to change the operational state as a manual operation.
*/
void OnOvenOperationalStateChange(std::string device, std::string operation, Json::Value param);

/**
* Should be called when it is necessary to change the Occupancy attribute.
*/
void HandleSetOccupancyChange(chip::EndpointId endpointId, uint8_t occupancyValue);
static void OccupancyPresentTimerHandler(chip::System::Layer * systemLayer, void * appState);
};

class AllClustersCommandDelegate : public NamedPipeCommandDelegate
Expand Down
2 changes: 2 additions & 0 deletions examples/all-clusters-app/linux/ButtonEventsSimulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ void ButtonEventsSimulator::Next()
break;
}
case ButtonEventsSimulator::State::kEmitStartOfMultiPress: {
SetButtonPosition(mEndpointId, mPressedButtonId);
EmitInitialPress(mEndpointId, mPressedButtonId);
if (mFeatureMap & static_cast<uint32_t>(Clusters::Switch::Feature::kActionSwitch))
{
Expand Down Expand Up @@ -268,6 +269,7 @@ void ButtonEventsSimulator::Next()
{
EmitShortRelease(mEndpointId, mPressedButtonId);
}
SetButtonPosition(mEndpointId, mIdleButtonId);
StartTimer(mMultiPressReleasedTimeMillis);
break;
}
Expand Down
8 changes: 4 additions & 4 deletions examples/chef/common/chef-rvc-mode-delegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ void emberAfRvcRunModeClusterInitCallback(chip::EndpointId endpointId)
VerifyOrDie(!gRvcRunModeDelegate && !gRvcRunModeInstance);

gRvcRunModeDelegate = std::make_unique<RvcRunModeDelegate>();
gRvcRunModeInstance = std::make_unique<ModeBase::Instance>(gRvcRunModeDelegate.get(), endpointId, RvcRunMode::Id,
chip::to_underlying(RvcRunMode::Feature::kNoFeatures));
gRvcRunModeInstance =
std::make_unique<ModeBase::Instance>(gRvcRunModeDelegate.get(), endpointId, RvcRunMode::Id, 0 /* No feature bits */);
gRvcRunModeInstance->Init();
}

Expand Down Expand Up @@ -290,8 +290,8 @@ void emberAfRvcCleanModeClusterInitCallback(chip::EndpointId endpointId)
VerifyOrDie(!gRvcCleanModeDelegate && !gRvcCleanModeInstance);

gRvcCleanModeDelegate = std::make_unique<RvcCleanModeDelegate>();
gRvcCleanModeInstance = std::make_unique<ModeBase::Instance>(gRvcCleanModeDelegate.get(), endpointId, RvcCleanMode::Id,
chip::to_underlying(RvcCleanMode::Feature::kNoFeatures));
gRvcCleanModeInstance =
std::make_unique<ModeBase::Instance>(gRvcCleanModeDelegate.get(), endpointId, RvcCleanMode::Id, 0 /* No feature bits */);
gRvcCleanModeInstance->Init();
}
#endif // MATTER_DM_PLUGIN_RVC_CLEAN_MODE_SERVER
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@
}
],
"package": [
{
"pathRelativity": "relativeToZap",
"path": "../../../src/app/zap-templates/app-templates.json",
"type": "gen-templates-json",
"category": "matter",
"version": "chip-v1"
},
{
"pathRelativity": "relativeToZap",
"path": "../../../src/app/zap-templates/zcl/zcl.json",
"type": "zcl-properties",
"category": "matter",
"version": 1,
"description": "Matter SDK ZCL data"
},
{
"pathRelativity": "relativeToZap",
"path": "../../../src/app/zap-templates/app-templates.json",
"type": "gen-templates-json",
"category": "matter",
"version": "chip-v1"
}
],
"endpointTypes": [
Expand Down
Loading

0 comments on commit cd820e7

Please sign in to comment.