Skip to content

Commit

Permalink
Align General Commissioning cluster XML to spec changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
bzbarsky-apple committed May 22, 2023
1 parent e217219 commit d3827bd
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ bool emberAfGeneralCommissioningClusterSetRegulatoryConfigCallback(app::CommandH
DeviceControlServer * server = &DeviceLayer::DeviceControlServer::DeviceControlSvr();
Commands::SetRegulatoryConfigResponse::Type response;

if (commandData.newRegulatoryConfig > RegulatoryLocationType::kIndoorOutdoor)
if (commandData.newRegulatoryConfig > RegulatoryLocationTypeEnum::kIndoorOutdoor)
{
response.errorCode = CommissioningError::kValueOutsideRange;
response.debugText = commandData.countryCode;
Expand All @@ -301,7 +301,7 @@ bool emberAfGeneralCommissioningClusterSetRegulatoryConfigCallback(app::CommandH

// If the LocationCapability attribute is not Indoor/Outdoor and the NewRegulatoryConfig value received does not match
// either the Indoor or Outdoor fixed value in LocationCapability.
if ((locationCapability != to_underlying(RegulatoryLocationType::kIndoorOutdoor)) && (location != locationCapability))
if ((locationCapability != to_underlying(RegulatoryLocationTypeEnum::kIndoorOutdoor)) && (location != locationCapability))
{
response.errorCode = CommissioningError::kValueOutsideRange;
response.debugText = commandData.countryCode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ limitations under the License.
-->
<configurator>
<domain name="CHIP"/>
<enum name="CommissioningError" type="ENUM8">
<enum name="CommissioningErrorEnum" type="ENUM8">
<cluster code="0x0030"/>
<item name="OK" value="0x0"/>
<item name="ValueOutsideRange" value="0x1"/>
<item name="InvalidAuthentication" value="0x2"/>
<item name="NoFailSafe" value="0x3"/>
<item name="BusyWithOtherAdmin" value="0x4"/>
</enum>
<enum name="RegulatoryLocationType" type="ENUM8">
<enum name="RegulatoryLocationTypeEnum" type="ENUM8">
<cluster code="0x0030"/>
<item name="Indoor" value="0x0"/>
<item name="Outdoor" value="0x1"/>
Expand All @@ -47,8 +47,8 @@ limitations under the License.
<access op="write" privilege="administer"/>
</attribute>
<attribute side="server" code="0x01" define="BASIC_COMMISSIONING_INFO" type="BasicCommissioningInfo" writable="false" optional="false">BasicCommissioningInfo</attribute>
<attribute side="server" code="0x02" define="REGULATORY_CONFIG" type="RegulatoryLocationType" writable="false" optional="false">RegulatoryConfig</attribute>
<attribute side="server" code="0x03" define="LOCATION_CAPABILITY" type="RegulatoryLocationType" writable="false" optional="false">LocationCapability</attribute>
<attribute side="server" code="0x02" define="REGULATORY_CONFIG" type="RegulatoryLocationTypeEnum" writable="false" optional="false">RegulatoryConfig</attribute>
<attribute side="server" code="0x03" define="LOCATION_CAPABILITY" type="RegulatoryLocationTypeEnum" writable="false" optional="false">LocationCapability</attribute>
<attribute side="server" code="0x04" define="SUPPORTS_CONCURRENT_CONNECTION" type="boolean" writable="false" default="1" optional="false">SupportsConcurrentConnection</attribute>

<command source="client" code="0x00" name="ArmFailSafe" response="ArmFailSafeResponse" optional="false" cli="chip fabric_commissioning armfailsafe">
Expand All @@ -59,19 +59,19 @@ limitations under the License.
</command>
<command source="server" code="0x01" name="ArmFailSafeResponse" optional="false" cli="chip fabric_commissioning armfailsaferesponse">
<description>Success/failure response for ArmFailSafe command</description>
<arg name="ErrorCode" type="CommissioningError"/>
<arg name="ErrorCode" type="CommissioningErrorEnum"/>
<arg name="DebugText" type="CHAR_STRING"/>
</command>
<command source="client" code="0x02" name="SetRegulatoryConfig" response="SetRegulatoryConfigResponse" cli="chip fabric_commissioning setregulatoryconfig">
<description>Set the regulatory configuration to be used during commissioning</description>
<arg name="NewRegulatoryConfig" type="RegulatoryLocationType"/>
<arg name="NewRegulatoryConfig" type="RegulatoryLocationTypeEnum"/>
<arg name="CountryCode" type="CHAR_STRING"/>
<arg name="Breadcrumb" type="INT64U"/>
<access op="invoke" privilege="administer"/>
</command>
<command source="server" code="0x03" name="SetRegulatoryConfigResponse" cli="chip fabric_commissioning setregulatoryconfigresponse">
<description>Success/failure response for SetRegulatoryConfig command</description>
<arg name="ErrorCode" type="CommissioningError"/>
<arg name="ErrorCode" type="CommissioningErrorEnum"/>
<arg name="DebugText" type="CHAR_STRING"/>
</command>
<command source="client" code="0x04" name="CommissioningComplete" response="CommissioningCompleteResponse" isFabricScoped="true" optional="false" cli="chip fabric_commissioning commissioningcomplete">
Expand All @@ -80,7 +80,7 @@ limitations under the License.
</command>
<command source="server" code="0x05" name="CommissioningCompleteResponse" optional="false" cli="chip fabric_commissioning commissioningcompleteresponse">
<description>Indicates to client whether CommissioningComplete command succeeded</description>
<arg name="ErrorCode" type="CommissioningError"/>
<arg name="ErrorCode" type="CommissioningErrorEnum"/>
<arg name="DebugText" type="CHAR_STRING"/>
</command>
</cluster>
Expand Down
8 changes: 4 additions & 4 deletions src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2309,10 +2309,10 @@ void DeviceCommissioner::PerformCommissioningStep(DeviceProxy * proxy, Commissio
// TODO(cecille): Where is the country config actually set?
ChipLogProgress(Controller, "Setting Regulatory Config");
auto capability =
params.GetLocationCapability().ValueOr(app::Clusters::GeneralCommissioning::RegulatoryLocationType::kOutdoor);
app::Clusters::GeneralCommissioning::RegulatoryLocationType regulatoryConfig;
params.GetLocationCapability().ValueOr(app::Clusters::GeneralCommissioning::RegulatoryLocationTypeEnum::kOutdoor);
app::Clusters::GeneralCommissioning::RegulatoryLocationTypeEnum regulatoryConfig;
// Value is only switchable on the devices with indoor/outdoor capability
if (capability == app::Clusters::GeneralCommissioning::RegulatoryLocationType::kIndoorOutdoor)
if (capability == app::Clusters::GeneralCommissioning::RegulatoryLocationTypeEnum::kIndoorOutdoor)
{
// If the device supports indoor and outdoor configs, use the setting from the commissioner, otherwise fall back to
// the current device setting then to outdoor (most restrictive)
Expand All @@ -2330,7 +2330,7 @@ void DeviceCommissioner::PerformCommissioningStep(DeviceProxy * proxy, Commissio
}
else
{
regulatoryConfig = app::Clusters::GeneralCommissioning::RegulatoryLocationType::kOutdoor;
regulatoryConfig = app::Clusters::GeneralCommissioning::RegulatoryLocationTypeEnum::kOutdoor;
ChipLogProgress(Controller, "No overrride or device regulatory config supplied, setting to outdoor");
}
}
Expand Down
26 changes: 13 additions & 13 deletions src/controller/CommissioningDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class CommissioningParameters
// (from GetLocationCapability - see below). If the regulatory location is not supplied, this will fall back to the location in
// GetDefaultRegulatoryLocation and then to Outdoor (most restrictive).
// This value should be set before calling PerformCommissioningStep for the kConfigRegulatory step.
const Optional<app::Clusters::GeneralCommissioning::RegulatoryLocationType> GetDeviceRegulatoryLocation() const
const Optional<app::Clusters::GeneralCommissioning::RegulatoryLocationTypeEnum> GetDeviceRegulatoryLocation() const
{
return mDeviceRegulatoryLocation;
}
Expand Down Expand Up @@ -228,15 +228,15 @@ class CommissioningParameters
// Default regulatory location set by the node, as read from the GeneralCommissioning cluster. In the AutoCommissioner, this is
// automatically set from report from the kReadCommissioningInfo stage.
// This should be set before calling PerformCommissioningStep for the kConfigRegulatory step.
const Optional<app::Clusters::GeneralCommissioning::RegulatoryLocationType> GetDefaultRegulatoryLocation() const
const Optional<app::Clusters::GeneralCommissioning::RegulatoryLocationTypeEnum> GetDefaultRegulatoryLocation() const
{
return mDefaultRegulatoryLocation;
}

// Location capabilities of the node, as read from the GeneralCommissioning cluster. In the AutoCommissioner, this is
// automatically set from report from the kReadCommissioningInfo stage.
// This should be set before calling PerformCommissioningStep for the kConfigRegulatory step.
const Optional<app::Clusters::GeneralCommissioning::RegulatoryLocationType> GetLocationCapability() const
const Optional<app::Clusters::GeneralCommissioning::RegulatoryLocationTypeEnum> GetLocationCapability() const
{
return mLocationCapability;
}
Expand All @@ -257,7 +257,7 @@ class CommissioningParameters
return *this;
}

CommissioningParameters & SetDeviceRegulatoryLocation(app::Clusters::GeneralCommissioning::RegulatoryLocationType location)
CommissioningParameters & SetDeviceRegulatoryLocation(app::Clusters::GeneralCommissioning::RegulatoryLocationTypeEnum location)
{
mDeviceRegulatoryLocation.SetValue(location);
return *this;
Expand Down Expand Up @@ -368,12 +368,12 @@ class CommissioningParameters
mRemoteProductId = MakeOptional(id);
return *this;
}
CommissioningParameters & SetDefaultRegulatoryLocation(app::Clusters::GeneralCommissioning::RegulatoryLocationType location)
CommissioningParameters & SetDefaultRegulatoryLocation(app::Clusters::GeneralCommissioning::RegulatoryLocationTypeEnum location)
{
mDefaultRegulatoryLocation = MakeOptional(location);
return *this;
}
CommissioningParameters & SetLocationCapability(app::Clusters::GeneralCommissioning::RegulatoryLocationType capability)
CommissioningParameters & SetLocationCapability(app::Clusters::GeneralCommissioning::RegulatoryLocationTypeEnum capability)
{
mLocationCapability = MakeOptional(capability);
return *this;
Expand Down Expand Up @@ -451,7 +451,7 @@ class CommissioningParameters
// Items that can be set by the commissioner
Optional<uint16_t> mFailsafeTimerSeconds;
Optional<uint16_t> mCASEFailsafeTimerSeconds;
Optional<app::Clusters::GeneralCommissioning::RegulatoryLocationType> mDeviceRegulatoryLocation;
Optional<app::Clusters::GeneralCommissioning::RegulatoryLocationTypeEnum> mDeviceRegulatoryLocation;
Optional<ByteSpan> mCSRNonce;
Optional<ByteSpan> mAttestationNonce;
Optional<WiFiCredentials> mWiFiCreds;
Expand All @@ -471,8 +471,8 @@ class CommissioningParameters
Optional<NodeId> mRemoteNodeId;
Optional<VendorId> mRemoteVendorId;
Optional<uint16_t> mRemoteProductId;
Optional<app::Clusters::GeneralCommissioning::RegulatoryLocationType> mDefaultRegulatoryLocation;
Optional<app::Clusters::GeneralCommissioning::RegulatoryLocationType> mLocationCapability;
Optional<app::Clusters::GeneralCommissioning::RegulatoryLocationTypeEnum> mDefaultRegulatoryLocation;
Optional<app::Clusters::GeneralCommissioning::RegulatoryLocationTypeEnum> mLocationCapability;
CompletionStatus completionStatus;
Credentials::DeviceAttestationDelegate * mDeviceAttestationDelegate =
nullptr; // Delegate to handle device attestation failures during commissioning
Expand Down Expand Up @@ -542,10 +542,10 @@ struct GeneralCommissioningInfo
{
uint64_t breadcrumb = 0;
uint16_t recommendedFailsafe = 0;
app::Clusters::GeneralCommissioning::RegulatoryLocationType currentRegulatoryLocation =
app::Clusters::GeneralCommissioning::RegulatoryLocationType::kIndoorOutdoor;
app::Clusters::GeneralCommissioning::RegulatoryLocationType locationCapability =
app::Clusters::GeneralCommissioning::RegulatoryLocationType::kIndoorOutdoor;
app::Clusters::GeneralCommissioning::RegulatoryLocationTypeEnum currentRegulatoryLocation =
app::Clusters::GeneralCommissioning::RegulatoryLocationTypeEnum::kIndoorOutdoor;
app::Clusters::GeneralCommissioning::RegulatoryLocationTypeEnum locationCapability =
app::Clusters::GeneralCommissioning::RegulatoryLocationTypeEnum::kIndoorOutdoor;
;
};

Expand Down
42 changes: 35 additions & 7 deletions src/darwin/Framework/CHIP/templates/availability.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3098,8 +3098,16 @@
- WiredCurrentTypeEnum
- WiredFaultEnum
GeneralCommissioning:
- CommissioningError
- RegulatoryLocationType
# CommissioningErrorEnum was originally just named
# CommissioningError, but we generate the same API
# for both of those names, so the name can just change
# here.
- CommissioningErrorEnum
# RegulatoryLocationTypeEnum was originally just named
# RegulatoryLocationType, but we generate the same API
# for both of those names, so the name can just change
# here.
- RegulatoryLocationTypeEnum
NetworkCommissioning:
- NetworkCommissioningStatus
- WiFiBand
Expand Down Expand Up @@ -3414,13 +3422,21 @@
- OverVoltage
- UnderVoltage
GeneralCommissioning:
CommissioningError:
# CommissioningErrorEnum was originally just named
# CommissioningError, but we generate the same API
# for both of those names, so the name can just change
# here.
CommissioningErrorEnum:
- Ok
- ValueOutsideRange
- InvalidAuthentication
- NoFailSafe
- BusyWithOtherAdmin
RegulatoryLocationType:
# RegulatoryLocationTypeEnum was originally just named
# RegulatoryLocationType, but we generate the same API
# for both of those names, so the name can just change
# here.
RegulatoryLocationTypeEnum:
- Indoor
- Outdoor
- IndoorOutdoor
Expand Down Expand Up @@ -5646,7 +5662,11 @@
- ValueB
- ValueC
GeneralCommissioning:
CommissioningError:
# CommissioningErrorEnum was originally just named
# CommissioningError, but we generate the same API
# for both of those names, so the name can just change
# here.
CommissioningErrorEnum:
- OK
AccessControl:
AccessControlEntryPrivilegeEnum:
Expand Down Expand Up @@ -6211,7 +6231,11 @@
- DoorLockProgrammingEventCode
enum values:
GeneralCommissioning:
CommissioningError:
# CommissioningErrorEnum was originally just named
# CommissioningError, but we generate the same API
# for both of those names, so the name can just change
# here.
CommissioningErrorEnum:
- Ok
PowerSource:
BatChargeLevelEnum:
Expand Down Expand Up @@ -6569,7 +6593,11 @@
UserTypeEnum: DlUserType
enum values:
GeneralCommissioning:
CommissioningError:
# CommissioningErrorEnum was originally just named
# CommissioningError, but we generate the same API
# for both of those names, so the name can just change
# here.
CommissioningErrorEnum:
OK: Ok
PowerSource:
BatChargeLevelEnum:
Expand Down
2 changes: 1 addition & 1 deletion src/include/platform/ConfigurationManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void SetConfigurationMgr(ConfigurationManager * configurationManager);

inline CHIP_ERROR ConfigurationManager::GetLocationCapability(uint8_t & location)
{
location = to_underlying(chip::app::Clusters::GeneralCommissioning::RegulatoryLocationType::kIndoor);
location = to_underlying(chip::app::Clusters::GeneralCommissioning::RegulatoryLocationTypeEnum::kIndoor);
return CHIP_NO_ERROR;
}

Expand Down
4 changes: 2 additions & 2 deletions src/platform/Darwin/ConfigurationManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,13 @@ CHIP_ERROR ConfigurationManagerImpl::Init()

if (!PosixConfig::ConfigValueExists(PosixConfig::kConfigKey_RegulatoryLocation))
{
uint32_t location = to_underlying(chip::app::Clusters::GeneralCommissioning::RegulatoryLocationType::kIndoor);
uint32_t location = to_underlying(chip::app::Clusters::GeneralCommissioning::RegulatoryLocationTypeEnum::kIndoor);
ReturnErrorOnFailure(WriteConfigValue(PosixConfig::kConfigKey_RegulatoryLocation, location));
}

if (!PosixConfig::ConfigValueExists(PosixConfig::kConfigKey_LocationCapability))
{
uint32_t location = to_underlying(chip::app::Clusters::GeneralCommissioning::RegulatoryLocationType::kIndoor);
uint32_t location = to_underlying(chip::app::Clusters::GeneralCommissioning::RegulatoryLocationTypeEnum::kIndoor);
ReturnErrorOnFailure(WriteConfigValue(PosixConfig::kConfigKey_LocationCapability, location));
}

Expand Down
2 changes: 1 addition & 1 deletion src/platform/ESP32/ConfigurationManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ CHIP_ERROR ConfigurationManagerImpl::GetLocationCapability(uint8_t & location)

return err;
#else
location = static_cast<uint8_t>(chip::app::Clusters::GeneralCommissioning::RegulatoryLocationType::kIndoor);
location = static_cast<uint8_t>(chip::app::Clusters::GeneralCommissioning::RegulatoryLocationTypeEnum::kIndoor);
return CHIP_NO_ERROR;
#endif
}
Expand Down
4 changes: 2 additions & 2 deletions src/platform/Linux/ConfigurationManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ CHIP_ERROR ConfigurationManagerImpl::Init()

if (!PosixConfig::ConfigValueExists(PosixConfig::kConfigKey_RegulatoryLocation))
{
uint32_t location = to_underlying(chip::app::Clusters::GeneralCommissioning::RegulatoryLocationType::kIndoor);
uint32_t location = to_underlying(chip::app::Clusters::GeneralCommissioning::RegulatoryLocationTypeEnum::kIndoor);
err = WriteConfigValue(PosixConfig::kConfigKey_RegulatoryLocation, location);
SuccessOrExit(err);
}

if (!PosixConfig::ConfigValueExists(PosixConfig::kConfigKey_LocationCapability))
{
uint32_t location = to_underlying(chip::app::Clusters::GeneralCommissioning::RegulatoryLocationType::kIndoorOutdoor);
uint32_t location = to_underlying(chip::app::Clusters::GeneralCommissioning::RegulatoryLocationTypeEnum::kIndoorOutdoor);
err = WriteConfigValue(PosixConfig::kConfigKey_LocationCapability, location);
SuccessOrExit(err);
}
Expand Down
4 changes: 2 additions & 2 deletions src/platform/webos/ConfigurationManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ CHIP_ERROR ConfigurationManagerImpl::Init()

if (!PosixConfig::ConfigValueExists(PosixConfig::kConfigKey_RegulatoryLocation))
{
uint32_t location = to_underlying(chip::app::Clusters::GeneralCommissioning::RegulatoryLocationType::kIndoor);
uint32_t location = to_underlying(chip::app::Clusters::GeneralCommissioning::RegulatoryLocationTypeEnum::kIndoor);
err = WriteConfigValue(PosixConfig::kConfigKey_RegulatoryLocation, location);
SuccessOrExit(err);
}

if (!PosixConfig::ConfigValueExists(PosixConfig::kConfigKey_LocationCapability))
{
uint32_t location = to_underlying(chip::app::Clusters::GeneralCommissioning::RegulatoryLocationType::kIndoor);
uint32_t location = to_underlying(chip::app::Clusters::GeneralCommissioning::RegulatoryLocationTypeEnum::kIndoor);
err = WriteConfigValue(PosixConfig::kConfigKey_LocationCapability, location);
SuccessOrExit(err);
}
Expand Down

0 comments on commit d3827bd

Please sign in to comment.