Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add switching between fast and slow polling interval for SED (#11314)
Browse files Browse the repository at this point in the history
The spec says about sleepy end devices (SED) that they should
switch between active and idle modes and use fast or slow polling
intervals depending on the commissioning window opening
and existing active exchanges. Currently the slow polling interval
is used all the time. Moreover setting CRA/CRI values is not
compatible with the spec (as both values use the same polling
interval, not the other ones).

* Exposed existing Thread SED polling configuration API to the
ConnectivityManager that will allow using also for SEDs of different
technologies.
* Added few CHIP_DEVICE_CONFIG SED defines that enables SED support
in Matter and configure the slow and fast polling intervals.
* Added setting SED ACTIVE mode if commissioning window is opened
and SED IDLE if it's closed
* Added setting SED ACTIVE mode if during a message exchange device
expects getting response (and further communication). In other case
mode is set to IDLE, as device doesn't need to wait for response.
* Added generating kSEDPollingIntervalChange event on polling
configuration change and handling it to refresh CRA/CRI values
advertised in operational discovery service.
* Modified calculating CRA and CRI values to use respectively fast
and slow polling intervals instead the same one in both cases.
* Aligned examples configuring SED poll interval to follow the new
convention (removed setting poll configs, as it is done automatically
by the ThreadStackMgr).
kkasperczyk-no authored and pull[bot] committed Jul 5, 2022
1 parent 61582ef commit 4702057
Showing 38 changed files with 364 additions and 230 deletions.
8 changes: 8 additions & 0 deletions config/zephyr/Kconfig
Original file line number Diff line number Diff line change
@@ -93,6 +93,14 @@ config CHIP_ENABLE_DNS_CLIENT
help
Enables DNS client support used for resolving and browsing services.

config CHIP_ENABLE_SLEEPY_END_DEVICE_SUPPORT
bool "Enable sleepy end device support"
default n
depends on OPENTHREAD_MTD
imply OPENTHREAD_MTD_SED
help
Enables Thread Sleepy End Device support in Matter.

config APP_LINK_WITH_CHIP
bool "Link 'app' with Connected Home over IP"
default y
4 changes: 0 additions & 4 deletions examples/lighting-app/efr32/include/AppConfig.h
Original file line number Diff line number Diff line change
@@ -27,10 +27,6 @@
// state to another.
#define ACTUATOR_MOVEMENT_PERIOS_MS 10

// ---- Thread Polling Config ----
#define THREAD_ACTIVE_POLLING_INTERVAL_MS 100
#define THREAD_INACTIVE_POLLING_INTERVAL_MS 1000

// EFR Logging
#ifdef __cplusplus
extern "C" {
Original file line number Diff line number Diff line change
@@ -44,10 +44,6 @@
#define SWU_INTERVAl_WINDOW_MIN_MS (23 * 60 * 60 * 1000) // 23 hours
#define SWU_INTERVAl_WINDOW_MAX_MS (24 * 60 * 60 * 1000) // 24 hours

// ---- Thread Polling Config ----
#define THREAD_ACTIVE_POLLING_INTERVAL_MS 100
#define THREAD_INACTIVE_POLLING_INTERVAL_MS 1000

#if K32W_LOG_ENABLED
#define K32W_LOG(...) otPlatLog(OT_LOG_LEVEL_NONE, OT_LOG_REGION_API, ##__VA_ARGS__);
#else
4 changes: 0 additions & 4 deletions examples/lighting-app/qpg/include/AppConfig.h
Original file line number Diff line number Diff line change
@@ -27,8 +27,4 @@

#define SYSTEM_STATE_LED LED_GREEN

// ---- Thread Polling Config ----
#define THREAD_ACTIVE_POLLING_INTERVAL_MS 100
#define THREAD_INACTIVE_POLLING_INTERVAL_MS 1000

#endif // APP_CONFIG_H
13 changes: 0 additions & 13 deletions examples/lock-app/cc13x2x7_26x2x7/main/AppTask.cpp
Original file line number Diff line number Diff line change
@@ -83,7 +83,6 @@ int AppTask::Init()
{
LED_Params ledParams;
Button_Params buttionParams;
ConnectivityManager::ThreadPollingConfig pollingConfig;

cc13x2_26x2LogInit();

@@ -114,18 +113,6 @@ int AppTask::Init()
;
}

pollingConfig.Clear();
pollingConfig.ActivePollingIntervalMS = 5000; // ms
pollingConfig.InactivePollingIntervalMS = 5000; // ms

ret = ConnectivityMgr().SetThreadPollingConfig(pollingConfig);
if (ret != CHIP_NO_ERROR)
{
PLAT_LOG("ConnectivityMgr().SetThreadPollingConfig() failed");
while (1)
;
}

ret = PlatformMgr().StartEventLoopTask();
if (ret != CHIP_NO_ERROR)
{
Original file line number Diff line number Diff line change
@@ -148,6 +148,10 @@
*/
#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT 1

#define CHIP_DEVICE_CONFIG_ENABLE_SED 1
#define CHIP_DEVICE_CONFIG_SED_SLOW_POLLING_INTERVAL 5000
#define CHIP_DEVICE_CONFIG_SED_FAST_POLLING_INTERVAL 5000

/**
* CHIP_CONFIG_EVENT_LOGGING_DEFAULT_IMPORTANCE
*
4 changes: 0 additions & 4 deletions examples/lock-app/efr32/include/AppConfig.h
Original file line number Diff line number Diff line change
@@ -27,10 +27,6 @@
// state to another.
#define ACTUATOR_MOVEMENT_PERIOS_MS 2000

// ---- Thread Polling Config ----
#define THREAD_ACTIVE_POLLING_INTERVAL_MS 100
#define THREAD_INACTIVE_POLLING_INTERVAL_MS 1000

// EFR Logging
#ifdef __cplusplus
extern "C" {
2 changes: 2 additions & 0 deletions examples/lock-app/nrfconnect/main/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
@@ -37,3 +37,5 @@
// Use a default pairing code if one hasn't been provisioned in flash.
#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021
#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00

#define CHIP_DEVICE_CONFIG_SED_SLOW_POLLING_INTERVAL 2000
19 changes: 1 addition & 18 deletions examples/lock-app/nrfconnect/main/main.cpp
Original file line number Diff line number Diff line change
@@ -68,31 +68,14 @@ int main()

#ifdef CONFIG_OPENTHREAD_MTD_SED
err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_SleepyEndDevice);
if (err != CHIP_NO_ERROR)
{
LOG_ERR("ConnectivityMgr().SetThreadDeviceType() failed");
goto exit;
}

ConnectivityManager::ThreadPollingConfig pollingConfig;
pollingConfig.Clear();
pollingConfig.ActivePollingIntervalMS = CONFIG_OPENTHREAD_POLL_PERIOD;
pollingConfig.InactivePollingIntervalMS = CONFIG_OPENTHREAD_POLL_PERIOD;

err = ConnectivityMgr().SetThreadPollingConfig(pollingConfig);
if (err != CHIP_NO_ERROR)
{
LOG_ERR("ConnectivityMgr().SetThreadPollingConfig() failed");
goto exit;
}
#else
err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_MinimalEndDevice);
#endif
if (err != CHIP_NO_ERROR)
{
LOG_ERR("ConnectivityMgr().SetThreadDeviceType() failed");
goto exit;
}
#endif

ret = GetAppTask().StartApp();
if (ret != 0)
3 changes: 1 addition & 2 deletions examples/lock-app/nrfconnect/overlay-low_power.conf
Original file line number Diff line number Diff line change
@@ -15,8 +15,7 @@
#

# Enable MTD Sleepy End Device
CONFIG_OPENTHREAD_MTD_SED=y
CONFIG_OPENTHREAD_POLL_PERIOD=2000
CONFIG_CHIP_ENABLE_SLEEPY_END_DEVICE_SUPPORT=y

# Disable UART console
CONFIG_SHELL=n
4 changes: 4 additions & 0 deletions examples/lock-app/nxp/k32w/k32w0/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
@@ -201,6 +201,10 @@
*/
#define CHIP_CONFIG_MAX_DEVICE_ADMINS 4 // 3 fabrics + 1 for rotation slack

#define CHIP_DEVICE_CONFIG_ENABLE_SED 1
#define CHIP_DEVICE_CONFIG_SED_SLOW_POLLING_INTERVAL 1000
#define CHIP_DEVICE_CONFIG_SED_FAST_POLLING_INTERVAL 100

/**
* CHIP_CONFIG_EVENT_LOGGING_DEFAULT_IMPORTANCE
*
15 changes: 0 additions & 15 deletions examples/lock-app/nxp/k32w/k32w0/main/main.cpp
Original file line number Diff line number Diff line change
@@ -145,21 +145,6 @@ extern "C" void main_task(void const * argument)
goto exit;
}

// Configure the Thread polling behavior for the device.
{
ConnectivityManager::ThreadPollingConfig pollingConfig;
pollingConfig.Clear();
pollingConfig.ActivePollingIntervalMS = THREAD_ACTIVE_POLLING_INTERVAL_MS;
pollingConfig.InactivePollingIntervalMS = THREAD_INACTIVE_POLLING_INTERVAL_MS;

ret = ConnectivityMgr().SetThreadPollingConfig(pollingConfig);
if (ret != CHIP_NO_ERROR)
{
K32W_LOG("Error during ConnectivityMgr().SetThreadPollingConfig(pollingConfig)");
goto exit;
}
}

ret = PlatformMgr().StartEventLoopTask();
if (ret != CHIP_NO_ERROR)
{
4 changes: 0 additions & 4 deletions examples/lock-app/qpg/include/AppConfig.h
Original file line number Diff line number Diff line change
@@ -35,8 +35,4 @@
#define SWU_INTERVAl_WINDOW_MIN_MS (23 * 60 * 60 * 1000) // 23 hours
#define SWU_INTERVAl_WINDOW_MAX_MS (24 * 60 * 60 * 1000) // 24 hours

// ---- Thread Polling Config ----
#define THREAD_ACTIVE_POLLING_INTERVAL_MS 100
#define THREAD_INACTIVE_POLLING_INTERVAL_MS 1000

#endif // APP_CONFIG_H
13 changes: 0 additions & 13 deletions examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp
Original file line number Diff line number Diff line change
@@ -94,7 +94,6 @@ int AppTask::Init()
{
LED_Params ledParams;
Button_Params buttonParams;
ConnectivityManager::ThreadPollingConfig pollingConfig;

cc13x2_26x2LogInit();

@@ -125,18 +124,6 @@ int AppTask::Init()
;
}

pollingConfig.Clear();
pollingConfig.ActivePollingIntervalMS = 5000; // ms
pollingConfig.InactivePollingIntervalMS = 5000; // ms

ret = ConnectivityMgr().SetThreadPollingConfig(pollingConfig);
if (ret != CHIP_NO_ERROR)
{
PLAT_LOG("ConnectivityMgr().SetThreadPollingConfig() failed");
while (1)
;
}

ret = PlatformMgr().StartEventLoopTask();
if (ret != CHIP_NO_ERROR)
{
Original file line number Diff line number Diff line change
@@ -140,6 +140,10 @@
*/
#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT 1

#define CHIP_DEVICE_CONFIG_ENABLE_SED 1
#define CHIP_DEVICE_CONFIG_SED_SLOW_POLLING_INTERVAL 5000
#define CHIP_DEVICE_CONFIG_SED_FAST_POLLING_INTERVAL 5000

/**
* CHIP_CONFIG_EVENT_LOGGING_DEFAULT_IMPORTANCE
*
13 changes: 0 additions & 13 deletions examples/pump-controller-app/cc13x2x7_26x2x7/main/AppTask.cpp
Original file line number Diff line number Diff line change
@@ -89,7 +89,6 @@ int AppTask::Init()
{
LED_Params ledParams;
Button_Params buttonParams;
ConnectivityManager::ThreadPollingConfig pollingConfig;

cc13x2_26x2LogInit();

@@ -120,18 +119,6 @@ int AppTask::Init()
;
}

pollingConfig.Clear();
pollingConfig.ActivePollingIntervalMS = 5000; // ms
pollingConfig.InactivePollingIntervalMS = 5000; // ms

ret = ConnectivityMgr().SetThreadPollingConfig(pollingConfig);
if (ret != CHIP_NO_ERROR)
{
PLAT_LOG("ConnectivityMgr().SetThreadPollingConfig() failed");
while (1)
;
}

ret = PlatformMgr().StartEventLoopTask();
if (ret != CHIP_NO_ERROR)
{
Original file line number Diff line number Diff line change
@@ -140,6 +140,10 @@
*/
#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT 1

#define CHIP_DEVICE_CONFIG_ENABLE_SED 1
#define CHIP_DEVICE_CONFIG_SED_SLOW_POLLING_INTERVAL 5000
#define CHIP_DEVICE_CONFIG_SED_FAST_POLLING_INTERVAL 5000

/**
* CHIP_CONFIG_EVENT_LOGGING_DEFAULT_IMPORTANCE
*
4 changes: 0 additions & 4 deletions examples/shell/efr32/include/AppConfig.h
Original file line number Diff line number Diff line change
@@ -49,10 +49,6 @@
#define SWU_INTERVAl_WINDOW_MIN_MS (23 * 60 * 60 * 1000) // 23 hours
#define SWU_INTERVAl_WINDOW_MAX_MS (24 * 60 * 60 * 1000) // 24 hours

// ---- Thread Polling Config ----
#define THREAD_ACTIVE_POLLING_INTERVAL_MS 100
#define THREAD_INACTIVE_POLLING_INTERVAL_MS 1000

// EFR Logging
#ifdef __cplusplus
extern "C" {
4 changes: 0 additions & 4 deletions examples/shell/nxp/k32w/k32w0/main/include/app_config.h
Original file line number Diff line number Diff line change
@@ -45,10 +45,6 @@
#define SWU_INTERVAl_WINDOW_MIN_MS (23 * 60 * 60 * 1000) // 23 hours
#define SWU_INTERVAl_WINDOW_MAX_MS (24 * 60 * 60 * 1000) // 24 hours

// ---- Thread Polling Config ----
#define THREAD_ACTIVE_POLLING_INTERVAL_MS 100
#define THREAD_INACTIVE_POLLING_INTERVAL_MS 1000

#if K32W_LOG_ENABLED
#define K32W_LOG(...) otPlatLog(OT_LOG_LEVEL_NONE, OT_LOG_REGION_API, ##__VA_ARGS__);
#else
9 changes: 9 additions & 0 deletions src/app/server/CommissioningWindowManager.cpp
Original file line number Diff line number Diff line change
@@ -275,6 +275,11 @@ CHIP_ERROR CommissioningWindowManager::StartAdvertisement()
mAppDelegate->OnPairingWindowOpened();
}
mCommissioningWindowOpen = true;

#if CHIP_DEVICE_CONFIG_ENABLE_SED
DeviceLayer::ConnectivityMgr().RequestSEDFastPollingMode(true);
#endif

return CHIP_NO_ERROR;
}

@@ -287,6 +292,10 @@ CHIP_ERROR CommissioningWindowManager::StopAdvertisement()

mCommissioningWindowOpen = false;

#if CHIP_DEVICE_CONFIG_ENABLE_SED
DeviceLayer::ConnectivityMgr().RequestSEDFastPollingMode(false);
#endif

if (mIsBLE)
{
ReturnErrorOnFailure(chip::DeviceLayer::ConnectivityMgr().SetBLEAdvertisingEnabled(false));
6 changes: 5 additions & 1 deletion src/app/server/Dnssd.cpp
Original file line number Diff line number Diff line change
@@ -58,7 +58,11 @@ bool HaveOperationalCredentials()

void OnPlatformEvent(const DeviceLayer::ChipDeviceEvent * event)
{
if (event->Type == DeviceLayer::DeviceEventType::kDnssdPlatformInitialized)
if (event->Type == DeviceLayer::DeviceEventType::kDnssdPlatformInitialized
#if CHIP_DEVICE_CONFIG_ENABLE_SED
|| event->Type == DeviceLayer::DeviceEventType::kSEDPollingIntervalChange
#endif
)
{
app::DnssdServer::Instance().StartServer();
}
29 changes: 29 additions & 0 deletions src/include/platform/CHIPDeviceConfig.h
Original file line number Diff line number Diff line change
@@ -116,6 +116,35 @@
#define CHIP_DEVICE_CONFIG_LOG_PROVISIONING_HASH 1
#endif

/**
* CHIP_DEVICE_CONFIG_ENABLE_SED
*
* Enable support for sleepy end device behavior.
*/
#ifndef CHIP_DEVICE_CONFIG_ENABLE_SED
#define CHIP_DEVICE_CONFIG_ENABLE_SED 0
#endif

/**
* CHIP_DEVICE_CONFIG_SED_SLOW_POLLING_INTERVAL
*
* The default amount of time in milliseconds that the sleepy end device will use as a slow-polling interval.
* This interval is used by the device to periodically wake up and poll the data in the idle mode.
*/
#ifndef CHIP_DEVICE_CONFIG_SED_SLOW_POLLING_INTERVAL
#define CHIP_DEVICE_CONFIG_SED_SLOW_POLLING_INTERVAL 5000
#endif

/**
* CHIP_DEVICE_CONFIG_SED_FAST_POLLING_INTERVAL
*
* The default amount of time in milliseconds that the sleepy end device will use as a fast-polling interval.
* This interval is used by the device to periodically wake up and poll the data in the active mode.
*/
#ifndef CHIP_DEVICE_CONFIG_SED_FAST_POLLING_INTERVAL
#define CHIP_DEVICE_CONFIG_SED_FAST_POLLING_INTERVAL 200
#endif

// -------------------- Device Identification Configuration --------------------

/**
7 changes: 7 additions & 0 deletions src/include/platform/CHIPDeviceEvent.h
Original file line number Diff line number Diff line change
@@ -158,6 +158,13 @@ enum PublicEventTypes
*/
kTimeSyncChange,

/**
* SED Polling Interval Change
*
* Signals a change to the sleepy end device polling interval.
*/
kSEDPollingIntervalChange,

/**
* Security Session Established
*
Loading

0 comments on commit 4702057

Please sign in to comment.