diff --git a/libraries/WiFi/src/WiFiClient.h b/libraries/WiFi/src/WiFiClient.h index 09841f1a..4915cfd5 100644 --- a/libraries/WiFi/src/WiFiClient.h +++ b/libraries/WiFi/src/WiFiClient.h @@ -28,7 +28,15 @@ class WiFiClientSocketHandle; class WiFiClientRxBuffer; -class WiFiClient : public Client +class ESPLwIPClient : public Client +{ +public: + virtual int connect(IPAddress ip, uint16_t port, int32_t timeout) = 0; + virtual int connect(const char *host, uint16_t port, int32_t timeout) = 0; + virtual int setTimeout(uint32_t seconds) = 0; +}; + +class WiFiClient : public ESPLwIPClient { protected: std::shared_ptr clientSocketHandle; diff --git a/libraries/WiFiClientSecure/src/WiFiClientSecure.h b/libraries/WiFiClientSecure/src/WiFiClientSecure.h index 1e838295..cd4f20e0 100644 --- a/libraries/WiFiClientSecure/src/WiFiClientSecure.h +++ b/libraries/WiFiClientSecure/src/WiFiClientSecure.h @@ -72,6 +72,8 @@ public: bool verify(const char* fingerprint, const char* domain_name); void setHandshakeTimeout(unsigned long handshake_timeout); + int setTimeout(uint32_t seconds){ return 0; } + operator bool() { return connected(); diff --git a/libraries/WiFiClientSecure/src/ssl_client.cpp b/libraries/WiFiClientSecure/src/ssl_client.cpp index ce48ebeb..ce8b31c7 100644 --- a/libraries/WiFiClientSecure/src/ssl_client.cpp +++ b/libraries/WiFiClientSecure/src/ssl_client.cpp @@ -22,7 +22,7 @@ const char *pers = "esp32-tls"; -static int handle_error(int err) +static int _handle_error(int err, const char * file, int line) { if(err == -30848){ return err; @@ -30,12 +30,15 @@ static int handle_error(int err) #ifdef MBEDTLS_ERROR_C char error_buf[100]; mbedtls_strerror(err, error_buf, 100); - log_e("%s", error_buf); + log_e("[%s():%d]: (%d) %s", file, line, err, error_buf); +#else + log_e("[%s():%d]: code %d", file, line, err); #endif - log_e("MbedTLS message code: %d", err); return err; } +#define handle_error(e) _handle_error(e, __FUNCTION__, __LINE__) + void ssl_init(sslclient_context *ssl_client) {