Skip to content

Commit ddf373c

Browse files
[IM] Remove EmberAfStatus from src/app/clusters (project-chip#32055)
* 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
1 parent ea56e40 commit ddf373c

File tree

54 files changed

+665
-630
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+665
-630
lines changed

src/app/app-platform/ContentApp.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -29,35 +29,37 @@
2929
#include <lib/support/CodeUtils.h>
3030
#include <lib/support/ZclString.h>
3131
#include <platform/CHIPDeviceLayer.h>
32+
#include <protocols/interaction_model/StatusCode.h>
3233

3334
#if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
3435

3536
using namespace chip;
3637
using namespace chip::AppPlatform;
3738

39+
using chip::Protocols::InteractionModel::Status;
40+
3841
namespace chip {
3942
namespace AppPlatform {
4043

4144
#define ZCL_DESCRIPTOR_CLUSTER_REVISION (1u)
4245
#define ZCL_APPLICATION_BASIC_CLUSTER_REVISION (1u)
4346

44-
EmberAfStatus ContentApp::HandleReadAttribute(ClusterId clusterId, AttributeId attributeId, uint8_t * buffer,
45-
uint16_t maxReadLength)
47+
Status ContentApp::HandleReadAttribute(ClusterId clusterId, AttributeId attributeId, uint8_t * buffer, uint16_t maxReadLength)
4648
{
4749
ChipLogProgress(DeviceLayer,
4850
"Read Attribute for endpoint " ChipLogFormatMEI " cluster " ChipLogFormatMEI " attribute " ChipLogFormatMEI,
4951
ChipLogValueMEI(mEndpointId), ChipLogValueMEI(clusterId), ChipLogValueMEI(attributeId));
5052

51-
return EMBER_ZCL_STATUS_FAILURE;
53+
return Status::Failure;
5254
}
5355

54-
EmberAfStatus ContentApp::HandleWriteAttribute(ClusterId clusterId, AttributeId attributeId, uint8_t * buffer)
56+
Status ContentApp::HandleWriteAttribute(ClusterId clusterId, AttributeId attributeId, uint8_t * buffer)
5557
{
5658
ChipLogProgress(DeviceLayer,
5759
"Read Attribute for endpoint " ChipLogFormatMEI " cluster " ChipLogFormatMEI " attribute " ChipLogFormatMEI,
5860
ChipLogValueMEI(mEndpointId), ChipLogValueMEI(clusterId), ChipLogValueMEI(attributeId));
5961

60-
return EMBER_ZCL_STATUS_FAILURE;
62+
return Status::Failure;
6163
}
6264

6365
} // namespace AppPlatform

src/app/app-platform/ContentApp.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <app/clusters/media-playback-server/media-playback-delegate.h>
3434
#include <app/clusters/target-navigator-server/target-navigator-delegate.h>
3535
#include <app/util/attribute-storage.h>
36+
#include <protocols/interaction_model/StatusCode.h>
3637

3738
namespace chip {
3839
namespace AppPlatform {
@@ -65,8 +66,9 @@ class DLL_EXPORT ContentApp
6566
virtual MediaPlaybackDelegate * GetMediaPlaybackDelegate() = 0;
6667
virtual TargetNavigatorDelegate * GetTargetNavigatorDelegate() = 0;
6768

68-
EmberAfStatus HandleReadAttribute(ClusterId clusterId, AttributeId attributeId, uint8_t * buffer, uint16_t maxReadLength);
69-
EmberAfStatus HandleWriteAttribute(ClusterId clusterId, AttributeId attributeId, uint8_t * buffer);
69+
Protocols::InteractionModel::Status HandleReadAttribute(ClusterId clusterId, AttributeId attributeId, uint8_t * buffer,
70+
uint16_t maxReadLength);
71+
Protocols::InteractionModel::Status HandleWriteAttribute(ClusterId clusterId, AttributeId attributeId, uint8_t * buffer);
7072

7173
protected:
7274
EndpointId mEndpointId = 0;

src/app/app-platform/ContentAppPlatform.cpp

+15-13
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <lib/support/CodeUtils.h>
3333
#include <lib/support/ZclString.h>
3434
#include <platform/CHIPDeviceLayer.h>
35+
#include <protocols/interaction_model/StatusCode.h>
3536

3637
#if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
3738

@@ -41,19 +42,20 @@ using namespace chip::app::Clusters;
4142
using namespace chip::Access;
4243
using ApplicationStatusEnum = app::Clusters::ApplicationBasic::ApplicationStatusEnum;
4344
using GetSetupPINResponseType = app::Clusters::AccountLogin::Commands::GetSetupPINResponse::Type;
45+
using chip::Protocols::InteractionModel::Status;
4446

4547
// Device Version for dynamic endpoints:
4648
#define DEVICE_VERSION_DEFAULT 1
4749

48-
EmberAfStatus emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId,
49-
const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer,
50-
uint16_t maxReadLength)
50+
Status emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId,
51+
const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer,
52+
uint16_t maxReadLength)
5153
{
5254
uint16_t endpointIndex = emberAfGetDynamicIndexFromEndpoint(endpoint);
5355

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

56-
EmberAfStatus ret = EMBER_ZCL_STATUS_FAILURE;
58+
Status ret = Status::Failure;
5759

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

71-
EmberAfStatus emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId,
72-
const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer)
73+
Status emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId,
74+
const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer)
7375
{
7476
uint16_t endpointIndex = emberAfGetDynamicIndexFromEndpoint(endpoint);
7577

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

78-
EmberAfStatus ret = EMBER_ZCL_STATUS_FAILURE;
80+
Status ret = Status::Failure;
7981

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

96-
EmberAfStatus __attribute__((weak)) AppPlatformExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId,
97-
const EmberAfAttributeMetadata * attributeMetadata,
98-
uint8_t * buffer, uint16_t maxReadLength)
98+
Status __attribute__((weak)) AppPlatformExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId,
99+
const EmberAfAttributeMetadata * attributeMetadata,
100+
uint8_t * buffer, uint16_t maxReadLength)
99101
{
100-
return (EMBER_ZCL_STATUS_FAILURE);
102+
return (Status::Failure);
101103
}
102104

103-
EmberAfStatus __attribute__((weak))
105+
Status __attribute__((weak))
104106
AppPlatformExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId,
105107
const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer)
106108
{
107-
return (EMBER_ZCL_STATUS_FAILURE);
109+
return (Status::Failure);
108110
}
109111

110112
EndpointId ContentAppPlatform::AddContentApp(ContentApp * app, EmberAfEndpointType * ep,

src/app/app-platform/ContentAppPlatform.h

+8-6
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <app/util/attribute-storage.h>
2828
#include <controller/CHIPCluster.h>
2929
#include <platform/CHIPDeviceLayer.h>
30+
#include <protocols/interaction_model/StatusCode.h>
3031
#include <protocols/user_directed_commissioning/UserDirectedCommissioning.h>
3132

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

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

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

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

162164
/**
163165
* @brief

src/app/clusters/account-login-server/account-login-server.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <app/util/attribute-storage.h>
3535
#include <app/util/config.h>
3636
#include <platform/CHIPDeviceConfig.h>
37+
#include <protocols/interaction_model/StatusCode.h>
3738

3839
#if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
3940
#include <app/app-platform/ContentAppPlatform.h>

src/app/clusters/application-launcher-server/application-launcher-server.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ bool HasFeature(chip::EndpointId endpoint, Feature feature)
116116
bool hasFeature = false;
117117
uint32_t featureMap = 0;
118118

119-
EmberAfStatus status = Attributes::FeatureMap::Get(endpoint, &featureMap);
120-
if (EMBER_ZCL_STATUS_SUCCESS == status)
119+
Status status = Attributes::FeatureMap::Get(endpoint, &featureMap);
120+
if (Status::Success == status)
121121
{
122122
hasFeature = (featureMap & chip::to_underlying(feature));
123123
}

src/app/clusters/audio-output-server/audio-output-server.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ bool HasFeature(chip::EndpointId endpoint, Feature feature)
9292
bool hasFeature = false;
9393
uint32_t featureMap = 0;
9494

95-
EmberAfStatus status = Attributes::FeatureMap::Get(endpoint, &featureMap);
96-
if (EMBER_ZCL_STATUS_SUCCESS == status)
95+
Status status = Attributes::FeatureMap::Get(endpoint, &featureMap);
96+
if (Status::Success == status)
9797
{
9898
hasFeature = (featureMap & chip::to_underlying(feature));
9999
}

src/app/clusters/barrier-control-server/barrier-control-server.cpp

+17-17
Original file line numberDiff line numberDiff line change
@@ -102,29 +102,29 @@ static void cancelEndpointTimerCallback(EndpointId endpoint)
102102
uint8_t emAfPluginBarrierControlServerGetBarrierPosition(EndpointId endpoint)
103103
{
104104
uint8_t position;
105-
EmberAfStatus status = Attributes::BarrierPosition::Get(endpoint, &position);
106-
assert(status == EMBER_ZCL_STATUS_SUCCESS);
105+
Status status = Attributes::BarrierPosition::Get(endpoint, &position);
106+
assert(status == Status::Success);
107107
return position;
108108
}
109109

110110
void emAfPluginBarrierControlServerSetBarrierPosition(EndpointId endpoint, uint8_t position)
111111
{
112-
EmberAfStatus status = Attributes::BarrierPosition::Set(endpoint, position);
113-
assert(status == EMBER_ZCL_STATUS_SUCCESS);
112+
Status status = Attributes::BarrierPosition::Set(endpoint, position);
113+
assert(status == Status::Success);
114114
}
115115

116116
bool emAfPluginBarrierControlServerIsPartialBarrierSupported(EndpointId endpoint)
117117
{
118118
uint8_t bitmap;
119-
EmberAfStatus status = Attributes::BarrierCapabilities::Get(endpoint, &bitmap);
120-
assert(status == EMBER_ZCL_STATUS_SUCCESS);
119+
Status status = Attributes::BarrierCapabilities::Get(endpoint, &bitmap);
120+
assert(status == Status::Success);
121121
return (bitmap & to_underlying(BarrierControlCapabilities::kPartialBarrier)) != 0;
122122
}
123123

124124
static uint16_t getOpenOrClosePeriod(EndpointId endpoint, bool open)
125125
{
126-
uint16_t period = 0;
127-
EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
126+
uint16_t period = 0;
127+
Status status = Status::Success;
128128
#if defined(ZCL_USING_BARRIER_CONTROL_CLUSTER_BARRIER_OPEN_PERIOD_ATTRIBUTE)
129129
if (open)
130130
{
@@ -137,21 +137,21 @@ static uint16_t getOpenOrClosePeriod(EndpointId endpoint, bool open)
137137
status = Attributes::BarrierClosePeriod::Get(endpoint, &period);
138138
}
139139
#endif
140-
assert(status == EMBER_ZCL_STATUS_SUCCESS);
140+
assert(status == Status::Success);
141141
return period;
142142
}
143143

144144
static void setMovingState(EndpointId endpoint, uint8_t newState)
145145
{
146-
EmberAfStatus status = Attributes::BarrierMovingState::Set(endpoint, newState);
147-
assert(status == EMBER_ZCL_STATUS_SUCCESS);
146+
Status status = Attributes::BarrierMovingState::Set(endpoint, newState);
147+
assert(status == Status::Success);
148148
}
149149

150150
uint16_t emAfPluginBarrierControlServerGetSafetyStatus(EndpointId endpoint)
151151
{
152152
uint16_t safetyStatus;
153-
EmberAfStatus status = Attributes::BarrierSafetyStatus::Get(endpoint, &safetyStatus);
154-
assert(status == EMBER_ZCL_STATUS_SUCCESS);
153+
Status status = Attributes::BarrierSafetyStatus::Get(endpoint, &safetyStatus);
154+
assert(status == Status::Success);
155155
return safetyStatus;
156156
}
157157

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

164164
void emAfPluginBarrierControlServerIncrementEvents(EndpointId endpoint, bool open, bool command)
165165
{
166-
EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
167-
uint16_t events = 0;
166+
Status status = Status::Success;
167+
uint16_t events = 0;
168168

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

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

231231
// -----------------------------------------------------------------------------

src/app/clusters/basic-information/basic-information.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <platform/ConfigurationManager.h>
3131
#include <platform/DeviceInstanceInfoProvider.h>
3232
#include <platform/PlatformManager.h>
33+
#include <protocols/interaction_model/StatusCode.h>
3334

3435
#include <cstddef>
3536
#include <cstring>
@@ -41,6 +42,7 @@ using namespace chip::app::Clusters;
4142
using namespace chip::app::Clusters::BasicInformation;
4243
using namespace chip::app::Clusters::BasicInformation::Attributes;
4344
using namespace chip::DeviceLayer;
45+
using chip::Protocols::InteractionModel::Status;
4446

4547
namespace {
4648

@@ -463,9 +465,9 @@ namespace Clusters {
463465
namespace BasicInformation {
464466
bool IsLocalConfigDisabled()
465467
{
466-
bool disabled = false;
467-
EmberAfStatus status = LocalConfigDisabled::Get(0, &disabled);
468-
return status == EMBER_ZCL_STATUS_SUCCESS && disabled;
468+
bool disabled = false;
469+
Status status = LocalConfigDisabled::Get(0, &disabled);
470+
return status == Status::Success && disabled;
469471
}
470472
} // namespace BasicInformation
471473
} // namespace Clusters

0 commit comments

Comments
 (0)