Skip to content

Commit

Permalink
Change how we namespace our attribute ids (#10110)
Browse files Browse the repository at this point in the history
* Update codegen templates to use per-cluster-attribute namespaces.

* Regenerate generated files

* Mass-replace Attributes::Ids::* with Attributes::*::Id.

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

  git sed -f g "Attributes::Ids::\([A-Za-z0-9]*\)" "Attributes::\1::Id"

* Mass-replace " Ids::*" with " *::Id" in cluster impls.

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

  git sed " Ids::\([A-Za-z0-9]*\)" " \1::Id" -- src/app/clusters
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Oct 13, 2021
1 parent 720ee66 commit 2048328
Show file tree
Hide file tree
Showing 31 changed files with 6,655 additions and 3,604 deletions.
2 changes: 1 addition & 1 deletion examples/lighting-app/efr32/src/ZclCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void emberAfPostAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId
{
if (clusterId == OnOff::Id)
{
if (attributeId != OnOff::Attributes::Ids::OnOff)
if (attributeId != OnOff::Attributes::OnOff::Id)
{
ChipLogError(Zcl, "ON OFF attribute ID: " ChipLogFormatMEI " Type: %" PRIu8 " Value: %" PRIu16 ", length %" PRIu16,
ChipLogValueMEI(attributeId), type, *value, size);
Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/k32w/main/ZclCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void emberAfPostAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId
return;
}

if (attributeId != OnOff::Attributes::Ids::OnOff)
if (attributeId != OnOff::Attributes::OnOff::Id)
{
ChipLogProgress(Zcl, "Unknown attribute ID: " ChipLogFormatMEI, ChipLogValueMEI(attributeId));
return;
Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void emberAfPostAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId
return;
}

if (attributeId != OnOff::Attributes::Ids::OnOff)
if (attributeId != OnOff::Attributes::OnOff::Id)
{
ChipLogProgress(Zcl, "Unknown attribute ID: " ChipLogFormatMEI, ChipLogValueMEI(attributeId));
return;
Expand Down
4 changes: 2 additions & 2 deletions examples/lighting-app/nrfconnect/main/ZclCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ using namespace chip::app::Clusters;
void emberAfPostAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId, uint8_t mask,
uint16_t manufacturerCode, uint8_t type, uint16_t size, uint8_t * value)
{
if (clusterId == OnOff::Id && attributeId == OnOff::Attributes::Ids::OnOff)
if (clusterId == OnOff::Id && attributeId == OnOff::Attributes::OnOff::Id)
{
ChipLogProgress(Zcl, "Cluster OnOff: attribute OnOff set to %" PRIu8, *value);
LightingMgr().InitiateAction(*value ? LightingManager::ON_ACTION : LightingManager::OFF_ACTION,
AppEvent::kEventType_Lighting, size, value);
}
else if (clusterId == LevelControl::Id && attributeId == LevelControl::Attributes::Ids::CurrentLevel)
else if (clusterId == LevelControl::Id && attributeId == LevelControl::Attributes::CurrentLevel::Id)
{
ChipLogProgress(Zcl, "Cluster LevelControl: attribute CurrentLevel set to %" PRIu8, *value);
LightingMgr().InitiateAction(LightingManager::LEVEL_ACTION, AppEvent::kEventType_Lighting, size, value);
Expand Down
4 changes: 2 additions & 2 deletions examples/lighting-app/telink/src/ZclCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void emberAfPostAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId

if (clusterId == OnOff::Id)
{
if (attributeId != OnOff::Attributes::Ids::OnOff)
if (attributeId != OnOff::Attributes::OnOff::Id)
{
ChipLogProgress(Zcl, "Unknown attribute ID: " ChipLogFormatMEI, ChipLogValueMEI(attributeId));
return;
Expand All @@ -48,7 +48,7 @@ void emberAfPostAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId
}
else if (clusterId == LevelControl::Id)
{
if (attributeId != LevelControl::Attributes::Ids::CurrentLevel)
if (attributeId != LevelControl::Attributes::CurrentLevel::Id)
{
ChipLogProgress(Zcl, "Unknown attribute ID: " ChipLogFormatMEI, ChipLogValueMEI(attributeId));
return;
Expand Down
2 changes: 1 addition & 1 deletion examples/lock-app/cc13x2x7_26x2x7/main/ZclCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void emberAfPostAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId
return;
}

if (attributeId != OnOff::Attributes::Ids::OnOff)
if (attributeId != OnOff::Attributes::OnOff::Id)
{
ChipLogProgress(Zcl, "Unknown attribute ID: " ChipLogFormatMEI, ChipLogValueMEI(attributeId));
return;
Expand Down
2 changes: 1 addition & 1 deletion examples/lock-app/efr32/src/ZclCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void emberAfPostAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId
return;
}

if (attributeId != OnOff::Attributes::Ids::OnOff)
if (attributeId != OnOff::Attributes::OnOff::Id)
{
EFR32_LOG("Unknown attribute ID: " ChipLogFormatMEI, ChipLogValueMEI(attributeId));
return;
Expand Down
2 changes: 1 addition & 1 deletion examples/lock-app/k32w/main/ZclCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void emberAfPostAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId
return;
}

if (attributeId != OnOff::Attributes::Ids::OnOff)
if (attributeId != OnOff::Attributes::OnOff::Id)
{
ChipLogProgress(Zcl, "Unknown attribute ID: " ChipLogFormatMEI, ChipLogValueMEI(attributeId));
return;
Expand Down
2 changes: 1 addition & 1 deletion examples/lock-app/nrfconnect/main/ZclCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ using namespace ::chip::app::Clusters;
void emberAfPostAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId, uint8_t mask,
uint16_t manufacturerCode, uint8_t type, uint16_t size, uint8_t * value)
{
if (clusterId == OnOff::Id && attributeId == OnOff::Attributes::Ids::OnOff)
if (clusterId == OnOff::Id && attributeId == OnOff::Attributes::OnOff::Id)
{
ChipLogProgress(Zcl, "Cluster OnOff: attribute OnOff set to %" PRIu8, *value);
BoltLockMgr().InitiateAction(0, *value ? BoltLockManager::LOCK_ACTION : BoltLockManager::UNLOCK_ACTION);
Expand Down
2 changes: 1 addition & 1 deletion examples/pump-app/cc13x2x7_26x2x7/main/ZclCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void emberAfPostAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId
return;
}

if (attributeId != OnOff::Attributes::Ids::OnOff)
if (attributeId != OnOff::Attributes::OnOff::Id)
{
ChipLogProgress(Zcl, "Unknown attribute ID: " ChipLogFormatMEI, ChipLogValueMEI(attributeId));
return;
Expand Down
2 changes: 1 addition & 1 deletion examples/pump-app/nrfconnect/main/ZclCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void emberAfPostAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId
return;
}

if (attributeId != OnOff::Attributes::Ids::OnOff)
if (attributeId != OnOff::Attributes::OnOff::Id)
{
ChipLogProgress(Zcl, "Unknown attribute ID: %" PRIx32, attributeId);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void emberAfPostAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId
return;
}

if (attributeId != OnOff::Attributes::Ids::OnOff)
if (attributeId != OnOff::Attributes::OnOff::Id)
{
ChipLogProgress(Zcl, "Unknown attribute ID: " ChipLogFormatMEI, ChipLogValueMEI(attributeId));
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void emberAfPostAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId
return;
}

if (attributeId != OnOff::Attributes::Ids::OnOff)
if (attributeId != OnOff::Attributes::OnOff::Id)
{
ChipLogProgress(Zcl, "Unknown attribute ID: %" PRIx32, attributeId);
return;
Expand Down
6 changes: 3 additions & 3 deletions src/app/clusters/descriptor/descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ EmberAfStatus writeAttribute(EndpointId endpoint, AttributeId attributeId, uint8
EmberAfStatus writeClientServerAttribute(EndpointId endpoint, bool server)
{
EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
AttributeId attributeId = server ? Descriptor::Attributes::Ids::ServerList : Descriptor::Attributes::Ids::ClientList;
AttributeId attributeId = server ? Descriptor::Attributes::ServerList::Id : Descriptor::Attributes::ClientList::Id;

uint16_t clusterCount = emberAfClusterCount(endpoint, server);

Expand Down Expand Up @@ -85,7 +85,7 @@ EmberAfStatus writeClientAttribute(EndpointId endpoint)
EmberAfStatus writeDeviceAttribute(EndpointId endpoint, uint16_t index)
{
EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
AttributeId attributeId = Descriptor::Attributes::Ids::DeviceList;
AttributeId attributeId = Descriptor::Attributes::DeviceList::Id;

uint16_t deviceTypeCount = 1;
DeviceTypeId deviceTypeId = emberAfDeviceIdFromIndex(index);
Expand All @@ -104,7 +104,7 @@ EmberAfStatus writeDeviceAttribute(EndpointId endpoint, uint16_t index)
EmberAfStatus writePartsAttribute(EndpointId endpoint)
{
EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
AttributeId attributeId = Descriptor::Attributes::Ids::PartsList;
AttributeId attributeId = Descriptor::Attributes::PartsList::Id;

uint16_t partsCount = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,19 @@ CHIP_ERROR EthernetDiagosticsAttrAccess::Read(ClusterInfo & aClusterInfo, const
*aDataRead = true;
switch (aClusterInfo.mFieldId)
{
case Ids::PacketRxCount: {
case PacketRxCount::Id: {
return ReadIfSupported(&ConnectivityManager::GetEthPacketRxCount, aEncoder);
}
case Ids::PacketTxCount: {
case PacketTxCount::Id: {
return ReadIfSupported(&ConnectivityManager::GetEthPacketTxCount, aEncoder);
}
case Ids::TxErrCount: {
case TxErrCount::Id: {
return ReadIfSupported(&ConnectivityManager::GetEthTxErrCount, aEncoder);
}
case Ids::CollisionCount: {
case CollisionCount::Id: {
return ReadIfSupported(&ConnectivityManager::GetEthCollisionCount, aEncoder);
}
case Ids::OverrunCount: {
case OverrunCount::Id: {
return ReadIfSupported(&ConnectivityManager::GetEthOverrunCount, aEncoder);
}
default: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,16 @@ CHIP_ERROR GeneralDiagosticsAttrAccess::Read(ClusterInfo & aClusterInfo, const A
*aDataRead = true;
switch (aClusterInfo.mFieldId)
{
case Ids::RebootCount: {
case RebootCount::Id: {
return ReadIfSupported(&PlatformManager::GetRebootCount, aEncoder);
}
case Ids::UpTime: {
case UpTime::Id: {
return ReadIfSupported(&PlatformManager::GetUpTime, aEncoder);
}
case Ids::TotalOperationalHours: {
case TotalOperationalHours::Id: {
return ReadIfSupported(&PlatformManager::GetTotalOperationalHours, aEncoder);
}
case Ids::BootReasons: {
case BootReasons::Id: {
return ReadIfSupported(&PlatformManager::GetBootReasons, aEncoder);
}
default: {
Expand Down
2 changes: 1 addition & 1 deletion src/app/clusters/identify-server/identify-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ static inline void identify_deactivate(Identify * identify)

void emberAfIdentifyClusterServerAttributeChangedCallback(EndpointId endpoint, AttributeId attributeId)
{
if (attributeId == Clusters::Identify::Attributes::Ids::IdentifyTime)
if (attributeId == Clusters::Identify::Attributes::IdentifyTime::Id)
{
Identify * identify = inst(endpoint);
uint16_t identifyTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ CHIP_ERROR SoftwareDiagosticsAttrAccess::Read(ClusterInfo & aClusterInfo, const
*aDataRead = true;
switch (aClusterInfo.mFieldId)
{
case Ids::CurrentHeapFree: {
case CurrentHeapFree::Id: {
return ReadIfSupported(&PlatformManager::GetCurrentHeapFree, aEncoder);
}
case Ids::CurrentHeapUsed: {
case CurrentHeapUsed::Id: {
return ReadIfSupported(&PlatformManager::GetCurrentHeapUsed, aEncoder);
}
case Ids::CurrentHeapHighWatermark: {
case CurrentHeapHighWatermark::Id: {
return ReadIfSupported(&PlatformManager::GetCurrentHeapHighWatermark, aEncoder);
}
default: {
Expand Down
16 changes: 8 additions & 8 deletions src/app/clusters/thermostat-server/thermostat-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ EmberAfStatus emberAfThermostatClusterServerPreAttributeChangedCallback(chip::En

switch (attributeId)
{
case Ids::OccupiedHeatingSetpoint: {
case OccupiedHeatingSetpoint::Id: {
int16_t AbsMinHeatSetpointLimit;
int16_t AbsMaxHeatSetpointLimit;
int16_t MinHeatSetpointLimit;
Expand Down Expand Up @@ -112,7 +112,7 @@ EmberAfStatus emberAfThermostatClusterServerPreAttributeChangedCallback(chip::En
break;
}

case Ids::OccupiedCoolingSetpoint: {
case OccupiedCoolingSetpoint::Id: {
int16_t AbsMinCoolSetpointLimit;
int16_t AbsMaxCoolSetpointLimit;
int16_t MinCoolSetpointLimit;
Expand Down Expand Up @@ -151,8 +151,8 @@ EmberAfStatus emberAfThermostatClusterServerPreAttributeChangedCallback(chip::En
break;
}

case Ids::MinHeatSetpointLimit:
case Ids::MaxHeatSetpointLimit: {
case MinHeatSetpointLimit::Id:
case MaxHeatSetpointLimit::Id: {
int16_t AbsMinHeatSetpointLimit;
int16_t AbsMaxHeatSetpointLimit;

Expand All @@ -176,8 +176,8 @@ EmberAfStatus emberAfThermostatClusterServerPreAttributeChangedCallback(chip::En

break;
}
case Ids::MinCoolSetpointLimit:
case Ids::MaxCoolSetpointLimit: {
case MinCoolSetpointLimit::Id:
case MaxCoolSetpointLimit::Id: {
int16_t AbsMinCoolSetpointLimit;
int16_t AbsMaxCoolSetpointLimit;

Expand All @@ -202,7 +202,7 @@ EmberAfStatus emberAfThermostatClusterServerPreAttributeChangedCallback(chip::En
break;
}

case Ids::ControlSequenceOfOperation: {
case ControlSequenceOfOperation::Id: {
uint8_t requestedCSO;
requestedCSO = *value;
if (requestedCSO > EMBER_ZCL_THERMOSTAT_CONTROL_SEQUENCE_COOLING_AND_HEATING_WITH_REHEAT)
Expand All @@ -213,7 +213,7 @@ EmberAfStatus emberAfThermostatClusterServerPreAttributeChangedCallback(chip::En
break;
}

case Ids::SystemMode: {
case SystemMode::Id: {
uint8_t ControlSequenceOfOperation = kInvalidControlSequenceOfOperation;
uint8_t RequestedSystemMode = kInvalidRequestedSystemMode;
GetControlSequenceOfOperation(endpoint, &ControlSequenceOfOperation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,40 +78,40 @@ CHIP_ERROR WiFiDiagosticsAttrAccess::Read(ClusterInfo & aClusterInfo, const Attr
*aDataRead = true;
switch (aClusterInfo.mFieldId)
{
case Ids::SecurityType: {
case SecurityType::Id: {
return ReadIfSupported(&ConnectivityManager::GetWiFiSecurityType, aEncoder);
}
case Ids::WiFiVersion: {
case WiFiVersion::Id: {
return ReadIfSupported(&ConnectivityManager::GetWiFiVersion, aEncoder);
}
case Ids::ChannelNumber: {
case ChannelNumber::Id: {
return ReadIfSupported(&ConnectivityManager::GetWiFiChannelNumber, aEncoder);
}
case Ids::Rssi: {
case Rssi::Id: {
return ReadIfSupported(&ConnectivityManager::GetWiFiRssi, aEncoder);
}
case Ids::BeaconLostCount: {
case BeaconLostCount::Id: {
return ReadIfSupported(&ConnectivityManager::GetWiFiBeaconLostCount, aEncoder);
}
case Ids::BeaconRxCount: {
case BeaconRxCount::Id: {
return ReadIfSupported(&ConnectivityManager::GetWiFiBeaconRxCount, aEncoder);
}
case Ids::PacketMulticastRxCount: {
case PacketMulticastRxCount::Id: {
return ReadIfSupported(&ConnectivityManager::GetWiFiPacketMulticastRxCount, aEncoder);
}
case Ids::PacketMulticastTxCount: {
case PacketMulticastTxCount::Id: {
return ReadIfSupported(&ConnectivityManager::GetWiFiPacketMulticastTxCount, aEncoder);
}
case Ids::PacketUnicastRxCount: {
case PacketUnicastRxCount::Id: {
return ReadIfSupported(&ConnectivityManager::GetWiFiPacketUnicastRxCount, aEncoder);
}
case Ids::PacketUnicastTxCount: {
case PacketUnicastTxCount::Id: {
return ReadIfSupported(&ConnectivityManager::GetWiFiPacketUnicastTxCount, aEncoder);
}
case Ids::CurrentMaxRate: {
case CurrentMaxRate::Id: {
return ReadIfSupported(&ConnectivityManager::GetWiFiCurrentMaxRate, aEncoder);
}
case Ids::OverrunCount: {
case OverrunCount::Id: {
return ReadIfSupported(&ConnectivityManager::GetWiFiOverrunCount, aEncoder);
}
default: {
Expand Down
4 changes: 2 additions & 2 deletions src/app/zap-templates/templates/app/CHIPClusters-src.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,14 @@ CHIP_ERROR {{asUpperCamelCase parent.name}}Cluster::SubscribeAttribute{{asUpperC
chip::app::AttributePathParams attributePath;
attributePath.mEndpointId = mEndpoint;
attributePath.mClusterId = mClusterId;
attributePath.mFieldId = {{#if isGlobalAttribute}}Globals{{else}}{{asUpperCamelCase parent.name}}{{/if}}::Attributes::Ids::{{asUpperCamelCase name}};
attributePath.mFieldId = {{#if isGlobalAttribute}}Globals{{else}}{{asUpperCamelCase parent.name}}{{/if}}::Attributes::{{asUpperCamelCase name}}::Id;
attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid);
return mDevice->SendSubscribeAttributeRequest(attributePath, minInterval, maxInterval, onSuccessCallback, onFailureCallback);
}

CHIP_ERROR {{asUpperCamelCase parent.name}}Cluster::ReportAttribute{{asUpperCamelCase name}}(Callback::Cancelable * onReportCallback)
{
return RequestAttributeReporting({{#if isGlobalAttribute}}Globals{{else}}{{asUpperCamelCase parent.name}}{{/if}}::Attributes::Ids::{{asUpperCamelCase name}}, onReportCallback, BasicAttributeFilter<{{chipCallback.name}}AttributeCallback>);
return RequestAttributeReporting({{#if isGlobalAttribute}}Globals{{else}}{{asUpperCamelCase parent.name}}{{/if}}::Attributes::{{asUpperCamelCase name}}::Id, onReportCallback, BasicAttributeFilter<{{chipCallback.name}}AttributeCallback>);
}

{{/if}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ namespace Attributes {
{{#if (canHaveSimpleAccessors type)}}
EmberAfStatus Get{{asUpperCamelCase label}}(chip::EndpointId endpoint, {{asUnderlyingZclType type}} * {{asLowerCamelCase label}})
{
return emberAfReadServerAttribute(endpoint, {{asUpperCamelCase parent.label}}::Id, Ids::{{asUpperCamelCase label}}, (uint8_t *) {{asLowerCamelCase label}}, sizeof(*{{asLowerCamelCase label}}));
return emberAfReadServerAttribute(endpoint, {{asUpperCamelCase parent.label}}::Id, {{asUpperCamelCase label}}::Id, (uint8_t *) {{asLowerCamelCase label}}, sizeof(*{{asLowerCamelCase label}}));

}
EmberAfStatus Set{{asUpperCamelCase label}}(chip::EndpointId endpoint, {{asUnderlyingZclType type}} {{asLowerCamelCase label}})
{
return emberAfWriteServerAttribute(endpoint, {{asUpperCamelCase parent.label}}::Id, Ids::{{asUpperCamelCase label}}, (uint8_t *) &{{asLowerCamelCase label}}, ZCL_{{asDelimitedMacro type}}_ATTRIBUTE_TYPE);
return emberAfWriteServerAttribute(endpoint, {{asUpperCamelCase parent.label}}::Id, {{asUpperCamelCase label}}::Id, (uint8_t *) &{{asLowerCamelCase label}}, ZCL_{{asDelimitedMacro type}}_ATTRIBUTE_TYPE);
}
{{/if}}
{{/if}}
Expand Down
Loading

0 comments on commit 2048328

Please sign in to comment.