this is using the mbed os version 5-13-1
Diff: source/main-https.cpp
- Branch:
- PassingRegression
- Revision:
- 118:8df0e9c2ee3f
- Parent:
- 117:8fd05113efc1
- Child:
- 119:8d939a902333
--- a/source/main-https.cpp Sun May 19 16:22:59 2019 +0000
+++ b/source/main-https.cpp Sat May 25 16:25:42 2019 +0000
@@ -81,6 +81,16 @@
static Queue<at_data_msg_t, PQDSZ> wiFi2ATDataQueue;
+/* Queue and memory pool for AT to BLE data */
+static MemoryPool<at_ble_msg_t, PQDSZ_BLE> aT2BleDatamPool;
+static Queue<at_ble_msg_t, PQDSZ_BLE> aT2BleDataQueue;
+
+
+/* Queue and memory pool for BLE to AT data */
+static MemoryPool<ble_at_msg_t, PQDSZ_BLE> ble2ATDatamPool;
+static Queue<ble_at_msg_t, PQDSZ_BLE> ble2ATDataQueue;
+
+
/* creates three tread objects with different priorities */
@@ -122,6 +132,9 @@
Mutex _smutex; // Protect memory access
+bool ble_mgr_started;
+bool wifi_mgr_started;
+
uint64_t lastTime = 0;
uint64_t now = 0;
uint32_t callCount = 0;
@@ -149,8 +162,8 @@
void printWaitAbortKeyPress(int numSecs, const char * printStr=NULL)
{
-#ifdef DEBUG_ENABLED
- return
+#ifndef DEBUG_ENABLED
+ return;
#endif
dbg_printf(LOG, "%s", printStr);
dbg_printf(LOG, "Waiting for %d seconds... [press key to abort]\n", numSecs);
@@ -306,15 +319,21 @@
#endif
dbg_printf(LOG, "\r\n PERIPHERAL \r\n\r\n");
peripheral = new SMDevicePeripheral(_ble, eventQueue_ble, peer_address,
+ &aT2BleDatamPool, &aT2BleDataQueue,
+ &ble2ATDatamPool, &ble2ATDataQueue,
&app_config.ble_config);
peripheral->run();
btle_thread.start(callback(&eventQueue_ble, &EventQueue::dispatch_forever));
+ ble_mgr_started = true;
+ wait_ms(10);
}
void stop_BLE()
{
delete peripheral;
+ ble_mgr_started = false;
+ wait_ms(10);
}
void start_WiFi()
@@ -335,11 +354,13 @@
printWaitAbortKeyPress(120, "Wait after WiFi Manager dispatch\r\n");
// dispatch wifi event queue on event thread
wifi_evt_thread.start(callback(&eventQueue_wifi, &EventQueue::dispatch_forever));
+ wifi_mgr_started = true;
}
void stop_WiFi()
{
delete network;
+ wifi_mgr_started = false;
}
@@ -368,7 +389,7 @@
//#define USE_DEFAULT_CONFIGURATION
//#define TEST_NVSTORE
-#define STARTUP_DEBUG_ENABLE
+//#define STARTUP_DEBUG_ENABLE
//#define AUTO_START_BLE_MANAGER
//#define AUTO_START_WIFI_MANAGER
#define PAUSE_SECONDS 0
@@ -383,8 +404,12 @@
setupDefaultCloudConfig();
#endif
device = new RawSerial(USBTX, USBRX, app_config.uart_config.baudrate);
+#if defined (STARTUP_DEBUG_ENABLE) || defined (DEBUG_ENABLED)
uint8_t debug_level = (LOG | ERR | TXT | DBG);
initialise_debug(debug_level);
+#else
+ initialise_debug(NONE);
+#endif
#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
@@ -428,6 +453,8 @@
&wiFi2ATmPool, &wiFi2ATCmdQueue,
&aT2WiFiDatamPool, &aT2WiFiDataQueue,
&wiFi2ATDatamPool, &wiFi2ATDataQueue,
+ &aT2BleDatamPool, &aT2BleDataQueue,
+ &ble2ATDatamPool, &ble2ATDataQueue,
false);
atcmd_thread.start(callback(aTCmdManager, &ATCmdManager::runMain));
dbg_printf(LOG, "\r\n after starting atcmd thread \r\n");
@@ -446,6 +473,10 @@
mainLoop = MAIN_IDLE;
break;
case START_WIFI:
+ if(!ble_mgr_started)
+ {
+ start_BLE();
+ }
start_WiFi();
mainLoop = MAIN_IDLE;
break;