[EFR32] WF200 Wifi diagnostics and overrun counter changes (#23609)

* WF200 Wifi diagnostics and overrun counter changes

* Added changes according to comments

* Restyled by whitespace

* Restyled by clang-format

* Added changes according to comments

* Restyled by whitespace

* Added changes according to comments - WF200 build error fix

Co-authored-by: Restyled.io <commits@restyled.io>
diff --git a/examples/platform/efr32/wf200/host_if.cpp b/examples/platform/efr32/wf200/host_if.cpp
index d6f9041..60b914c 100644
--- a/examples/platform/efr32/wf200/host_if.cpp
+++ b/examples/platform/efr32/wf200/host_if.cpp
@@ -60,6 +60,7 @@
 TaskHandle_t wfx_events_task_handle;
 static sl_wfx_mac_address_t ap_mac;
 static uint32_t sta_ip;
+static wfx_wifi_scan_result_t ap_info;
 
 // Set Scan Parameters
 #define ACTIVE_CHANNEL_TIME 110
@@ -88,6 +89,9 @@
 /* station network interface structures */
 struct netif * sta_netif;
 wfx_wifi_provision_t wifi_provision;
+sl_wfx_get_counters_cnf_t * counters;
+sl_wfx_get_counters_cnf_t * Tempcounters;
+#define PUT_COUNTER(name) EFR32_LOG("%-24s %lu\r\n", #name, (unsigned long) counters->body.count_##name);
 
 bool hasNotifiedIPV6             = false;
 bool hasNotifiedIPV4             = false;
@@ -111,7 +115,7 @@
 static void wfx_events_task(void * p_arg);
 
 /* WF200 host callbacks */
-static void sl_wfx_connect_callback(uint8_t * mac, uint32_t status);
+static void sl_wfx_connect_callback(sl_wfx_connect_ind_body_t connect_indication_body);
 static void sl_wfx_disconnect_callback(uint8_t * mac, uint16_t reason);
 static void sl_wfx_generic_status_callback(sl_wfx_generic_ind_t * frame);
 
@@ -123,12 +127,11 @@
 static void sl_wfx_ap_client_rejected_callback(uint32_t status, uint8_t * mac);
 #endif
 
+extern uint32_t gOverrunCount;
+
 /***************************************************************************
- * @fn  static void wfx_events_task_start()
  * @brief
  * Creates WFX events processing task.
- * @param[in] None
- * @return None
  ******************************************************************************/
 static void wfx_events_task_start()
 {
@@ -144,7 +147,6 @@
 }
 
 /****************************************************************************
- * @fn   sl_status_t sl_wfx_host_process_event(sl_wfx_generic_message_t *event_payload)
  * @brief
  * Called when the driver needs to post an event
  * @param[in]  event_payload:
@@ -163,7 +165,7 @@
     }
     case SL_WFX_CONNECT_IND_ID: {
         sl_wfx_connect_ind_t * connect_indication = (sl_wfx_connect_ind_t *) event_payload;
-        sl_wfx_connect_callback(connect_indication->body.mac, connect_indication->body.status);
+        sl_wfx_connect_callback(connect_indication->body);
         break;
     }
     case SL_WFX_DISCONNECT_IND_ID: {
@@ -272,11 +274,9 @@
 
 #ifdef SL_WFX_CONFIG_SCAN
 /****************************************************************************
- * @fn   static void sl_wfx_scan_result_callback(sl_wfx_scan_result_ind_body_t *scan_result)
  * @brief
  * Callback for individual scan result
- * @param[in] scan_result:
- * @return None
+ * @param[in] scan_result: Scan result of all SSID's
  *****************************************************************************/
 static void sl_wfx_scan_result_callback(sl_wfx_scan_result_ind_body_t * scan_result)
 {
@@ -334,11 +334,9 @@
 }
 
 /****************************************************************************
- * @fn   static void sl_wfx_scan_complete_callback(uint32_t status)
  * @brief
  * Callback for scan complete
- * @param[in] status:
- * @return None
+ * @param[in] status:Status of WLAN scan api
  *****************************************************************************/
 /* ARGSUSED */
 static void sl_wfx_scan_complete_callback(uint32_t status)
@@ -350,16 +348,15 @@
 #endif /* SL_WFX_CONFIG_SCAN */
 
 /****************************************************************************
- * @fn  static void sl_wfx_connect_callback(uint8_t *mac, uint32_t status)
  * @brief
  * Callback when station connects
- * @param[in]  mac:
- * @param[in]  status:
- * @return None
+ * @param[in]  mac: MAC address of device
+ * @param[in]  status: Status of connect call
  *****************************************************************************/
-static void sl_wfx_connect_callback(uint8_t * mac, uint32_t status)
+static void sl_wfx_connect_callback(sl_wfx_connect_ind_body_t connect_indication_body)
 {
-    (void) (mac);
+    uint8_t * mac   = connect_indication_body.mac;
+    uint32_t status = connect_indication_body.status;
     switch (status)
     {
     case WFM_STATUS_SUCCESS: {
@@ -407,12 +404,10 @@
 }
 
 /****************************************************************************
- * @fn   static void sl_wfx_disconnect_callback(uint8_t *mac, uint16_t reason)
  * @brief
  * Callback for station disconnect
- * @param[in]  mac:
- * @param[in]  reason:
- * @return None
+ * @param[in]  mac: MAC address of device
+ * @param[in]  reason: Reason code of disconnection
  *****************************************************************************/
 static void sl_wfx_disconnect_callback(uint8_t * mac, uint16_t reason)
 {
@@ -425,11 +420,9 @@
 
 #ifdef SL_WFX_CONFIG_SOFTAP
 /****************************************************************************
- * @fn  static void sl_wfx_start_ap_callback(uint32_t status)
  * @brief
  * Callback for AP started
- * @param[in]  status:
- * @return None
+ * @param[in]  status: Status of wfx start ap api
  *****************************************************************************/
 static void sl_wfx_start_ap_callback(uint32_t status)
 {
@@ -448,11 +441,8 @@
 }
 
 /****************************************************************************
- * @fn   static void sl_wfx_stop_ap_callback(void)
  * @brief
  * Callback for AP stopped
- * @param[in]  None
- * @return None
  *****************************************************************************/
 static void sl_wfx_stop_ap_callback(void)
 {
@@ -465,11 +455,9 @@
 }
 
 /****************************************************************************
- * @fn  static void sl_wfx_client_connected_callback(uint8_t *mac)
  * @brief
  * Callback for client connect to AP
- * @param[in]  mac:
- * @return None
+ * @param[in]  mac: MAC adress of device
  *****************************************************************************/
 static void sl_wfx_client_connected_callback(uint8_t * mac)
 {
@@ -479,747 +467,804 @@
 }
 
 /****************************************************************************
- * @fn  static void sl_wfx_ap_client_rejected_callback(uint32_t status, uint8_t *mac)
  * @brief
  * Callback for client rejected from AP
- * @param[in] status:
- * @param[in] mac:
- * @return None
+ * @param[in] status: Status of ap rejected
+ * @param[in] mac: MAC adress of device
  *****************************************************************************/
 static void sl_wfx_ap_client_rejected_callback(uint32_t status, uint8_t * mac)
 {
-    {
-        // TODO
-        EFR32_LOG("Client rejected, reason: %d, MAC: %02X:%02X:%02X:%02X:%02X:%02X\r\n", (int) status, mac[0], mac[1], mac[2],
-                  mac[3], mac[4], mac[5]);
-    }
+    EFR32_LOG("Client rejected, reason: %d, MAC: %02X:%02X:%02X:%02X:%02X:%02X\r\n", (int) status, mac[0], mac[1], mac[2], mac[3],
+              mac[4], mac[5]);
+}
 
-    /****************************************************************************
-     * @fn  static void sl_wfx_ap_client_disconnected_callback(uint32_t status, uint8_t *mac)
-     * @brief
-     * Callback for AP client disconnect
-     * @param[in] status:
-     * @param[in]  mac:
-     * @return  None
-     *****************************************************************************/
-    static void sl_wfx_ap_client_disconnected_callback(uint32_t status, uint8_t * mac)
-    {
-        // TODO
-        EFR32_LOG("Client disconnected, reason: %d, MAC: %02X:%02X:%02X:%02X:%02X:%02X\r\n", (int) status, mac[0], mac[1], mac[2],
-                  mac[3], mac[4], mac[5]);
-    }
+/****************************************************************************
+ * @brief
+ * Callback for AP client disconnect
+ * @param[in] status: Status of ap dissconnect
+ * @param[in]  mac:
+ *****************************************************************************/
+static void sl_wfx_ap_client_disconnected_callback(uint32_t status, uint8_t * mac)
+{
+    // TODO
+    EFR32_LOG("Client disconnected, reason: %d, MAC: %02X:%02X:%02X:%02X:%02X:%02X\r\n", (int) status, mac[0], mac[1], mac[2],
+              mac[3], mac[4], mac[5]);
+}
 #endif /* SL_WFX_CONFIG_SOFTAP */
 
-    /****************************************************************************
-     * @fn   static void sl_wfx_generic_status_callback(sl_wfx_generic_ind_t *frame)
-     * @brief
-     * Callback for generic status received
-     * @param[in] farme:
-     * @return None
-     *****************************************************************************/
-    static void sl_wfx_generic_status_callback(sl_wfx_generic_ind_t * frame)
-    {
-        (void) (frame);
-        EFR32_LOG("WFX Generic status received\r\n");
-    }
+/****************************************************************************
+ * @brief
+ * Callback for generic status received
+ * @param[in] farme:
+ *****************************************************************************/
+static void sl_wfx_generic_status_callback(sl_wfx_generic_ind_t * frame)
+{
+    (void) (frame);
+    EFR32_LOG("WFX Generic status received\r\n");
+}
 
-    /***************************************************************************
-     * @fn  static void wfx_events_task(void *p_arg)
-     * @brief
-     * WFX events processing task.
-     * @param[in] p_arg:
-     * @return None
-     ******************************************************************************/
-    static void wfx_events_task(void * p_arg)
-    {
-        TickType_t last_dhcp_poll, now;
-        EventBits_t flags;
-        (void) p_arg;
+/***************************************************************************
+ * @brief
+ * WFX events processing task.
+ * @param[in] p_arg:
+ *  ******************************************************************************/
+static void wfx_events_task(void * p_arg)
+{
+    TickType_t last_dhcp_poll, now;
+    EventBits_t flags;
+    (void) p_arg;
 
-        sta_netif      = wfx_get_netif(SL_WFX_STA_INTERFACE);
-        last_dhcp_poll = xTaskGetTickCount();
-        while (true)
-        {
-            flags = xEventGroupWaitBits(sl_wfx_event_group,
-                                        SL_WFX_CONNECT | SL_WFX_DISCONNECT
+    sta_netif      = wfx_get_netif(SL_WFX_STA_INTERFACE);
+    last_dhcp_poll = xTaskGetTickCount();
+    while (true)
+    {
+        flags = xEventGroupWaitBits(sl_wfx_event_group,
+                                    SL_WFX_CONNECT | SL_WFX_DISCONNECT
 #ifdef SL_WFX_CONFIG_SOFTAP
-                                            | SL_WFX_START_AP | SL_WFX_STOP_AP
+                                        | SL_WFX_START_AP | SL_WFX_STOP_AP
 #endif /* SL_WFX_CONFIG_SOFTAP */
 #ifdef SL_WFX_CONFIG_SCAN
-                                            | SL_WFX_SCAN_START | SL_WFX_SCAN_COMPLETE
+                                        | SL_WFX_SCAN_START | SL_WFX_SCAN_COMPLETE
 #endif /* SL_WFX_CONFIG_SCAN */
-                                            | BITS_TO_WAIT,
-                                        pdTRUE, pdFALSE, pdMS_TO_TICKS(250)); /* 250 msec delay converted to ticks */
-            if (flags & SL_WFX_RETRY_CONNECT)
+                                        | BITS_TO_WAIT,
+                                    pdTRUE, pdFALSE, pdMS_TO_TICKS(250)); /* 250 msec delay converted to ticks */
+        if (flags & SL_WFX_RETRY_CONNECT)
+        {
+            if (!retryInProgress)
             {
-                if (!retryInProgress)
-                {
-                    EFR32_LOG("WFX sending the connect command");
-                    wfx_connect_to_ap();
-                    retryInProgress = true;
-                }
+                EFR32_LOG("WFX sending the connect command");
+                wfx_connect_to_ap();
+                retryInProgress = true;
             }
+        }
 
-            if (wifi_extra & WE_ST_STA_CONN)
-            {
-                if ((now = xTaskGetTickCount()) > (last_dhcp_poll + pdMS_TO_TICKS(250)))
-                {
-#if (CHIP_DEVICE_CONFIG_ENABLE_IPV4)
-                    uint8_t dhcp_state = dhcpclient_poll(sta_netif);
-
-                    if ((dhcp_state == DHCP_ADDRESS_ASSIGNED) && !hasNotifiedIPV4)
-                    {
-                        wfx_dhcp_got_ipv4((uint32_t) sta_netif->ip_addr.u_addr.ip4.addr);
-                        hasNotifiedIPV4 = true;
-                        if (!hasNotifiedWifiConnectivity)
-                        {
-                            EFR32_LOG("WIFI: Has Notified Wifi Connectivity");
-                            wfx_connected_notify(CONNECTION_STATUS_SUCCESS, &ap_mac);
-                            hasNotifiedWifiConnectivity = true;
-                        }
-                    }
-                    else if (dhcp_state == DHCP_OFF)
-                    {
-                        wfx_ip_changed_notify(IP_STATUS_FAIL);
-                        hasNotifiedIPV4 = false;
-                    }
-#endif // CHIP_DEVICE_CONFIG_ENABLE_IPV4
-                    if ((ip6_addr_ispreferred(netif_ip6_addr_state(sta_netif, 0))) && !hasNotifiedIPV6)
-                    {
-                        wfx_ipv6_notify(GET_IPV6_SUCCESS);
-                        hasNotifiedIPV6 = true;
-                        if (!hasNotifiedWifiConnectivity)
-                        {
-                            wfx_connected_notify(CONNECTION_STATUS_SUCCESS, &ap_mac);
-                            hasNotifiedWifiConnectivity = true;
-                        }
-                    }
-                    last_dhcp_poll = now;
-                }
-            }
-
-            if (flags & SL_WFX_CONNECT)
+        if (wifi_extra & WE_ST_STA_CONN)
+        {
+            if ((now = xTaskGetTickCount()) > (last_dhcp_poll + pdMS_TO_TICKS(250)))
             {
 #if (CHIP_DEVICE_CONFIG_ENABLE_IPV4)
-                wfx_ip_changed_notify(IP_STATUS_FAIL);
-                hasNotifiedIPV4 = false;
+                uint8_t dhcp_state = dhcpclient_poll(&sta_netif);
+
+                if ((dhcp_state == DHCP_ADDRESS_ASSIGNED) && !hasNotifiedIPV4)
+                {
+                    wfx_dhcp_got_ipv4((uint32_t) sta_netif->ip_addr.u_addr.ip4.addr);
+                    hasNotifiedIPV4 = true;
+                    if (!hasNotifiedWifiConnectivity)
+                    {
+                        EFR32_LOG("WIFI: Has Notified Wifi Connectivity");
+                        wfx_connected_notify(CONNECTION_STATUS_SUCCESS, &ap_mac);
+                        hasNotifiedWifiConnectivity = true;
+                    }
+                }
+                else if (dhcp_state == DHCP_OFF)
+                {
+                    wfx_ip_changed_notify(IP_STATUS_FAIL);
+                    hasNotifiedIPV4 = false;
+                }
 #endif // CHIP_DEVICE_CONFIG_ENABLE_IPV4
-                wfx_ipv6_notify(GET_IPV6_FAIL);
-                hasNotifiedIPV6             = false;
-                hasNotifiedWifiConnectivity = false;
-                EFR32_LOG("WIFI: Connected to AP");
-                wifi_extra |= WE_ST_STA_CONN;
-                wfx_lwip_set_sta_link_up();
+                if ((ip6_addr_ispreferred(netif_ip6_addr_state(sta_netif, 0))) && !hasNotifiedIPV6)
+                {
+                    wfx_ipv6_notify(1);
+                    hasNotifiedIPV6 = true;
+                    if (!hasNotifiedWifiConnectivity)
+                    {
+                        wfx_connected_notify(CONNECTION_STATUS_SUCCESS, &ap_mac);
+                        hasNotifiedWifiConnectivity = true;
+                    }
+                }
+                last_dhcp_poll = now;
+            }
+        }
+
+        if (flags & SL_WFX_CONNECT)
+        {
+#if (CHIP_DEVICE_CONFIG_ENABLE_IPV4)
+            wfx_ip_changed_notify(IP_STATUS_FAIL);
+            hasNotifiedIPV4 = false;
+#endif // CHIP_DEVICE_CONFIG_ENABLE_IPV4
+            wfx_ipv6_notify(GET_IPV6_FAIL);
+            hasNotifiedIPV6             = false;
+            hasNotifiedWifiConnectivity = false;
+            EFR32_LOG("WIFI: Connected to AP");
+            wifi_extra |= WE_ST_STA_CONN;
+            wfx_lwip_set_sta_link_up();
 #ifdef SLEEP_ENABLED
-                if (!(wfx_get_wifi_state() & SL_WFX_AP_INTERFACE_UP))
-                {
-                    // Enable the power save
-                    sl_wfx_set_power_mode(WFM_PM_MODE_PS, WFM_PM_POLL_UAPSD, BEACON_1);
-                    sl_wfx_enable_device_power_save();
-                }
-#endif // SLEEP_ENABLED
-            }
-
-            if (flags & SL_WFX_DISCONNECT)
+            if (!(wfx_get_wifi_state() & SL_WFX_AP_INTERFACE_UP))
             {
+                // Enable the power save
+                sl_wfx_set_power_mode(WFM_PM_MODE_PS, WFM_PM_POLL_UAPSD, BEACON_1);
+                sl_wfx_enable_device_power_save();
+            }
+#endif // SLEEP_ENABLED
+        }
+
+        if (flags & SL_WFX_DISCONNECT)
+        {
 
 #if (CHIP_DEVICE_CONFIG_ENABLE_IPV4)
-                wfx_ip_changed_notify(IP_STATUS_FAIL);
-                hasNotifiedIPV4 = false;
+            wfx_ip_changed_notify(IP_STATUS_FAIL);
+            hasNotifiedIPV4 = false;
 #endif // CHIP_DEVICE_CONFIG_ENABLE_IPV4
-                wfx_ipv6_notify(GET_IPV6_FAIL);
-                hasNotifiedIPV6             = false;
-                hasNotifiedWifiConnectivity = false;
-                wifi_extra &= ~WE_ST_STA_CONN;
-                wfx_lwip_set_sta_link_down();
-            }
+            wfx_ipv6_notify(GET_IPV6_FAIL);
+            hasNotifiedIPV6             = false;
+            hasNotifiedWifiConnectivity = false;
+            wifi_extra &= ~WE_ST_STA_CONN;
+            wfx_lwip_set_sta_link_down();
+        }
 
 #ifdef SL_WFX_CONFIG_SCAN
-            if (flags & SL_WFX_SCAN_START)
+        if (flags & SL_WFX_SCAN_START)
+        {
+            /*
+             * Start the Scan
+             */
+            sl_wfx_ssid_def_t ssid, *sp;
+            uint16_t num_ssid, slen;
+            if (scan_ssid)
             {
-                /*
-                 * Start the Scan
-                 */
-                sl_wfx_ssid_def_t ssid, *sp;
-                uint16_t num_ssid, slen;
-                if (scan_ssid)
-                {
-                    memset(&ssid, 0, sizeof(ssid));
-                    slen = strlen(scan_ssid);
-                    memcpy(&ssid.ssid[0], scan_ssid, slen);
-                    ssid.ssid_length = slen;
-                    num_ssid         = 1;
-                    sp               = &ssid;
-                }
-                else
-                {
-                    num_ssid = 0;
-                    sp       = (sl_wfx_ssid_def_t *) 0;
-                }
-
-                EFR32_LOG("WIFI Scan Paramter set to Active channel time %d, Passive "
-                          "Channel Time: %d, Number of prob: %d",
-                          ACTIVE_CHANNEL_TIME, PASSIVE_CHANNEL_TIME, NUM_PROBE_REQUEST);
-                (void) sl_wfx_set_scan_parameters(ACTIVE_CHANNEL_TIME, PASSIVE_CHANNEL_TIME, NUM_PROBE_REQUEST);
-                (void) sl_wfx_send_scan_command(WFM_SCAN_MODE_ACTIVE, CHANNEL_LIST, /* Channel list */
-                                                CHANNEL_COUNT,                      /* Scan all chans */
-                                                sp, num_ssid, IE_DATA,              /* IE we're looking for */
-                                                IE_DATA_LENGTH, BSSID_SCAN);
+                memset(&ssid, 0, sizeof(ssid));
+                slen = strlen(scan_ssid);
+                memcpy(&ssid.ssid[0], scan_ssid, slen);
+                ssid.ssid_length = slen;
+                num_ssid         = 1;
+                sp               = &ssid;
             }
-            if (flags & SL_WFX_SCAN_COMPLETE)
+            else
             {
-                struct scan_result_holder *hp, *next;
-
-                EFR32_LOG("WIFI: Return %d scan results", scan_count);
-                for (hp = scan_save; hp; hp = next)
-                {
-                    next = hp->next;
-                    (*scan_cb)(&hp->scan);
-                    vPortFree(hp);
-                }
-                (*scan_cb)((wfx_wifi_scan_result *) 0);
-                scan_save  = (struct scan_result_holder *) 0;
-                scan_count = 0;
-                if (scan_ssid)
-                {
-                    vPortFree(scan_ssid);
-                    scan_ssid = (char *) 0;
-                }
-                /* Terminate scan */
-                scan_cb = 0;
+                num_ssid = 0;
+                sp       = (sl_wfx_ssid_def_t *) 0;
             }
+
+            EFR32_LOG("WIFI Scan Paramter set to Active channel time %d, Passive "
+                      "Channel Time: %d, Number of prob: %d",
+                      ACTIVE_CHANNEL_TIME, PASSIVE_CHANNEL_TIME, NUM_PROBE_REQUEST);
+            (void) sl_wfx_set_scan_parameters(ACTIVE_CHANNEL_TIME, PASSIVE_CHANNEL_TIME, NUM_PROBE_REQUEST);
+            (void) sl_wfx_send_scan_command(WFM_SCAN_MODE_ACTIVE, CHANNEL_LIST, /* Channel list */
+                                            CHANNEL_COUNT,                      /* Scan all chans */
+                                            sp, num_ssid, IE_DATA,              /* IE we're looking for */
+                                            IE_DATA_LENGTH, BSSID_SCAN);
+        }
+        if (flags & SL_WFX_SCAN_COMPLETE)
+        {
+            struct scan_result_holder *hp, *next;
+
+            EFR32_LOG("WIFI: Return %d scan results", scan_count);
+            for (hp = scan_save; hp; hp = next)
+            {
+                next = hp->next;
+                (*scan_cb)(&hp->scan);
+                vPortFree(hp);
+            }
+            (*scan_cb)((wfx_wifi_scan_result *) 0);
+            scan_save  = (struct scan_result_holder *) 0;
+            scan_count = 0;
+            if (scan_ssid)
+            {
+                vPortFree(scan_ssid);
+                scan_ssid = (char *) 0;
+            }
+            /* Terminate scan */
+            scan_cb = 0;
+        }
 #endif /* SL_WFX_CONFIG_SCAN */
-        }
     }
+}
 
-    /****************************************************************************
-     * @fn   static sl_status_t wfx_init(void)
-     * @brief
-     * Initialize the WF200 used by the two interfaces
-     * @param[in]  None
-     * @return None
-     *****************************************************************************/
-    static sl_status_t wfx_init(void)
+/****************************************************************************
+ * @brief
+ * Initialize the WF200 used by the two interfaces
+ *****************************************************************************/
+static sl_status_t wfx_init(void)
+{
+    /* Initialize the WF200 used by the two interfaces */
+    wfx_events_task_start();
+    sl_status_t status = sl_wfx_init(&wifiContext);
+    EFR32_LOG("FMAC Driver version    %s", FMAC_DRIVER_VERSION_STRING);
+    switch (status)
     {
-        /* Initialize the WF200 used by the two interfaces */
-        wfx_events_task_start();
-        sl_status_t status = sl_wfx_init(&wifiContext);
-        EFR32_LOG("FMAC Driver version    %s", FMAC_DRIVER_VERSION_STRING);
-        switch (status)
+    case SL_STATUS_OK:
+        EFR32_LOG("WF200 FW ver:%d.%d.%d [MAC %02x:%02x:%02x-%02x:%02x:%02x]", wifiContext.firmware_major,
+                  wifiContext.firmware_minor, wifiContext.firmware_build, wifiContext.mac_addr_0.octet[0],
+                  wifiContext.mac_addr_0.octet[1], wifiContext.mac_addr_0.octet[2], wifiContext.mac_addr_0.octet[3],
+                  wifiContext.mac_addr_0.octet[4], wifiContext.mac_addr_0.octet[5]);
+        EFR32_LOG("WF200 Init OK");
+
+        if (wifiContext.state == SL_WFX_STA_INTERFACE_CONNECTED)
         {
-        case SL_STATUS_OK:
-            EFR32_LOG("WF200 FW ver:%d.%d.%d [MAC %02x:%02x:%02x-%02x:%02x:%02x]", wifiContext.firmware_major,
-                      wifiContext.firmware_minor, wifiContext.firmware_build, wifiContext.mac_addr_0.octet[0],
-                      wifiContext.mac_addr_0.octet[1], wifiContext.mac_addr_0.octet[2], wifiContext.mac_addr_0.octet[3],
-                      wifiContext.mac_addr_0.octet[4], wifiContext.mac_addr_0.octet[5]);
-            EFR32_LOG("WF200 Init OK");
-
-            if (wifiContext.state == SL_WFX_STA_INTERFACE_CONNECTED)
-            {
-                sl_wfx_send_disconnect_command();
-            }
-
-            break;
-        case SL_STATUS_WIFI_INVALID_KEY:
-            EFR32_LOG("*ERR*WF200: F/W keyset invalid");
-            break;
-        case SL_STATUS_WIFI_FIRMWARE_DOWNLOAD_TIMEOUT:
-            EFR32_LOG("*ERR*WF200: F/W download timo");
-            break;
-        case SL_STATUS_TIMEOUT:
-            EFR32_LOG("*ERR*WF200: Poll for value timo");
-            break;
-        case SL_STATUS_FAIL:
-            EFR32_LOG("*ERR*WF200: Error");
-            break;
-        default:
-            EFR32_LOG("*ERR*WF200: Unknown");
+            sl_wfx_send_disconnect_command();
         }
 
-        return status;
+        break;
+    case SL_STATUS_WIFI_INVALID_KEY:
+        EFR32_LOG("*ERR*WF200: F/W keyset invalid");
+        break;
+    case SL_STATUS_WIFI_FIRMWARE_DOWNLOAD_TIMEOUT:
+        EFR32_LOG("*ERR*WF200: F/W download timo");
+        break;
+    case SL_STATUS_TIMEOUT:
+        EFR32_LOG("*ERR*WF200: Poll for value timo");
+        break;
+    case SL_STATUS_FAIL:
+        EFR32_LOG("*ERR*WF200: Error");
+        break;
+    default:
+        EFR32_LOG("*ERR*WF200: Unknown");
     }
 
-    /*****************************************************************************
-     * @fn  static void wfx_wifi_hw_start(void)
-     * @brief
-     *   tcp ip, wfx and lwip stack and start dhcp client.
-     *
-     * @param[in]
-     *    not used
-     *
-     * @return
-     *    sl_status_t Shows init succes or error.
-     ******************************************************************************/
-    static void wfx_wifi_hw_start(void)
+    return status;
+}
+
+/*****************************************************************************
+ * @brief
+ *   tcp ip, wfx and lwip stack and start dhcp client.
+ * @return
+ *    sl_status_t Shows init succes or error.
+ ******************************************************************************/
+static void wfx_wifi_hw_start(void)
+{
+    sl_status_t status;
+
+    if (wifi_extra & WE_ST_HW_STARTED)
+        return;
+    EFR32_LOG("STARTING WF200\n");
+    wifi_extra |= WE_ST_HW_STARTED;
+
+    sl_wfx_host_gpio_init();
+    if ((status = wfx_init()) == SL_STATUS_OK)
     {
-        sl_status_t status;
+        /* Initialize the LwIP stack */
+        EFR32_LOG("WF200:Start LWIP");
+        wfx_lwip_start();
+        wifiContext.state = SL_WFX_STARTED; /* Really this is a bit mask */
+        EFR32_LOG("WF200:ready..");
+    }
+    else
+    {
+        EFR32_LOG("*ERR*WF200:init failed");
+    }
+}
 
-        if (wifi_extra & WE_ST_HW_STARTED)
-            return;
-        EFR32_LOG("STARTING WF200\n");
-        wifi_extra |= WE_ST_HW_STARTED;
+/***********************************************************************
+ * @brief
+ * Get AP info
+ * @param[in]  ap: access point information
+ * @return returns -1
+ **************************************************************************/
+int32_t wfx_get_ap_info(wfx_wifi_scan_result_t * ap)
+{
+    int32_t signal_strength;
+    EFR32_LOG("WIFI:SSID:: %s", &ap_info.ssid[0]);
+    memcpy(ap->ssid, ap_info.ssid, sizeof(ap_info.ssid));
+    EFR32_LOG("WIFI:Mac addr:: %02x:%02x:%02x:%02x:%02x:%02x", ap_info.bssid[0], ap_info.bssid[1], ap_info.bssid[2],
+              ap_info.bssid[3], ap_info.bssid[4], ap_info.bssid[5]);
+    memcpy(ap->bssid, ap_info.bssid, sizeof(ap_info.bssid));
+    ap->security = ap_info.security;
+    EFR32_LOG("WIFI:security:: %d", ap->security);
+    ap->chan = ap_info.chan;
+    EFR32_LOG("WIFI:Channel:: to %d", ap->chan);
 
-        sl_wfx_host_gpio_init();
-        if ((status = wfx_init()) == SL_STATUS_OK)
+    sl_status_t status = sl_wfx_get_signal_strength((uint32_t *) &signal_strength);
+
+    if (status == SL_STATUS_OK)
+    {
+        EFR32_LOG("status SL_STATUS_OK & signal_strength:: %d", signal_strength);
+        ap->rssi = (signal_strength - 220) / 2;
+    }
+    return status;
+}
+
+/************************************************************************
+ * @brief
+ * Get AP extra info
+ * @param[in]  extra_info: access point extra information
+ * @return returns -1
+ **************************************************************************/
+int32_t wfx_get_ap_ext(wfx_wifi_scan_ext_t * extra_info)
+{
+    int32_t status;
+    status = get_all_counters();
+    if (status != SL_STATUS_OK)
+    {
+        EFR32_LOG("Failed to get the couters");
+    }
+    else
+    {
+        extra_info->beacon_lost_count = counters->body.count_miss_beacon;
+        extra_info->beacon_rx_count   = counters->body.count_rx_beacon;
+        extra_info->mcast_rx_count    = counters->body.count_rx_multicast_frames;
+        extra_info->mcast_tx_count    = counters->body.count_tx_multicast_frames;
+        extra_info->ucast_rx_count    = counters->body.count_rx_packets;
+        extra_info->ucast_tx_count    = counters->body.count_tx_packets;
+        extra_info->overrun_count     = gOverrunCount;
+    }
+    return status;
+}
+
+sl_status_t get_all_counters(void)
+{
+    sl_status_t result;
+    uint8_t command_id         = 0x05;
+    uint16_t mib_id            = 0x2035;
+    sl_wfx_mib_req_t * request = NULL;
+    uint32_t request_length    = SL_WFX_ROUND_UP_EVEN(sizeof(sl_wfx_header_mib_t) + sizeof(sl_wfx_mib_req_body_t));
+
+    result =
+        sl_wfx_allocate_command_buffer((sl_wfx_generic_message_t **) &request, command_id, SL_WFX_CONTROL_BUFFER, request_length);
+
+    if (request == NULL)
+    {
+    }
+
+    request->body.mib_id      = mib_id;
+    request->header.interface = 0x2;
+    request->header.encrypted = 0x0;
+
+    result = sl_wfx_send_request(command_id, (sl_wfx_generic_message_t *) request, request_length);
+    SL_WFX_ERROR_CHECK(result);
+
+    result = sl_wfx_host_wait_for_confirmation(command_id, SL_WFX_DEFAULT_REQUEST_TIMEOUT_MS, (void **) &counters);
+    SL_WFX_ERROR_CHECK(result);
+
+    EFR32_LOG("%-24s %12s \r\n", "", "Debug Counters Content");
+    EFR32_LOG("%-24s %lu\r\n", "rcpi", (unsigned long) counters->body.rcpi);
+    PUT_COUNTER(plcp_errors);
+    PUT_COUNTER(fcs_errors);
+    PUT_COUNTER(tx_packets);
+    PUT_COUNTER(rx_packets);
+    PUT_COUNTER(rx_packet_errors);
+    PUT_COUNTER(rx_decryption_failures);
+    PUT_COUNTER(rx_mic_failures);
+    PUT_COUNTER(rx_no_key_failures);
+    PUT_COUNTER(tx_multicast_frames);
+    PUT_COUNTER(tx_frames_success);
+    PUT_COUNTER(tx_frame_failures);
+    PUT_COUNTER(tx_frames_retried);
+    PUT_COUNTER(tx_frames_multi_retried);
+    PUT_COUNTER(rx_frame_duplicates);
+    PUT_COUNTER(rts_success);
+    PUT_COUNTER(rts_failures);
+    PUT_COUNTER(ack_failures);
+    PUT_COUNTER(rx_multicast_frames);
+    PUT_COUNTER(rx_frames_success);
+    PUT_COUNTER(rx_cmacicv_errors);
+    PUT_COUNTER(rx_cmac_replays);
+    PUT_COUNTER(rx_mgmt_ccmp_replays);
+    PUT_COUNTER(rx_bipmic_errors);
+    PUT_COUNTER(rx_beacon);
+    PUT_COUNTER(miss_beacon);
+
+error_handler:
+
+    if (result == SL_STATUS_TIMEOUT)
+    {
+        if (sl_wfx_context->used_buffers > 0)
         {
-            /* Initialize the LwIP stack */
-            EFR32_LOG("WF200:Start LWIP");
-            wfx_lwip_start();
-            wifiContext.state = SL_WFX_STARTED; /* Really this is a bit mask */
-            EFR32_LOG("WF200:ready..");
-        }
-        else
-        {
-            EFR32_LOG("*ERR*WF200:init failed");
+            sl_wfx_context->used_buffers--;
         }
     }
-
-    /************************************************************************
-     * @fn   int32_t wfx_get_ap_info(wfx_wifi_scan_result_t *ap)
-     * @brief
-     * Get AP info
-     * @param[in]  ap: access point
-     * @return returns -1
-     **************************************************************************/
-    int32_t wfx_get_ap_info(wfx_wifi_scan_result_t * ap)
+    if (request != NULL)
     {
-        /* TODO */
-        return -1;
+        sl_wfx_free_command_buffer((sl_wfx_generic_message_t *) request, command_id, SL_WFX_CONTROL_BUFFER);
     }
 
-    /************************************************************************
-     * @fn   int32_t wfx_get_ap_ext(wfx_wifi_scan_ext_t *extra_info)
-     * @brief
-     * Get AP extra info
-     * @param[in]  extra_info: access point extra information
-     * @return returns -1
-     **************************************************************************/
-    int32_t wfx_get_ap_ext(wfx_wifi_scan_ext_t * extra_info)
-    {
-        /* TODO */
-        return -1;
-    }
+    return result;
+}
 
-    /************************************************************************
-     * @fn    int32_t wfx_reset_counts()
-     * @brief
-     *    reset the count
-     * @param[in]  None
-     * @return returns -1
-     **************************************************************************/
-    int32_t wfx_reset_counts()
-    {
-        /* TODO */
-        return -1;
-    }
+/************************************************************************
+ * @brief
+ *    reset the count
+ * @return returns -1
+ **************************************************************************/
+int32_t wfx_reset_counts()
+{
+    /* TODO */
+    return -1;
+}
 
-    /*************************************************************************
-     * @fn   sl_status_t wfx_wifi_start(void)
-     * @brief
-     * I think that this is getting called before FreeRTOS threads are ready
-     * @param[in] none
-     * @return  returns SL_STATUS_OK
-     **************************************************************************/
-    sl_status_t wfx_wifi_start(void)
+/*************************************************************************
+ * @brief
+ * I think that this is getting called before FreeRTOS threads are ready
+ * @return  returns SL_STATUS_OK
+ **************************************************************************/
+sl_status_t wfx_wifi_start(void)
+{
+    if (wifi_extra & WE_ST_STARTED)
     {
-        if (wifi_extra & WE_ST_STARTED)
-        {
-            EFR32_LOG("WIFI: Already started");
-            return SL_STATUS_OK;
-        }
-        wifi_extra |= WE_ST_STARTED;
-        wfx_soft_init();
-        wfx_wifi_hw_start();
-
+        EFR32_LOG("WIFI: Already started");
         return SL_STATUS_OK;
     }
+    wifi_extra |= WE_ST_STARTED;
+    wfx_soft_init();
+    wfx_wifi_hw_start();
 
-    /****************************************************************************
-     * @fn sl_wfx_state_t wfx_get_wifi_state(void)
-     * @brief
-     *      get the wifi state
-     * @param[in]  None
-     * @return returns wificonetext state
-     *****************************************************************************/
-    sl_wfx_state_t wfx_get_wifi_state(void) { return wifiContext.state; }
+    return SL_STATUS_OK;
+}
 
-    /****************************************************************************
-     * @fn  struct netif *wfx_GetNetif(sl_wfx_interface_t interface)
-     * @brief
-     *      getnetif using interface
-     * @param[in]  interface:
-     * @return returns selectedNetif
-     *****************************************************************************/
-    struct netif * wfx_GetNetif(sl_wfx_interface_t interface)
+/****************************************************************************
+ * @brief
+ *      get the wifi state
+ * @return returns wificonetext state
+ *****************************************************************************/
+sl_wfx_state_t wfx_get_wifi_state(void)
+{
+    return wifiContext.state;
+}
+
+/****************************************************************************
+ * @brief
+ *      getnetif using interface
+ * @param[in]  interface:
+ * @return returns selectedNetif
+ *****************************************************************************/
+struct netif * wfx_GetNetif(sl_wfx_interface_t interface)
+{
+    struct netif * SelectedNetif = NULL;
+    if (interface == SL_WFX_STA_INTERFACE)
     {
-        struct netif * SelectedNetif = NULL;
-        if (interface == SL_WFX_STA_INTERFACE)
-        {
-            SelectedNetif = sta_netif;
-        }
+        SelectedNetif = sta_netif;
+    }
 #ifdef SL_WFX_CONFIG_SOFTAP
-        else if (interface == SL_WFX_SOFTAP_INTERFACE)
-        {
-            // no ap currently
-        }
+    else if (interface == SL_WFX_SOFTAP_INTERFACE)
+    {
+        // no ap currently
+    }
 #endif
-        return SelectedNetif;
-    }
+    return SelectedNetif;
+}
 
-    /****************************************************************************
-     * @fn  sl_wfx_mac_address_t wfx_get_wifi_mac_addr(sl_wfx_interface_t interface)
-     * @brief
-     * get the wifi mac address using interface
-     * @param[in] interface:
-     * @return  returns wificontext.mac_addr_o if successful,
-     *          wificontext.mac_addr_1 otherwise
-     *****************************************************************************/
-    sl_wfx_mac_address_t wfx_get_wifi_mac_addr(sl_wfx_interface_t interface)
+/****************************************************************************
+ * @brief
+ * get the wifi mac address using interface
+ * @param[in] interface:
+ * @return  returns wificontext.mac_addr_o if successful,
+ *          wificontext.mac_addr_1 otherwise
+ *****************************************************************************/
+sl_wfx_mac_address_t wfx_get_wifi_mac_addr(sl_wfx_interface_t interface)
+{
+    // return Mac address used by WFX SL_WFX_STA_INTERFACE or SL_WFX_SOFTAP_INTERFACE,
+    return (interface == SL_WFX_STA_INTERFACE) ? wifiContext.mac_addr_0 : wifiContext.mac_addr_1;
+}
+
+/****************************************************************************
+ * @brief
+ * set the wifi provision
+ * @param[in] wifiConfig: configuration of wifi
+ *****************************************************************************/
+void wfx_set_wifi_provision(wfx_wifi_provision_t * wifiConfig)
+{
+    memcpy(wifi_provision.ssid, wifiConfig->ssid, sizeof(wifiConfig->ssid));
+    memcpy(wifi_provision.passkey, wifiConfig->passkey, sizeof(wifiConfig->passkey));
+    EFR32_LOG("WIFI: Provision SSID=%s", &wifi_provision.ssid[0]);
+
+    /* Not very good - To be improved */
+    switch (wifiConfig->security)
     {
-        // return Mac address used by WFX SL_WFX_STA_INTERFACE or SL_WFX_SOFTAP_INTERFACE,
-        return (interface == SL_WFX_STA_INTERFACE) ? wifiContext.mac_addr_0 : wifiContext.mac_addr_1;
+    case WFX_SEC_WPA:
+        wifi_provision.security = static_cast<uint8_t>(sl_wfx_security_mode_e::WFM_SECURITY_MODE_WPA2_WPA1_PSK);
+        break;
+    case WFX_SEC_WPA3:
+        wifi_provision.security = WFM_SECURITY_MODE_WPA3_SAE;
+        break;
+    case WFX_SEC_WPA2:
+        wifi_provision.security = static_cast<uint8_t>(sl_wfx_security_mode_e::WFM_SECURITY_MODE_WPA2_WPA1_PSK);
+        break;
+    case WFX_SEC_WPA_WPA2_MIXED:
+        wifi_provision.security = static_cast<uint8_t>(sl_wfx_security_mode_e::WFM_SECURITY_MODE_WPA2_WPA1_PSK);
+        break;
+    default:
+        wifi_provision.security = WFM_SECURITY_MODE_WPA2_PSK;
+        break;
     }
+}
 
-    /****************************************************************************
-     * @fn  void wfx_set_wifi_provision(wfx_wifi_provision_t *wifiConfig)
-     * @brief
-     * set the wifi provision
-     * @param[in] wifiConfig: configuration of wifi
-     * @return None
-     *****************************************************************************/
-    void wfx_set_wifi_provision(wfx_wifi_provision_t * wifiConfig)
+/****************************************************************************
+ * @brief
+ * get the wifi provision
+ * @param[in] wifiConfig: configuration of wifi
+ * @return returns true if successful,
+ *         false otherwise
+ *****************************************************************************/
+bool wfx_get_wifi_provision(wfx_wifi_provision_t * wifiConfig)
+{
+    if (wifiConfig == NULL)
     {
-        memcpy(wifi_provision.ssid, wifiConfig->ssid, sizeof(wifiConfig->ssid));
-        memcpy(wifi_provision.passkey, wifiConfig->passkey, sizeof(wifiConfig->passkey));
-        EFR32_LOG("WIFI: Provision SSID=%s", &wifi_provision.ssid[0]);
-
-        /* Not very good - To be improved */
-        switch (wifiConfig->security)
-        {
-        case WFX_SEC_WPA:
-            wifi_provision.security = static_cast<uint8_t>(sl_wfx_security_mode_e::WFM_SECURITY_MODE_WPA2_WPA1_PSK);
-            break;
-        case WFX_SEC_WPA3:
-            wifi_provision.security = WFM_SECURITY_MODE_WPA3_SAE;
-            break;
-        case WFX_SEC_WPA2:
-            wifi_provision.security = static_cast<uint8_t>(sl_wfx_security_mode_e::WFM_SECURITY_MODE_WPA2_WPA1_PSK);
-            break;
-        case WFX_SEC_WPA_WPA2_MIXED:
-            wifi_provision.security = static_cast<uint8_t>(sl_wfx_security_mode_e::WFM_SECURITY_MODE_WPA2_WPA1_PSK);
-            break;
-        default:
-            wifi_provision.security = WFM_SECURITY_MODE_WPA2_PSK;
-            break;
-        }
+        return false;
     }
+    memcpy(wifiConfig, &wifi_provision, sizeof(wfx_wifi_provision_t));
 
-    /****************************************************************************
-     * @fn bool wfx_get_wifi_provision(wfx_wifi_provision_t *wifiConfig)
-     * @brief
-     * get the wifi provision
-     * @param[in] wifiConfig: configuration of wifi
-     * @return returns true if successful,
-     *         false otherwise
-     *****************************************************************************/
-    bool wfx_get_wifi_provision(wfx_wifi_provision_t * wifiConfig)
+    return true;
+}
+
+/****************************************************************************
+ * @brief
+ * clear the wifi provision
+ * @return returns true if successful,
+ *         false otherwise
+ *****************************************************************************/
+void wfx_clear_wifi_provision(void)
+{
+    memset(&wifi_provision, 0, sizeof(wifi_provision));
+}
+
+/****************************************************************************
+ * @brief
+ *      driver STA provisioned
+ * @return returns true if successful,
+ *         false otherwise
+ *****************************************************************************/
+bool wfx_is_sta_provisioned(void)
+{
+    return (wifi_provision.ssid[0]) ? true : false;
+}
+
+/****************************************************************************
+ * @fn  sl_status_t wfx_connect_to_ap(void)
+ * @brief
+ *  driver connect to ap
+ * @return returns SL_STATUS_NOT_AVAILABLE
+ *****************************************************************************/
+sl_status_t wfx_connect_to_ap(void)
+{
+    sl_status_t result;
+
+    if (wifi_provision.ssid[0] == 0)
     {
-        if (wifiConfig == NULL)
-        {
-            return false;
-        }
-        memcpy(wifiConfig, &wifi_provision, sizeof(wfx_wifi_provision_t));
-
-        return true;
+        return SL_STATUS_NOT_AVAILABLE;
     }
+    EFR32_LOG("WIFI:JOIN to %s", &wifi_provision.ssid[0]);
 
-    /****************************************************************************
-     * @fn  void wfx_clear_wifi_provision(void)
-     * @brief
-     * clear the wifi provision
-     * @param[in] None
-     * @return returns true if successful,
-     *         false otherwise
-     *****************************************************************************/
-    void wfx_clear_wifi_provision(void) { memset(&wifi_provision, 0, sizeof(wifi_provision)); }
+    EFR32_LOG("WIFI Scan Paramter set to Active channel time %d, Passive Channel "
+              "Time: %d, Number of prob: %d",
+              ACTIVE_CHANNEL_TIME, PASSIVE_CHANNEL_TIME, NUM_PROBE_REQUEST);
+    (void) sl_wfx_set_scan_parameters(ACTIVE_CHANNEL_TIME, PASSIVE_CHANNEL_TIME, NUM_PROBE_REQUEST);
+    result =
+        sl_wfx_send_join_command((uint8_t *) wifi_provision.ssid, strlen(wifi_provision.ssid), NULL, CHANNEL_0,
+                                 static_cast<sl_wfx_security_mode_t>(wifi_provision.security), PREVENT_ROAMING, DISABLE_PMF_MODE,
+                                 (uint8_t *) wifi_provision.passkey, strlen(wifi_provision.passkey), NULL, IE_DATA_LENGTH);
 
-    /****************************************************************************
-     * @fn  bool wfx_is_sta_provisioned(void)
-     * @brief
-     *      driver STA provisioned
-     * @param[in] None
-     * @return returns true if successful,
-     *         false otherwise
-     *****************************************************************************/
-    bool wfx_is_sta_provisioned(void) { return (wifi_provision.ssid[0]) ? true : false; }
+    return result;
+}
 
-    /****************************************************************************
-     * @fn  sl_status_t wfx_connect_to_ap(void)
-     * @brief
-     *  driver connect to ap
-     * @param[in] None
-     * @return returns SL_STATUS_NOT_AVAILABLE
-     *****************************************************************************/
-    sl_status_t wfx_connect_to_ap(void)
-    {
-        sl_status_t result;
-
-        if (wifi_provision.ssid[0] == 0)
-        {
-            return SL_STATUS_NOT_AVAILABLE;
-        }
-        EFR32_LOG("WIFI:JOIN to %s", &wifi_provision.ssid[0]);
-
-        EFR32_LOG("WIFI Scan Paramter set to Active channel time %d, Passive Channel "
-                  "Time: %d, Number of prob: %d",
-                  ACTIVE_CHANNEL_TIME, PASSIVE_CHANNEL_TIME, NUM_PROBE_REQUEST);
-        (void) sl_wfx_set_scan_parameters(ACTIVE_CHANNEL_TIME, PASSIVE_CHANNEL_TIME, NUM_PROBE_REQUEST);
-        result = sl_wfx_send_join_command((uint8_t *) wifi_provision.ssid, strlen(wifi_provision.ssid), NULL, CHANNEL_0,
-                                          static_cast<sl_wfx_security_mode_t>(wifi_provision.security), PREVENT_ROAMING,
-                                          DISABLE_PMF_MODE, (uint8_t *) wifi_provision.passkey, strlen(wifi_provision.passkey),
-                                          NULL, IE_DATA_LENGTH);
-
-        return result;
-    }
-
-    /****************************************************************************
-     * @fn  void wfx_get_wifi_mac_addr(sl_wfx_interface_t interface, sl_wfx_mac_address_t *addr)
-     * @brief
-     * get the wifi mac addresss
-     * @param[in] interface:
-     * @param[in] addr : address
-     * @return None
-     *****************************************************************************/
-    void wfx_get_wifi_mac_addr(sl_wfx_interface_t interface, sl_wfx_mac_address_t * addr)
-    {
-        sl_wfx_mac_address_t * mac;
+/****************************************************************************
+ * @brief
+ * get the wifi mac addresss
+ * @param[in] interface:
+ * @param[in] addr : address
+ *****************************************************************************/
+void wfx_get_wifi_mac_addr(sl_wfx_interface_t interface, sl_wfx_mac_address_t * addr)
+{
+    sl_wfx_mac_address_t * mac;
 
 #ifdef SL_WFX_CONFIG_SOFTAP
-        mac = (interface == SL_WFX_SOFTAP_INTERFACE) ? &wifiContext.mac_addr_1 : &wifiContext.mac_addr_0;
+    mac = (interface == SL_WFX_SOFTAP_INTERFACE) ? &wifiContext.mac_addr_1 : &wifiContext.mac_addr_0;
 #else
     mac = &wifiContext.mac_addr_0;
 #endif
-        *addr = *mac;
-        EFR32_LOG("WLAN:Get WiFi Mac addr %02x:%02x:%02x:%02x:%02x:%02x", mac->octet[0], mac->octet[1], mac->octet[2],
-                  mac->octet[3], mac->octet[4], mac->octet[5]);
-    }
-
-    /****************************************************************************
-     * @fn  bool wfx_have_ipv4_addr(sl_wfx_interface_t which_if)
-     * @brief
-     *     function called when driver have ipv4 address
-     * @param[in]  which_if:
-     * @return returns false if sucessful,
-     *         true otherwise
-     *****************************************************************************/
-    bool wfx_have_ipv4_addr(sl_wfx_interface_t which_if)
-    {
-        if (which_if == SL_WFX_STA_INTERFACE)
-        {
-            return (sta_ip == STA_IP_FAIL) ? false : true;
-        }
-        else
-        {
-            return false; /* TODO */
-        }
-    }
-
-    /****************************************************************************
-     * @fn  bool wfx_have_ipv6_addr(sl_wfx_interface_t which_if)
-     * @brief
-     *     function called when driver have ipv6 address
-     * @param[in]  which_if:
-     * @return returns false if sucessful,
-     *         true otherwise
-     *****************************************************************************/
-    bool wfx_have_ipv6_addr(sl_wfx_interface_t which_if)
-    {
-        EFR32_LOG("%s: started.", __func__);
-        bool status = false;
-        if (which_if == SL_WFX_STA_INTERFACE)
-        {
-            status = wfx_is_sta_connected();
-        }
-        else
-        {
-            status = false; /* TODO */
-        }
-        EFR32_LOG("%s: status: %d", __func__, status);
-        return status;
-    }
-
-    /****************************************************************************
-     * @fn   sl_status_t wfx_sta_discon(void)
-     * @brief
-     * Disconnect station mode from connected AP
-     * @param[in]  None
-     * @returns Returns SL_STATUS_OK if successful,
-     *             SL_STATUS_FAIL otherwise
-     *****************************************************************************/
-    sl_status_t wfx_sta_discon(void)
-    {
-        EFR32_LOG("STA-Disconnecting");
-        int32_t status = sl_wfx_send_disconnect_command();
-        wifi_extra &= ~WE_ST_STA_CONN;
-        xEventGroupSetBits(sl_wfx_event_group, SL_WFX_RETRY_CONNECT);
-        return status;
-    }
-
-    /****************************************************************************
-     * @fn  bool wfx_is_sta_mode_enabled(void)
-     * @brief
-     *     enable the STA mode
-     * @param[in]  None
-     * @return returns true
-     *****************************************************************************/
-    bool wfx_is_sta_mode_enabled(void) { return true; /* It always is */ }
-
-    /****************************************************************************
-     * @fn  bool wfx_is_sta_connected(void)
-     * @brief
-     *     fuction called when driver is STA connected
-     * @param[in]  None
-     * @return returns true if sucessful,
-     *         false otherwise
-     *****************************************************************************/
-    bool wfx_is_sta_connected(void)
-    {
-        bool val;
-
-        val = (wifi_extra & WE_ST_STA_CONN) ? true : false;
-
-        EFR32_LOG("WLAN: STA %s connected", (val ? "IS" : "NOT"));
-
-        return val;
-    }
-
-    /****************************************************************************
-     * @fn  void wfx_setup_ip6_link_local(sl_wfx_interface_t whichif)
-     * @brief
-     *      It is automatically done when lwip link up
-     * @param[in]  None
-     * @return returns true if sucessful,
-     *         false otherwise
-     *****************************************************************************/
-    void wfx_setup_ip6_link_local(sl_wfx_interface_t whichif)
-    {
-        EFR32_LOG("Setup-IP6: TODO"); /* It is automatically done when lwip link up */
-    }
-
-    /****************************************************************************
-     * @fn  wifi_mode_t wfx_get_wifi_mode()
-     * @brief
-     *      get the wifi mode
-     * @param[in]  None
-     * @return returns WIFI_MODE_NULL if sucessful,
-     *         WIFI_MODE_STA otherwise
-     *****************************************************************************/
-    wifi_mode_t wfx_get_wifi_mode()
-    {
-        if (wifiContext.state & SL_WFX_STARTED)
-            return WIFI_MODE_STA;
-        return WIFI_MODE_NULL;
-    }
-
-    /*****************************************************************************
-     * @fn  bool wfx_hw_ready(void)
-     * @brief
-     * This is called from the context of AppTask
-     * For WF200 - Start WIFI here
-     * @param[in]  None
-     * @return returns true if sucessful,
-     *         false otherwise
-     ******************************************************************************/
-    bool wfx_hw_ready(void) { return (wifiContext.state & SL_WFX_STARTED) ? true : false; }
-
-#if CHIP_DEVICE_CONFIG_ENABLE_IPV4
-    /*****************************************************************************
-     * @fn  void wfx_dhcp_got_ipv4(uint32_t ip)
-     * @brief
-     *    function called when dhcp got ipv4
-     * @param[in]  ip : internet protocol
-     *@return  None
-     ******************************************************************************/
-    void wfx_dhcp_got_ipv4(uint32_t ip)
-    {
-        /* Acquire the new IP address
-         */
-        sta_ip = ip;
-        wfx_ip_changed_notify(IP_STATUS_SUCCESS);
-    }
-#endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */
-
-    /*****************************************************************************
-     * @fn  wfx_enable_sta_mode(void)
-     * @brief
-     *    function called from connectivityManager
-     * @param[in]
-     * @return  None
-     ******************************************************************************/
-    void wfx_enable_sta_mode(void)
-    {
-        /* Nothing to do - default is that it is
-           place holder */
-    }
+    *addr = *mac;
+    EFR32_LOG("WLAN:Get WiFi Mac addr %02x:%02x:%02x:%02x:%02x:%02x", mac->octet[0], mac->octet[1], mac->octet[2], mac->octet[3],
+              mac->octet[4], mac->octet[5]);
+    memcpy(&ap_info.bssid[0], &mac->octet[0], 6);
+}
 
 /****************************************************************************
- * @fn bool wfx_start_scan(char *ssid, void (*callback)(wfx_wifi_scan_result_t *))
+ * @brief
+ *     function called when driver have ipv4 address
+ * @param[in]  which_if:
+ * @return returns false if sucessful,
+ *         true otherwise
+ *****************************************************************************/
+bool wfx_have_ipv4_addr(sl_wfx_interface_t which_if)
+{
+    if (which_if == SL_WFX_STA_INTERFACE)
+    {
+        return (sta_ip == STA_IP_FAIL) ? false : true;
+    }
+    else
+    {
+        return false; /* TODO */
+    }
+}
+
+/****************************************************************************
+ * @brief
+ *     function called when driver have ipv6 address
+ * @param[in]  which_if:
+ * @return returns false if sucessful,
+ *         true otherwise
+ *****************************************************************************/
+bool wfx_have_ipv6_addr(sl_wfx_interface_t which_if)
+{
+    EFR32_LOG("%s: started.", __func__);
+    bool status = false;
+    if (which_if == SL_WFX_STA_INTERFACE)
+    {
+        status = wfx_is_sta_connected();
+    }
+    else
+    {
+        status = false; /* TODO */
+    }
+    EFR32_LOG("%s: status: %d", __func__, status);
+    return status;
+}
+
+/****************************************************************************
+ * @brief
+ * Disconnect station mode from connected AP
+ * @returns Returns SL_STATUS_OK if successful,
+ *             SL_STATUS_FAIL otherwise
+ *****************************************************************************/
+sl_status_t wfx_sta_discon(void)
+{
+    EFR32_LOG("STA-Disconnecting");
+    int32_t status = sl_wfx_send_disconnect_command();
+    wifi_extra &= ~WE_ST_STA_CONN;
+    xEventGroupSetBits(sl_wfx_event_group, SL_WFX_RETRY_CONNECT);
+    return status;
+}
+
+/****************************************************************************
+ * @brief
+ *     enable the STA mode
+ * @return returns true
+ *****************************************************************************/
+bool wfx_is_sta_mode_enabled(void)
+{
+    return true; /* It always is */
+}
+
+/****************************************************************************
+ * @brief
+ *     fuction called when driver is STA connected
+ * @return returns true if sucessful,
+ *         false otherwise
+ *****************************************************************************/
+bool wfx_is_sta_connected(void)
+{
+    bool val;
+
+    val = (wifi_extra & WE_ST_STA_CONN) ? true : false;
+
+    EFR32_LOG("WLAN: STA %s connected", (val ? "IS" : "NOT"));
+
+    return val;
+}
+
+/****************************************************************************
+ * @brief
+ *      It is automatically done when lwip link up
+ * @return returns true if sucessful,
+ *         false otherwise
+ *****************************************************************************/
+void wfx_setup_ip6_link_local(sl_wfx_interface_t whichif)
+{
+    EFR32_LOG("Setup-IP6: TODO"); /* It is automatically done when lwip link up */
+}
+
+/****************************************************************************
+ * @brief
+ *      get the wifi mode
+ * @return returns WIFI_MODE_NULL if sucessful,
+ *         WIFI_MODE_STA otherwise
+ *****************************************************************************/
+wifi_mode_t wfx_get_wifi_mode()
+{
+    if (wifiContext.state & SL_WFX_STARTED)
+        return WIFI_MODE_STA;
+    return WIFI_MODE_NULL;
+}
+
+/*****************************************************************************
+ * @brief
+ * This is called from the context of AppTask
+ * For WF200 - Start WIFI here
+ * @return returns true if sucessful,
+ *         false otherwise
+ ******************************************************************************/
+bool wfx_hw_ready(void)
+{
+    return (wifiContext.state & SL_WFX_STARTED) ? true : false;
+}
+
+#if CHIP_DEVICE_CONFIG_ENABLE_IPV4
+/*****************************************************************************
+ * @brief
+ *    function called when dhcp got ipv4
+ * @param[in]  ip : internet protocol
+ ******************************************************************************/
+void wfx_dhcp_got_ipv4(uint32_t ip)
+{
+    /* Acquire the new IP address
+     */
+    sta_ip = ip;
+    wfx_ip_changed_notify(IP_STATUS_SUCCESS);
+}
+#endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */
+
+/*****************************************************************************
+ * @brief
+ *    function called from connectivityManager
+ ******************************************************************************/
+void wfx_enable_sta_mode(void)
+{
+    /* Nothing to do - default is that it is
+       place holder */
+}
+
+/****************************************************************************
  * @brief
  * driver scan start
- * @param[in]  callback:
+ * @param[in]  callback: Callback from the wifi scan  results
  * @return returns true if sucessful,
  *         false otherwise
  *****************************************************************************/
 #ifdef SL_WFX_CONFIG_SCAN
-    bool wfx_start_scan(char * ssid, void (*callback)(wfx_wifi_scan_result_t *))
+bool wfx_start_scan(char * ssid, void (*callback)(wfx_wifi_scan_result_t *))
+{
+    int sz;
+
+    if (scan_cb)
+        return false; /* Already in progress */
+    if (ssid)
     {
-        int sz;
-
-        if (scan_cb)
-            return false; /* Already in progress */
-        if (ssid)
+        sz = strlen(ssid);
+        if ((scan_ssid = (char *) pvPortMalloc(sz + 1)) == (char *) 0)
         {
-            sz = strlen(ssid);
-            if ((scan_ssid = (char *) pvPortMalloc(sz + 1)) == (char *) 0)
-            {
-                return false;
-            }
-            strcpy(scan_ssid, ssid);
+            return false;
         }
-        scan_cb = callback;
-        xEventGroupSetBits(sl_wfx_event_group, SL_WFX_SCAN_START);
-
-        return true;
+        strcpy(scan_ssid, ssid);
     }
+    scan_cb = callback;
+    xEventGroupSetBits(sl_wfx_event_group, SL_WFX_SCAN_START);
 
-    /****************************************************************************
-     * @fn  void wfx_cancel_scan(void)
-     * @brief
-     * driver scan cancelation
-     * @param[in]  None
-     * @return None
-     *****************************************************************************/
-    void wfx_cancel_scan(void)
+    return true;
+}
+
+/****************************************************************************
+ * @brief
+ * driver scan cancelation
+ *****************************************************************************/
+void wfx_cancel_scan(void)
+{
+    struct scan_result_holder *hp, *next;
+    /* Not possible */
+    if (!scan_cb)
     {
-        struct scan_result_holder *hp, *next;
-        /* Not possible */
-        if (!scan_cb)
-        {
-            return;
-        }
-        sl_wfx_send_stop_scan_command();
-        for (hp = scan_save; hp; hp = next)
-        {
-            next = hp->next;
-            vPortFree(hp);
-        }
-        scan_save  = (struct scan_result_holder *) 0;
-        scan_count = 0;
-        if (scan_ssid)
-        {
-            vPortFree(scan_ssid);
-            scan_ssid = (char *) 0;
-        }
-        scan_cb = 0;
+        return;
     }
+    sl_wfx_send_stop_scan_command();
+    for (hp = scan_save; hp; hp = next)
+    {
+        next = hp->next;
+        vPortFree(hp);
+    }
+    scan_save  = (struct scan_result_holder *) 0;
+    scan_count = 0;
+    if (scan_ssid)
+    {
+        vPortFree(scan_ssid);
+        scan_ssid = (char *) 0;
+    }
+    scan_cb = 0;
+}
 #endif /* SL_WFX_CONFIG_SCAN */
diff --git a/src/platform/EFR32/wifi/ethernetif.cpp b/src/platform/EFR32/wifi/ethernetif.cpp
index 4ac27d6..8c2e818 100644
--- a/src/platform/EFR32/wifi/ethernetif.cpp
+++ b/src/platform/EFR32/wifi/ethernetif.cpp
@@ -61,6 +61,8 @@
 
 #define LWIP_FRAME_ALIGNMENT 60
 
+uint32_t gOverrunCount = 0;
+
 /*****************************************************************************
  * Variables
  ******************************************************************************/
@@ -168,9 +170,16 @@
 
         if (netif->input(p, netif) != ERR_OK)
         {
+            gOverrunCount++;
+            EFR32_LOG("overrun count entering when fail to alloc value %d", gOverrunCount);
             pbuf_free(p);
         }
     }
+    else
+    {
+        gOverrunCount++;
+        EFR32_LOG("overrun count entering when fail to alloc value %d", gOverrunCount);
+    }
 }
 
 /*****************************************************************************
@@ -217,6 +226,8 @@
     if (sl_wfx_host_allocate_buffer((void **) &tx_buffer, SL_WFX_TX_FRAME_BUFFER, asize) != SL_STATUS_OK)
     {
         EFR32_LOG("*ERR*EN-Out: No mem frame len=%d", framelength);
+        gOverrunCount++;
+        EFR32_LOG("overrun count exiting when faied to alloc value %d", gOverrunCount);
         return ERR_MEM;
     }
     buffer = tx_buffer->body.packet_data;
diff --git a/src/platform/EFR32/wifi/wfx_host_events.h b/src/platform/EFR32/wifi/wfx_host_events.h
index be64a8a..40e4d8e 100644
--- a/src/platform/EFR32/wifi/wfx_host_events.h
+++ b/src/platform/EFR32/wifi/wfx_host_events.h
@@ -26,7 +26,77 @@
 
 #include "sl_wfx_cmd_api.h"
 #include "sl_wfx_constants.h"
-#else /* RS911x */
+
+typedef struct __attribute__((__packed__)) sl_wfx_get_counters_cnf_body_s
+{
+    uint32_t status;
+    uint16_t mib_id;
+    uint16_t length;
+    uint32_t rcpi;
+    uint32_t count_plcp_errors;
+    uint32_t count_fcs_errors;
+    uint32_t count_tx_packets;
+    uint32_t count_rx_packets;
+    uint32_t count_rx_packet_errors;
+    uint32_t count_rx_decryption_failures;
+    uint32_t count_rx_mic_failures;
+    uint32_t count_rx_no_key_failures;
+    uint32_t count_tx_multicast_frames;
+    uint32_t count_tx_frames_success;
+    uint32_t count_tx_frame_failures;
+    uint32_t count_tx_frames_retried;
+    uint32_t count_tx_frames_multi_retried;
+    uint32_t count_rx_frame_duplicates;
+    uint32_t count_rts_success;
+    uint32_t count_rts_failures;
+    uint32_t count_ack_failures;
+    uint32_t count_rx_multicast_frames;
+    uint32_t count_rx_frames_success;
+    uint32_t count_rx_cmacicv_errors;
+    uint32_t count_rx_cmac_replays;
+    uint32_t count_rx_mgmt_ccmp_replays;
+    uint32_t count_rx_bipmic_errors;
+    uint32_t count_rx_beacon;
+    uint32_t count_miss_beacon;
+    uint32_t reserved[15];
+} sl_wfx_get_counters_cnf_body_t;
+
+typedef struct __attribute__((__packed__)) sl_wfx_get_counters_cnf_s
+{
+    /** Common message header. */
+    sl_wfx_header_t header;
+    /** Confirmation message body. */
+    sl_wfx_get_counters_cnf_body_t body;
+} sl_wfx_get_counters_cnf_t;
+
+typedef struct __attribute__((__packed__)) sl_wfx_mib_req_body_s
+{
+    uint16_t mib_id; ///< ID of the MIB to be read.
+    uint16_t reserved;
+} sl_wfx_mib_req_body_t;
+
+typedef struct __attribute__((__packed__)) sl_wfx_header_mib_s
+{
+    uint16_t length; ///< Message length in bytes including this uint16_t.
+                     ///< Maximum value is 8188 but maximum Request size is FW dependent and reported in the
+                     ///< ::sl_wfx_startup_ind_body_t::size_inp_ch_buf.
+    uint8_t id;      ///< Contains the message Id indexed by sl_wfx_general_commands_ids_t or sl_wfx_message_ids_t.
+    uint8_t reserved : 1;
+    uint8_t interface : 2;
+    uint8_t seqnum : 3;
+    uint8_t encrypted : 2;
+} sl_wfx_header_mib_t;
+
+typedef struct __attribute__((__packed__)) sl_wfx_mib_req_s
+{
+    /** Common message header. */
+    sl_wfx_header_mib_t header;
+    /** Request message body. */
+    sl_wfx_mib_req_body_t body;
+} sl_wfx_mib_req_t;
+
+#else /* End WF200 else RS911x */
+
 #include "wfx_msgs.h"
 
 /* Wi-Fi events*/
@@ -296,6 +366,7 @@
 
 #ifdef WF200_WIFI
 void wfx_bus_start(void);
+sl_status_t get_all_counters(void);
 void sl_wfx_host_gpio_init(void);
 sl_status_t sl_wfx_host_process_event(sl_wfx_generic_message_t * event_payload);
 #endif