Skip to content

Commit

Permalink
Add Threshold timer as active consumer (#24523)
Browse files Browse the repository at this point in the history
  • Loading branch information
jepenven-silabs authored and pull[bot] committed Aug 2, 2023
1 parent 75e8e6f commit 9de00e5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1896,20 +1896,25 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_RequestSEDActiv

if (!onOff && delayIdle && CHIP_DEVICE_CONFIG_SED_ACTIVE_THRESHOLD.count() != 0)
{
err = DeviceLayer::SystemLayer().StartTimer(CHIP_DEVICE_CONFIG_SED_ACTIVE_THRESHOLD, RequestSEDModeChange, this);
err = DeviceLayer::SystemLayer().StartTimer(CHIP_DEVICE_CONFIG_SED_ACTIVE_THRESHOLD, RequestSEDModeUpdate, this);
if (CHIP_NO_ERROR == err)
{
if (!mDelayIdleTimerRunning)
{
mDelayIdleTimerRunning = true;
mActiveModeConsumers++;
}
return err;
}

ChipLogError(DeviceLayer, "Failed to postponed Idle Mode with error %" CHIP_ERROR_FORMAT, err.Format());
ChipLogError(DeviceLayer, "Failed to postpone Idle Mode with error %" CHIP_ERROR_FORMAT, err.Format());
}

return SEDChangeMode();
return SEDUpdateMode();
}

template <class ImplClass>
CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::SEDChangeMode()
CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::SEDUpdateMode()
{
CHIP_ERROR err = CHIP_NO_ERROR;
ConnectivityManager::SEDIntervalMode mode;
Expand All @@ -1923,12 +1928,20 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::SEDChangeMode()
}

template <class ImplClass>
void GenericThreadStackManagerImpl_OpenThread<ImplClass>::RequestSEDModeChange(chip::System::Layer * apSystemLayer,
void GenericThreadStackManagerImpl_OpenThread<ImplClass>::RequestSEDModeUpdate(chip::System::Layer * apSystemLayer,
void * apAppState)
{
if (apAppState != nullptr)
{
static_cast<GenericThreadStackManagerImpl_OpenThread *>(apAppState)->SEDChangeMode();
GenericThreadStackManagerImpl_OpenThread * obj = static_cast<GenericThreadStackManagerImpl_OpenThread *>(apAppState);
if (obj->mActiveModeConsumers > 0)
{
obj->mActiveModeConsumers--;
}

obj->mDelayIdleTimerRunning = false;

obj->SEDUpdateMode();
}
}
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ class GenericThreadStackManagerImpl_OpenThread
CHIP_ERROR _GetSEDIntervalsConfig(ConnectivityManager::SEDIntervalsConfig & intervalsConfig);
CHIP_ERROR _SetSEDIntervalsConfig(const ConnectivityManager::SEDIntervalsConfig & intervalsConfig);
CHIP_ERROR _RequestSEDActiveMode(bool onOff, bool delayIdle);
CHIP_ERROR SEDChangeMode(void);
static void RequestSEDModeChange(chip::System::Layer * apSystemLayer, void * apAppState);
CHIP_ERROR SEDUpdateMode();
static void RequestSEDModeUpdate(chip::System::Layer * apSystemLayer, void * apAppState);
#endif

bool _HaveMeshConnectivity(void);
Expand Down Expand Up @@ -164,6 +164,7 @@ class GenericThreadStackManagerImpl_OpenThread
ConnectivityManager::SEDIntervalsConfig mIntervalsConfig;
ConnectivityManager::SEDIntervalMode mIntervalsMode = ConnectivityManager::SEDIntervalMode::Idle;
uint32_t mActiveModeConsumers = 0;
bool mDelayIdleTimerRunning = false;
#endif

#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT
Expand Down

0 comments on commit 9de00e5

Please sign in to comment.