diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter index e7f2052c8255c0..9e867f1be026a7 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter @@ -2505,6 +2505,7 @@ server cluster RefrigeratorAlarm = 87 { readonly attribute AlarmMap mask = 0; readonly attribute AlarmMap state = 2; + readonly attribute AlarmMap supported = 3; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -6321,6 +6322,7 @@ endpoint 1 { emits event Notify; ram attribute mask default = 1; ram attribute state default = 0; + ram attribute supported default = 1; callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute eventList; diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap index fde21d164e306b..518c6e563eaa70 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap @@ -13603,6 +13603,22 @@ "maxInterval": 65534, "reportableChange": 0 }, + { + "name": "Supported", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "AlarmMap", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "GeneratedCommandList", "code": 65528, 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 719b144902776d..ea609dd9578645 100644 --- a/src/app/clusters/refrigerator-alarm-server/refrigerator-alarm-server.cpp +++ b/src/app/clusters/refrigerator-alarm-server/refrigerator-alarm-server.cpp @@ -47,10 +47,11 @@ EmberAfStatus RefrigeratorAlarmServer::GetMaskValue(EndpointId endpoint, BitMask if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogProgress(Zcl, "Refrigerator Alarm: ERR: reading mask, err:0x%x", status); - return status; } - - ChipLogProgress(Zcl, "Refrigerator Alarm: Mask ep%d value: %" PRIu32 "", endpoint, mask->Raw()); + else + { + ChipLogDetail(Zcl, "Refrigerator Alarm: Mask ep%d value: %" PRIx32 "", endpoint, mask->Raw()); + } return status; } @@ -61,10 +62,26 @@ EmberAfStatus RefrigeratorAlarmServer::GetStateValue(EndpointId endpoint, BitMas if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogProgress(Zcl, "Refrigerator Alarm: ERR: reading state, err:0x%x", status); - return status; } + else + { + ChipLogDetail(Zcl, "Refrigerator Alarm: State ep%d value: %" PRIx32 "", endpoint, state->Raw()); + } + + return status; +} - ChipLogProgress(Zcl, "Refrigerator Alarm: State ep%d value: %" PRIu32 "", endpoint, state->Raw()); +EmberAfStatus RefrigeratorAlarmServer::GetSupportedValue(EndpointId endpoint, BitMask * supported) +{ + EmberAfStatus status = Attributes::Supported::Get(endpoint, supported); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogProgress(Zcl, "Refrigerator Alarm: ERR: reading supported, err:0x%x", status); + } + else + { + ChipLogDetail(Zcl, "Refrigerator Alarm: Supported ep%d value: %" PRIx32 "", endpoint, supported->Raw()); + } return status; } @@ -79,7 +96,7 @@ EmberAfStatus RefrigeratorAlarmServer::SetMaskValue(EndpointId endpoint, const B return status; } - ChipLogProgress(Zcl, "Refrigerator Alarm: Mask ep%d value: %" PRIu32 "", endpoint, mask.Raw()); + ChipLogProgress(Zcl, "Refrigerator Alarm: Mask ep%d value: %" PRIx32 "", endpoint, mask.Raw()); // Whenever there is change in Mask, State should change accordingly. BitMask state; @@ -116,7 +133,7 @@ EmberAfStatus RefrigeratorAlarmServer::SetStateValue(EndpointId endpoint, BitMas return status; } - ChipLogProgress(Zcl, "Refrigerator Alarm: State ep%d value: %" PRIu32 "", endpoint, newState.Raw()); + ChipLogProgress(Zcl, "Refrigerator Alarm: State ep%d value: %" PRIx32 "", endpoint, newState.Raw()); // Generate Notify event. BitMask becameActive; @@ -136,6 +153,34 @@ EmberAfStatus RefrigeratorAlarmServer::SetStateValue(EndpointId endpoint, BitMas return status; } +EmberAfStatus RefrigeratorAlarmServer::SetSupportedValue(EndpointId endpoint, const BitMask supported) +{ + EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; + status = Attributes::Supported::Set(endpoint, supported); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogProgress(Zcl, "Refrigerator Alarm: ERR: writing supported, err:0x%x", status); + return status; + } + + ChipLogProgress(Zcl, "Refrigerator Alarm: Supported ep%d value: %" PRIx32 "", endpoint, supported.Raw()); + + // Whenever there is change in Supported attribute, Mask, State should change accordingly. + BitMask mask; + status = GetMaskValue(endpoint, &mask); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + return status; + } + + if (!supported.HasAll(mask)) + { + mask = supported & mask; + status = SetMaskValue(endpoint, mask); + } + return status; +} + void RefrigeratorAlarmServer::SendNotifyEvent(EndpointId endpointId, BitMask becameActive, BitMask becameInactive, BitMask newState, BitMask mask) { 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 a165a6c62d0d15..1ed6023a9dbeab 100644 --- a/src/app/clusters/refrigerator-alarm-server/refrigerator-alarm-server.h +++ b/src/app/clusters/refrigerator-alarm-server/refrigerator-alarm-server.h @@ -31,8 +31,10 @@ class RefrigeratorAlarmServer EmberAfStatus GetMaskValue(chip::EndpointId endpoint, chip::BitMask * mask); EmberAfStatus GetStateValue(chip::EndpointId endpoint, chip::BitMask * state); + EmberAfStatus GetSupportedValue(chip::EndpointId endpoint, + chip::BitMask * suppported); - // Whenever there is change on Mask we should change State accordingly. + // A change in mask value will result in a corresponding change in state. EmberAfStatus SetMaskValue(chip::EndpointId endpoint, const chip::BitMask mask); @@ -40,6 +42,10 @@ class RefrigeratorAlarmServer EmberAfStatus SetStateValue(chip::EndpointId endpoint, chip::BitMask newState); + // A change in supported value will result in a corresponding change in mask and state. + EmberAfStatus SetSupportedValue(chip::EndpointId endpoint, + const chip::BitMask supported); + private: static RefrigeratorAlarmServer instance;