Skip to content

Commit

Permalink
[Silabs] Si917: C files converted to C++. (#32547)
Browse files Browse the repository at this point in the history
* [Silabs] Si917: C files converted to C++.

* Restyled by clang-format

---------

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
rcasallas-silabs and restyled-commits authored Mar 19, 2024
1 parent 8228705 commit 0ad1a36
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 39 deletions.
4 changes: 2 additions & 2 deletions examples/platform/silabs/SiWx917/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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;

Expand Down Expand Up @@ -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<wfx_sec_t>(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);
Expand All @@ -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<wfx_sec_t>(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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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 };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}

/*********************************************************************
Expand All @@ -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;
}
}

/*********************************************************************
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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
{
Expand All @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions examples/platform/silabs/efr32/rs911x/rs9117.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/silabs/efr32/rs911x/rs911x.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion examples/platform/silabs/efr32/rs911x/sl_wifi_if.c

This file was deleted.

1 change: 1 addition & 0 deletions examples/platform/silabs/efr32/rs911x/sl_wifi_if.cpp

0 comments on commit 0ad1a36

Please sign in to comment.