@@ -52,23 +52,30 @@ static int _handle_error(int err, const char * file, int line)
5252 */
5353static int client_net_recv ( void *ctx, unsigned char *buf, size_t len ) {
5454 Client *client = (Client*)ctx;
55- if (!client) {
55+ if (!client) {
5656 log_e (" Uninitialised!" );
5757 return -1 ;
5858 }
59-
59+
6060 // if (!client->connected()) {
6161 // log_e("Not connected!");
6262 // return -2;
6363 // }
64+ if (client->available () == 0 ) {
65+ log_d (" Want to read %u" , len);
66+ return MBEDTLS_ERR_SSL_WANT_READ;
67+ }
6468
6569 int result = client->read (buf, len);
6670 log_d (" SSL client RX res=%d len=%d" , result, len);
6771
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 ;
7074 }
71-
75+ // if (result > 0) {
76+ // esp_log_buffer_hexdump_internal("SSL.RD", buf, (uint16_t)result, ESP_LOG_VERBOSE);
77+ // }
78+
7279 return result;
7380}
7481
@@ -307,7 +314,7 @@ int start_ssl_client(sslclient_context *ssl_client, const char *host, uint32_t p
307314
308315 log_v (" Setting up IO callbacks..." );
309316 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 );
311318
312319 log_v (" Performing the SSL/TLS handshake..." );
313320 unsigned long handshake_start_time=millis ();
0 commit comments