this is using the mbed os version 5-13-1
Diff: source/WiFiManager.cpp
- Branch:
- PassingRegression
- Revision:
- 112:a0999ea4ece0
- Parent:
- 111:3ab1d9644835
- Child:
- 113:888e262ff0a9
--- a/source/WiFiManager.cpp Fri May 10 13:45:50 2019 +0000
+++ b/source/WiFiManager.cpp Sat May 11 11:55:29 2019 +0000
@@ -43,7 +43,8 @@
wifiWatchdogTimer.start();
watchdogCnt = 0;
//_event_queue.call_every(10000, this, &WiFiManager::callWifiWatchDog);
- watchDogTick.attach(this, &WiFiManager::callWifiWatchDogIsr, 10000.0); // call flip function every 2 seconds
+ watchDogTick.attach(callback(this, &WiFiManager::callWifiWatchDogIsr), 10000.0); // call flip function every 10 seconds
+
}
WiFiManager::~WiFiManager()
@@ -70,7 +71,7 @@
sendATresponseString(WIFI_WATCH_DOG);
watchdogCnt = 0;
}
- else if(wifiWatchdogTimer.read() > 30.0 && responseString==NULL)
+ else if(wifiWatchdogTimer.read() > 30 && responseString==NULL)
{
if(wifiCmd == WIFI_CMD_NONE)
inactivity_monitor++;
@@ -430,11 +431,8 @@
WiFiAccessPoint *ap;
nsapi_size_or_error_t count;
count = ncount;
- //count = wiFiManager->scanNetworks();
if (count <= 0) {
- //_smutex.lock();
dbg_printf(LOG, "[WIFI-MAN] scan() failed with return value: %d\n", count);
- //_smutex.unlock();
return 0;
}
/* Limit number of network arbitrary to 15 */
@@ -692,12 +690,9 @@
{
dbg_printf(LOG, "[WIFI-MAN] about to call status_callback_event... \r\n");
_event_queue.call_in(50, this, &WiFiManager::status_callback_event, status, param);
- //status_callback_event(status, param);
}
void WiFiManager::status_callback_event(nsapi_event_t status, intptr_t param)
{
- //if (status == NSAPI_EVENT_CONNECTION_STATUS_CHANGE) {
- //}
switch(param) {
case NSAPI_STATUS_LOCAL_UP:
dbg_printf(LOG, "[WIFI-MAN] Local IP address set!\r\n");
@@ -720,7 +715,6 @@
dbg_printf(LOG, "No connection to network!\r\n");
dbg_printf(LOG, "\n [WIFI-MAN] No connection to network!\n");
is_connected = false;
- //queueATresponse(AT_DISCONNECT_RESP);
// attempt reconnection if always connected scheme is set
if(internet_config.connectionScheme == ALWAYS_CONNECTED)
{
@@ -741,11 +735,6 @@
- // NSAPI_STATUS_LOCAL_UP = 0, /*!< local IP address set */
- // NSAPI_STATUS_GLOBAL_UP = 1, /*!< global IP address set */
- // NSAPI_STATUS_DISCONNECTED = 2, /*!< no connection to network */
- // NSAPI_STATUS_CONNECTING = 3, /*!< connecting to network */
- // NSAPI_STATUS_ERROR_UNSUPPORTED = NSAPI_ERROR_UNSUPPORTED
nsapi_error_t WiFiManager::connect()
{
@@ -817,9 +806,9 @@
dbg_printf(LOG, "\r\nHOSTNAME TRANSLATION FAILURE : error code = %d \r\n", result);
if(responseString == NULL)
{
- //responseString = (char *) malloc(100);
- //sprintf(responseString, "\r\nHOSTNAME TRANSLATION FAILURE : error code = %d \r\n", result);
- //sendATresponseString(AT_EVENT);
+ responseString = (char *) malloc(100);
+ sprintf(responseString, "\r\nHOSTNAME TRANSLATION FAILURE : error code = %d \r\n", result);
+ sendATresponseString(AT_EVENT);
}
}
wifiBusy = 0;
@@ -854,11 +843,7 @@
void WiFiManager::sendResponseDownloadData(at_cmd_resp_t at_cmd, const uint8_t * buf, int bufLen)
{
- //dbg_printf(LOG, "before call to new at_data_msg_t \n");
- //print_memory_info();
at_data_resp = new at_data_msg_t;
- //dbg_printf(LOG, "after call to new at_data_msg_t \n");
- //print_memory_info();
at_data_resp->at_resp = at_cmd;
size_t bufSize = sizeof(at_data_resp->buffer);
int pos = 0;
@@ -982,11 +967,6 @@
void WiFiManager::printBufferInHex(const uint8_t *buf, int pLen)
{
- //for(int i =0;i<pLen;i++){
- // if(i%8==0) dbg_printf(LOG, "\n[%3d]",i);
- // dbg_printf(LOG, "%02x ", buf[i]);
- //}
- //dbg_printf(LOG, "\n");
print_debug_hex(buf, pLen);
}
@@ -1044,7 +1024,6 @@
char errstr[100];
mbedtls_strerror(r, errstr, 100);
dbg_printf(LOG, "TLS connect failed (err = %d) for hostname '%s' -- ERROR = %s !!\n", r, hostName, errstr);
- //printf("TLS connect failed for hostname %s -- ERROR = %s !!\n", hostName, errstr);
socket->close();
return false;
}
@@ -1129,11 +1108,8 @@
callback(this, &WiFiManager::body_callback));
setHttpHeader("Host", http_req_cfg->hostName);
setHttpHeader("Accept", http_req_cfg->AcceptVal);
- //dbg_printf(LOG, "http_req_cfg->method = %d\n", http_req_cfg->method);
if(http_req_cfg->method == HTTP_GET){
dbg_printf(LOG, "HTTP_GET -- ignoring body\n");
- //setHttpHeader("Content-Type", http_req_cfg->contentType);
- //setHttpHeader("Content-Length", http_req_cfg->contentLen);
http_response = http_request->send(NULL, 0);
}
else{
@@ -1146,7 +1122,6 @@
char buf[100];
mbedtls_strerror(http_request->get_error(), buf, 100);
dbg_printf(LOG, "HttpRequest failed (error code %s)\n", buf);
- //dbg_printf(LOG, "HttpsRequest failed (error code %d)\n", https_request->get_error());
delete http_request; // free the memory
return false;
}
@@ -1180,17 +1155,9 @@
updateRemotePeerDetails();
// send socket connection event before proceeding to send https request
// give about 2 ms
- //_event_queue.call(this, &WiFiManager::sendSocketConnectionEvent);
sendSocketConnectionEvent();
- //https_connection_active = true; // set true whenever connection succeeds
- //return true;
- //dbg_printf(LOG, "[create https] TLS connection successful for https site : %s\n", host);
- //dbg_printf(LOG, "after call to createTLSconnection \n");
- //print_memory_info();
}
// Pass in `socket`, instead of `network` as first argument, and omit the `SSL_CA_PEM` argument
- //HttpsRequest* get_req = new HttpsRequest(socket, HTTP_GET, "https://httpbin.org/status/418");
- //_wmutex.lock();
stoptime = Kernel::get_ms_count();
dbg_printf(LOG, "\r\nTLS connection time : %d ms\r\n", (stoptime - starttime));
starttime = Kernel::get_ms_count();
@@ -1216,33 +1183,17 @@
dbg_printf(LOG, "HTTP_GET -- ignoring body\n");
setHttpsHeader("Host", http_req_cfg->hostName);
setHttpsHeader("Accept", http_req_cfg->AcceptVal);
- //setHttpHeader("Content-Type", http_req_cfg->contentType);
- //setHttpHeader("Content-Length", http_req_cfg->contentLen);
http_response = https_request->send(NULL, 0);
}
else{
- //dbg_printf(LOG, "about to setup https headers\r\n");
setHttpsHeader("Host", http_req_cfg->hostName);
setHttpsHeader("Accept", http_req_cfg->AcceptVal);
setHttpsHeader("Content-Type", http_req_cfg->contentType);
setHttpsHeader("Content-Length", http_req_cfg->contentLen);
dbg_printf(LOG, "https headers setup - about to send request\r\n");
// Grab the heap statistics
- //mbed_stats_heap_t heap_stats;
- //mbed_stats_heap_get(&heap_stats);
dbg_printf(LOG, "Heap size: %lu / %lu bytes\r\n", heap_stats.current_size, heap_stats.reserved_size);
-#ifdef SEND_DEBUG_MESSAGES
- responseString = (char *) malloc(200);
- sprintf(responseString, "\r\nABOUT TO SEND HTTP REQUEST\r\n");
- sendDebugMessage();
- responseString = (char *) malloc(200);
- sprintf(responseString, "Heap size= %lu / %lu bytes\r\n", heap_stats.current_size, heap_stats.reserved_size);
- sendDebugMessage();
http_response = https_request->send(http_req_cfg->body, bodyLen);
- responseString = (char *) malloc(100);
- sprintf(responseString, "\r\nRETURNED FROM SENDING HTTP REQUEST\r\n");
- sendDebugMessage();
-#endif
}
#else
setHttpsHeader("Host", http_req_cfg->hostName);