Skip to content

Commit

Permalink
TBD eCSL Matter changes
Browse files Browse the repository at this point in the history
  • Loading branch information
suveshpratapa committed Oct 15, 2024
1 parent d951f52 commit 85d86bd
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 1 deletion.
2 changes: 2 additions & 0 deletions examples/platform/silabs/MatterConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ CHIP_ERROR SilabsMatterConfig::InitOpenThread(void)
#if CHIP_CONFIG_ENABLE_ICD_SERVER
#if CHIP_DEVICE_CONFIG_THREAD_SSED
ReturnErrorOnFailure(ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_SynchronizedSleepyEndDevice));
#elif CHIP_DEVICE_CONFIG_THREAD_ECSL_SED
ReturnErrorOnFailure(ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_EnhancedCslSleepyEndDevice));
#else
ReturnErrorOnFailure(ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_SleepyEndDevice));
#endif
Expand Down
10 changes: 10 additions & 0 deletions examples/platform/silabs/efr32/project_include/OpenThreadConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@
// Timeout after 2 missed checkin or 4 mins if sleep interval is too short.
#define OPENTHREAD_CONFIG_MLE_CHILD_TIMEOUT_DEFAULT ((SL_MLE_TIMEOUT_s < 120) ? 240 : ((SL_MLE_TIMEOUT_s * 2) + 1))

#if defined(SL_ECSL_ENABLE) && SL_ECSL_ENABLE

#define OPENTHREAD_CONFIG_MAC_CSL_PERIPHERAL_ENABLE 1
#define OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE 1
#define OPENTHREAD_CONFIG_MAC_CSL_AUTO_SYNC_ENABLE 1
#define OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE 1
#define OPENTHREAD_CONFIG_CSL_TIMEOUT SL_CSL_TIMEOUT

#endif // SL_ECSL_ENABLE

#if defined(SL_CSL_ENABLE) && SL_CSL_ENABLE

#define OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE 1
Expand Down
4 changes: 4 additions & 0 deletions scripts/examples/gn_silabs_example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ if [ "$#" == "0" ]; then
Enable Synchronized Sleepy end device. (Default false)
Must also set chip_enable_icd_server=true chip_openthread_ftd=false
--icd can be used to configure both arguments
enable_ecsl_mobile_sed
Enable Enhanced CSL Sleepy end device for Thread in Mobile. (Default false)
Must also set chip_enable_icd_server=true chip_openthread_ftd=false
--icd can be used to configure both arguments
use_rs9116
Build wifi example with extension board rs9116. (Default false)
use_SiWx917
Expand Down
11 changes: 11 additions & 0 deletions src/include/platform/CHIPDeviceConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,17 @@ static_assert(CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING_INTERVAL_MIN <= CHIP_DEVICE
#define CHIP_DEVICE_CONFIG_THREAD_SSED 0
#endif

/**
* CHIP_DEVICE_CONFIG_THREAD_ECSL_SED
*
* Enable support for Thread Enhanced CSL Sleepy End Device behavior.
* (For Thread in Mobile)
*
*/
#ifndef CHIP_DEVICE_CONFIG_THREAD_ECSL_SED
#define CHIP_DEVICE_CONFIG_THREAD_ECSL_SED 0
#endif

/**
* CHIP_DEVICE_CONFIG_THREAD_BORDER_ROUTER
*
Expand Down
1 change: 1 addition & 0 deletions src/include/platform/ConnectivityManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ class ConnectivityManager
kThreadDeviceType_MinimalEndDevice = 3,
kThreadDeviceType_SleepyEndDevice = 4,
kThreadDeviceType_SynchronizedSleepyEndDevice = 5,
kThreadDeviceType_EnhancedCslSleepyEndDevice = 6,
};

enum BLEAdvertisingMode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ ThreadCapabilities GenericThreadDriver::GetSupportedThreadFeatures()
capabilites.SetField(ThreadCapabilities::kIsFullThreadDevice, CHIP_DEVICE_CONFIG_THREAD_FTD);
capabilites.SetField(ThreadCapabilities::kIsSynchronizedSleepyEndDeviceCapable,
(!CHIP_DEVICE_CONFIG_THREAD_FTD && CHIP_DEVICE_CONFIG_THREAD_SSED));
capabilites.SetField(ThreadCapabilities::kIsEnhancedCslSleepyEndDeviceCapable,
(!CHIP_DEVICE_CONFIG_THREAD_FTD && CHIP_DEVICE_CONFIG_THREAD_ECSL_SED));
return capabilites;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,18 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_SetThreadProvis

// Set the dataset as the active dataset for the node.
Impl()->LockThreadStack();
otErr = otDatasetSetActiveTlvs(mOTInst, &tlvs);
// otErr = otDatasetSetActiveTlvs(mOTInst, &tlvs);

otOperationalDataset dataset;
otErr = otDatasetParseTlvs(&tlvs, &dataset);
if (otErr != OT_ERROR_NONE)
{
return MapOpenThreadError(otErr);
}
dataset.mComponents.mIsWakeupChannelPresent = true;
dataset.mWakeupChannel = 11;
otErr = otDatasetSetActive(mOTInst, &dataset);

Impl()->UnlockThreadStack();
if (otErr != OT_ERROR_NONE)
{
Expand Down Expand Up @@ -521,6 +532,10 @@ ConnectivityManager::ThreadDeviceType GenericThreadStackManagerImpl_OpenThread<I
ExitNow(deviceType = ConnectivityManager::kThreadDeviceType_SynchronizedSleepyEndDevice);
#endif // CHIP_DEVICE_CONFIG_THREAD_SSED

#if CHIP_DEVICE_CONFIG_THREAD_ECSL_SED
ExitNow(deviceType = ConnectivityManager::kThreadDeviceType_EnhancedCslSleepyEndDevice);
#endif // CHIP_DEVICE_CONFIG_THREAD_ECSL_SED

ExitNow(deviceType = ConnectivityManager::kThreadDeviceType_SleepyEndDevice);

exit:
Expand All @@ -547,6 +562,9 @@ GenericThreadStackManagerImpl_OpenThread<ImplClass>::_SetThreadDeviceType(Connec
case ConnectivityManager::kThreadDeviceType_SleepyEndDevice:
#if CHIP_DEVICE_CONFIG_THREAD_SSED
case ConnectivityManager::kThreadDeviceType_SynchronizedSleepyEndDevice:
#endif
#if CHIP_DEVICE_CONFIG_THREAD_ECSL_SED
case ConnectivityManager::kThreadDeviceType_EnhancedCslSleepyEndDevice:
#endif
break;
default:
Expand Down Expand Up @@ -574,6 +592,11 @@ GenericThreadStackManagerImpl_OpenThread<ImplClass>::_SetThreadDeviceType(Connec
case ConnectivityManager::kThreadDeviceType_SynchronizedSleepyEndDevice:
deviceTypeStr = "SYNCHRONIZED SLEEPY END DEVICE";
break;
#endif
#if CHIP_DEVICE_CONFIG_THREAD_ECSL_SED
case ConnectivityManager::kThreadDeviceType_EnhancedCslSleepyEndDevice:
deviceTypeStr = "ENHANCED CSL SLEEPY END DEVICE";
break;
#endif
default:
deviceTypeStr = "(unknown)";
Expand Down Expand Up @@ -604,6 +627,7 @@ GenericThreadStackManagerImpl_OpenThread<ImplClass>::_SetThreadDeviceType(Connec
break;
case ConnectivityManager::kThreadDeviceType_SleepyEndDevice:
case ConnectivityManager::kThreadDeviceType_SynchronizedSleepyEndDevice:
case ConnectivityManager::kThreadDeviceType_EnhancedCslSleepyEndDevice:
linkMode.mDeviceType = false;
linkMode.mRxOnWhenIdle = false;
break;
Expand Down Expand Up @@ -1107,8 +1131,33 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::DoInit(otInstanc
otErr = otIp6SetEnabled(otInst, true);
VerifyOrExit(otErr == OT_ERROR_NONE, err = MapOpenThreadError(otErr));

#if CHIP_DEVICE_CONFIG_THREAD_ECSL_SED
otErr = otLinkWorEnable(otInst, true);

if (otErr == OT_ERROR_NONE)
{
#if OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE
// Use lower log level so as to not affect schedule rx and tx timings.
otErr = otLoggingSetLevel(OT_LOG_LEVEL_WARN);
VerifyOrExit(otErr == OT_ERROR_NONE, err = MapOpenThreadError(otErr));
#endif // OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE
otOperationalDataset activeDataset;
otErr = otDatasetGetActive(mOTInst, &activeDataset);
VerifyOrExit(otErr == OT_ERROR_NONE, err = MapOpenThreadError(otErr));

if (activeDataset.mComponents.mIsWakeupChannelPresent)
{
ChipLogProgress(DeviceLayer, "OpenThread listening for wakeup frames on channel %d.", activeDataset.mWakeupChannel);
}
}
else
{
err = MapOpenThreadError(otErr);
}
#else
otErr = otThreadSetEnabled(otInst, true);
VerifyOrExit(otErr == OT_ERROR_NONE, err = MapOpenThreadError(otErr));
#endif // CHIP_DEVICE_CONFIG_THREAD_ECSL_SED

ChipLogProgress(DeviceLayer, "OpenThread ifconfig up and thread start");
}
Expand Down Expand Up @@ -1153,6 +1202,9 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_SetPollingInter
// Get CSL period in units of 10 symbols, convert it to microseconds and divide by 1000 to get milliseconds.
uint32_t curIntervalMS = otLinkCslGetPeriod(mOTInst) * OT_US_PER_TEN_SYMBOLS / 1000;
#endif // OPENTHREAD_API_VERSION
#elif CHIP_DEVICE_CONFIG_THREAD_ECSL_SED
// Get CSL period in units of us and divide by 1000 to get milliseconds.
uint32_t curIntervalMS = otLinkGetCslPeriod(mOTInst) / 1000;
#else
uint32_t curIntervalMS = otLinkGetPollPeriod(mOTInst);
#endif
Expand All @@ -1169,6 +1221,10 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_SetPollingInter
otErr = otLinkCslSetPeriod(mOTInst, pollingInterval.count() * 1000 / OT_US_PER_TEN_SYMBOLS);
curIntervalMS = otLinkCslGetPeriod(mOTInst) * OT_US_PER_TEN_SYMBOLS / 1000;
#endif // OPENTHREAD_API_VERSION
#elif CHIP_DEVICE_CONFIG_THREAD_ECSL_SED
// Set initial CSL period to 0 for eCSL SEDs. The value is later negotiated with its WC parent.
otErr = otLinkSetCslPeriod(mOTInst, 0);
curIntervalMS = 0;
#else
otErr = otLinkSetPollPeriod(mOTInst, pollingInterval.count());
curIntervalMS = otLinkGetPollPeriod(mOTInst);
Expand Down
14 changes: 14 additions & 0 deletions third_party/silabs/efr32_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ declare_args() {
# SSED Specific configurations
sl_ot_csl_timeout_sec = 30 # 30s CSL timeout

# eCSL-SED Specific configurations
sl_ot_ecsl_timeout_sec = 20 # 20s CSL timeout

# ICD Matter Configuration flags
sl_idle_mode_duration_s = 600 # 10min Idle Mode Duration
sl_active_mode_duration_ms = 1000 # 1s Active Mode Duration
Expand All @@ -68,6 +71,9 @@ declare_args() {
# Enable Synchronized Sleepy End Device
enable_synchronized_sed = false

# Enable Enhanced CSL Sleepy End Device (Thread in Mobile)
enable_ecsl_mobile_sed = false

# Argument to enable IPv4 for wifi
# aligning to match chip_inet_config_enable_ipv4 default configuration
chip_enable_wifi_ipv4 = false
Expand Down Expand Up @@ -461,6 +467,14 @@ template("efr32_sdk") {
"SL_CSL_TIMEOUT=${sl_ot_csl_timeout_sec}",
]
}

if (enable_ecsl_mobile_sed) {
defines += [
"CHIP_DEVICE_CONFIG_THREAD_ECSL_SED=1",
"SL_ECSL_ENABLE=1",
"SL_CSL_TIMEOUT=${sl_ot_ecsl_timeout_sec}",
]
}
}

if (defined(invoker.chip_enable_wifi) && invoker.chip_enable_wifi) {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 85d86bd

Please sign in to comment.