Skip to content

Commit

Permalink
[IM] Remove EmberAfStatus from src/app/clusters (#32055)
Browse files Browse the repository at this point in the history
* Remove EmberAfStatus from src/app/clusters

* fix ci

* fix specs compliance

* remove using Status from headers

* fix comments

* Remove using Status from headers

* fix comments

* fix ci

* fix door lock
  • Loading branch information
jepenven-silabs authored Feb 13, 2024
1 parent ea56e40 commit ddf373c
Show file tree
Hide file tree
Showing 54 changed files with 665 additions and 630 deletions.
12 changes: 7 additions & 5 deletions src/app/app-platform/ContentApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,37 @@
#include <lib/support/CodeUtils.h>
#include <lib/support/ZclString.h>
#include <platform/CHIPDeviceLayer.h>
#include <protocols/interaction_model/StatusCode.h>

#if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED

using namespace chip;
using namespace chip::AppPlatform;

using chip::Protocols::InteractionModel::Status;

namespace chip {
namespace AppPlatform {

#define ZCL_DESCRIPTOR_CLUSTER_REVISION (1u)
#define ZCL_APPLICATION_BASIC_CLUSTER_REVISION (1u)

EmberAfStatus ContentApp::HandleReadAttribute(ClusterId clusterId, AttributeId attributeId, uint8_t * buffer,
uint16_t maxReadLength)
Status ContentApp::HandleReadAttribute(ClusterId clusterId, AttributeId attributeId, uint8_t * buffer, uint16_t maxReadLength)
{
ChipLogProgress(DeviceLayer,
"Read Attribute for endpoint " ChipLogFormatMEI " cluster " ChipLogFormatMEI " attribute " ChipLogFormatMEI,
ChipLogValueMEI(mEndpointId), ChipLogValueMEI(clusterId), ChipLogValueMEI(attributeId));

return EMBER_ZCL_STATUS_FAILURE;
return Status::Failure;
}

EmberAfStatus ContentApp::HandleWriteAttribute(ClusterId clusterId, AttributeId attributeId, uint8_t * buffer)
Status ContentApp::HandleWriteAttribute(ClusterId clusterId, AttributeId attributeId, uint8_t * buffer)
{
ChipLogProgress(DeviceLayer,
"Read Attribute for endpoint " ChipLogFormatMEI " cluster " ChipLogFormatMEI " attribute " ChipLogFormatMEI,
ChipLogValueMEI(mEndpointId), ChipLogValueMEI(clusterId), ChipLogValueMEI(attributeId));

return EMBER_ZCL_STATUS_FAILURE;
return Status::Failure;
}

} // namespace AppPlatform
Expand Down
6 changes: 4 additions & 2 deletions src/app/app-platform/ContentApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <app/clusters/media-playback-server/media-playback-delegate.h>
#include <app/clusters/target-navigator-server/target-navigator-delegate.h>
#include <app/util/attribute-storage.h>
#include <protocols/interaction_model/StatusCode.h>

namespace chip {
namespace AppPlatform {
Expand Down Expand Up @@ -65,8 +66,9 @@ class DLL_EXPORT ContentApp
virtual MediaPlaybackDelegate * GetMediaPlaybackDelegate() = 0;
virtual TargetNavigatorDelegate * GetTargetNavigatorDelegate() = 0;

EmberAfStatus HandleReadAttribute(ClusterId clusterId, AttributeId attributeId, uint8_t * buffer, uint16_t maxReadLength);
EmberAfStatus HandleWriteAttribute(ClusterId clusterId, AttributeId attributeId, uint8_t * buffer);
Protocols::InteractionModel::Status HandleReadAttribute(ClusterId clusterId, AttributeId attributeId, uint8_t * buffer,
uint16_t maxReadLength);
Protocols::InteractionModel::Status HandleWriteAttribute(ClusterId clusterId, AttributeId attributeId, uint8_t * buffer);

protected:
EndpointId mEndpointId = 0;
Expand Down
28 changes: 15 additions & 13 deletions src/app/app-platform/ContentAppPlatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <lib/support/CodeUtils.h>
#include <lib/support/ZclString.h>
#include <platform/CHIPDeviceLayer.h>
#include <protocols/interaction_model/StatusCode.h>

#if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED

Expand All @@ -41,19 +42,20 @@ using namespace chip::app::Clusters;
using namespace chip::Access;
using ApplicationStatusEnum = app::Clusters::ApplicationBasic::ApplicationStatusEnum;
using GetSetupPINResponseType = app::Clusters::AccountLogin::Commands::GetSetupPINResponse::Type;
using chip::Protocols::InteractionModel::Status;

// Device Version for dynamic endpoints:
#define DEVICE_VERSION_DEFAULT 1

EmberAfStatus emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId,
const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer,
uint16_t maxReadLength)
Status emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId,
const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer,
uint16_t maxReadLength)
{
uint16_t endpointIndex = emberAfGetDynamicIndexFromEndpoint(endpoint);

ChipLogDetail(DeviceLayer, "emberAfExternalAttributeReadCallback endpoint %d ", endpointIndex);

EmberAfStatus ret = EMBER_ZCL_STATUS_FAILURE;
Status ret = Status::Failure;

ContentApp * app = ContentAppPlatform::GetInstance().GetContentApp(endpoint);
if (app != nullptr)
Expand All @@ -68,14 +70,14 @@ EmberAfStatus emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterI
return ret;
}

EmberAfStatus emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId,
const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer)
Status emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId,
const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer)
{
uint16_t endpointIndex = emberAfGetDynamicIndexFromEndpoint(endpoint);

ChipLogDetail(DeviceLayer, "emberAfExternalAttributeWriteCallback endpoint %d ", endpointIndex);

EmberAfStatus ret = EMBER_ZCL_STATUS_FAILURE;
Status ret = Status::Failure;

ContentApp * app = ContentAppPlatform::GetInstance().GetContentApp(endpoint);
if (app != nullptr)
Expand All @@ -93,18 +95,18 @@ EmberAfStatus emberAfExternalAttributeWriteCallback(EndpointId endpoint, Cluster
namespace chip {
namespace AppPlatform {

EmberAfStatus __attribute__((weak)) AppPlatformExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId,
const EmberAfAttributeMetadata * attributeMetadata,
uint8_t * buffer, uint16_t maxReadLength)
Status __attribute__((weak)) AppPlatformExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId,
const EmberAfAttributeMetadata * attributeMetadata,
uint8_t * buffer, uint16_t maxReadLength)
{
return (EMBER_ZCL_STATUS_FAILURE);
return (Status::Failure);
}

EmberAfStatus __attribute__((weak))
Status __attribute__((weak))
AppPlatformExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId,
const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer)
{
return (EMBER_ZCL_STATUS_FAILURE);
return (Status::Failure);
}

EndpointId ContentAppPlatform::AddContentApp(ContentApp * app, EmberAfEndpointType * ep,
Expand Down
14 changes: 8 additions & 6 deletions src/app/app-platform/ContentAppPlatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <app/util/attribute-storage.h>
#include <controller/CHIPCluster.h>
#include <platform/CHIPDeviceLayer.h>
#include <protocols/interaction_model/StatusCode.h>
#include <protocols/user_directed_commissioning/UserDirectedCommissioning.h>

using chip::app::Clusters::ApplicationBasic::CatalogVendorApp;
Expand All @@ -40,14 +41,15 @@ namespace AppPlatform {

// The AppPlatform overrides emberAfExternalAttributeReadCallback to handle external attribute reads for ContentApps.
// This callback can be used to handle external attribute reads for attributes belonging to static endpoints.
EmberAfStatus AppPlatformExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId,
const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer,
uint16_t maxReadLength);
Protocols::InteractionModel::Status AppPlatformExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId,
const EmberAfAttributeMetadata * attributeMetadata,
uint8_t * buffer, uint16_t maxReadLength);

// The AppPlatform overrides emberAfExternalAttributeWriteCallback to handle external attribute writes for ContentApps.
// This callback can be used to handle external attribute writes for attributes belonging to static endpoints.
EmberAfStatus AppPlatformExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId,
const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer);
Protocols::InteractionModel::Status AppPlatformExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId,
const EmberAfAttributeMetadata * attributeMetadata,
uint8_t * buffer);

inline constexpr EndpointId kTargetBindingClusterEndpointId = 0;
inline constexpr EndpointId kLocalVideoPlayerEndpointId = 1;
Expand Down Expand Up @@ -157,7 +159,7 @@ class DLL_EXPORT ContentAppPlatform
// loads given app and calls HandleGetSetupPasscode. Sets passcode to 0 if it cannot be obtained.
// return true if a matching app was found (and it granted this client access), even if a passcode was not obtained
bool HasTargetContentApp(uint16_t vendorId, uint16_t productId, CharSpan rotatingId,
chip::Protocols::UserDirectedCommissioning::TargetAppInfo & info, uint32_t & passcode);
Protocols::UserDirectedCommissioning::TargetAppInfo & info, uint32_t & passcode);

/**
* @brief
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <app/util/attribute-storage.h>
#include <app/util/config.h>
#include <platform/CHIPDeviceConfig.h>
#include <protocols/interaction_model/StatusCode.h>

#if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
#include <app/app-platform/ContentAppPlatform.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ bool HasFeature(chip::EndpointId endpoint, Feature feature)
bool hasFeature = false;
uint32_t featureMap = 0;

EmberAfStatus status = Attributes::FeatureMap::Get(endpoint, &featureMap);
if (EMBER_ZCL_STATUS_SUCCESS == status)
Status status = Attributes::FeatureMap::Get(endpoint, &featureMap);
if (Status::Success == status)
{
hasFeature = (featureMap & chip::to_underlying(feature));
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/clusters/audio-output-server/audio-output-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ bool HasFeature(chip::EndpointId endpoint, Feature feature)
bool hasFeature = false;
uint32_t featureMap = 0;

EmberAfStatus status = Attributes::FeatureMap::Get(endpoint, &featureMap);
if (EMBER_ZCL_STATUS_SUCCESS == status)
Status status = Attributes::FeatureMap::Get(endpoint, &featureMap);
if (Status::Success == status)
{
hasFeature = (featureMap & chip::to_underlying(feature));
}
Expand Down
34 changes: 17 additions & 17 deletions src/app/clusters/barrier-control-server/barrier-control-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,29 +102,29 @@ static void cancelEndpointTimerCallback(EndpointId endpoint)
uint8_t emAfPluginBarrierControlServerGetBarrierPosition(EndpointId endpoint)
{
uint8_t position;
EmberAfStatus status = Attributes::BarrierPosition::Get(endpoint, &position);
assert(status == EMBER_ZCL_STATUS_SUCCESS);
Status status = Attributes::BarrierPosition::Get(endpoint, &position);
assert(status == Status::Success);
return position;
}

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

bool emAfPluginBarrierControlServerIsPartialBarrierSupported(EndpointId endpoint)
{
uint8_t bitmap;
EmberAfStatus status = Attributes::BarrierCapabilities::Get(endpoint, &bitmap);
assert(status == EMBER_ZCL_STATUS_SUCCESS);
Status status = Attributes::BarrierCapabilities::Get(endpoint, &bitmap);
assert(status == Status::Success);
return (bitmap & to_underlying(BarrierControlCapabilities::kPartialBarrier)) != 0;
}

static uint16_t getOpenOrClosePeriod(EndpointId endpoint, bool open)
{
uint16_t period = 0;
EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
uint16_t period = 0;
Status status = Status::Success;
#if defined(ZCL_USING_BARRIER_CONTROL_CLUSTER_BARRIER_OPEN_PERIOD_ATTRIBUTE)
if (open)
{
Expand All @@ -137,21 +137,21 @@ static uint16_t getOpenOrClosePeriod(EndpointId endpoint, bool open)
status = Attributes::BarrierClosePeriod::Get(endpoint, &period);
}
#endif
assert(status == EMBER_ZCL_STATUS_SUCCESS);
assert(status == Status::Success);
return period;
}

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

uint16_t emAfPluginBarrierControlServerGetSafetyStatus(EndpointId endpoint)
{
uint16_t safetyStatus;
EmberAfStatus status = Attributes::BarrierSafetyStatus::Get(endpoint, &safetyStatus);
assert(status == EMBER_ZCL_STATUS_SUCCESS);
Status status = Attributes::BarrierSafetyStatus::Get(endpoint, &safetyStatus);
assert(status == Status::Success);
return safetyStatus;
}

Expand All @@ -163,8 +163,8 @@ static bool isRemoteLockoutOn(EndpointId endpoint)

void emAfPluginBarrierControlServerIncrementEvents(EndpointId endpoint, bool open, bool command)
{
EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
uint16_t events = 0;
Status status = Status::Success;
uint16_t events = 0;

#if defined(ZCL_USING_BARRIER_CONTROL_CLUSTER_BARRIER_OPEN_EVENTS_ATTRIBUTE)
if (open && !command)
Expand All @@ -190,7 +190,7 @@ void emAfPluginBarrierControlServerIncrementEvents(EndpointId endpoint, bool ope
status = Attributes::BarrierCommandCloseEvents::Get(endpoint, &events);
}
#endif
assert(status == EMBER_ZCL_STATUS_SUCCESS);
assert(status == Status::Success);

// Section 7.1.2.1.5-8 says that this events counter SHALL NOT roll over.
// The maximum 16-bit unsigned integer in Zigbee is 0xFFFE, so we have this
Expand Down Expand Up @@ -225,7 +225,7 @@ void emAfPluginBarrierControlServerIncrementEvents(EndpointId endpoint, bool ope
status = Attributes::BarrierCommandCloseEvents::Set(endpoint, events);
}
#endif
assert(status == EMBER_ZCL_STATUS_SUCCESS);
assert(status == Status::Success);
}

// -----------------------------------------------------------------------------
Expand Down
8 changes: 5 additions & 3 deletions src/app/clusters/basic-information/basic-information.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <platform/ConfigurationManager.h>
#include <platform/DeviceInstanceInfoProvider.h>
#include <platform/PlatformManager.h>
#include <protocols/interaction_model/StatusCode.h>

#include <cstddef>
#include <cstring>
Expand All @@ -41,6 +42,7 @@ using namespace chip::app::Clusters;
using namespace chip::app::Clusters::BasicInformation;
using namespace chip::app::Clusters::BasicInformation::Attributes;
using namespace chip::DeviceLayer;
using chip::Protocols::InteractionModel::Status;

namespace {

Expand Down Expand Up @@ -463,9 +465,9 @@ namespace Clusters {
namespace BasicInformation {
bool IsLocalConfigDisabled()
{
bool disabled = false;
EmberAfStatus status = LocalConfigDisabled::Get(0, &disabled);
return status == EMBER_ZCL_STATUS_SUCCESS && disabled;
bool disabled = false;
Status status = LocalConfigDisabled::Get(0, &disabled);
return status == Status::Success && disabled;
}
} // namespace BasicInformation
} // namespace Clusters
Expand Down
Loading

0 comments on commit ddf373c

Please sign in to comment.