Skip to content

Commit 837b4d9

Browse files
brosahayrosahay-silabs
authored andcommitted
Refactor SILABS_LOGS
1 parent f838219 commit 837b4d9

File tree

1 file changed

+47
-55
lines changed
  • examples/platform/silabs/efr32/rs911x

1 file changed

+47
-55
lines changed

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

+47-55
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ static void wfx_rsi_join_cb(uint16_t status, const uint8_t * buf, const uint16_t
279279
/*
280280
* We should enable retry.. (Need config variable for this)
281281
*/
282-
SILABS_LOG("%s: failed. retry: %d", __func__, wfx_rsi.join_retries);
282+
SILABS_LOG("wfx_rsi_join_cb: failed. retry: %d", wfx_rsi.join_retries);
283283
wfx_retry_interval_handler(is_wifi_disconnection_event, wfx_rsi.join_retries++);
284284
if (is_wifi_disconnection_event || wfx_rsi.join_retries <= WFX_RSI_CONFIG_MAX_JOIN)
285285
{
@@ -292,8 +292,8 @@ static void wfx_rsi_join_cb(uint16_t status, const uint8_t * buf, const uint16_t
292292
/*
293293
* Join was complete - Do the DHCP
294294
*/
295+
SILABS_LOG("wfx_rsi_join_cb: success");
295296
memset(&temp_reset, 0, sizeof(wfx_wifi_scan_ext_t));
296-
SILABS_LOG("%s: join completed.", __func__);
297297
WfxEvent.eventType = WFX_EVT_STA_CONN;
298298
WfxPostEvent(&WfxEvent);
299299
wfx_rsi.join_retries = 0;
@@ -313,7 +313,7 @@ static void wfx_rsi_join_cb(uint16_t status, const uint8_t * buf, const uint16_t
313313
*********************************************************************/
314314
static void wfx_rsi_join_fail_cb(uint16_t status, uint8_t * buf, uint32_t len)
315315
{
316-
SILABS_LOG("%s: error: failed status: %02x", __func__, status);
316+
SILABS_LOG("wfx_rsi_join_fail_cb: status: %02x", status);
317317
WfxEvent_t WfxEvent;
318318
wfx_rsi.join_retries += 1;
319319
wfx_rsi.dev_state &= ~(WFX_RSI_ST_STA_CONNECTING | WFX_RSI_ST_STA_CONNECTED);
@@ -354,31 +354,28 @@ static int32_t wfx_rsi_init(void)
354354
uint8_t buf[RSI_RESPONSE_HOLD_BUFF_SIZE];
355355
extern void rsi_hal_board_init(void);
356356

357-
SILABS_LOG("%s: starting(HEAP_SZ = %d)", __func__, SL_HEAP_SIZE);
357+
SILABS_LOG("wfx_rsi_init: starting(HEAP_SZ = %d)", SL_HEAP_SIZE);
358358
//! Driver initialization
359359
status = rsi_driver_init(wfx_rsi_drv_buf, WFX_RSI_BUF_SZ);
360360
if ((status < RSI_DRIVER_STATUS) || (status > WFX_RSI_BUF_SZ))
361361
{
362-
SILABS_LOG("%s: error: RSI Driver initialization failed with status: %02x", __func__, status);
362+
SILABS_LOG("wfx_rsi_init: rsi_driver_init failed: %02x", status);
363363
return status;
364364
}
365-
366-
SILABS_LOG("%s: rsi_device_init", __func__);
367365
/* ! Redpine module intialisation */
368366
if ((status = rsi_device_init(LOAD_NWP_FW)) != RSI_SUCCESS)
369367
{
370-
SILABS_LOG("%s: error: rsi_device_init failed with status: %02x", __func__, status);
368+
SILABS_LOG("wfx_rsi_init: rsi_device_init failed: %02x", status);
371369
return status;
372370
}
373-
SILABS_LOG("%s: start wireless drv task", __func__);
374371
/*
375372
* Create the driver task
376373
*/
377374
wfx_rsi.drv_task = xTaskCreateStatic((TaskFunction_t) rsi_wireless_driver_task, "rsi_drv", WFX_RSI_WLAN_TASK_SZ, NULL,
378375
WLAN_TASK_PRIORITY, driverRsiTaskStack, &driverRsiTaskBuffer);
379376
if (NULL == wfx_rsi.drv_task)
380377
{
381-
SILABS_LOG("%s: error: rsi_wireless_driver_task failed", __func__);
378+
SILABS_LOG("wfx_rsi_init: failed to create task");
382379
return RSI_ERROR_INVALID_PARAM;
383380
}
384381

@@ -389,40 +386,38 @@ static int32_t wfx_rsi_init(void)
389386
if ((status = rsi_wireless_init(OPER_MODE_0, COEX_MODE_0)) != RSI_SUCCESS)
390387
{
391388
#endif
392-
SILABS_LOG("%s: error: Initialize WiSeConnect failed with status: %02x", __func__, status);
389+
SILABS_LOG("wfx_rsi_init: rsi_wireless_init failed: %02x", status);
393390
return status;
394391
}
395392

396-
SILABS_LOG("%s: get FW version..", __func__);
397393
/*
398394
* Get the MAC and other info to let the user know about it.
399395
*/
400396
if (rsi_wlan_get(RSI_FW_VERSION, buf, sizeof(buf)) != RSI_SUCCESS)
401397
{
402-
SILABS_LOG("%s: error: rsi_wlan_get(RSI_FW_VERSION) failed with status: %02x", __func__, status);
398+
SILABS_LOG("wfx_rsi_init: rsi_wlan_get(RSI_FW_VERSION) failed: %02x", status);
403399
return status;
404400
}
405401

406402
buf[sizeof(buf) - 1] = 0;
407-
SILABS_LOG("%s: RSI firmware version: %s", __func__, buf);
403+
SILABS_LOG("RSI firmware version: %s", buf);
408404
//! Send feature frame
409405
if ((status = rsi_send_feature_frame()) != RSI_SUCCESS)
410406
{
411-
SILABS_LOG("%s: error: rsi_send_feature_frame failed with status: %02x", __func__, status);
407+
SILABS_LOG("error: rsi_send_feature_frame failed: %02x", status);
412408
return status;
413409
}
414410

415-
SILABS_LOG("%s: sent rsi_send_feature_frame", __func__);
416411
/* initializes wlan radio parameters and WLAN supplicant parameters.
417412
*/
418413
(void) rsi_wlan_radio_init(); /* Required so we can get MAC address */
419414
if ((status = rsi_wlan_get(RSI_MAC_ADDRESS, &wfx_rsi.sta_mac.octet[0], RESP_BUFF_SIZE)) != RSI_SUCCESS)
420415
{
421-
SILABS_LOG("%s: error: rsi_wlan_get failed with status: %02x", __func__, status);
416+
SILABS_LOG("wfx_rsi_init: rsi_wlan_get(RSI_MAC_ADDRESS) failed: %02x", status);
422417
return status;
423418
}
424419

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

428423
// Create the message queue
@@ -445,12 +440,12 @@ static int32_t wfx_rsi_init(void)
445440
*/
446441
if ((status = rsi_wlan_register_callbacks(RSI_JOIN_FAIL_CB, wfx_rsi_join_fail_cb)) != RSI_SUCCESS)
447442
{
448-
SILABS_LOG("%s: RSI callback register join failed with status: %02x", __func__, status);
443+
SILABS_LOG("wfx_rsi_init: rsi_wlan_register_callbacks failed: %02x", status);
449444
return status;
450445
}
451446
if ((status = rsi_wlan_register_callbacks(RSI_WLAN_DATA_RECEIVE_NOTIFY_CB, wfx_rsi_wlan_pkt_cb)) != RSI_SUCCESS)
452447
{
453-
SILABS_LOG("%s: RSI callback register data-notify failed with status: %02x", __func__, status);
448+
SILABS_LOG("wfx_rsi_init: rsi_wlan_register_callbacks failed with status: %02x", status);
454449
return status;
455450
}
456451

@@ -459,7 +454,7 @@ static int32_t wfx_rsi_init(void)
459454
#endif
460455

461456
wfx_rsi.dev_state |= WFX_RSI_ST_DEV_READY;
462-
SILABS_LOG("%s: RSI: OK", __func__);
457+
SILABS_LOG("wfx_rsi_init: success");
463458
return RSI_SUCCESS;
464459
}
465460

@@ -488,7 +483,7 @@ static void wfx_rsi_save_ap_info() // translation
488483
#else /* !WIFI_ENABLE_SECURITY_WPA3_TRANSITION */
489484
wfx_rsi.sec.security = WFX_SEC_WPA2;
490485
#endif /* WIFI_ENABLE_SECURITY_WPA3_TRANSITION */
491-
SILABS_LOG("%s: warn: failed with status: %02x", __func__, status);
486+
SILABS_LOG("warn: scan failed with status: %02x", status);
492487
return;
493488
}
494489
wfx_rsi.sec.security = WFX_SEC_UNSPECIFIED;
@@ -524,7 +519,7 @@ static void wfx_rsi_save_ap_info() // translation
524519
break;
525520
}
526521

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

530525
/********************************************************************************************
@@ -541,7 +536,7 @@ static void wfx_rsi_do_join(void)
541536

542537
if (wfx_rsi.dev_state & (WFX_RSI_ST_STA_CONNECTING | WFX_RSI_ST_STA_CONNECTED))
543538
{
544-
SILABS_LOG("%s: not joining - already in progress", __func__);
539+
SILABS_LOG("wfx_rsi_do_join: already in progress");
545540
}
546541
else
547542
{
@@ -564,11 +559,11 @@ static void wfx_rsi_do_join(void)
564559
connect_security_mode = RSI_OPEN;
565560
break;
566561
default:
567-
SILABS_LOG("%s: error: unknown security type.", __func__);
562+
SILABS_LOG("wfx_rsi_do_join: error: unknown security type.");
568563
return;
569564
}
570565

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

573568
/*
574569
* Join the network
@@ -580,7 +575,7 @@ static void wfx_rsi_do_join(void)
580575

581576
if ((status = rsi_wlan_register_callbacks(RSI_JOIN_FAIL_CB, wfx_rsi_join_fail_cb)) != RSI_SUCCESS)
582577
{
583-
SILABS_LOG("%s: RSI callback register join failed with status: %02x", __func__, status);
578+
SILABS_LOG("wfx_rsi_do_join: rsi_wlan_register_callbacks failed: %02x", status);
584579
}
585580

586581
/* Try to connect Wifi with given Credentials
@@ -596,14 +591,14 @@ static void wfx_rsi_do_join(void)
596591
{
597592

598593
wfx_rsi.dev_state &= ~WFX_RSI_ST_STA_CONNECTING;
599-
SILABS_LOG("%s: rsi_wlan_connect_async failed with status: %02x on try %d", __func__, status, wfx_rsi.join_retries);
594+
SILABS_LOG("wfx_rsi_do_join: rsi_wlan_connect_async failed: %02x on try %d", status, wfx_rsi.join_retries);
600595

601596
wfx_retry_interval_handler(is_wifi_disconnection_event, wfx_rsi.join_retries);
602597
wfx_rsi.join_retries++;
603598
}
604599
else
605600
{
606-
SILABS_LOG("%s: starting JOIN to %s after %d tries\n", __func__, (char *) &wfx_rsi.sec.ssid[0],
601+
SILABS_LOG("wfx_rsi_do_join: starting join to %s after %d tries", (char *) &wfx_rsi.sec.ssid[0],
607602
wfx_rsi.join_retries);
608603
break; // exit while loop
609604
}
@@ -701,7 +696,7 @@ void ProcessEvent(WfxEvent_t inEvent)
701696
switch (inEvent.eventType)
702697
{
703698
case WFX_EVT_STA_CONN:
704-
SILABS_LOG("%s: starting LwIP STA", __func__);
699+
SILABS_LOG("_onWFXEvent: WFX_EVT_STA_CONN");
705700
wfx_rsi.dev_state |= WFX_RSI_ST_STA_CONNECTED;
706701
ResetDHCPNotificationFlags();
707702
wfx_lwip_set_sta_link_up();
@@ -712,10 +707,10 @@ void ProcessEvent(WfxEvent_t inEvent)
712707
// is independant of IP connectivity.
713708
break;
714709
case WFX_EVT_STA_DISCONN:
710+
SILABS_LOG("_onWFXEvent: WFX_EVT_STA_DISCONN");
715711
// TODO: This event is not being posted anywhere, seems to be a dead code or we are missing something
716712
wfx_rsi.dev_state &=
717713
~(WFX_RSI_ST_STA_READY | WFX_RSI_ST_STA_CONNECTING | WFX_RSI_ST_STA_CONNECTED | WFX_RSI_ST_STA_DHCP_DONE);
718-
SILABS_LOG("%s: disconnect notify", __func__);
719714
/* TODO: Implement disconnect notify */
720715
ResetDHCPNotificationFlags();
721716
wfx_lwip_set_sta_link_down(); // Internally dhcpclient_poll(netif) ->
@@ -736,32 +731,30 @@ void ProcessEvent(WfxEvent_t inEvent)
736731
rsi_rsp_scan_t scan_rsp = { 0 };
737732
int32_t status = rsi_wlan_bgscan_profile(1, &scan_rsp, sizeof(scan_rsp));
738733

739-
if (status)
734+
if (status != RSI_SUCCESS)
740735
{
741-
SILABS_LOG("SSID scan failed: %02x ", status);
736+
SILABS_LOG("rsi_wlan_bgscan failed: %02x ", status);
737+
return;
742738
}
743-
else
739+
rsi_scan_info_t * scan;
740+
wfx_wifi_scan_result_t ap;
741+
for (int x = 0; x < scan_rsp.scan_count[0]; x++)
744742
{
745-
rsi_scan_info_t * scan;
746-
wfx_wifi_scan_result_t ap;
747-
for (int x = 0; x < scan_rsp.scan_count[0]; x++)
743+
scan = &scan_rsp.scan_info[x];
744+
// is it a scan all or target scan
745+
if (!wfx_rsi.scan_ssid || (wfx_rsi.scan_ssid && strcmp(wfx_rsi.scan_ssid, (char *) scan->ssid) == CMP_SUCCESS))
748746
{
749-
scan = &scan_rsp.scan_info[x];
750-
// is it a scan all or target scan
751-
if (!wfx_rsi.scan_ssid || (wfx_rsi.scan_ssid && strcmp(wfx_rsi.scan_ssid, (char *) scan->ssid) == CMP_SUCCESS))
747+
strncpy(ap.ssid, (char *) scan->ssid, MIN(sizeof(ap.ssid), sizeof(scan->ssid)));
748+
ap.security = scan->security_mode;
749+
ap.rssi = (-1) * scan->rssi_val;
750+
configASSERT(sizeof(ap.bssid) >= BSSID_LEN);
751+
configASSERT(sizeof(scan->bssid) >= BSSID_LEN);
752+
memcpy(ap.bssid, scan->bssid, BSSID_LEN);
753+
(*wfx_rsi.scan_cb)(&ap);
754+
755+
if (wfx_rsi.scan_ssid)
752756
{
753-
strncpy(ap.ssid, (char *) scan->ssid, MIN(sizeof(ap.ssid), sizeof(scan->ssid)));
754-
ap.security = scan->security_mode;
755-
ap.rssi = (-1) * scan->rssi_val;
756-
configASSERT(sizeof(ap.bssid) >= BSSID_LEN);
757-
configASSERT(sizeof(scan->bssid) >= BSSID_LEN);
758-
memcpy(ap.bssid, scan->bssid, BSSID_LEN);
759-
(*wfx_rsi.scan_cb)(&ap);
760-
761-
if (wfx_rsi.scan_ssid)
762-
{
763-
break; // we found the targeted ssid.
764-
}
757+
break; // we found the targeted ssid.
765758
}
766759
}
767760
}
@@ -813,7 +806,7 @@ void wfx_rsi_task(void * arg)
813806
uint32_t rsi_status = wfx_rsi_init();
814807
if (rsi_status != RSI_SUCCESS)
815808
{
816-
SILABS_LOG("%s: error: wfx_rsi_init with status: %02x", __func__, rsi_status);
809+
SILABS_LOG("error: wfx_rsi_init with status: %02x", rsi_status);
817810
return;
818811
}
819812
WfxEvent_t wfxEvent;
@@ -853,8 +846,7 @@ void wfx_dhcp_got_ipv4(uint32_t ip)
853846
wfx_rsi.ip4_addr[1] = (ip >> 8) & HEX_VALUE_FF;
854847
wfx_rsi.ip4_addr[2] = (ip >> 16) & HEX_VALUE_FF;
855848
wfx_rsi.ip4_addr[3] = (ip >> 24) & HEX_VALUE_FF;
856-
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],
857-
wfx_rsi.ip4_addr[3]);
849+
SILABS_LOG("DHCP OK: IP=%d.%d.%d.%d", wfx_rsi.ip4_addr[0], wfx_rsi.ip4_addr[1], wfx_rsi.ip4_addr[2], wfx_rsi.ip4_addr[3]);
858850
/* Notify the Connectivity Manager - via the app */
859851
wfx_rsi.dev_state |= WFX_RSI_ST_STA_DHCP_DONE;
860852
wfx_ip_changed_notify(IP_STATUS_SUCCESS);

0 commit comments

Comments
 (0)