Skip to content

Commit ae482fb

Browse files
committed
Revert "Enforce length constraint for CountryCode in SetRegulatoryConfig. (project-chip#27949)"
This reverts commit b0350f2.
1 parent 81e800a commit ae482fb

File tree

2 files changed

+4
-21
lines changed

2 files changed

+4
-21
lines changed

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

+1-5
Original file line numberDiff line numberDiff line change
@@ -344,11 +344,7 @@ CHIP_ERROR BasicAttrAccess::WriteLocation(AttributeValueDecoder & aDecoder)
344344
ReturnErrorOnFailure(aDecoder.Decode(location));
345345

346346
bool isValidLength = location.size() == DeviceLayer::ConfigurationManager::kMaxLocationLength;
347-
if (!isValidLength)
348-
{
349-
ChipLogError(Zcl, "Invalid country code: '%.*s'", static_cast<int>(location.size()), location.data());
350-
return CHIP_IM_GLOBAL_STATUS(ConstraintError);
351-
}
347+
VerifyOrReturnError(isValidLength, StatusIB(Protocols::InteractionModel::Status::InvalidValue).ToChipError());
352348

353349
return DeviceLayer::ConfigurationMgr().StoreCountryCode(location.data(), location.size());
354350
}

src/app/clusters/general-commissioning-server/general-commissioning-server.cpp

+3-16
Original file line numberDiff line numberDiff line change
@@ -287,21 +287,10 @@ bool emberAfGeneralCommissioningClusterSetRegulatoryConfigCallback(app::CommandH
287287
DeviceControlServer * server = &DeviceLayer::DeviceControlServer::DeviceControlSvr();
288288
Commands::SetRegulatoryConfigResponse::Type response;
289289

290-
auto & countryCode = commandData.countryCode;
291-
bool isValidLength = countryCode.size() == DeviceLayer::ConfigurationManager::kMaxLocationLength;
292-
if (!isValidLength)
293-
{
294-
ChipLogError(Zcl, "Invalid country code: '%.*s'", static_cast<int>(countryCode.size()), countryCode.data());
295-
commandObj->AddStatus(commandPath, Protocols::InteractionModel::Status::ConstraintError);
296-
return true;
297-
}
298-
299290
if (commandData.newRegulatoryConfig > RegulatoryLocationTypeEnum::kIndoorOutdoor)
300291
{
301292
response.errorCode = CommissioningErrorEnum::kValueOutsideRange;
302-
// TODO: How does using the country code in debug text make sense, if
303-
// the real issue is the newRegulatoryConfig value?
304-
response.debugText = countryCode;
293+
response.debugText = commandData.countryCode;
305294
}
306295
else
307296
{
@@ -315,13 +304,11 @@ bool emberAfGeneralCommissioningClusterSetRegulatoryConfigCallback(app::CommandH
315304
if ((locationCapability != to_underlying(RegulatoryLocationTypeEnum::kIndoorOutdoor)) && (location != locationCapability))
316305
{
317306
response.errorCode = CommissioningErrorEnum::kValueOutsideRange;
318-
// TODO: How does using the country code in debug text make sense, if
319-
// the real issue is the newRegulatoryConfig value?
320-
response.debugText = countryCode;
307+
response.debugText = commandData.countryCode;
321308
}
322309
else
323310
{
324-
CheckSuccess(server->SetRegulatoryConfig(location, countryCode), Failure);
311+
CheckSuccess(server->SetRegulatoryConfig(location, commandData.countryCode), Failure);
325312
Breadcrumb::Set(commandPath.mEndpointId, commandData.breadcrumb);
326313
response.errorCode = CommissioningErrorEnum::kOk;
327314
}

0 commit comments

Comments
 (0)