
this is using the mbed os version 5-13-1
source/main-https.cpp@113:888e262ff0a9, 2019-05-18 (annotated)
- Committer:
- ocomeni
- Date:
- Sat May 18 10:50:49 2019 +0000
- Branch:
- PassingRegression
- Revision:
- 113:888e262ff0a9
- Parent:
- 112:a0999ea4ece0
- Child:
- 114:b11bb96c09f3
BLE now working at startup.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ocomeni | 73:6f5021cbe752 | 1 | #define MBED_CONF_MBED_TRACE_ENABLE 1 |
ocomeni | 73:6f5021cbe752 | 2 | |
ocomeni | 73:6f5021cbe752 | 3 | #include "select-demo.h" |
ocomeni | 103:7b566b522427 | 4 | #include "debug.h" |
ocomeni | 73:6f5021cbe752 | 5 | |
ocomeni | 73:6f5021cbe752 | 6 | #if DEMO == DEMO_HTTPS |
ocomeni | 73:6f5021cbe752 | 7 | |
ocomeni | 73:6f5021cbe752 | 8 | #include <events/mbed_events.h> |
ocomeni | 73:6f5021cbe752 | 9 | #include <mbed.h> |
ocomeni | 73:6f5021cbe752 | 10 | #include "ble/BLE.h" |
ocomeni | 88:7ffa053be662 | 11 | #include "fault_handlers.h" |
ocomeni | 73:6f5021cbe752 | 12 | #include "ATCmdParser.h" |
ocomeni | 103:7b566b522427 | 13 | |
ocomeni | 73:6f5021cbe752 | 14 | |
ocomeni | 73:6f5021cbe752 | 15 | #include "LEDService.h" |
ocomeni | 73:6f5021cbe752 | 16 | #include "ble/services/UARTService.h" |
ocomeni | 74:f26e846adfe9 | 17 | #include "common_config.h" |
ocomeni | 79:a2187bbfa407 | 18 | #include "common_types.h" |
ocomeni | 74:f26e846adfe9 | 19 | #include "ATCmdManager.h" |
ocomeni | 75:08eff6258e1b | 20 | #include "BleManager.h" |
ocomeni | 78:07bb86e3ce14 | 21 | #include "WiFiManager.h" |
ocomeni | 92:ec9550034276 | 22 | #include "mbed_memory_status.h" |
ocomeni | 73:6f5021cbe752 | 23 | UARTService *uart; |
ocomeni | 73:6f5021cbe752 | 24 | |
ocomeni | 108:3c8fb2c6e7bf | 25 | DigitalOut led1(LED1); |
ocomeni | 108:3c8fb2c6e7bf | 26 | DigitalOut led2(LED2); |
ocomeni | 108:3c8fb2c6e7bf | 27 | DigitalOut led3(LED3); |
ocomeni | 73:6f5021cbe752 | 28 | |
ocomeni | 103:7b566b522427 | 29 | #define FILE_CODE "main" |
ocomeni | 73:6f5021cbe752 | 30 | |
ocomeni | 74:f26e846adfe9 | 31 | static RawSerial *device; // tx, rx |
ocomeni | 78:07bb86e3ce14 | 32 | |
ocomeni | 78:07bb86e3ce14 | 33 | // wifi configuration |
ocomeni | 78:07bb86e3ce14 | 34 | static wifi_config_t wifi_config; |
ocomeni | 78:07bb86e3ce14 | 35 | // wifi interface pointer |
ocomeni | 78:07bb86e3ce14 | 36 | static WiFiInterface *network; |
ocomeni | 78:07bb86e3ce14 | 37 | // wifi manager pointer |
ocomeni | 78:07bb86e3ce14 | 38 | static WiFiManager *wiFiManager; |
ocomeni | 78:07bb86e3ce14 | 39 | |
ocomeni | 78:07bb86e3ce14 | 40 | // BLE configuration |
ocomeni | 78:07bb86e3ce14 | 41 | static ble_config_t ble_config; |
ocomeni | 79:a2187bbfa407 | 42 | const uint8_t pairingPassword[6] = "1101"; |
ocomeni | 78:07bb86e3ce14 | 43 | // BLE peripheral pointer |
ocomeni | 77:0b505d1e15f4 | 44 | static SMDevicePeripheral *peripheral; |
ocomeni | 78:07bb86e3ce14 | 45 | |
ocomeni | 78:07bb86e3ce14 | 46 | const static char DEVICE_NAME_MAIN[] = "UBLOX-BLE"; |
ocomeni | 73:6f5021cbe752 | 47 | char buffer[BUFFER_LEN]; |
ocomeni | 109:c274780ff609 | 48 | static EventQueue eventQueue_atcmd(/* event count */ 32 * EVENTS_EVENT_SIZE); |
ocomeni | 109:c274780ff609 | 49 | static EventQueue eventQueue_wifi(/* event count */ 32 * EVENTS_EVENT_SIZE); |
ocomeni | 113:888e262ff0a9 | 50 | static EventQueue eventQueue_ble(/* event count */ 10 * EVENTS_EVENT_SIZE); |
ocomeni | 73:6f5021cbe752 | 51 | |
ocomeni | 80:e8f0e92e3ac9 | 52 | /* Queue and memory pool for AT to Wifi commands */ |
ocomeni | 92:ec9550034276 | 53 | static MemoryPool<wifi_cmd_message_t, 16> aT2WiFimPool; |
ocomeni | 92:ec9550034276 | 54 | static Queue<wifi_cmd_message_t, 16> aT2WiFiCmdQueue; |
ocomeni | 79:a2187bbfa407 | 55 | |
ocomeni | 80:e8f0e92e3ac9 | 56 | /* Queue and memory pool for WiFi to AT commands */ |
ocomeni | 92:ec9550034276 | 57 | static MemoryPool<at_resp_message_t, 16> wiFi2ATmPool; |
ocomeni | 92:ec9550034276 | 58 | static Queue<at_resp_message_t, 16> wiFi2ATCmdQueue; |
ocomeni | 80:e8f0e92e3ac9 | 59 | |
ocomeni | 80:e8f0e92e3ac9 | 60 | /* Queue and memory pool for AT to WiFi data */ |
ocomeni | 92:ec9550034276 | 61 | static MemoryPool<wifi_data_msg_t, PQDSZ> aT2WiFiDatamPool; |
ocomeni | 92:ec9550034276 | 62 | static Queue<wifi_data_msg_t, PQDSZ> aT2WiFiDataQueue; |
ocomeni | 80:e8f0e92e3ac9 | 63 | |
ocomeni | 80:e8f0e92e3ac9 | 64 | |
ocomeni | 80:e8f0e92e3ac9 | 65 | /* Queue and memory pool for WiFi to AT data */ |
ocomeni | 92:ec9550034276 | 66 | static MemoryPool<at_data_msg_t, PQDSZ> wiFi2ATDatamPool; |
ocomeni | 92:ec9550034276 | 67 | static Queue<at_data_msg_t, PQDSZ> wiFi2ATDataQueue; |
ocomeni | 80:e8f0e92e3ac9 | 68 | |
ocomeni | 80:e8f0e92e3ac9 | 69 | |
ocomeni | 80:e8f0e92e3ac9 | 70 | |
ocomeni | 74:f26e846adfe9 | 71 | |
ocomeni | 74:f26e846adfe9 | 72 | /* creates three tread objects with different priorities */ |
ocomeni | 74:f26e846adfe9 | 73 | //Thread real_time_thread(osPriorityRealtime, 1024, &rt_stk[0]); |
ocomeni | 74:f26e846adfe9 | 74 | //Thread high_prio_thread(osPriorityHigh, 1024, &hp_stk[0]); |
ocomeni | 74:f26e846adfe9 | 75 | //Thread low_prio_thread(osPriorityNormal, 1024, &lp_stk[0]); |
ocomeni | 84:7c7add00f4bf | 76 | |
ocomeni | 84:7c7add00f4bf | 77 | #ifdef USE_MAIN_THREAD_STACK |
ocomeni | 84:7c7add00f4bf | 78 | // using main thread stack |
ocomeni | 84:7c7add00f4bf | 79 | unsigned char btle_stk[1024]; |
ocomeni | 84:7c7add00f4bf | 80 | unsigned char wifi_stk[8*1024]; |
ocomeni | 84:7c7add00f4bf | 81 | unsigned char atcmd_stk[4*1024]; |
ocomeni | 74:f26e846adfe9 | 82 | Thread btle_thread(BTLE_THREAD_PRIORITY, 1024, &btle_stk[0]); |
ocomeni | 84:7c7add00f4bf | 83 | Thread wifi_thread(WIFI_THREAD_PRIORITY, 8*1024, &wifi_stk[0]); |
ocomeni | 81:637a87eb8170 | 84 | Thread atcmd_thread(ATCMD_THREAD_PRIORITY, 4*1024, &atcmd_stk[0]); |
ocomeni | 84:7c7add00f4bf | 85 | #else |
ocomeni | 84:7c7add00f4bf | 86 | // using global heap |
ocomeni | 113:888e262ff0a9 | 87 | Thread btle_thread(BTLE_THREAD_PRIORITY, 4*1024); |
ocomeni | 109:c274780ff609 | 88 | Thread wifi_thread(WIFI_THREAD_PRIORITY, 4*1024); |
ocomeni | 87:99b37d26ff2a | 89 | Thread atcmd_thread(ATCMD_THREAD_PRIORITY, 4*1024); |
ocomeni | 84:7c7add00f4bf | 90 | #endif |
ocomeni | 74:f26e846adfe9 | 91 | |
ocomeni | 74:f26e846adfe9 | 92 | /* create a semaphore to synchronize the threads */ |
ocomeni | 74:f26e846adfe9 | 93 | Semaphore sync_sema; |
ocomeni | 74:f26e846adfe9 | 94 | |
ocomeni | 109:c274780ff609 | 95 | Thread atcmd_evt_thread(osPriorityNormal, 1024); |
ocomeni | 109:c274780ff609 | 96 | Thread wifi_evt_thread; |
ocomeni | 74:f26e846adfe9 | 97 | #include "network-helper.h" |
ocomeni | 73:6f5021cbe752 | 98 | |
ocomeni | 73:6f5021cbe752 | 99 | /* List of trusted root CA certificates |
ocomeni | 73:6f5021cbe752 | 100 | * currently two: GlobalSign, the CA for os.mbed.com and Let's Encrypt, the CA for httpbin.org |
ocomeni | 73:6f5021cbe752 | 101 | * |
ocomeni | 73:6f5021cbe752 | 102 | * To add more root certificates, just concatenate them. |
ocomeni | 73:6f5021cbe752 | 103 | */ |
ocomeni | 73:6f5021cbe752 | 104 | #include "https_certificates.h" |
ocomeni | 73:6f5021cbe752 | 105 | |
ocomeni | 74:f26e846adfe9 | 106 | // wifi demo |
ocomeni | 74:f26e846adfe9 | 107 | #include "wifi_demo.h" |
ocomeni | 73:6f5021cbe752 | 108 | |
ocomeni | 77:0b505d1e15f4 | 109 | Mutex _smutex; // Protect memory access |
ocomeni | 87:99b37d26ff2a | 110 | |
ocomeni | 73:6f5021cbe752 | 111 | uint64_t lastTime = 0; |
ocomeni | 73:6f5021cbe752 | 112 | uint64_t now = 0; |
ocomeni | 73:6f5021cbe752 | 113 | uint32_t callCount = 0; |
ocomeni | 73:6f5021cbe752 | 114 | |
ocomeni | 73:6f5021cbe752 | 115 | |
ocomeni | 73:6f5021cbe752 | 116 | // Wifi-demo |
ocomeni | 73:6f5021cbe752 | 117 | void wifi_demo(NetworkInterface* network){ |
ocomeni | 74:f26e846adfe9 | 118 | int n = wifi_demo_func(network); |
ocomeni | 74:f26e846adfe9 | 119 | if(n > 0)// error |
ocomeni | 73:6f5021cbe752 | 120 | { |
ocomeni | 103:7b566b522427 | 121 | dbg_printf(LOG, "\n --- Error running wifi demo --- \n"); |
ocomeni | 73:6f5021cbe752 | 122 | } |
ocomeni | 74:f26e846adfe9 | 123 | } |
ocomeni | 73:6f5021cbe752 | 124 | |
ocomeni | 74:f26e846adfe9 | 125 | // Wifi-demo2 |
ocomeni | 74:f26e846adfe9 | 126 | void wifi_demo2(){ |
ocomeni | 74:f26e846adfe9 | 127 | //int n = wifi_demo_func(network); |
ocomeni | 74:f26e846adfe9 | 128 | int n =5; |
ocomeni | 74:f26e846adfe9 | 129 | if(n > 0)// error |
ocomeni | 73:6f5021cbe752 | 130 | { |
ocomeni | 103:7b566b522427 | 131 | dbg_printf(LOG, "\n --- Error running wifi demo --- \n"); |
ocomeni | 73:6f5021cbe752 | 132 | } |
ocomeni | 74:f26e846adfe9 | 133 | } |
ocomeni | 73:6f5021cbe752 | 134 | |
ocomeni | 73:6f5021cbe752 | 135 | |
ocomeni | 113:888e262ff0a9 | 136 | void printWaitAbortKeyPress(int numSecs, const char * printStr=NULL) |
ocomeni | 79:a2187bbfa407 | 137 | { |
ocomeni | 113:888e262ff0a9 | 138 | dbg_printf(LOG, "%s", printStr); |
ocomeni | 103:7b566b522427 | 139 | dbg_printf(LOG, "Waiting for %d seconds... [press key to abort]\n", numSecs); |
ocomeni | 79:a2187bbfa407 | 140 | char fmtstr[20]; |
ocomeni | 79:a2187bbfa407 | 141 | for(int i=0;i<numSecs;i++){ |
ocomeni | 103:7b566b522427 | 142 | dbg_printf(LOG, "%d", i); |
ocomeni | 103:7b566b522427 | 143 | dbg_printf(LOG, "\n"); |
ocomeni | 79:a2187bbfa407 | 144 | sprintf(fmtstr, "BLE: loop # %d\n", i); |
ocomeni | 79:a2187bbfa407 | 145 | peripheral->sendBLEUartData(fmtstr); |
ocomeni | 79:a2187bbfa407 | 146 | wait(0.5); |
ocomeni | 113:888e262ff0a9 | 147 | //eventQueue_atcmd.dispatch(500); // Dispatch time - 500msec |
ocomeni | 79:a2187bbfa407 | 148 | if(device->readable()){ |
ocomeni | 103:7b566b522427 | 149 | dbg_printf(LOG, "keypress detected aborting....\n"); |
ocomeni | 79:a2187bbfa407 | 150 | device->getc(); |
ocomeni | 79:a2187bbfa407 | 151 | break; |
ocomeni | 79:a2187bbfa407 | 152 | } |
ocomeni | 79:a2187bbfa407 | 153 | } |
ocomeni | 79:a2187bbfa407 | 154 | } |
ocomeni | 79:a2187bbfa407 | 155 | |
ocomeni | 79:a2187bbfa407 | 156 | |
ocomeni | 78:07bb86e3ce14 | 157 | |
ocomeni | 78:07bb86e3ce14 | 158 | void setupDefaultBleConfig() |
ocomeni | 78:07bb86e3ce14 | 159 | { |
ocomeni | 78:07bb86e3ce14 | 160 | strcpy(ble_config.deviceName, DEVICE_NAME_MAIN);// set BLE device name |
ocomeni | 78:07bb86e3ce14 | 161 | ble_config.advInterval = 1000; // set advertising interval to 1 second default |
ocomeni | 78:07bb86e3ce14 | 162 | ble_config.advTimeout = 0; // set advertising timeout to disabled by default |
ocomeni | 79:a2187bbfa407 | 163 | // This works in C and C++ |
ocomeni | 79:a2187bbfa407 | 164 | memcpy(ble_config.pairingKey, pairingPassword, 6); // |
ocomeni | 79:a2187bbfa407 | 165 | |
ocomeni | 79:a2187bbfa407 | 166 | //ble_config.pairingKey = pairingPassword; |
ocomeni | 78:07bb86e3ce14 | 167 | } |
ocomeni | 78:07bb86e3ce14 | 168 | |
ocomeni | 78:07bb86e3ce14 | 169 | void setupDefaultWiFiConfig() |
ocomeni | 78:07bb86e3ce14 | 170 | { |
ocomeni | 78:07bb86e3ce14 | 171 | strcpy(wifi_config.ssid, MBED_CONF_APP_WIFI_SSID); |
ocomeni | 78:07bb86e3ce14 | 172 | strcpy(wifi_config.pass, MBED_CONF_APP_WIFI_PASSWORD); |
ocomeni | 78:07bb86e3ce14 | 173 | wifi_config.security = NSAPI_SECURITY_WPA_WPA2; |
ocomeni | 78:07bb86e3ce14 | 174 | } |
ocomeni | 78:07bb86e3ce14 | 175 | |
ocomeni | 74:f26e846adfe9 | 176 | static int reset_counter = 0; |
ocomeni | 73:6f5021cbe752 | 177 | |
ocomeni | 75:08eff6258e1b | 178 | |
ocomeni | 75:08eff6258e1b | 179 | |
ocomeni | 105:e5ce023eee93 | 180 | //#define ENABLE_MEMORY_CHECKS |
ocomeni | 75:08eff6258e1b | 181 | |
ocomeni | 77:0b505d1e15f4 | 182 | void print_memory_info() { |
ocomeni | 103:7b566b522427 | 183 | #ifdef ENABLE_MEMORY_CHECKS |
ocomeni | 77:0b505d1e15f4 | 184 | // allocate enough room for every thread's stack statistics |
ocomeni | 77:0b505d1e15f4 | 185 | int cnt = osThreadGetCount(); |
ocomeni | 77:0b505d1e15f4 | 186 | mbed_stats_stack_t *stats = (mbed_stats_stack_t*) malloc(cnt * sizeof(mbed_stats_stack_t)); |
ocomeni | 77:0b505d1e15f4 | 187 | |
ocomeni | 77:0b505d1e15f4 | 188 | cnt = mbed_stats_stack_get_each(stats, cnt); |
ocomeni | 77:0b505d1e15f4 | 189 | for (int i = 0; i < cnt; i++) { |
ocomeni | 103:7b566b522427 | 190 | dbg_printf(LOG, "Thread: 0x%lX, Stack size: %lu / %lu\r\n", stats[i].thread_id, stats[i].max_size, stats[i].reserved_size); |
ocomeni | 77:0b505d1e15f4 | 191 | } |
ocomeni | 77:0b505d1e15f4 | 192 | free(stats); |
ocomeni | 77:0b505d1e15f4 | 193 | |
ocomeni | 77:0b505d1e15f4 | 194 | // Grab the heap statistics |
ocomeni | 77:0b505d1e15f4 | 195 | mbed_stats_heap_t heap_stats; |
ocomeni | 77:0b505d1e15f4 | 196 | mbed_stats_heap_get(&heap_stats); |
ocomeni | 103:7b566b522427 | 197 | dbg_printf(LOG, "Heap size: %lu / %lu bytes\r\n", heap_stats.current_size, heap_stats.reserved_size); |
ocomeni | 103:7b566b522427 | 198 | #endif |
ocomeni | 77:0b505d1e15f4 | 199 | } |
ocomeni | 77:0b505d1e15f4 | 200 | |
ocomeni | 108:3c8fb2c6e7bf | 201 | void blinkLEDs() |
ocomeni | 108:3c8fb2c6e7bf | 202 | { |
ocomeni | 108:3c8fb2c6e7bf | 203 | static int cnt =0; |
ocomeni | 108:3c8fb2c6e7bf | 204 | cnt++; |
ocomeni | 108:3c8fb2c6e7bf | 205 | if(cnt == 3){ |
ocomeni | 108:3c8fb2c6e7bf | 206 | cnt = 0; |
ocomeni | 108:3c8fb2c6e7bf | 207 | } |
ocomeni | 108:3c8fb2c6e7bf | 208 | if(cnt==0) |
ocomeni | 108:3c8fb2c6e7bf | 209 | led1 = !led1; |
ocomeni | 108:3c8fb2c6e7bf | 210 | //wait(1.0); |
ocomeni | 108:3c8fb2c6e7bf | 211 | if(cnt==1) |
ocomeni | 108:3c8fb2c6e7bf | 212 | led2 = !led2; |
ocomeni | 108:3c8fb2c6e7bf | 213 | //wait(1.0); |
ocomeni | 108:3c8fb2c6e7bf | 214 | if(cnt==2) |
ocomeni | 108:3c8fb2c6e7bf | 215 | led3 = !led3; |
ocomeni | 108:3c8fb2c6e7bf | 216 | } |
ocomeni | 108:3c8fb2c6e7bf | 217 | |
ocomeni | 86:04fc2fcda7ec | 218 | #define PAUSE_SECONDS 0 |
ocomeni | 103:7b566b522427 | 219 | #define PAUSE_SECONDS_BLE 0 |
ocomeni | 73:6f5021cbe752 | 220 | int main() { |
ocomeni | 106:e1f04c3d0647 | 221 | device = new RawSerial(USBTX, USBRX, 2*DEFAULT_BAUD_RATE); |
ocomeni | 113:888e262ff0a9 | 222 | uint8_t debug_level = (LOG | ERR | TXT | DBG); |
ocomeni | 113:888e262ff0a9 | 223 | initialise_debug(debug_level); |
ocomeni | 99:05398b3184f8 | 224 | #ifdef MBED_MAJOR_VERSION |
ocomeni | 103:7b566b522427 | 225 | dbg_printf(LOG, "Mbed OS version %d.%d.%d\n\n", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION); |
ocomeni | 99:05398b3184f8 | 226 | #endif |
ocomeni | 99:05398b3184f8 | 227 | |
ocomeni | 74:f26e846adfe9 | 228 | reset_counter++; |
ocomeni | 103:7b566b522427 | 229 | dbg_printf(LOG, "\r\n ++++++ PROGRAM STARTING -- reset count = %d ++++++ \r\n", reset_counter); |
ocomeni | 79:a2187bbfa407 | 230 | setupDefaultWiFiConfig(); |
ocomeni | 78:07bb86e3ce14 | 231 | setupDefaultBleConfig(); |
ocomeni | 78:07bb86e3ce14 | 232 | BLE& _ble = BLE::Instance(); |
ocomeni | 77:0b505d1e15f4 | 233 | #if MBED_CONF_APP_FILESYSTEM_SUPPORT |
ocomeni | 77:0b505d1e15f4 | 234 | /* if filesystem creation fails or there is no filesystem the security manager |
ocomeni | 77:0b505d1e15f4 | 235 | * will fallback to storing the security database in memory */ |
ocomeni | 77:0b505d1e15f4 | 236 | if (!create_filesystem()) { |
ocomeni | 103:7b566b522427 | 237 | dbg_printf(LOG, "Filesystem creation failed, will use memory storage\r\n"); |
ocomeni | 75:08eff6258e1b | 238 | } |
ocomeni | 76:6afda865fbf8 | 239 | #endif |
ocomeni | 103:7b566b522427 | 240 | dbg_printf(LOG, "\r\n PERIPHERAL \r\n\r\n"); |
ocomeni | 113:888e262ff0a9 | 241 | peripheral = new SMDevicePeripheral(_ble, eventQueue_ble, peer_address, ble_config); |
ocomeni | 77:0b505d1e15f4 | 242 | |
ocomeni | 77:0b505d1e15f4 | 243 | peripheral->run(); |
ocomeni | 113:888e262ff0a9 | 244 | btle_thread.start(callback(&eventQueue_ble, &EventQueue::dispatch_forever)); |
ocomeni | 113:888e262ff0a9 | 245 | //btle_thread.start(callback(peripheral, &SMDevicePeripheral::run)); |
ocomeni | 113:888e262ff0a9 | 246 | printWaitAbortKeyPress(120, "Wait after BLE dispatch\r\n"); |
ocomeni | 77:0b505d1e15f4 | 247 | int start = Kernel::get_ms_count(); |
ocomeni | 79:a2187bbfa407 | 248 | network = WiFiInterface::get_default_instance(); |
ocomeni | 79:a2187bbfa407 | 249 | if (!network) { |
ocomeni | 103:7b566b522427 | 250 | dbg_printf(LOG, "ERROR: No WiFiInterface found.\n"); |
ocomeni | 79:a2187bbfa407 | 251 | } |
ocomeni | 113:888e262ff0a9 | 252 | printWaitAbortKeyPress(120, "Wait after WiFi instantiation\r\n"); |
ocomeni | 80:e8f0e92e3ac9 | 253 | wiFiManager = new WiFiManager(wifi_config, network, |
ocomeni | 109:c274780ff609 | 254 | eventQueue_wifi, |
ocomeni | 80:e8f0e92e3ac9 | 255 | &aT2WiFimPool, &aT2WiFiCmdQueue, |
ocomeni | 80:e8f0e92e3ac9 | 256 | &wiFi2ATmPool, &wiFi2ATCmdQueue, |
ocomeni | 80:e8f0e92e3ac9 | 257 | &aT2WiFiDatamPool, &aT2WiFiDataQueue, |
ocomeni | 80:e8f0e92e3ac9 | 258 | &wiFi2ATDatamPool, &wiFi2ATDataQueue |
ocomeni | 80:e8f0e92e3ac9 | 259 | ); |
ocomeni | 103:7b566b522427 | 260 | dbg_printf(LOG, "\r\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \r\n"); |
ocomeni | 103:7b566b522427 | 261 | dbg_printf(LOG, "\r\n++++++ Test WiFi Manager Network scan from thread ++++++ \r\n"); |
ocomeni | 103:7b566b522427 | 262 | dbg_printf(LOG, "\r\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \r\n"); |
ocomeni | 81:637a87eb8170 | 263 | wifi_thread.start(callback(wiFiManager, &WiFiManager::runMain)); |
ocomeni | 103:7b566b522427 | 264 | dbg_printf(LOG, "\r\n after starting wifi thread \r\n"); |
ocomeni | 113:888e262ff0a9 | 265 | printWaitAbortKeyPress(120, "Wait after WiFi Manager dispatch\r\n"); |
ocomeni | 113:888e262ff0a9 | 266 | initialise_debug(NONE); |
ocomeni | 112:a0999ea4ece0 | 267 | // dispatch wifi event queue on event thread |
ocomeni | 109:c274780ff609 | 268 | wifi_evt_thread.start(callback(&eventQueue_wifi, &EventQueue::dispatch_forever)); |
ocomeni | 112:a0999ea4ece0 | 269 | // dispatch atcmd event queue on event thread |
ocomeni | 109:c274780ff609 | 270 | atcmd_evt_thread.start(callback(&eventQueue_atcmd, &EventQueue::dispatch_forever)); |
ocomeni | 103:7b566b522427 | 271 | dbg_printf(LOG, "\r\n++++++ Starting ATCmdmanager ++++++ \r\n"); |
ocomeni | 79:a2187bbfa407 | 272 | ATCmdManager *aTCmdManager = new ATCmdManager(USBTX, USBRX, peripheral, |
ocomeni | 109:c274780ff609 | 273 | eventQueue_atcmd, wiFiManager, |
ocomeni | 80:e8f0e92e3ac9 | 274 | &aT2WiFimPool, &aT2WiFiCmdQueue, |
ocomeni | 80:e8f0e92e3ac9 | 275 | &wiFi2ATmPool, &wiFi2ATCmdQueue, |
ocomeni | 80:e8f0e92e3ac9 | 276 | &aT2WiFiDatamPool, &aT2WiFiDataQueue, |
ocomeni | 80:e8f0e92e3ac9 | 277 | &wiFi2ATDatamPool, &wiFi2ATDataQueue, |
ocomeni | 82:10072c1794d3 | 278 | false); |
ocomeni | 81:637a87eb8170 | 279 | atcmd_thread.start(callback(aTCmdManager, &ATCmdManager::runMain)); |
ocomeni | 103:7b566b522427 | 280 | dbg_printf(LOG, "\r\n after starting atcmd thread \r\n"); |
ocomeni | 88:7ffa053be662 | 281 | print_memory_info(); |
ocomeni | 108:3c8fb2c6e7bf | 282 | while(1) |
ocomeni | 108:3c8fb2c6e7bf | 283 | { |
ocomeni | 108:3c8fb2c6e7bf | 284 | wait(0.1); |
ocomeni | 108:3c8fb2c6e7bf | 285 | } |
ocomeni | 73:6f5021cbe752 | 286 | } |
ocomeni | 73:6f5021cbe752 | 287 | |
ocomeni | 73:6f5021cbe752 | 288 | #endif |