Skip to content

Commit 2f75be5

Browse files
committed
addressing the review comments
1 parent 8eb2380 commit 2f75be5

File tree

2 files changed

+46
-52
lines changed

2 files changed

+46
-52
lines changed

examples/platform/silabs/efr32/rs911x/rsi_if.c

+32-32
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ static void wfx_rsi_join_cb(uint16_t status, const uint8_t * buf, const uint16_t
273273
/*
274274
* We should enable retry.. (Need config variable for this)
275275
*/
276-
SILABS_LOG("%s: failed. retry: %d", __func__, wfx_rsi.join_retries);
276+
SILABS_LOG("wfx_rsi_join_cb: failed. retry: %d", wfx_rsi.join_retries);
277277
wfx_retry_connection(++wfx_rsi.join_retries);
278278
}
279279
else
@@ -282,7 +282,7 @@ static void wfx_rsi_join_cb(uint16_t status, const uint8_t * buf, const uint16_t
282282
* Join was complete - Do the DHCP
283283
*/
284284
memset(&temp_reset, 0, sizeof(wfx_wifi_scan_ext_t));
285-
SILABS_LOG("%s: join completed.", __func__);
285+
SILABS_LOG("wfx_rsi_join_cb: join completed.");
286286
WfxEvent.eventType = WFX_EVT_STA_CONN;
287287
WfxPostEvent(&WfxEvent);
288288
wfx_rsi.join_retries = 0;
@@ -301,7 +301,7 @@ static void wfx_rsi_join_cb(uint16_t status, const uint8_t * buf, const uint16_t
301301
*********************************************************************/
302302
static void wfx_rsi_join_fail_cb(uint16_t status, uint8_t * buf, uint32_t len)
303303
{
304-
SILABS_LOG("%s: error: failed status: %02x", __func__, status);
304+
SILABS_LOG("wfx_rsi_join_fail_cb: error: failed status: %02x", status);
305305
WfxEvent_t WfxEvent;
306306
wfx_rsi.join_retries += 1;
307307
wfx_rsi.dev_state &= ~(WFX_RSI_ST_STA_CONNECTING | WFX_RSI_ST_STA_CONNECTED);
@@ -341,31 +341,31 @@ static int32_t wfx_rsi_init(void)
341341
uint8_t buf[RSI_RESPONSE_HOLD_BUFF_SIZE];
342342
extern void rsi_hal_board_init(void);
343343

344-
SILABS_LOG("%s: starting(HEAP_SZ = %d)", __func__, SL_HEAP_SIZE);
344+
SILABS_LOG("wfx_rsi_init: starting(HEAP_SZ = %d)", SL_HEAP_SIZE);
345345
//! Driver initialization
346346
status = rsi_driver_init(wfx_rsi_drv_buf, WFX_RSI_BUF_SZ);
347347
if ((status < RSI_DRIVER_STATUS) || (status > WFX_RSI_BUF_SZ))
348348
{
349-
SILABS_LOG("%s: error: RSI Driver initialization failed with status: %02x", __func__, status);
349+
SILABS_LOG("wfx_rsi_init: error: RSI Driver initialization failed with status: %02x", status);
350350
return status;
351351
}
352352

353-
SILABS_LOG("%s: rsi_device_init", __func__);
353+
SILABS_LOG("wfx_rsi_init: rsi_device_init", __func__);
354354
/* ! Redpine module intialisation */
355355
if ((status = rsi_device_init(LOAD_NWP_FW)) != RSI_SUCCESS)
356356
{
357-
SILABS_LOG("%s: error: rsi_device_init failed with status: %02x", __func__, status);
357+
SILABS_LOG("wfx_rsi_init: error: rsi_device_init failed with status: %02x", status);
358358
return status;
359359
}
360-
SILABS_LOG("%s: start wireless drv task", __func__);
360+
SILABS_LOG("wfx_rsi_init: start wireless drv task", __func__);
361361
/*
362362
* Create the driver task
363363
*/
364364
wfx_rsi.drv_task = xTaskCreateStatic((TaskFunction_t) rsi_wireless_driver_task, "rsi_drv", WFX_RSI_WLAN_TASK_SZ, NULL,
365365
WLAN_TASK_PRIORITY, driverRsiTaskStack, &driverRsiTaskBuffer);
366366
if (NULL == wfx_rsi.drv_task)
367367
{
368-
SILABS_LOG("%s: error: rsi_wireless_driver_task failed", __func__);
368+
SILABS_LOG("wfx_rsi_init: error: rsi_wireless_driver_task failed", __func__);
369369
return RSI_ERROR_INVALID_PARAM;
370370
}
371371

@@ -376,40 +376,40 @@ static int32_t wfx_rsi_init(void)
376376
if ((status = rsi_wireless_init(OPER_MODE_0, COEX_MODE_0)) != RSI_SUCCESS)
377377
{
378378
#endif
379-
SILABS_LOG("%s: error: Initialize WiSeConnect failed with status: %02x", __func__, status);
379+
SILABS_LOG("wfx_rsi_init: error: Initialize WiSeConnect failed with status: %02x", status);
380380
return status;
381381
}
382382

383-
SILABS_LOG("%s: get FW version..", __func__);
383+
SILABS_LOG("wfx_rsi_init: get FW version..", __func__);
384384
/*
385385
* Get the MAC and other info to let the user know about it.
386386
*/
387387
if (rsi_wlan_get(RSI_FW_VERSION, buf, sizeof(buf)) != RSI_SUCCESS)
388388
{
389-
SILABS_LOG("%s: error: rsi_wlan_get(RSI_FW_VERSION) failed with status: %02x", __func__, status);
389+
SILABS_LOG("wfx_rsi_init: error: rsi_wlan_get(RSI_FW_VERSION) failed with status: %02x", status);
390390
return status;
391391
}
392392

393393
buf[sizeof(buf) - 1] = 0;
394-
SILABS_LOG("%s: RSI firmware version: %s", __func__, buf);
394+
SILABS_LOG("wfx_rsi_init: RSI firmware version: %s", buf);
395395
//! Send feature frame
396396
if ((status = rsi_send_feature_frame()) != RSI_SUCCESS)
397397
{
398-
SILABS_LOG("%s: error: rsi_send_feature_frame failed with status: %02x", __func__, status);
398+
SILABS_LOG("wfx_rsi_init: error: rsi_send_feature_frame failed with status: %02x", status);
399399
return status;
400400
}
401401

402-
SILABS_LOG("%s: sent rsi_send_feature_frame", __func__);
402+
SILABS_LOG("wfx_rsi_init: sent rsi_send_feature_frame", __func__);
403403
/* initializes wlan radio parameters and WLAN supplicant parameters.
404404
*/
405405
(void) rsi_wlan_radio_init(); /* Required so we can get MAC address */
406406
if ((status = rsi_wlan_get(RSI_MAC_ADDRESS, &wfx_rsi.sta_mac.octet[0], RESP_BUFF_SIZE)) != RSI_SUCCESS)
407407
{
408-
SILABS_LOG("%s: error: rsi_wlan_get failed with status: %02x", __func__, status);
408+
SILABS_LOG("wfx_rsi_init: error: rsi_wlan_get failed with status: %02x", status);
409409
return status;
410410
}
411411

412-
SILABS_LOG("%s: WLAN: MAC %02x:%02x:%02x %02x:%02x:%02x", __func__, wfx_rsi.sta_mac.octet[0], wfx_rsi.sta_mac.octet[1],
412+
SILABS_LOG("wfx_rsi_init: WLAN: MAC %02x:%02x:%02x %02x:%02x:%02x", wfx_rsi.sta_mac.octet[0], wfx_rsi.sta_mac.octet[1],
413413
wfx_rsi.sta_mac.octet[2], wfx_rsi.sta_mac.octet[3], wfx_rsi.sta_mac.octet[4], wfx_rsi.sta_mac.octet[5]);
414414

415415
// Create the message queue
@@ -432,12 +432,12 @@ static int32_t wfx_rsi_init(void)
432432
*/
433433
if ((status = rsi_wlan_register_callbacks(RSI_JOIN_FAIL_CB, wfx_rsi_join_fail_cb)) != RSI_SUCCESS)
434434
{
435-
SILABS_LOG("%s: RSI callback register join failed with status: %02x", __func__, status);
435+
SILABS_LOG("wfx_rsi_init: RSI callback register join failed with status: %02x", status);
436436
return status;
437437
}
438438
if ((status = rsi_wlan_register_callbacks(RSI_WLAN_DATA_RECEIVE_NOTIFY_CB, wfx_rsi_wlan_pkt_cb)) != RSI_SUCCESS)
439439
{
440-
SILABS_LOG("%s: RSI callback register data-notify failed with status: %02x", __func__, status);
440+
SILABS_LOG("wfx_rsi_init: RSI callback register data-notify failed with status: %02x", status);
441441
return status;
442442
}
443443

@@ -446,7 +446,7 @@ static int32_t wfx_rsi_init(void)
446446
#endif
447447

448448
wfx_rsi.dev_state |= WFX_RSI_ST_DEV_READY;
449-
SILABS_LOG("%s: RSI: OK", __func__);
449+
SILABS_LOG("wfx_rsi_init: RSI: OK", __func__);
450450
return RSI_SUCCESS;
451451
}
452452

@@ -475,7 +475,7 @@ static void wfx_rsi_save_ap_info() // translation
475475
#else /* !WIFI_ENABLE_SECURITY_WPA3_TRANSITION */
476476
wfx_rsi.sec.security = WFX_SEC_WPA2;
477477
#endif /* WIFI_ENABLE_SECURITY_WPA3_TRANSITION */
478-
SILABS_LOG("%s: warn: failed with status: %02x", __func__, status);
478+
SILABS_LOG("wfx_rsi_save_ap_info: warn: failed with status: %02x", status);
479479
return;
480480
}
481481
wfx_rsi.sec.security = WFX_SEC_UNSPECIFIED;
@@ -511,7 +511,7 @@ static void wfx_rsi_save_ap_info() // translation
511511
break;
512512
}
513513

514-
SILABS_LOG("%s: WLAN: connecting to %s, sec=%d, status=%02x", __func__, &wfx_rsi.sec.ssid[0], wfx_rsi.sec.security, status);
514+
SILABS_LOG("wfx_rsi_save_ap_info: WLAN: connecting to %s, sec=%d, status=%02x", &wfx_rsi.sec.ssid[0], wfx_rsi.sec.security, status);
515515
}
516516

517517
/********************************************************************************************
@@ -528,7 +528,7 @@ static void wfx_rsi_do_join(void)
528528

529529
if (wfx_rsi.dev_state & (WFX_RSI_ST_STA_CONNECTING | WFX_RSI_ST_STA_CONNECTED))
530530
{
531-
SILABS_LOG("%s: not joining - already in progress", __func__);
531+
SILABS_LOG("wfx_rsi_do_join: not joining - already in progress");
532532
}
533533
else
534534
{
@@ -551,11 +551,11 @@ static void wfx_rsi_do_join(void)
551551
connect_security_mode = RSI_OPEN;
552552
break;
553553
default:
554-
SILABS_LOG("%s: error: unknown security type.", __func__);
554+
SILABS_LOG("wfx_rsi_do_join: error: unknown security type.");
555555
return;
556556
}
557557

558-
SILABS_LOG("%s: WLAN: connecting to %s, sec=%d", __func__, &wfx_rsi.sec.ssid[0], wfx_rsi.sec.security);
558+
SILABS_LOG("wfx_rsi_do_join: WLAN: connecting to %s, sec=%d", &wfx_rsi.sec.ssid[0], wfx_rsi.sec.security);
559559

560560
/*
561561
* Join the network
@@ -567,7 +567,7 @@ static void wfx_rsi_do_join(void)
567567

568568
if ((status = rsi_wlan_register_callbacks(RSI_JOIN_FAIL_CB, wfx_rsi_join_fail_cb)) != RSI_SUCCESS)
569569
{
570-
SILABS_LOG("%s: RSI callback register join failed with status: %02x", __func__, status);
570+
SILABS_LOG("wfx_rsi_do_join: RSI callback register join failed with status: %02x", status);
571571
}
572572

573573
/* Try to connect Wifi with given Credentials
@@ -577,12 +577,12 @@ static void wfx_rsi_do_join(void)
577577
wfx_rsi_join_cb)) != RSI_SUCCESS)
578578
{
579579
wfx_rsi.dev_state &= ~WFX_RSI_ST_STA_CONNECTING;
580-
SILABS_LOG("%s: rsi_wlan_connect_async failed with status: %02x on try %d", __func__, status, wfx_rsi.join_retries);
580+
SILABS_LOG("wfx_rsi_do_join: rsi_wlan_connect_async failed with status: %02x on try %d", status, wfx_rsi.join_retries);
581581
wfx_retry_connection(++wfx_rsi.join_retries);
582582
}
583583
else
584584
{
585-
SILABS_LOG("%s: starting JOIN to %s after %d tries\n", __func__, (char *) &wfx_rsi.sec.ssid[0], wfx_rsi.join_retries);
585+
SILABS_LOG("wfx_rsi_do_join: starting JOIN to %s after %d tries\n", (char *) &wfx_rsi.sec.ssid[0], wfx_rsi.join_retries);
586586
}
587587
}
588588
}
@@ -677,7 +677,7 @@ void ProcessEvent(WfxEvent_t inEvent)
677677
switch (inEvent.eventType)
678678
{
679679
case WFX_EVT_STA_CONN:
680-
SILABS_LOG("%s: starting LwIP STA", __func__);
680+
SILABS_LOG("Starting LwIP STA");
681681
wfx_rsi.dev_state |= WFX_RSI_ST_STA_CONNECTED;
682682
ResetDHCPNotificationFlags();
683683
wfx_lwip_set_sta_link_up();
@@ -691,7 +691,7 @@ void ProcessEvent(WfxEvent_t inEvent)
691691
// TODO: This event is not being posted anywhere, seems to be a dead code or we are missing something
692692
wfx_rsi.dev_state &=
693693
~(WFX_RSI_ST_STA_READY | WFX_RSI_ST_STA_CONNECTING | WFX_RSI_ST_STA_CONNECTED | WFX_RSI_ST_STA_DHCP_DONE);
694-
SILABS_LOG("%s: disconnect notify", __func__);
694+
SILABS_LOG("Disconnect notify");
695695
/* TODO: Implement disconnect notify */
696696
ResetDHCPNotificationFlags();
697697
wfx_lwip_set_sta_link_down(); // Internally dhcpclient_poll(netif) ->
@@ -789,7 +789,7 @@ void wfx_rsi_task(void * arg)
789789
uint32_t rsi_status = wfx_rsi_init();
790790
if (rsi_status != RSI_SUCCESS)
791791
{
792-
SILABS_LOG("%s: error: wfx_rsi_init with status: %02x", __func__, rsi_status);
792+
SILABS_LOG("wfx_rsi_task: error: wfx_rsi_init with status: %02x", rsi_status);
793793
return;
794794
}
795795
WfxEvent_t wfxEvent;
@@ -829,7 +829,7 @@ void wfx_dhcp_got_ipv4(uint32_t ip)
829829
wfx_rsi.ip4_addr[1] = (ip >> 8) & HEX_VALUE_FF;
830830
wfx_rsi.ip4_addr[2] = (ip >> 16) & HEX_VALUE_FF;
831831
wfx_rsi.ip4_addr[3] = (ip >> 24) & HEX_VALUE_FF;
832-
SILABS_LOG("%s: DHCP OK: IP=%d.%d.%d.%d", __func__, wfx_rsi.ip4_addr[0], wfx_rsi.ip4_addr[1], wfx_rsi.ip4_addr[2],
832+
SILABS_LOG("wfx_dhcp_got_ipv4: DHCP OK: IP=%d.%d.%d.%d", wfx_rsi.ip4_addr[0], wfx_rsi.ip4_addr[1], wfx_rsi.ip4_addr[2],
833833
wfx_rsi.ip4_addr[3]);
834834
/* Notify the Connectivity Manager - via the app */
835835
wfx_rsi.dev_state |= WFX_RSI_ST_STA_DHCP_DONE;

examples/platform/silabs/wifi/wfx_notify.cpp

+14-20
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <stdio.h>
1919
#include <stdlib.h>
2020
#include <string.h>
21-
21+
#include <icd/server/ICDServerConfig.h>
2222
#include "AppConfig.h"
2323
#include "BaseApplication.h"
2424

@@ -37,8 +37,10 @@
3737
using namespace ::chip;
3838
using namespace ::chip::DeviceLayer;
3939

40-
static uint16_t retryInterval = WLAN_MIN_RETRY_TIMER_MS;
41-
static osTimerId_t sRetryTimer;
40+
namespace {
41+
uint16_t retryInterval = WLAN_MIN_RETRY_TIMER_MS;
42+
osTimerId_t sRetryTimer;
43+
}
4244
/*
4345
* Notifications to the upper-layer
4446
* All done in the context of the RSI/WiFi task (rsi_if.c)
@@ -47,7 +49,6 @@ static osTimerId_t sRetryTimer;
4749
static void RetryConnectionTimerHandler(void * arg)
4850
{
4951
#if CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE
50-
// TODO: remove this once it is fixed in the wifi sdk SI91X-15845
5152
wfx_rsi_power_save(RSI_ACTIVE, HIGH_PERFORMANCE);
5253
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE
5354
if (wfx_connect_to_ap() != SL_STATUS_OK)
@@ -69,12 +70,7 @@ void wfx_started_notify()
6970

7071
// Creating a timer which will be used to retry connection with AP
7172
sRetryTimer = osTimerNew(RetryConnectionTimerHandler, osTimerOnce, NULL, NULL);
72-
if (sRetryTimer == NULL)
73-
{
74-
return;
75-
}
76-
77-
ChipLogProgress(DeviceLayer, "wfx_started_notify: started.");
73+
VerifyOrReturnError(sRetryTimer != NULL, SL_STATUS_ALLOCATION_FAILED);
7874

7975
memset(&evt, 0, sizeof(evt));
8076
evt.header.id = SL_WFX_STARTUP_IND_ID;
@@ -99,16 +95,12 @@ void wfx_connected_notify(int32_t status, sl_wfx_mac_address_t * ap)
9995
{
10096
sl_wfx_connect_ind_t evt;
10197

102-
ChipLogProgress(DeviceLayer, "wfx_connected_notify : started.");
103-
10498
if (status != SUCCESS_STATUS)
10599
{
106100
ChipLogProgress(DeviceLayer, "wfx_connected_notify : error: failed status: %ld.", status);
107101
return;
108102
}
109103

110-
ChipLogProgress(DeviceLayer, "wfx_connected_notify : connected.");
111-
112104
memset(&evt, 0, sizeof(evt));
113105
evt.header.id = SL_WFX_CONNECT_IND_ID;
114106
evt.header.length = sizeof evt;
@@ -132,8 +124,6 @@ void wfx_disconnected_notify(int32_t status)
132124
{
133125
sl_wfx_disconnect_ind_t evt;
134126

135-
ChipLogProgress(DeviceLayer, "wfx_disconnected_notify: started.");
136-
137127
memset(&evt, 0, sizeof(evt));
138128
evt.header.id = SL_WFX_DISCONNECT_IND_ID;
139129
evt.header.length = sizeof evt;
@@ -152,8 +142,6 @@ void wfx_ipv6_notify(int got_ip)
152142
{
153143
sl_wfx_generic_message_t eventData;
154144

155-
ChipLogProgress(DeviceLayer, "wfx_ipv6_notify: started.");
156-
157145
memset(&eventData, 0, sizeof(eventData));
158146
eventData.header.id = got_ip ? IP_EVENT_GOT_IP6 : IP_EVENT_STA_LOST_IP;
159147
eventData.header.length = sizeof(eventData.header);
@@ -171,8 +159,6 @@ void wfx_ip_changed_notify(int got_ip)
171159
{
172160
sl_wfx_generic_message_t eventData;
173161

174-
ChipLogProgress(DeviceLayer, "wfx_ip_changed_notify: started.");
175-
176162
memset(&eventData, 0, sizeof(eventData));
177163
eventData.header.id = got_ip ? IP_EVENT_STA_GOT_IP : IP_EVENT_STA_LOST_IP;
178164
eventData.header.length = sizeof(eventData.header);
@@ -200,6 +186,10 @@ void wfx_retry_connection(uint16_t retryAttempt)
200186
if (osTimerStart(sRetryTimer, pdMS_TO_TICKS(WLAN_RETRY_TIMER_MS)) != osOK)
201187
{
202188
ChipLogProgress(DeviceLayer, "Failed to start retry timer");
189+
// Sending the join command if retry timer failed to start
190+
if (wfx_connect_to_ap() != SL_STATUS_OK) {
191+
ChipLogError(DeviceLayer, "wfx_connect_to_ap() failed.");
192+
}
203193
return;
204194
}
205195
}
@@ -222,6 +212,10 @@ void wfx_retry_connection(uint16_t retryAttempt)
222212
if (osTimerStart(sRetryTimer, pdMS_TO_TICKS(retryInterval)) != osOK)
223213
{
224214
ChipLogProgress(DeviceLayer, "Failed to start retry timer");
215+
// Sending the join command if retry timer failed to start
216+
if (wfx_connect_to_ap() != SL_STATUS_OK) {
217+
ChipLogError(DeviceLayer, "wfx_connect_to_ap() failed.");
218+
}
225219
return;
226220
}
227221
#if CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE

0 commit comments

Comments
 (0)