From 2d6d6cd85a81488cf06f5ad90f44735dea364604 Mon Sep 17 00:00:00 2001 From: Kamil Kasperczyk <66371704+kkasperczyk-no@users.noreply.github.com> Date: Wed, 10 Nov 2021 01:41:02 +0100 Subject: [PATCH] Added documentation regarding requesting SED poll interval update. (#11521) In the https://github.com/project-chip/connectedhomeip/pull/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. --- src/include/platform/ConnectivityManager.h | 15 +++++++++++++++ src/include/platform/ThreadStackManager.h | 15 +++++++++++++++ src/messaging/ExchangeContext.cpp | 7 +++---- src/messaging/ExchangeContext.h | 6 +----- .../GenericThreadStackManagerImpl_OpenThread.cpp | 14 +++++--------- 5 files changed, 39 insertions(+), 18 deletions(-) diff --git a/src/include/platform/ConnectivityManager.h b/src/include/platform/ConnectivityManager.h index 1d2ebbbe78ee51..88ce7bd11159d3 100644 --- a/src/include/platform/ConnectivityManager.h +++ b/src/include/platform/ConnectivityManager.h @@ -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 diff --git a/src/include/platform/ThreadStackManager.h b/src/include/platform/ThreadStackManager.h index a80f6ca5bfa887..80a03478e9f09f 100644 --- a/src/include/platform/ThreadStackManager.h +++ b/src/include/platform/ThreadStackManager.h @@ -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 diff --git a/src/messaging/ExchangeContext.cpp b/src/messaging/ExchangeContext.cpp index d86c001907d30d..257537017eb32b 100644 --- a/src/messaging/ExchangeContext.cpp +++ b/src/messaging/ExchangeContext.cpp @@ -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)) { @@ -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()) diff --git a/src/messaging/ExchangeContext.h b/src/messaging/ExchangeContext.h index 6a8c03cb89a55b..1494056191e420 100644 --- a/src/messaging/ExchangeContext.h +++ b/src/messaging/ExchangeContext.h @@ -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 diff --git a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp index 15e4638f670121..02ad1997c46faa 100644 --- a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp +++ b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp @@ -1468,7 +1468,7 @@ template CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::_RequestSEDFastPollingMode(bool onOff) { CHIP_ERROR err = CHIP_NO_ERROR; - uint32_t interval; + ConnectivityManager::SEDPollingMode mode; if (onOff) { @@ -1480,14 +1480,10 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::_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; }