this is using the mbed os version 5-13-1

Dependencies:   mbed-http

Branch:
PassingRegression
Revision:
119:8d939a902333
Parent:
118:8df0e9c2ee3f
Child:
120:779b74689747
--- a/source/ATCmdManager.cpp	Sat May 25 16:25:42 2019 +0000
+++ b/source/ATCmdManager.cpp	Mon May 27 12:34:58 2019 +0000
@@ -246,12 +246,46 @@
                 at_resp = AT_RESP_NONE;
                 break;
             }
+            case BLE_CONNECT_EVENT:  
+            {
+                // AT Event state 
+                dbg_printf(LOG, "\n [ATCMD MAN] BLE_CONNECT_EVENT RESPONSE RECEIVED!!\r\n");
+                uint8_t * respBytes = ble_resp_data->buffer;
+                sendBleConnectEvent((const char *)respBytes, ble_resp_data->dataLen);
+                at_resp = AT_RESP_NONE;
+                break;
+            }
+            case AT_BLE_EVENT:  
+            {
+                // AT Event state 
+                dbg_printf(LOG, "\n [ATCMD MAN] AT_BLE_EVENT RESPONSE RECEIVED!!\r\n");
+                respStr = (char *) resp_data->buffer;
+                sendBleAtEvent(respStr, resp_data->dataLen);
+                at_resp = AT_RESP_NONE;
+                break;
+            }
             case AT_BLE_RESPONSE:  
             {
                 // AT Event state 
-                dbg_printf(LOG, "\n [ATCMD MAN] BLE RESPONSE RECEIVED!!\r\n");
-                respStr = (char *) resp_data->buffer;
-                sendBleDataEvent(respStr, resp_data->dataLen);
+                dbg_printf(LOG, "\n [ATCMD MAN] AT_BLE_RESPONSE RECEIVED!!\r\n");
+                respStr = (char *) ble_resp_data->buffer;
+                sendBleDataEvent(respStr, ble_resp_data->dataLen);
+                at_resp = AT_RESP_NONE;
+                break;
+            }
+            case AT_SOCKET_KEEP_ALIVE_OK:  
+            {
+                // AT Event state 
+                dbg_printf(LOG, "\n [ATCMD MAN] AT_SOCKET_KEEP_ALIVE OK RESPONSE RECEIVED!!\r\n");
+                sendAtEvent("\r\nCLOUD CONNECTION OK\r\n");
+                at_resp = AT_RESP_NONE;
+                break;
+            }
+            case AT_SOCKET_KEEP_ALIVE_FAILED:  
+            {
+                // AT Event state 
+                dbg_printf(LOG, "\n [ATCMD MAN] AT_SOCKET_KEEP_ALIVE FAILED RESPONSE RECEIVED!!\r\n");
+                sendAtEvent("\r\nCLOUD CONNECTION FAILED\r\n");
                 at_resp = AT_RESP_NONE;
                 break;
             }
@@ -548,6 +582,7 @@
                         dbg_printf(LOG, "Timeout while reading message payload bytes - expected %d!\r\n", pLen);
                         free(rx_buf_ptr); // make sure to free buffer
                         rx_buf_ptr = NULL;
+                        sendAtConfirmation(UART_TIMEOUT_ERROR);
                         break; // timeout!
                     }
                     dbg_printf(LOG, "%d bytes read - expected %d!\n", n, pLen);
@@ -1260,8 +1295,58 @@
             break;
     }
     _smutex.unlock();
-    _wiFi2ATDatamPool->free(resp_data);
-    resp_data = NULL;
+    _ble2ATDatamPool->free(ble_resp_data);
+    ble_resp_data = NULL;
+}
+
+
+
+void ATCmdManager::sendBleAtEvent(const char *buf, int len)
+{
+    _smutex.lock();
+    switch(dataMode){
+        case AT_CMD_DATA_MODE:
+            _parser.send(buf);
+            break;
+        case AT_STD_DATA_MODE:
+            _parser.send(buf);
+            break;
+        case AT_EXT_DATA_MODE:
+        {
+            outputEDMdata((const uint8_t *) buf, len, AT_MSG_ID, EVENT_MSG_TYPE, BLE_CHANNEL);
+            break;
+        }
+        default:
+            _parser.send(buf);
+            break;
+    }
+    _smutex.unlock();
+    _ble2ATDatamPool->free(ble_resp_data);
+    ble_resp_data = NULL;
+}
+
+void ATCmdManager::sendBleConnectEvent(const char *buf, int len)
+{
+    _smutex.lock();
+    switch(dataMode){
+        case AT_CMD_DATA_MODE:
+            _parser.send(buf);
+            break;
+        case AT_STD_DATA_MODE:
+            _parser.send(buf);
+            break;
+        case AT_EXT_DATA_MODE:
+        {
+            outputEDMdata((const uint8_t *) buf, len, CONNECT_MSG_ID, EVENT_MSG_TYPE, BLE_CHANNEL);
+            break;
+        }
+        default:
+            _parser.send(buf);
+            break;
+    }
+    _smutex.unlock();
+    _ble2ATDatamPool->free(ble_resp_data);
+    ble_resp_data = NULL;
 }