Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Silabs] SiWx917 platform changes #23799

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 40 additions & 31 deletions examples/lighting-app/silabs/SiWx917/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import("//build_overrides/efr32_sdk.gni")
import("//build_overrides/pigweed.gni")

import("${build_root}/config/defaults.gni")
import("${efr32_sdk_build_root}/SiWx917_sdk.gni")
import("${efr32_sdk_build_root}/efr32_executable.gni")
import("${efr32_sdk_build_root}/efr32_sdk.gni")

import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni")
import("${chip_root}/src/platform/device.gni")
Expand All @@ -31,8 +31,8 @@ if (chip_enable_pw_rpc) {

assert(current_os == "freertos")

efr32_project_dir = "${chip_root}/examples/lighting-app/silabs/efr32"
examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32"
efr32_project_dir = "${chip_root}/examples/lighting-app/silabs/SiWx917"
examples_plat_dir = "${chip_root}/examples/platform/silabs/SiWx917"
examples_common_plat_dir = "${chip_root}/examples/platform/silabs"

declare_args() {
Expand All @@ -56,13 +56,19 @@ declare_args() {
sl_wfx_config_scan = true

# Disable LCD on supported devices
disable_lcd = false
disable_lcd = true

# Argument to Disable IPv4 for wifi(rs911)
chip_enable_wifi_ipv4 = false

# Argument to force enable WPA3 security on rs91x
rs91x_wpa3_only = false

#default WiFi SSID
ssid = ""

#default Wifi Password
psk = ""
}

declare_args() {
Expand All @@ -80,7 +86,7 @@ assert(!(use_wf200 && chip_enable_openthread))
if (chip_enable_wifi) {
assert(use_rs911x || use_wf200)
enable_openthread_cli = false
import("${chip_root}/src/platform/silabs/EFR32/wifi_args.gni")
import("${chip_root}/src/platform/silabs/SiWx917/wifi_args.gni")
}

# ThunderBoards, Explorer Kit and MGM240L do not support LCD (No LCD)
Expand All @@ -90,14 +96,28 @@ if (silabs_board == "BRD4166A" || silabs_board == "BRD2601B" ||
disable_lcd = true
}

defines = []

# WiFi settings
if (chip_enable_wifi) {
# disabling LCD for MG24 for wifi
if (silabs_board == "BRD4186A" || silabs_board == "BRD4187A") {
show_qr_code = false
disable_lcd = true
}
wifi_sdk_dir = "${chip_root}/src/platform/silabs/EFR32/wifi"

if (ssid != "") {
defines += [
"CHIP_ONNETWORK_PAIRING = 1",
"CHIP_WIFI_SSID = $ssid",
]
}
if (psk != "") {
assert(ssid != "", "ssid can't be null if psk is provided")
defines += [ "CHIP_WIFI_PSK = $psk" ]
}

wifi_sdk_dir = "${chip_root}/src/platform/silabs/SiWx917/wifi"
efr32_lwip_defs = [ "LWIP_NETIF_API=1" ]
if (lwip_ipv4) {
efr32_lwip_defs += [
Expand All @@ -122,13 +142,8 @@ if (chip_enable_wifi) {
efr32_lwip_defs += [ "LWIP_IPV6=0" ]
}

if (use_rs911x) {
wiseconnect_sdk_root =
"${chip_root}/third_party/silabs/wiseconnect-wifi-bt-sdk"
import("${examples_plat_dir}/rs911x/rs911x.gni")
} else {
import("${examples_plat_dir}/wf200/wf200.gni")
}
wiseconnect_sdk_root = "${chip_root}/third_party/silabs/wisemcu-wifi-bt-sdk"
import("${examples_plat_dir}/SiWx917/rs911x.gni")
}

efr32_sdk("sdk") {
Expand All @@ -138,22 +153,18 @@ efr32_sdk("sdk") {
]

include_dirs = [
"${chip_root}/src/platform/silabs/EFR32",
"${chip_root}/src/platform/silabs/SiWx917",
"${efr32_project_dir}/include",
"${examples_plat_dir}",
"${chip_root}/src/lib",
"${examples_common_plat_dir}",
]

defines = [
defines += [
"BOARD_ID=${silabs_board}",
"OTA_PERIODIC_TIMEOUT=${OTA_periodic_query_timeout}",
]

if (enable_heap_monitoring) {
defines += [ "HEAP_MONITORING" ]
}

if (chip_enable_pw_rpc) {
defines += [
"HAL_VCOM_ENABLE=1",
Expand Down Expand Up @@ -196,22 +207,23 @@ efr32_executable("lighting_app") {
sources = [
"${examples_common_plat_dir}/heap_4_silabs.c",
"${examples_plat_dir}/BaseApplication.cpp",
"${examples_plat_dir}/efr32_utils.cpp",
"${examples_plat_dir}/init_efrPlatform.cpp",
"${examples_plat_dir}/init_ccpPlatform.cpp",
"${examples_plat_dir}/matter_config.cpp",
"${examples_plat_dir}/siwx917_utils.cpp",
"src/AppTask.cpp",
"src/LightingManager.cpp",
"src/ZclCallbacks.cpp",
"src/main.cpp",
]

if (use_wstk_leds) {
sources += [ "${examples_plat_dir}/LEDWidget.cpp" ]
# TODO: Commentting for CCP till the bring up of this is done
#sources += [ "${examples_plat_dir}/LEDWidget.cpp" ]
}

if (chip_enable_pw_rpc || chip_build_libshell || enable_openthread_cli ||
use_wf200 || use_rs911x) {
sources += [ "${examples_plat_dir}/uart.cpp" ]
if (chip_enable_pw_rpc || chip_build_libshell || use_rs911x) {
# TODO: Commentting for CCP till the bring up of this is done
#sources += [ "${examples_plat_dir}/uart.cpp" ]
}

deps = [
Expand All @@ -231,10 +243,7 @@ efr32_executable("lighting_app") {
]
}

if (chip_enable_ota_requestor) {
defines += [ "EFR32_OTA_ENABLED" ]
sources += [ "${examples_plat_dir}/OTAConfig.cpp" ]
}
#TODO: OTA should be added

# WiFi Settings
if (chip_enable_wifi) {
Expand Down Expand Up @@ -326,7 +335,7 @@ efr32_executable("lighting_app") {
"${chip_root}/examples/common/pigweed:lighting_service.nanopb_rpc",
"${chip_root}/examples/common/pigweed:ot_cli_service.nanopb_rpc",
"${chip_root}/examples/common/pigweed:thread_service.nanopb_rpc",
"${examples_plat_dir}/pw_sys_io:pw_sys_io_efr32",
"${examples_plat_dir}/pw_sys_io:pw_sys_io_siwx917",
]

deps += pw_build_LINK_DEPS
Expand Down Expand Up @@ -365,7 +374,7 @@ efr32_executable("lighting_app") {

# Attestation Credentials
if (chip_build_platform_attestation_credentials_provider) {
deps += [ "${examples_plat_dir}:efr32-attestation-credentials" ]
deps += [ "${examples_plat_dir}:siwx917-attestation-credentials" ]
}

# Factory Data Provider
Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/silabs/SiWx917/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import("//build_overrides/chip.gni")
import("//build_overrides/pigweed.gni")
import("${chip_root}/config/standalone/args.gni")
import("${chip_root}/src/platform/silabs/EFR32/args.gni")
import("${chip_root}/src/platform/silabs/SiWx917/args.gni")

efr32_sdk_target = get_label_info(":sdk", "label_no_toolchain")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import("${chip_root}/config/standalone/args.gni")

efr32_sdk_target = get_label_info(":sdk", "label_no_toolchain")
chip_enable_openthread = false
import("${chip_root}/src/platform/silabs/EFR32/wifi_args.gni")
import("${chip_root}/src/platform/silabs/SiWx917/wifi_args.gni")

chip_enable_ota_requestor = true

Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/silabs/SiWx917/include/AppConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#pragma once

#include "efr32_utils.h"
#include "siwx917_utils.h"

// ---- Lighting Example App Config ----

Expand Down
11 changes: 0 additions & 11 deletions examples/lighting-app/silabs/SiWx917/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include "BaseApplication.h"
#include "FreeRTOS.h"
#include "LightingManager.h"
#include "sl_simple_button_instances.h"
#include "timers.h" // provides FreeRTOS timer support
#include <app/clusters/identify-server/identify-server.h>
#include <ble/BLEEndPoint.h>
Expand Down Expand Up @@ -70,16 +69,6 @@ class AppTask : public BaseApplication

CHIP_ERROR StartAppTask();

/**
* @brief Event handler when a button is pressed
* Function posts an event for button processing
*
* @param buttonHandle APP_LIGHT_SWITCH or APP_FUNCTION_BUTTON
* @param btnAction button action - SL_SIMPLE_BUTTON_PRESSED,
* SL_SIMPLE_BUTTON_RELEASED or SL_SIMPLE_BUTTON_DISABLED
*/
void ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAction) override;

/**
* @brief Callback called by the identify-server when an identify command is received
*
Expand Down
62 changes: 9 additions & 53 deletions examples/lighting-app/silabs/SiWx917/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@
#include "AppConfig.h"
#include "AppEvent.h"

#ifdef ENABLE_WSTK_LEDS
#include "LEDWidget.h"
#include "sl_simple_led_instances.h"
#endif // ENABLE_WSTK_LEDS

#include <app-common/zap-generated/attribute-id.h>
#include <app-common/zap-generated/attribute-type.h>
#include <app-common/zap-generated/cluster-id.h>
Expand All @@ -44,11 +39,6 @@

#include <platform/CHIPDeviceLayer.h>

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

#define APP_FUNCTION_BUTTON &sl_button_btn0
#define APP_LIGHT_SWITCH &sl_button_btn1

Expand All @@ -57,10 +47,6 @@ using namespace ::chip::DeviceLayer;

namespace {

#ifdef ENABLE_WSTK_LEDS
LEDWidget sLightLED;
#endif // ENABLE_WSTK_LEDS

EmberAfIdentifyEffectIdentifier sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT;

/**********************************************************
Expand Down Expand Up @@ -145,19 +131,16 @@ CHIP_ERROR AppTask::Init()
appError(err);
}

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

LightMgr().SetCallbacks(ActionInitiated, ActionCompleted);
/* TODO
err = LightMgr().Init();
if (err != CHIP_NO_ERROR)
{
SILABS_LOG("LightMgr::Init() failed");
appError(err);
}

#ifdef ENABLE_WSTK_LEDS
sLightLED.Init(LIGHT_LED);
sLightLED.Set(LightMgr().IsLightOn());
#endif // ENABLE_WSTK_LEDS
LightMgr().SetCallbacks(ActionInitiated, ActionCompleted);
*/

return err;
}
Expand Down Expand Up @@ -247,39 +230,12 @@ void AppTask::LightActionEventHandler(AppEvent * aEvent)
}
}

void AppTask::ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAction)
{
if (buttonHandle == NULL)
{
return;
}

AppEvent button_event = {};
button_event.Type = AppEvent::kEventType_Button;
button_event.ButtonEvent.Action = btnAction;

if (buttonHandle == APP_LIGHT_SWITCH && btnAction == SL_SIMPLE_BUTTON_PRESSED)
{
button_event.Handler = LightActionEventHandler;
sAppTask.PostEvent(&button_event);
}
else if (buttonHandle == APP_FUNCTION_BUTTON)
{
button_event.Handler = BaseApplication::ButtonHandler;
sAppTask.PostEvent(&button_event);
}
}

void AppTask::ActionInitiated(LightingManager::Action_t aAction, int32_t aActor)
{
// Action initiated, update the light led
bool lightOn = aAction == LightingManager::ON_ACTION;
SILABS_LOG("Turning light %s", (lightOn) ? "On" : "Off")

#ifdef ENABLE_WSTK_LEDS
sLightLED.Set(lightOn);
#endif // ENABLE_WSTK_LEDS

#ifdef DISPLAY_ENABLED
sAppTask.GetLCD().WriteDemoUI(lightOn);
#endif
Expand Down
24 changes: 11 additions & 13 deletions examples/lighting-app/silabs/SiWx917/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@
#include <AppTask.h>

#include "AppConfig.h"
#include "init_efrPlatform.h"
#include "sl_simple_button_instances.h"
#include "sl_system_kernel.h"
#include "init_ccpPlatform.h"

#include <DeviceInfoProviderImpl.h>
#include <app/server/Server.h>
#include <credentials/DeviceAttestationCredsProvider.h>
#include <matter_config.h>
#ifdef EFR32_ATTESTATION_CREDENTIALS
#ifdef SI917_ATTESTATION_CREDENTIALS
#include <examples/platform/silabs/SilabsDeviceAttestationCreds.h>
#else
#include <credentials/examples/DeviceAttestationCredsExample.h>
Expand All @@ -49,16 +48,18 @@ static chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider;
// ================================================================================
int main(void)
{
init_efrPlatform();
if (EFR32MatterConfig::InitMatter(BLE_DEV_NAME) != CHIP_NO_ERROR)
init_ccpPlatform();
if (SI917MatterConfig::InitMatter(BLE_DEV_NAME) != CHIP_NO_ERROR)
{
appError(CHIP_ERROR_INTERNAL);
}

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

chip::DeviceLayer::PlatformMgr().LockChipStack();
// Initialize device attestation config
#ifdef EFR32_ATTESTATION_CREDENTIALS
#ifdef SI917_ATTESTATION_CREDENTIALS
SetDeviceAttestationCredentialsProvider(Silabs::GetSilabsDacProvider());
#else
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
Expand All @@ -67,18 +68,15 @@ int main(void)

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

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

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

void sl_button_on_change(const sl_button_t * handle)
{
AppTask::GetAppTask().ButtonEventHandler(handle, sl_button_get_state(handle));
}
Loading