diff --git a/examples/chef/common/chef-rvc-mode-delegate.cpp b/examples/chef/common/chef-rvc-mode-delegate.cpp index 2af784bd42b191..b275d08e21d474 100644 --- a/examples/chef/common/chef-rvc-mode-delegate.cpp +++ b/examples/chef/common/chef-rvc-mode-delegate.cpp @@ -37,7 +37,12 @@ using ModeTagStructType = chip::app::Clusters::detail::Structs::ModeTagStruct::T using namespace chip::app::Clusters::RvcRunMode; static std::unique_ptr gRvcRunModeDelegate; -std::unique_ptr gRvcRunModeInstance; +static std::unique_ptr gRvcRunModeInstance; + +chip::app::Clusters::ModeBase::Instance * getRvcRunModeInstance() +{ + return gRvcRunModeInstance.get(); +} CHIP_ERROR RvcRunModeDelegate::Init() { @@ -63,7 +68,7 @@ void RvcRunModeDelegate::HandleChangeToMode(uint8_t NewMode, ModeBase::Commands: if (currentMode != RvcRunMode::ModeIdle) { // Stop existing cycle when going from cleaning/mapping to idle. ChipLogProgress(DeviceLayer, "Stopping RVC cycle: %d", currentMode); - gRvcOperationalStateDelegate->HandleStopStateCallback(err); + getRvcOperationalStateDelegate()->HandleStopStateCallback(err); } } else @@ -71,7 +76,7 @@ void RvcRunModeDelegate::HandleChangeToMode(uint8_t NewMode, ModeBase::Commands: if (currentMode == RvcRunMode::ModeIdle) { // Start a new cycle when going from idle to clening/mapping. ChipLogProgress(DeviceLayer, "Starting new RVC cycle: %d", NewMode); - gRvcOperationalStateDelegate->HandleStartStateCallback(err); + getRvcOperationalStateDelegate()->HandleStartStateCallback(err); } } if (err.IsEqual(OperationalState::GenericOperationalError(to_underlying(OperationalState::ErrorStateEnum::kNoError)))) diff --git a/examples/chef/common/chef-rvc-mode-delegate.h b/examples/chef/common/chef-rvc-mode-delegate.h index 63674a9787e24b..f5b155cd718b79 100644 --- a/examples/chef/common/chef-rvc-mode-delegate.h +++ b/examples/chef/common/chef-rvc-mode-delegate.h @@ -123,7 +123,7 @@ void Shutdown(); } // namespace chip #ifdef MATTER_DM_PLUGIN_RVC_RUN_MODE_SERVER -extern std::unique_ptr gRvcRunModeInstance; +chip::app::Clusters::ModeBase::Instance * getRvcRunModeInstance(); chip::Protocols::InteractionModel::Status chefRvcRunModeWriteCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata, diff --git a/examples/chef/common/chef-rvc-operational-state-delegate.cpp b/examples/chef/common/chef-rvc-operational-state-delegate.cpp index 4c30adb2d47c34..1a1cf0696c2074 100644 --- a/examples/chef/common/chef-rvc-operational-state-delegate.cpp +++ b/examples/chef/common/chef-rvc-operational-state-delegate.cpp @@ -32,9 +32,14 @@ using chip::Protocols::InteractionModel::Status; #include #endif // MATTER_DM_PLUGIN_RVC_RUN_MODE_SERVER -std::unique_ptr gRvcOperationalStateDelegate; +static std::unique_ptr gRvcOperationalStateDelegate; static std::unique_ptr gRvcOperationalStateInstance; +RvcOperationalStateDelegate * getRvcOperationalStateDelegate() +{ + return gRvcOperationalStateDelegate.get(); +} + static void onOperationalStateTimerTick(System::Layer * systemLayer, void * data); DataModel::Nullable RvcOperationalStateDelegate::GetCountdownTime() @@ -234,7 +239,7 @@ static void onOperationalStateTimerTick(System::Layer * systemLayer, void * data gRvcOperationalStateDelegate->mCountdownTime.SetNull(); #ifdef MATTER_DM_PLUGIN_RVC_RUN_MODE_SERVER - gRvcRunModeInstance->UpdateCurrentMode(RvcRunMode::ModeIdle); + getRvcRunModeInstance()->UpdateCurrentMode(RvcRunMode::ModeIdle); #endif // MATTER_DM_PLUGIN_RVC_RUN_MODE_SERVER } } diff --git a/examples/chef/common/chef-rvc-operational-state-delegate.h b/examples/chef/common/chef-rvc-operational-state-delegate.h index 2fd93d847e228b..d551182787dc36 100644 --- a/examples/chef/common/chef-rvc-operational-state-delegate.h +++ b/examples/chef/common/chef-rvc-operational-state-delegate.h @@ -122,7 +122,7 @@ void Shutdown(); } // namespace app } // namespace chip -extern std::unique_ptr gRvcOperationalStateDelegate; +chip::app::Clusters::RvcOperationalState::RvcOperationalStateDelegate * getRvcOperationalStateDelegate(); chip::Protocols::InteractionModel::Status chefRvcOperationalStateWriteCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata,