Skip to content

Commit

Permalink
last fabric
Browse files Browse the repository at this point in the history
  • Loading branch information
swan-amazon committed Aug 29, 2024
1 parent bb90708 commit 107bbc0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <platform/ConfigurationManager.h>
#include <platform/DeviceControlServer.h>
#include <tracing/macros.h>
#include <credentials/FabricTable.h>

using namespace chip;
using namespace chip::app;
Expand Down Expand Up @@ -477,12 +478,7 @@ void OnPlatformEventHandler(const DeviceLayer::ChipDeviceEvent * event, intptr_t

} // anonymous namespace

void MatterGeneralCommissioningPluginServerInitCallback()
{
Breadcrumb::Set(0, 0);
AttributeAccessInterfaceRegistry::Instance().Register(&gAttrAccess);
DeviceLayer::PlatformMgrImpl().AddEventHandler(OnPlatformEventHandler);
}


namespace chip {
namespace app {
Expand All @@ -496,3 +492,29 @@ void SetBreadcrumb(Attributes::Breadcrumb::TypeInfo::Type breadcrumb)
} // namespace Clusters
} // namespace app
} // namespace chip

class GeneralCommissioningFabricTableDelegate : public chip::FabricTable::Delegate
{
public:
// Gets called when a fabric is deleted
void OnFabricRemoved(const FabricTable & fabricTable, FabricIndex fabricIndex) override
{
// If the FabricIndex matches the last remaining entry in the Fabrics list, then the device SHALL delete all Matter
// related data on the node which was created since it was commissioned.
if (Server::GetInstance().GetFabricTable().FabricCount() == 0)
{
ChipLogProgress(Zcl, "general-commissioning-server: Last Fabric index 0x%x was removed", static_cast<unsigned>(fabricIndex));
Server::GetInstance().GetTermsAndConditionsProvider()->ResetAcceptance();
}
}
};

void MatterGeneralCommissioningPluginServerInitCallback()
{
Breadcrumb::Set(0, 0);
AttributeAccessInterfaceRegistry::Instance().Register(&gAttrAccess);
DeviceLayer::PlatformMgrImpl().AddEventHandler(OnPlatformEventHandler);

static GeneralCommissioningFabricTableDelegate generalCommissioningFabricTableDelegate;
Server::GetInstance().GetFabricTable().AddFabricDelegate(&generalCommissioningFabricTableDelegate);
}
2 changes: 1 addition & 1 deletion src/app/server/DefaultTermsAndConditionsProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ CHIP_ERROR chip::app::DefaultTermsAndConditionsProvider::CheckAcceptance(const O
// Validate if we have received any terms and conditions acceptance
if (!inTermsAndConditions.HasValue())
{
ChipLogError(AppServer, "Failed to HasReceivedTermsAndConditionsAcknowledgements");
ChipLogError(AppServer, "No terms and conditions have been accepted");
outState = TermsAndConditionsState::TC_ACKNOWLEDGEMENTS_NOT_RECEIVED;
return CHIP_NO_ERROR;
}
Expand Down

0 comments on commit 107bbc0

Please sign in to comment.