Skip to content

Commit

Permalink
Added comment for behavior in case of changes in kMaxScenePerFabric a…
Browse files Browse the repository at this point in the history
…nd kMaxClustersPerScene
  • Loading branch information
lpbeliveau-silabs committed Mar 24, 2023
1 parent 7d1ab62 commit b6ce0e2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/app/clusters/scenes/ExtensionFieldSetsImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ CHIP_ERROR ExtensionFieldSetsImpl::Deserialize(TLV::TLVReader & reader, TLV::Tag
}
mFieldSetsCount = i;

// In the event of an OTA where the maximum number of cluster per scene has been reduced, the extension field set will be
// considered "corrupted" if we don't manage to load it all (if err == CHIP_NO_ERROR after the loop). We therefore return an
// error and this scene will have to be deleted. This is done because truncating an EFS doesn't garrantee the order of the
// clusters loaded, which might allow to load clusters that are no longer supported and loosing supported ones.
if (err != CHIP_END_OF_TLV)
{
if (err == CHIP_NO_ERROR)
Expand Down
3 changes: 3 additions & 0 deletions src/app/clusters/scenes/SceneTableImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ struct FabricSceneData : public PersistentData<kPersistentFabricBufferMax>

i++;
}
// In the event of an OTA, is kMaxScenesPerFabric was reduced, err will be equal to CHIP_NO_ERROR. We close the TLV with
// only the acceptable number of scenes and the next save will take care of reducing the memory usage of the map. This
// allows the user to preserve their scenes in between OTA updates.
VerifyOrReturnError(err == CHIP_END_OF_TLV || err == CHIP_NO_ERROR, err);

ReturnErrorOnFailure(reader.ExitContainer(sceneMapContainer));
Expand Down
1 change: 0 additions & 1 deletion src/app/tests/TestSceneTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,6 @@ void TestHandlerRegistration(nlTestSuite * aSuite, void * aContext)
void TestHandlerFunctions(nlTestSuite * aSuite, void * aContext)
{
SceneTable * sceneTable = &sSceneTable;
ClusterId tempCluster = 0;

app::Clusters::Scenes::Structs::ExtensionFieldSet::Type extensionFieldSetOut;
app::Clusters::Scenes::Structs::ExtensionFieldSet::DecodableType extensionFieldSetIn;
Expand Down

0 comments on commit b6ce0e2

Please sign in to comment.