Skip to content

Commit

Permalink
Merge branch 'master' into jds
Browse files Browse the repository at this point in the history
  • Loading branch information
jonsmirl authored Aug 19, 2022
2 parents f488b99 + 1f83af0 commit 96db248
Show file tree
Hide file tree
Showing 63 changed files with 1,497 additions and 592 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/examples-efr32.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
- name: Build example EFR32 Lighting App for BRD4161A with RPCs
timeout-minutes: 15
run: |
scripts/examples/gn_efr32_example.sh examples/lighting-app/efr32/ out/lighting_app_debug_rpc BRD4161A \
scripts/examples/gn_efr32_example.sh examples/lighting-app/efr32/ out/lighting_app_debug_rpc BRD4161A "is_debug=false" \
'import("//with_pw_rpc.gni")'
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py efr32 BRD4161A+rpc lighting-app \
out/lighting_app_debug_rpc/BRD4161A/chip-efr32-lighting-example.out /tmp/bloat_reports/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3850,7 +3850,14 @@ server cluster FaultInjection = 4294048774 {
BOOLEAN takeMutex = 4;
}

request struct FailRandomlyAtFaultRequest {
FaultType type = 0;
INT32U id = 1;
INT8U percentage = 2;
}

command access(invoke: manage) FailAtFault(FailAtFaultRequest): DefaultSuccess = 0;
command access(invoke: manage) FailRandomlyAtFault(FailRandomlyAtFaultRequest): DefaultSuccess = 1;
}

endpoint 0 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8461,6 +8461,14 @@
"source": "client",
"incoming": 1,
"outgoing": 1
},
{
"name": "FailRandomlyAtFault",
"code": 1,
"mfgCode": null,
"source": "client",
"incoming": 1,
"outgoing": 0
}
],
"attributes": [
Expand Down
6 changes: 5 additions & 1 deletion examples/chef/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,11 @@ efr32_executable("chef_app") {
}

if (!disable_lcd) {
sources += [ "${examples_plat_dir}/display/lcd.c" ]
sources += [
"${examples_plat_dir}/display/demo-ui.c",
"${examples_plat_dir}/display/lcd.cpp",
]
include_dirs += [ "${examples_plat_dir}/display" ]
defines += [ "DISPLAY_ENABLED" ]
if (show_qr_code) {
defines += [ "QR_CODE_ENABLED" ]
Expand Down
11 changes: 9 additions & 2 deletions examples/light-switch-app/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,15 @@ efr32_executable("light_switch_app") {
}

if (!disable_lcd) {
sources += [ "${examples_plat_dir}/display/lcd.c" ]
defines += [ "DISPLAY_ENABLED" ]
sources += [
"${examples_plat_dir}/display/demo-ui.c",
"${examples_plat_dir}/display/lcd.cpp",
]
include_dirs += [ "${examples_plat_dir}/display" ]
defines += [
"DISPLAY_ENABLED",
"IS_DEMO_SWITCH=1",
]
if (show_qr_code) {
defines += [ "QR_CODE_ENABLED" ]
deps += [ "${chip_root}/examples/common/QRCode" ]
Expand Down
21 changes: 20 additions & 1 deletion examples/light-switch-app/efr32/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ namespace {

EmberAfIdentifyEffectIdentifier sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT;

bool mCurrentButtonState = false;

/**********************************************************
* Identify Callbacks
*********************************************************/
Expand Down Expand Up @@ -146,6 +148,9 @@ AppTask AppTask::sAppTask;
CHIP_ERROR AppTask::Init()
{
CHIP_ERROR err = CHIP_NO_ERROR;
#ifdef DISPLAY_ENABLED
GetLCD().Init((uint8_t *) "Light Switch");
#endif

err = BaseApplication::Init(&gIdentify);
if (err != CHIP_NO_ERROR)
Expand Down Expand Up @@ -221,9 +226,23 @@ void AppTask::SwitchActionEventHandler(AppEvent * aEvent)
if (aEvent->Type == AppEvent::kEventType_Button)
{
BindingCommandData * data = Platform::New<BindingCommandData>();
data->commandId = chip::app::Clusters::OnOff::Commands::Toggle::Id;
data->clusterId = chip::app::Clusters::OnOff::Id;

if (mCurrentButtonState)
{
mCurrentButtonState = false;
data->commandId = chip::app::Clusters::OnOff::Commands::Off::Id;
}
else
{
data->commandId = chip::app::Clusters::OnOff::Commands::On::Id;
mCurrentButtonState = true;
}

#ifdef DISPLAY_ENABLED
sAppTask.GetLCD().WriteDemoUI(mCurrentButtonState);
#endif

DeviceLayer::PlatformMgr().ScheduleWork(SwitchWorkerFunction, reinterpret_cast<intptr_t>(data));
}
}
Expand Down
12 changes: 10 additions & 2 deletions examples/lighting-app/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,16 @@ efr32_executable("lighting_app") {
}

if (!disable_lcd) {
sources += [ "${examples_plat_dir}/display/lcd.c" ]
defines += [ "DISPLAY_ENABLED" ]
sources += [
"${examples_plat_dir}/display/demo-ui.c",
"${examples_plat_dir}/display/lcd.cpp",
]

include_dirs += [ "${examples_plat_dir}/display" ]
defines += [
"DISPLAY_ENABLED",
"IS_DEMO_LIGHT=1",
]
if (show_qr_code) {
defines += [ "QR_CODE_ENABLED" ]

Expand Down
27 changes: 11 additions & 16 deletions examples/lighting-app/efr32/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,7 @@
#include "AppConfig.h"
#include "AppEvent.h"
#include "LEDWidget.h"
#ifdef DISPLAY_ENABLED
#include "lcd.h"
#ifdef QR_CODE_ENABLED
#include "qrcodegen.h"
#endif // QR_CODE_ENABLED
#endif // DISPLAY_ENABLED

#include "sl_simple_led_instances.h"
#include <app-common/zap-generated/attribute-id.h>
#include <app-common/zap-generated/attribute-type.h>
Expand Down Expand Up @@ -132,6 +127,9 @@ AppTask AppTask::sAppTask;
CHIP_ERROR AppTask::Init()
{
CHIP_ERROR err = CHIP_NO_ERROR;
#ifdef DISPLAY_ENABLED
GetLCD().Init((uint8_t *) "Lighting-App");
#endif

err = BaseApplication::Init(&gIdentify);
if (err != CHIP_NO_ERROR)
Expand Down Expand Up @@ -266,16 +264,13 @@ void AppTask::ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAc
void AppTask::ActionInitiated(LightingManager::Action_t aAction, int32_t aActor)
{
// Action initiated, update the light led
if (aAction == LightingManager::ON_ACTION)
{
EFR32_LOG("Turning light ON")
sLightLED.Set(true);
}
else if (aAction == LightingManager::OFF_ACTION)
{
EFR32_LOG("Turning light OFF")
sLightLED.Set(false);
}
bool lightOn = aAction == LightingManager::ON_ACTION;
EFR32_LOG("Turning light %s", (lightOn) ? "On" : "Off")
sLightLED.Set(lightOn);

#ifdef DISPLAY_ENABLED
sAppTask.GetLCD().WriteDemoUI(lightOn);
#endif

if (aActor == AppEvent::kEventType_Button)
{
Expand Down
11 changes: 9 additions & 2 deletions examples/lock-app/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,15 @@ efr32_executable("lock_app") {
}

if (!disable_lcd) {
sources += [ "${examples_plat_dir}/display/lcd.c" ]
defines += [ "DISPLAY_ENABLED" ]
sources += [
"${examples_plat_dir}/display/demo-ui.c",
"${examples_plat_dir}/display/lcd.cpp",
]
include_dirs += [ "${examples_plat_dir}/display" ]
defines += [
"DISPLAY_ENABLED",
"IS_DEMO_LOCK=1",
]
if (show_qr_code) {
defines += [ "QR_CODE_ENABLED" ]
deps += [ "${chip_root}/examples/common/QRCode" ]
Expand Down
20 changes: 11 additions & 9 deletions examples/lock-app/efr32/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ CHIP_ERROR AppTask::Init()
{
CHIP_ERROR err = CHIP_NO_ERROR;

#ifdef DISPLAY_ENABLED
GetLCD().Init((uint8_t *) "Lock-App", true);
#endif

err = BaseApplication::Init(&gIdentify);
if (err != CHIP_NO_ERROR)
{
Expand Down Expand Up @@ -354,16 +358,14 @@ void AppTask::ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAc

void AppTask::ActionInitiated(LockManager::Action_t aAction, int32_t aActor)
{
// Action initiated, update the light led
if (aAction == LockManager::LOCK_ACTION)
if (aAction == LockManager::UNLOCK_ACTION || aAction == LockManager::LOCK_ACTION)
{
EFR32_LOG("Lock Action has been initiated")
sLockLED.Set(false);
}
else if (aAction == LockManager::UNLOCK_ACTION)
{
EFR32_LOG("Unlock Action has been initiated")
sLockLED.Set(true);
bool locked = (aAction == LockManager::LOCK_ACTION);
EFR32_LOG("%s Action has been initiated", (locked) ? "Lock" : "Unlock");
sLockLED.Set(!locked);
#ifdef DISPLAY_ENABLED
sAppTask.GetLCD().WriteDemoUI(locked);
#endif
}

if (aActor == AppEvent::kEventType_Button)
Expand Down
17 changes: 16 additions & 1 deletion examples/platform/efr32/BaseApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ bool mFunctionTimerActive;

Identify * gIdentifyptr = nullptr;

#ifdef DISPLAY_ENABLED
SilabsLCD slLCD;
#endif

} // namespace

/**********************************************************
Expand Down Expand Up @@ -214,7 +218,8 @@ CHIP_ERROR BaseApplication::Init(Identify * identifyObj)

if (GetQRCode(QRCode, chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE)) == CHIP_NO_ERROR)
{
LCDWriteQRCode((uint8_t *) QRCode.data());
slLCD.SetQRCode((uint8_t *) QRCode.data(), QRCode.size());
slLCD.ShowQRCode(true, true);
}
else
{
Expand Down Expand Up @@ -386,6 +391,9 @@ void BaseApplication::ButtonHandler(AppEvent * aEvent)
CancelFunctionTimer();
mFunction = kFunction_NoneSelected;

// TOGGLE QRCode/LCD demo UI
slLCD.ToggleQRCode();

#ifdef SL_WIFI
if (!ConnectivityMgr().IsWiFiStationProvisioned())
#else
Expand Down Expand Up @@ -469,6 +477,13 @@ void BaseApplication::LightTimerEventHandler(TimerHandle_t xTimer)
LightEventHandler();
}

#ifdef DISPLAY_ENABLED
SilabsLCD & BaseApplication::GetLCD(void)
{
return slLCD;
}
#endif

void BaseApplication::PostEvent(const AppEvent * aEvent)
{
if (sAppEventQueue != NULL)
Expand Down
18 changes: 16 additions & 2 deletions examples/platform/efr32/BaseApplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@
#include <lib/core/CHIPError.h>
#include <platform/CHIPDeviceLayer.h>

#ifdef DISPLAY_ENABLED
#include "demo-ui.h"
#include "lcd.h"
#ifdef QR_CODE_ENABLED
#include "qrcodegen.h"
#endif // QR_CODE_ENABLED
#endif // DISPLAY_ENABLED

/**********************************************************
* Defines
*********************************************************/
Expand Down Expand Up @@ -73,6 +81,13 @@ class BaseApplication
*/
static void PostEvent(const AppEvent * event);

#ifdef DISPLAY_ENABLED
/**
* @brief Return LCD object
*/
static SilabsLCD & GetLCD(void);
#endif

/**
* @brief Event handler when a button is pressed
* Function posts an event for button processing
Expand Down Expand Up @@ -165,8 +180,7 @@ class BaseApplication
static void LightEventHandler();

/**********************************************************
* Private Attributes declaration
* Protected Attributes declaration
*********************************************************/

bool mSyncClusterToButtonAction;
};
2 changes: 1 addition & 1 deletion examples/platform/efr32/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */

#ifndef configTOTAL_HEAP_SIZE
#ifdef SL_WIFI
#define configTOTAL_HEAP_SIZE ((size_t)(30 * 1024))
#define configTOTAL_HEAP_SIZE ((size_t)(34 * 1024))
#else
#define configTOTAL_HEAP_SIZE ((size_t)(20 * 1024))
#endif
Expand Down
Loading

0 comments on commit 96db248

Please sign in to comment.