diff --git a/src/app/clusters/refrigerator-alarm-server/refrigerator-alarm-server.cpp b/src/app/clusters/refrigerator-alarm-server/refrigerator-alarm-server.cpp index a3841d239f36e2..c8260d986cb90c 100644 --- a/src/app/clusters/refrigerator-alarm-server/refrigerator-alarm-server.cpp +++ b/src/app/clusters/refrigerator-alarm-server/refrigerator-alarm-server.cpp @@ -46,7 +46,7 @@ EmberAfStatus RefrigeratorAlarmServer::GetMaskValue(EndpointId endpoint, BitMask EmberAfStatus status = Attributes::Mask::Get(endpoint, mask); if (status != EMBER_ZCL_STATUS_SUCCESS) { - ChipLogProgress(Zcl, "Refrigerator Alarm: ERR: reading mask %x", status); + ChipLogProgress(Zcl, "Refrigerator Alarm: ERR: reading mask, err:0x%x", status); return status; } @@ -60,7 +60,7 @@ EmberAfStatus RefrigeratorAlarmServer::GetStateValue(EndpointId endpoint, BitMas EmberAfStatus status = Attributes::State::Get(endpoint, state); if (status != EMBER_ZCL_STATUS_SUCCESS) { - ChipLogProgress(Zcl, "Refrigerator Alarm: ERR: reading state %x", status); + ChipLogProgress(Zcl, "Refrigerator Alarm: ERR: reading state, err:0x%x", status); return status; } @@ -69,19 +69,28 @@ EmberAfStatus RefrigeratorAlarmServer::GetStateValue(EndpointId endpoint, BitMas return status; } -EmberAfStatus RefrigeratorAlarmServer::SetMaskValue(EndpointId endpoint, const BitMask & mask) +EmberAfStatus RefrigeratorAlarmServer::SetMaskValue(EndpointId endpoint, const BitMask mask) { EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; status = Attributes::Mask::Set(endpoint, mask); if (status != EMBER_ZCL_STATUS_SUCCESS) { - ChipLogProgress(Zcl, "Refrigerator Alarm: ERR: writing mask %x", status); + ChipLogProgress(Zcl, "Refrigerator Alarm: ERR: writing mask, err:0x%x", status); return status; } ChipLogProgress(Zcl, "Refrigerator Alarm: Mask ep%d value: %" PRIu32 "", endpoint, mask.Raw()); - return status; + // Whenever there is change in Mask, State should change accordingly. + BitMask state; + status = GetStateValue(endpoint, &state); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + return status; + } + + state = mask & state; + return SetStateValue(endpoint, state); } EmberAfStatus RefrigeratorAlarmServer::SetStateValue(EndpointId endpoint, BitMask newState) @@ -92,14 +101,14 @@ EmberAfStatus RefrigeratorAlarmServer::SetStateValue(EndpointId endpoint, BitMas status = Attributes::State::Get(endpoint, ¤tState); if (status != EMBER_ZCL_STATUS_SUCCESS) { - ChipLogProgress(Zcl, "Refrigerator Alarm: ERR: reading state %x", status); + ChipLogProgress(Zcl, "Refrigerator Alarm: ERR: reading state, err:0x%x", status); return status; } status = Attributes::State::Set(endpoint, newState); if (status != EMBER_ZCL_STATUS_SUCCESS) { - ChipLogProgress(Zcl, "Refrigerator Alarm: ERR: writing state %x", status); + ChipLogProgress(Zcl, "Refrigerator Alarm: ERR: writing state, err:0x%x", status); return status; } diff --git a/src/app/clusters/refrigerator-alarm-server/refrigerator-alarm-server.h b/src/app/clusters/refrigerator-alarm-server/refrigerator-alarm-server.h index 10cc29f3345708..a165a6c62d0d15 100644 --- a/src/app/clusters/refrigerator-alarm-server/refrigerator-alarm-server.h +++ b/src/app/clusters/refrigerator-alarm-server/refrigerator-alarm-server.h @@ -32,10 +32,11 @@ class RefrigeratorAlarmServer EmberAfStatus GetMaskValue(chip::EndpointId endpoint, chip::BitMask * mask); EmberAfStatus GetStateValue(chip::EndpointId endpoint, chip::BitMask * state); + // Whenever there is change on Mask we should change State accordingly. EmberAfStatus SetMaskValue(chip::EndpointId endpoint, - const chip::BitMask & mask); + const chip::BitMask mask); - // When State changes we are generating Notify event + // When State changes we are generating Notify event. EmberAfStatus SetStateValue(chip::EndpointId endpoint, chip::BitMask newState);