@@ -52,23 +52,30 @@ static int _handle_error(int err, const char * file, int line)
52
52
*/
53
53
static int client_net_recv ( void *ctx, unsigned char *buf, size_t len ) {
54
54
Client *client = (Client*)ctx;
55
- if (!client) {
55
+ if (!client) {
56
56
log_e (" Uninitialised!" );
57
57
return -1 ;
58
58
}
59
-
59
+
60
60
// if (!client->connected()) {
61
61
// log_e("Not connected!");
62
62
// return -2;
63
63
// }
64
+ if (client->available () == 0 ) {
65
+ log_d (" Want to read %u" , len);
66
+ return MBEDTLS_ERR_SSL_WANT_READ;
67
+ }
64
68
65
69
int result = client->read (buf, len);
66
70
log_d (" SSL client RX res=%d len=%d" , result, len);
67
71
68
- if (result > 0 ) {
69
- // esp_log_buffer_hexdump_internal("SSL.RD", buf, (uint16_t)result, ESP_LOG_VERBOSE) ;
72
+ if (result < 0 ) {
73
+ return MBEDTLS_ERR_SSL_WANT_READ ;
70
74
}
71
-
75
+ // if (result > 0) {
76
+ // esp_log_buffer_hexdump_internal("SSL.RD", buf, (uint16_t)result, ESP_LOG_VERBOSE);
77
+ // }
78
+
72
79
return result;
73
80
}
74
81
@@ -307,7 +314,7 @@ int start_ssl_client(sslclient_context *ssl_client, const char *host, uint32_t p
307
314
308
315
log_v (" Setting up IO callbacks..." );
309
316
mbedtls_ssl_set_bio (&ssl_client->ssl_ctx , ssl_client->client ,
310
- client_net_send, NULL , client_net_recv_timeout );
317
+ client_net_send, client_net_recv, NULL );
311
318
312
319
log_v (" Performing the SSL/TLS handshake..." );
313
320
unsigned long handshake_start_time=millis ();
0 commit comments