Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QPG] QPG examples bulk update #34501

Merged
merged 11 commits into from
Jul 25, 2024
Prev Previous commit
Next Next commit
Set groups cluster to server in switch.zap and improve command handli…
…ng for unicast and multicast
  • Loading branch information
lucicop authored and adamb-q committed Jul 25, 2024
commit 85d5afc4fb20560497c8cbb55bf9bd6660df5fa0
1 change: 1 addition & 0 deletions examples/light-switch-app/qpg/src/SwitchManager.cpp
Original file line number Diff line number Diff line change
@@ -48,6 +48,7 @@ void SwitchManager::ToggleHandler(AppEvent * aEvent)
data->localEndpointId = SWITCH_ENDPOINT_ID;
data->clusterId = chip::app::Clusters::OnOff::Id;
data->commandId = chip::app::Clusters::OnOff::Commands::Toggle::Id;
data->isGroup = true;

DeviceLayer::PlatformMgr().ScheduleWork(SwitchWorkerFunction, reinterpret_cast<intptr_t>(data));
}
131 changes: 95 additions & 36 deletions examples/light-switch-app/qpg/src/binding-handler.cpp
Original file line number Diff line number Diff line change
@@ -38,31 +38,59 @@ static void ProcessSwitchUnicastBindingCommand(CommandId commandId, const EmberB
ChipLogError(NotSpecified, "Switch command failed: %" CHIP_ERROR_FORMAT, error.Format());
};

switch (commandId)
switch (data->clusterId)
{
case Clusters::OnOff::Commands::Toggle::Id:
Clusters::OnOff::Commands::Toggle::Type toggleCommand;
Controller::InvokeCommandRequest(exchangeMgr, sessionHandle, binding.remote, toggleCommand, onSuccess, onFailure);
break;
case Clusters::OnOff::Id:
switch (commandId)
{
case Clusters::OnOff::Commands::Toggle::Id:
Clusters::OnOff::Commands::Toggle::Type toggleCommand;
Controller::InvokeCommandRequest(exchangeMgr, sessionHandle, binding.remote, toggleCommand, onSuccess, onFailure);
break;
case Clusters::OnOff::Commands::On::Id:
Clusters::OnOff::Commands::On::Type onCommand;
Controller::InvokeCommandRequest(exchangeMgr, sessionHandle, binding.remote, onCommand, onSuccess, onFailure);
break;

case Clusters::LevelControl::Commands::MoveToLevel::Id: {
Clusters::LevelControl::Commands::MoveToLevel::Type moveToLevelCommand;
moveToLevelCommand.level = data->level;
Controller::InvokeCommandRequest(exchangeMgr, sessionHandle, binding.remote, moveToLevelCommand, onSuccess, onFailure);
}
break;
case Clusters::ColorControl::Commands::MoveToColor::Id: {
case Clusters::OnOff::Commands::Off::Id:
Clusters::OnOff::Commands::Off::Type offCommand;
Controller::InvokeCommandRequest(exchangeMgr, sessionHandle, binding.remote, offCommand, onSuccess, onFailure);
break;
default:
ChipLogError(NotSpecified, "Unsupported Command Id");
break;
}
break;

Clusters::ColorControl::Commands::MoveToColor::Type moveToColorCommand;
case Clusters::LevelControl::Id:
if (commandId == Clusters::LevelControl::Commands::MoveToLevel::Id)
{
Clusters::LevelControl::Commands::MoveToLevel::Type moveToLevelCommand;
moveToLevelCommand.level = data->level;
Controller::InvokeCommandRequest(exchangeMgr, sessionHandle, binding.remote, moveToLevelCommand, onSuccess, onFailure);
}
else
{
ChipLogError(NotSpecified, "Unsupported Command Id");
}
break;

moveToColorCommand.colorX = data->colorXY.x;
moveToColorCommand.colorY = data->colorXY.y;
Controller::InvokeCommandRequest(exchangeMgr, sessionHandle, binding.remote, moveToColorCommand, onSuccess, onFailure);
}
break;
case Clusters::ColorControl::Id:
if (commandId == Clusters::ColorControl::Commands::MoveToColor::Id)
{
Clusters::ColorControl::Commands::MoveToColor::Type moveToColorCommand;
moveToColorCommand.colorX = data->colorXY.x;
moveToColorCommand.colorY = data->colorXY.y;
Controller::InvokeCommandRequest(exchangeMgr, sessionHandle, binding.remote, moveToColorCommand, onSuccess, onFailure);
}
else
{
ChipLogError(NotSpecified, "Unsupported Command Id");
}
break;

default:
ChipLogError(NotSpecified, "Unsupported Command Id");
ChipLogError(NotSpecified, "Unsupported Cluster Id");
break;
}
}
@@ -71,28 +99,59 @@ static void ProcessSwitchGroupBindingCommand(CommandId commandId, const EmberBin
{
Messaging::ExchangeManager & exchangeMgr = Server::GetInstance().GetExchangeManager();

switch (commandId)
switch (data->clusterId)
{
case Clusters::OnOff::Commands::Toggle::Id: {
Clusters::OnOff::Commands::Toggle::Type toggleCommand;
Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, toggleCommand);
case Clusters::OnOff::Id:
switch (commandId)
{
case Clusters::OnOff::Commands::Toggle::Id:
Clusters::OnOff::Commands::Toggle::Type toggleCommand;
Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, toggleCommand);
break;
case Clusters::OnOff::Commands::On::Id:
Clusters::OnOff::Commands::On::Type onCommand;
Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, onCommand);

break;
case Clusters::OnOff::Commands::Off::Id:
Clusters::OnOff::Commands::Off::Type offCommand;
Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, offCommand);
break;
default:
ChipLogError(NotSpecified, "Unsupported Command Id");
break;
}
break;
}
case Clusters::LevelControl::Commands::MoveToLevel::Id: {
Clusters::LevelControl::Commands::MoveToLevel::Type moveToLevelCommand;
moveToLevelCommand.level = data->level;
Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, moveToLevelCommand);

case Clusters::LevelControl::Id:
if (commandId == Clusters::LevelControl::Commands::MoveToLevel::Id)
{
Clusters::LevelControl::Commands::MoveToLevel::Type moveToLevelCommand;
moveToLevelCommand.level = data->level;
Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, moveToLevelCommand);
}
else
{
ChipLogError(NotSpecified, "Unsupported Command Id");
}
break;
}
case Clusters::ColorControl::Commands::MoveToColor::Id: {
Clusters::ColorControl::Commands::MoveToColor::Type moveToColorCommand;
moveToColorCommand.colorX = data->colorXY.x;
moveToColorCommand.colorY = data->colorXY.y;
Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, moveToColorCommand);

case Clusters::ColorControl::Id:
if (commandId == Clusters::ColorControl::Commands::MoveToColor::Id)
{
Clusters::ColorControl::Commands::MoveToColor::Type moveToColorCommand;
moveToColorCommand.colorX = data->colorXY.x;
moveToColorCommand.colorY = data->colorXY.y;
Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, moveToColorCommand);
}
else
{
ChipLogError(NotSpecified, "Unsupported Command Id");
}
break;
}

default:
ChipLogError(NotSpecified, "Unsupported Command Id");
ChipLogError(NotSpecified, "Unsupported Cluster Id");
break;
}
}
22 changes: 21 additions & 1 deletion examples/light-switch-app/qpg/zap/switch.matter
Original file line number Diff line number Diff line change
@@ -2675,7 +2675,6 @@ endpoint 1 {
device type ma_colordimmerswitch = 261, version 1;

binding cluster Identify;
binding cluster Groups;
binding cluster OnOff;
binding cluster LevelControl;
binding cluster ScenesManagement;
@@ -2695,6 +2694,27 @@ endpoint 1 {
handle command TriggerEffect;
}

server cluster Groups {
ram attribute nameSupport;
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
callback attribute eventList;
callback attribute attributeList;
ram attribute featureMap default = 0;
ram attribute clusterRevision default = 4;

handle command AddGroup;
handle command AddGroupResponse;
handle command ViewGroup;
handle command ViewGroupResponse;
handle command GetGroupMembership;
handle command GetGroupMembershipResponse;
handle command RemoveGroup;
handle command RemoveGroupResponse;
handle command RemoveAllGroups;
handle command AddGroupIfIdentifying;
}

server cluster Descriptor {
callback attribute deviceTypeList;
callback attribute serverList;
96 changes: 80 additions & 16 deletions examples/light-switch-app/qpg/zap/switch.zap
Original file line number Diff line number Diff line change
@@ -4909,96 +4909,160 @@
"code": 4,
"mfgCode": null,
"define": "GROUPS_CLUSTER",
"side": "client",
"side": "server",
"enabled": 1,
"commands": [
{
"name": "AddGroup",
"code": 0,
"mfgCode": null,
"source": "client",
"isIncoming": 0,
"isIncoming": 1,
"isEnabled": 1
},
{
"name": "AddGroupResponse",
"code": 0,
"mfgCode": null,
"source": "server",
"isIncoming": 1,
"isIncoming": 0,
"isEnabled": 1
},
{
"name": "ViewGroup",
"code": 1,
"mfgCode": null,
"source": "client",
"isIncoming": 0,
"isIncoming": 1,
"isEnabled": 1
},
{
"name": "ViewGroupResponse",
"code": 1,
"mfgCode": null,
"source": "server",
"isIncoming": 1,
"isIncoming": 0,
"isEnabled": 1
},
{
"name": "GetGroupMembership",
"code": 2,
"mfgCode": null,
"source": "client",
"isIncoming": 0,
"isIncoming": 1,
"isEnabled": 1
},
{
"name": "GetGroupMembershipResponse",
"code": 2,
"mfgCode": null,
"source": "server",
"isIncoming": 1,
"isIncoming": 0,
"isEnabled": 1
},
{
"name": "RemoveGroup",
"code": 3,
"mfgCode": null,
"source": "client",
"isIncoming": 0,
"isIncoming": 1,
"isEnabled": 1
},
{
"name": "RemoveGroupResponse",
"code": 3,
"mfgCode": null,
"source": "server",
"isIncoming": 1,
"isIncoming": 0,
"isEnabled": 1
},
{
"name": "RemoveAllGroups",
"code": 4,
"mfgCode": null,
"source": "client",
"isIncoming": 0,
"isIncoming": 1,
"isEnabled": 1
},
{
"name": "AddGroupIfIdentifying",
"code": 5,
"mfgCode": null,
"source": "client",
"isIncoming": 0,
"isIncoming": 1,
"isEnabled": 1
}
],
"attributes": [
{
"name": "NameSupport",
"code": 0,
"mfgCode": null,
"side": "server",
"type": "NameSupportBitmap",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "GeneratedCommandList",
"code": 65528,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "AcceptedCommandList",
"code": 65529,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "AttributeList",
"code": 65531,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "FeatureMap",
"code": 65532,
"mfgCode": null,
"side": "client",
"side": "server",
"type": "bitmap32",
"included": 1,
"storageOption": "RAM",
@@ -5014,17 +5078,17 @@
"name": "ClusterRevision",
"code": 65533,
"mfgCode": null,
"side": "client",
"side": "server",
"type": "int16u",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "4",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": null
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
}
]
},