Fix #1465 - rename LL_* constants, introduce MG_* log macros

This commit is contained in:
Sergey Lyubka committed 2022-02-12 18:17:25 +00:00
1 parent da72dafbfb
commit 969b84043c
40 files changed
+361 -372

No files matched your search

+2 -2
View File
@@ -39,7 +39,7 @@ void app_main(void) {
esp_vfs_spiffs_conf_t conf = {
.base_path = FS_ROOT, .max_files = 20, .format_if_mount_failed = true};
int res = esp_vfs_spiffs_register(&conf);
LOG(res == ESP_OK ? LL_INFO : LL_ERROR, ("FS %s, %d", conf.base_path, res));
MG_INFO(("FS %s, %d", conf.base_path, res));
mg_file_printf(&mg_fs_posix, FS_ROOT "/hello.txt", "%s", "hello from ESP");
// Setup wifi. This function is implemented in wifi.c
@@ -52,6 +52,6 @@ void app_main(void) {
mg_log_set("3");
mg_mgr_init(&mgr);
mg_http_listen(&mgr, "http://0.0.0.0:80", cb, &mgr); // Listening server
LOG(LL_INFO, ("Starting Mongoose web server v%s", MG_VERSION));
MG_INFO(("Starting Mongoose web server v%s", MG_VERSION));
for (;;) mg_mgr_poll(&mgr, 1000); // Infinite event loop
}
+7 -7
View File
@@ -35,14 +35,14 @@ static void event_handler(void *arg, esp_event_base_t event_base,
if (s_retry_num < 3) {
esp_wifi_connect();
s_retry_num++;
LOG(LL_INFO, ("retry to connect to the AP"));
MG_INFO(("retry to connect to the AP"));
} else {
xEventGroupSetBits(s_wifi_event_group, WIFI_FAIL_BIT);
}
LOG(LL_ERROR, ("connect to the AP fail"));
MG_ERROR(("connect to the AP fail"));
} else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) {
ip_event_got_ip_t *event = (ip_event_got_ip_t *) event_data;
LOG(LL_INFO, ("got ip:" IPSTR, IP2STR(&event->ip_info.ip)));
MG_INFO(("got ip:" IPSTR, IP2STR(&event->ip_info.ip)));
s_retry_num = 0;
xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT);
}
@@ -81,18 +81,18 @@ void wifi_init(const char *ssid, const char *pass) {
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &c));
ESP_ERROR_CHECK(esp_wifi_start());
LOG(LL_DEBUG, ("wifi_init_sta finished."));
MG_DEBUG(("wifi_init_sta finished."));
EventBits_t bits = xEventGroupWaitBits(s_wifi_event_group,
WIFI_CONNECTED_BIT | WIFI_FAIL_BIT,
pdFALSE, pdFALSE, portMAX_DELAY);
if (bits & WIFI_CONNECTED_BIT) {
LOG(LL_INFO, ("connected to ap SSID:%s password:%s", ssid, pass));
MG_INFO(("connected to ap SSID:%s password:%s", ssid, pass));
} else if (bits & WIFI_FAIL_BIT) {
LOG(LL_ERROR, ("Failed to connect to SSID:%s, password:%s", ssid, pass));
MG_ERROR(("Failed to connect to SSID:%s, password:%s", ssid, pass));
} else {
LOG(LL_ERROR, ("UNEXPECTED EVENT"));
MG_ERROR(("UNEXPECTED EVENT"));
}
/* The event will not be processed after unregister */