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

Dependencies:   mbed-http

Revision:
99:05398b3184f8
Parent:
98:65c2333a38b6
Child:
100:80ef4bc31b7a
--- a/source/ATCmdManager.cpp	Sun Apr 21 13:06:41 2019 +0000
+++ b/source/ATCmdManager.cpp	Mon Apr 22 11:11:41 2019 +0000
@@ -41,7 +41,7 @@
     _serial.set_baud(DEFAULT_BAUD_RATE);
     _parser.debug_on(debug);
     _parser.set_delimiter("\r\n");
-    _parser.send("+STARTUP");
+    _parser.send("+STARTUP\r\n");
     _parser.oob("AT\n", callback(this, &ATCmdManager::_oob_ok_hdlr));
     _parser.oob("ATE0", callback(this, &ATCmdManager::_oob_echo_off));
     _parser.oob("ATE1", callback(this, &ATCmdManager::_oob_echo_on));
@@ -124,15 +124,21 @@
                 at_resp = AT_RESP_NONE;
                 break;
             case AT_CONNECT_RESP:  
+            {
                 // AT_CONNECT_RESP response state 
                 printf("\n [ATCMD MAN] WIFI CONNECT RESPONSE RECEIVED!!\r\n");
                 //_smutex.lock();
                 //sendAtConfirmation(OK_RESP);   //_parser.send(OK_RESP);
                 respStr = (char *) resp_data->buffer;
                 sendAtConfirmationFreeMpool(respStr);
+                char * urc = new char[20];
+                sprintf(urc, "\r\n%s=%d\r\n", NETWORK_UP_URC, WIFI_INTERFACE_ID);
+                sendAtEvent(urc);
+                delete urc;
                 //_smutex.unlock();
                 at_resp = AT_RESP_NONE;
                 break;
+            }
             case AT_DISCONNECT_RESP:  
                 // AT_DISCONNECT_RESP response state 
                 //////_smutex.lock();
@@ -215,6 +221,14 @@
                 //_smutex.unlock();
                 at_resp = AT_RESP_NONE;
                 break;
+            case CONNECT_EVENT:  
+            {
+                // Connect Event state 
+                printf("\n [ATCMD MAN] CONNECT EVENT RECEIVED!!\r\n");
+                sendConnectEvent(resp_data->buffer, resp_data->dataLen);
+                at_resp = AT_RESP_NONE;
+                break;
+            }
             case AT_COMMAND_FAILED:  
             {
                 // AT_HTTP_RESP response state 
@@ -259,13 +273,13 @@
 bool ATCmdManager::validate(edm_header_t edm_header)
 {
     if(edm_header.startByte != EDM_START_BYTE)return false; // unexpected start byte found!
-    if(edm_header.payloadID != CONNECT_EVENT &&
-       edm_header.payloadID != DISCONNECT_EVENT &&
-       edm_header.payloadID != DATA_EVENT &&
-       edm_header.payloadID != DATA_COMMAND &&
-       edm_header.payloadID != AT_REQUEST &&
-       edm_header.payloadID != AT_CONFIRMATION &&
-       edm_header.payloadID != AT_EVENT 
+    if(edm_header.payloadID != CONNECT_EVENT_ID &&
+       edm_header.payloadID != DISCONNECT_EVENT_ID &&
+       edm_header.payloadID != DATA_EVENT_ID &&
+       edm_header.payloadID != DATA_COMMAND_ID &&
+       edm_header.payloadID != AT_REQUEST_ID &&
+       edm_header.payloadID != AT_CONFIRMATION_ID &&
+       edm_header.payloadID != AT_EVENT_ID 
        )return false; // unexpected payload ID found!
     if(edm_header.payloadLen > MAX_EDM_PAYLOAD_LEN ||
        edm_header.payloadLen < MIN_EDM_PAYLOAD_LEN 
@@ -413,7 +427,7 @@
             start = Kernel::get_ms_count();
             if(n == -1) break; // break if it times out
             int pT;
-            if(edm_hdr.payloadID < AT_REQUEST) //
+            if(edm_hdr.payloadID < AT_REQUEST_ID) //
             {
                 n += _parser.read((char *)edm, 1);
                 edm_hdr.channel_id = (channel_id_t) edm[0];
@@ -434,7 +448,7 @@
                                                                          edm_hdr.channel_id);
             if(n == (EDM_HDR_LEN-pT) && validate(edm_hdr)) // if AT command use process oob to decode
             {
-                if(edm_hdr.payloadID == AT_REQUEST)
+                if(edm_hdr.payloadID == AT_REQUEST_ID)
                 {
                     //_parser.process_oob();
                     while (_parser.process_oob() && all) {
@@ -464,16 +478,16 @@
                     }
                     switch(edm_hdr.payloadID)
                     {
-                        case CONNECT_EVENT:
+                        case CONNECT_EVENT_ID:
                             printf("Connection Event received!\n");
                             break;
-                        case DISCONNECT_EVENT:
+                        case DISCONNECT_EVENT_ID:
                             printf("DISCONNECT_EVENT received!\n");
                             break;
-                        case DATA_EVENT:
+                        case DATA_EVENT_ID:
                             printf("DATA_EVENT received!\n");
                             break;
-                        case DATA_COMMAND:
+                        case DATA_COMMAND_ID:
                         {
                             printf("DATA_COMMAND received!\n");
                             sendAtConfirmation(OK_RESP);   //_parser.send(OK_RESP);
@@ -493,13 +507,13 @@
                             printf("\n Time Elapsed = %d\n", stop-start);
                             break;
                         }
-                        case AT_REQUEST:
+                        case AT_REQUEST_ID:
                             printf("AT_REQUEST received!\n");
                             break;
-                        case AT_CONFIRMATION:
+                        case AT_CONFIRMATION_ID:
                             printf("AT_CONFIRMATION received!\n");
                             break;
-                        case AT_EVENT:
+                        case AT_EVENT_ID:
                             printf("AT_EVENT received!\n");
                             break;
                         default:
@@ -612,7 +626,7 @@
     //_smutex.lock();
     printf("\n Received EDM mode command!!\n");
     if(_parser.scanf("%d", &dataMode) >0) {
-        printf("\nATCmdParser: Data mode=%d\n", dataMode);
+        printf("\nATCmdParser: Data mode=%d\r\n", dataMode);
         sendAtConfirmation(OK_RESP);   //_parser.send(OK_RESP);
         switch(dataMode)
         {
@@ -1079,6 +1093,7 @@
     if(evt.status == osEventMessage){
         resp_data = (at_data_msg_t*)evt.value.p;
         setNextResponse(resp_data->at_resp);
+        printf("[ATCMD MAN] dequeued data size = %d : at_resr = %d\n", resp_data->dataLen, resp_data->at_resp);
         _event_queue.call_in(10, &print_heap_and_isr_stack_info);
         //print_heap_and_isr_stack_info();
     }
@@ -1120,16 +1135,36 @@
             _parser.send(buf);
             break;
         case AT_EXT_DATA_MODE:
+        {
             int len =  strlen(buf);
             outputEDMdata((const uint8_t *) buf, len, AT_MSG_ID, EVENT_MSG_TYPE, NO_CHANNEL);
             break;
-        //default:
-            //_parser.send(buf);
-            //break;
+        }
+        default:
+            _parser.send(buf);
+            break;
     }
     _smutex.unlock();
 }
 
+
+void ATCmdManager::sendConnectEvent(const uint8_t *buf, int len)
+{
+    //_smutex.lock();
+    switch(dataMode){
+        case AT_CMD_DATA_MODE:
+            _parser.send((const char*) buf);
+            break;
+        case AT_STD_DATA_MODE:
+            _parser.send((const char*)buf);
+            break;
+        case AT_EXT_DATA_MODE:
+            outputEDMdata((const uint8_t *) buf, len, CONNECT_MSG_ID, EVENT_MSG_TYPE, WIFI_CHANNEL);
+            break;
+    }
+}
+
+
 void ATCmdManager::outputEDMdata(const uint8_t *buf, int pLen, 
                                  edm_msg_id_t identifier, edm_msg_type_t type,
                                  channel_id_t channel_id)