optimize ESP Insights handling
Signed-off-by: Peter Siegmund <developer@mars3142.org>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "wifi_handler.h"
|
||||
|
||||
#include "esp_event.h"
|
||||
#include "esp_insights.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_wifi.h"
|
||||
@@ -44,7 +45,7 @@ static void event_handler(void *arg, esp_event_base_t event_base, int32_t event_
|
||||
|
||||
esp_wifi_connect();
|
||||
s_retry_num++;
|
||||
ESP_LOGI(TAG, "Retrying to connect to the AP");
|
||||
ESP_DIAG_EVENT(TAG, "Retrying to connect to the AP");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -54,7 +55,7 @@ static void event_handler(void *arg, esp_event_base_t event_base, int32_t event_
|
||||
|
||||
xEventGroupSetBits(s_wifi_event_group, WIFI_FAIL_BIT);
|
||||
}
|
||||
ESP_LOGI(TAG, "Failed to connect to the AP");
|
||||
ESP_DIAG_EVENT(TAG, "Failed to connect to the AP");
|
||||
}
|
||||
else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP)
|
||||
{
|
||||
@@ -65,7 +66,7 @@ static void event_handler(void *arg, esp_event_base_t event_base, int32_t event_
|
||||
led_status_set_behavior(0, led0_behavior);
|
||||
|
||||
ip_event_got_ip_t *event = (ip_event_got_ip_t *)event_data;
|
||||
ESP_LOGI(TAG, "Got IP address:" IPSTR, IP2STR(&event->ip_info.ip));
|
||||
ESP_DIAG_EVENT(TAG, "Got IP address:" IPSTR, IP2STR(&event->ip_info.ip));
|
||||
s_retry_num = 0;
|
||||
xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT);
|
||||
}
|
||||
@@ -102,7 +103,7 @@ void wifi_init_sta()
|
||||
ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config));
|
||||
ESP_ERROR_CHECK(esp_wifi_start());
|
||||
|
||||
ESP_LOGI(TAG, "wifi_init_sta finished.");
|
||||
ESP_DIAG_EVENT(TAG, "wifi_init_sta finished.");
|
||||
|
||||
/* Waiting until either the connection is established (WIFI_CONNECTED_BIT) or
|
||||
connection failed for the maximum number of retries (WIFI_FAIL_BIT). The bits are set by event_handler() */
|
||||
@@ -111,11 +112,11 @@ void wifi_init_sta()
|
||||
|
||||
if (bits & WIFI_CONNECTED_BIT)
|
||||
{
|
||||
ESP_LOGI(TAG, "Connected to AP SSID:%s", CONFIG_WIFI_SSID);
|
||||
ESP_DIAG_EVENT(TAG, "Connected to AP SSID:%s", CONFIG_WIFI_SSID);
|
||||
}
|
||||
else if (bits & WIFI_FAIL_BIT)
|
||||
{
|
||||
ESP_LOGI(TAG, "Failed to connect to SSID:%s", CONFIG_WIFI_SSID);
|
||||
ESP_DIAG_EVENT(TAG, "Failed to connect to SSID:%s", CONFIG_WIFI_SSID);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user