Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
mkardous-silabs committed Oct 16, 2023
1 parent 5ef4681 commit 6c607fb
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 126 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
218 changes: 114 additions & 104 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 @@ -117,6 +120,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 Expand Up @@ -157,112 +163,116 @@ else
shift
while [ $# -gt 0 ]; do
case $1 in
--clean)
DIR_CLEAN=true
shift
;;
--wifi)
if [ -z "$2" ]; then
echo "--wifi requires rs9116 or SiWx917 or wf200"
exit 1
fi
if [ "$2" = "rs9116" ]; then
optArgs+="use_rs9116=true "
elif [ "$2" = "SiWx917" ]; then
optArgs+="use_SiWx917=true "
elif [ "$2" = "wf200" ]; then
optArgs+="use_wf200=true "
else
echo "Wifi usage: --wifi rs9116|SiWx917|wf200"
exit 1
fi
--clean)
DIR_CLEAN=true
shift
;;
--wifi)
if [ -z "$2" ]; then
echo "--wifi requires rs9116 or SiWx917 or wf200"
exit 1
fi
if [ "$2" = "rs9116" ]; then
optArgs+="use_rs9116=true "
elif [ "$2" = "SiWx917" ]; then
optArgs+="use_SiWx917=true "
elif [ "$2" = "wf200" ]; then
optArgs+="use_wf200=true "
else
echo "Wifi usage: --wifi rs9116|SiWx917|wf200"
exit 1
fi
USE_WIFI=true
optArgs+="chip_device_platform =\"efr32\" "
shift
shift
;;
--icd)
optArgs+="chip_enable_icd_server=true chip_openthread_ftd=false "
shift
;;
--ssed)
optArgs+="enable_sleepy_device=true enable_synchronized_sed=true chip_openthread_ftd=false "
shift
;;
--low-power)
optArgs+="chip_build_libshell=false enable_openthread_cli=false show_qr_code=false disable_lcd=true "
shift
;;
--chip_enable_wifi_ipv4)
optArgs="chip_enable_wifi_ipv4=true chip_inet_config_enable_ipv4=true "
shift
;;
--additional_data_advertising)
optArgs+="chip_enable_additional_data_advertising=true chip_enable_rotating_device_id=true "
shift
;;
--use_ot_lib)
optArgs+="use_silabs_thread_lib=true chip_openthread_target=$SILABS_THREAD_TARGET openthread_external_platform=\"""\" "
shift
;;
--use_ot_coap_lib)
optArgs+="use_silabs_thread_lib=true chip_openthread_target=$SILABS_THREAD_TARGET openthread_external_platform=\"""\" use_thread_coap_lib=true "
shift
;;
--use_chip_lwip_lib)
optArgs+="lwip_root=\""//third_party/connectedhomeip/third_party/lwip"\" "
shift
;;
# Option not to be used until ot-efr32 github is updated
# --use_ot_github_sources)
# optArgs+="openthread_root=\"//third_party/connectedhomeip/third_party/openthread/ot-efr32/openthread\" openthread_efr32_root=\"//third_party/connectedhomeip/third_party/openthread/ot-efr32/src/src\""
# shift
# ;;
--release)
optArgs+="is_debug=false disable_lcd=true chip_build_libshell=false enable_openthread_cli=false use_external_flash=false chip_logging=false silabs_log_enabled=false "
shift
;;
--docker)
optArgs+="efr32_sdk_root=\"$GSDK_ROOT\" "
USE_DOCKER=true
shift
;;
--uart_log)
optArgs+="sl_uart_log_output=true "
shift
;;

--slc_generate)
optArgs+="slc_generate=true "
USE_SLC=true
shift
;;
--slc_reuse_files)
optArgs+="slc_reuse_files=true "
USE_SLC=true
shift
;;
--gn_path)
if [ -z "$2" ]; then
echo "--gn_path requires a path to GN"
exit 1
else
GN_PATH="$2"
fi
GN_PATH_PROVIDED=true
shift
shift
;;
*"sl_matter_version_str="*)
optArgs+="$1 "
USE_GIT_SHA_FOR_VERSION=false
shift
;;
*)
if [ "$1" =~ *"use_rs9116=true"* ] || [ "$1" =~ *"use_SiWx917=true"* ] || [ "$1" =~ *"use_wf200=true"* ]; then
USE_WIFI=true
# NCP Mode so base MCU is an EFR32
optArgs+="chip_device_platform =\"efr32\" "
shift
shift
;;
--icd)
optArgs+="chip_enable_icd_server=true chip_openthread_ftd=false "
shift
;;
--low-power)
optArgs+="chip_build_libshell=false enable_openthread_cli=false show_qr_code=false disable_lcd=true "
shift
;;
--chip_enable_wifi_ipv4)
optArgs="chip_enable_wifi_ipv4=true chip_inet_config_enable_ipv4=true "
shift
;;
--additional_data_advertising)
optArgs+="chip_enable_additional_data_advertising=true chip_enable_rotating_device_id=true "
shift
;;
--use_ot_lib)
optArgs+="use_silabs_thread_lib=true chip_openthread_target=$SILABS_THREAD_TARGET openthread_external_platform=\"""\" "
shift
;;
--use_ot_coap_lib)
optArgs+="use_silabs_thread_lib=true chip_openthread_target=$SILABS_THREAD_TARGET openthread_external_platform=\"""\" use_thread_coap_lib=true "
shift
;;
--use_chip_lwip_lib)
optArgs+="lwip_root=\""//third_party/connectedhomeip/third_party/lwip"\" "
shift
;;
# Option not to be used until ot-efr32 github is updated
# --use_ot_github_sources)
# optArgs+="openthread_root=\"//third_party/connectedhomeip/third_party/openthread/ot-efr32/openthread\" openthread_efr32_root=\"//third_party/connectedhomeip/third_party/openthread/ot-efr32/src/src\""
# shift
# ;;
--release)
optArgs+="is_debug=false disable_lcd=true chip_build_libshell=false enable_openthread_cli=false use_external_flash=false chip_logging=false silabs_log_enabled=false "
shift
;;
--docker)
optArgs+="efr32_sdk_root=\"$GSDK_ROOT\" "
USE_DOCKER=true
shift
;;
--uart_log)
optArgs+="sl_uart_log_output=true "
shift
;;

--slc_generate)
optArgs+="slc_generate=true "
USE_SLC=true
shift
;;
--slc_reuse_files)
optArgs+="slc_reuse_files=true "
USE_SLC=true
shift
;;
--gn_path)
if [ -z "$2" ]; then
echo "--gn_path requires a path to GN"
exit 1
else
GN_PATH="$2"
fi
GN_PATH_PROVIDED=true
shift
shift
;;
*"sl_matter_version_str="*)
optArgs+="$1 "
USE_GIT_SHA_FOR_VERSION=false
shift
;;
*)
if [ "$1" =~ *"use_rs9116=true"* ] || [ "$1" =~ *"use_SiWx917=true"* ] || [ "$1" =~ *"use_wf200=true"* ]; then
USE_WIFI=true
# NCP Mode so base MCU is an EFR32
optArgs+="chip_device_platform =\"efr32\" "
fi
optArgs+=$1" "
shift
;;
fi
optArgs+=$1" "
shift
;;
esac
done

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -526,9 +526,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 @@ -551,11 +549,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 @@ -587,6 +583,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
Loading

0 comments on commit 6c607fb

Please sign in to comment.