From 3d6e4e1b94ccdfe269da9c314b755e2345a164fa Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Mon, 15 Apr 2019 17:27:54 +0200 Subject: [PATCH] Use milliseconds for timeout --- libraries/WiFiClientSecure/src/WiFiClientSecure.cpp | 4 ++-- libraries/WiFiClientSecure/src/ssl_client.cpp | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/libraries/WiFiClientSecure/src/WiFiClientSecure.cpp b/libraries/WiFiClientSecure/src/WiFiClientSecure.cpp index 357a688f..3f545c67 100644 --- a/libraries/WiFiClientSecure/src/WiFiClientSecure.cpp +++ b/libraries/WiFiClientSecure/src/WiFiClientSecure.cpp @@ -124,7 +124,7 @@ int WiFiClientSecure::connect(IPAddress ip, uint16_t port, const char *_CA_cert, int WiFiClientSecure::connect(const char *host, uint16_t port, const char *_CA_cert, const char *_cert, const char *_private_key) { if(_timeout > 0){ - sslclient->handshake_timeout = _timeout * 1000; + sslclient->handshake_timeout = _timeout; } int ret = start_ssl_client(sslclient, host, port, _timeout, _CA_cert, _cert, _private_key, NULL, NULL); _lastError = ret; @@ -144,7 +144,7 @@ int WiFiClientSecure::connect(IPAddress ip, uint16_t port, const char *pskIdent, int WiFiClientSecure::connect(const char *host, uint16_t port, const char *pskIdent, const char *psKey) { log_v("start_ssl_client with PSK"); if(_timeout > 0){ - sslclient->handshake_timeout = _timeout * 1000; + sslclient->handshake_timeout = _timeout; } int ret = start_ssl_client(sslclient, host, port, _timeout, NULL, NULL, NULL, _pskIdent, _psKey); _lastError = ret; diff --git a/libraries/WiFiClientSecure/src/ssl_client.cpp b/libraries/WiFiClientSecure/src/ssl_client.cpp index f5ad4c6b..ce48ebeb 100644 --- a/libraries/WiFiClientSecure/src/ssl_client.cpp +++ b/libraries/WiFiClientSecure/src/ssl_client.cpp @@ -74,9 +74,8 @@ int start_ssl_client(sslclient_context *ssl_client, const char *host, uint32_t p if (lwip_connect(ssl_client->socket, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) == 0) { if(timeout <= 0){ - timeout = 30; + timeout = 30000; } - timeout *= 1000;//to milliseconds lwip_setsockopt(ssl_client->socket, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)); lwip_setsockopt(ssl_client->socket, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(timeout)); lwip_setsockopt(ssl_client->socket, IPPROTO_TCP, TCP_NODELAY, &enable, sizeof(enable));