Skip to content

Commit 0ad1a36

Browse files
rcasallas-silabsrestyled-commits
andauthoredMar 19, 2024
[Silabs] Si917: C files converted to C++. (#32547)
* [Silabs] Si917: C files converted to C++. * Restyled by clang-format --------- Co-authored-by: Restyled.io <commits@restyled.io>
1 parent 8228705 commit 0ad1a36

File tree

8 files changed

+39
-39
lines changed

8 files changed

+39
-39
lines changed
 

‎examples/platform/silabs/SiWx917/BUILD.gn

+2-2
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@ source_set("siwx917-common") {
219219
"${silabs_plat_si91x_wifi_dir}/ethernetif.cpp",
220220
"${silabs_plat_si91x_wifi_dir}/lwip_netif.cpp",
221221
"${silabs_plat_si91x_wifi_dir}/wfx_notify.cpp",
222-
"SiWx917/sl_wifi_if.c",
223-
"SiWx917/wfx_rsi_host.c",
222+
"SiWx917/sl_wifi_if.cpp",
223+
"SiWx917/wfx_rsi_host.cpp",
224224
]
225225

226226
if (chip_enable_pw_rpc || chip_build_libshell || sl_uart_log_output) {

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

+16-14
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,11 @@
2525
#include "FreeRTOS.h"
2626
#include "event_groups.h"
2727
#include "sl_board_configuration.h"
28-
#include "sl_net.h"
29-
#include "sl_si91x_host_interface.h"
3028
#include "sl_si91x_types.h"
31-
#include "sl_wifi_callback_framework.h"
3229
#include "sl_wifi_constants.h"
3330
#include "sl_wifi_types.h"
3431
#include "sl_wlan_config.h"
3532
#include "task.h"
36-
#include "wfx_host_events.h"
3733

3834
#if (EXP_BOARD)
3935
#include "rsi_bt_common_apis.h"
@@ -53,7 +49,6 @@ bool btn0_pressed = false;
5349
#endif // SL_ICD_ENABLED && SLI_SI91X_MCU_INTERFACE
5450

5551
#include "dhcp_client.h"
56-
#include "sl_wifi.h"
5752
#include "wfx_host_events.h"
5853
#include "wfx_rsi.h"
5954
#define ADV_SCAN_THRESHOLD -40
@@ -65,11 +60,17 @@ bool btn0_pressed = false;
6560

6661
// TODO: Confirm that this value works for size and timing
6762
#define WFX_QUEUE_SIZE 10
68-
63+
extern "C" {
64+
#include "sl_net.h"
65+
#include "sl_si91x_host_interface.h"
66+
#include "sl_wifi.h"
67+
#include "sl_wifi_callback_framework.h"
68+
#include "wfx_host_events.h"
6969
#if SLI_SI91X_MCU_INTERFACE
7070
#include "sl_si91x_trng.h"
7171
#define TRNGKEY_SIZE 4
7272
#endif // SLI_SI91X_MCU_INTERFACE
73+
} // extern "C" {
7374

7475
WfxRsi_t wfx_rsi;
7576

@@ -553,7 +554,7 @@ sl_status_t show_scan_results(sl_wifi_scan_result_t * scan_result)
553554
SILABS_LOG("SCAN SSID: %s , ap scan: %s", wfx_rsi.scan_ssid, ap.ssid);
554555
if (strcmp(wfx_rsi.scan_ssid, ap.ssid) == CMP_SUCCESS)
555556
{
556-
ap.security = scan_result->scan_info[x].security_mode;
557+
ap.security = static_cast<wfx_sec_t>(scan_result->scan_info[x].security_mode);
557558
ap.rssi = (-1) * scan_result->scan_info[x].rssi_val;
558559
memcpy(&ap.bssid[0], &scan_result->scan_info[x].bssid[0], BSSID_MAX_STR_LEN);
559560
(*wfx_rsi.scan_cb)(&ap);
@@ -562,7 +563,7 @@ sl_status_t show_scan_results(sl_wifi_scan_result_t * scan_result)
562563
}
563564
else
564565
{
565-
ap.security = scan_result->scan_info[x].security_mode;
566+
ap.security = static_cast<wfx_sec_t>(scan_result->scan_info[x].security_mode);
566567
ap.rssi = (-1) * scan_result->scan_info[x].rssi_val;
567568
memcpy(&ap.bssid[0], &scan_result->scan_info[x].bssid[0], BSSID_MAX_STR_LEN);
568569
(*wfx_rsi.scan_cb)(&ap);
@@ -597,8 +598,7 @@ static void wfx_rsi_save_ap_info() // translation
597598
{
598599
sl_status_t status = SL_STATUS_OK;
599600
#ifndef EXP_BOARD // TODO: this changes will be reverted back after the SDK team fix the scan API
600-
sl_wifi_scan_configuration_t wifi_scan_configuration = { 0 };
601-
wifi_scan_configuration = default_wifi_scan_configuration;
601+
sl_wifi_scan_configuration_t wifi_scan_configuration = default_wifi_scan_configuration;
602602
#endif
603603
sl_wifi_ssid_t ssid_arg;
604604
ssid_arg.length = strlen(wfx_rsi.sec.ssid);
@@ -682,10 +682,11 @@ static sl_status_t wfx_rsi_do_join(void)
682682
/* Call rsi connect call with given ssid and password
683683
* And check there is a success
684684
*/
685-
sl_wifi_credential_t cred = { 0 };
686-
cred.type = SL_WIFI_PSK_CREDENTIAL;
685+
sl_wifi_credential_t cred;
686+
memset(&cred, 0, sizeof(sl_wifi_credential_t));
687+
cred.type = SL_WIFI_PSK_CREDENTIAL;
687688
memcpy(cred.psk.value, &wfx_rsi.sec.passkey[0], strlen(wfx_rsi.sec.passkey));
688-
sl_wifi_credential_id_t id = SL_NET_DEFAULT_WIFI_CLIENT_CREDENTIAL_ID;
689+
sl_net_credential_id_t id = SL_NET_DEFAULT_WIFI_CLIENT_CREDENTIAL_ID;
689690
status = sl_net_set_credential(id, SL_NET_WIFI_PSK, &wfx_rsi.sec.passkey[0], strlen(wfx_rsi.sec.passkey));
690691
if (SL_STATUS_OK != status)
691692
{
@@ -851,7 +852,8 @@ void ProcessEvent(WfxEvent_t inEvent)
851852
if (!(wfx_rsi.dev_state & WFX_RSI_ST_SCANSTARTED))
852853
{
853854
SILABS_LOG("%s: start SSID scan", __func__);
854-
sl_wifi_scan_configuration_t wifi_scan_configuration = { 0 };
855+
sl_wifi_scan_configuration_t wifi_scan_configuration;
856+
memset(&wifi_scan_configuration, 0, sizeof(sl_wifi_scan_configuration_t));
855857

856858
// TODO: Add scan logic
857859
sl_wifi_advanced_scan_configuration_t advanced_scan_configuration = { 0 };

‎examples/platform/silabs/SiWx917/SiWx917/wfx_rsi_host.c ‎examples/platform/silabs/SiWx917/SiWx917/wfx_rsi_host.cpp

+17-19
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,14 @@ bool wfx_is_sta_mode_enabled(void)
103103
***********************************************************************/
104104
void wfx_get_wifi_mac_addr(sl_wfx_interface_t interface, sl_wfx_mac_address_t * addr)
105105
{
106-
sl_wfx_mac_address_t * mac;
107-
106+
if (addr)
107+
{
108108
#ifdef SL_WFX_CONFIG_SOFTAP
109-
mac = (interface == SL_WFX_SOFTAP_INTERFACE) ? &wfx_rsi.softap_mac : &wfx_rsi.sta_mac;
109+
*addr = (interface == SL_WFX_SOFTAP_INTERFACE) ? wfx_rsi.softap_mac : wfx_rsi.sta_mac;
110110
#else
111-
mac = &wfx_rsi.sta_mac;
111+
*addr = wfx_rsi.sta_mac;
112112
#endif
113-
*addr = *mac;
114-
SILABS_LOG("%s: %02x:%02x:%02x:%02x:%02x:%02x", __func__, mac->octet[0], mac->octet[1], mac->octet[2], mac->octet[3],
115-
mac->octet[4], mac->octet[5]);
113+
}
116114
}
117115

118116
/*********************************************************************
@@ -125,10 +123,11 @@ void wfx_get_wifi_mac_addr(sl_wfx_interface_t interface, sl_wfx_mac_address_t *
125123
***********************************************************************/
126124
void wfx_set_wifi_provision(wfx_wifi_provision_t * cfg)
127125
{
128-
SILABS_LOG("%s: SSID: %s", __func__, &wfx_rsi.sec.ssid[0]);
129-
130-
wfx_rsi.sec = *cfg;
131-
wfx_rsi.dev_state |= WFX_RSI_ST_STA_PROVISIONED;
126+
if (cfg)
127+
{
128+
wfx_rsi.sec = *cfg;
129+
wfx_rsi.dev_state |= WFX_RSI_ST_STA_PROVISIONED;
130+
}
132131
}
133132

134133
/*********************************************************************
@@ -179,13 +178,13 @@ sl_status_t wfx_connect_to_ap(void)
179178
WfxEvent_t event;
180179
if (wfx_rsi.dev_state & WFX_RSI_ST_STA_PROVISIONED)
181180
{
182-
SILABS_LOG("%s: connecting to access point -> SSID: %s", __func__, &wfx_rsi.sec.ssid[0]);
181+
SILABS_LOG("Connecting to access point -> SSID: %s", &wfx_rsi.sec.ssid[0]);
183182
event.eventType = WFX_EVT_STA_START_JOIN;
184183
WfxPostEvent(&event);
185184
}
186185
else
187186
{
188-
SILABS_LOG("%s: error: access point not provisioned", __func__);
187+
SILABS_LOG("Error: access point not provisioned.");
189188
return SL_STATUS_INVALID_CONFIGURATION;
190189
}
191190
return SL_STATUS_OK;
@@ -237,9 +236,8 @@ void wfx_setup_ip6_link_local(sl_wfx_interface_t whichif)
237236
***********************************************************************/
238237
bool wfx_is_sta_connected(void)
239238
{
240-
bool status;
241-
status = (wfx_rsi.dev_state & WFX_RSI_ST_STA_CONNECTED) ? true : false;
242-
SILABS_LOG("%s: status: %s", __func__, (status ? "connected" : "not connected"));
239+
bool status = (wfx_rsi.dev_state & WFX_RSI_ST_STA_CONNECTED) > 0;
240+
SILABS_LOG("%s: %s", __func__, (status ? "Connected" : "Disconnected"));
243241
return status;
244242
}
245243

@@ -289,7 +287,7 @@ bool wfx_have_ipv4_addr(sl_wfx_interface_t which_if)
289287
bool status = false;
290288
if (which_if == SL_WFX_STA_INTERFACE)
291289
{
292-
status = (wfx_rsi.dev_state & WFX_RSI_ST_STA_DHCP_DONE) ? true : false;
290+
status = (wfx_rsi.dev_state & WFX_RSI_ST_STA_DHCP_DONE) > 0;
293291
}
294292
else
295293
{
@@ -313,13 +311,13 @@ bool wfx_have_ipv6_addr(sl_wfx_interface_t which_if)
313311
bool status = false;
314312
if (which_if == SL_WFX_STA_INTERFACE)
315313
{
316-
status = (wfx_rsi.dev_state & WFX_RSI_ST_STA_CONNECTED) ? true : false;
314+
status = (wfx_rsi.dev_state & WFX_RSI_ST_STA_CONNECTED) > 0;
317315
}
318316
else
319317
{
320318
status = false; /* TODO */
321319
}
322-
SILABS_LOG("%s: status: %d", __func__, status);
320+
SILABS_LOG("%s: %d", __func__, status);
323321
return status;
324322
}
325323

‎examples/platform/silabs/efr32/rs911x/rs9117.gni

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import("//build_overrides/efr32_sdk.gni")
33
import("${efr32_sdk_build_root}/efr32_sdk.gni")
44

55
rs911x_src_plat = [
6-
"${examples_plat_dir}/rs911x/sl_wifi_if.c",
7-
"${examples_plat_dir}/rs911x/wfx_rsi_host.c",
6+
"${examples_plat_dir}/rs911x/sl_wifi_if.cpp",
7+
"${examples_plat_dir}/rs911x/wfx_rsi_host.cpp",
88
"${examples_plat_dir}/rs911x/hal/rsi_hal_mcu_interrupt.c",
99
"${examples_plat_dir}/rs911x/hal/sl_si91x_ncp_utility.c",
1010
"${examples_plat_dir}/rs911x/hal/efx32_ncp_host.c",

‎examples/platform/silabs/efr32/rs911x/rs911x.gni

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import("${efr32_sdk_build_root}/efr32_sdk.gni")
44

55
rs911x_src_plat = [
66
"${examples_plat_dir}/rs911x/rsi_if.c",
7-
"${examples_plat_dir}/rs911x/wfx_rsi_host.c",
7+
"${examples_plat_dir}/rs911x/wfx_rsi_host.cpp",
88
"${examples_plat_dir}/rs911x/hal/rsi_hal_mcu_interrupt.c",
99
"${examples_plat_dir}/rs911x/hal/rsi_hal_mcu_ioports.c",
1010
"${examples_plat_dir}/rs911x/hal/rsi_hal_mcu_timer.c",

‎examples/platform/silabs/efr32/rs911x/sl_wifi_if.c

-1
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../SiWx917/SiWx917/sl_wifi_if.cpp

0 commit comments

Comments
 (0)