diff --git a/examples/platform/silabs/SiWx917/BUILD.gn b/examples/platform/silabs/SiWx917/BUILD.gn index 9214e97adef89e..73e70c18e1d7f8 100644 --- a/examples/platform/silabs/SiWx917/BUILD.gn +++ b/examples/platform/silabs/SiWx917/BUILD.gn @@ -219,8 +219,8 @@ source_set("siwx917-common") { "${silabs_plat_si91x_wifi_dir}/ethernetif.cpp", "${silabs_plat_si91x_wifi_dir}/lwip_netif.cpp", "${silabs_plat_si91x_wifi_dir}/wfx_notify.cpp", - "SiWx917/sl_wifi_if.c", - "SiWx917/wfx_rsi_host.c", + "SiWx917/sl_wifi_if.cpp", + "SiWx917/wfx_rsi_host.cpp", ] if (chip_enable_pw_rpc || chip_build_libshell || sl_uart_log_output) { diff --git a/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.c b/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.cpp similarity index 98% rename from examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.c rename to examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.cpp index 48b8f54ff540fa..c443bec49b072c 100644 --- a/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.c +++ b/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.cpp @@ -25,15 +25,11 @@ #include "FreeRTOS.h" #include "event_groups.h" #include "sl_board_configuration.h" -#include "sl_net.h" -#include "sl_si91x_host_interface.h" #include "sl_si91x_types.h" -#include "sl_wifi_callback_framework.h" #include "sl_wifi_constants.h" #include "sl_wifi_types.h" #include "sl_wlan_config.h" #include "task.h" -#include "wfx_host_events.h" #if (EXP_BOARD) #include "rsi_bt_common_apis.h" @@ -53,7 +49,6 @@ bool btn0_pressed = false; #endif // SL_ICD_ENABLED && SLI_SI91X_MCU_INTERFACE #include "dhcp_client.h" -#include "sl_wifi.h" #include "wfx_host_events.h" #include "wfx_rsi.h" #define ADV_SCAN_THRESHOLD -40 @@ -65,11 +60,17 @@ bool btn0_pressed = false; // TODO: Confirm that this value works for size and timing #define WFX_QUEUE_SIZE 10 - +extern "C" { +#include "sl_net.h" +#include "sl_si91x_host_interface.h" +#include "sl_wifi.h" +#include "sl_wifi_callback_framework.h" +#include "wfx_host_events.h" #if SLI_SI91X_MCU_INTERFACE #include "sl_si91x_trng.h" #define TRNGKEY_SIZE 4 #endif // SLI_SI91X_MCU_INTERFACE +} // extern "C" { WfxRsi_t wfx_rsi; @@ -553,7 +554,7 @@ sl_status_t show_scan_results(sl_wifi_scan_result_t * scan_result) SILABS_LOG("SCAN SSID: %s , ap scan: %s", wfx_rsi.scan_ssid, ap.ssid); if (strcmp(wfx_rsi.scan_ssid, ap.ssid) == CMP_SUCCESS) { - ap.security = scan_result->scan_info[x].security_mode; + ap.security = static_cast(scan_result->scan_info[x].security_mode); ap.rssi = (-1) * scan_result->scan_info[x].rssi_val; memcpy(&ap.bssid[0], &scan_result->scan_info[x].bssid[0], BSSID_MAX_STR_LEN); (*wfx_rsi.scan_cb)(&ap); @@ -562,7 +563,7 @@ sl_status_t show_scan_results(sl_wifi_scan_result_t * scan_result) } else { - ap.security = scan_result->scan_info[x].security_mode; + ap.security = static_cast(scan_result->scan_info[x].security_mode); ap.rssi = (-1) * scan_result->scan_info[x].rssi_val; memcpy(&ap.bssid[0], &scan_result->scan_info[x].bssid[0], BSSID_MAX_STR_LEN); (*wfx_rsi.scan_cb)(&ap); @@ -597,8 +598,7 @@ static void wfx_rsi_save_ap_info() // translation { sl_status_t status = SL_STATUS_OK; #ifndef EXP_BOARD // TODO: this changes will be reverted back after the SDK team fix the scan API - sl_wifi_scan_configuration_t wifi_scan_configuration = { 0 }; - wifi_scan_configuration = default_wifi_scan_configuration; + sl_wifi_scan_configuration_t wifi_scan_configuration = default_wifi_scan_configuration; #endif sl_wifi_ssid_t ssid_arg; ssid_arg.length = strlen(wfx_rsi.sec.ssid); @@ -682,10 +682,11 @@ static sl_status_t wfx_rsi_do_join(void) /* Call rsi connect call with given ssid and password * And check there is a success */ - sl_wifi_credential_t cred = { 0 }; - cred.type = SL_WIFI_PSK_CREDENTIAL; + sl_wifi_credential_t cred; + memset(&cred, 0, sizeof(sl_wifi_credential_t)); + cred.type = SL_WIFI_PSK_CREDENTIAL; memcpy(cred.psk.value, &wfx_rsi.sec.passkey[0], strlen(wfx_rsi.sec.passkey)); - sl_wifi_credential_id_t id = SL_NET_DEFAULT_WIFI_CLIENT_CREDENTIAL_ID; + sl_net_credential_id_t id = SL_NET_DEFAULT_WIFI_CLIENT_CREDENTIAL_ID; status = sl_net_set_credential(id, SL_NET_WIFI_PSK, &wfx_rsi.sec.passkey[0], strlen(wfx_rsi.sec.passkey)); if (SL_STATUS_OK != status) { @@ -851,7 +852,8 @@ void ProcessEvent(WfxEvent_t inEvent) if (!(wfx_rsi.dev_state & WFX_RSI_ST_SCANSTARTED)) { SILABS_LOG("%s: start SSID scan", __func__); - sl_wifi_scan_configuration_t wifi_scan_configuration = { 0 }; + sl_wifi_scan_configuration_t wifi_scan_configuration; + memset(&wifi_scan_configuration, 0, sizeof(sl_wifi_scan_configuration_t)); // TODO: Add scan logic sl_wifi_advanced_scan_configuration_t advanced_scan_configuration = { 0 }; diff --git a/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi_host.c b/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi_host.cpp similarity index 93% rename from examples/platform/silabs/SiWx917/SiWx917/wfx_rsi_host.c rename to examples/platform/silabs/SiWx917/SiWx917/wfx_rsi_host.cpp index 1711076e46bd1c..83c3a95ec0caf7 100644 --- a/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi_host.c +++ b/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi_host.cpp @@ -103,16 +103,14 @@ bool wfx_is_sta_mode_enabled(void) ***********************************************************************/ void wfx_get_wifi_mac_addr(sl_wfx_interface_t interface, sl_wfx_mac_address_t * addr) { - sl_wfx_mac_address_t * mac; - + if (addr) + { #ifdef SL_WFX_CONFIG_SOFTAP - mac = (interface == SL_WFX_SOFTAP_INTERFACE) ? &wfx_rsi.softap_mac : &wfx_rsi.sta_mac; + *addr = (interface == SL_WFX_SOFTAP_INTERFACE) ? wfx_rsi.softap_mac : wfx_rsi.sta_mac; #else - mac = &wfx_rsi.sta_mac; + *addr = wfx_rsi.sta_mac; #endif - *addr = *mac; - SILABS_LOG("%s: %02x:%02x:%02x:%02x:%02x:%02x", __func__, mac->octet[0], mac->octet[1], mac->octet[2], mac->octet[3], - mac->octet[4], mac->octet[5]); + } } /********************************************************************* @@ -125,10 +123,11 @@ void wfx_get_wifi_mac_addr(sl_wfx_interface_t interface, sl_wfx_mac_address_t * ***********************************************************************/ void wfx_set_wifi_provision(wfx_wifi_provision_t * cfg) { - SILABS_LOG("%s: SSID: %s", __func__, &wfx_rsi.sec.ssid[0]); - - wfx_rsi.sec = *cfg; - wfx_rsi.dev_state |= WFX_RSI_ST_STA_PROVISIONED; + if (cfg) + { + wfx_rsi.sec = *cfg; + wfx_rsi.dev_state |= WFX_RSI_ST_STA_PROVISIONED; + } } /********************************************************************* @@ -179,13 +178,13 @@ sl_status_t wfx_connect_to_ap(void) WfxEvent_t event; if (wfx_rsi.dev_state & WFX_RSI_ST_STA_PROVISIONED) { - SILABS_LOG("%s: connecting to access point -> SSID: %s", __func__, &wfx_rsi.sec.ssid[0]); + SILABS_LOG("Connecting to access point -> SSID: %s", &wfx_rsi.sec.ssid[0]); event.eventType = WFX_EVT_STA_START_JOIN; WfxPostEvent(&event); } else { - SILABS_LOG("%s: error: access point not provisioned", __func__); + SILABS_LOG("Error: access point not provisioned."); return SL_STATUS_INVALID_CONFIGURATION; } return SL_STATUS_OK; @@ -237,9 +236,8 @@ void wfx_setup_ip6_link_local(sl_wfx_interface_t whichif) ***********************************************************************/ bool wfx_is_sta_connected(void) { - bool status; - status = (wfx_rsi.dev_state & WFX_RSI_ST_STA_CONNECTED) ? true : false; - SILABS_LOG("%s: status: %s", __func__, (status ? "connected" : "not connected")); + bool status = (wfx_rsi.dev_state & WFX_RSI_ST_STA_CONNECTED) > 0; + SILABS_LOG("%s: %s", __func__, (status ? "Connected" : "Disconnected")); return status; } @@ -289,7 +287,7 @@ bool wfx_have_ipv4_addr(sl_wfx_interface_t which_if) bool status = false; if (which_if == SL_WFX_STA_INTERFACE) { - status = (wfx_rsi.dev_state & WFX_RSI_ST_STA_DHCP_DONE) ? true : false; + status = (wfx_rsi.dev_state & WFX_RSI_ST_STA_DHCP_DONE) > 0; } else { @@ -313,13 +311,13 @@ bool wfx_have_ipv6_addr(sl_wfx_interface_t which_if) bool status = false; if (which_if == SL_WFX_STA_INTERFACE) { - status = (wfx_rsi.dev_state & WFX_RSI_ST_STA_CONNECTED) ? true : false; + status = (wfx_rsi.dev_state & WFX_RSI_ST_STA_CONNECTED) > 0; } else { status = false; /* TODO */ } - SILABS_LOG("%s: status: %d", __func__, status); + SILABS_LOG("%s: %d", __func__, status); return status; } diff --git a/examples/platform/silabs/efr32/rs911x/rs9117.gni b/examples/platform/silabs/efr32/rs911x/rs9117.gni index 5a561c9f201eab..c068e7aa3efaff 100644 --- a/examples/platform/silabs/efr32/rs911x/rs9117.gni +++ b/examples/platform/silabs/efr32/rs911x/rs9117.gni @@ -3,8 +3,8 @@ import("//build_overrides/efr32_sdk.gni") import("${efr32_sdk_build_root}/efr32_sdk.gni") rs911x_src_plat = [ - "${examples_plat_dir}/rs911x/sl_wifi_if.c", - "${examples_plat_dir}/rs911x/wfx_rsi_host.c", + "${examples_plat_dir}/rs911x/sl_wifi_if.cpp", + "${examples_plat_dir}/rs911x/wfx_rsi_host.cpp", "${examples_plat_dir}/rs911x/hal/rsi_hal_mcu_interrupt.c", "${examples_plat_dir}/rs911x/hal/sl_si91x_ncp_utility.c", "${examples_plat_dir}/rs911x/hal/efx32_ncp_host.c", diff --git a/examples/platform/silabs/efr32/rs911x/rs911x.gni b/examples/platform/silabs/efr32/rs911x/rs911x.gni index 6b52ff1b99c676..ebf7c546f6a068 100644 --- a/examples/platform/silabs/efr32/rs911x/rs911x.gni +++ b/examples/platform/silabs/efr32/rs911x/rs911x.gni @@ -4,7 +4,7 @@ import("${efr32_sdk_build_root}/efr32_sdk.gni") rs911x_src_plat = [ "${examples_plat_dir}/rs911x/rsi_if.c", - "${examples_plat_dir}/rs911x/wfx_rsi_host.c", + "${examples_plat_dir}/rs911x/wfx_rsi_host.cpp", "${examples_plat_dir}/rs911x/hal/rsi_hal_mcu_interrupt.c", "${examples_plat_dir}/rs911x/hal/rsi_hal_mcu_ioports.c", "${examples_plat_dir}/rs911x/hal/rsi_hal_mcu_timer.c", diff --git a/examples/platform/silabs/efr32/rs911x/sl_wifi_if.c b/examples/platform/silabs/efr32/rs911x/sl_wifi_if.c deleted file mode 120000 index eae406da321152..00000000000000 --- a/examples/platform/silabs/efr32/rs911x/sl_wifi_if.c +++ /dev/null @@ -1 +0,0 @@ -../../SiWx917/SiWx917/sl_wifi_if.c \ No newline at end of file diff --git a/examples/platform/silabs/efr32/rs911x/sl_wifi_if.cpp b/examples/platform/silabs/efr32/rs911x/sl_wifi_if.cpp new file mode 120000 index 00000000000000..2f233ccc6cdbe0 --- /dev/null +++ b/examples/platform/silabs/efr32/rs911x/sl_wifi_if.cpp @@ -0,0 +1 @@ +../../SiWx917/SiWx917/sl_wifi_if.cpp \ No newline at end of file diff --git a/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c b/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.cpp similarity index 100% rename from examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c rename to examples/platform/silabs/efr32/rs911x/wfx_rsi_host.cpp