Skip to content

Commit

Permalink
Convert to per-attribute namespaces for our Get/Set accessors (#10131)
Browse files Browse the repository at this point in the history
* Change codegen templates to use namespaced accessors.

* Regenerate generated files

* Mass-replace consumers of attribute accessors with namespaced API.

This was generated by installing the git-extras package and running:

  git sed -f g "Attributes::\([GS]\)et\([A-Za-z0-9]*\)" "Attributes::\2::\1et"

* Update thermostat cluster to use namespaced accessors.

This changeset was generated by installing the git-extras package and then running:

  git sed -f g "\([^:]\)Get\([A-Za-z0-9]*\)(endpoint" "\1\2::Get(endpoint" -- src/app/clusters/thermostat-server/thermostat-server.cpp
  git sed -f g "\([^:A-Za-z]\)Set\([A-Za-z0-9]*\)(aEndpointId" "\1\2::Set(aEndpointId" -- src/app/clusters/thermostat-server/thermostat-server.cpp
  git sed -f g "\([^:]\)Get\([A-Za-z0-9]*\)(aEndpointId" "\1\2::Get(aEndpointId" -- src/app/clusters/thermostat-server/thermostat-server.cpp
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Nov 3, 2021
1 parent 4aae391 commit b20a388
Show file tree
Hide file tree
Showing 18 changed files with 10,200 additions and 3,644 deletions.
8 changes: 4 additions & 4 deletions examples/lighting-app/qpg/src/ZclCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ void emberAfPostAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId
{
xy.x = *reinterpret_cast<uint16_t *>(value);
// get Y from cluster value storage
EmberAfStatus status = ColorControl::Attributes::GetCurrentY(endpoint, &xy.y);
EmberAfStatus status = ColorControl::Attributes::CurrentY::Get(endpoint, &xy.y);
assert(status == EMBER_ZCL_STATUS_SUCCESS);
}
if (attributeId == ZCL_COLOR_CONTROL_CURRENT_Y_ATTRIBUTE_ID)
{
xy.y = *reinterpret_cast<uint16_t *>(value);
// get X from cluster value storage
EmberAfStatus status = ColorControl::Attributes::GetCurrentX(endpoint, &xy.x);
EmberAfStatus status = ColorControl::Attributes::CurrentX::Get(endpoint, &xy.x);
assert(status == EMBER_ZCL_STATUS_SUCCESS);
}
ChipLogProgress(Zcl, "New XY color: %u|%u", xy.x, xy.y);
Expand All @@ -110,14 +110,14 @@ void emberAfPostAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId
{
hsv.h = *value;
// get saturation from cluster value storage
EmberAfStatus status = ColorControl::Attributes::GetCurrentSaturation(endpoint, &hsv.s);
EmberAfStatus status = ColorControl::Attributes::CurrentSaturation::Get(endpoint, &hsv.s);
assert(status == EMBER_ZCL_STATUS_SUCCESS);
}
if (attributeId == ZCL_COLOR_CONTROL_CURRENT_SATURATION_ATTRIBUTE_ID)
{
hsv.s = *value;
// get hue from cluster value storage
EmberAfStatus status = ColorControl::Attributes::GetCurrentHue(endpoint, &hsv.h);
EmberAfStatus status = ColorControl::Attributes::CurrentHue::Get(endpoint, &hsv.h);
assert(status == EMBER_ZCL_STATUS_SUCCESS);
}
ChipLogProgress(Zcl, "New HSV color: %u|%u", hsv.h, hsv.s);
Expand Down
24 changes: 12 additions & 12 deletions examples/window-app/common/src/WindowApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,11 +335,11 @@ void WindowApp::Cover::Init(chip::EndpointId endpoint)
mLiftTimer = WindowApp::Instance().CreateTimer("Timer:Lift", COVER_LIFT_TILT_TIMEOUT, OnLiftTimeout, this);
mTiltTimer = WindowApp::Instance().CreateTimer("Timer:Tilt", COVER_LIFT_TILT_TIMEOUT, OnTiltTimeout, this);

Attributes::SetInstalledOpenLimitLift(endpoint, LIFT_OPEN_LIMIT);
Attributes::SetInstalledClosedLimitLift(endpoint, LIFT_CLOSED_LIMIT);
Attributes::InstalledOpenLimitLift::Set(endpoint, LIFT_OPEN_LIMIT);
Attributes::InstalledClosedLimitLift::Set(endpoint, LIFT_CLOSED_LIMIT);
LiftPositionSet(endpoint, LiftToPercent100ths(endpoint, LIFT_CLOSED_LIMIT));
Attributes::SetInstalledOpenLimitTilt(endpoint, TILT_OPEN_LIMIT);
Attributes::SetInstalledClosedLimitTilt(endpoint, TILT_CLOSED_LIMIT);
Attributes::InstalledOpenLimitTilt::Set(endpoint, TILT_OPEN_LIMIT);
Attributes::InstalledClosedLimitTilt::Set(endpoint, TILT_CLOSED_LIMIT);
TiltPositionSet(endpoint, TiltToPercent100ths(endpoint, TILT_CLOSED_LIMIT));

// Attribute: Id 0 Type
Expand Down Expand Up @@ -383,7 +383,7 @@ void WindowApp::Cover::LiftUp()
{
uint16_t percent100ths = 0;

Attributes::GetCurrentPositionLiftPercent100ths(mEndpoint, &percent100ths);
Attributes::CurrentPositionLiftPercent100ths::Get(mEndpoint, &percent100ths);
if (percent100ths < 9000)
{
percent100ths += 1000;
Expand All @@ -399,7 +399,7 @@ void WindowApp::Cover::LiftDown()
{
uint16_t percent100ths = 0;

Attributes::GetCurrentPositionLiftPercent100ths(mEndpoint, &percent100ths);
Attributes::CurrentPositionLiftPercent100ths::Get(mEndpoint, &percent100ths);
if (percent100ths > 1000)
{
percent100ths -= 1000;
Expand All @@ -415,8 +415,8 @@ void WindowApp::Cover::GotoLift(EventId action)
{
uint16_t current = 0;
uint16_t target = 0;
Attributes::GetTargetPositionLiftPercent100ths(mEndpoint, &target);
Attributes::GetCurrentPositionLiftPercent100ths(mEndpoint, &current);
Attributes::TargetPositionLiftPercent100ths::Get(mEndpoint, &target);
Attributes::CurrentPositionLiftPercent100ths::Get(mEndpoint, &current);

if (EventId::None != action)
{
Expand Down Expand Up @@ -455,7 +455,7 @@ void WindowApp::Cover::GotoLift(EventId action)
void WindowApp::Cover::TiltUp()
{
uint16_t percent100ths = 0;
Attributes::GetCurrentPositionTiltPercent100ths(mEndpoint, &percent100ths);
Attributes::CurrentPositionTiltPercent100ths::Get(mEndpoint, &percent100ths);
if (percent100ths < 9000)
{
percent100ths += 1000;
Expand All @@ -470,7 +470,7 @@ void WindowApp::Cover::TiltUp()
void WindowApp::Cover::TiltDown()
{
uint16_t percent100ths = 0;
Attributes::GetCurrentPositionTiltPercent100ths(mEndpoint, &percent100ths);
Attributes::CurrentPositionTiltPercent100ths::Get(mEndpoint, &percent100ths);
if (percent100ths > 1000)
{
percent100ths -= 1000;
Expand All @@ -487,8 +487,8 @@ void WindowApp::Cover::GotoTilt(EventId action)
uint16_t current = 0;
uint16_t target = 0;

Attributes::GetTargetPositionTiltPercent100ths(mEndpoint, &target);
Attributes::GetCurrentPositionTiltPercent100ths(mEndpoint, &current);
Attributes::TargetPositionTiltPercent100ths::Get(mEndpoint, &target);
Attributes::CurrentPositionTiltPercent100ths::Get(mEndpoint, &current);

if (EventId::None != action)
{
Expand Down
8 changes: 4 additions & 4 deletions examples/window-app/common/src/ZclCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ void emberAfPostAttributeChangeCallback(chip::EndpointId endpoint, chip::Cluster
break;

case ZCL_WC_TARGET_POSITION_LIFT_PERCENT100_THS_ATTRIBUTE_ID:
Attributes::GetTargetPositionLiftPercent100ths(endpoint, &target);
Attributes::GetCurrentPositionLiftPercent100ths(endpoint, &current);
Attributes::TargetPositionLiftPercent100ths::Get(endpoint, &target);
Attributes::CurrentPositionLiftPercent100ths::Get(endpoint, &current);
if (current > target)
{
app.PostEvent(WindowApp::Event(WindowApp::EventId::LiftDown, endpoint));
Expand All @@ -69,8 +69,8 @@ void emberAfPostAttributeChangeCallback(chip::EndpointId endpoint, chip::Cluster
break;

case ZCL_WC_TARGET_POSITION_TILT_PERCENT100_THS_ATTRIBUTE_ID:
Attributes::GetTargetPositionTiltPercent100ths(endpoint, &target);
Attributes::GetCurrentPositionTiltPercent100ths(endpoint, &current);
Attributes::TargetPositionTiltPercent100ths::Get(endpoint, &target);
Attributes::CurrentPositionTiltPercent100ths::Get(endpoint, &current);
if (current > target)
{
app.PostEvent(WindowApp::Event(WindowApp::EventId::TiltDown, endpoint));
Expand Down
4 changes: 2 additions & 2 deletions examples/window-app/efr32/src/WindowAppImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ void WindowAppImpl::UpdateLCD()
EmberAfWcType type = TypeGet(cover.mEndpoint);
uint16_t lift = 0;
uint16_t tilt = 0;
Attributes::GetCurrentPositionLift(cover.mEndpoint, &lift);
Attributes::GetCurrentPositionTilt(cover.mEndpoint, &tilt);
Attributes::CurrentPositionLift::Get(cover.mEndpoint, &lift);
Attributes::CurrentPositionTilt::Get(cover.mEndpoint, &tilt);
LcdPainter::Paint(type, static_cast<uint8_t>(lift), static_cast<uint8_t>(tilt), mIcon);
}
else
Expand Down
30 changes: 15 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 @@ -85,21 +85,21 @@ void emberAfPluginBarrierControlServerInitCallback(void) {}
uint8_t emAfPluginBarrierControlServerGetBarrierPosition(EndpointId endpoint)
{
uint8_t position;
EmberAfStatus status = BarrierControl::Attributes::GetBarrierPosition(endpoint, &position);
EmberAfStatus status = BarrierControl::Attributes::BarrierPosition::Get(endpoint, &position);
assert(status == EMBER_ZCL_STATUS_SUCCESS);
return position;
}

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

bool emAfPluginBarrierControlServerIsPartialBarrierSupported(EndpointId endpoint)
{
uint8_t bitmap;
EmberAfStatus status = BarrierControl::Attributes::GetBarrierCapabilities(endpoint, &bitmap);
EmberAfStatus status = BarrierControl::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 +111,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::GetBarrierOpenPeriod(endpoint, &period);
status = BarrierControl::Attributes::BarrierOpenPeriod::Get(endpoint, &period);
}
#endif
#if defined(ZCL_USING_BARRIER_CONTROL_CLUSTER_BARRIER_CLOSE_PERIOD_ATTRIBUTE)
if (!open)
{
status = BarrierControl::Attributes::GetBarrierClosePeriod(endpoint, &period);
status = BarrierControl::Attributes::BarrierClosePeriod::Get(endpoint, &period);
}
#endif
assert(status == EMBER_ZCL_STATUS_SUCCESS);
Expand All @@ -126,14 +126,14 @@ static uint16_t getOpenOrClosePeriod(EndpointId endpoint, bool open)

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

uint16_t emAfPluginBarrierControlServerGetSafetyStatus(EndpointId endpoint)
{
uint16_t safetyStatus;
EmberAfStatus status = BarrierControl::Attributes::GetBarrierSafetyStatus(endpoint, &safetyStatus);
EmberAfStatus status = BarrierControl::Attributes::BarrierSafetyStatus::Get(endpoint, &safetyStatus);
assert(status == EMBER_ZCL_STATUS_SUCCESS);
return safetyStatus;
}
Expand All @@ -152,25 +152,25 @@ void emAfPluginBarrierControlServerIncrementEvents(EndpointId endpoint, bool ope
#if defined(ZCL_USING_BARRIER_CONTROL_CLUSTER_BARRIER_OPEN_EVENTS_ATTRIBUTE)
if (open && !command)
{
status = BarrierControl::Attributes::GetBarrierOpenEvents(endpoint, &events);
status = BarrierControl::Attributes::BarrierOpenEvents::Get(endpoint, &events);
}
#endif
#if defined(ZCL_USING_BARRIER_CONTROL_CLUSTER_BARRIER_CLOSE_EVENTS_ATTRIBUTE)
if (!open && !command)
{
status = BarrierControl::Attributes::GetBarrierCloseEvents(endpoint, &events);
status = BarrierControl::Attributes::BarrierCloseEvents::Get(endpoint, &events);
}
#endif
#if defined(ZCL_USING_BARRIER_CONTROL_CLUSTER_BARRIER_COMMAND_OPEN_EVENTS_ATTRIBUTE)
if (open && command)
{
status = BarrierControl::Attributes::GetBarrierCommandOpenEvents(endpoint, &events);
status = BarrierControl::Attributes::BarrierCommandOpenEvents::Get(endpoint, &events);
}
#endif
#if defined(ZCL_USING_BARRIER_CONTROL_CLUSTER_BARRIER_COMMAND_CLOSE_EVENTS_ATTRIBUTE)
if (!open && command)
{
status = BarrierControl::Attributes::GetBarrierCommandCloseEvents(endpoint, &events);
status = BarrierControl::Attributes::BarrierCommandCloseEvents::Get(endpoint, &events);
}
#endif
assert(status == EMBER_ZCL_STATUS_SUCCESS);
Expand All @@ -187,25 +187,25 @@ void emAfPluginBarrierControlServerIncrementEvents(EndpointId endpoint, bool ope
#if defined(ZCL_USING_BARRIER_CONTROL_CLUSTER_BARRIER_OPEN_EVENTS_ATTRIBUTE)
if (open && !command)
{
status = BarrierControl::Attributes::SetBarrierOpenEvents(endpoint, events);
status = BarrierControl::Attributes::BarrierOpenEvents::Set(endpoint, events);
}
#endif
#if defined(ZCL_USING_BARRIER_CONTROL_CLUSTER_BARRIER_CLOSE_EVENTS_ATTRIBUTE)
if (!open && !command)
{
status = BarrierControl::Attributes::SetBarrierCloseEvents(endpoint, events);
status = BarrierControl::Attributes::BarrierCloseEvents::Set(endpoint, events);
}
#endif
#if defined(ZCL_USING_BARRIER_CONTROL_CLUSTER_BARRIER_COMMAND_OPEN_EVENTS_ATTRIBUTE)
if (open && command)
{
status = BarrierControl::Attributes::SetBarrierCommandOpenEvents(endpoint, events);
status = BarrierControl::Attributes::BarrierCommandOpenEvents::Set(endpoint, events);
}
#endif
#if defined(ZCL_USING_BARRIER_CONTROL_CLUSTER_BARRIER_COMMAND_CLOSE_EVENTS_ATTRIBUTE)
if (!open && command)
{
status = BarrierControl::Attributes::SetBarrierCommandCloseEvents(endpoint, events);
status = BarrierControl::Attributes::BarrierCommandCloseEvents::Set(endpoint, events);
}
#endif
assert(status == EMBER_ZCL_STATUS_SUCCESS);
Expand Down
Loading

0 comments on commit b20a388

Please sign in to comment.