diff --git a/src/EspNetworkFunctions.cpp b/src/EspNetworkFunctions.cpp index 68a40a3..104b679 100644 --- a/src/EspNetworkFunctions.cpp +++ b/src/EspNetworkFunctions.cpp @@ -8,6 +8,7 @@ #include #include "esp_wifi.h" +#include tcpip_adapter_if_t tcpip_if[MAX_ACTIVE_INTERFACES] = { TCPIP_ADAPTER_IF_MAX }; @@ -137,34 +138,8 @@ network_result_t network_wait_for_connection(int32_t listeningSocket, int32_t* c // error return E_NETWORK_RESULT_FAILED; } - if (ip_addr) { - // check on which network interface the client was connected and save the IP address - tcpip_adapter_ip_info_t ip_info = { 0 }; - int n_if = network_get_active_interfaces(); - - if (n_if > 0) { - struct sockaddr_in clientAddr; - in_addrSize = sizeof(struct sockaddr_in); - getpeername(_sd, (struct sockaddr*)&clientAddr, (socklen_t*)&in_addrSize); - ESP_LOGI(NETWORK_TAG, "Client IP: %08x", clientAddr.sin_addr.s_addr); - *ip_addr = 0; - for (int i = 0; i < n_if; i++) { - tcpip_adapter_get_ip_info(tcpip_if[i], &ip_info); - ESP_LOGI(NETWORK_TAG, "Adapter: %08x, %08x", ip_info.ip.addr, ip_info.netmask.addr); - if ((ip_info.ip.addr & ip_info.netmask.addr) == (ip_info.netmask.addr & clientAddr.sin_addr.s_addr)) { - *ip_addr = ip_info.ip.addr; - ESP_LOGI(NETWORK_TAG, "Client connected on interface %d", tcpip_if[i]); - break; - } - } - if (*ip_addr == 0) { - ESP_LOGE(NETWORK_TAG, "No IP address detected (?!)"); - } - } - else { - ESP_LOGE(NETWORK_TAG, "No active interface (?!)"); - } + *ip_addr = WiFi.localIP(); } // enable non-blocking mode if not data channel connection diff --git a/src/WifiCachingStream.cpp b/src/WifiCachingStream.cpp index 9b05d95..fcd419e 100644 --- a/src/WifiCachingStream.cpp +++ b/src/WifiCachingStream.cpp @@ -99,7 +99,7 @@ void WifiCachingStream::flush() size_t WifiCachingStream::readBytes(char* buffer, size_t length) { - int received = 0; + size_t received = 0; auto result = network_recv_non_blocking(_connection_sd, buffer, (int)length, &received); if (received >= 1) { diff --git a/src/WifiCachingStream.h b/src/WifiCachingStream.h index b16145f..2331fc1 100644 --- a/src/WifiCachingStream.h +++ b/src/WifiCachingStream.h @@ -13,10 +13,10 @@ class WifiCachingStream : public Stream { private: static constexpr int SendBufferSize = 500; - int _sd; - int _port; + int32_t _sd; + int32_t _port; - int _connection_sd; + int32_t _connection_sd; byte _sendBuffer[SendBufferSize]; int _sendBufferIndex;