Skip to content

Commit

Permalink
Revert "[nrf fromtree] Enforce length constraint for CountryCode in S…
Browse files Browse the repository at this point in the history
…etRegulatoryConfig. (project-chip#27949)"

This reverts commit 96ea933.
  • Loading branch information
kkasperczyk-no committed Nov 9, 2023
1 parent f7f2c3a commit fded3e8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 21 deletions.
6 changes: 1 addition & 5 deletions src/app/clusters/basic-information/basic-information.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,11 +344,7 @@ CHIP_ERROR BasicAttrAccess::WriteLocation(AttributeValueDecoder & aDecoder)
ReturnErrorOnFailure(aDecoder.Decode(location));

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

return DeviceLayer::ConfigurationMgr().StoreCountryCode(location.data(), location.size());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,21 +287,10 @@ bool emberAfGeneralCommissioningClusterSetRegulatoryConfigCallback(app::CommandH
DeviceControlServer * server = &DeviceLayer::DeviceControlServer::DeviceControlSvr();
Commands::SetRegulatoryConfigResponse::Type response;

auto & countryCode = commandData.countryCode;
bool isValidLength = countryCode.size() == DeviceLayer::ConfigurationManager::kMaxLocationLength;
if (!isValidLength)
{
ChipLogError(Zcl, "Invalid country code: '%.*s'", static_cast<int>(countryCode.size()), countryCode.data());
commandObj->AddStatus(commandPath, Protocols::InteractionModel::Status::ConstraintError);
return true;
}

if (commandData.newRegulatoryConfig > RegulatoryLocationType::kIndoorOutdoor)
{
response.errorCode = CommissioningError::kValueOutsideRange;
// TODO: How does using the country code in debug text make sense, if
// the real issue is the newRegulatoryConfig value?
response.debugText = countryCode;
response.debugText = commandData.countryCode;
}
else
{
Expand All @@ -315,13 +304,11 @@ bool emberAfGeneralCommissioningClusterSetRegulatoryConfigCallback(app::CommandH
if ((locationCapability != to_underlying(RegulatoryLocationType::kIndoorOutdoor)) && (location != locationCapability))
{
response.errorCode = CommissioningError::kValueOutsideRange;
// TODO: How does using the country code in debug text make sense, if
// the real issue is the newRegulatoryConfig value?
response.debugText = countryCode;
response.debugText = commandData.countryCode;
}
else
{
CheckSuccess(server->SetRegulatoryConfig(location, countryCode), Failure);
CheckSuccess(server->SetRegulatoryConfig(location, commandData.countryCode), Failure);
Breadcrumb::Set(commandPath.mEndpointId, commandData.breadcrumb);
response.errorCode = CommissioningError::kOk;
}
Expand Down

0 comments on commit fded3e8

Please sign in to comment.