Skip to content

Commit

Permalink
Added fic for echo system
Browse files Browse the repository at this point in the history
  • Loading branch information
shgutte committed Oct 17, 2023
1 parent 8eca744 commit 862d6d4
Showing 1 changed file with 20 additions and 25 deletions.
45 changes: 20 additions & 25 deletions examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ bool is_wifi_disconnection_event = false;
uint32_t retryInterval = WLAN_MIN_RETRY_TIMER_MS;
volatile bool scan_results_complete = false;
volatile bool bg_scan_results_complete = false;
volatile bool scan_in_progress = false;
#define WIFI_SCAN_TIMEOUT_TICK 10000

extern osSemaphoreId_t sl_rs_ble_init_sem;
Expand Down Expand Up @@ -295,7 +294,6 @@ sl_status_t scan_callback_handler(sl_wifi_event_t event, sl_wifi_scan_result_t *
{
callback_status = *(sl_status_t *) scan_result;
scan_results_complete = true;
scan_in_progress = false;
#if WIFI_ENABLE_SECURITY_WPA3_TRANSITION
wfx_rsi.sec.security = WFX_SEC_WPA3;
#else
Expand Down Expand Up @@ -335,6 +333,7 @@ sl_status_t scan_callback_handler(sl_wifi_event_t event, sl_wifi_scan_result_t *
wfx_rsi.sec.security = WFX_SEC_UNSPECIFIED;
break;
}
wfx_rsi.dev_state &= ~WFX_RSI_ST_SCANSTARTED;
scan_results_complete = true;
return SL_STATUS_OK;
}
Expand All @@ -343,30 +342,28 @@ sl_status_t show_scan_results(sl_wifi_scan_result_t * scan_result)
ARGS_CHECK_NULL_POINTER(scan_result);
int x;
wfx_wifi_scan_result_t ap;
if (wfx_rsi.dev_state & WFX_RSI_ST_STA_CONNECTED)
for (x = 0; x < (int)scan_result->scan_count; x++)
{
for (x = 0; x < (int) scan_result->scan_count; x++)
strcpy(&ap.ssid[0], (char *) &scan_result->scan_info[x].ssid);
if (wfx_rsi.scan_ssid)
{
strcpy(&ap.ssid[0], (char *) &scan_result->scan_info[x].ssid);
if (wfx_rsi.scan_ssid)
{
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.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);
}
}
else
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.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);
break;
}
}
else
{
ap.security = 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);
}
}
wfx_rsi.dev_state &= ~WFX_RSI_ST_SCANSTARTED;
(*wfx_rsi.scan_cb)((wfx_wifi_scan_result_t *) 0);
Expand All @@ -382,7 +379,6 @@ sl_status_t bg_scan_callback_handler(sl_wifi_event_t event, sl_wifi_scan_result_
{
callback_status = show_scan_results(result);
bg_scan_results_complete = true;
scan_in_progress = false;
return SL_STATUS_OK;
}
/***************************************************************************************
Expand All @@ -395,18 +391,18 @@ sl_status_t bg_scan_callback_handler(sl_wifi_event_t event, sl_wifi_scan_result_
*******************************************************************************************/
static void wfx_rsi_save_ap_info() // translation
{
if(wfx_rsi.dev_state & WFX_RSI_ST_SCANSTARTED)
{
return;
}
wfx_rsi.dev_state |= WFX_RSI_ST_SCANSTARTED;
sl_status_t status = SL_STATUS_OK;
sl_wifi_scan_configuration_t wifi_scan_configuration = { 0 };
wifi_scan_configuration = default_wifi_scan_configuration;
sl_wifi_ssid_t ssid_arg;
ssid_arg.length = strlen(wfx_rsi.sec.ssid);
memcpy(ssid_arg.value, (int8_t *) &wfx_rsi.sec.ssid[0], ssid_arg.length);
sl_wifi_set_scan_callback(scan_callback_handler, NULL);
if(scan_in_progress)
{
return;
}
scan_in_progress = true;
status = sl_wifi_start_scan(SL_WIFI_CLIENT_2_4GHZ_INTERFACE, &ssid_arg, &wifi_scan_configuration);
if (SL_STATUS_IN_PROGRESS == status)
{
Expand Down Expand Up @@ -679,7 +675,6 @@ void wfx_rsi_task(void * arg)
advanced_scan_configuration.trigger_level_change = ADV_RSSI_TOLERANCE_THRESHOLD;
advanced_scan_configuration.enable_multi_probe = ADV_MULTIPROBE;
status = sl_wifi_set_advanced_scan_configuration(&advanced_scan_configuration);

if (wfx_rsi.dev_state & WFX_RSI_ST_STA_CONNECTED)
{
/* Terminate with end of scan which is no ap sent back */
Expand All @@ -691,7 +686,7 @@ void wfx_rsi_task(void * arg)
wifi_scan_configuration = default_wifi_scan_configuration;
}
sl_wifi_set_scan_callback(bg_scan_callback_handler, NULL);
scan_in_progress = true;
wfx_rsi.dev_state |= WFX_RSI_ST_SCANSTARTED;
status = sl_wifi_start_scan(SL_WIFI_CLIENT_2_4GHZ_INTERFACE, NULL, &wifi_scan_configuration);
if (SL_STATUS_IN_PROGRESS == status)
{
Expand Down

0 comments on commit 862d6d4

Please sign in to comment.