Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
mkardous-silabs committed Feb 1, 2024
1 parent b1bf11e commit b68f9c2
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 22 deletions.
3 changes: 2 additions & 1 deletion examples/light-switch-app/silabs/openthread.gni
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ openthread_external_platform =

# ICD Default configurations
chip_enable_icd_server = true
enable_synchronized_sed = true
chip_subscription_timeout_resumption = false
sl_use_subscription_synching = true

# Openthread Configuration flags
sl_ot_idle_interval_ms = 30000 # 30s Idle Intervals
sl_ot_idle_interval_ms = 500 # 30s Idle Intervals
sl_ot_active_interval_ms = 500 # 500ms Active Intervals

# ICD Matter Configuration flags
Expand Down
10 changes: 10 additions & 0 deletions examples/light-switch-app/silabs/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
#include "AppEvent.h"
#include "BindingHandler.h"

#if defined(SL_CATALOG_POWER_MANAGER_PRESENT)
#include "sl_power_manager.h"
#endif

#include "LEDWidget.h"

#include "LightSwitchMgr.h"
Expand Down Expand Up @@ -124,6 +128,12 @@ void AppTask::AppTaskMain(void * pvParameter)
#endif

SILABS_LOG("App Task started");

#if defined(SL_CATALOG_POWER_MANAGER_PRESENT)
SILABS_LOG("----------------------------------------------- ADING EM1 requirement ---------------------------------");
sl_power_manager_add_em_requirement(SL_POWER_MANAGER_EM1);
#endif

while (true)
{
BaseType_t eventReceived = xQueueReceive(sAppEventQueue, &event, portMAX_DELAY);
Expand Down
22 changes: 22 additions & 0 deletions examples/platform/silabs/MatterConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ static chip::DeviceLayer::Internal::Efr32PsaOperationalKeystore gOperationalKeys
#include <openthread/tasklet.h>
#include <openthread/thread.h>

#if defined(SL_CATALOG_POWER_MANAGER_PRESENT)
#include "sl_power_manager.h"
#endif

// ================================================================================
// Matter Networking Callbacks
// ================================================================================
Expand All @@ -113,7 +117,11 @@ CHIP_ERROR SilabsMatterConfig::InitOpenThread(void)
ReturnErrorOnFailure(ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_Router));
#else // CHIP_DEVICE_CONFIG_THREAD_FTD
#if CHIP_CONFIG_ENABLE_ICD_SERVER
#if CHIP_DEVICE_CONFIG_THREAD_SSED
ReturnErrorOnFailure(ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_SynchronizedSleepyEndDevice));
#else
ReturnErrorOnFailure(ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_SleepyEndDevice));
#endif
#else // CHIP_CONFIG_ENABLE_ICD_SERVER
ReturnErrorOnFailure(ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_MinimalEndDevice));
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER
Expand Down Expand Up @@ -144,6 +152,20 @@ void SilabsMatterConfig::ConnectivityEventCallback(const ChipDeviceEvent * event
chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds32(OTAConfig::kInitOTARequestorDelaySec),
InitOTARequestorHandler, nullptr);
#endif

SILABS_LOG("------------------------------------ Send Data Request -------------------------------------")
otLinkSendDataRequest(chip::DeviceLayer::ThreadStackMgrImpl().OTInstance());

}

if (event->Type == DeviceLayer::DeviceEventType::kCommissioningComplete)
{
#if CHIP_ENABLE_OPENTHREAD
#if defined(SL_CATALOG_POWER_MANAGER_PRESENT)
SILABS_LOG("------------------------------------ REMOVE EM 1 REQUIREMENT -------------------------------------")
sl_power_manager_remove_em_requirement(SL_POWER_MANAGER_EM1);
#endif
#endif // CHIP_ENABLE_OPENTHREAD
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@
// 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))


#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

#endif // SL_ICD_ENABLED

/****Uncomment below section for OpenThread Debug logs*/
Expand Down
6 changes: 6 additions & 0 deletions scripts/examples/gn_silabs_example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ if [ "$#" == "0" ]; then
chip_enable_icd_server
Configure has a Intermitently connected device. (Default false)
Must also set chip_openthread_ftd=false
enable_synchronized_sed
Enable Synchronized Sleepy end device. (Default false)
Must also set enable_sleepy_device=true chip_openthread_ftd=false
use_rs9116
Build wifi example with extension board rs9116. (Default false)
use_SiWx917
Expand Down Expand Up @@ -121,6 +124,9 @@ if [ "$#" == "0" ]; then
--icd
enable ICD features, set thread mtd
For minimum consumption, add --low-power
--ssed
enable synchronized sleepy end device, with csl
For minimum consumption, add --low-power
--low-power
disables all power consuming features for the most power efficient build
This flag is to be used with --icd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -535,9 +535,7 @@ GenericThreadStackManagerImpl_OpenThread<ImplClass>::_SetThreadDeviceType(Connec
#endif
case ConnectivityManager::kThreadDeviceType_MinimalEndDevice:
case ConnectivityManager::kThreadDeviceType_SleepyEndDevice:
#if CHIP_DEVICE_CONFIG_THREAD_SSED
case ConnectivityManager::kThreadDeviceType_SynchronizedSleepyEndDevice:
#endif
break;
default:
ExitNow(err = CHIP_ERROR_INVALID_ARGUMENT);
Expand All @@ -560,11 +558,9 @@ GenericThreadStackManagerImpl_OpenThread<ImplClass>::_SetThreadDeviceType(Connec
case ConnectivityManager::kThreadDeviceType_SleepyEndDevice:
deviceTypeStr = "SLEEPY END DEVICE";
break;
#if CHIP_DEVICE_CONFIG_THREAD_SSED
case ConnectivityManager::kThreadDeviceType_SynchronizedSleepyEndDevice:
deviceTypeStr = "SYNCHRONIZED SLEEPY END DEVICE";
break;
#endif
default:
deviceTypeStr = "(unknown)";
break;
Expand Down Expand Up @@ -596,6 +592,7 @@ GenericThreadStackManagerImpl_OpenThread<ImplClass>::_SetThreadDeviceType(Connec
case ConnectivityManager::kThreadDeviceType_SynchronizedSleepyEndDevice:
linkMode.mDeviceType = false;
linkMode.mRxOnWhenIdle = false;
linkMode.mNetworkData = true;
break;
default:
break;
Expand Down
16 changes: 0 additions & 16 deletions src/platform/silabs/CHIPDevicePlatformConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,22 +118,6 @@

// ========== Platform-specific Configuration Overrides =========

#ifndef CHIP_DEVICE_CONFIG_BLE_LL_TASK_PRIORITY
#define CHIP_DEVICE_CONFIG_BLE_LL_TASK_PRIORITY (configTIMER_TASK_PRIORITY - 1)
#endif // CHIP_DEVICE_CONFIG_BLE_LL_TASK_PRIORITY

#ifndef CHIP_DEVICE_CONFIG_BLE_STACK_TASK_PRIORITY
#define CHIP_DEVICE_CONFIG_BLE_STACK_TASK_PRIORITY (CHIP_DEVICE_CONFIG_BLE_LL_TASK_PRIORITY - 1)
#endif // CHIP_DEVICE_CONFIG_BLE_STACK_TASK_PRIORITY

#ifndef CHIP_DEVICE_CONFIG_BLE_APP_TASK_PRIORITY
#define CHIP_DEVICE_CONFIG_BLE_APP_TASK_PRIORITY (CHIP_DEVICE_CONFIG_BLE_STACK_TASK_PRIORITY - 1)
#endif // CHIP_DEVICE_CONFIG_BLE_STACK_TASK_PRIORITY

#ifndef CHIP_DEVICE_CONFIG_BLE_APP_TASK_STACK_SIZE
#define CHIP_DEVICE_CONFIG_BLE_APP_TASK_STACK_SIZE 1536
#endif // CHIP_DEVICE_CONFIG_BLE_APP_TASK_STACK_SIZE

#ifndef CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE
#define CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE (6 * 1024)
#endif // CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE
Expand Down
17 changes: 16 additions & 1 deletion third_party/silabs/efr32_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ declare_args() {
# ICD Openthread Configuration flags
sl_ot_idle_interval_ms = 15000 # 15s Idle Intervals
sl_ot_active_interval_ms = 200 # 200ms Active Intervals

# SSED Specific configurations
sl_ot_csl_timeout_sec = 30 # 30s CSL timeout

# ICD Matter Configuration flags
sl_idle_mode_interval_s = 600 # 10min Idle Mode Interval
Expand All @@ -59,6 +62,9 @@ declare_args() {

silabs_log_enabled = true

# Enable Synchronized Sleepy End Device
enable_synchronized_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 @@ -160,7 +166,6 @@ template("efr32_sdk") {
"${efr32_sdk_root}/platform/radio/rail_lib/protocol/ieee802154",
"${efr32_sdk_root}/platform/radio/rail_lib/protocol/ble",
"${efr32_sdk_root}/platform/radio/rail_lib/plugin/pa-conversions",
"${efr32_sdk_root}/platform/radio/rail_lib/plugin/rail_util_power_manager_init",
"${efr32_sdk_root}/platform/radio/rail_lib/plugin/rail_util_pti",
"${efr32_sdk_root}/platform/radio/rail_lib/plugin/rail_util_power_manager_init",
"${efr32_sdk_root}/platform/service/device_init/inc",
Expand Down Expand Up @@ -433,6 +438,16 @@ template("efr32_sdk") {
"SL_OT_IDLE_INTERVAL=${sl_ot_idle_interval_ms}",
"SL_OT_ACTIVE_INTERVAL=${sl_ot_active_interval_ms}",
]

if (enable_synchronized_sed) {
defines += [
"CHIP_DEVICE_CONFIG_THREAD_SSED=1",
"OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE=1",
"OPENTHREAD_CONFIG_MAC_CSL_AUTO_SYNC_ENABLE=1",
"OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE=1",
"OPENTHREAD_CONFIG_CSL_TIMEOUT=${sl_ot_csl_timeout_sec}",
]
}
}

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

0 comments on commit b68f9c2

Please sign in to comment.