Skip to content

Commit

Permalink
Manual changes to make clusters compile.
Browse files Browse the repository at this point in the history
Mostly:

* Include headers needed for ConcreteCommandPath and the command field structs.
* Make sure the namespaces are done right (add using declarations or
  namespace prefixes as needed).
* Resolve some name ambiguities due to name collisions between
  cluster-objects.h and af-structs.h.  We need to find a better solution for
  this.
  • Loading branch information
bzbarsky-apple committed Oct 2, 2021
1 parent 47de348 commit d3e974a
Show file tree
Hide file tree
Showing 37 changed files with 232 additions and 126 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
#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/cluster-objects.h>
#include <app-common/zap-generated/command-id.h>

#include <app/Command.h>
#include <app/CommandHandler.h>
#include <app/ConcreteCommandPath.h>
#include <app/util/af.h>
#include <app/util/basic-types.h>
#include <lib/core/CHIPSafeCasts.h>
Expand Down Expand Up @@ -103,9 +105,9 @@ static void sendResponse(const char * responseName, ContentLaunchResponse launch
}
}

bool emberAfContentLauncherClusterLaunchContentCallback(app::CommandHandler * command, const app::ConcreteCommandPath & commandPath,
EndpointId endpoint, bool autoplay, unsigned char * data,
Commands::LaunchContent::DecodableType & fields)
bool emberAfContentLauncherClusterLaunchContentCallback(
chip::app::CommandHandler * command, const chip::app::ConcreteCommandPath & commandPath, chip::EndpointId endpoint,
bool autoplay, unsigned char * data, chip::app::Clusters::ContentLauncher::Commands::LaunchContent::DecodableType & fields)
{

string dataString(reinterpret_cast<char *>(data));
Expand All @@ -115,9 +117,10 @@ bool emberAfContentLauncherClusterLaunchContentCallback(app::CommandHandler * co
return true;
}

bool emberAfContentLauncherClusterLaunchURLCallback(app::CommandHandler * command, const app::ConcreteCommandPath & commandPath,
EndpointId endpoint, unsigned char * contentUrl, unsigned char * displayString,
Commands::LaunchURL::DecodableType & fields)
bool emberAfContentLauncherClusterLaunchURLCallback(
chip::app::CommandHandler * command, const chip::app::ConcreteCommandPath & commandPath, chip::EndpointId endpoint,
unsigned char * contentUrl, unsigned char * displayString,
chip::app::Clusters::ContentLauncher::Commands::LaunchURL::DecodableType & fields)
{
string contentUrlString(reinterpret_cast<char *>(contentUrl));
string displayStringString(reinterpret_cast<char *>(displayString));
Expand Down
5 changes: 3 additions & 2 deletions examples/window-app/common/src/ZclCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ void emberAfPostAttributeChangeCallback(chip::EndpointId endpoint, chip::Cluster
/**
* @brief Cluster StopMotion Command callback (from client)
*/
bool emberAfWindowCoveringClusterStopMotionCallback(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath,
EndpointId endpoint, Commands::StopMotion::DecodableType & fields)
bool emberAfWindowCoveringClusterStopMotionCallback(chip::app::CommandHandler * commandObj,
const chip::app::ConcreteCommandPath & commandPath, chip::EndpointId endpoint,
Commands::StopMotion::DecodableType & fields)
{
ChipLogProgress(Zcl, "StopMotion command received");
WindowApp::Instance().PostEvent(WindowApp::Event(WindowApp::EventId::StopMotion, endpoint));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@
******************************************************************************/

#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::AccountLogin;

bool accountLoginClusterIsUserLoggedIn(std::string requestTempAccountIdentifier, std::string requestSetupPin);
std::string accountLoginClusterGetSetupPin(std::string requestTempAccountIdentifier, EndpointId endpoint);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@
* @brief Implementation for the Administrator Commissioning Cluster
***************************************************************************/

#include <app-common/zap-generated/cluster-objects.h>
#include <app/CommandHandler.h>
#include <app/ConcreteCommandPath.h>
#include <app/server/Server.h>
#include <app/util/af.h>
#include <lib/support/CodeUtils.h>
#include <lib/support/logging/CHIPLogging.h>
#include <setup_payload/SetupPayload.h>

using namespace chip;
using namespace chip::app::Clusters::AdministratorCommissioning;

// Specifications section 5.4.2.3. Announcement Duration
constexpr uint32_t kMaxCommissionioningTimeoutSeconds = 15 * 60;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@
*******************************************************************************
******************************************************************************/

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

using namespace chip;
using namespace chip::app::Clusters::ApplicationBasic;

bool applicationBasicClusterChangeApplicationStatus(EmberAfApplicationBasicStatus status, EndpointId endpoint);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,18 @@

#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::ApplicationLauncher;

ApplicationLauncherResponse applicationLauncherClusterLaunchApp(ApplicationLauncherApp application, std::string data);
ApplicationLauncherResponse applicationLauncherClusterLaunchApp(::ApplicationLauncherApp application, std::string data);

bool emberAfApplicationLauncherClusterLaunchAppCallback(app::CommandHandler * commandObj,
const app::ConcreteCommandPath & commandPath, EndpointId endpoint,
Expand Down Expand Up @@ -61,11 +64,11 @@ void sendResponse(app::CommandHandler * command, ApplicationLauncherResponse res
}
}

ApplicationLauncherApp getApplicationFromCommand(uint16_t catalogVendorId, uint8_t * applicationId)
::ApplicationLauncherApp getApplicationFromCommand(uint16_t catalogVendorId, uint8_t * applicationId)
{
ApplicationLauncherApp application = {};
application.applicationId = applicationId;
application.catalogVendorId = catalogVendorId;
::ApplicationLauncherApp application = {};
application.applicationId = applicationId;
application.catalogVendorId = catalogVendorId;
return application;
}

Expand All @@ -74,7 +77,7 @@ bool emberAfApplicationLauncherClusterLaunchAppCallback(app::CommandHandler * co
uint16_t requestApplicationCatalogVendorId, uint8_t * requestApplicationId,
Commands::LaunchApp::DecodableType & fields)
{
ApplicationLauncherApp application = getApplicationFromCommand(requestApplicationCatalogVendorId, requestApplicationId);
::ApplicationLauncherApp application = getApplicationFromCommand(requestApplicationCatalogVendorId, requestApplicationId);
// TODO: Char is not null terminated, verify this code once #7963 gets merged.
std::string reqestDataString(reinterpret_cast<char *>(requestData));
ApplicationLauncherResponse response = applicationLauncherClusterLaunchApp(application, reqestDataString);
Expand Down
3 changes: 3 additions & 0 deletions src/app/clusters/audio-output-server/audio-output-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@
*******************************************************************************
******************************************************************************/

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

using namespace chip;
using namespace chip::app::Clusters::AudioOutput;

bool audioOutputClusterSelectOutput(uint8_t index);
bool audioOutputClusterRenameOutput(uint8_t index, uint8_t * name);
Expand Down
33 changes: 18 additions & 15 deletions src/app/clusters/barrier-control-server/barrier-control-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@
#include "barrier-control-server.h"
#include <app-common/zap-generated/af-structs.h>
#include <app-common/zap-generated/attributes/Accessors.h>
#include <app-common/zap-generated/cluster-objects.h>
#include <app-common/zap-generated/ids/Clusters.h>
#include <app/CommandHandler.h>
#include <app/ConcreteCommandPath.h>
#include <app/util/af.h>

#include <assert.h>
Expand All @@ -52,6 +54,7 @@

using namespace chip;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::BarrierControl;

typedef struct
{
Expand Down Expand Up @@ -85,21 +88,21 @@ void emberAfPluginBarrierControlServerInitCallback(void) {}
uint8_t emAfPluginBarrierControlServerGetBarrierPosition(EndpointId endpoint)
{
uint8_t position;
EmberAfStatus status = BarrierControl::Attributes::BarrierPosition::Get(endpoint, &position);
EmberAfStatus status = Attributes::BarrierPosition::Get(endpoint, &position);
assert(status == EMBER_ZCL_STATUS_SUCCESS);
return position;
}

void emAfPluginBarrierControlServerSetBarrierPosition(EndpointId endpoint, uint8_t position)
{
EmberAfStatus status = BarrierControl::Attributes::BarrierPosition::Set(endpoint, position);
EmberAfStatus status = Attributes::BarrierPosition::Set(endpoint, position);
assert(status == EMBER_ZCL_STATUS_SUCCESS);
}

bool emAfPluginBarrierControlServerIsPartialBarrierSupported(EndpointId endpoint)
{
uint8_t bitmap;
EmberAfStatus status = BarrierControl::Attributes::BarrierCapabilities::Get(endpoint, &bitmap);
EmberAfStatus status = Attributes::BarrierCapabilities::Get(endpoint, &bitmap);
assert(status == EMBER_ZCL_STATUS_SUCCESS);
return READBITS(bitmap, EMBER_AF_BARRIER_CONTROL_CAPABILITIES_PARTIAL_BARRIER);
}
Expand All @@ -111,13 +114,13 @@ static uint16_t getOpenOrClosePeriod(EndpointId endpoint, bool open)
#if defined(ZCL_USING_BARRIER_CONTROL_CLUSTER_BARRIER_OPEN_PERIOD_ATTRIBUTE)
if (open)
{
status = BarrierControl::Attributes::BarrierOpenPeriod::Get(endpoint, &period);
status = Attributes::BarrierOpenPeriod::Get(endpoint, &period);
}
#endif
#if defined(ZCL_USING_BARRIER_CONTROL_CLUSTER_BARRIER_CLOSE_PERIOD_ATTRIBUTE)
if (!open)
{
status = BarrierControl::Attributes::BarrierClosePeriod::Get(endpoint, &period);
status = Attributes::BarrierClosePeriod::Get(endpoint, &period);
}
#endif
assert(status == EMBER_ZCL_STATUS_SUCCESS);
Expand All @@ -126,14 +129,14 @@ static uint16_t getOpenOrClosePeriod(EndpointId endpoint, bool open)

static void setMovingState(EndpointId endpoint, uint8_t newState)
{
EmberAfStatus status = BarrierControl::Attributes::BarrierMovingState::Set(endpoint, newState);
EmberAfStatus status = Attributes::BarrierMovingState::Set(endpoint, newState);
assert(status == EMBER_ZCL_STATUS_SUCCESS);
}

uint16_t emAfPluginBarrierControlServerGetSafetyStatus(EndpointId endpoint)
{
uint16_t safetyStatus;
EmberAfStatus status = BarrierControl::Attributes::BarrierSafetyStatus::Get(endpoint, &safetyStatus);
EmberAfStatus status = Attributes::BarrierSafetyStatus::Get(endpoint, &safetyStatus);
assert(status == EMBER_ZCL_STATUS_SUCCESS);
return safetyStatus;
}
Expand All @@ -152,25 +155,25 @@ void emAfPluginBarrierControlServerIncrementEvents(EndpointId endpoint, bool ope
#if defined(ZCL_USING_BARRIER_CONTROL_CLUSTER_BARRIER_OPEN_EVENTS_ATTRIBUTE)
if (open && !command)
{
status = BarrierControl::Attributes::BarrierOpenEvents::Get(endpoint, &events);
status = Attributes::BarrierOpenEvents::Get(endpoint, &events);
}
#endif
#if defined(ZCL_USING_BARRIER_CONTROL_CLUSTER_BARRIER_CLOSE_EVENTS_ATTRIBUTE)
if (!open && !command)
{
status = BarrierControl::Attributes::BarrierCloseEvents::Get(endpoint, &events);
status = Attributes::BarrierCloseEvents::Get(endpoint, &events);
}
#endif
#if defined(ZCL_USING_BARRIER_CONTROL_CLUSTER_BARRIER_COMMAND_OPEN_EVENTS_ATTRIBUTE)
if (open && command)
{
status = BarrierControl::Attributes::BarrierCommandOpenEvents::Get(endpoint, &events);
status = Attributes::BarrierCommandOpenEvents::Get(endpoint, &events);
}
#endif
#if defined(ZCL_USING_BARRIER_CONTROL_CLUSTER_BARRIER_COMMAND_CLOSE_EVENTS_ATTRIBUTE)
if (!open && command)
{
status = BarrierControl::Attributes::BarrierCommandCloseEvents::Get(endpoint, &events);
status = Attributes::BarrierCommandCloseEvents::Get(endpoint, &events);
}
#endif
assert(status == EMBER_ZCL_STATUS_SUCCESS);
Expand All @@ -187,25 +190,25 @@ void emAfPluginBarrierControlServerIncrementEvents(EndpointId endpoint, bool ope
#if defined(ZCL_USING_BARRIER_CONTROL_CLUSTER_BARRIER_OPEN_EVENTS_ATTRIBUTE)
if (open && !command)
{
status = BarrierControl::Attributes::BarrierOpenEvents::Set(endpoint, events);
status = Attributes::BarrierOpenEvents::Set(endpoint, events);
}
#endif
#if defined(ZCL_USING_BARRIER_CONTROL_CLUSTER_BARRIER_CLOSE_EVENTS_ATTRIBUTE)
if (!open && !command)
{
status = BarrierControl::Attributes::BarrierCloseEvents::Set(endpoint, events);
status = Attributes::BarrierCloseEvents::Set(endpoint, events);
}
#endif
#if defined(ZCL_USING_BARRIER_CONTROL_CLUSTER_BARRIER_COMMAND_OPEN_EVENTS_ATTRIBUTE)
if (open && command)
{
status = BarrierControl::Attributes::BarrierCommandOpenEvents::Set(endpoint, events);
status = Attributes::BarrierCommandOpenEvents::Set(endpoint, events);
}
#endif
#if defined(ZCL_USING_BARRIER_CONTROL_CLUSTER_BARRIER_COMMAND_CLOSE_EVENTS_ATTRIBUTE)
if (!open && command)
{
status = BarrierControl::Attributes::BarrierCommandCloseEvents::Set(endpoint, events);
status = Attributes::BarrierCommandCloseEvents::Set(endpoint, events);
}
#endif
assert(status == EMBER_ZCL_STATUS_SUCCESS);
Expand Down
3 changes: 3 additions & 0 deletions src/app/clusters/bindings/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@

#include <app/util/af.h>

#include <app-common/zap-generated/cluster-objects.h>
#include <app/CommandHandler.h>
#include <app/ConcreteCommandPath.h>
#include <app/util/binding-table.h>
#include <lib/support/logging/CHIPLogging.h>

using namespace chip;
using namespace chip::app::Clusters::Binding;

EmberStatus prepareBinding(EmberBindingTableEntry & binding, NodeId nodeId, GroupId groupId, EndpointId endpointId,
ClusterId clusterId)
Expand Down
Loading

0 comments on commit d3e974a

Please sign in to comment.