Skip to content

Commit

Permalink
Remove cluster-id.h and use accessors into various clusters
Browse files Browse the repository at this point in the history
  • Loading branch information
vivien-apple committed Oct 22, 2021
1 parent 0c16976 commit 07a12b6
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 121 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@
*******************************************************************************
******************************************************************************/

#include <app-common/zap-generated/cluster-id.h>
#include <app-common/zap-generated/cluster-objects.h>
#include <app-common/zap-generated/command-id.h>
#include <app/CommandHandler.h>
#include <app/ConcreteCommandPath.h>
#include <app/util/af.h>
#include <string>

using namespace chip;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::AccountLogin;

bool accountLoginClusterIsUserLoggedIn(std::string requestTempAccountIdentifier, std::string requestSetupPin);
Expand All @@ -38,8 +37,8 @@ std::string accountLoginClusterGetSetupPin(std::string requestTempAccountIdentif
void sendResponse(app::CommandHandler * command, const char * responseSetupPin)
{
CHIP_ERROR err = CHIP_NO_ERROR;
app::CommandPathParams cmdParams = { emberAfCurrentEndpoint(), /* group id */ 0, ZCL_ACCOUNT_LOGIN_CLUSTER_ID,
ZCL_GET_SETUP_PIN_RESPONSE_COMMAND_ID, (app::CommandPathFlags::kEndpointIdValid) };
app::CommandPathParams cmdParams = { emberAfCurrentEndpoint(), /* group id */ 0, AccountLogin::Id,
Commands::GetSetupPINResponse::Id, (app::CommandPathFlags::kEndpointIdValid) };
TLV::TLVWriter * writer = nullptr;
SuccessOrExit(err = command->PrepareCommand(cmdParams));
VerifyOrExit((writer = command->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,15 @@
******************************************************************************/

#include <app-common/zap-generated/af-structs.h>
#include <app-common/zap-generated/cluster-id.h>
#include <app-common/zap-generated/cluster-objects.h>
#include <app-common/zap-generated/command-id.h>
#include <app-common/zap-generated/enums.h>
#include <app/CommandHandler.h>
#include <app/ConcreteCommandPath.h>
#include <app/clusters/application-launcher-server/application-launcher-server.h>
#include <app/util/af.h>

using namespace chip;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::ApplicationLauncher;

ApplicationLauncherResponse applicationLauncherClusterLaunchApp(::ApplicationLauncherApp application, std::string data);
Expand All @@ -49,8 +48,8 @@ bool emberAfApplicationLauncherClusterLaunchAppCallback(app::CommandHandler * co
void sendResponse(app::CommandHandler * command, ApplicationLauncherResponse response)
{
CHIP_ERROR err = CHIP_NO_ERROR;
app::CommandPathParams cmdParams = { emberAfCurrentEndpoint(), /* group id */ 0, ZCL_APPLICATION_LAUNCHER_CLUSTER_ID,
ZCL_LAUNCH_APP_RESPONSE_COMMAND_ID, (app::CommandPathFlags::kEndpointIdValid) };
app::CommandPathParams cmdParams = { emberAfCurrentEndpoint(), /* group id */ 0, ApplicationLauncher::Id,
Commands::LaunchAppResponse::Id, (app::CommandPathFlags::kEndpointIdValid) };
TLV::TLVWriter * writer = nullptr;
SuccessOrExit(err = command->PrepareCommand(cmdParams));
VerifyOrExit((writer = command->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE);
Expand Down
19 changes: 8 additions & 11 deletions src/app/clusters/color-control-server/color-control-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@
#include <app/util/af.h>

#include <app-common/zap-generated/af-structs.h>
#include <app-common/zap-generated/attribute-id.h>
#include <app-common/zap-generated/attribute-type.h>
#include <app-common/zap-generated/attributes/Accessors.h>
#include <app-common/zap-generated/cluster-id.h>
#include <app-common/zap-generated/cluster-objects.h>
#include <app/CommandHandler.h>
#include <app/ConcreteCommandPath.h>
Expand Down Expand Up @@ -94,7 +91,7 @@ bool ColorControlServer::shouldExecuteIfOff(EndpointId endpoint, uint8_t optionM
// (FALSE).
// - The value of the ExecuteIfOff bit is 0."

if (!emberAfContainsServer(endpoint, ZCL_ON_OFF_CLUSTER_ID))
if (!emberAfContainsServer(endpoint, OnOff::Id))
{
return true;
}
Expand Down Expand Up @@ -257,7 +254,7 @@ uint16_t ColorControlServer::computeTransitionTimeFromStateAndRate(ColorControlS
*/
EmberEventControl * ColorControlServer::getEventControl(EndpointId endpoint)
{
uint16_t index = emberAfFindClusterServerEndpointIndex(endpoint, ZCL_COLOR_CONTROL_CLUSTER_ID);
uint16_t index = emberAfFindClusterServerEndpointIndex(endpoint, ColorControl::Id);
return &eventControls[index];
}

Expand Down Expand Up @@ -357,7 +354,7 @@ bool ColorControlServer::computeNewColor16uValue(ColorControlServer::Color16uTra
*/
ColorControlServer::ColorHueTransitionState * ColorControlServer::getColorHueTransitionState(EndpointId endpoint)
{
uint16_t index = emberAfFindClusterServerEndpointIndex(endpoint, ZCL_COLOR_CONTROL_CLUSTER_ID);
uint16_t index = emberAfFindClusterServerEndpointIndex(endpoint, ColorControl::Id);
return &colorHueTransitionStates[index];
}

Expand All @@ -369,7 +366,7 @@ ColorControlServer::ColorHueTransitionState * ColorControlServer::getColorHueTra
*/
ColorControlServer::Color16uTransitionState * ColorControlServer::getSaturationTransitionState(EndpointId endpoint)
{
uint16_t index = emberAfFindClusterServerEndpointIndex(endpoint, ZCL_COLOR_CONTROL_CLUSTER_ID);
uint16_t index = emberAfFindClusterServerEndpointIndex(endpoint, ColorControl::Id);
return &colorSatTransitionStates[index];
}

Expand Down Expand Up @@ -1520,7 +1517,7 @@ void ColorControlServer::updateHueSatCommand(EndpointId endpoint)
*/
ColorControlServer::Color16uTransitionState * ColorControlServer::getXTransitionState(EndpointId endpoint)
{
uint16_t index = emberAfFindClusterServerEndpointIndex(endpoint, ZCL_COLOR_CONTROL_CLUSTER_ID);
uint16_t index = emberAfFindClusterServerEndpointIndex(endpoint, ColorControl::Id);
return &colorXtransitionStates[index];
}

Expand All @@ -1532,7 +1529,7 @@ ColorControlServer::Color16uTransitionState * ColorControlServer::getXTransition
*/
ColorControlServer::Color16uTransitionState * ColorControlServer::getYTransitionState(EndpointId endpoint)
{
uint16_t index = emberAfFindClusterServerEndpointIndex(endpoint, ZCL_COLOR_CONTROL_CLUSTER_ID);
uint16_t index = emberAfFindClusterServerEndpointIndex(endpoint, ColorControl::Id);
return &colorYtransitionStates[index];
}

Expand Down Expand Up @@ -1815,7 +1812,7 @@ void ColorControlServer::updateXYCommand(EndpointId endpoint)
*/
ColorControlServer::Color16uTransitionState * ColorControlServer::getTempTransitionState(EndpointId endpoint)
{
uint16_t index = emberAfFindClusterServerEndpointIndex(endpoint, ZCL_COLOR_CONTROL_CLUSTER_ID);
uint16_t index = emberAfFindClusterServerEndpointIndex(endpoint, ColorControl::Id);
return &colorTempTransitionStates[index];
}

Expand Down Expand Up @@ -2231,7 +2228,7 @@ void ColorControlServer::levelControlColorTempChangeCommand(EndpointId endpoint)
// Control cluster is equal to 0, there SHALL be no link between color
// temperature and current level.

if (!emberAfContainsServer(endpoint, ZCL_COLOR_CONTROL_CLUSTER_ID))
if (!emberAfContainsServer(endpoint, ColorControl::Id))
{
return;
}
Expand Down
26 changes: 11 additions & 15 deletions src/app/clusters/groups-server/groups-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,8 @@
// *******************************************************************
#include "groups-server.h"

#include <app-common/zap-generated/att-storage.h>
#include <app-common/zap-generated/attribute-id.h>
#include <app-common/zap-generated/attribute-type.h>
#include <app-common/zap-generated/cluster-id.h>
#include <app-common/zap-generated/attributes/Accessors.h>
#include <app-common/zap-generated/cluster-objects.h>
#include <app-common/zap-generated/command-id.h>
#include <app/CommandHandler.h>
#include <app/ConcreteCommandPath.h>
#include <app/util/af.h>
Expand All @@ -62,6 +58,7 @@
#endif // EMBER_AF_PLUGIN_SCENES

using namespace chip;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::Groups;

static bool isGroupPresent(EndpointId endpoint, GroupId groupId);
Expand All @@ -76,8 +73,7 @@ void emberAfGroupsClusterServerInitCallback(EndpointId endpoint)
// Group names are not supported by this plugin.
EmberAfStatus status;
uint8_t nameSupport = (uint8_t) emberAfPluginGroupsServerGroupNamesSupportedCallback(endpoint);
status = emberAfWriteAttribute(endpoint, ZCL_GROUPS_CLUSTER_ID, ZCL_GROUP_NAME_SUPPORT_ATTRIBUTE_ID, CLUSTER_MASK_SERVER,
(uint8_t *) &nameSupport, ZCL_BITMAP8_ATTRIBUTE_TYPE);
status = Attributes::NameSupport::Set(endpoint, nameSupport);
if (status != EMBER_ZCL_STATUS_SUCCESS)
{
emberAfGroupsClusterPrintln("ERR: writing name support %x", status);
Expand Down Expand Up @@ -174,8 +170,8 @@ bool emberAfGroupsClusterAddGroupCallback(app::CommandHandler * commandObj, cons
}

{
app::CommandPathParams cmdParams = { emberAfCurrentEndpoint(), /* group id */ 0, ZCL_GROUPS_CLUSTER_ID,
ZCL_ADD_GROUP_RESPONSE_COMMAND_ID, (app::CommandPathFlags::kEndpointIdValid) };
app::CommandPathParams cmdParams = { emberAfCurrentEndpoint(), /* group id */ 0, Groups::Id, Commands::AddGroupResponse::Id,
(app::CommandPathFlags::kEndpointIdValid) };
TLV::TLVWriter * writer = nullptr;
SuccessOrExit(err = commandObj->PrepareCommand(cmdParams));
VerifyOrExit((writer = commandObj->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE);
Expand Down Expand Up @@ -218,8 +214,8 @@ bool emberAfGroupsClusterViewGroupCallback(app::CommandHandler * commandObj, con
}

{
app::CommandPathParams cmdParams = { emberAfCurrentEndpoint(), /* group id */ 0, ZCL_GROUPS_CLUSTER_ID,
ZCL_VIEW_GROUP_RESPONSE_COMMAND_ID, (app::CommandPathFlags::kEndpointIdValid) };
app::CommandPathParams cmdParams = { emberAfCurrentEndpoint(), /* group id */ 0, Groups::Id,
Commands::ViewGroupResponse::Id, (app::CommandPathFlags::kEndpointIdValid) };
TLV::TLVWriter * writer = nullptr;
SuccessOrExit(err = commandObj->PrepareCommand(cmdParams));
VerifyOrExit((writer = commandObj->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE);
Expand Down Expand Up @@ -316,8 +312,8 @@ bool emberAfGroupsClusterGetGroupMembershipCallback(app::CommandHandler * comman
// used for other purposes besides groups, we can't be sure what the
// capacity will be in the future.
{
app::CommandPathParams cmdParams = { emberAfCurrentEndpoint(), /* group id */ 0, ZCL_GROUPS_CLUSTER_ID,
ZCL_GET_GROUP_MEMBERSHIP_RESPONSE_COMMAND_ID,
app::CommandPathParams cmdParams = { emberAfCurrentEndpoint(), /* group id */ 0, Groups::Id,
Commands::GetGroupMembershipResponse::Id,
(app::CommandPathFlags::kEndpointIdValid) };
TLV::TLVWriter * writer = nullptr;
SuccessOrExit(err = commandObj->PrepareCommand(cmdParams));
Expand Down Expand Up @@ -369,8 +365,8 @@ bool emberAfGroupsClusterRemoveGroupCallback(app::CommandHandler * commandObj, c
// removed the scenes associated with that group SHOULD be removed."
emberAfScenesClusterRemoveScenesInGroupCallback(emberAfCurrentEndpoint(), groupId);
{
app::CommandPathParams cmdParams = { emberAfCurrentEndpoint(), /* group id */ 0, ZCL_GROUPS_CLUSTER_ID,
ZCL_REMOVE_GROUP_RESPONSE_COMMAND_ID, (app::CommandPathFlags::kEndpointIdValid) };
app::CommandPathParams cmdParams = { emberAfCurrentEndpoint(), /* group id */ 0, Groups::Id,
Commands::RemoveGroupResponse::Id, (app::CommandPathFlags::kEndpointIdValid) };
TLV::TLVWriter * writer = nullptr;
SuccessOrExit(err = commandObj->PrepareCommand(cmdParams));
VerifyOrExit((writer = commandObj->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE);
Expand Down
9 changes: 3 additions & 6 deletions src/app/clusters/media-input-server/media-input-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,15 @@
*******************************************************************************
******************************************************************************/

#include <app-common/zap-generated/attribute-id.h>
#include <app-common/zap-generated/attribute-type.h>
#include <app-common/zap-generated/cluster-id.h>
#include <app-common/zap-generated/attributes/Accessors.h>
#include <app-common/zap-generated/cluster-objects.h>
#include <app-common/zap-generated/command-id.h>
#include <app/CommandHandler.h>
#include <app/ConcreteCommandPath.h>
#include <app/util/af.h>
#include <string>

using namespace chip;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::MediaInput;

bool mediaInputClusterSelectInput(uint8_t input);
Expand All @@ -41,8 +39,7 @@ bool mediaInputClusterRenameInput(uint8_t input, std::string name);

static void storeCurrentInput(EndpointId endpoint, uint8_t currentInput)
{
EmberAfStatus status = emberAfWriteServerAttribute(
endpoint, ZCL_MEDIA_INPUT_CLUSTER_ID, ZCL_MEDIA_INPUT_CURRENT_INPUT_ATTRIBUTE_ID, &currentInput, ZCL_INT8U_ATTRIBUTE_TYPE);
EmberAfStatus status = Attributes::CurrentMediaInput::Set(endpoint, currentInput);
if (status != EMBER_ZCL_STATUS_SUCCESS)
{
ChipLogError(Zcl, "Failed to store media playback attribute.");
Expand Down
Loading

0 comments on commit 07a12b6

Please sign in to comment.