Skip to content

Commit

Permalink
Added documentation regarding requesting SED poll interval update. (#…
Browse files Browse the repository at this point in the history
…11521)

In the #11314
PR there were some post-merge comments regarding missing
documentation.

* Added missing documentation for the RequestSEDFastPollingMode
and SetSEDPollingConfig methods.
* Added setting new mode only if it's different than the current
one.
  • Loading branch information
kkasperczyk-no authored and pull[bot] committed Jul 8, 2022
1 parent 8f8dd1f commit 1096028
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 18 deletions.
15 changes: 15 additions & 0 deletions src/include/platform/ConnectivityManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,22 @@ class ConnectivityManager
// Sleepy end device methods
#if CHIP_DEVICE_CONFIG_ENABLE_SED
CHIP_ERROR GetSEDPollingConfig(SEDPollingConfig & pollingConfig);

/**
* Sets Sleepy End Device polling configuration and posts kSEDPollingIntervalChange event to inform other software
* modules about the change.
*
* @param[in] pollingConfig polling intervals configuration to be set
*/
CHIP_ERROR SetSEDPollingConfig(const SEDPollingConfig & pollingConfig);

/**
* Requests setting Sleepy End Device fast polling interval on or off.
* Every method call with onOff parameter set to true or false results in incrementing or decrementing the fast polling
* consumers counter. Fast polling mode is set if the consumers counter is bigger than 0.
*
* @param[in] onOff true if fast polling should be enabled and false otherwise.
*/
CHIP_ERROR RequestSEDFastPollingMode(bool onOff);
#endif

Expand Down
15 changes: 15 additions & 0 deletions src/include/platform/ThreadStackManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,22 @@ class ThreadStackManager

#if CHIP_DEVICE_CONFIG_ENABLE_SED
CHIP_ERROR GetSEDPollingConfig(ConnectivityManager::SEDPollingConfig & pollingConfig);

/**
* Sets Sleepy End Device polling configuration and posts kSEDPollingIntervalChange event to inform other software
* modules about the change.
*
* @param[in] pollingConfig polling intervals configuration to be set
*/
CHIP_ERROR SetSEDPollingConfig(const ConnectivityManager::SEDPollingConfig & pollingConfig);

/**
* Requests setting Sleepy End Device fast polling interval on or off.
* Every method call with onOff parameter set to true or false results in incrementing or decrementing the fast polling
* consumers counter. Fast polling mode is set if the consumers counter is bigger than 0.
*
* @param[in] onOff true if fast polling should be enabled and false otherwise.
*/
CHIP_ERROR RequestSEDFastPollingMode(bool onOff);
#endif

Expand Down
7 changes: 3 additions & 4 deletions src/messaging/ExchangeContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ void ExchangeContext::SetResponseTimeout(Timeout timeout)
}

#if CONFIG_DEVICE_LAYER && CHIP_DEVICE_CONFIG_ENABLE_SED
void ExchangeContext::UpdateSEDPollingMode(Transport::Type transportType)
void ExchangeContext::UpdateSEDPollingMode()
{
if (transportType != Transport::Type::kBle)
if (GetSessionHandle().GetPeerAddress(mExchangeMgr->GetSessionManager())->GetTransportType() != Transport::Type::kBle)
{
if (!IsResponseExpected() && !IsSendExpected() && (mExchangeMgr->GetNumActiveExchanges() == 1))
{
Expand Down Expand Up @@ -488,8 +488,7 @@ CHIP_ERROR ExchangeContext::HandleMessage(uint32_t messageCounter, const Payload
void ExchangeContext::MessageHandled()
{
#if CONFIG_DEVICE_LAYER && CHIP_DEVICE_CONFIG_ENABLE_SED
const Transport::PeerAddress * peerAddress = GetSessionHandle().GetPeerAddress(mExchangeMgr->GetSessionManager());
UpdateSEDPollingMode(peerAddress->GetTransportType());
UpdateSEDPollingMode();
#endif

if (mFlags.Has(Flags::kFlagClosed) || IsResponseExpected() || IsSendExpected())
Expand Down
6 changes: 1 addition & 5 deletions src/messaging/ExchangeContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,11 @@ class DLL_EXPORT ExchangeContext : public ReliableMessageContext, public Referen
* - set IDLE polling mode if all conditions are met:
* - device doesn't expect getting response nor sending message
* - there is no other active exchange than the current one
* - active state is not forced (commissioning window is not opened)
* - set ACTIVE polling mode if any of the conditions is met:
* - device expects getting response or sending message
* - there is another active exchange
* - active state is forced (commissioning window is currently open)
*
* @param[in] transportType transport used by the exchange
*/
void UpdateSEDPollingMode(Transport::Type transportType);
void UpdateSEDPollingMode();
};

} // namespace Messaging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1468,7 +1468,7 @@ template <class ImplClass>
CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_RequestSEDFastPollingMode(bool onOff)
{
CHIP_ERROR err = CHIP_NO_ERROR;
uint32_t interval;
ConnectivityManager::SEDPollingMode mode;

if (onOff)
{
Expand All @@ -1480,14 +1480,10 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_RequestSEDFastP
mFastPollingConsumers--;
}

if (mFastPollingConsumers > 0)
{
err = SetSEDPollingMode(ConnectivityManager::SEDPollingMode::Active);
}
else
{
err = SetSEDPollingMode(ConnectivityManager::SEDPollingMode::Idle);
}
mode = mFastPollingConsumers > 0 ? ConnectivityManager::SEDPollingMode::Active : ConnectivityManager::SEDPollingMode::Idle;

if (mPollingMode != mode)
err = SetSEDPollingMode(mode);

return err;
}
Expand Down

0 comments on commit 1096028

Please sign in to comment.