diff --git a/libraries/WiFi/src/WiFiClient.cpp b/libraries/WiFi/src/WiFiClient.cpp index e7acdbce1e4ece462e0f360e8f2d44a157ca5f5f..803f8d99126b1f7a3fd39eb74b35dad46cabad7a 100644 --- a/libraries/WiFi/src/WiFiClient.cpp +++ b/libraries/WiFi/src/WiFiClient.cpp @@ -59,7 +59,7 @@ int WiFiClient::connect(IPAddress ip, uint16_t port) { sockfd = socket(AF_INET, SOCK_STREAM, 0); if (sockfd < 0) { - log_e("error: %d", errno); + log_e("socket: %d", errno); return 0; } uint32_t ip_addr = ip; @@ -70,7 +70,7 @@ int WiFiClient::connect(IPAddress ip, uint16_t port) serveraddr.sin_port = htons(port); int res = lwip_connect_r(sockfd, (struct sockaddr*)&serveraddr, sizeof(serveraddr)); if (res < 0) { - log_e("error: %d", errno); + log_e("lwip_connect_r: %d", errno); close(sockfd); sockfd = -1; return 0; @@ -94,7 +94,7 @@ int WiFiClient::setSocketOption(int option, char* value, size_t len) { int res = setsockopt(sockfd, SOL_SOCKET, option, value, len); if(res < 0) { - log_e("error: %d", errno); + log_e("%d", errno); } return res; } @@ -114,7 +114,7 @@ int WiFiClient::setOption(int option, int *value) { int res = setsockopt(sockfd, IPPROTO_TCP, option, (char *)value, sizeof(int)); if(res < 0) { - log_e("error: %d", errno); + log_e("%d", errno); } return res; } @@ -124,7 +124,7 @@ int WiFiClient::getOption(int option, int *value) size_t size = sizeof(int); int res = getsockopt(sockfd, IPPROTO_TCP, option, (char *)value, &size); if(res < 0) { - log_e("error: %d", errno); + log_e("%d", errno); } return res; } @@ -164,7 +164,7 @@ size_t WiFiClient::write(const uint8_t *buf, size_t size) } int res = send(sockfd, (void*)buf, size, MSG_DONTWAIT); if(res < 0) { - log_e("error: %d", errno); + log_e("%d", errno); _connected = false; sockfd = -1; res = 0; @@ -179,7 +179,7 @@ int WiFiClient::read(uint8_t *buf, size_t size) } int res = recv(sockfd, buf, size, MSG_DONTWAIT); if(res < 0 && errno != EWOULDBLOCK) { - log_e("error: %d", errno); + log_e("%d", errno); _connected = false; sockfd = -1; } @@ -194,7 +194,7 @@ int WiFiClient::available() int count; int res = ioctl(sockfd, FIONREAD, &count); if(res < 0) { - log_e("error: %d", errno); + log_e("%d", errno); _connected = false; sockfd = -1; return 0; diff --git a/libraries/WiFi/src/WiFiGeneric.cpp b/libraries/WiFi/src/WiFiGeneric.cpp index 39646586cde72df72b1ad7af1873b1fbe7db2086..d9a4efc424863c40d660e8139308ed559f1d8881 100644 --- a/libraries/WiFi/src/WiFiGeneric.cpp +++ b/libraries/WiFi/src/WiFiGeneric.cpp @@ -32,11 +32,11 @@ extern "C" { #include #include #include + #include #include #include -#include - +#include "lwip/ip_addr.h" #include "lwip/opt.h" #include "lwip/err.h" #include "lwip/dns.h" @@ -44,9 +44,6 @@ extern "C" { #include "esp32-hal-log.h" } -//#include "WiFiClient.h" -//#include "WiFiUdp.h" - #undef min #undef max #include @@ -107,7 +104,7 @@ void WiFiGenericClass::removeEvent(WiFiEventCb cbEvent, system_event_id_t event) */ esp_err_t WiFiGenericClass::_eventCallback(void *arg, system_event_t *event) { - log_d("wifi evt: %d", event->event_id); + log_d("%d", event->event_id); if(event->event_id == SYSTEM_EVENT_SCAN_DONE) { WiFiScanClass::_scanDone(); @@ -122,7 +119,6 @@ esp_err_t WiFiGenericClass::_eventCallback(void *arg, system_event_t *event) } else { WiFiSTAClass::_setStatus(WL_DISCONNECTED); } - log_d("wifi reason: %d", reason); } else if(event->event_id == SYSTEM_EVENT_STA_START) { WiFiSTAClass::_setStatus(WL_DISCONNECTED); } else if(event->event_id == SYSTEM_EVENT_STA_STOP) { @@ -303,13 +299,13 @@ void startWiFi() err = esp_wifi_start(); if (err != ESP_OK) { - log_e("esp_wifi_start fail %d\n", err); + log_e("esp_wifi_start: %d", err); return; } err = esp_wifi_get_mode(&mode); if (err != ESP_OK) { - log_e("esp_wifi_get_mode fail %d\n", err); + log_e("esp_wifi_get_mode: %d", err); return; } @@ -317,7 +313,7 @@ void startWiFi() if ((mode == WIFI_MODE_STA || mode == WIFI_MODE_APSTA) && auto_connect) { err = esp_wifi_connect(); if (err != ESP_OK) { - log_e("esp_wifi_connect fail %d\n", err); + log_e("esp_wifi_connect: %d", err); } } }