Skip to content

Commit 31d0b73

Browse files
committed
Merge branch 'erase_flash' of https://github.com/PilnyTomas/arduino-esp32 into pr/7043
2 parents 3f47a0c + 6f0cb63 commit 31d0b73

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

libraries/WiFi/src/WiFiClient.cpp

+8-7
Original file line numberDiff line numberDiff line change
@@ -305,20 +305,21 @@ int WiFiClient::connect(const char *host, uint16_t port, int32_t timeout)
305305

306306
int WiFiClient::setSocketOption(int option, char* value, size_t len)
307307
{
308-
int res = setsockopt(fd(), SOL_SOCKET, option, value, len);
308+
return setSocketOption(SOL_SOCKET, option, (const void*)value, len);
309+
}
310+
311+
int WiFiClient::setSocketOption(int level, int option, const void* value, size_t len)
312+
{
313+
int res = setsockopt(fd(), level, option, value, len);
309314
if(res < 0) {
310-
log_e("%X : %d", option, errno);
315+
log_e("fail on %d, errno: %d, \"%s\"", fd(), errno, strerror(errno));
311316
}
312317
return res;
313318
}
314319

315320
int WiFiClient::setOption(int option, int *value)
316321
{
317-
int res = setsockopt(fd(), IPPROTO_TCP, option, (char *) value, sizeof(int));
318-
if(res < 0) {
319-
log_e("fail on fd %d, errno: %d, \"%s\"", fd(), errno, strerror(errno));
320-
}
321-
return res;
322+
return setSocketOption(IPPROTO_TCP, option, (const void*)value, sizeof(int));
322323
}
323324

324325
int WiFiClient::getOption(int option, int *value)

libraries/WiFi/src/WiFiClient.h

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ class WiFiClient : public ESPLwIPClient
8888
int fd() const;
8989

9090
int setSocketOption(int option, char* value, size_t len);
91+
int setSocketOption(int level, int option, const void* value, size_t len);
9192
int setOption(int option, int *value);
9293
int getOption(int option, int *value);
9394
int setNoDelay(bool nodelay);

libraries/WiFiClientSecure/src/WiFiClientSecure.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -389,9 +389,14 @@ void WiFiClientSecure::setAlpnProtocols(const char **alpn_protos)
389389

390390
int WiFiClientSecure::setSocketOption(int option, char* value, size_t len)
391391
{
392-
int res = setsockopt(sslclient->socket, SOL_SOCKET, option, value, len);
392+
return setSocketOption(SOL_SOCKET, option, (const void*)value, len);
393+
}
394+
395+
int WiFiClientSecure::setSocketOption(int level, int option, const void* value, size_t len)
396+
{
397+
int res = setsockopt(sslclient->socket, level, option, value, len);
393398
if(res < 0) {
394-
log_e("%X : %d", option, errno);
399+
log_e("fail on %d, errno: %d, \"%s\"", sslclient->socket, errno, strerror(errno));
395400
}
396401
return res;
397402
}

libraries/WiFiClientSecure/src/WiFiClientSecure.h

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class WiFiClientSecure : public WiFiClient
8080
const mbedtls_x509_crt* getPeerCertificate() { return mbedtls_ssl_get_peer_cert(&sslclient->ssl_ctx); };
8181
bool getFingerprintSHA256(uint8_t sha256_result[32]) { return get_peer_fingerprint(sslclient, sha256_result); };
8282
int setSocketOption(int option, char* value, size_t len);
83+
int setSocketOption(int level, int option, const void* value, size_t len);
8384

8485
operator bool()
8586
{

0 commit comments

Comments
 (0)