Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for Thread Synchronized Sleepy End Devices #66

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,7 @@ config NRF_802154_SER_RADIO
config NRF_RTC_TIMER_USER_CHAN_COUNT
int
default 2

config NRF_802154_ENCRYPTION
bool
default y
6 changes: 6 additions & 0 deletions config/zephyr/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ config CHIP_ENABLE_SLEEPY_END_DEVICE_SUPPORT
help
Enables Thread Sleepy End Device support in Matter.

config CHIP_THREAD_SSED
bool "Enable Thread Synchronized Sleepy End Device support"
depends on OPENTHREAD_CSL_RECEIVER && CHIP_ENABLE_SLEEPY_END_DEVICE_SUPPORT
help
Enables Thread Synchronized Sleepy End Device support in Matter.

config CHIP_OTA_REQUESTOR
bool "Enable OTA requestor"
help
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
#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_ms32
#define CHIP_DEVICE_CONFIG_SED_IDLE_INTERVAL 2000_ms32
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
/* 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_ms32
#define CHIP_DEVICE_CONFIG_SED_IDLE_INTERVAL 2000_ms32
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@
#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_ms32
#define CHIP_DEVICE_CONFIG_SED_IDLE_INTERVAL 2000_ms32
4 changes: 2 additions & 2 deletions examples/lock-app/nxp/k32w/k32w0/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@
#define CHIP_CONFIG_MAX_FABRICS 4 // 3 fabrics + 1 for rotation slack

#define CHIP_DEVICE_CONFIG_ENABLE_SED 1
#define CHIP_DEVICE_CONFIG_SED_SLOW_POLLING_INTERVAL 1000_ms32
#define CHIP_DEVICE_CONFIG_SED_FAST_POLLING_INTERVAL 100_ms32
#define CHIP_DEVICE_CONFIG_SED_IDLE_INTERVAL 1000_ms32
#define CHIP_DEVICE_CONFIG_SED_ACTIVE_INTERVAL 100_ms32

/**
* CHIP_CONFIG_EVENT_LOGGING_DEFAULT_IMPORTANCE
Expand Down
4 changes: 2 additions & 2 deletions src/app/server/CommissioningWindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ CHIP_ERROR CommissioningWindowManager::StartAdvertisement()
#if CHIP_DEVICE_CONFIG_ENABLE_SED
if (!mIsBLE && mWindowStatus == AdministratorCommissioning::CommissioningWindowStatus::kWindowNotOpen)
{
DeviceLayer::ConnectivityMgr().RequestSEDFastPollingMode(true);
DeviceLayer::ConnectivityMgr().RequestSEDActiveMode(true);
}
#endif

Expand Down Expand Up @@ -386,7 +386,7 @@ CHIP_ERROR CommissioningWindowManager::StopAdvertisement(bool aShuttingDown)
#if CHIP_DEVICE_CONFIG_ENABLE_SED
if (!mIsBLE && mWindowStatus != AdministratorCommissioning::CommissioningWindowStatus::kWindowNotOpen)
{
DeviceLayer::ConnectivityMgr().RequestSEDFastPollingMode(false);
DeviceLayer::ConnectivityMgr().RequestSEDActiveMode(false);
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/app/server/Dnssd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void OnPlatformEvent(const DeviceLayer::ChipDeviceEvent * event)
{
if (event->Type == DeviceLayer::DeviceEventType::kDnssdPlatformInitialized
#if CHIP_DEVICE_CONFIG_ENABLE_SED
|| event->Type == DeviceLayer::DeviceEventType::kSEDPollingIntervalChange
|| event->Type == DeviceLayer::DeviceEventType::kSEDIntervalChange
#endif
)
{
Expand Down
26 changes: 18 additions & 8 deletions src/include/platform/CHIPDeviceConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,23 +126,23 @@
#endif

/**
* CHIP_DEVICE_CONFIG_SED_SLOW_POLLING_INTERVAL
* CHIP_DEVICE_CONFIG_SED_IDLE_INTERVAL
*
* The default amount of time in milliseconds that the sleepy end device will use as a slow-polling interval.
* The default amount of time in milliseconds that the sleepy end device will use as an idle 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_ms32
#ifndef CHIP_DEVICE_CONFIG_SED_IDLE_INTERVAL
#define CHIP_DEVICE_CONFIG_SED_IDLE_INTERVAL 5000_ms32
#endif

/**
* CHIP_DEVICE_CONFIG_SED_FAST_POLLING_INTERVAL
* CHIP_DEVICE_CONFIG_SED_ACTIVE_INTERVAL
*
* The default amount of time in milliseconds that the sleepy end device will use as a fast-polling interval.
* The default amount of time in milliseconds that the sleepy end device will use as an active 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_ms32
#ifndef CHIP_DEVICE_CONFIG_SED_ACTIVE_INTERVAL
#define CHIP_DEVICE_CONFIG_SED_ACTIVE_INTERVAL 200_ms32
#endif

// -------------------- Device Identification Configuration --------------------
Expand Down Expand Up @@ -691,6 +691,16 @@
#define CHIP_DEVICE_CONFIG_THREAD_FTD 1
#endif

/**
* CHIP_DEVICE_CONFIG_THREAD_SSED
*
* Enable support for Thread Synchronized Sleepy End Device behavior.
*
*/
#ifndef CHIP_DEVICE_CONFIG_THREAD_SSED
#define CHIP_DEVICE_CONFIG_THREAD_SSED 0
#endif

/**
* CHIP_DEVICE_CONFIG_THREAD_TASK_NAME
*
Expand Down
6 changes: 3 additions & 3 deletions src/include/platform/CHIPDeviceEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,11 @@ enum PublicEventTypes
kTimeSyncChange,

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

/**
* Security Session Established
Expand Down
61 changes: 31 additions & 30 deletions src/include/platform/ConnectivityManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,12 @@ class ConnectivityManager

enum ThreadDeviceType
{
kThreadDeviceType_NotSupported = 0,
kThreadDeviceType_Router = 1,
kThreadDeviceType_FullEndDevice = 2,
kThreadDeviceType_MinimalEndDevice = 3,
kThreadDeviceType_SleepyEndDevice = 4,
kThreadDeviceType_NotSupported = 0,
kThreadDeviceType_Router = 1,
kThreadDeviceType_FullEndDevice = 2,
kThreadDeviceType_MinimalEndDevice = 3,
kThreadDeviceType_SleepyEndDevice = 4,
kThreadDeviceType_SynchronizedSleepyEndDevice = 5,
};

enum BLEAdvertisingMode
Expand All @@ -146,13 +147,13 @@ class ConnectivityManager
kSlowAdvertising = 1,
};

enum class SEDPollingMode
enum class SEDIntervalMode
{
Idle = 0,
Active = 1,
};

struct SEDPollingConfig;
struct SEDIntervalsConfig;

void SetDelegate(ConnectivityManagerDelegate * delegate) { mDelegate = delegate; }
ConnectivityManagerDelegate * GetDelegate() const { return mDelegate; }
Expand Down Expand Up @@ -195,24 +196,24 @@ class ConnectivityManager

// Sleepy end device methods
#if CHIP_DEVICE_CONFIG_ENABLE_SED
CHIP_ERROR GetSEDPollingConfig(SEDPollingConfig & pollingConfig);
CHIP_ERROR GetSEDIntervalsConfig(SEDIntervalsConfig & intervalsConfig);

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

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

// CHIPoBLE service methods
Expand Down Expand Up @@ -271,17 +272,17 @@ class ConnectivityManager
};

/**
* Information describing the desired polling behavior of a sleepy end device (SED).
* Information describing the desired intervals for a sleepy end device (SED).
*/
struct ConnectivityManager::SEDPollingConfig
struct ConnectivityManager::SEDIntervalsConfig
{
/** Interval at which the device polls its parent when there are active chip exchanges in progress. Only meaningful when the
* device is acting as a sleepy end node. */
System::Clock::Milliseconds32 FastPollingIntervalMS;
/** Interval at which the device is able to communicate with its parent when there are active chip exchanges in progress. Only
* meaningful when the device is acting as a sleepy end node. */
System::Clock::Milliseconds32 ActiveIntervalMS;

/** Interval at which the device polls its parent when there are NO active chip exchanges in progress. Only meaningful when the
* device is acting as a sleepy end node. */
System::Clock::Milliseconds32 SlowPollingIntervalMS;
/** Interval at which the device is able to communicate with its parent when there are NO active chip exchanges in progress.
* Only meaningful when the device is acting as a sleepy end node. */
System::Clock::Milliseconds32 IdleIntervalMS;
};

/**
Expand Down Expand Up @@ -442,19 +443,19 @@ inline CHIP_ERROR ConnectivityManager::SetThreadDeviceType(ThreadDeviceType devi
}

#if CHIP_DEVICE_CONFIG_ENABLE_SED
inline CHIP_ERROR ConnectivityManager::GetSEDPollingConfig(SEDPollingConfig & pollingConfig)
inline CHIP_ERROR ConnectivityManager::GetSEDIntervalsConfig(SEDIntervalsConfig & intervalsConfig)
{
return static_cast<ImplClass *>(this)->_GetSEDPollingConfig(pollingConfig);
return static_cast<ImplClass *>(this)->_GetSEDIntervalsConfig(intervalsConfig);
}

inline CHIP_ERROR ConnectivityManager::SetSEDPollingConfig(const SEDPollingConfig & pollingConfig)
inline CHIP_ERROR ConnectivityManager::SetSEDIntervalsConfig(const SEDIntervalsConfig & intervalsConfig)
{
return static_cast<ImplClass *>(this)->_SetSEDPollingConfig(pollingConfig);
return static_cast<ImplClass *>(this)->_SetSEDIntervalsConfig(intervalsConfig);
}

inline CHIP_ERROR ConnectivityManager::RequestSEDFastPollingMode(bool onOff)
inline CHIP_ERROR ConnectivityManager::RequestSEDActiveMode(bool onOff)
{
return static_cast<ImplClass *>(this)->_RequestSEDFastPollingMode(onOff);
return static_cast<ImplClass *>(this)->_RequestSEDActiveMode(onOff);
}
#endif

Expand Down
30 changes: 15 additions & 15 deletions src/include/platform/ThreadStackManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,24 +163,24 @@ class ThreadStackManager
CHIP_ERROR SetThreadDeviceType(ConnectivityManager::ThreadDeviceType threadRole);

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

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

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

bool HaveMeshConnectivity();
Expand Down Expand Up @@ -390,19 +390,19 @@ inline CHIP_ERROR ThreadStackManager::SetThreadDeviceType(ConnectivityManager::T
}

#if CHIP_DEVICE_CONFIG_ENABLE_SED
inline CHIP_ERROR ThreadStackManager::GetSEDPollingConfig(ConnectivityManager::SEDPollingConfig & pollingConfig)
inline CHIP_ERROR ThreadStackManager::GetSEDIntervalsConfig(ConnectivityManager::SEDIntervalsConfig & intervalsConfig)
{
return static_cast<ImplClass *>(this)->_GetSEDPollingConfig(pollingConfig);
return static_cast<ImplClass *>(this)->_GetSEDIntervalsConfig(intervalsConfig);
}

inline CHIP_ERROR ThreadStackManager::SetSEDPollingConfig(const ConnectivityManager::SEDPollingConfig & pollingConfig)
inline CHIP_ERROR ThreadStackManager::SetSEDIntervalsConfig(const ConnectivityManager::SEDIntervalsConfig & intervalsConfig)
{
return static_cast<ImplClass *>(this)->_SetSEDPollingConfig(pollingConfig);
return static_cast<ImplClass *>(this)->_SetSEDIntervalsConfig(intervalsConfig);
}

inline CHIP_ERROR ThreadStackManager::RequestSEDFastPollingMode(bool onOff)
inline CHIP_ERROR ThreadStackManager::RequestSEDActiveMode(bool onOff)
{
return static_cast<ImplClass *>(this)->_RequestSEDFastPollingMode(onOff);
return static_cast<ImplClass *>(this)->_RequestSEDActiveMode(onOff);
}
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ class GenericConnectivityManagerImpl_NoThread
bool _IsThreadApplicationControlled(void);
ConnectivityManager::ThreadDeviceType _GetThreadDeviceType(void);
CHIP_ERROR _SetThreadDeviceType(ConnectivityManager::ThreadDeviceType deviceType);
CHIP_ERROR _GetSEDPollingConfig(ConnectivityManager::SEDPollingConfig & pollingConfig);
CHIP_ERROR _SetSEDPollingConfig(const ConnectivityManager::SEDPollingConfig & pollingConfig);
CHIP_ERROR _RequestSEDFastPollingMode(bool onOff);
CHIP_ERROR _GetSEDIntervalsConfig(ConnectivityManager::SEDIntervalsConfig & intervalsConfig);
CHIP_ERROR _SetSEDIntervalsConfig(const ConnectivityManager::SEDIntervalsConfig & intervalsConfig);
CHIP_ERROR _RequestSEDActiveMode(bool onOff);
bool _IsThreadAttached(void);
bool _IsThreadProvisioned(void);
void _ErasePersistentInfo(void);
Expand Down Expand Up @@ -116,21 +116,21 @@ GenericConnectivityManagerImpl_NoThread<ImplClass>::_SetThreadDeviceType(Connect
}

template <class ImplClass>
inline CHIP_ERROR
GenericConnectivityManagerImpl_NoThread<ImplClass>::_GetSEDPollingConfig(ConnectivityManager::SEDPollingConfig & pollingConfig)
inline CHIP_ERROR GenericConnectivityManagerImpl_NoThread<ImplClass>::_GetSEDIntervalsConfig(
ConnectivityManager::SEDIntervalsConfig & intervalsConfig)
{
return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
}

template <class ImplClass>
inline CHIP_ERROR GenericConnectivityManagerImpl_NoThread<ImplClass>::_SetSEDPollingConfig(
const ConnectivityManager::SEDPollingConfig & pollingConfig)
inline CHIP_ERROR GenericConnectivityManagerImpl_NoThread<ImplClass>::_SetSEDIntervalsConfig(
const ConnectivityManager::SEDIntervalsConfig & intervalsConfig)
{
return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
}

template <class ImplClass>
inline CHIP_ERROR GenericConnectivityManagerImpl_NoThread<ImplClass>::_RequestSEDFastPollingMode(bool onOff)
inline CHIP_ERROR GenericConnectivityManagerImpl_NoThread<ImplClass>::_RequestSEDActiveMode(bool onOff)
{
return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
}
Expand Down
Loading