Skip to content

Commit b4b576b

Browse files
authored
Merge branch 'master' into 0307_good_lock
2 parents 6077410 + eecc2a6 commit b4b576b

30 files changed

+1655
-604
lines changed

config/openiotsdk/chip-gn/.gn

+11
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import("//build_overrides/build.gni")
1616
import("//build_overrides/chip.gni")
17+
import("//build_overrides/pigweed.gni")
1718

1819
# The location of the build configuration file.
1920
buildconfig = "//build/config/BUILDCONFIG.gn"
@@ -26,4 +27,14 @@ default_args = {
2627
target_os = "cmsis-rtos"
2728

2829
import("${chip_root}/config/openiotsdk/chip-gn/args.gni")
30+
31+
pw_sys_io_BACKEND = dir_pw_sys_io_stdio
32+
33+
pw_assert_BACKEND = dir_pw_assert_log
34+
pw_log_BACKEND = dir_pw_log_basic
35+
36+
pw_build_LINK_DEPS = [
37+
"$dir_pw_assert:impl",
38+
"$dir_pw_log:impl",
39+
]
2940
}

config/openiotsdk/chip-gn/BUILD.gn

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ group("openiotsdk") {
1919
deps = [ "${chip_root}/src/lib" ]
2020

2121
if (chip_build_tests) {
22-
deps += [ "${chip_root}/src:tests" ]
22+
deps += [
23+
"${chip_root}/src:tests",
24+
"${chip_root}/src/lib/support:pw_tests_wrapper",
25+
]
2326
}
2427
}
2528

examples/platform/silabs/MatterConfig.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ CHIP_ERROR SilabsMatterConfig::InitWiFi(void)
293293
sl_status_t status;
294294
if ((status = wfx_wifi_rsi_init()) != SL_STATUS_OK)
295295
{
296+
SILABS_LOG("wfx_wifi_rsi_init failed with status: %x", status);
296297
ReturnErrorOnFailure((CHIP_ERROR) status);
297298
}
298299
#endif // SLI_SI91X_MCU_INTERFACE

examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.c

+20-14
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ bool btn0_pressed = false;
6868
#define TRNGKEY_SIZE 4
6969
#endif // SLI_SI91X_MCU_INTERFACE
7070

71-
struct wfx_rsi wfx_rsi;
71+
WfxRsi_t wfx_rsi;
7272

7373
/* Declare a variable to hold the data associated with the created event group. */
7474
StaticEventGroup_t rsiDriverEventGroup;
@@ -98,6 +98,9 @@ static wfx_wifi_scan_ext_t temp_reset;
9898

9999
volatile sl_status_t callback_status = SL_STATUS_OK;
100100

101+
// Scan semaphore
102+
static osSemaphoreId_t sScanSemaphore;
103+
101104
/******************************************************************
102105
* @fn int32_t wfx_rsi_get_ap_info(wfx_wifi_scan_result_t *ap)
103106
* @brief
@@ -305,8 +308,16 @@ int32_t wfx_wifi_rsi_init(void)
305308
status = sl_wifi_init(&config, NULL, sl_wifi_default_event_handler);
306309
if (status != SL_STATUS_OK)
307310
{
308-
SILABS_LOG("wfx_wifi_rsi_init failed %x", status);
311+
return status;
312+
}
313+
314+
// Create Sempaphore for scan
315+
sScanSemaphore = osSemaphoreNew(1, 0, NULL);
316+
if (sScanSemaphore == NULL)
317+
{
318+
return SL_STATUS_ALLOCATION_FAILED;
309319
}
320+
310321
return status;
311322
}
312323

@@ -421,6 +432,8 @@ sl_status_t scan_callback_handler(sl_wifi_event_t event, sl_wifi_scan_result_t *
421432
#else
422433
wfx_rsi.sec.security = WFX_SEC_WPA2;
423434
#endif /* WIFI_ENABLE_SECURITY_WPA3_TRANSITION */
435+
436+
osSemaphoreRelease(sScanSemaphore);
424437
return SL_STATUS_FAIL;
425438
}
426439
wfx_rsi.sec.security = WFX_SEC_UNSPECIFIED;
@@ -457,6 +470,8 @@ sl_status_t scan_callback_handler(sl_wifi_event_t event, sl_wifi_scan_result_t *
457470
}
458471
wfx_rsi.dev_state &= ~WFX_RSI_ST_SCANSTARTED;
459472
scan_results_complete = true;
473+
474+
osSemaphoreRelease(sScanSemaphore);
460475
return SL_STATUS_OK;
461476
}
462477
sl_status_t show_scan_results(sl_wifi_scan_result_t * scan_result)
@@ -501,6 +516,7 @@ sl_status_t bg_scan_callback_handler(sl_wifi_event_t event, sl_wifi_scan_result_
501516
{
502517
callback_status = show_scan_results(result);
503518
bg_scan_results_complete = true;
519+
osSemaphoreRelease(sScanSemaphore);
504520
return SL_STATUS_OK;
505521
}
506522
/***************************************************************************************
@@ -529,12 +545,7 @@ static void wfx_rsi_save_ap_info() // translation
529545
#endif
530546
if (SL_STATUS_IN_PROGRESS == status)
531547
{
532-
const uint32_t start = osKernelGetTickCount();
533-
while (!scan_results_complete && (osKernelGetTickCount() - start) <= WIFI_SCAN_TIMEOUT_TICK)
534-
{
535-
osThreadYield();
536-
}
537-
status = scan_results_complete ? callback_status : SL_STATUS_TIMEOUT;
548+
osSemaphoreAcquire(sScanSemaphore, WIFI_SCAN_TIMEOUT_TICK);
538549
}
539550
}
540551

@@ -817,12 +828,7 @@ void wfx_rsi_task(void * arg)
817828
status = sl_wifi_start_scan(SL_WIFI_CLIENT_2_4GHZ_INTERFACE, NULL, &wifi_scan_configuration);
818829
if (SL_STATUS_IN_PROGRESS == status)
819830
{
820-
const uint32_t start = osKernelGetTickCount();
821-
while (!bg_scan_results_complete && (osKernelGetTickCount() - start) <= WIFI_SCAN_TIMEOUT_TICK)
822-
{
823-
osThreadYield();
824-
}
825-
status = bg_scan_results_complete ? callback_status : SL_STATUS_TIMEOUT;
831+
osSemaphoreAcquire(sScanSemaphore, WIFI_SCAN_TIMEOUT_TICK);
826832
}
827833
}
828834
}

examples/platform/silabs/SiWx917/SiWx917/wfx_rsi.h

+30-23
Original file line numberDiff line numberDiff line change
@@ -33,30 +33,37 @@
3333
* Various events fielded by the wfx_rsi task
3434
* Make sure that we only use 8 bits (otherwise freeRTOS - may need some changes)
3535
*/
36-
#define WFX_EVT_STA_CONN (0x01)
37-
#define WFX_EVT_STA_DISCONN (0x02)
38-
#define WFX_EVT_AP_START (0x04)
39-
#define WFX_EVT_AP_STOP (0x08)
40-
#define WFX_EVT_SCAN (0x10) /* This is used as scan result and start */
41-
#define WFX_EVT_STA_START_JOIN (0x20)
42-
#define WFX_EVT_STA_DO_DHCP (0x40)
43-
#define WFX_EVT_STA_DHCP_DONE (0x80)
36+
typedef enum
37+
{
38+
WFX_EVT_STA_CONN = (1 << 0),
39+
WFX_EVT_STA_DISCONN = (1 << 1),
40+
WFX_EVT_AP_START = (1 << 2),
41+
WFX_EVT_AP_STOP = (1 << 3),
42+
WFX_EVT_SCAN = (1 << 4), /* This is used as scan result and start */
43+
WFX_EVT_STA_START_JOIN = (1 << 5),
44+
WFX_EVT_STA_DO_DHCP = (1 << 6),
45+
WFX_EVT_STA_DHCP_DONE = (1 << 7)
46+
} WfxEventType_e;
4447

45-
#define WFX_RSI_ST_DEV_READY (0x01)
46-
#define WFX_RSI_ST_AP_READY (0x02)
47-
#define WFX_RSI_ST_STA_PROVISIONED (0x04)
48-
#define WFX_RSI_ST_STA_CONNECTING (0x08)
49-
#define WFX_RSI_ST_STA_CONNECTED (0x10)
50-
#define WFX_RSI_ST_STA_DHCP_DONE (0x40) /* Requested to do DHCP after conn */
51-
#define WFX_RSI_ST_STA_MODE (0x80) /* Enable Station Mode */
52-
#define WFX_RSI_ST_AP_MODE (0x100) /* Enable AP Mode */
53-
#define WFX_RSI_ST_STA_READY (WFX_RSI_ST_STA_CONNECTED | WFX_RSI_ST_STA_DHCP_DONE)
54-
#define WFX_RSI_ST_STARTED (0x200) /* RSI task started */
55-
#define WFX_RSI_ST_SCANSTARTED (0x400) /* Scan Started */
56-
#define WFX_RSI_ST_SLEEP_READY (0x800) /* Notify the M4 to go to sleep*/
48+
typedef enum
49+
{
50+
WFX_RSI_ST_DEV_READY = (1 << 0),
51+
WFX_RSI_ST_AP_READY = (1 << 1),
52+
WFX_RSI_ST_STA_PROVISIONED = (1 << 2),
53+
WFX_RSI_ST_STA_CONNECTING = (1 << 3),
54+
WFX_RSI_ST_STA_CONNECTED = (1 << 4),
55+
WFX_RSI_ST_STA_DHCP_DONE = (1 << 6), /* Requested to do DHCP after conn */
56+
WFX_RSI_ST_STA_MODE = (1 << 7), /* Enable Station Mode */
57+
WFX_RSI_ST_AP_MODE = (1 << 8), /* Enable AP Mode */
58+
WFX_RSI_ST_STA_READY = (WFX_RSI_ST_STA_CONNECTED | WFX_RSI_ST_STA_DHCP_DONE),
59+
WFX_RSI_ST_STARTED = (1 << 9), /* RSI task started */
60+
WFX_RSI_ST_SCANSTARTED = (1 << 10), /* Scan Started */
61+
WFX_RSI_ST_SLEEP_READY = (1 << 11) /* Notify the M4 to go to sleep*/
62+
} WfxStateType_e;
5763

58-
struct wfx_rsi
64+
typedef struct wfx_rsi_s
5965
{
66+
// TODO: Change tp WfxEventType_e once the event queue is implemented
6067
EventGroupHandle_t events;
6168
TaskHandle_t drv_task;
6269
TaskHandle_t wlan_task;
@@ -77,9 +84,9 @@ struct wfx_rsi
7784
sl_wfx_mac_address_t ap_bssid; /* To which our STA is connected */
7885
uint16_t join_retries;
7986
uint8_t ip4_addr[4]; /* Not sure if this is enough */
80-
};
87+
} WfxRsi_t;
8188

82-
extern struct wfx_rsi wfx_rsi;
89+
extern WfxRsi_t wfx_rsi;
8390
#ifdef __cplusplus
8491
extern "C" {
8592
#endif

examples/platform/silabs/efr32/rs911x/rsi_if.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -866,4 +866,4 @@ int32_t wfx_rsi_send_data(void * p, uint16_t len)
866866
return status;
867867
}
868868

869-
struct wfx_rsi wfx_rsi;
869+
WfxRsi_t wfx_rsi;

examples/platform/silabs/efr32/rs911x/wfx_rsi.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
#define WFX_RSI_ST_SCANSTARTED (0x400) /* Scan Started */
5454
#define WFX_RSI_ST_SLEEP_READY (0x800) /* Notify the M4 to go to sleep*/
5555

56-
struct wfx_rsi
56+
typedef struct wfx_rsi_s
5757
{
5858
EventGroupHandle_t events;
5959
TaskHandle_t drv_task;
@@ -76,9 +76,9 @@ struct wfx_rsi
7676
sl_wfx_mac_address_t ap_bssid; /* To which our STA is connected */
7777
uint16_t join_retries;
7878
uint8_t ip4_addr[4]; /* Not sure if this is enough */
79-
};
79+
} WfxRsi_t;
8080

81-
extern struct wfx_rsi wfx_rsi;
81+
extern WfxRsi_t wfx_rsi;
8282
#ifdef __cplusplus
8383
extern "C" {
8484
#endif

scripts/examples/openiotsdk_example.sh

+2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ readarray -t SUPPORTED_APP_NAMES <"$CHIP_ROOT"/examples/platform/openiotsdk/supp
5353
SUPPORTED_APP_NAMES+=("unit-tests")
5454

5555
readarray -t TEST_NAMES <"$CHIP_ROOT"/src/test_driver/openiotsdk/unit-tests/test_components.txt
56+
readarray -t TEST_NAMES_NL <"$CHIP_ROOT"/src/test_driver/openiotsdk/unit-tests/test_components_nl.txt
57+
TEST_NAMES+=("${TEST_NAMES_NL[@]}")
5658

5759
function show_usage() {
5860
cat <<EOF

src/BUILD.gn

+2-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ if (chip_build_tests) {
144144
# TODO [PW_MIGRATION] Remove this if after migartion to PW_TEST is completed for all platforms
145145
# TODO [PW_MIGRATION] There will be a list of already migrated platforms
146146
if (chip_device_platform == "esp32" ||
147-
chip_device_platform == "nrfconnect") {
147+
chip_device_platform == "nrfconnect" ||
148+
chip_device_platform == "openiotsdk") {
148149
deps += [ "${chip_root}/src/lib/support:pw_tests_wrapper" ]
149150
}
150151
build_monolithic_library = true

0 commit comments

Comments
 (0)