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 23, 2023
1 parent 853691d commit 07763c8
Show file tree
Hide file tree
Showing 17 changed files with 113 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ bool emberAfGeneralCommissioningClusterArmFailSafeCallback(app::CommandHandler *
Server::GetInstance().GetCommissioningWindowManager().IsCommissioningWindowOpen() &&
commandObj->GetSubjectDescriptor().authMode == Access::AuthMode::kCase)
{
response.errorCode = CommissioningError::kBusyWithOtherAdmin;
response.errorCode = CommissioningErrorEnum::kBusyWithOtherAdmin;
commandObj->AddResponse(commandPath, response);
}
else if (commandData.expiryLengthSeconds == 0)
Expand All @@ -190,7 +190,7 @@ bool emberAfGeneralCommissioningClusterArmFailSafeCallback(app::CommandHandler *
failSafeContext.ForceFailSafeTimerExpiry();
// Don't set the breadcrumb, since expiring the failsafe should
// reset it anyway.
response.errorCode = CommissioningError::kOk;
response.errorCode = CommissioningErrorEnum::kOk;
commandObj->AddResponse(commandPath, response);
}
else
Expand All @@ -199,13 +199,13 @@ bool emberAfGeneralCommissioningClusterArmFailSafeCallback(app::CommandHandler *
failSafeContext.ArmFailSafe(accessingFabricIndex, System::Clock::Seconds16(commandData.expiryLengthSeconds)),
Failure);
Breadcrumb::Set(commandPath.mEndpointId, commandData.breadcrumb);
response.errorCode = CommissioningError::kOk;
response.errorCode = CommissioningErrorEnum::kOk;
commandObj->AddResponse(commandPath, response);
}
}
else
{
response.errorCode = CommissioningError::kBusyWithOtherAdmin;
response.errorCode = CommissioningErrorEnum::kBusyWithOtherAdmin;
commandObj->AddResponse(commandPath, response);
}

Expand All @@ -227,7 +227,7 @@ bool emberAfGeneralCommissioningClusterCommissioningCompleteCallback(
Commands::CommissioningCompleteResponse::Type response;
if (!failSafe.IsFailSafeArmed())
{
response.errorCode = CommissioningError::kNoFailSafe;
response.errorCode = CommissioningErrorEnum::kNoFailSafe;
}
else
{
Expand All @@ -238,7 +238,7 @@ bool emberAfGeneralCommissioningClusterCommissioningCompleteCallback(
handle->AsSecureSession()->GetSecureSessionType() != SecureSession::Type::kCASE ||
!failSafe.MatchesFabricIndex(commandObj->GetAccessingFabricIndex()))
{
response.errorCode = CommissioningError::kInvalidAuthentication;
response.errorCode = CommissioningErrorEnum::kInvalidAuthentication;
ChipLogError(FailSafe, "GeneralCommissioning: Got commissioning complete in invalid security context");
}
else
Expand Down Expand Up @@ -270,7 +270,7 @@ bool emberAfGeneralCommissioningClusterCommissioningCompleteCallback(
Failure);

Breadcrumb::Set(commandPath.mEndpointId, 0);
response.errorCode = CommissioningError::kOk;
response.errorCode = CommissioningErrorEnum::kOk;
}
}

Expand All @@ -287,9 +287,9 @@ 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.errorCode = CommissioningErrorEnum::kValueOutsideRange;
response.debugText = commandData.countryCode;
}
else
Expand All @@ -301,16 +301,16 @@ 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.errorCode = CommissioningErrorEnum::kValueOutsideRange;
response.debugText = commandData.countryCode;
}
else
{
CheckSuccess(server->SetRegulatoryConfig(location, commandData.countryCode), Failure);
Breadcrumb::Set(commandPath.mEndpointId, commandData.breadcrumb);
response.errorCode = CommissioningError::kOk;
response.errorCode = CommissioningErrorEnum::kOk;
}
}

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
14 changes: 7 additions & 7 deletions src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2070,7 +2070,7 @@ void DeviceCommissioner::OnArmFailSafe(void * context,
CHIP_ERROR err = CHIP_NO_ERROR;

ChipLogProgress(Controller, "Received ArmFailSafe response errorCode=%u", to_underlying(data.errorCode));
if (data.errorCode != GeneralCommissioning::CommissioningError::kOk)
if (data.errorCode != GeneralCommissioning::CommissioningErrorEnum::kOk)
{
err = CHIP_ERROR_INTERNAL;
report.Set<CommissioningErrorInfo>(data.errorCode);
Expand All @@ -2087,7 +2087,7 @@ void DeviceCommissioner::OnSetRegulatoryConfigResponse(
CHIP_ERROR err = CHIP_NO_ERROR;

ChipLogProgress(Controller, "Received SetRegulatoryConfig response errorCode=%u", to_underlying(data.errorCode));
if (data.errorCode != GeneralCommissioning::CommissioningError::kOk)
if (data.errorCode != GeneralCommissioning::CommissioningErrorEnum::kOk)
{
err = CHIP_ERROR_INTERNAL;
report.Set<CommissioningErrorInfo>(data.errorCode);
Expand Down Expand Up @@ -2181,7 +2181,7 @@ void DeviceCommissioner::OnCommissioningCompleteResponse(
CHIP_ERROR err = CHIP_NO_ERROR;

ChipLogProgress(Controller, "Received CommissioningComplete response, errorCode=%u", to_underlying(data.errorCode));
if (data.errorCode != GeneralCommissioning::CommissioningError::kOk)
if (data.errorCode != GeneralCommissioning::CommissioningErrorEnum::kOk)
{
err = CHIP_ERROR_INTERNAL;
report.Set<CommissioningErrorInfo>(data.errorCode);
Expand Down 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
32 changes: 16 additions & 16 deletions src/controller/CommissioningDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ struct CompletionStatus
CHIP_ERROR err;
Optional<CommissioningStage> failedStage;
Optional<Credentials::AttestationVerificationResult> attestationResult;
Optional<app::Clusters::GeneralCommissioning::CommissioningError> commissioningError;
Optional<app::Clusters::GeneralCommissioning::CommissioningErrorEnum> commissioningError;
Optional<app::Clusters::NetworkCommissioning::NetworkCommissioningStatus> networkCommissioningStatus;
};

Expand Down 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 All @@ -565,8 +565,8 @@ struct AttestationErrorInfo

struct CommissioningErrorInfo
{
CommissioningErrorInfo(app::Clusters::GeneralCommissioning::CommissioningError result) : commissioningError(result) {}
app::Clusters::GeneralCommissioning::CommissioningError commissioningError;
CommissioningErrorInfo(app::Clusters::GeneralCommissioning::CommissioningErrorEnum result) : commissioningError(result) {}
app::Clusters::GeneralCommissioning::CommissioningErrorEnum commissioningError;
};

struct NetworkCommissioningStatusInfo
Expand Down
8 changes: 4 additions & 4 deletions src/controller/java/CHIPDeviceController-JNI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,11 +428,11 @@ JNI_METHOD(jlong, newDeviceController)(JNIEnv * env, jobject self, jobject contr
using namespace app::Clusters::GeneralCommissioning;

jint regulatoryLocationJint = chip::JniReferences::GetInstance().IntegerToPrimitive(regulatoryLocation);
VerifyOrExit(chip::CanCastTo<RegulatoryLocationType>(regulatoryLocationJint), err = CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrExit(chip::CanCastTo<RegulatoryLocationTypeEnum>(regulatoryLocationJint), err = CHIP_ERROR_INVALID_ARGUMENT);

RegulatoryLocationType regulatoryLocationType = static_cast<RegulatoryLocationType>(regulatoryLocationJint);
VerifyOrExit(regulatoryLocationType >= RegulatoryLocationType::kIndoor, err = CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrExit(regulatoryLocationType <= RegulatoryLocationType::kIndoorOutdoor, err = CHIP_ERROR_INVALID_ARGUMENT);
auto regulatoryLocationType = static_cast<RegulatoryLocationTypeEnum>(regulatoryLocationJint);
VerifyOrExit(regulatoryLocationType >= RegulatoryLocationTypeEnum::kIndoor, err = CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrExit(regulatoryLocationType <= RegulatoryLocationTypeEnum::kIndoorOutdoor, err = CHIP_ERROR_INVALID_ARGUMENT);

chip::Controller::CommissioningParameters commissioningParams = wrapper->GetCommissioningParameters();
commissioningParams.SetDeviceRegulatoryLocation(regulatoryLocationType);
Expand Down
Loading

0 comments on commit 07763c8

Please sign in to comment.