NuMaker connection with AWS IoT thru MQTT/HTTPS

Dependencies:   MQTT

Files at this revision

API Documentation at this revision

Comitter:
ccli8
Date:
Fri Oct 12 17:57:02 2018 +0800
Parent:
15:47ab2fe3a0fc
Child:
17:6f0ff065cd76
Commit message:
Fix TLSSocket read/write return code for MQTT

Fix return code in TLSSocket read/write when mbedtls_ssl_read/mbedtls_ssl_write
return MBEDTLS_ERR_SSL_WANT_READ/MBEDTLS_ERR_SSL_WANT_WRITE.

Changed in this revision

TLSSocket.h Show annotated file Show diff for this revision Revisions of this file
--- a/TLSSocket.h	Fri Oct 12 15:36:09 2018 +0800
+++ b/TLSSocket.h	Fri Oct 12 17:57:02 2018 +0800
@@ -287,7 +287,8 @@
      */
     int read(unsigned char* buffer, int len, int timeout) {
         set_timeout(timeout);
-        return recv(buffer, len);
+        int rc = recv(buffer, len);
+        return (rc == MBEDTLS_ERR_SSL_WANT_READ || rc == MBEDTLS_ERR_SSL_WANT_WRITE) ? 0 : rc;
     }
 
     /**
@@ -295,7 +296,8 @@
      */
     int write(unsigned char* buffer, int len, int timeout) {
         set_timeout(timeout);
-        return send(buffer, len);
+        int rc = send(buffer, len);
+        return (rc == MBEDTLS_ERR_SSL_WANT_READ || rc == MBEDTLS_ERR_SSL_WANT_WRITE) ? 0 : rc;
     }
     
 protected: