Skip to content

Commit

Permalink
WindowCovering: Improve Xml enum for OperationalStatus (#18300)
Browse files Browse the repository at this point in the history
* DEV: Rename feature

* DEV: BitFlags add Set/Get field/mask

* DEV/ZAP: Rename SafetyStatus

* DEV: Changes feature + Remove Useless artifact

* ZAP: Update OperationalStatus definition

* DEV: Rework OperationalStatus

* FIX: SetField

* Add prints

* Dev: add operational status checks

* DEV: Rework OperationalStatus from ESP32

* FIX: Update nrfconnect code

* Restyled by clang-format

* ZAP: Update + Regen

* Restyled by google-java-format

* ZAP: Update + Regen

* DEV: Update from BitFlags to BitMask

* ZAP: Update + Regen

* Zap: Update + Regen

* Drop: BitFlags modifications

* ZAP: Update + Regen

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Jul 20, 2023
1 parent afd95b7 commit 3664523
Show file tree
Hide file tree
Showing 27 changed files with 498 additions and 465 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3711,28 +3711,28 @@ server cluster WindowCovering = 258 {
kTiltEncoderControlled = 0x40;
}

bitmap Mode : BITMAP8 {
kMotorDirectionReversed = 0x1;
kCalibrationMode = 0x2;
kMaintenanceMode = 0x4;
kLedFeedback = 0x8;
}

bitmap WcFeature : BITMAP32 {
bitmap Feature : BITMAP32 {
kLift = 0x1;
kTilt = 0x2;
kPositionAwareLift = 0x4;
kAbsolutePosition = 0x8;
kPositionAwareTilt = 0x10;
}

bitmap WcOperationalStatus : BITMAP8 {
bitmap Mode : BITMAP8 {
kMotorDirectionReversed = 0x1;
kCalibrationMode = 0x2;
kMaintenanceMode = 0x4;
kLedFeedback = 0x8;
}

bitmap OperationalStatus : BITMAP8 {
kGlobal = 0x3;
kLift = 0xC;
kTilt = 0x30;
}

bitmap WcSafetyStatus : BITMAP16 {
bitmap SafetyStatus : BITMAP16 {
kRemoteLockout = 0x1;
kTamperDetection = 0x2;
kFailedCommunication = 0x4;
Expand All @@ -3757,7 +3757,7 @@ server cluster WindowCovering = 258 {
readonly attribute ConfigStatus configStatus = 7;
readonly attribute nullable Percent currentPositionLiftPercentage = 8;
readonly attribute nullable Percent currentPositionTiltPercentage = 9;
readonly attribute bitmap8 operationalStatus = 10;
readonly attribute OperationalStatus operationalStatus = 10;
readonly attribute nullable Percent100ths targetPositionLiftPercent100ths = 11;
readonly attribute nullable Percent100ths targetPositionTiltPercent100ths = 12;
readonly attribute EndProductType endProductType = 13;
Expand All @@ -3768,7 +3768,7 @@ server cluster WindowCovering = 258 {
readonly attribute int16u installedOpenLimitTilt = 18;
readonly attribute int16u installedClosedLimitTilt = 19;
attribute access(write: manage) Mode mode = 23;
readonly attribute bitmap16 safetyStatus = 26;
readonly attribute SafetyStatus safetyStatus = 26;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute attrib_id attributeList[] = 65531;
Expand Down
8 changes: 6 additions & 2 deletions examples/all-clusters-app/esp32/main/DeviceWithDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,9 @@ class EditAttributeListModel : public TouchesMatterStackModel
{
// update the operational status here for hardcoded endpoint 1
ESP_LOGI(TAG, "Operational status changed to : %d", n);
app::Clusters::WindowCovering::Attributes::OperationalStatus::Set(1, static_cast<uint8_t>(n));
chip::BitFlags<app::Clusters::WindowCovering::OperationalStatus> opStatus =
static_cast<chip::BitFlags<app::Clusters::WindowCovering::OperationalStatus>>(n);
app::Clusters::WindowCovering::Attributes::OperationalStatus::Set(1, opStatus);
}
else if (name == "Bat remaining")
{
Expand Down Expand Up @@ -676,7 +678,9 @@ void SetupPretendDevices()
AddAttribute("Current Tilt", "5");
app::Clusters::WindowCovering::Attributes::CurrentPositionTiltPercent100ths::Set(1, static_cast<uint16_t>(5 * 100));
AddAttribute("Opr Status", "0");
app::Clusters::WindowCovering::Attributes::OperationalStatus::Set(1, static_cast<uint8_t>(0));
chip::BitFlags<app::Clusters::WindowCovering::OperationalStatus> opStatus =
static_cast<chip::BitFlags<app::Clusters::WindowCovering::OperationalStatus>>(0);
app::Clusters::WindowCovering::Attributes::OperationalStatus::Set(1, opStatus);

AddDevice("Battery");
AddEndpoint("1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3174,28 +3174,28 @@ server cluster WindowCovering = 258 {
kTiltEncoderControlled = 0x40;
}

bitmap Mode : BITMAP8 {
kMotorDirectionReversed = 0x1;
kCalibrationMode = 0x2;
kMaintenanceMode = 0x4;
kLedFeedback = 0x8;
}

bitmap WcFeature : BITMAP32 {
bitmap Feature : BITMAP32 {
kLift = 0x1;
kTilt = 0x2;
kPositionAwareLift = 0x4;
kAbsolutePosition = 0x8;
kPositionAwareTilt = 0x10;
}

bitmap WcOperationalStatus : BITMAP8 {
bitmap Mode : BITMAP8 {
kMotorDirectionReversed = 0x1;
kCalibrationMode = 0x2;
kMaintenanceMode = 0x4;
kLedFeedback = 0x8;
}

bitmap OperationalStatus : BITMAP8 {
kGlobal = 0x3;
kLift = 0xC;
kTilt = 0x30;
}

bitmap WcSafetyStatus : BITMAP16 {
bitmap SafetyStatus : BITMAP16 {
kRemoteLockout = 0x1;
kTamperDetection = 0x2;
kFailedCommunication = 0x4;
Expand All @@ -3212,7 +3212,7 @@ server cluster WindowCovering = 258 {

readonly attribute Type type = 0;
readonly attribute ConfigStatus configStatus = 7;
readonly attribute bitmap8 operationalStatus = 10;
readonly attribute OperationalStatus operationalStatus = 10;
readonly attribute EndProductType endProductType = 13;
attribute access(write: manage) Mode mode = 23;
readonly attribute bitmap32 featureMap = 65532;
Expand Down
24 changes: 12 additions & 12 deletions examples/placeholder/linux/apps/app1/config.matter
Original file line number Diff line number Diff line change
Expand Up @@ -2496,28 +2496,28 @@ server cluster WindowCovering = 258 {
kTiltEncoderControlled = 0x40;
}

bitmap Mode : BITMAP8 {
kMotorDirectionReversed = 0x1;
kCalibrationMode = 0x2;
kMaintenanceMode = 0x4;
kLedFeedback = 0x8;
}

bitmap WcFeature : BITMAP32 {
bitmap Feature : BITMAP32 {
kLift = 0x1;
kTilt = 0x2;
kPositionAwareLift = 0x4;
kAbsolutePosition = 0x8;
kPositionAwareTilt = 0x10;
}

bitmap WcOperationalStatus : BITMAP8 {
bitmap Mode : BITMAP8 {
kMotorDirectionReversed = 0x1;
kCalibrationMode = 0x2;
kMaintenanceMode = 0x4;
kLedFeedback = 0x8;
}

bitmap OperationalStatus : BITMAP8 {
kGlobal = 0x3;
kLift = 0xC;
kTilt = 0x30;
}

bitmap WcSafetyStatus : BITMAP16 {
bitmap SafetyStatus : BITMAP16 {
kRemoteLockout = 0x1;
kTamperDetection = 0x2;
kFailedCommunication = 0x4;
Expand All @@ -2538,7 +2538,7 @@ server cluster WindowCovering = 258 {
readonly attribute ConfigStatus configStatus = 7;
readonly attribute nullable Percent currentPositionLiftPercentage = 8;
readonly attribute nullable Percent currentPositionTiltPercentage = 9;
readonly attribute bitmap8 operationalStatus = 10;
readonly attribute OperationalStatus operationalStatus = 10;
readonly attribute nullable Percent100ths targetPositionLiftPercent100ths = 11;
readonly attribute nullable Percent100ths targetPositionTiltPercent100ths = 12;
readonly attribute EndProductType endProductType = 13;
Expand All @@ -2549,7 +2549,7 @@ server cluster WindowCovering = 258 {
readonly attribute int16u installedOpenLimitTilt = 18;
readonly attribute int16u installedClosedLimitTilt = 19;
attribute access(write: manage) Mode mode = 23;
readonly attribute bitmap16 safetyStatus = 26;
readonly attribute SafetyStatus safetyStatus = 26;
readonly attribute bitmap32 featureMap = 65532;
readonly attribute int16u clusterRevision = 65533;

Expand Down
24 changes: 12 additions & 12 deletions examples/placeholder/linux/apps/app2/config.matter
Original file line number Diff line number Diff line change
Expand Up @@ -2496,28 +2496,28 @@ server cluster WindowCovering = 258 {
kTiltEncoderControlled = 0x40;
}

bitmap Mode : BITMAP8 {
kMotorDirectionReversed = 0x1;
kCalibrationMode = 0x2;
kMaintenanceMode = 0x4;
kLedFeedback = 0x8;
}

bitmap WcFeature : BITMAP32 {
bitmap Feature : BITMAP32 {
kLift = 0x1;
kTilt = 0x2;
kPositionAwareLift = 0x4;
kAbsolutePosition = 0x8;
kPositionAwareTilt = 0x10;
}

bitmap WcOperationalStatus : BITMAP8 {
bitmap Mode : BITMAP8 {
kMotorDirectionReversed = 0x1;
kCalibrationMode = 0x2;
kMaintenanceMode = 0x4;
kLedFeedback = 0x8;
}

bitmap OperationalStatus : BITMAP8 {
kGlobal = 0x3;
kLift = 0xC;
kTilt = 0x30;
}

bitmap WcSafetyStatus : BITMAP16 {
bitmap SafetyStatus : BITMAP16 {
kRemoteLockout = 0x1;
kTamperDetection = 0x2;
kFailedCommunication = 0x4;
Expand All @@ -2538,7 +2538,7 @@ server cluster WindowCovering = 258 {
readonly attribute ConfigStatus configStatus = 7;
readonly attribute nullable Percent currentPositionLiftPercentage = 8;
readonly attribute nullable Percent currentPositionTiltPercentage = 9;
readonly attribute bitmap8 operationalStatus = 10;
readonly attribute OperationalStatus operationalStatus = 10;
readonly attribute nullable Percent100ths targetPositionLiftPercent100ths = 11;
readonly attribute nullable Percent100ths targetPositionTiltPercent100ths = 12;
readonly attribute EndProductType endProductType = 13;
Expand All @@ -2549,7 +2549,7 @@ server cluster WindowCovering = 258 {
readonly attribute int16u installedOpenLimitTilt = 18;
readonly attribute int16u installedClosedLimitTilt = 19;
attribute access(write: manage) Mode mode = 23;
readonly attribute bitmap16 safetyStatus = 26;
readonly attribute SafetyStatus safetyStatus = 26;
readonly attribute bitmap32 featureMap = 65532;
readonly attribute int16u clusterRevision = 65533;

Expand Down
13 changes: 5 additions & 8 deletions examples/window-app/common/include/WindowApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,14 @@ class WindowApp
void LiftContinueToTarget() { LiftUpdate(false); }
void LiftStepToward(OperationalState direction);
void LiftSchedulePositionSet(chip::Percent100ths position) { SchedulePositionSet(position, false); }
void LiftScheduleOperationalStateSet(OperationalState opState) { ScheduleOperationalStateSet(opState, false); }

void TiltUpdate(bool newTarget);
void TiltGoToTarget() { TiltUpdate(true); }
void TiltContinueToTarget() { TiltUpdate(false); }
void TiltStepToward(OperationalState direction);
void TiltSchedulePositionSet(chip::Percent100ths position) { SchedulePositionSet(position, true); }
void TiltScheduleOperationalStateSet(OperationalState opState) { ScheduleOperationalStateSet(opState, true); }

void StepToward(OperationalState direction, bool isTilt);

Expand All @@ -128,11 +130,6 @@ class WindowApp

chip::EndpointId mEndpoint = 0;

// Attribute: Id 10 OperationalStatus
OperationalStatus mOperationalStatus = { .global = OperationalState::Stall,
.lift = OperationalState::Stall,
.tilt = OperationalState::Stall };

Timer * mLiftTimer = nullptr;
Timer * mTiltTimer = nullptr;
OperationalState mLiftOpState = OperationalState::Stall;
Expand All @@ -146,14 +143,14 @@ class WindowApp
union
{
chip::Percent100ths percent100ths;
OperationalStatus opStatus;
OperationalState opState;
};
};

void SchedulePositionSet(chip::Percent100ths position, bool isTilt);
static void CallbackPositionSet(intptr_t arg);
void ScheduleOperationalStatusSetWithGlobalUpdate(OperationalStatus opStatus);
static void CallbackOperationalStatusSetWithGlobalUpdate(intptr_t arg);
void ScheduleOperationalStateSet(OperationalState opState, bool isTilt);
static void CallbackOperationalStateSet(intptr_t arg);
};

static WindowApp & Instance();
Expand Down
33 changes: 15 additions & 18 deletions examples/window-app/common/src/WindowApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ void WindowApp::DispatchEventAttributeChange(chip::EndpointId endpoint, chip::At
Cover * cover = GetCover(endpoint);
chip::BitMask<Mode> mode;
chip::BitMask<ConfigStatus> configStatus;
chip::BitMask<OperationalStatus> opStatus;

if (nullptr == cover)
{
Expand All @@ -316,7 +317,8 @@ void WindowApp::DispatchEventAttributeChange(chip::EndpointId endpoint, chip::At
/* RO OperationalStatus */
case Attributes::OperationalStatus::Id:
chip::DeviceLayer::PlatformMgr().LockChipStack();
emberAfWindowCoveringClusterPrint("Global OpState: %02X\n", (unsigned int) OperationalStatusGet(endpoint).global);
opStatus = OperationalStatusGet(endpoint);
OperationalStatusPrint(opStatus);
chip::DeviceLayer::PlatformMgr().UnlockChipStack();
break;
/* RW Mode */
Expand Down Expand Up @@ -432,8 +434,6 @@ void WindowApp::Cover::Init(chip::EndpointId endpoint)
configStatus.Set(ConfigStatus::kOnlineReserved);
ConfigStatusSet(endpoint, configStatus);

OperationalStatusSetWithGlobalUpdated(endpoint, mOperationalStatus);

// Attribute: Id 13 EndProductType
EndProductTypeSet(endpoint, EndProductType::kInteriorBlind);

Expand All @@ -448,8 +448,7 @@ void WindowApp::Cover::Init(chip::EndpointId endpoint)
ModeSet(endpoint, mode);

// Attribute: Id 27 SafetyStatus (Optional)
SafetyStatus safetyStatus = { 0x00 }; // 0 is no issues;
SafetyStatusSet(endpoint, safetyStatus);
chip::BitFlags<SafetyStatus> safetyStatus(0x00); // 0 is no issues;
}

void WindowApp::Cover::Finish()
Expand Down Expand Up @@ -489,8 +488,7 @@ void WindowApp::Cover::LiftUpdate(bool newTarget)
Attributes::TargetPositionLiftPercent100ths::Get(mEndpoint, target);
Attributes::CurrentPositionLiftPercent100ths::Get(mEndpoint, current);

OperationalStatus opStatus = OperationalStatusGet(mEndpoint);
OperationalState opState = ComputeOperationalState(target, current);
OperationalState opState = ComputeOperationalState(target, current);

chip::DeviceLayer::PlatformMgr().UnlockChipStack();

Expand All @@ -514,9 +512,8 @@ void WindowApp::Cover::LiftUpdate(bool newTarget)

mLiftOpState = OperationalState::Stall;
}
opStatus.lift = mLiftOpState;

ScheduleOperationalStatusSetWithGlobalUpdate(opStatus);
LiftScheduleOperationalStateSet(mLiftOpState);

if ((OperationalState::Stall != mLiftOpState) && mLiftTimer)
{
Expand Down Expand Up @@ -555,8 +552,7 @@ void WindowApp::Cover::TiltUpdate(bool newTarget)
Attributes::TargetPositionTiltPercent100ths::Get(mEndpoint, target);
Attributes::CurrentPositionTiltPercent100ths::Get(mEndpoint, current);

OperationalStatus opStatus = OperationalStatusGet(mEndpoint);
OperationalState opState = ComputeOperationalState(target, current);
OperationalState opState = ComputeOperationalState(target, current);

chip::DeviceLayer::PlatformMgr().UnlockChipStack();

Expand All @@ -580,9 +576,8 @@ void WindowApp::Cover::TiltUpdate(bool newTarget)

mTiltOpState = OperationalState::Stall;
}
opStatus.tilt = mTiltOpState;

ScheduleOperationalStatusSetWithGlobalUpdate(opStatus);
TiltScheduleOperationalStateSet(mTiltOpState);

if ((OperationalState::Stall != mTiltOpState) && mTiltTimer)
{
Expand Down Expand Up @@ -676,21 +671,23 @@ void WindowApp::Cover::CallbackPositionSet(intptr_t arg)
chip::Platform::Delete(data);
}

void WindowApp::Cover::ScheduleOperationalStatusSetWithGlobalUpdate(OperationalStatus opStatus)
void WindowApp::Cover::ScheduleOperationalStateSet(OperationalState opState, bool isTilt)
{
CoverWorkData * data = chip::Platform::New<CoverWorkData>();
VerifyOrReturn(data != nullptr, emberAfWindowCoveringClusterPrint("Cover::OperationalStatusSet - Out of Memory for WorkData"));

data->mEndpointId = mEndpoint;
data->opStatus = opStatus;
data->opState = opState;
data->isTilt = isTilt;

chip::DeviceLayer::PlatformMgr().ScheduleWork(CallbackOperationalStatusSetWithGlobalUpdate, reinterpret_cast<intptr_t>(data));
chip::DeviceLayer::PlatformMgr().ScheduleWork(CallbackOperationalStateSet, reinterpret_cast<intptr_t>(data));
}

void WindowApp::Cover::CallbackOperationalStatusSetWithGlobalUpdate(intptr_t arg)
void WindowApp::Cover::CallbackOperationalStateSet(intptr_t arg)
{
WindowApp::Cover::CoverWorkData * data = reinterpret_cast<WindowApp::Cover::CoverWorkData *>(arg);
OperationalStatusSetWithGlobalUpdated(data->mEndpointId, data->opStatus);

OperationalStateSet(data->mEndpointId, data->isTilt ? OperationalStatus::kTilt : OperationalStatus::kLift, data->opState);

chip::Platform::Delete(data);
}
Loading

0 comments on commit 3664523

Please sign in to comment.