espressif / esp-insights

ESP Insights: A remote diagnostics/observability framework for connected devices
Apache License 2.0
101 stars 27 forks source link

spam "wifi:Haven't to connect to a suitable AP now!" when using 4G or ethernet #37

Open TiDiChi opened 8 months ago

TiDiChi commented 8 months ago

Hi, i am learning about esp-insights. I want to add this into my project using 4G/Ethernet/Wifi. When i config my project using Wifi, my device runs normally, but if 4G/Ethernet this spams "wifi:Haven't to connect to a suitable AP now!". What should i do to fix this !

sarveshb14 commented 8 months ago

Hi @TiDiChi ,

This warning print Haven't to connect to a suitable AP now! is displayed when esp_wifi_sta_get_ap_info(wifi_ap_record_t *ap_info) is called before esp_wifi_connect(void).

You can ignore this message as application (esp-insights in this case) uses this API just to check whether station is connected to Wi-Fi or not.

cc: @vikramdattu

TiDiChi commented 8 months ago

Hi @TiDiChi ,

This warning print Haven't to connect to a suitable AP now! is displayed when esp_wifi_sta_get_ap_info(wifi_ap_record_t *ap_info) is called before esp_wifi_connect(void).

You can ignore this message as application (esp-insights in this case) uses this API just to check whether station is connected to Wi-Fi or not.

cc: @vikramdattu

Thank you very much. I did it and this spam did not appear!

vikramdattu commented 7 months ago

@TiDiChi if you're using interface other than Wi-Fi, it is better to use the netif APIs to query if that particular interface is connected or not. That would be much cleaner.

e.g., for ethernet

     esp_netif_t *esp_netif = esp_netif_get_handle_from_ifkey("ETH_DEF"); // ethernet handle
     if (esp_netif_is_netif_up(esp_netif) && esp_netif_get_ip_info(esp_netif, &ip_info) == ESP_OK) {
         // Do your stuff here
     }

Do check esp_netif.h.