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:
Thu Mar 28 23:03:33 2019 +0000
Parent:
84:7c7add00f4bf
Child:
86:04fc2fcda7ec
Commit message:
http request getting to wifi manager

Changed in this revision

source/ATCmdManager.cpp 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
--- a/source/ATCmdManager.cpp	Thu Mar 28 22:13:06 2019 +0000
+++ b/source/ATCmdManager.cpp	Thu Mar 28 23:03:33 2019 +0000
@@ -245,12 +245,14 @@
     // package and send on wifi data queue
     wifi_data_msg_t data_msg;
     data_msg.wifi_cmd = WIFI_CMD_SEND_HTTPS_REQ;
-    data_msg.dataLen = sizeof(http_req) + http_req.request_URI.length() +
-                       http_req.http_version.length() + 
-                       http_req.hostName.length() +
-                       http_req.AcceptVal.length() +
-                       http_req.contentType.length() +
-                       http_req.contentLen.length();
+    data_msg.dataLen = sizeof(http_req.method) + 
+                       sizeof(http_req.body) + 
+                       http_req.request_URI.capacity() +
+                       http_req.http_version.capacity() + 
+                       http_req.hostName.capacity() +
+                       http_req.AcceptVal.capacity() +
+                       http_req.contentType.capacity() +
+                       http_req.contentLen.capacity();
     memcpy(data_msg.buffer,&http_req, data_msg.dataLen);
     // queue next data request
     queueWiFiDataRequest(data_msg);
@@ -568,16 +570,12 @@
 
 void ATCmdManager::_oob_setupInternetConnection()
 {
-    ////print_memory_info();
-    char str[200]; // = (char *) malloc(200);
-    char url[60]; // = (char *) malloc(60);
+    char str[200];
+    char url[60];
     int n;
-    //internet_config_t *internet_config = (internet_config_t *) malloc(sizeof(internet_config_t));
     internet_config_t internet_config;
+    //_smutex.lock();
     printf("sizeof internet_config_t = %d\n", sizeof(internet_config_t));
-    //internet_config->url;
-    //internet_config->url;
-    //_smutex.lock();
     n = ReadBytes((uint8_t *)str, 199);
     str[n]=NULL;
     printf("\n read string = %s , n = %d\n", str, n);
@@ -588,28 +586,15 @@
     printf("\n read string = %s , n = %d -- strlen(url) = %d\n", internet_config.url, n, strlen(url));
     if(n>0) 
     {
-        //printf("before assign - still ok\n");
-        //internet_config.url.append(url);
-        //printf("after assign - still ok\n");
-        //print_all_thread_info();
-        //print_memory_info();
-        //internet_config->url->assign(url);
-        ////print_memory_info();
         printf("peer_id = %1d, url = %s, connScheme = %1d\n", internet_config.peer_id, 
                                                           internet_config.url, ///->c_str(), 
                                                           internet_config.connectionScheme);
-        //print_memory_info();
         // package and send on wifi data queue
         wifi_data_msg_t data_msg; // = (wifi_data_msg_t *) malloc(sizeof(wifi_data_msg_t));
         data_msg.wifi_cmd = WIFI_CMD_INTERNET_CONFIG;
         data_msg.dataLen = sizeof(internet_config_t); // + strlen(internet_config.url);
         printf("\n url size = %d url str = %s\n",strlen(internet_config.url), internet_config.url );
         memcpy(data_msg.buffer,&internet_config, data_msg.dataLen);
-        //print_memory_info();
-        //free(internet_config->url);
-        //free(internet_config);
-        //free(str);
-        //free(url);
         // queue next data request
         queueWiFiDataRequest(data_msg);
         print_memory_info();
--- a/source/WiFiManager.cpp	Thu Mar 28 22:13:06 2019 +0000
+++ b/source/WiFiManager.cpp	Thu Mar 28 23:03:33 2019 +0000
@@ -432,7 +432,8 @@
     //Callback<void(const char *at, uint32_t length)> body_callback = 0
     printf("\n[WIFI MAN] Http Request received:");
     http_req_cfg = (http_request_t *) data_msg->buffer;
-    strncat(internet_config.url, http_req_cfg->request_URI.c_str(), strlen(http_req_cfg->request_URI.c_str()+1));
+    printf("\n[WIFI MAN] uri = %s", http_req_cfg->request_URI.c_str());
+    strncat(internet_config.url, http_req_cfg->request_URI.c_str(), http_req_cfg->request_URI.size());
     printf("\n[WIFI MAN] server url = %s\n", internet_config.url);
     //printf("\n[WIFI MAN] server url = %s\n", internet_config.url.c_str());
     //const char* url = internet_config.url;