Skip to content

Commit 6d6d733

Browse files
Silabs wifi - chip support for EFR32 - Using WF200 and RS911x (#13193)
* EFR32+SiLabs WiFi port - using lock app * Changed Wiseconnect SDK to relative symbolic link * Moved WiFi stuff to efr32_sdk/repo/matter/wifi * added Lighting app to silabs_wifi * Silabs_wifi Lighting-app removed some junk files * Update for building with scripts/examples/gn_efr32_example.sh * Rebased to master - Fixes to AppTask.cpp+BUILD.gn * Merged Thread and WiFi apps (Lighting and Windows) into examples/xxx-app/efr32 * Updated lock-app/efr32 to include WiFi build * Fixes to ifdef's in lock-app for efr32 * Removed examples/xx-app/silabs_wifi. Merged into examples/xx-app/efr32 * updated build-script for efr32 to use wifi * WiFi fixes to initialize RS911X for EFR32 * Update for WiFi port to sync with SiLabs work * WiFi - Added saving SSID/PSK/Security * Cleaned up comments in BUILD.gn * Restyled by whitespace * Restyled by clang-format * Restyled by gn * Restyled by shellharden * Restyled by shfmt * Restyled by clang-format * include file reference was changed to <lib/support> * Added WF200 files and changed Defines to match master * Fixed issue with build script that does not handle ARG3/4 Co-authored-by: Restyled.io <commits@restyled.io>
1 parent 4ac926a commit 6d6d733

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2230
-309
lines changed

.github/workflows/examples-efr32.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ jobs:
8282
timeout-minutes: 10
8383
run: |
8484
scripts/examples/gn_efr32_example.sh examples/lighting-app/efr32/ out/lighting_app_debug_rpc BRD4161A \
85-
-args='import("//with_pw_rpc.gni")'
85+
'import("//with_pw_rpc.gni")'
8686
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py efr32 BRD4161A+rpc lighting-app \
8787
out/lighting_app_debug_rpc/BRD4161A/chip-efr32-lighting-example.out /tmp/bloat_reports/
8888
- name: Build example EFR32 Window Covering for BRD4161A

config/efr32/toolchain/BUILD.gn

+6
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,9 @@ arm_toolchain("efr32_window_app") {
3737
import("${chip_root}/examples/window-app/efr32/args.gni")
3838
}
3939
}
40+
arm_toolchain("rs911x_lock_app") {
41+
toolchain_args = {
42+
current_os = "freertos"
43+
import("${chip_root}/examples/lock-app/rs911x/args.gni")
44+
}
45+
}

examples/lighting-app/efr32/BUILD.gn

+94-16
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ declare_args() {
4444

4545
# Monitor & log memory usage at runtime.
4646
enable_heap_monitoring = false
47+
48+
# Wifi related stuff - they are overriden by gn -args="use_wf200=true"
49+
use_wf200 = false
50+
use_rs911x = false
51+
use_rs911x_sockets = false
52+
sl_wfx_config_softap = false
53+
sl_wfx_config_scan = false
4754
}
4855

4956
show_qr_code = true
@@ -52,6 +59,26 @@ show_qr_code = true
5259
if (efr32_board == "BRD4166A" || efr32_board == "BRD4180A") {
5360
show_qr_code = false
5461
}
62+
if (use_rs911x || use_wf200) {
63+
wifi_sdk_dir = "${chip_root}/third_party/efr32_sdk/repo/matter/wifi"
64+
if (use_rs911x) {
65+
wiseconnect_sdk_root = "${chip_root}/third_party/wiseconnect-wifi-bt-sdk"
66+
import("${wifi_sdk_dir}/rs911x/rs911x.gni")
67+
} else {
68+
import("${wifi_sdk_dir}/wf200/wf200.gni")
69+
}
70+
}
71+
efr32_lwip_defs = [ "LWIP_NETIF_API=1" ]
72+
if (use_rs911x || use_wf200) {
73+
efr32_lwip_defs += [
74+
"LWIP_IPV4=1",
75+
"LWIP_ARP=1",
76+
"LWIP_ICMP=1",
77+
"LWIP_DHCP=1",
78+
"LWIP_IPV6_ND=1",
79+
"LWIP_IGMP=1",
80+
]
81+
}
5582

5683
efr32_sdk("sdk") {
5784
sources = [
@@ -63,6 +90,7 @@ efr32_sdk("sdk") {
6390
"${chip_root}/src/platform/EFR32",
6491
"${efr32_project_dir}/include",
6592
"${examples_plat_dir}",
93+
"${chip_root}/src/lib",
6694
]
6795

6896
defines = [
@@ -77,10 +105,36 @@ efr32_sdk("sdk") {
77105
"PW_RPC_ENABLED",
78106
]
79107
}
108+
if (use_rs911x) {
109+
defines += rs911x_defs
110+
include_dirs += rs911x_plat_incs
111+
} else if (use_wf200) {
112+
defines += wf200_defs
113+
include_dirs += wf200_plat_incs
114+
} else {
115+
defines += [ "SL_HEAP_SIZE=20480" ]
116+
}
117+
if (use_rs911x_sockets) {
118+
include_dirs += [ "${examples_plat_dir}/wifi/rsi-sockets" ]
119+
defines += rs911x_sock_defs
120+
} else {
121+
# Using LWIP instead of the native TCP/IP stack
122+
# Thread also uses LWIP
123+
#
124+
defines += efr32_lwip_defs
125+
}
126+
if (sl_wfx_config_softap) {
127+
defines += "SL_WFX_CONFIG_SOFTAP"
128+
}
129+
if (sl_wfx_config_scan) {
130+
defines += "SL_WFX_CONFIG_SCAN"
131+
}
80132
}
81133

82134
efr32_executable("lighting_app") {
83135
output_name = "chip-efr32-lighting-example.out"
136+
include_dirs = [ "include" ]
137+
defines = []
84138

85139
sources = [
86140
"${examples_plat_dir}/LEDWidget.cpp",
@@ -99,26 +153,50 @@ efr32_executable("lighting_app") {
99153
"${chip_root}/examples/lighting-app/lighting-common",
100154
"${chip_root}/src/lib",
101155
"${chip_root}/src/setup_payload",
102-
"${chip_root}/third_party/openthread/platforms:libopenthread-platform",
103-
"${chip_root}/third_party/openthread/platforms:libopenthread-platform-utils",
104-
"${examples_plat_dir}:efr-matter-shell",
105156
]
106-
107-
if (chip_openthread_ftd) {
108-
deps += [
109-
"${chip_root}/third_party/openthread/repo:libopenthread-cli-ftd",
110-
"${chip_root}/third_party/openthread/repo:libopenthread-ftd",
111-
]
112-
} else {
157+
if (!use_rs911x && !use_wf200) {
113158
deps += [
114-
"${chip_root}/third_party/openthread/repo:libopenthread-cli-mtd",
115-
"${chip_root}/third_party/openthread/repo:libopenthread-mtd",
159+
"${chip_root}/third_party/openthread/platforms:libopenthread-platform",
160+
"${chip_root}/third_party/openthread/platforms:libopenthread-platform-utils",
161+
"${examples_plat_dir}:efr-matter-shell",
116162
]
163+
if (chip_openthread_ftd) {
164+
deps += [
165+
"${chip_root}/third_party/openthread/repo:libopenthread-cli-ftd",
166+
"${chip_root}/third_party/openthread/repo:libopenthread-ftd",
167+
]
168+
} else {
169+
deps += [
170+
"${chip_root}/third_party/openthread/repo:libopenthread-cli-mtd",
171+
"${chip_root}/third_party/openthread/repo:libopenthread-mtd",
172+
]
173+
}
174+
}
175+
if (use_rs911x) {
176+
sources += rs911x_src_plat
177+
178+
# All the stuff from wiseconnect
179+
sources += rs911x_src_sapi
180+
181+
# Apparently - the rsi library needs this (though we may not use use it)
182+
sources += rs911x_src_sock
183+
include_dirs += rs911x_inc_plat
184+
185+
if (use_rs911x_sockets) {
186+
#
187+
# Using native sockets inside RS911x
188+
#
189+
include_dirs += rs911x_sock_inc
190+
} else {
191+
#
192+
# We use LWIP - not built-in sockets
193+
#
194+
sources += rs911x_src_lwip
195+
}
196+
} else if (use_wf200) {
197+
sources += wf200_plat_src
198+
include_dirs += wf200_plat_incs
117199
}
118-
119-
include_dirs = [ "include" ]
120-
121-
defines = []
122200

123201
if (show_qr_code) {
124202
sources += [ "${examples_plat_dir}/display/lcd.c" ]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright (c) 2020 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
import("//build_overrides/chip.gni")
15+
import("//build_overrides/pigweed.gni")
16+
17+
efr32_sdk_target = get_label_info(":sdk", "label_no_toolchain")
18+
chip_enable_openthread = false
19+
import("${chip_root}/src/platform/EFR32/wifi_args.gni")
20+
21+
pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip"
22+
pw_assert_BACKEND = "$dir_pw_assert_log"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright (c) 2020 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import("//build_overrides/build.gni")
16+
17+
# The location of the build configuration file.
18+
buildconfig = "${build_root}/config/BUILDCONFIG.gn"
19+
20+
# CHIP uses angle bracket includes.
21+
check_system_includes = true
22+
23+
default_args = {
24+
target_cpu = "arm"
25+
target_os = "freertos"
26+
use_thread = false
27+
import("//build_for_wifi_args.gni")
28+
}

examples/lighting-app/efr32/include/AppConfig.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
// ---- Lighting Example App Config ----
2323

24-
#define APP_TASK_NAME "APP"
24+
#define APP_TASK_NAME "Lit"
2525

2626
// Time it takes in ms for the simulated actuator to move from one
2727
// state to another.

examples/lighting-app/efr32/include/FreeRTOSConfig.h

+4
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,11 @@ See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
237237
#define configENABLE_BACKWARD_COMPATIBILITY (1)
238238
#define configSUPPORT_STATIC_ALLOCATION (1)
239239
#define configSUPPORT_DYNAMIC_ALLOCATION (1)
240+
#ifdef SL_WIFI
241+
#define configTOTAL_HEAP_SIZE ((size_t)(28 * 1024))
242+
#else
240243
#define configTOTAL_HEAP_SIZE ((size_t)(20 * 1024))
244+
#endif
241245

242246
/* Optional functions - most linkers will remove unused functions anyway. */
243247
#define INCLUDE_vTaskPrioritySet (1)

examples/lighting-app/efr32/src/AppTask.cpp

+45-15
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@
5151
#include <platform/OpenThread/OpenThreadUtils.h>
5252
#include <platform/ThreadStackManager.h>
5353
#endif
54+
#ifdef SL_WIFI
55+
#include "wfx_host_events.h"
56+
#endif /* SL_WIFI */
5457

5558
#define FACTORY_RESET_TRIGGER_TIMEOUT 3000
5659
#define FACTORY_RESET_CANCEL_WINDOW_TIMEOUT 3000
@@ -73,9 +76,17 @@ QueueHandle_t sAppEventQueue;
7376
LEDWidget sStatusLED;
7477
LEDWidget sLightLED;
7578

79+
#ifdef SL_WIFI
80+
bool sIsWiFiProvisioned = false;
81+
bool sIsWiFiEnabled = false;
82+
bool sIsWiFiAttached = false;
83+
#endif /* SL_WIFI */
84+
85+
#if CHIP_ENABLE_OPENTHREAD
7686
bool sIsThreadProvisioned = false;
7787
bool sIsThreadEnabled = false;
78-
bool sHaveBLEConnections = false;
88+
#endif /* CHIP_ENABLE_OPENTHREAD */
89+
bool sHaveBLEConnections = false;
7990

8091
EmberAfIdentifyEffectIdentifier sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT;
8192

@@ -88,6 +99,7 @@ StaticTask_t appTaskStruct;
8899
/**********************************************************
89100
* Identify Callbacks
90101
*********************************************************/
102+
91103
namespace {
92104
void OnTriggerIdentifyEffectCompleted(chip::System::Layer * systemLayer, void * appState)
93105
{
@@ -208,6 +220,18 @@ CHIP_ERROR AppTask::Init()
208220
{
209221
CHIP_ERROR err = CHIP_NO_ERROR;
210222

223+
#ifdef SL_WIFI
224+
/*
225+
* Wait for the WiFi to be initialized
226+
*/
227+
EFR32_LOG("APP: Wait WiFi Init");
228+
while (!wfx_hw_ready())
229+
{
230+
vTaskDelay(10);
231+
}
232+
EFR32_LOG("APP: Done WiFi Init");
233+
/* We will init server when we get IP */
234+
#endif
211235
// Init ZCL Data Model
212236
chip::Server::GetInstance().Init();
213237

@@ -294,9 +318,16 @@ void AppTask::AppTaskMain(void * pvParameter)
294318
// when the CHIP task is busy (e.g. with a long crypto operation).
295319
if (PlatformMgr().TryLockChipStack())
296320
{
321+
#ifdef SL_WIFI
322+
sIsWiFiProvisioned = ConnectivityMgr().IsWiFiStationProvisioned();
323+
sIsWiFiEnabled = ConnectivityMgr().IsWiFiStationEnabled();
324+
sIsWiFiAttached = ConnectivityMgr().IsWiFiStationConnected();
325+
#endif /* SL_WIFI */
326+
#if CHIP_ENABLE_OPENTHREAD
297327
sIsThreadProvisioned = ConnectivityMgr().IsThreadProvisioned();
298328
sIsThreadEnabled = ConnectivityMgr().IsThreadEnabled();
299-
sHaveBLEConnections = (ConnectivityMgr().NumBLEConnections() != 0);
329+
#endif /* CHIP_ENABLE_OPENTHREAD */
330+
sHaveBLEConnections = (ConnectivityMgr().NumBLEConnections() != 0);
300331
PlatformMgr().UnlockChipStack();
301332
}
302333

@@ -333,18 +364,16 @@ void AppTask::AppTaskMain(void * pvParameter)
333364
sStatusLED.Blink(300, 700);
334365
}
335366
}
336-
else if (sIsThreadProvisioned && sIsThreadEnabled)
367+
#if CHIP_ENABLE_OPENTHREAD
368+
if (sIsThreadProvisioned && sIsThreadEnabled)
369+
#else
370+
if (sIsWiFiProvisioned && sIsWiFiEnabled && !sIsWiFiAttached)
371+
#endif
337372
{
338373
sStatusLED.Blink(950, 50);
339374
}
340-
else if (sHaveBLEConnections)
341-
{
342-
sStatusLED.Blink(100, 100);
343-
}
344-
else
345-
{
346-
sStatusLED.Blink(50, 950);
347-
}
375+
else if (sHaveBLEConnections) { sStatusLED.Blink(100, 100); }
376+
else { sStatusLED.Blink(50, 950); }
348377
}
349378

350379
sStatusLED.Animate();
@@ -484,16 +513,17 @@ void AppTask::FunctionHandler(AppEvent * aEvent)
484513
sAppTask.CancelTimer();
485514
sAppTask.mFunction = kFunction_NoneSelected;
486515

516+
#ifdef SL_WIFI
517+
if (!ConnectivityMgr().IsWiFiStationProvisioned())
518+
#else
487519
if (!ConnectivityMgr().IsThreadProvisioned())
520+
#endif /* !SL_WIFI */
488521
{
489522
// Enable BLE advertisements
490523
ConnectivityMgr().SetBLEAdvertisingEnabled(true);
491524
ConnectivityMgr().SetBLEAdvertisingMode(ConnectivityMgr().kFastAdvertising);
492525
}
493-
else
494-
{
495-
EFR32_LOG("Network is already provisioned, Ble advertissement not enabled");
496-
}
526+
else { EFR32_LOG("Network is already provisioned, Ble advertissement not enabled"); }
497527
}
498528
else if (sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_FactoryReset)
499529
{

0 commit comments

Comments
 (0)