Skip to content

Commit

Permalink
Merge branch 'release_2.5-1.4' into bugfix/rs9116-update-logs
Browse files Browse the repository at this point in the history
  • Loading branch information
rosahay-silabs authored Nov 28, 2024
2 parents cfbffab + c352461 commit c1f6e78
Show file tree
Hide file tree
Showing 32 changed files with 968 additions and 38 deletions.
1 change: 1 addition & 0 deletions examples/lighting-app/silabs/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ CHIP_ERROR AppTask::Init()
#endif // QR_CODE_ENABLED
#endif

BaseApplication::InitCompleteCallback(err);
return err;
}

Expand Down
23 changes: 23 additions & 0 deletions examples/platform/silabs/BaseApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@
#include "sl_cmp_config.h"
#endif

// Tracing
#include <matter/tracing/build_config.h>
#if MATTER_TRACING_ENABLED
#include <TracingShellCommands.h>
#include <platform/silabs/tracing/SilabsTracing.h>
#endif // MATTER_TRACING_ENABLED

/**********************************************************
* Defines and Constants
*********************************************************/
Expand All @@ -113,6 +120,11 @@ using namespace chip::app;
using namespace ::chip::DeviceLayer;
using namespace ::chip::DeviceLayer::Silabs;

#if MATTER_TRACING_ENABLED
using TimeTraceOperation = chip::Tracing::Silabs::TimeTraceOperation;
using SilabsTracer = chip::Tracing::Silabs::SilabsTracer;
#endif // MATTER_TRACING_ENABLED

namespace {

/**********************************************************
Expand Down Expand Up @@ -322,6 +334,9 @@ CHIP_ERROR BaseApplication::Init()
#if CHIP_CONFIG_ENABLE_ICD_SERVER
ICDCommands::RegisterCommands();
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER
#if MATTER_TRACING_ENABLED
TracingCommands::RegisterCommands();
#endif // MATTER_TRACING_ENABLED
#endif // ENABLE_CHIP_SHELL

#ifdef PERFORMANCE_TEST_ENABLED
Expand All @@ -340,6 +355,14 @@ CHIP_ERROR BaseApplication::Init()
return err;
}

void BaseApplication::InitCompleteCallback(CHIP_ERROR err)
{
#if MATTER_TRACING_ENABLED
SilabsTracer::Instance().TimeTraceEnd(TimeTraceOperation::kAppInit);
SilabsTracer::Instance().TimeTraceEnd(TimeTraceOperation::kBootup);
#endif // MATTER_TRACING_ENABLED
}

void BaseApplication::FunctionTimerEventHandler(void * timerCbArg)
{
AppEvent event;
Expand Down
11 changes: 10 additions & 1 deletion examples/platform/silabs/BaseApplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class BaseApplication

public:
BaseApplication() = default;
virtual ~BaseApplication() {};
virtual ~BaseApplication(){};
static bool sIsProvisioned;
static bool sIsFactoryResetTriggered;
static LEDWidget * sAppActionLed;
Expand Down Expand Up @@ -122,6 +122,7 @@ class BaseApplication
*
* @param event AppEvent to post
*/

static void PostEvent(const AppEvent * event);

/**
Expand Down Expand Up @@ -176,6 +177,14 @@ class BaseApplication
protected:
CHIP_ERROR Init();

/** @brief
* Function to be called at the end of Init to indicate that the application has completed its initialization.
* Currently only used for tracing, might want to move logging here as well in the future
* @param err CHIP_NO_ERROR on success, corresponding error code on Init failure, note that Init failure leads to an app error so
* this is purely to have a trace logged with the error code
*/
void InitCompleteCallback(CHIP_ERROR err);

/**
* @brief Function called to start the function timer
*
Expand Down
45 changes: 45 additions & 0 deletions examples/platform/silabs/MatterConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER
#endif /* SL_WIFI */

#if SL_MATTER_ENABLE_APP_SLEEP_MANAGER
#include "ApplicationSleepManager.h"
#endif // SL_MATTER_ENABLE_APP_SLEEP_MANAGER

#if PW_RPC_ENABLED
#include "Rpc.h"
#endif
Expand Down Expand Up @@ -91,6 +95,13 @@ static chip::DeviceLayer::Internal::Efr32PsaOperationalKeystore gOperationalKeys
#include "sl_power_manager.h"
#endif

#include <matter/tracing/build_config.h>
#if MATTER_TRACING_ENABLED
#include <platform/silabs/tracing/BackendImpl.h>
#include <platform/silabs/tracing/SilabsTracing.h>
#include <tracing/registry.h>
#endif // MATTER_TRACING_ENABLED

/**********************************************************
* Defines
*********************************************************/
Expand All @@ -101,6 +112,11 @@ using namespace ::chip::DeviceLayer;
using namespace ::chip::Credentials;
using namespace chip::DeviceLayer::Silabs;

#if MATTER_TRACING_ENABLED
using TimeTraceOperation = chip::Tracing::Silabs::TimeTraceOperation;
using SilabsTracer = chip::Tracing::Silabs::SilabsTracer;
#endif // MATTER_TRACING_ENABLED

#if CHIP_ENABLE_OPENTHREAD
#include <inet/EndPointStateOpenThread.h>
#include <openthread/cli.h>
Expand Down Expand Up @@ -175,6 +191,11 @@ void ApplicationStart(void * unused)
if (err != CHIP_NO_ERROR)
appError(err);

#if MATTER_TRACING_ENABLED
SilabsTracer::Instance().TimeTraceEnd(TimeTraceOperation::kMatterInit);
SilabsTracer::Instance().TimeTraceBegin(TimeTraceOperation::kAppInit);
#endif // MATTER_TRACING_ENABLED

gExampleDeviceInfoProvider.SetStorageDelegate(&chip::Server::GetInstance().GetPersistentStorage());
chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider);

Expand Down Expand Up @@ -205,6 +226,10 @@ void SilabsMatterConfig::AppInit()
sMainTaskHandle = osThreadNew(ApplicationStart, nullptr, &kMainTaskAttr);
ChipLogProgress(DeviceLayer, "Starting scheduler");
VerifyOrDie(sMainTaskHandle); // We can't proceed if the Main Task creation failed.

#if MATTER_TRACING_ENABLED
SilabsTracer::Instance().TimeTraceEnd(TimeTraceOperation::kBootup);
#endif // MATTER_TRACING_ENABLED
GetPlatform().StartScheduler();

// Should never get here.
Expand Down Expand Up @@ -312,6 +337,26 @@ CHIP_ERROR SilabsMatterConfig::InitMatter(const char * appName)
// Init Matter Server and Start Event Loop
err = chip::Server::GetInstance().Init(initParams);

// [sl-only]: Configure Wi-Fi App Sleep Manager
#if SL_MATTER_ENABLE_APP_SLEEP_MANAGER
err = app::Silabs::ApplicationSleepManager::GetInstance()
.SetFabricTable(&Server::GetInstance().GetFabricTable())
.SetSubscriptionInfoProvider(app::InteractionModelEngine::GetInstance())
.SetCommissioningWindowManager(&Server::GetInstance().GetCommissioningWindowManager())
.SetWifiSleepManager(&WifiSleepManager::GetInstance())
.Init();
VerifyOrReturnError(err == CHIP_NO_ERROR, err, ChipLogError(DeviceLayer, "ApplicationSleepManager init failed"));

// Register ReadHandler::ApplicationCallback
app::InteractionModelEngine::GetInstance()->RegisterReadHandlerAppCallback(
&app::Silabs::ApplicationSleepManager::GetInstance());
#endif // SL_MATTER_ENABLE_APP_SLEEP_MANAGER

#if MATTER_TRACING_ENABLED
static Tracing::Silabs::BackendImpl backend;
Tracing::Register(backend);
#endif // MATTER_TRACING_ENABLED

chip::DeviceLayer::PlatformMgr().UnlockChipStack();

ReturnErrorOnFailure(err);
Expand Down
5 changes: 5 additions & 0 deletions examples/platform/silabs/SiWx917/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import("//build_overrides/chip.gni")
import("//build_overrides/efr32_sdk.gni")
import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni")
import("${chip_root}/examples/platform/silabs/args.gni")
import("${chip_root}/src/app/icd/icd.gni")
import("${chip_root}/src/lib/lib.gni")
import("${chip_root}/src/platform/device.gni")
import("${chip_root}/src/platform/silabs/wifi/args.gni")
Expand Down Expand Up @@ -204,6 +205,10 @@ source_set("siwx917-common") {
]
}

if (chip_enable_icd_server) {
public_deps += [ "${silabs_common_plat_dir}/wifi/icd:app-sleep-manager" ]
}

if (app_data_model != "") {
public_deps += [ app_data_model ]
}
Expand Down
11 changes: 11 additions & 0 deletions examples/platform/silabs/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni")
import("${chip_root}/src/app/icd/icd.gni")
import("${chip_root}/src/lib/lib.gni")
import("${chip_root}/src/platform/device.gni")
import("${chip_root}/src/tracing/tracing_args.gni")
import("${silabs_sdk_build_root}/efr32_sdk.gni")
import("${silabs_sdk_build_root}/silabs_board.gni")

Expand Down Expand Up @@ -110,6 +111,9 @@ source_set("matter-shell") {
"${chip_root}/src/lib/shell:shell",
"${chip_root}/src/lib/shell:shell_core",
]
if (matter_enable_tracing_support) {
public_deps += [ "${chip_root}/src/platform/silabs/tracing:SilabsTracing" ]
}
}

config("efr32-common-config") {
Expand Down Expand Up @@ -210,6 +214,9 @@ source_set("efr32-common") {
if (chip_enable_icd_server) {
deps += [ "${silabs_common_plat_dir}/shell:icd" ]
}
if (matter_enable_tracing_support) {
public_deps += [ "${silabs_common_plat_dir}/shell:tracing" ]
}
}

public_deps += [
Expand All @@ -233,4 +240,8 @@ source_set("efr32-common") {
if (app_data_model != "") {
public_deps += [ app_data_model ]
}

if (matter_enable_tracing_support) {
public_deps += [ "${chip_root}/src/platform/silabs/tracing:SilabsTracing" ]
}
}
19 changes: 18 additions & 1 deletion examples/platform/silabs/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,27 @@
#include "sl_system_kernel.h"
#include <MatterConfig.h>

#include <matter/tracing/build_config.h>
#if MATTER_TRACING_ENABLED
#include <platform/silabs/tracing/SilabsTracing.h>
#endif // MATTER_TRACING_ENABLED

#if MATTER_TRACING_ENABLED
using TimeTraceOperation = chip::Tracing::Silabs::TimeTraceOperation;
using SilabsTracer = chip::Tracing::Silabs::SilabsTracer;
#endif // MATTER_TRACING_ENABLED

int main(void)
{
#if MATTER_TRACING_ENABLED
SilabsTracer::Instance().TimeTraceBegin(TimeTraceOperation::kBootup);
SilabsTracer::Instance().TimeTraceBegin(TimeTraceOperation::kSilabsInit);
#endif // MATTER_TRACING_ENABLED
sl_system_init();

#if MATTER_TRACING_ENABLED
SilabsTracer::Instance().TimeTraceEnd(TimeTraceOperation::kSilabsInit);
SilabsTracer::Instance().TimeTraceBegin(TimeTraceOperation::kMatterInit);
#endif // MATTER_TRACING_ENABLED
// Initialize the application. For example, create periodic timer(s) or
// task(s) if the kernel is present.
SilabsMatterConfig::AppInit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
extern "C" {
#endif
#include <sparkfun_sgp40.h>
#include <sparkfun_sgp40_i2c.h>
}
#include "sl_i2cspm_instances.h"
#endif // USE_SPARKFUN_AIR_QUALITY_SENSOR
Expand Down
25 changes: 20 additions & 5 deletions examples/platform/silabs/shell/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,32 @@ if (use_SiWx917) {
shell_dependency_path = "${chip_root}/examples/platform/silabs/SiWx917"
}

config("shell-config") {
include_dirs = [ "." ]
config("icd-shell-config") {
include_dirs = [ "./icd/" ]
}

config("tracing-shell-config") {
include_dirs = [ "./tracing/" ]
}

source_set("icd") {
sources = [
"ICDShellCommands.cpp",
"ICDShellCommands.h",
"./icd/ICDShellCommands.cpp",
"./icd/ICDShellCommands.h",
]

public_configs = [ ":icd-shell-config" ]

deps = [ "${shell_dependency_path}:matter-shell" ]
}

source_set("tracing") {
sources = [
"./tracing/TracingShellCommands.cpp",
"./tracing/TracingShellCommands.h",
]

public_configs = [ ":shell-config" ]
public_configs = [ ":tracing-shell-config" ]

deps = [ "${shell_dependency_path}:matter-shell" ]
}
Loading

0 comments on commit c1f6e78

Please sign in to comment.