V.06 11/3

Dependencies:   FT6206 SDFileSystem SPI_TFT_ILI9341 TFT_fonts

Fork of ATT_AWS_IoT_demo by attiot

Revision:
16:02008a2a2569
Parent:
15:6f2798e45099
Child:
18:6370da1de572
--- a/AWS_openssl/aws_iot_src/protocol/mqtt/aws_iot_embedded_client_wrapper/platform_mbed_os/openssl/network.cpp	Thu Dec 01 18:05:38 2016 +0000
+++ b/AWS_openssl/aws_iot_src/protocol/mqtt/aws_iot_embedded_client_wrapper/platform_mbed_os/openssl/network.cpp	Fri Dec 02 22:39:56 2016 +0000
@@ -31,7 +31,7 @@
     int rc = -1;
     WNCInterface eth_iface;
     
-    INFO("...Using Avnet AT&T wireless Shield");
+    INFO("...Using Avnet Shield and AT&T wireless LTE");
     rc = eth_iface.init(NULL, &pc);                   
     INFO("WNC Module %s initialized (%02X).", rc?"IS":"IS NOT", rc);
     if( !rc ) {
@@ -60,7 +60,7 @@
     
     /* Connect to the server */
     INFO("Connecting with %s\r\n", host);
-    ret = _tcpsocket->connect(host, AWS_IOT_MQTT_PORT); //TODO
+    ret = _tcpsocket->connect(host, AWS_IOT_MQTT_PORT);
      
     return ret;
 }
@@ -79,23 +79,24 @@
 
 int mbedtls_net_set_block( mbedtls_net_context *ctx )
 {
+    DEBUG("...mbedtls_net_set_block");
     _tcpsocket->set_blocking (false,1500);
     return 0;
 }
 
 void mbedtls_net_free( mbedtls_net_context *ctx )
 {
-    DEBUG("...TODO: mbedtls_net_free");
+    DEBUG("...mbedtls_net_free");
     return; 
 }
-
+#endif
 
 //=====================================================================================================================
 //
 // Uses FRDM-K64F wired ethernet
 //
 //=====================================================================================================================
-#else
+#ifdef USING_FRDM_K64F_LWIP
 // Network Socket
 TCPSocket* _tcpsocket;
 
@@ -119,7 +120,6 @@
     }  
     _tcpsocket = new TCPSocket(&eth_iface);
     
-    //ctx->fd = -1;
     return;
 }
 
@@ -127,11 +127,10 @@
 {
     DEBUG("...mbedtls_net_connect");
     int ret;
-    uint16_t _port = AWS_IOT_MQTT_PORT; // TODO
     
     INFO("...Connecting with %s", host);
-    ret = _tcpsocket->connect(host, _port);
-    _tcpsocket->bind(host, _port);
+    ret = _tcpsocket->connect(host, AWS_IOT_MQTT_PORT);
+    _tcpsocket->bind(host, AWS_IOT_MQTT_PORT);
     if (ret != NSAPI_ERROR_OK) {
         ERROR("Failed to connect");
         return ret;
@@ -144,12 +143,8 @@
 int mbedtls_net_recv_timeout( void *ctx, unsigned char *buf, size_t len, uint32_t timeout )
 {
     DEBUG("...mbedtls_net_recv_timeout len: %d, timeout: %d", len, timeout);
+    int recv = -1;
     
-    int recv = -1;
-    //TCPSocket *socket = static_cast<TCPSocket *>(ctx);
-    //socket->set_blocking(false);   
-    //recv = socket->recv(buf, len);
-    //_tcpsocket->set_blocking(true);
     _tcpsocket->set_timeout(timeout);
     recv = _tcpsocket->recv(buf, len);
         
@@ -168,11 +163,9 @@
 
 int mbedtls_net_send( void *ctx, const unsigned char *buf, size_t len )
 {
-    DEBUG("...mbedtls_net_send");
-    
+    DEBUG("...mbedtls_net_send");  
     int size = -1;
-    //TCPSocket *socket = static_cast<TCPSocket *>(ctx);
-    //size = socket->send(buf, len);
+
     size = _tcpsocket->send(buf, len);
 
     if(NSAPI_ERROR_WOULD_BLOCK == size){
@@ -189,13 +182,14 @@
 
 int mbedtls_net_set_block( mbedtls_net_context *ctx )
 {
+    DEBUG("...mbedtls_net_set_block");
     _tcpsocket->set_blocking(false);
     return 0;
 }
 
 void mbedtls_net_free( mbedtls_net_context *ctx )
 {
-    DEBUG("...TODO: mbedtls_net_free");
+    DEBUG("...mbedtls_net_free");   
     return; 
 }
 #endif
\ No newline at end of file