Skip to content

Commit

Permalink
Wi-fi: Code review.
Browse files Browse the repository at this point in the history
  • Loading branch information
rcasallas-silabs committed Mar 28, 2024
1 parent c849583 commit 6eb654b
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 48 deletions.
9 changes: 0 additions & 9 deletions examples/platform/silabs/wifi/rs911x/rsi_if.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -874,12 +874,3 @@ int32_t wfx_rsi_send_data(void * p, uint16_t len)

return status;
}

namespace {
WfxRsi sInstance;
}

WfxRsi & WfxRsi::Instance()
{
return sInstance;
}
22 changes: 5 additions & 17 deletions examples/platform/silabs/wifi/sl_wifi_if.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ uint32_t retryInterval = WLAN_MIN_RETRY_TIMER_MS;
volatile bool scan_results_complete = false;
volatile bool bg_scan_results_complete = false;


extern osSemaphoreId_t sl_rs_ble_init_sem;

/*
Expand All @@ -94,7 +93,6 @@ static wfx_wifi_scan_ext_t temp_reset;

volatile sl_status_t callback_status = SL_STATUS_OK;


/******************************************************************
* @fn int32_t wfx_rsi_get_ap_info(wfx_wifi_scan_result_t *ap)
* @brief
Expand All @@ -105,7 +103,7 @@ volatile sl_status_t callback_status = SL_STATUS_OK;
*********************************************************************/
int32_t wfx_rsi_get_ap_info(wfx_wifi_scan_result_t * ap)
{
WfxRsi & wfx_rsi = WfxRsi::Instance();
WfxRsi & wfx_rsi = WfxRsi::Instance();
sl_status_t status = SL_STATUS_OK;
int32_t rssi = 0;
ap->security = wfx_rsi.sec.security;
Expand Down Expand Up @@ -517,7 +515,7 @@ sl_status_t show_scan_results(sl_wifi_scan_result_t * scan_result)

sl_status_t bg_scan_callback_handler(sl_wifi_event_t event, sl_wifi_scan_result_t * result, uint32_t result_length, void * arg)
{
WfxRsi & wfx_rsi = WfxRsi::Instance();
WfxRsi & wfx_rsi = WfxRsi::Instance();
callback_status = show_scan_results(result);
bg_scan_results_complete = true;
wfx_rsi.ReleaseScan();
Expand All @@ -534,7 +532,7 @@ sl_status_t bg_scan_callback_handler(sl_wifi_event_t event, sl_wifi_scan_result_
*******************************************************************************************/
static void wfx_rsi_save_ap_info() // translation
{
WfxRsi & wfx_rsi = WfxRsi::Instance();
WfxRsi & wfx_rsi = WfxRsi::Instance();
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 = default_wifi_scan_configuration;
Expand Down Expand Up @@ -563,7 +561,7 @@ static void wfx_rsi_save_ap_info() // translation
**********************************************************************************************/
static sl_status_t wfx_rsi_do_join(void)
{
WfxRsi & wfx_rsi = WfxRsi::Instance();
WfxRsi & wfx_rsi = WfxRsi::Instance();
sl_status_t status = SL_STATUS_OK;
sl_wifi_security_t connect_security_mode;
WfxEvent_t event;
Expand Down Expand Up @@ -672,7 +670,6 @@ static sl_status_t wfx_rsi_do_join(void)
return status;
}


void ProcessEvent(WfxEvent_t inEvent)
{
WfxRsi & wfx_rsi = WfxRsi::Instance();
Expand Down Expand Up @@ -787,7 +784,7 @@ void ProcessEvent(WfxEvent_t inEvent)
/* ARGSUSED */
void wfx_rsi_task(void * arg)
{
WfxRsi & wfx_rsi = WfxRsi::Instance();
WfxRsi & wfx_rsi = WfxRsi::Instance();
sl_status_t status = wfx_rsi_init();
(void) arg;

Expand Down Expand Up @@ -887,12 +884,3 @@ int32_t wfx_rsi_send_data(void * p, uint16_t len)
}

#endif

namespace {
WfxRsi sInstance;
}

WfxRsi & WfxRsi::Instance()
{
return sInstance;
}
29 changes: 13 additions & 16 deletions examples/platform/silabs/wifi/wfx_rsi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// TODO: Confirm that this value works for size and timing
#define WFX_QUEUE_SIZE 10


sl_status_t WfxRsi::Init()
{
sl_status_t status = SL_STATUS_OK;
Expand Down Expand Up @@ -35,7 +34,6 @@ sl_status_t WfxRsi::Init()
return status;
}


void WfxRsi::PostEvent(WfxEvent_t * event)
{
sl_status_t status = osMessageQueuePut(mEventQueue, event, 0, 0);
Expand All @@ -47,22 +45,18 @@ void WfxRsi::PostEvent(WfxEvent_t * event)
}
}


sl_status_t WfxRsi::GetNextEvent(WfxEvent_t & wfxEvent)
{
return osMessageQueueGet(mEventQueue, &wfxEvent, NULL, osWaitForever);
return osMessageQueueGet(mEventQueue, &wfxEvent, NULL, osWaitForever) ? SL_STATUS_FAIL : SL_STATUS_OK;
}


void WfxRsi::DHCPTimerEventHandler(void * arg)
{
WfxRsi & wfx_rsi = WfxRsi::Instance();
WfxEvent_t event;
event.eventType = WFX_EVT_DHCP_POLL;
wfx_rsi.PostEvent(&event);
WfxRsi::Instance().PostEvent(&event);
}


void WfxRsi::StartDHCPTimer(uint32_t timeout)
{
osStatus_t status;
Expand All @@ -77,7 +71,6 @@ void WfxRsi::StartDHCPTimer(uint32_t timeout)
}
}


void WfxRsi::CancelDHCPTimer()
{
osStatus_t status;
Expand All @@ -96,19 +89,16 @@ void WfxRsi::CancelDHCPTimer()
}
}


void WfxRsi::BlockScan()
{
osSemaphoreAcquire(mScanSemaphore, WIFI_SCAN_TIMEOUT_TICK);
}


void WfxRsi::ReleaseScan()
{
osSemaphoreRelease(mScanSemaphore);
}


/// NotifyConnectivity
/// @brief Notify the application about the connectivity status if it has not been notified yet.
/// Helper function for HandleDHCPPolling.
Expand All @@ -121,7 +111,6 @@ void WfxRsi::NotifyConnectivity()
}
}


void WfxRsi::HandleDHCPPolling()
{
struct netif * sta_netif;
Expand Down Expand Up @@ -155,7 +144,7 @@ void WfxRsi::HandleDHCPPolling()
{
wfx_ipv6_notify(GET_IPV6_SUCCESS);
mHasNotifiedIPV6 = true;
event.eventType = WFX_EVT_STA_DHCP_DONE;
event.eventType = WFX_EVT_STA_DHCP_DONE;
PostEvent(&event);
NotifyConnectivity();
}
Expand All @@ -166,7 +155,6 @@ void WfxRsi::HandleDHCPPolling()
/// and emits a WFX_EVT_STA_DO_DHCP event to trigger DHCP polling checks. Helper function for ProcessEvent.
void WfxRsi::ResetDHCPNotificationFlags()
{
WfxRsi & wfx_rsi = WfxRsi::Instance();
WfxEvent_t outEvent;

#if (CHIP_DEVICE_CONFIG_ENABLE_IPV4)
Expand All @@ -176,5 +164,14 @@ void WfxRsi::ResetDHCPNotificationFlags()
mHasNotifiedWifiConnectivity = false;

outEvent.eventType = WFX_EVT_STA_DO_DHCP;
wfx_rsi.PostEvent(&outEvent);
PostEvent(&outEvent);
}

namespace {
WfxRsi sInstance;
}

WfxRsi & WfxRsi::Instance()
{
return sInstance;
}
11 changes: 5 additions & 6 deletions examples/platform/silabs/wifi/wfx_rsi.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
#pragma once

#include <FreeRTOS.h>
#include <event_groups.h>
#include <cmsis_os2.h>
#include <wfx_host_events.h>
#include <event_groups.h>
#include <sl_status.h>
#include <wfx_host_events.h>

#ifndef RSI_BLE_ENABLE
#define RSI_BLE_ENABLE (1)
Expand Down Expand Up @@ -72,7 +72,6 @@ typedef struct WfxEvent_s
void * eventData; // event data TODO: confirm needed
} WfxEvent_t;


struct WfxRsi
{
// TODO: Change tp WfxEventType_e once the event queue is implemented
Expand Down Expand Up @@ -124,10 +123,10 @@ struct WfxRsi
// DHCP Poll timer
osTimerId_t mDHCPTimer;
bool mHasNotifiedWifiConnectivity = false;
bool mHasNotifiedIPV6 = false;
#if (CHIP_DEVICE_CONFIG_ENABLE_IPV4)
bool mHasNotifiedIPV6 = false;
#if (CHIP_DEVICE_CONFIG_ENABLE_IPV4)
bool mHasNotifiedIPV4 = false;
#endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */
#endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */
};

#ifdef __cplusplus
Expand Down
1 change: 1 addition & 0 deletions third_party/silabs/SiWx917_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import("${chip_root}/src/lib/lib.gni")
import("silabs_board.gni")

examples_plat_dir = "${chip_root}/examples/platform/silabs"
silabs_plat_dir = "${chip_root}/src/platform/silabs"

declare_args() {
# Enable the Alarm Based Wakeup for 917 SoC when sleep is enabled
Expand Down
1 change: 1 addition & 0 deletions third_party/silabs/efr32_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ declare_args() {
chip_enable_multi_ota_requestor = false
}
examples_plat_dir = "${chip_root}/examples/platform/silabs"
silabs_plat_dir = "${chip_root}/src/platform/silabs"
silabs_plat_efr32_wifi_dir = "${chip_root}/src/platform/silabs/efr32/wifi"

assert(efr32_sdk_root != "", "efr32_sdk_root must be specified")
Expand Down

0 comments on commit 6eb654b

Please sign in to comment.