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

Dependencies:   mbed-http

Files at this revision

API Documentation at this revision

Comitter:
ocomeni
Date:
Sun Apr 07 17:31:56 2019 +0000
Parent:
90:ed0267eca7b5
Child:
92:ec9550034276
Commit message:
added method to handle sending expected command response strings

Changed in this revision

source/ATCmdManager.cpp Show annotated file Show diff for this revision Revisions of this file
source/ATCmdManager.h Show annotated file Show diff for this revision Revisions of this file
source/WiFiManager.cpp Show annotated file Show diff for this revision Revisions of this file
source/WiFiManager.h Show annotated file Show diff for this revision Revisions of this file
--- a/source/ATCmdManager.cpp	Sun Apr 07 10:52:37 2019 +0000
+++ b/source/ATCmdManager.cpp	Sun Apr 07 17:31:56 2019 +0000
@@ -863,7 +863,8 @@
 }
 
 void ATCmdManager::outputEDMdata(const uint8_t *buf, int pLen, 
-                                 edm_msg_id_t identifier, edm_msg_type_t type)
+                                 edm_msg_id_t identifier, edm_msg_type_t type,
+                                 channel_id_t channel_id)
 {
     int epLen = pLen + 2; // edm payload length = data length + 2
     _smutex.lock();
@@ -875,6 +876,8 @@
     // send EDM Identifier + Type
     _parser.putc(identifier>>8);
     _parser.putc(identifier%256 | type);
+    // send EDM Identifier + Type
+    _parser.putc(channel_id);
     // send the data
     _parser.write((const char *)buf, pLen);
     // send EDM Message stop byte
@@ -895,7 +898,8 @@
         printBufferInHex((uint8_t *)resp, resp_data->dataLen);
     }
     //_parser.write(resp, resp_data->dataLen);
-    outputEDMdata((const uint8_t *)resp, resp_data->dataLen, DATA_MSG_ID, EVENT_MSG_TYPE);
+    outputEDMdata((const uint8_t *)resp, resp_data->dataLen, DATA_MSG_ID, 
+                  EVENT_MSG_TYPE, WIFI_CHANNEL);
     _smutex.unlock();
     _wiFi2ATDatamPool->free(resp_data);
     
--- a/source/ATCmdManager.h	Sun Apr 07 10:52:37 2019 +0000
+++ b/source/ATCmdManager.h	Sun Apr 07 17:31:56 2019 +0000
@@ -109,7 +109,8 @@
     void        return_response(bool download=false); 
     void        printBufferInHex(uint8_t *buf, int pLen);
     void        outputEDMdata(const uint8_t *buf, int pLen, 
-                              edm_msg_id_t identifier, edm_msg_type_t type);
+                              edm_msg_id_t identifier, edm_msg_type_t type,
+                              channel_id_t channel_id);
     
     /**
     * Allows timeout to be changed between commands
--- a/source/WiFiManager.cpp	Sun Apr 07 10:52:37 2019 +0000
+++ b/source/WiFiManager.cpp	Sun Apr 07 17:31:56 2019 +0000
@@ -121,6 +121,33 @@
     
 }
 
+
+void  WiFiManager::sentATresponseString(at_cmd_resp_t at_cmd, 
+                                        const char *responseString, 
+                                        int strLen)
+{
+    at_data_resp = new at_data_msg_t;
+    // create message pointer for response header generation
+    char * msgPtr = (char *)at_data_resp->buffer;
+    // set string length 
+    at_data_resp->dataLen = strLen;
+    memcpy(at_data_resp->buffer, responseString, strLen);
+    // package and send on wifi data queue    
+    at_data_resp->at_resp = at_cmd;
+    bool queueResult = true;
+    int wait_count = 0;
+    do
+    {
+        if(!queueResult){
+            wait_count++;
+            printf("ATCMD Queue full waiting %d ms so far...\n", wait_count*10);
+            wait_ms(10);
+        }
+        queueResult = queueWiFiDataResponse(*at_data_resp);
+    }while(queueResult == false);
+    delete at_data_resp;
+}                                            
+
 bool  WiFiManager::dequeueWiFiCommands(){
     if(wifiCmd != WIFI_CMD_NONE) return false; // busy
     osEvent evt = _aT2WiFiCmdQueue->get(0);
@@ -234,6 +261,7 @@
     strcpy(wifi_config.ssid, wifi_ssid);
     printf("[WIFI-MAN]  wifi_ssid set to %s\n", wifi_config.ssid);
     https_connection_active = false; // reset whenever any of the security credentials change
+    delete socket;
 }
 
 
@@ -242,6 +270,7 @@
     strcpy(wifi_config.pass, wifi_pass);
     printf("[WIFI-MAN]  wifi_pass set to %s\n", wifi_config.pass);
     https_connection_active = false; // reset whenever any of the security credentials change
+    delete socket;
 }
 
 
@@ -250,6 +279,7 @@
     wifi_config.security = wifi_security;
     printf("[WIFI-MAN]  wifi_security set to %s\n", sec2str(wifi_config.security));
     https_connection_active = false; // reset whenever any of the security credentials change
+    delete socket;
 }
 
 
@@ -266,6 +296,7 @@
                                                       internet_config.url, 
                                                       internet_config.connectionScheme);
     https_connection_active = false; // reset whenever any of the security credentials change
+    delete socket;
 }
 
 void WiFiManager::free_DataMsg()
@@ -300,7 +331,7 @@
             if(internet_config.connectionScheme == ALWAYS_CONNECTED)
             {
                 nsapi_error_t error;
-                error = scanNetworks();
+                error = connect();
                 queueATresponse(WIFI_RECONNECT_INFO);
             }
             break;
--- a/source/WiFiManager.h	Sun Apr 07 10:52:37 2019 +0000
+++ b/source/WiFiManager.h	Sun Apr 07 17:31:56 2019 +0000
@@ -103,6 +103,9 @@
     bool                  createTLSconnection(const char *hostName);
     void                  printBufferInHex(uint8_t *buf, int pLen);
     void                  copyResponseHdr2Queue();
+    void                  sentATresponseString(at_cmd_resp_t at_cmd, 
+                                               const char *responseString, 
+                                               int strLen);
 
 
     /**