Skip to content

Commit

Permalink
Update server implemetation of refrigerator cluster to sync spec
Browse files Browse the repository at this point in the history
  • Loading branch information
jadhavrohit924 committed Jun 26, 2023
1 parent 7806dd1 commit b568c3c
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2365,6 +2365,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;
Expand Down Expand Up @@ -6160,6 +6161,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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13158,6 +13158,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,
Expand Down Expand Up @@ -32125,4 +32141,4 @@
}
],
"log": []
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,21 @@ EmberAfStatus RefrigeratorAlarmServer::GetStateValue(EndpointId endpoint, BitMas
return status;
}

EmberAfStatus RefrigeratorAlarmServer::GetSupportedValue(EndpointId endpoint, BitMask<AlarmMap> * supported)
{
EmberAfStatus status = Attributes::Supported::Get(endpoint, supported);
if (status != EMBER_ZCL_STATUS_SUCCESS)
{
printf("################################################################\n");
ChipLogProgress(Zcl, "Refrigerator Alarm: ERR: reading supported, err:0x%x", status);
return status;
}

ChipLogProgress(Zcl, "Refrigerator Alarm: Supported ep%d value: %" PRIu32 "", endpoint, supported->Raw());

return status;
}

EmberAfStatus RefrigeratorAlarmServer::SetMaskValue(EndpointId endpoint, const BitMask<AlarmMap> mask)
{
EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
Expand Down Expand Up @@ -136,6 +151,34 @@ EmberAfStatus RefrigeratorAlarmServer::SetStateValue(EndpointId endpoint, BitMas
return status;
}

EmberAfStatus RefrigeratorAlarmServer::SetSupportedValue(EndpointId endpoint, const BitMask<AlarmMap> 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: %" PRIu32 "", endpoint, supported.Raw());

// Whenever there is change in Supported attribute, Mask, State should change accordingly.
BitMask<AlarmMap> mask;
status = GetMaskValue(endpoint, &mask);
if (status != EMBER_ZCL_STATUS_SUCCESS)
{
return status;
}

if (mask != (supported & mask))
{
mask = supported & mask;
status = SetMaskValue(endpoint, mask);
}
return status;
}

void RefrigeratorAlarmServer::SendNotifyEvent(EndpointId endpointId, BitMask<AlarmMap> becameActive,
BitMask<AlarmMap> becameInactive, BitMask<AlarmMap> newState, BitMask<AlarmMap> mask)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class RefrigeratorAlarmServer

EmberAfStatus GetMaskValue(chip::EndpointId endpoint, chip::BitMask<chip::app::Clusters::RefrigeratorAlarm::AlarmMap> * mask);
EmberAfStatus GetStateValue(chip::EndpointId endpoint, chip::BitMask<chip::app::Clusters::RefrigeratorAlarm::AlarmMap> * state);
EmberAfStatus GetSupportedValue(chip::EndpointId endpoint,
chip::BitMask<chip::app::Clusters::RefrigeratorAlarm::AlarmMap> * suppported);

// Whenever there is change on Mask we should change State accordingly.
EmberAfStatus SetMaskValue(chip::EndpointId endpoint,
Expand All @@ -40,6 +42,10 @@ class RefrigeratorAlarmServer
EmberAfStatus SetStateValue(chip::EndpointId endpoint,
chip::BitMask<chip::app::Clusters::RefrigeratorAlarm::AlarmMap> newState);

// Whenever there is change on Supported attribute we should change Mask and State accordingly.
EmberAfStatus SetSupportedValue(chip::EndpointId endpoint,
const chip::BitMask<chip::app::Clusters::RefrigeratorAlarm::AlarmMap> supported);

private:
static RefrigeratorAlarmServer instance;

Expand Down

0 comments on commit b568c3c

Please sign in to comment.