From b9de5a56c96944237ffc22576f0c2462552730a0 Mon Sep 17 00:00:00 2001 From: pankore <86098180+pankore@users.noreply.github.com> Date: Fri, 13 Oct 2023 14:02:44 +0800 Subject: [PATCH] [Ameba] Updated switch case at ManualOperationalStateCommand.h and updated raise and lower alarm function at ManualDishWasherAlarmCommand.h --- .../include/ManualDishWasherAlarmCommand.h | 55 +++++++++++++++++-- .../include/ManualOperationalStateCommand.h | 54 +++++------------- 2 files changed, 62 insertions(+), 47 deletions(-) diff --git a/examples/all-clusters-app/ameba/main/include/ManualDishWasherAlarmCommand.h b/examples/all-clusters-app/ameba/main/include/ManualDishWasherAlarmCommand.h index 8a29e7f3e68f93..c1a37be41d385a 100644 --- a/examples/all-clusters-app/ameba/main/include/ManualDishWasherAlarmCommand.h +++ b/examples/all-clusters-app/ameba/main/include/ManualDishWasherAlarmCommand.h @@ -59,25 +59,49 @@ CHIP_ERROR ManualDishWasherAlarmCommandHandler(int argc, char ** argv) CHIP_ERROR ManualDishWasherAlarmSetRaiseCommandHandler(int argc, char ** argv) { + if (argc != 0) + { + return ManualDishWasherAlarmCommandHelpHandler(argc, argv); + } + CHIP_ERROR err = CHIP_NO_ERROR; EmberAfStatus status; DishwasherAlarmServer & serverInstance = DishwasherAlarmServer::Instance(); - status = serverInstance.SetSupportedValue(1, 47); + BitMask supported; // Set dishwasher alarm supported value + supported.SetField(AlarmMap::kInflowError, 1); // 0x01, 1 + supported.SetField(AlarmMap::kDrainError, 1); // 0x02, 2 + supported.SetField(AlarmMap::kDoorError, 1); // 0x04, 4 + supported.SetField(AlarmMap::kTempTooLow, 1); // 0x08, 8 + supported.SetField(AlarmMap::kWaterLevelError, 1); // 0x20, 32 + + BitMask mask; // Set dishwasher alarm mask value + mask.SetField(AlarmMap::kInflowError, 1); // 0x01, 1 + mask.SetField(AlarmMap::kDrainError, 1); // 0x02, 2 + mask.SetField(AlarmMap::kDoorError, 1); // 0x04, 4 + mask.SetField(AlarmMap::kTempTooLow, 1); // 0x08, 8 + mask.SetField(AlarmMap::kWaterLevelError, 1); // 0x20, 32 + + BitMask state; // Set dishwasher alarm state value + state.SetField(AlarmMap::kDrainError, 1); // 0x02, 2 + state.SetField(AlarmMap::kDoorError, 1); // 0x04, 4 + state.SetField(AlarmMap::kTempTooLow, 1); // 0x08, 8 + + status = serverInstance.SetSupportedValue(1, supported); // 0x2F, 47 if (status != EMBER_ZCL_STATUS_SUCCESS) { err = CHIP_ERROR_INTERNAL; goto exit; } - status = serverInstance.SetMaskValue(1, 47); + status = serverInstance.SetMaskValue(1, mask); // 0x2F, 47 if (status != EMBER_ZCL_STATUS_SUCCESS) { err = CHIP_ERROR_INTERNAL; goto exit; } - status = serverInstance.SetStateValue(1, 14, 0); + status = serverInstance.SetStateValue(1, state); // 0x0E, 14 if (status != EMBER_ZCL_STATUS_SUCCESS) { err = CHIP_ERROR_INTERNAL; @@ -94,25 +118,44 @@ CHIP_ERROR ManualDishWasherAlarmSetRaiseCommandHandler(int argc, char ** argv) CHIP_ERROR ManualDishWasherAlarmSetLowerCommandHandler(int argc, char ** argv) { + if (argc != 0) + { + return ManualDishWasherAlarmCommandHelpHandler(argc, argv); + } + CHIP_ERROR err = CHIP_NO_ERROR; EmberAfStatus status; DishwasherAlarmServer & serverInstance = DishwasherAlarmServer::Instance(); - status = serverInstance.SetSupportedValue(1, 47); + BitMask supported; // Set dishwasher alarm supported value + supported.SetField(AlarmMap::kInflowError, 1); // 0x01, 1 + supported.SetField(AlarmMap::kDrainError, 1); // 0x02, 2 + supported.SetField(AlarmMap::kDoorError, 1); // 0x04, 4 + supported.SetField(AlarmMap::kTempTooLow, 1); // 0x08, 8 + supported.SetField(AlarmMap::kWaterLevelError, 1); // 0x20, 32 + + BitMask mask; // Set dishwasher alarm mask value + mask.SetField(AlarmMap::kInflowError, 1); // 0x01, 1 + mask.SetField(AlarmMap::kDrainError, 1); // 0x02, 2 + mask.SetField(AlarmMap::kDoorError, 1); // 0x04, 4 + mask.SetField(AlarmMap::kTempTooLow, 1); // 0x08, 8 + mask.SetField(AlarmMap::kWaterLevelError, 1); // 0x20, 32 + + status = serverInstance.SetSupportedValue(1, supported); // 0x2F, 47 if (status != EMBER_ZCL_STATUS_SUCCESS) { err = CHIP_ERROR_INTERNAL; goto exit; } - status = serverInstance.SetMaskValue(1, 47); + status = serverInstance.SetMaskValue(1, mask); // 0x2F, 47 if (status != EMBER_ZCL_STATUS_SUCCESS) { err = CHIP_ERROR_INTERNAL; goto exit; } - status = serverInstance.SetStateValue(1, 14, 0); + status = serverInstance.SetStateValue(1, 0); // Set dishwasher alarm state value 0x00, 0 if (status != EMBER_ZCL_STATUS_SUCCESS) { err = CHIP_ERROR_INTERNAL; diff --git a/examples/all-clusters-app/ameba/main/include/ManualOperationalStateCommand.h b/examples/all-clusters-app/ameba/main/include/ManualOperationalStateCommand.h index f2b9281cd8317f..dbe07ade006f9f 100644 --- a/examples/all-clusters-app/ameba/main/include/ManualOperationalStateCommand.h +++ b/examples/all-clusters-app/ameba/main/include/ManualOperationalStateCommand.h @@ -93,16 +93,10 @@ CHIP_ERROR ManualOperationalStateSetErrorCommandHandler(int argc, char ** argv) switch (error) { case to_underlying(OperationalState::ErrorStateEnum::kNoError): - err.errorStateID = to_underlying(OperationalState::ErrorStateEnum::kNoError); - break; case to_underlying(OperationalState::ErrorStateEnum::kUnableToStartOrResume): - err.errorStateID = to_underlying(OperationalState::ErrorStateEnum::kUnableToStartOrResume); - break; case to_underlying(OperationalState::ErrorStateEnum::kUnableToCompleteOperation): - err.errorStateID = to_underlying(OperationalState::ErrorStateEnum::kUnableToCompleteOperation); - break; case to_underlying(OperationalState::ErrorStateEnum::kCommandInvalidInState): - err.errorStateID = to_underlying(OperationalState::ErrorStateEnum::kCommandInvalidInState); + err.errorStateID = error; break; default: err.errorStateID = to_underlying(OperationalState::ErrorStateEnum::kUnknownEnumValue); @@ -165,41 +159,19 @@ CHIP_ERROR ManualRVCOperationalStateSetErrorCommandHandler(int argc, char ** arg switch (error) { - case to_underlying(OperationalState::ErrorStateEnum::kNoError): // 0x00, 0 - err.errorStateID = to_underlying(OperationalState::ErrorStateEnum::kNoError); - break; - case to_underlying(OperationalState::ErrorStateEnum::kUnableToStartOrResume): // 0x01, 1 - err.errorStateID = to_underlying(OperationalState::ErrorStateEnum::kUnableToStartOrResume); - break; - case to_underlying(OperationalState::ErrorStateEnum::kUnableToCompleteOperation): // 0x02, 2 - err.errorStateID = to_underlying(OperationalState::ErrorStateEnum::kUnableToCompleteOperation); - break; - case to_underlying(OperationalState::ErrorStateEnum::kCommandInvalidInState): // 0x03, 3 - err.errorStateID = to_underlying(OperationalState::ErrorStateEnum::kCommandInvalidInState); - break; + case to_underlying(OperationalState::ErrorStateEnum::kNoError): // 0x00, 0 + case to_underlying(OperationalState::ErrorStateEnum::kUnableToStartOrResume): // 0x01, 1 + case to_underlying(OperationalState::ErrorStateEnum::kUnableToCompleteOperation): // 0x02, 2 + case to_underlying(OperationalState::ErrorStateEnum::kCommandInvalidInState): // 0x03, 3 case to_underlying(RvcOperationalState::ErrorStateEnum::kFailedToFindChargingDock): // 0x40, 64 - err.errorStateID = to_underlying(RvcOperationalState::ErrorStateEnum::kFailedToFindChargingDock); - break; - case to_underlying(RvcOperationalState::ErrorStateEnum::kStuck): // 0x41, 65 - err.errorStateID = to_underlying(RvcOperationalState::ErrorStateEnum::kStuck); - break; - case to_underlying(RvcOperationalState::ErrorStateEnum::kDustBinMissing): // 0x42, 66 - err.errorStateID = to_underlying(RvcOperationalState::ErrorStateEnum::kDustBinMissing); - break; - case to_underlying(RvcOperationalState::ErrorStateEnum::kDustBinFull): // 0x43, 67 - err.errorStateID = to_underlying(RvcOperationalState::ErrorStateEnum::kDustBinFull); - break; - case to_underlying(RvcOperationalState::ErrorStateEnum::kWaterTankEmpty): // 0x44, 68 - err.errorStateID = to_underlying(RvcOperationalState::ErrorStateEnum::kWaterTankEmpty); - break; - case to_underlying(RvcOperationalState::ErrorStateEnum::kWaterTankMissing): // 0x45, 69 - err.errorStateID = to_underlying(RvcOperationalState::ErrorStateEnum::kWaterTankMissing); - break; - case to_underlying(RvcOperationalState::ErrorStateEnum::kWaterTankLidOpen): // 0x46, 70 - err.errorStateID = to_underlying(RvcOperationalState::ErrorStateEnum::kWaterTankLidOpen); - break; - case to_underlying(RvcOperationalState::ErrorStateEnum::kMopCleaningPadMissing): // 0x47, 71 - err.errorStateID = to_underlying(RvcOperationalState::ErrorStateEnum::kMopCleaningPadMissing); + case to_underlying(RvcOperationalState::ErrorStateEnum::kStuck): // 0x41, 65 + case to_underlying(RvcOperationalState::ErrorStateEnum::kDustBinMissing): // 0x42, 66 + case to_underlying(RvcOperationalState::ErrorStateEnum::kDustBinFull): // 0x43, 67 + case to_underlying(RvcOperationalState::ErrorStateEnum::kWaterTankEmpty): // 0x44, 68 + case to_underlying(RvcOperationalState::ErrorStateEnum::kWaterTankMissing): // 0x45, 69 + case to_underlying(RvcOperationalState::ErrorStateEnum::kWaterTankLidOpen): // 0x46, 70 + case to_underlying(RvcOperationalState::ErrorStateEnum::kMopCleaningPadMissing): // 0x47, 71 + err.errorStateID = error; break; default: err.errorStateID = to_underlying(RvcOperationalState::ErrorStateEnum::kUnknownEnumValue);