Skip to content

Commit

Permalink
[Silabs] EFR32 common files modification, logging and some extra chan…
Browse files Browse the repository at this point in the history
…ges (#23751)

* example/platform/silabs/efr32 modifications of common files

* App modifications for the logging

* src/platform folder modification with logging and common file modifications

* restyling and some build changes that were missed

* adding logs to places where it was missed for the build to pass
  • Loading branch information
chirag-silabs authored and pull[bot] committed May 16, 2023
1 parent bf09435 commit 1527708
Show file tree
Hide file tree
Showing 78 changed files with 795 additions and 788 deletions.
4 changes: 2 additions & 2 deletions examples/chef/efr32/include/AppConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
extern "C" {
#endif

void efr32InitLog(void);
void silabsInitLog(void);

void efr32Log(const char * aFormat, ...);
#define EFR32_LOG(...) efr32Log(__VA_ARGS__);
#define SILABS_LOG(...) efr32Log(__VA_ARGS__);
void appError(int err);

#ifdef __cplusplus
Expand Down
6 changes: 3 additions & 3 deletions examples/chef/efr32/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ CHIP_ERROR AppTask::Init()
err = BaseApplication::Init(&gIdentify);
if (err != CHIP_NO_ERROR)
{
EFR32_LOG("BaseApplication::Init() failed");
SILABS_LOG("BaseApplication::Init() failed");
appError(err);
}

Expand All @@ -155,11 +155,11 @@ void AppTask::AppTaskMain(void * pvParameter)
CHIP_ERROR err = sAppTask.Init();
if (err != CHIP_NO_ERROR)
{
EFR32_LOG("AppTask.Init() failed");
SILABS_LOG("AppTask.Init() failed");
appError(err);
}

EFR32_LOG("App Task started");
SILABS_LOG("App Task started");

while (true)
{
Expand Down
12 changes: 6 additions & 6 deletions examples/chef/efr32/src/LightingManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ CHIP_ERROR LightingManager::Init()

if (sLightTimer == NULL)
{
EFR32_LOG("sLightTimer timer create failed");
SILABS_LOG("sLightTimer timer create failed");
return APP_ERROR_CREATE_TIMER_FAILED;
}

Expand Down Expand Up @@ -125,7 +125,7 @@ void LightingManager::StartTimer(uint32_t aTimeoutMs)
{
if (xTimerIsTimerActive(sLightTimer))
{
EFR32_LOG("app timer already started!");
SILABS_LOG("app timer already started!");
CancelTimer();
}

Expand All @@ -134,7 +134,7 @@ void LightingManager::StartTimer(uint32_t aTimeoutMs)
// cannot immediately be sent to the timer command queue.
if (xTimerChangePeriod(sLightTimer, (aTimeoutMs / portTICK_PERIOD_MS), 100) != pdPASS)
{
EFR32_LOG("sLightTimer timer start() failed");
SILABS_LOG("sLightTimer timer start() failed");
appError(APP_ERROR_START_TIMER_FAILED);
}
}
Expand All @@ -143,7 +143,7 @@ void LightingManager::CancelTimer(void)
{
if (xTimerStop(sLightTimer, 0) == pdFAIL)
{
EFR32_LOG("sLightTimer stop() failed");
SILABS_LOG("sLightTimer stop() failed");
appError(APP_ERROR_STOP_TIMER_FAILED);
}
}
Expand Down Expand Up @@ -183,7 +183,7 @@ void LightingManager::AutoTurnOffTimerEventHandler(AppEvent * aEvent)

light->mAutoTurnOffTimerArmed = false;

EFR32_LOG("Auto Turn Off has been triggered!");
SILABS_LOG("Auto Turn Off has been triggered!");

light->InitiateAction(actor, OFF_ACTION);
}
Expand Down Expand Up @@ -219,7 +219,7 @@ void LightingManager::ActuatorMovementTimerEventHandler(AppEvent * aEvent)

light->mAutoTurnOffTimerArmed = true;

EFR32_LOG("Auto Turn off enabled. Will be triggered in %u seconds", light->mAutoTurnOffDuration);
SILABS_LOG("Auto Turn off enabled. Will be triggered in %u seconds", light->mAutoTurnOffDuration);
}
}
}
6 changes: 3 additions & 3 deletions examples/chef/efr32/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,16 @@ int main(void)
#endif
chip::DeviceLayer::PlatformMgr().UnlockChipStack();

EFR32_LOG("Starting App Task");
SILABS_LOG("Starting App Task");
if (AppTask::GetAppTask().StartAppTask() != CHIP_NO_ERROR)
appError(CHIP_ERROR_INTERNAL);

EFR32_LOG("Starting FreeRTOS scheduler");
SILABS_LOG("Starting FreeRTOS scheduler");
sl_system_kernel_start();

// Should never get here.
chip::Platform::MemoryShutdown();
EFR32_LOG("vTaskStartScheduler() failed");
SILABS_LOG("vTaskStartScheduler() failed");
appError(CHIP_ERROR_INTERNAL);
}

Expand Down
4 changes: 2 additions & 2 deletions examples/light-switch-app/efr32/include/AppConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
extern "C" {
#endif

void efr32InitLog(void);
void silabsInitLog(void);

void efr32Log(const char * aFormat, ...);
#define EFR32_LOG(...) efr32Log(__VA_ARGS__);
#define SILABS_LOG(...) efr32Log(__VA_ARGS__);
void appError(int err);

#ifdef __cplusplus
Expand Down
8 changes: 4 additions & 4 deletions examples/light-switch-app/efr32/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,15 @@ CHIP_ERROR AppTask::Init()
err = BaseApplication::Init(&gIdentify);
if (err != CHIP_NO_ERROR)
{
EFR32_LOG("BaseApplication::Init() failed");
SILABS_LOG("BaseApplication::Init() failed");
appError(err);
}

// Configure Bindings - TODO ERROR PROCESSING
err = InitBindingHandler();
if (err != CHIP_NO_ERROR)
{
EFR32_LOG("InitBindingHandler() failed");
SILABS_LOG("InitBindingHandler() failed");
appError(err);
}

Expand All @@ -185,15 +185,15 @@ void AppTask::AppTaskMain(void * pvParameter)
CHIP_ERROR err = sAppTask.Init();
if (err != CHIP_NO_ERROR)
{
EFR32_LOG("AppTask.Init() failed");
SILABS_LOG("AppTask.Init() failed");
appError(err);
}

#if !(defined(CHIP_DEVICE_CONFIG_ENABLE_SED) && CHIP_DEVICE_CONFIG_ENABLE_SED)
sAppTask.StartStatusLEDTimer();
#endif

EFR32_LOG("App Task started");
SILABS_LOG("App Task started");
while (true)
{
BaseType_t eventReceived = xQueueReceive(sAppEventQueue, &event, portMAX_DELAY);
Expand Down
10 changes: 5 additions & 5 deletions examples/light-switch-app/efr32/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <credentials/DeviceAttestationCredsProvider.h>
#include <matter_config.h>
#ifdef EFR32_ATTESTATION_CREDENTIALS
#include <examples/platform/efr32/EFR32DeviceAttestationCreds.h>
#include <examples/platform/silabs/SilabsDeviceAttestationCreds.h>
#else
#include <credentials/examples/DeviceAttestationCredsExample.h>
#endif
Expand Down Expand Up @@ -59,22 +59,22 @@ int main(void)
chip::DeviceLayer::PlatformMgr().LockChipStack();
// Initialize device attestation config
#ifdef EFR32_ATTESTATION_CREDENTIALS
SetDeviceAttestationCredentialsProvider(EFR32::GetEFR32DacProvider());
SetDeviceAttestationCredentialsProvider(Silabs::GetSilabsDacProvider());
#else
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
#endif
chip::DeviceLayer::PlatformMgr().UnlockChipStack();

EFR32_LOG("Starting App Task");
SILABS_LOG("Starting App Task");
if (AppTask::GetAppTask().StartAppTask() != CHIP_NO_ERROR)
appError(CHIP_ERROR_INTERNAL);

EFR32_LOG("Starting FreeRTOS scheduler");
SILABS_LOG("Starting FreeRTOS scheduler");
sl_system_kernel_start();

// Should never get here.
chip::Platform::MemoryShutdown();
EFR32_LOG("vTaskStartScheduler() failed");
SILABS_LOG("vTaskStartScheduler() failed");
appError(CHIP_ERROR_INTERNAL);
}

Expand Down
18 changes: 9 additions & 9 deletions examples/lighting-app/silabs/efr32/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,14 @@ CHIP_ERROR AppTask::Init()
err = BaseApplication::Init(&gIdentify);
if (err != CHIP_NO_ERROR)
{
EFR32_LOG("BaseApplication::Init() failed");
SILABS_LOG("BaseApplication::Init() failed");
appError(err);
}

err = LightMgr().Init();
if (err != CHIP_NO_ERROR)
{
EFR32_LOG("LightMgr::Init() failed");
SILABS_LOG("LightMgr::Init() failed");
appError(err);
}

Expand All @@ -175,15 +175,15 @@ void AppTask::AppTaskMain(void * pvParameter)
CHIP_ERROR err = sAppTask.Init();
if (err != CHIP_NO_ERROR)
{
EFR32_LOG("AppTask.Init() failed");
SILABS_LOG("AppTask.Init() failed");
appError(err);
}

#if !(defined(CHIP_DEVICE_CONFIG_ENABLE_SED) && CHIP_DEVICE_CONFIG_ENABLE_SED)
sAppTask.StartStatusLEDTimer();
#endif

EFR32_LOG("App Task started");
SILABS_LOG("App Task started");

while (true)
{
Expand Down Expand Up @@ -242,7 +242,7 @@ void AppTask::LightActionEventHandler(AppEvent * aEvent)

if (!initiated)
{
EFR32_LOG("Action is already in progress or active.");
SILABS_LOG("Action is already in progress or active.");
}
}
}
Expand Down Expand Up @@ -274,7 +274,7 @@ void AppTask::ActionInitiated(LightingManager::Action_t aAction, int32_t aActor)
{
// Action initiated, update the light led
bool lightOn = aAction == LightingManager::ON_ACTION;
EFR32_LOG("Turning light %s", (lightOn) ? "On" : "Off")
SILABS_LOG("Turning light %s", (lightOn) ? "On" : "Off")

#ifdef ENABLE_WSTK_LEDS
sLightLED.Set(lightOn);
Expand All @@ -295,11 +295,11 @@ void AppTask::ActionCompleted(LightingManager::Action_t aAction)
// action has been completed bon the light
if (aAction == LightingManager::ON_ACTION)
{
EFR32_LOG("Light ON")
SILABS_LOG("Light ON")
}
else if (aAction == LightingManager::OFF_ACTION)
{
EFR32_LOG("Light OFF")
SILABS_LOG("Light OFF")
}

if (sAppTask.mSyncClusterToButtonAction)
Expand Down Expand Up @@ -328,6 +328,6 @@ void AppTask::UpdateClusterState(intptr_t context)

if (status != EMBER_ZCL_STATUS_SUCCESS)
{
EFR32_LOG("ERR: updating on/off %x", status);
SILABS_LOG("ERR: updating on/off %x", status);
}
}
14 changes: 7 additions & 7 deletions examples/lighting-app/silabs/efr32/src/LightingManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ CHIP_ERROR LightingManager::Init()

if (sLightTimer == NULL)
{
EFR32_LOG("sLightTimer timer create failed");
SILABS_LOG("sLightTimer timer create failed");
return APP_ERROR_CREATE_TIMER_FAILED;
}

Expand Down Expand Up @@ -156,7 +156,7 @@ void LightingManager::StartTimer(uint32_t aTimeoutMs)
{
if (xTimerIsTimerActive(sLightTimer))
{
EFR32_LOG("app timer already started!");
SILABS_LOG("app timer already started!");
CancelTimer();
}

Expand All @@ -165,7 +165,7 @@ void LightingManager::StartTimer(uint32_t aTimeoutMs)
// cannot immediately be sent to the timer command queue.
if (xTimerChangePeriod(sLightTimer, (aTimeoutMs / portTICK_PERIOD_MS), 100) != pdPASS)
{
EFR32_LOG("sLightTimer timer start() failed");
SILABS_LOG("sLightTimer timer start() failed");
appError(APP_ERROR_START_TIMER_FAILED);
}
}
Expand All @@ -174,7 +174,7 @@ void LightingManager::CancelTimer(void)
{
if (xTimerStop(sLightTimer, 0) == pdFAIL)
{
EFR32_LOG("sLightTimer stop() failed");
SILABS_LOG("sLightTimer stop() failed");
appError(APP_ERROR_STOP_TIMER_FAILED);
}
}
Expand Down Expand Up @@ -218,7 +218,7 @@ void LightingManager::AutoTurnOffTimerEventHandler(AppEvent * aEvent)

light->mAutoTurnOffTimerArmed = false;

EFR32_LOG("Auto Turn Off has been triggered!");
SILABS_LOG("Auto Turn Off has been triggered!");

light->InitiateAction(actor, OFF_ACTION);
}
Expand All @@ -236,7 +236,7 @@ void LightingManager::OffEffectTimerEventHandler(AppEvent * aEvent)

light->mOffEffectArmed = false;

EFR32_LOG("OffEffect completed");
SILABS_LOG("OffEffect completed");

light->InitiateAction(actor, OFF_ACTION);
}
Expand Down Expand Up @@ -272,7 +272,7 @@ void LightingManager::ActuatorMovementTimerEventHandler(AppEvent * aEvent)

light->mAutoTurnOffTimerArmed = true;

EFR32_LOG("Auto Turn off enabled. Will be triggered in %u seconds", light->mAutoTurnOffDuration);
SILABS_LOG("Auto Turn off enabled. Will be triggered in %u seconds", light->mAutoTurnOffDuration);
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions examples/lighting-app/silabs/efr32/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <credentials/DeviceAttestationCredsProvider.h>
#include <matter_config.h>
#ifdef EFR32_ATTESTATION_CREDENTIALS
#include <examples/platform/efr32/EFR32DeviceAttestationCreds.h>
#include <examples/platform/silabs/SilabsDeviceAttestationCreds.h>
#else
#include <credentials/examples/DeviceAttestationCredsExample.h>
#endif
Expand Down Expand Up @@ -59,22 +59,22 @@ int main(void)
chip::DeviceLayer::PlatformMgr().LockChipStack();
// Initialize device attestation config
#ifdef EFR32_ATTESTATION_CREDENTIALS
SetDeviceAttestationCredentialsProvider(EFR32::GetEFR32DacProvider());
SetDeviceAttestationCredentialsProvider(Silabs::GetSilabsDacProvider());
#else
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
#endif
chip::DeviceLayer::PlatformMgr().UnlockChipStack();

EFR32_LOG("Starting App Task");
SILABS_LOG("Starting App Task");
if (AppTask::GetAppTask().StartAppTask() != CHIP_NO_ERROR)
appError(CHIP_ERROR_INTERNAL);

EFR32_LOG("Starting FreeRTOS scheduler");
SILABS_LOG("Starting FreeRTOS scheduler");
sl_system_kernel_start();

// Should never get here.
chip::Platform::MemoryShutdown();
EFR32_LOG("vTaskStartScheduler() failed");
SILABS_LOG("vTaskStartScheduler() failed");
appError(CHIP_ERROR_INTERNAL);
}

Expand Down
4 changes: 2 additions & 2 deletions examples/lock-app/efr32/include/AppConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
extern "C" {
#endif

void efr32InitLog(void);
void silabsInitLog(void);

void efr32Log(const char * aFormat, ...);
#define EFR32_LOG(...) efr32Log(__VA_ARGS__);
#define SILABS_LOG(...) efr32Log(__VA_ARGS__);
void appError(int err);

#ifdef __cplusplus
Expand Down
Loading

0 comments on commit 1527708

Please sign in to comment.