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

Dependencies:   mbed-http

Branch:
PassingRegression
Revision:
113:888e262ff0a9
Parent:
112:a0999ea4ece0
Child:
114:b11bb96c09f3
--- a/source/main-https.cpp	Sat May 11 11:55:29 2019 +0000
+++ b/source/main-https.cpp	Sat May 18 10:50:49 2019 +0000
@@ -47,6 +47,7 @@
 char buffer[BUFFER_LEN];
 static EventQueue eventQueue_atcmd(/* event count */ 32 * EVENTS_EVENT_SIZE);
 static EventQueue eventQueue_wifi(/* event count */ 32 * EVENTS_EVENT_SIZE);
+static EventQueue eventQueue_ble(/* event count */ 10 * EVENTS_EVENT_SIZE);
 
 /*  Queue and memory pool for AT to Wifi commands */
 static MemoryPool<wifi_cmd_message_t, 16> aT2WiFimPool;
@@ -83,7 +84,7 @@
 Thread atcmd_thread(ATCMD_THREAD_PRIORITY, 4*1024, &atcmd_stk[0]);
 #else
 // using global heap
-Thread btle_thread(BTLE_THREAD_PRIORITY, 1024);
+Thread btle_thread(BTLE_THREAD_PRIORITY, 4*1024);
 Thread wifi_thread(WIFI_THREAD_PRIORITY, 4*1024);
 Thread atcmd_thread(ATCMD_THREAD_PRIORITY, 4*1024);
 #endif
@@ -132,8 +133,9 @@
 }
 
 
-void printWaitAbortKeyPress(int numSecs)
+void printWaitAbortKeyPress(int numSecs, const char * printStr=NULL)
 {
+    dbg_printf(LOG, "%s", printStr);
     dbg_printf(LOG, "Waiting for %d seconds... [press key to abort]\n", numSecs);
     char fmtstr[20];
     for(int i=0;i<numSecs;i++){
@@ -142,7 +144,7 @@
         sprintf(fmtstr, "BLE: loop # %d\n", i);
         peripheral->sendBLEUartData(fmtstr);
         wait(0.5);
-        eventQueue_atcmd.dispatch(500);        // Dispatch time - 500msec
+        //eventQueue_atcmd.dispatch(500);        // Dispatch time - 500msec
         if(device->readable()){
             dbg_printf(LOG, "keypress detected aborting....\n");
             device->getc();
@@ -217,7 +219,8 @@
 #define PAUSE_SECONDS_BLE 0
 int main() {
     device = new RawSerial(USBTX, USBRX, 2*DEFAULT_BAUD_RATE);
-    initialise_debug();
+    uint8_t debug_level = (LOG | ERR | TXT | DBG);
+    initialise_debug(debug_level);
 #ifdef MBED_MAJOR_VERSION
     dbg_printf(LOG, "Mbed OS version %d.%d.%d\n\n", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION);
 #endif
@@ -227,7 +230,6 @@
     setupDefaultWiFiConfig();
     setupDefaultBleConfig();
     BLE& _ble = BLE::Instance();
-    events::EventQueue queue(/* event count */ 10 * EVENTS_EVENT_SIZE);
 #if MBED_CONF_APP_FILESYSTEM_SUPPORT
     /* if filesystem creation fails or there is no filesystem the security manager
      * will fallback to storing the security database in memory */
@@ -236,16 +238,18 @@
     }
 #endif
     dbg_printf(LOG, "\r\n PERIPHERAL \r\n\r\n");
-    peripheral = new SMDevicePeripheral(_ble, queue, peer_address, ble_config);
+    peripheral = new SMDevicePeripheral(_ble, eventQueue_ble, peer_address, ble_config);
 
     peripheral->run();
-    btle_thread.start(callback(&queue, &EventQueue::dispatch_forever));
-
+    btle_thread.start(callback(&eventQueue_ble, &EventQueue::dispatch_forever));
+    //btle_thread.start(callback(peripheral, &SMDevicePeripheral::run));
+    printWaitAbortKeyPress(120, "Wait after BLE dispatch\r\n");
     int start = Kernel::get_ms_count();
     network = WiFiInterface::get_default_instance();
     if (!network) {
         dbg_printf(LOG, "ERROR: No WiFiInterface found.\n");
     }
+    printWaitAbortKeyPress(120, "Wait after WiFi instantiation\r\n");
     wiFiManager = new WiFiManager(wifi_config, network, 
                                   eventQueue_wifi,
                                   &aT2WiFimPool, &aT2WiFiCmdQueue,
@@ -258,6 +262,8 @@
     dbg_printf(LOG, "\r\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \r\n");
     wifi_thread.start(callback(wiFiManager, &WiFiManager::runMain));
     dbg_printf(LOG, "\r\n after starting wifi thread \r\n");
+    printWaitAbortKeyPress(120, "Wait after WiFi Manager dispatch\r\n");
+    initialise_debug(NONE);
     // dispatch wifi event queue on event thread
     wifi_evt_thread.start(callback(&eventQueue_wifi, &EventQueue::dispatch_forever));
     // dispatch atcmd event queue on event thread