Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix OTA Requestor implementation of write to DefaultOTAProviders. #33000

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions src/app/clusters/ota-requestor/ota-requestor-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,20 +115,24 @@ CHIP_ERROR OtaSoftwareUpdateRequestorAttrAccess::WriteDefaultOtaProviders(const
return CHIP_ERROR_NOT_FOUND;
}

switch (aPath.mListOp)
if (!aPath.IsListOperation() || aPath.mListOp == ConcreteDataAttributePath::ListOperation::ReplaceAll)
{
case ConcreteDataAttributePath::ListOperation::ReplaceAll: {
DataModel::DecodableList<OtaSoftwareUpdateRequestor::Structs::ProviderLocation::DecodableType> list;
ReturnErrorOnFailure(aDecoder.Decode(list));

// With chunking, a single large list is converted to a list of AttributeDataIBs. The first AttributeDataIB contains an
// empty list (to signal this is a replace so clear out contents) followed by a succession of single AttributeDataIBs for
// each entry to be added.
size_t count = 0;
ReturnErrorOnFailure(list.ComputeSize(&count));
VerifyOrReturnError(count == 0, CHIP_ERROR_INVALID_ARGUMENT);
return requestor->ClearDefaultOtaProviderList(aDecoder.AccessingFabricIndex());
ReturnErrorOnFailure(requestor->ClearDefaultOtaProviderList(aDecoder.AccessingFabricIndex()));

auto iter = list.begin();
while (iter.Next())
{
ReturnErrorOnFailure(requestor->AddDefaultOtaProvider(iter.GetValue()));
}

return iter.GetStatus();
}

switch (aPath.mListOp)
{
case ConcreteDataAttributePath::ListOperation::ReplaceItem:
return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
case ConcreteDataAttributePath::ListOperation::DeleteItem:
Expand Down
Loading