Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 61bb162

Browse files
committedApr 16, 2024·
Fix OTA Requestor implementation of write to DefaultOTAProviders.
Our implementation only handled chunked lists and failed if a non-chunked list was sent. This is bad, because typically this list is short, and chunking it wastes bytes on the wire.
1 parent 4aadee7 commit 61bb162

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed
 

‎src/app/clusters/ota-requestor/ota-requestor-server.cpp

+13-9
Original file line numberDiff line numberDiff line change
@@ -115,20 +115,24 @@ CHIP_ERROR OtaSoftwareUpdateRequestorAttrAccess::WriteDefaultOtaProviders(const
115115
return CHIP_ERROR_NOT_FOUND;
116116
}
117117

118-
switch (aPath.mListOp)
118+
if (!aPath.IsListOperation() || aPath.mListOp == ConcreteDataAttributePath::ListOperation::ReplaceAll)
119119
{
120-
case ConcreteDataAttributePath::ListOperation::ReplaceAll: {
121120
DataModel::DecodableList<OtaSoftwareUpdateRequestor::Structs::ProviderLocation::DecodableType> list;
122121
ReturnErrorOnFailure(aDecoder.Decode(list));
123122

124-
// With chunking, a single large list is converted to a list of AttributeDataIBs. The first AttributeDataIB contains an
125-
// empty list (to signal this is a replace so clear out contents) followed by a succession of single AttributeDataIBs for
126-
// each entry to be added.
127-
size_t count = 0;
128-
ReturnErrorOnFailure(list.ComputeSize(&count));
129-
VerifyOrReturnError(count == 0, CHIP_ERROR_INVALID_ARGUMENT);
130-
return requestor->ClearDefaultOtaProviderList(aDecoder.AccessingFabricIndex());
123+
ReturnErrorOnFailure(requestor->ClearDefaultOtaProviderList(aDecoder.AccessingFabricIndex()));
124+
125+
auto iter = list.begin();
126+
while (iter.Next())
127+
{
128+
ReturnErrorOnFailure(requestor->AddDefaultOtaProvider(iter.GetValue()));
129+
}
130+
131+
return iter.GetStatus();
131132
}
133+
134+
switch (aPath.mListOp)
135+
{
132136
case ConcreteDataAttributePath::ListOperation::ReplaceItem:
133137
return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
134138
case ConcreteDataAttributePath::ListOperation::DeleteItem:

0 commit comments

Comments
 (0)
Please sign in to comment.