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

Dependencies:   mbed-http

Revision:
87:99b37d26ff2a
Parent:
86:04fc2fcda7ec
Child:
88:7ffa053be662
--- a/source/ATCmdManager.cpp	Thu Mar 28 23:41:10 2019 +0000
+++ b/source/ATCmdManager.cpp	Fri Mar 29 22:18:33 2019 +0000
@@ -10,10 +10,10 @@
                            Queue<wifi_cmd_message_t, 16>      *aT2WiFiCmdQueue, 
                            MemoryPool<at_resp_message_t, 16>  *wiFi2ATmPool, 
                            Queue<at_resp_message_t, 16>       *wiFi2ATCmdQueue, 
-                           MemoryPool<wifi_data_msg_t, 4>     *aT2WiFiDatamPool, 
-                           Queue<wifi_data_msg_t, 4>          *aT2WiFiDataQueue, 
-                           MemoryPool<at_data_msg_t, 4>       *wiFi2ATDatamPool, 
-                           Queue<at_data_msg_t, 4>            *wiFi2ATDataQueue, 
+                           MemoryPool<wifi_data_msg_t, PQDSZ>     *aT2WiFiDatamPool, 
+                           Queue<wifi_data_msg_t, PQDSZ>          *aT2WiFiDataQueue, 
+                           MemoryPool<at_data_msg_t, PQDSZ>       *wiFi2ATDatamPool, 
+                           Queue<at_data_msg_t, PQDSZ>            *wiFi2ATDataQueue, 
                            bool debug)
     :
     _serial(tx, rx, DEFAULT_BAUD_RATE),
@@ -68,12 +68,14 @@
     printf("\n --- ATCmdManager constructor completed ---\n");
     at_resp = AT_RESP_NONE;
     dataMode = AT_CMD_DATA_MODE;
+    event_queue.call_every(120000,&print_memory_info);
     //AT+UMRS=230400,2,8,1,1,1
     // AT+UBTLE
 }
 
 
 void ATCmdManager::runMain(){
+    printf("\r\n [ATCMD MAN]  Thread Id = %d\r\n", Thread::gettid());
     while(true){
         _process_oob(UBLOX_ODIN_W2_RECV_TIMEOUT, true);
         wait_ms(MAIN_LOOP_WAIT_TIME_MS); // allow BTLE/WiFi some time 
@@ -84,6 +86,7 @@
 
 void ATCmdManager::processResponses(){
         dequeueATresponse();
+        dequeueWiFidataResponse();
         switch(at_resp){
             case AT_RESP_NONE:
                 // IDLE response state
@@ -140,6 +143,7 @@
                 // AT_HTTP_RESP response state 
                 //////_smutex.lock();
                 printf("\n [ATCMD MAN] WIFI HTTPS RESPONSE RECEIVED!!\n");
+                return_response();
                 _parser.send("OK\n");
                 //////_smutex.unlock();
                 at_resp = AT_RESP_NONE;
@@ -198,6 +202,8 @@
 bool ATCmdManager::createHttpRequest()
 {
     http_request_t http_req;
+    printf("\nsizeof(http_req) on creation = %d\n", sizeof(http_req));
+
     char s1[32];
     char s2[32];
     char s3[32];
@@ -254,6 +260,8 @@
     // package and send on wifi data queue
     wifi_data_msg_t data_msg;
     data_msg.wifi_cmd = WIFI_CMD_SEND_HTTPS_REQ;
+    printf("\nsizeof(http_req) on population = %d\n", sizeof(http_req));
+/*
     data_msg.dataLen = sizeof(http_req.method) + 
                        sizeof(http_req.body) + 
                        http_req.request_URI.capacity() +
@@ -262,6 +270,15 @@
                        http_req.AcceptVal.capacity() +
                        http_req.contentType.capacity() +
                        http_req.contentLen.capacity();
+*/
+    data_msg.dataLen = sizeof(http_req.method) + 
+                       sizeof(http_req.body) + 
+                       http_req.request_URI.size() +
+                       http_req.http_version.size() + 
+                       http_req.hostName.size() +
+                       http_req.AcceptVal.size() +
+                       http_req.contentType.size() +
+                       http_req.contentLen.size();
     memcpy(data_msg.buffer,&http_req, data_msg.dataLen);
     // queue next data request
     queueWiFiDataRequest(data_msg);
@@ -275,7 +292,7 @@
     if(dataMode == AT_EXT_DATA_MODE)
     {
         int n;
-        if(cnt++ % 10 == 0)printf("In EDM mode\n");
+        //if(cnt++ % 10 == 0)printf("In EDM mode\n");
         uint8_t edm[EDM_HDR_LEN];
         
         // Poll for edm packets
@@ -308,7 +325,7 @@
                     printf("%d bytes read - expected %d!\n", n, pLen);
                     for(int i =0;i<pLen;i++){
                         if(i%8==0) printf("\n[%3d]",i/8);
-                        printf("%2x ", rx_buf_ptr[i]);
+                        printf("%02x ", rx_buf_ptr[i]);
                     }
                     printf("\n");
                     printf("rx_buf_ptr[pLen-1] = %0x\n",rx_buf_ptr[pLen-1]);
@@ -782,7 +799,7 @@
     return true;
 }
 
-bool  ATCmdManager::dequeueATdataResponse(){
+bool  ATCmdManager::dequeueWiFidataResponse(){
     if(at_resp != AT_RESP_NONE) return false; // busy
     osEvent evt = _wiFi2ATDataQueue->get(0);
     if(evt.status == osEventMessage){
@@ -794,4 +811,10 @@
 }
 
 
-
+void ATCmdManager::return_response() {
+    char * resp = (char *) resp_data->buffer;
+    printf("\n[ATCMD MAN] received response:\n");
+    printf("%s\r\n", (char *)resp);
+    _wiFi2ATDatamPool->free(resp_data);
+    
+}