Skip to content

Commit

Permalink
# This is a combination of 4 commits.
Browse files Browse the repository at this point in the history
# This is the 1st commit message:

WIP

# This is the commit message #2:

WIP

# This is the commit message #3:

WIP

# This is the commit message #4:

WIP
  • Loading branch information
mkardous-silabs committed Oct 14, 2022
1 parent b6c9191 commit bfa08b0
Show file tree
Hide file tree
Showing 21 changed files with 125 additions and 33 deletions.
2 changes: 1 addition & 1 deletion examples/chef/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ chip_data_model("chef-common") {

# ThunderBoards, Explorer Kit and MGM240L do not support LCD (No LCD)
if (silabs_board == "BRD4166A" || silabs_board == "BRD2601B" ||
silabs_board == "BRD2703A" || silabs_board == "BRD4319A") {
silabs_board == "BRD2703A" || silabs_board == "BRD4319A" ) {
show_qr_code = false
disable_lcd = true
}
Expand Down
3 changes: 2 additions & 1 deletion examples/light-switch-app/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ if (chip_enable_wifi) {

# ThunderBoards, Explorer Kit and MGM240L do not support LCD (No LCD)
if (silabs_board == "BRD4166A" || silabs_board == "BRD2601B" ||
silabs_board == "BRD2703A" || silabs_board == "BRD4319A") {
silabs_board == "BRD2703A" || silabs_board == "BRD4319A" ||
silabs_board == "BRD2704A") {
show_qr_code = false
disable_lcd = true
}
Expand Down
6 changes: 6 additions & 0 deletions examples/light-switch-app/efr32/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@
#include "AppEvent.h"
#include "BaseApplication.h"
#include "FreeRTOS.h"

#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT
#include "sl_simple_button_instances.h"
#endif // SL_CATALOG_SIMPLE_BUTTON_PRESENT

#include "timers.h" // provides FreeRTOS timer support
#include <app/clusters/identify-server/identify-server.h>
#include <ble/BLEEndPoint.h>
Expand Down Expand Up @@ -69,6 +73,7 @@ class AppTask : public BaseApplication

CHIP_ERROR StartAppTask();

#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT
/**
* @brief Event handler when a button is pressed
* Function posts an event for button processing
Expand All @@ -78,6 +83,7 @@ class AppTask : public BaseApplication
* SL_SIMPLE_BUTTON_RELEASED or SL_SIMPLE_BUTTON_DISABLED
*/
void ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAction) override;
#endif // #ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT

/**
* @brief Callback called by the identify-server when an identify command is received
Expand Down
7 changes: 4 additions & 3 deletions examples/light-switch-app/efr32/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,10 @@
/**********************************************************
* Defines and Constants
*********************************************************/

#define SYSTEM_STATE_LED &sl_led_led0

#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT
#define APP_FUNCTION_BUTTON &sl_button_btn0
#define APP_LIGHT_SWITCH &sl_button_btn1
#endif // SL_CATALOG_SIMPLE_BUTTON_PRESENT

using namespace chip;
using namespace ::chip::DeviceLayer;
Expand Down Expand Up @@ -249,6 +248,7 @@ void AppTask::SwitchActionEventHandler(AppEvent * aEvent)
}
}

#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT
void AppTask::ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAction)
{
if (buttonHandle == NULL)
Expand All @@ -271,3 +271,4 @@ void AppTask::ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAc
sAppTask.PostEvent(&button_event);
}
}
#endif // SL_CATALOG_SIMPLE_BUTTON_PRESENT
6 changes: 6 additions & 0 deletions examples/light-switch-app/efr32/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@

#include "AppConfig.h"
#include "init_efrPlatform.h"

#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT
#include "sl_simple_button_instances.h"
#endif // SL_CATALOG_SIMPLE_BUTTON_PRESENT

#include "sl_system_kernel.h"
#include <DeviceInfoProviderImpl.h>
#include <app/server/Server.h>
Expand Down Expand Up @@ -78,7 +82,9 @@ int main(void)
appError(CHIP_ERROR_INTERNAL);
}

#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT
void sl_button_on_change(const sl_button_t * handle)
{
AppTask::GetAppTask().ButtonEventHandler(handle, sl_button_get_state(handle));
}
#endif // SL_CATALOG_SIMPLE_BUTTON_PRESENT
3 changes: 2 additions & 1 deletion examples/lighting-app/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ if (chip_enable_wifi) {

# ThunderBoards, Explorer Kit and MGM240L do not support LCD (No LCD)
if (silabs_board == "BRD4166A" || silabs_board == "BRD2601B" ||
silabs_board == "BRD2703A" || silabs_board == "BRD4319A") {
silabs_board == "BRD2703A" || silabs_board == "BRD4319A" ||
silabs_board == "BRD2704A") {
show_qr_code = false
disable_lcd = true
}
Expand Down
8 changes: 6 additions & 2 deletions examples/lighting-app/efr32/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@
#include "BaseApplication.h"
#include "FreeRTOS.h"
#include "LightingManager.h"

#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT
#include "sl_simple_button_instances.h"
#endif // SL_CATALOG_SIMPLE_BUTTON_PRESENT

#include "timers.h" // provides FreeRTOS timer support
#include <app/clusters/identify-server/identify-server.h>
#include <ble/BLEEndPoint.h>
Expand Down Expand Up @@ -69,7 +73,7 @@ class AppTask : public BaseApplication
static void AppTaskMain(void * pvParameter);

CHIP_ERROR StartAppTask();

#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT
/**
* @brief Event handler when a button is pressed
* Function posts an event for button processing
Expand All @@ -79,7 +83,7 @@ class AppTask : public BaseApplication
* SL_SIMPLE_BUTTON_RELEASED or SL_SIMPLE_BUTTON_DISABLED
*/
void ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAction) override;

#endif // SL_CATALOG_SIMPLE_BUTTON_PRESENT
/**
* @brief Callback called by the identify-server when an identify command is received
*
Expand Down
19 changes: 13 additions & 6 deletions examples/lighting-app/efr32/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,26 @@
#include <platform/CHIPDeviceLayer.h>

#ifdef ENABLE_WSTK_LEDS

#define SYSTEM_STATE_LED &sl_led_led0
#ifdef SL_CATALOG_LED1_PRESENT
#define LIGHT_LED &sl_led_led1
#endif // SL_CATALOG_LED1_PRESENT
#endif // ENABLE_WSTK_LEDS

#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT
#define APP_FUNCTION_BUTTON &sl_button_btn0
#define APP_LIGHT_SWITCH &sl_button_btn1
#endif // SL_CATALOG_SIMPLE_BUTTON_PRESENT

using namespace chip;
using namespace ::chip::DeviceLayer;

namespace {

#ifdef ENABLE_WSTK_LEDS
#if defined(ENABLE_WSTK_LEDS) && defined(SL_CATALOG_LED1_PRESENT)
LEDWidget sLightLED;
#endif // ENABLE_WSTK_LEDS
#endif // ENABLE_WSTK_LEDS && SL_CATALOG_LED1_PRESENT

EmberAfIdentifyEffectIdentifier sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT;

Expand Down Expand Up @@ -154,10 +159,10 @@ CHIP_ERROR AppTask::Init()

LightMgr().SetCallbacks(ActionInitiated, ActionCompleted);

#ifdef ENABLE_WSTK_LEDS
#if defined(ENABLE_WSTK_LEDS) && defined(SL_CATALOG_LED1_PRESENT)
sLightLED.Init(LIGHT_LED);
sLightLED.Set(LightMgr().IsLightOn());
#endif // ENABLE_WSTK_LEDS
#endif // ENABLE_WSTK_LEDS && SL_CATALOG_LED1_PRESENT

return err;
}
Expand Down Expand Up @@ -247,6 +252,7 @@ void AppTask::LightActionEventHandler(AppEvent * aEvent)
}
}

#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT
void AppTask::ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAction)
{
if (buttonHandle == NULL)
Expand All @@ -269,16 +275,17 @@ void AppTask::ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAc
sAppTask.PostEvent(&button_event);
}
}
#endif // SL_CATALOG_SIMPLE_BUTTON_PRESENT

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")

#ifdef ENABLE_WSTK_LEDS
#if defined(ENABLE_WSTK_LEDS) && defined(SL_CATALOG_LED1_PRESENT)
sLightLED.Set(lightOn);
#endif // ENABLE_WSTK_LEDS
#endif // ENABLE_WSTK_LEDS && SL_CATALOG_LED1_PRESENT

#ifdef DISPLAY_ENABLED
sAppTask.GetLCD().WriteDemoUI(lightOn);
Expand Down
8 changes: 7 additions & 1 deletion examples/lighting-app/efr32/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@

#include "AppConfig.h"
#include "init_efrPlatform.h"

#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT
#include "sl_simple_button_instances.h"
#endif // SL_CATALOG_SIMPLE_BUTTON_PRESENT

#include "sl_system_kernel.h"
#include <DeviceInfoProviderImpl.h>
#include <app/server/Server.h>
Expand All @@ -33,7 +37,7 @@
#include <credentials/examples/DeviceAttestationCredsExample.h>
#endif

#define BLE_DEV_NAME "SiLabs-Light"
#define BLE_DEV_NAME "BRD2704A-SiLabs-Light"
using namespace ::chip;
using namespace ::chip::Inet;
using namespace ::chip::DeviceLayer;
Expand Down Expand Up @@ -78,7 +82,9 @@ int main(void)
appError(CHIP_ERROR_INTERNAL);
}

#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT
void sl_button_on_change(const sl_button_t * handle)
{
AppTask::GetAppTask().ButtonEventHandler(handle, sl_button_get_state(handle));
}
#endif // SL_CATALOG_SIMPLE_BUTTON_PRESENT
3 changes: 2 additions & 1 deletion examples/lock-app/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ if (chip_enable_wifi) {

# ThunderBoards, Explorer Kit and MGM240L do not support LCD (No LCD)
if (silabs_board == "BRD4166A" || silabs_board == "BRD2601B" ||
silabs_board == "BRD2703A" || silabs_board == "BRD4319A") {
silabs_board == "BRD2703A" || silabs_board == "BRD4319A" ||
silabs_board == "BRD2704A") {
show_qr_code = false
disable_lcd = true
}
Expand Down
8 changes: 8 additions & 0 deletions examples/lock-app/efr32/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@
#include "BaseApplication.h"
#include "FreeRTOS.h"
#include "LockManager.h"

#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT
#include "sl_simple_button_instances.h"
#endif // SL_CATALOG_SIMPLE_BUTTON_PRESENT

#include "timers.h" // provides FreeRTOS timer support
#include <app/clusters/identify-server/identify-server.h>
#include <ble/BLEEndPoint.h>
Expand Down Expand Up @@ -75,6 +79,7 @@ class AppTask : public BaseApplication
static void ActionInitiated(LockManager::Action_t aAction, int32_t aActor);
static void ActionCompleted(LockManager::Action_t aAction);

#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT
/**
* @brief Event handler when a button is pressed
* Function posts an event for button processing
Expand All @@ -84,6 +89,7 @@ class AppTask : public BaseApplication
* SL_SIMPLE_BUTTON_RELEASED or SL_SIMPLE_BUTTON_DISABLED
*/
void ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAction) override;
#endif

/**
* @brief Callback called by the identify-server when an identify command is received
Expand All @@ -109,6 +115,7 @@ class AppTask : public BaseApplication
*/
CHIP_ERROR Init();

#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT
/**
* @brief PB0 Button event processing function
* Press and hold will trigger a factory reset timer start
Expand All @@ -125,6 +132,7 @@ class AppTask : public BaseApplication
* @param aEvent button event being processed
*/
static void SwitchActionEventHandler(AppEvent * aEvent);
#endif // SL_CATALOG_SIMPLE_BUTTON_PRESENT

/**
* @brief Update Cluster State
Expand Down
15 changes: 10 additions & 5 deletions examples/lock-app/efr32/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@

#ifdef ENABLE_WSTK_LEDS
#define SYSTEM_STATE_LED &sl_led_led0

#ifdef SL_CATALOG_LED1_PRESENT
#define LOCK_STATE_LED &sl_led_led1
#endif // SL_CATALOG_LED1_PRESENT
#endif // ENABLE_WSTK_LEDS

#define APP_FUNCTION_BUTTON &sl_button_btn0
Expand All @@ -73,7 +76,7 @@ using namespace ::chip::DeviceLayer::Internal;
using namespace EFR32DoorLock::LockInitParams;

namespace {
#ifdef ENABLE_WSTK_LEDS
#if defined(ENABLE_WSTK_LEDS) && defined(SL_CATALOG_LED1_PRESENT)
LEDWidget sLockLED;
#endif // ENABLE_WSTK_LEDS

Expand Down Expand Up @@ -235,11 +238,11 @@ CHIP_ERROR AppTask::Init()

LockMgr().SetCallbacks(ActionInitiated, ActionCompleted);

#ifdef ENABLE_WSTK_LEDS
#if defined(ENABLE_WSTK_LEDS) && defined(SL_CATALOG_LED1_PRESENT)
// Initialize LEDs
sLockLED.Init(LOCK_STATE_LED);
sLockLED.Set(state.Value() == DlLockState::kUnlocked);
#endif // ENABLE_WSTK_LEDS
#endif // ENABLE_WSTK_LEDS && SL_CATALOG_LED1_PRESENT

chip::DeviceLayer::PlatformMgr().ScheduleWork(UpdateClusterState, reinterpret_cast<intptr_t>(nullptr));

Expand Down Expand Up @@ -343,6 +346,7 @@ void AppTask::LockActionEventHandler(AppEvent * aEvent)
}
}

#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT
void AppTask::ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAction)
{
if (buttonHandle == NULL)
Expand All @@ -365,16 +369,17 @@ void AppTask::ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAc
sAppTask.PostEvent(&button_event);
}
}
#endif // SL_CATALOG_SIMPLE_BUTTON_PRESENT

void AppTask::ActionInitiated(LockManager::Action_t aAction, int32_t aActor)
{
if (aAction == LockManager::UNLOCK_ACTION || aAction == LockManager::LOCK_ACTION)
{
bool locked = (aAction == LockManager::LOCK_ACTION);
EFR32_LOG("%s Action has been initiated", (locked) ? "Lock" : "Unlock");
#ifdef ENABLE_WSTK_LEDS
#if defined(ENABLE_WSTK_LEDS) && defined(SL_CATALOG_LED1_PRESENT)
sLockLED.Set(!locked);
#endif // ENABLE_WSTK_LEDS
#endif // ENABLE_WSTK_LEDS && SL_CATALOG_LED1_PRESENT

#ifdef DISPLAY_ENABLED
sAppTask.GetLCD().WriteDemoUI(locked);
Expand Down
6 changes: 6 additions & 0 deletions examples/lock-app/efr32/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@

#include "AppConfig.h"
#include "init_efrPlatform.h"

#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT
#include "sl_simple_button_instances.h"
#endif // SL_CATALOG_SIMPLE_BUTTON_PRESENT

#include "sl_system_kernel.h"
#include <DeviceInfoProviderImpl.h>
#include <app/server/Server.h>
Expand Down Expand Up @@ -78,7 +82,9 @@ int main(void)
appError(CHIP_ERROR_INTERNAL);
}

#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT
void sl_button_on_change(const sl_button_t * handle)
{
AppTask::GetAppTask().ButtonEventHandler(handle, sl_button_get_state(handle));
}
#endif // SL_CATALOG_SIMPLE_BUTTON_PRESENT
Loading

0 comments on commit bfa08b0

Please sign in to comment.