
this is using the mbed os version 5-13-1
source/main-https.cpp@129:590bdc2dcf5b, 2019-07-19 (annotated)
- Committer:
- ocomeni
- Date:
- Fri Jul 19 16:49:26 2019 +0000
- Branch:
- PassingRegression
- Revision:
- 129:590bdc2dcf5b
- Parent:
- 126:9bc33f8b57d5
Implementation of Access token acquisition; 1. make request with credentials - DONE; 2. get response - DONE; 3. extract Id and refresh tokens from response - DONE; 4. integrate with code - DONE; Testing ongoing
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 | 117:8fd05113efc1 | 10 | #include "nvstore.h" |
ocomeni | 73:6f5021cbe752 | 11 | #include "ble/BLE.h" |
ocomeni | 88:7ffa053be662 | 12 | #include "fault_handlers.h" |
ocomeni | 73:6f5021cbe752 | 13 | #include "ATCmdParser.h" |
ocomeni | 103:7b566b522427 | 14 | |
ocomeni | 73:6f5021cbe752 | 15 | |
ocomeni | 73:6f5021cbe752 | 16 | #include "LEDService.h" |
ocomeni | 73:6f5021cbe752 | 17 | #include "ble/services/UARTService.h" |
ocomeni | 74:f26e846adfe9 | 18 | #include "common_config.h" |
ocomeni | 79:a2187bbfa407 | 19 | #include "common_types.h" |
ocomeni | 74:f26e846adfe9 | 20 | #include "ATCmdManager.h" |
ocomeni | 75:08eff6258e1b | 21 | #include "BleManager.h" |
ocomeni | 78:07bb86e3ce14 | 22 | #include "WiFiManager.h" |
ocomeni | 92:ec9550034276 | 23 | #include "mbed_memory_status.h" |
ocomeni | 73:6f5021cbe752 | 24 | UARTService *uart; |
ocomeni | 73:6f5021cbe752 | 25 | |
ocomeni | 108:3c8fb2c6e7bf | 26 | DigitalOut led1(LED1); |
ocomeni | 108:3c8fb2c6e7bf | 27 | DigitalOut led2(LED2); |
ocomeni | 108:3c8fb2c6e7bf | 28 | DigitalOut led3(LED3); |
ocomeni | 73:6f5021cbe752 | 29 | |
ocomeni | 103:7b566b522427 | 30 | #define FILE_CODE "main" |
ocomeni | 117:8fd05113efc1 | 31 | |
ocomeni | 117:8fd05113efc1 | 32 | // NVStore is a sigleton, get its instance |
ocomeni | 117:8fd05113efc1 | 33 | NVStore &nvstore = NVStore::get_instance(); |
ocomeni | 117:8fd05113efc1 | 34 | |
ocomeni | 114:b11bb96c09f3 | 35 | main_states_t mainLoop; |
ocomeni | 74:f26e846adfe9 | 36 | static RawSerial *device; // tx, rx |
ocomeni | 78:07bb86e3ce14 | 37 | |
ocomeni | 116:2296cf274661 | 38 | static app_config_t app_config; |
ocomeni | 78:07bb86e3ce14 | 39 | // wifi configuration |
ocomeni | 116:2296cf274661 | 40 | //static wifi_config_t wifi_config; |
ocomeni | 78:07bb86e3ce14 | 41 | // wifi interface pointer |
ocomeni | 78:07bb86e3ce14 | 42 | static WiFiInterface *network; |
ocomeni | 78:07bb86e3ce14 | 43 | // wifi manager pointer |
ocomeni | 78:07bb86e3ce14 | 44 | static WiFiManager *wiFiManager; |
ocomeni | 78:07bb86e3ce14 | 45 | |
ocomeni | 114:b11bb96c09f3 | 46 | // BLE instance |
ocomeni | 114:b11bb96c09f3 | 47 | //BLE& _ble; |
ocomeni | 114:b11bb96c09f3 | 48 | BLE& _ble = BLE::Instance(); |
ocomeni | 114:b11bb96c09f3 | 49 | |
ocomeni | 78:07bb86e3ce14 | 50 | // BLE configuration |
ocomeni | 116:2296cf274661 | 51 | //static ble_config_t ble_config; |
ocomeni | 116:2296cf274661 | 52 | |
ocomeni | 116:2296cf274661 | 53 | // internet/cloud configuration |
ocomeni | 116:2296cf274661 | 54 | //internet_config_t internet_config; |
ocomeni | 116:2296cf274661 | 55 | |
ocomeni | 79:a2187bbfa407 | 56 | const uint8_t pairingPassword[6] = "1101"; |
ocomeni | 78:07bb86e3ce14 | 57 | // BLE peripheral pointer |
ocomeni | 77:0b505d1e15f4 | 58 | static SMDevicePeripheral *peripheral; |
ocomeni | 78:07bb86e3ce14 | 59 | |
ocomeni | 78:07bb86e3ce14 | 60 | const static char DEVICE_NAME_MAIN[] = "UBLOX-BLE"; |
ocomeni | 119:8d939a902333 | 61 | //char buffer[BUFFER_LEN]; |
ocomeni | 109:c274780ff609 | 62 | static EventQueue eventQueue_atcmd(/* event count */ 32 * EVENTS_EVENT_SIZE); |
ocomeni | 119:8d939a902333 | 63 | static EventQueue eventQueue_wifi(/* event count */ 64 * EVENTS_EVENT_SIZE); |
ocomeni | 119:8d939a902333 | 64 | static EventQueue eventQueue_ble(/* event count */ 32 * EVENTS_EVENT_SIZE); |
ocomeni | 73:6f5021cbe752 | 65 | |
ocomeni | 80:e8f0e92e3ac9 | 66 | /* Queue and memory pool for AT to Wifi commands */ |
ocomeni | 92:ec9550034276 | 67 | static MemoryPool<wifi_cmd_message_t, 16> aT2WiFimPool; |
ocomeni | 92:ec9550034276 | 68 | static Queue<wifi_cmd_message_t, 16> aT2WiFiCmdQueue; |
ocomeni | 79:a2187bbfa407 | 69 | |
ocomeni | 80:e8f0e92e3ac9 | 70 | /* Queue and memory pool for WiFi to AT commands */ |
ocomeni | 92:ec9550034276 | 71 | static MemoryPool<at_resp_message_t, 16> wiFi2ATmPool; |
ocomeni | 92:ec9550034276 | 72 | static Queue<at_resp_message_t, 16> wiFi2ATCmdQueue; |
ocomeni | 80:e8f0e92e3ac9 | 73 | |
ocomeni | 80:e8f0e92e3ac9 | 74 | /* Queue and memory pool for AT to WiFi data */ |
ocomeni | 92:ec9550034276 | 75 | static MemoryPool<wifi_data_msg_t, PQDSZ> aT2WiFiDatamPool; |
ocomeni | 92:ec9550034276 | 76 | static Queue<wifi_data_msg_t, PQDSZ> aT2WiFiDataQueue; |
ocomeni | 80:e8f0e92e3ac9 | 77 | |
ocomeni | 80:e8f0e92e3ac9 | 78 | |
ocomeni | 80:e8f0e92e3ac9 | 79 | /* Queue and memory pool for WiFi to AT data */ |
ocomeni | 92:ec9550034276 | 80 | static MemoryPool<at_data_msg_t, PQDSZ> wiFi2ATDatamPool; |
ocomeni | 92:ec9550034276 | 81 | static Queue<at_data_msg_t, PQDSZ> wiFi2ATDataQueue; |
ocomeni | 80:e8f0e92e3ac9 | 82 | |
ocomeni | 80:e8f0e92e3ac9 | 83 | |
ocomeni | 118:8df0e9c2ee3f | 84 | /* Queue and memory pool for AT to BLE data */ |
ocomeni | 118:8df0e9c2ee3f | 85 | static MemoryPool<at_ble_msg_t, PQDSZ_BLE> aT2BleDatamPool; |
ocomeni | 118:8df0e9c2ee3f | 86 | static Queue<at_ble_msg_t, PQDSZ_BLE> aT2BleDataQueue; |
ocomeni | 118:8df0e9c2ee3f | 87 | |
ocomeni | 118:8df0e9c2ee3f | 88 | |
ocomeni | 118:8df0e9c2ee3f | 89 | /* Queue and memory pool for BLE to AT data */ |
ocomeni | 118:8df0e9c2ee3f | 90 | static MemoryPool<ble_at_msg_t, PQDSZ_BLE> ble2ATDatamPool; |
ocomeni | 118:8df0e9c2ee3f | 91 | static Queue<ble_at_msg_t, PQDSZ_BLE> ble2ATDataQueue; |
ocomeni | 118:8df0e9c2ee3f | 92 | |
ocomeni | 118:8df0e9c2ee3f | 93 | |
ocomeni | 80:e8f0e92e3ac9 | 94 | |
ocomeni | 74:f26e846adfe9 | 95 | |
ocomeni | 74:f26e846adfe9 | 96 | /* creates three tread objects with different priorities */ |
ocomeni | 74:f26e846adfe9 | 97 | //Thread real_time_thread(osPriorityRealtime, 1024, &rt_stk[0]); |
ocomeni | 74:f26e846adfe9 | 98 | //Thread high_prio_thread(osPriorityHigh, 1024, &hp_stk[0]); |
ocomeni | 74:f26e846adfe9 | 99 | //Thread low_prio_thread(osPriorityNormal, 1024, &lp_stk[0]); |
ocomeni | 84:7c7add00f4bf | 100 | |
ocomeni | 84:7c7add00f4bf | 101 | #ifdef USE_MAIN_THREAD_STACK |
ocomeni | 84:7c7add00f4bf | 102 | // using main thread stack |
ocomeni | 84:7c7add00f4bf | 103 | unsigned char btle_stk[1024]; |
ocomeni | 84:7c7add00f4bf | 104 | unsigned char wifi_stk[8*1024]; |
ocomeni | 84:7c7add00f4bf | 105 | unsigned char atcmd_stk[4*1024]; |
ocomeni | 74:f26e846adfe9 | 106 | Thread btle_thread(BTLE_THREAD_PRIORITY, 1024, &btle_stk[0]); |
ocomeni | 84:7c7add00f4bf | 107 | Thread wifi_thread(WIFI_THREAD_PRIORITY, 8*1024, &wifi_stk[0]); |
ocomeni | 81:637a87eb8170 | 108 | Thread atcmd_thread(ATCMD_THREAD_PRIORITY, 4*1024, &atcmd_stk[0]); |
ocomeni | 84:7c7add00f4bf | 109 | #else |
ocomeni | 84:7c7add00f4bf | 110 | // using global heap |
ocomeni | 113:888e262ff0a9 | 111 | Thread btle_thread(BTLE_THREAD_PRIORITY, 4*1024); |
ocomeni | 109:c274780ff609 | 112 | Thread wifi_thread(WIFI_THREAD_PRIORITY, 4*1024); |
ocomeni | 87:99b37d26ff2a | 113 | Thread atcmd_thread(ATCMD_THREAD_PRIORITY, 4*1024); |
ocomeni | 84:7c7add00f4bf | 114 | #endif |
ocomeni | 74:f26e846adfe9 | 115 | |
ocomeni | 74:f26e846adfe9 | 116 | /* create a semaphore to synchronize the threads */ |
ocomeni | 74:f26e846adfe9 | 117 | Semaphore sync_sema; |
ocomeni | 74:f26e846adfe9 | 118 | |
ocomeni | 109:c274780ff609 | 119 | Thread atcmd_evt_thread(osPriorityNormal, 1024); |
ocomeni | 126:9bc33f8b57d5 | 120 | Thread wifi_evt_thread; |
ocomeni | 74:f26e846adfe9 | 121 | #include "network-helper.h" |
ocomeni | 73:6f5021cbe752 | 122 | |
ocomeni | 73:6f5021cbe752 | 123 | /* List of trusted root CA certificates |
ocomeni | 73:6f5021cbe752 | 124 | * currently two: GlobalSign, the CA for os.mbed.com and Let's Encrypt, the CA for httpbin.org |
ocomeni | 73:6f5021cbe752 | 125 | * |
ocomeni | 73:6f5021cbe752 | 126 | * To add more root certificates, just concatenate them. |
ocomeni | 73:6f5021cbe752 | 127 | */ |
ocomeni | 73:6f5021cbe752 | 128 | #include "https_certificates.h" |
ocomeni | 73:6f5021cbe752 | 129 | |
ocomeni | 74:f26e846adfe9 | 130 | // wifi demo |
ocomeni | 74:f26e846adfe9 | 131 | #include "wifi_demo.h" |
ocomeni | 73:6f5021cbe752 | 132 | |
ocomeni | 77:0b505d1e15f4 | 133 | Mutex _smutex; // Protect memory access |
ocomeni | 87:99b37d26ff2a | 134 | |
ocomeni | 118:8df0e9c2ee3f | 135 | bool ble_mgr_started; |
ocomeni | 118:8df0e9c2ee3f | 136 | bool wifi_mgr_started; |
ocomeni | 118:8df0e9c2ee3f | 137 | |
ocomeni | 73:6f5021cbe752 | 138 | uint64_t lastTime = 0; |
ocomeni | 73:6f5021cbe752 | 139 | uint64_t now = 0; |
ocomeni | 73:6f5021cbe752 | 140 | uint32_t callCount = 0; |
ocomeni | 73:6f5021cbe752 | 141 | |
ocomeni | 73:6f5021cbe752 | 142 | |
ocomeni | 73:6f5021cbe752 | 143 | // Wifi-demo |
ocomeni | 73:6f5021cbe752 | 144 | void wifi_demo(NetworkInterface* network){ |
ocomeni | 74:f26e846adfe9 | 145 | int n = wifi_demo_func(network); |
ocomeni | 74:f26e846adfe9 | 146 | if(n > 0)// error |
ocomeni | 73:6f5021cbe752 | 147 | { |
ocomeni | 103:7b566b522427 | 148 | dbg_printf(LOG, "\n --- Error running wifi demo --- \n"); |
ocomeni | 73:6f5021cbe752 | 149 | } |
ocomeni | 74:f26e846adfe9 | 150 | } |
ocomeni | 73:6f5021cbe752 | 151 | |
ocomeni | 74:f26e846adfe9 | 152 | // Wifi-demo2 |
ocomeni | 74:f26e846adfe9 | 153 | void wifi_demo2(){ |
ocomeni | 74:f26e846adfe9 | 154 | //int n = wifi_demo_func(network); |
ocomeni | 74:f26e846adfe9 | 155 | int n =5; |
ocomeni | 74:f26e846adfe9 | 156 | if(n > 0)// error |
ocomeni | 73:6f5021cbe752 | 157 | { |
ocomeni | 103:7b566b522427 | 158 | dbg_printf(LOG, "\n --- Error running wifi demo --- \n"); |
ocomeni | 73:6f5021cbe752 | 159 | } |
ocomeni | 74:f26e846adfe9 | 160 | } |
ocomeni | 73:6f5021cbe752 | 161 | |
ocomeni | 73:6f5021cbe752 | 162 | |
ocomeni | 113:888e262ff0a9 | 163 | void printWaitAbortKeyPress(int numSecs, const char * printStr=NULL) |
ocomeni | 79:a2187bbfa407 | 164 | { |
ocomeni | 118:8df0e9c2ee3f | 165 | #ifndef DEBUG_ENABLED |
ocomeni | 118:8df0e9c2ee3f | 166 | return; |
ocomeni | 115:8054dbadfaa0 | 167 | #endif |
ocomeni | 113:888e262ff0a9 | 168 | dbg_printf(LOG, "%s", printStr); |
ocomeni | 103:7b566b522427 | 169 | dbg_printf(LOG, "Waiting for %d seconds... [press key to abort]\n", numSecs); |
ocomeni | 79:a2187bbfa407 | 170 | char fmtstr[20]; |
ocomeni | 120:779b74689747 | 171 | int len; |
ocomeni | 79:a2187bbfa407 | 172 | for(int i=0;i<numSecs;i++){ |
ocomeni | 103:7b566b522427 | 173 | dbg_printf(LOG, "%d", i); |
ocomeni | 103:7b566b522427 | 174 | dbg_printf(LOG, "\n"); |
ocomeni | 79:a2187bbfa407 | 175 | sprintf(fmtstr, "BLE: loop # %d\n", i); |
ocomeni | 120:779b74689747 | 176 | len = strlen(fmtstr)+1; |
ocomeni | 120:779b74689747 | 177 | peripheral->sendBLEUartData((const uint8_t *)fmtstr, len); |
ocomeni | 79:a2187bbfa407 | 178 | wait(0.5); |
ocomeni | 113:888e262ff0a9 | 179 | //eventQueue_atcmd.dispatch(500); // Dispatch time - 500msec |
ocomeni | 79:a2187bbfa407 | 180 | if(device->readable()){ |
ocomeni | 103:7b566b522427 | 181 | dbg_printf(LOG, "keypress detected aborting....\n"); |
ocomeni | 79:a2187bbfa407 | 182 | device->getc(); |
ocomeni | 79:a2187bbfa407 | 183 | break; |
ocomeni | 79:a2187bbfa407 | 184 | } |
ocomeni | 79:a2187bbfa407 | 185 | } |
ocomeni | 79:a2187bbfa407 | 186 | } |
ocomeni | 79:a2187bbfa407 | 187 | |
ocomeni | 79:a2187bbfa407 | 188 | |
ocomeni | 78:07bb86e3ce14 | 189 | |
ocomeni | 78:07bb86e3ce14 | 190 | void setupDefaultBleConfig() |
ocomeni | 78:07bb86e3ce14 | 191 | { |
ocomeni | 116:2296cf274661 | 192 | strcpy(app_config.ble_config.deviceName, DEVICE_NAME_MAIN);// set BLE device name |
ocomeni | 116:2296cf274661 | 193 | app_config.ble_config.advInterval = 1000; // set advertising interval to 1 second default |
ocomeni | 116:2296cf274661 | 194 | app_config.ble_config.advTimeout = 0; // set advertising timeout to disabled by default |
ocomeni | 79:a2187bbfa407 | 195 | // This works in C and C++ |
ocomeni | 116:2296cf274661 | 196 | memcpy(app_config.ble_config.pairingKey, pairingPassword, 6); // |
ocomeni | 79:a2187bbfa407 | 197 | |
ocomeni | 79:a2187bbfa407 | 198 | //ble_config.pairingKey = pairingPassword; |
ocomeni | 78:07bb86e3ce14 | 199 | } |
ocomeni | 78:07bb86e3ce14 | 200 | |
ocomeni | 78:07bb86e3ce14 | 201 | void setupDefaultWiFiConfig() |
ocomeni | 78:07bb86e3ce14 | 202 | { |
ocomeni | 116:2296cf274661 | 203 | strcpy(app_config.wifi_config.ssid, MBED_CONF_APP_WIFI_SSID); |
ocomeni | 116:2296cf274661 | 204 | strcpy(app_config.wifi_config.pass, MBED_CONF_APP_WIFI_PASSWORD); |
ocomeni | 116:2296cf274661 | 205 | app_config.wifi_config.security = NSAPI_SECURITY_WPA_WPA2; |
ocomeni | 116:2296cf274661 | 206 | } |
ocomeni | 116:2296cf274661 | 207 | |
ocomeni | 117:8fd05113efc1 | 208 | // Entry point for the example |
ocomeni | 117:8fd05113efc1 | 209 | void print_app_config() |
ocomeni | 117:8fd05113efc1 | 210 | { |
ocomeni | 117:8fd05113efc1 | 211 | //dbg_printf(LOG, "Return code is %d ", rc); |
ocomeni | 117:8fd05113efc1 | 212 | } |
ocomeni | 117:8fd05113efc1 | 213 | |
ocomeni | 117:8fd05113efc1 | 214 | // Entry point for the example |
ocomeni | 117:8fd05113efc1 | 215 | void print_return_code(int rc, int expected_rc) |
ocomeni | 117:8fd05113efc1 | 216 | { |
ocomeni | 117:8fd05113efc1 | 217 | dbg_printf(LOG, "Return code is %d ", rc); |
ocomeni | 117:8fd05113efc1 | 218 | if (rc == expected_rc) |
ocomeni | 117:8fd05113efc1 | 219 | dbg_printf(LOG, "(as expected).\n"); |
ocomeni | 117:8fd05113efc1 | 220 | else |
ocomeni | 117:8fd05113efc1 | 221 | dbg_printf(LOG, "(expected %d!).\n", expected_rc); |
ocomeni | 117:8fd05113efc1 | 222 | } |
ocomeni | 121:ac4f59839e4f | 223 | void setupDefaultStartupConfig() |
ocomeni | 121:ac4f59839e4f | 224 | { |
ocomeni | 121:ac4f59839e4f | 225 | app_config.startup_config.ble_enable = true; |
ocomeni | 121:ac4f59839e4f | 226 | } |
ocomeni | 117:8fd05113efc1 | 227 | |
ocomeni | 116:2296cf274661 | 228 | void setupDefaultCloudConfig() |
ocomeni | 116:2296cf274661 | 229 | { |
ocomeni | 116:2296cf274661 | 230 | strcpy(app_config.internet_config.url, "tcp://https://dev2.dnanudge.io"); |
ocomeni | 116:2296cf274661 | 231 | app_config.internet_config.peer_id = 0; |
ocomeni | 116:2296cf274661 | 232 | app_config.internet_config.remote_port = 443; // default HTTPS port |
ocomeni | 116:2296cf274661 | 233 | app_config.internet_config.connectionScheme = ALWAYS_CONNECTED; |
ocomeni | 78:07bb86e3ce14 | 234 | } |
ocomeni | 78:07bb86e3ce14 | 235 | |
ocomeni | 117:8fd05113efc1 | 236 | void setupDefaultUartConfig() |
ocomeni | 117:8fd05113efc1 | 237 | { |
ocomeni | 117:8fd05113efc1 | 238 | app_config.uart_config.baudrate = 2*DEFAULT_BAUD_RATE; |
ocomeni | 117:8fd05113efc1 | 239 | app_config.uart_config.flow_ctrl = 2; |
ocomeni | 117:8fd05113efc1 | 240 | app_config.uart_config.data_bits = 8; |
ocomeni | 117:8fd05113efc1 | 241 | app_config.uart_config.stop_bits = 1; |
ocomeni | 117:8fd05113efc1 | 242 | app_config.uart_config.parity = 1; |
ocomeni | 117:8fd05113efc1 | 243 | app_config.uart_config.change_after_confirm = 1; |
ocomeni | 117:8fd05113efc1 | 244 | } |
ocomeni | 117:8fd05113efc1 | 245 | |
ocomeni | 117:8fd05113efc1 | 246 | void resetConfiguration() |
ocomeni | 117:8fd05113efc1 | 247 | { |
ocomeni | 117:8fd05113efc1 | 248 | int rc; |
ocomeni | 117:8fd05113efc1 | 249 | // Clear NVStore data. Should only be done once at factory configuration |
ocomeni | 117:8fd05113efc1 | 250 | rc = nvstore.reset(); |
ocomeni | 117:8fd05113efc1 | 251 | dbg_printf(LOG, "Reset NVStore. "); |
ocomeni | 117:8fd05113efc1 | 252 | print_return_code(rc, NVSTORE_SUCCESS); |
ocomeni | 117:8fd05113efc1 | 253 | } |
ocomeni | 117:8fd05113efc1 | 254 | |
ocomeni | 121:ac4f59839e4f | 255 | bool deleteConfiguration(nvstore_key_t configKey) |
ocomeni | 117:8fd05113efc1 | 256 | { |
ocomeni | 117:8fd05113efc1 | 257 | int rc; |
ocomeni | 121:ac4f59839e4f | 258 | // Clear NVStore data. Should only be done once at factory configuration |
ocomeni | 121:ac4f59839e4f | 259 | rc = nvstore.remove(configKey); |
ocomeni | 121:ac4f59839e4f | 260 | dbg_printf(LOG, "Deleted config key %d from NVStore. ", (int)configKey); |
ocomeni | 121:ac4f59839e4f | 261 | print_return_code(rc, NVSTORE_SUCCESS); |
ocomeni | 121:ac4f59839e4f | 262 | return (rc == NVSTORE_SUCCESS); |
ocomeni | 121:ac4f59839e4f | 263 | } |
ocomeni | 121:ac4f59839e4f | 264 | |
ocomeni | 121:ac4f59839e4f | 265 | void saveConfiguration(nvstore_key_t configKey) |
ocomeni | 121:ac4f59839e4f | 266 | { |
ocomeni | 121:ac4f59839e4f | 267 | int rc; |
ocomeni | 121:ac4f59839e4f | 268 | rc = nvstore.set((uint16_t)configKey, sizeof(app_config), &app_config); |
ocomeni | 117:8fd05113efc1 | 269 | print_return_code(rc, NVSTORE_SUCCESS); |
ocomeni | 117:8fd05113efc1 | 270 | } |
ocomeni | 117:8fd05113efc1 | 271 | |
ocomeni | 121:ac4f59839e4f | 272 | bool loadConfiguration(nvstore_key_t configKey) |
ocomeni | 117:8fd05113efc1 | 273 | { |
ocomeni | 117:8fd05113efc1 | 274 | int rc; |
ocomeni | 117:8fd05113efc1 | 275 | // Get the value of this key (should be 3000) |
ocomeni | 117:8fd05113efc1 | 276 | uint16_t actual_len_bytes; |
ocomeni | 121:ac4f59839e4f | 277 | rc = nvstore.get((uint16_t)configKey, sizeof(app_config), &app_config, actual_len_bytes); |
ocomeni | 117:8fd05113efc1 | 278 | print_app_config(); |
ocomeni | 117:8fd05113efc1 | 279 | print_return_code(rc, NVSTORE_SUCCESS); |
ocomeni | 121:ac4f59839e4f | 280 | return (rc == NVSTORE_SUCCESS && (sizeof(app_config) == actual_len_bytes)); |
ocomeni | 117:8fd05113efc1 | 281 | } |
ocomeni | 117:8fd05113efc1 | 282 | |
ocomeni | 74:f26e846adfe9 | 283 | static int reset_counter = 0; |
ocomeni | 73:6f5021cbe752 | 284 | |
ocomeni | 75:08eff6258e1b | 285 | |
ocomeni | 75:08eff6258e1b | 286 | |
ocomeni | 105:e5ce023eee93 | 287 | //#define ENABLE_MEMORY_CHECKS |
ocomeni | 75:08eff6258e1b | 288 | |
ocomeni | 77:0b505d1e15f4 | 289 | void print_memory_info() { |
ocomeni | 103:7b566b522427 | 290 | #ifdef ENABLE_MEMORY_CHECKS |
ocomeni | 77:0b505d1e15f4 | 291 | // allocate enough room for every thread's stack statistics |
ocomeni | 77:0b505d1e15f4 | 292 | int cnt = osThreadGetCount(); |
ocomeni | 77:0b505d1e15f4 | 293 | mbed_stats_stack_t *stats = (mbed_stats_stack_t*) malloc(cnt * sizeof(mbed_stats_stack_t)); |
ocomeni | 77:0b505d1e15f4 | 294 | |
ocomeni | 77:0b505d1e15f4 | 295 | cnt = mbed_stats_stack_get_each(stats, cnt); |
ocomeni | 77:0b505d1e15f4 | 296 | for (int i = 0; i < cnt; i++) { |
ocomeni | 103:7b566b522427 | 297 | 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 | 298 | } |
ocomeni | 77:0b505d1e15f4 | 299 | free(stats); |
ocomeni | 77:0b505d1e15f4 | 300 | |
ocomeni | 77:0b505d1e15f4 | 301 | // Grab the heap statistics |
ocomeni | 77:0b505d1e15f4 | 302 | mbed_stats_heap_t heap_stats; |
ocomeni | 77:0b505d1e15f4 | 303 | mbed_stats_heap_get(&heap_stats); |
ocomeni | 103:7b566b522427 | 304 | dbg_printf(LOG, "Heap size: %lu / %lu bytes\r\n", heap_stats.current_size, heap_stats.reserved_size); |
ocomeni | 103:7b566b522427 | 305 | #endif |
ocomeni | 77:0b505d1e15f4 | 306 | } |
ocomeni | 77:0b505d1e15f4 | 307 | |
ocomeni | 108:3c8fb2c6e7bf | 308 | void blinkLEDs() |
ocomeni | 108:3c8fb2c6e7bf | 309 | { |
ocomeni | 108:3c8fb2c6e7bf | 310 | static int cnt =0; |
ocomeni | 108:3c8fb2c6e7bf | 311 | cnt++; |
ocomeni | 108:3c8fb2c6e7bf | 312 | if(cnt == 3){ |
ocomeni | 108:3c8fb2c6e7bf | 313 | cnt = 0; |
ocomeni | 108:3c8fb2c6e7bf | 314 | } |
ocomeni | 108:3c8fb2c6e7bf | 315 | if(cnt==0) |
ocomeni | 108:3c8fb2c6e7bf | 316 | led1 = !led1; |
ocomeni | 108:3c8fb2c6e7bf | 317 | //wait(1.0); |
ocomeni | 108:3c8fb2c6e7bf | 318 | if(cnt==1) |
ocomeni | 108:3c8fb2c6e7bf | 319 | led2 = !led2; |
ocomeni | 108:3c8fb2c6e7bf | 320 | //wait(1.0); |
ocomeni | 108:3c8fb2c6e7bf | 321 | if(cnt==2) |
ocomeni | 108:3c8fb2c6e7bf | 322 | led3 = !led3; |
ocomeni | 108:3c8fb2c6e7bf | 323 | } |
ocomeni | 108:3c8fb2c6e7bf | 324 | |
ocomeni | 114:b11bb96c09f3 | 325 | void start_BLE() |
ocomeni | 114:b11bb96c09f3 | 326 | { |
ocomeni | 114:b11bb96c09f3 | 327 | //_ble = BLE::Instance(); |
ocomeni | 77:0b505d1e15f4 | 328 | #if MBED_CONF_APP_FILESYSTEM_SUPPORT |
ocomeni | 77:0b505d1e15f4 | 329 | /* if filesystem creation fails or there is no filesystem the security manager |
ocomeni | 77:0b505d1e15f4 | 330 | * will fallback to storing the security database in memory */ |
ocomeni | 77:0b505d1e15f4 | 331 | if (!create_filesystem()) { |
ocomeni | 103:7b566b522427 | 332 | dbg_printf(LOG, "Filesystem creation failed, will use memory storage\r\n"); |
ocomeni | 75:08eff6258e1b | 333 | } |
ocomeni | 76:6afda865fbf8 | 334 | #endif |
ocomeni | 103:7b566b522427 | 335 | dbg_printf(LOG, "\r\n PERIPHERAL \r\n\r\n"); |
ocomeni | 116:2296cf274661 | 336 | peripheral = new SMDevicePeripheral(_ble, eventQueue_ble, peer_address, |
ocomeni | 118:8df0e9c2ee3f | 337 | &aT2BleDatamPool, &aT2BleDataQueue, |
ocomeni | 118:8df0e9c2ee3f | 338 | &ble2ATDatamPool, &ble2ATDataQueue, |
ocomeni | 116:2296cf274661 | 339 | &app_config.ble_config); |
ocomeni | 77:0b505d1e15f4 | 340 | |
ocomeni | 77:0b505d1e15f4 | 341 | peripheral->run(); |
ocomeni | 113:888e262ff0a9 | 342 | btle_thread.start(callback(&eventQueue_ble, &EventQueue::dispatch_forever)); |
ocomeni | 118:8df0e9c2ee3f | 343 | ble_mgr_started = true; |
ocomeni | 118:8df0e9c2ee3f | 344 | wait_ms(10); |
ocomeni | 114:b11bb96c09f3 | 345 | } |
ocomeni | 114:b11bb96c09f3 | 346 | |
ocomeni | 114:b11bb96c09f3 | 347 | void stop_BLE() |
ocomeni | 114:b11bb96c09f3 | 348 | { |
ocomeni | 124:eae4512b131b | 349 | btle_thread.terminate(); |
ocomeni | 114:b11bb96c09f3 | 350 | delete peripheral; |
ocomeni | 118:8df0e9c2ee3f | 351 | ble_mgr_started = false; |
ocomeni | 118:8df0e9c2ee3f | 352 | wait_ms(10); |
ocomeni | 114:b11bb96c09f3 | 353 | } |
ocomeni | 114:b11bb96c09f3 | 354 | |
ocomeni | 114:b11bb96c09f3 | 355 | void start_WiFi() |
ocomeni | 114:b11bb96c09f3 | 356 | { |
ocomeni | 116:2296cf274661 | 357 | wiFiManager = new WiFiManager(&app_config.wifi_config, network, |
ocomeni | 116:2296cf274661 | 358 | &app_config.internet_config, |
ocomeni | 109:c274780ff609 | 359 | eventQueue_wifi, |
ocomeni | 80:e8f0e92e3ac9 | 360 | &aT2WiFimPool, &aT2WiFiCmdQueue, |
ocomeni | 80:e8f0e92e3ac9 | 361 | &wiFi2ATmPool, &wiFi2ATCmdQueue, |
ocomeni | 80:e8f0e92e3ac9 | 362 | &aT2WiFiDatamPool, &aT2WiFiDataQueue, |
ocomeni | 80:e8f0e92e3ac9 | 363 | &wiFi2ATDatamPool, &wiFi2ATDataQueue |
ocomeni | 80:e8f0e92e3ac9 | 364 | ); |
ocomeni | 103:7b566b522427 | 365 | dbg_printf(LOG, "\r\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \r\n"); |
ocomeni | 103:7b566b522427 | 366 | dbg_printf(LOG, "\r\n++++++ Test WiFi Manager Network scan from thread ++++++ \r\n"); |
ocomeni | 103:7b566b522427 | 367 | dbg_printf(LOG, "\r\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \r\n"); |
ocomeni | 81:637a87eb8170 | 368 | wifi_thread.start(callback(wiFiManager, &WiFiManager::runMain)); |
ocomeni | 103:7b566b522427 | 369 | dbg_printf(LOG, "\r\n after starting wifi thread \r\n"); |
ocomeni | 113:888e262ff0a9 | 370 | printWaitAbortKeyPress(120, "Wait after WiFi Manager dispatch\r\n"); |
ocomeni | 112:a0999ea4ece0 | 371 | // dispatch wifi event queue on event thread |
ocomeni | 109:c274780ff609 | 372 | wifi_evt_thread.start(callback(&eventQueue_wifi, &EventQueue::dispatch_forever)); |
ocomeni | 118:8df0e9c2ee3f | 373 | wifi_mgr_started = true; |
ocomeni | 114:b11bb96c09f3 | 374 | } |
ocomeni | 114:b11bb96c09f3 | 375 | |
ocomeni | 114:b11bb96c09f3 | 376 | void stop_WiFi() |
ocomeni | 114:b11bb96c09f3 | 377 | { |
ocomeni | 124:eae4512b131b | 378 | wifi_evt_thread.terminate(); |
ocomeni | 124:eae4512b131b | 379 | wifi_thread.terminate(); |
ocomeni | 124:eae4512b131b | 380 | delete wiFiManager; |
ocomeni | 114:b11bb96c09f3 | 381 | delete network; |
ocomeni | 118:8df0e9c2ee3f | 382 | wifi_mgr_started = false; |
ocomeni | 114:b11bb96c09f3 | 383 | } |
ocomeni | 114:b11bb96c09f3 | 384 | |
ocomeni | 114:b11bb96c09f3 | 385 | |
ocomeni | 114:b11bb96c09f3 | 386 | void trigger_start_BLE() |
ocomeni | 114:b11bb96c09f3 | 387 | { |
ocomeni | 114:b11bb96c09f3 | 388 | mainLoop = START_BLE; |
ocomeni | 114:b11bb96c09f3 | 389 | } |
ocomeni | 114:b11bb96c09f3 | 390 | |
ocomeni | 114:b11bb96c09f3 | 391 | |
ocomeni | 114:b11bb96c09f3 | 392 | void trigger_stop_BLE() |
ocomeni | 114:b11bb96c09f3 | 393 | { |
ocomeni | 114:b11bb96c09f3 | 394 | mainLoop = STOP_BLE; |
ocomeni | 114:b11bb96c09f3 | 395 | } |
ocomeni | 114:b11bb96c09f3 | 396 | |
ocomeni | 114:b11bb96c09f3 | 397 | |
ocomeni | 114:b11bb96c09f3 | 398 | void trigger_start_WiFi() |
ocomeni | 114:b11bb96c09f3 | 399 | { |
ocomeni | 114:b11bb96c09f3 | 400 | mainLoop = START_WIFI; |
ocomeni | 114:b11bb96c09f3 | 401 | } |
ocomeni | 114:b11bb96c09f3 | 402 | |
ocomeni | 114:b11bb96c09f3 | 403 | |
ocomeni | 114:b11bb96c09f3 | 404 | void trigger_stop_WiFi() |
ocomeni | 114:b11bb96c09f3 | 405 | { |
ocomeni | 114:b11bb96c09f3 | 406 | mainLoop = STOP_WIFI; |
ocomeni | 114:b11bb96c09f3 | 407 | } |
ocomeni | 114:b11bb96c09f3 | 408 | |
ocomeni | 117:8fd05113efc1 | 409 | //#define USE_DEFAULT_CONFIGURATION |
ocomeni | 117:8fd05113efc1 | 410 | //#define TEST_NVSTORE |
ocomeni | 118:8df0e9c2ee3f | 411 | //#define STARTUP_DEBUG_ENABLE |
ocomeni | 115:8054dbadfaa0 | 412 | //#define AUTO_START_BLE_MANAGER |
ocomeni | 115:8054dbadfaa0 | 413 | //#define AUTO_START_WIFI_MANAGER |
ocomeni | 114:b11bb96c09f3 | 414 | #define PAUSE_SECONDS 0 |
ocomeni | 114:b11bb96c09f3 | 415 | #define PAUSE_SECONDS_BLE 0 |
ocomeni | 114:b11bb96c09f3 | 416 | int main() { |
ocomeni | 117:8fd05113efc1 | 417 | #ifndef USE_DEFAULT_CONFIGURATION |
ocomeni | 121:ac4f59839e4f | 418 | if(loadConfiguration(APP_CONFIG_0) == false) |
ocomeni | 121:ac4f59839e4f | 419 | { |
ocomeni | 121:ac4f59839e4f | 420 | setupDefaultStartupConfig(); |
ocomeni | 121:ac4f59839e4f | 421 | setupDefaultUartConfig(); |
ocomeni | 121:ac4f59839e4f | 422 | setupDefaultWiFiConfig(); |
ocomeni | 121:ac4f59839e4f | 423 | setupDefaultBleConfig(); |
ocomeni | 121:ac4f59839e4f | 424 | setupDefaultCloudConfig(); |
ocomeni | 121:ac4f59839e4f | 425 | } |
ocomeni | 121:ac4f59839e4f | 426 | if(app_config.startup_config.ble_enable) |
ocomeni | 121:ac4f59839e4f | 427 | { |
ocomeni | 121:ac4f59839e4f | 428 | trigger_start_BLE(); |
ocomeni | 121:ac4f59839e4f | 429 | } |
ocomeni | 117:8fd05113efc1 | 430 | #else |
ocomeni | 117:8fd05113efc1 | 431 | setupDefaultUartConfig(); |
ocomeni | 117:8fd05113efc1 | 432 | setupDefaultWiFiConfig(); |
ocomeni | 117:8fd05113efc1 | 433 | setupDefaultBleConfig(); |
ocomeni | 117:8fd05113efc1 | 434 | setupDefaultCloudConfig(); |
ocomeni | 117:8fd05113efc1 | 435 | #endif |
ocomeni | 117:8fd05113efc1 | 436 | device = new RawSerial(USBTX, USBRX, app_config.uart_config.baudrate); |
ocomeni | 118:8df0e9c2ee3f | 437 | #if defined (STARTUP_DEBUG_ENABLE) || defined (DEBUG_ENABLED) |
ocomeni | 114:b11bb96c09f3 | 438 | uint8_t debug_level = (LOG | ERR | TXT | DBG); |
ocomeni | 114:b11bb96c09f3 | 439 | initialise_debug(debug_level); |
ocomeni | 118:8df0e9c2ee3f | 440 | #else |
ocomeni | 118:8df0e9c2ee3f | 441 | initialise_debug(NONE); |
ocomeni | 118:8df0e9c2ee3f | 442 | #endif |
ocomeni | 114:b11bb96c09f3 | 443 | #ifdef MBED_MAJOR_VERSION |
ocomeni | 114:b11bb96c09f3 | 444 | dbg_printf(LOG, "Mbed OS version %d.%d.%d\n\n", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION); |
ocomeni | 114:b11bb96c09f3 | 445 | #endif |
ocomeni | 117:8fd05113efc1 | 446 | #ifdef TEST_NVSTORE |
ocomeni | 117:8fd05113efc1 | 447 | app_config_t *current_config = new app_config_t; |
ocomeni | 117:8fd05113efc1 | 448 | memcpy(current_config, &app_config, sizeof(app_config_t)); |
ocomeni | 117:8fd05113efc1 | 449 | saveConfiguration(APP_CONFIG_0); |
ocomeni | 117:8fd05113efc1 | 450 | memset(&app_config, 0, sizeof(app_config_t)); |
ocomeni | 117:8fd05113efc1 | 451 | loadConfiguration(APP_CONFIG_0); |
ocomeni | 117:8fd05113efc1 | 452 | int cmp; |
ocomeni | 117:8fd05113efc1 | 453 | cmp = memcmp(current_config, &app_config, sizeof(app_config_t)); |
ocomeni | 117:8fd05113efc1 | 454 | if(cmp == 0) |
ocomeni | 117:8fd05113efc1 | 455 | { |
ocomeni | 117:8fd05113efc1 | 456 | dbg_printf(LOG, " NVSTRORE TEST Passed!!\r\n"); |
ocomeni | 117:8fd05113efc1 | 457 | } |
ocomeni | 117:8fd05113efc1 | 458 | else |
ocomeni | 117:8fd05113efc1 | 459 | { |
ocomeni | 117:8fd05113efc1 | 460 | dbg_printf(LOG, " NVSTRORE TEST Failed!!\r\n", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION); |
ocomeni | 117:8fd05113efc1 | 461 | } |
ocomeni | 117:8fd05113efc1 | 462 | delete current_config; |
ocomeni | 117:8fd05113efc1 | 463 | #endif |
ocomeni | 114:b11bb96c09f3 | 464 | |
ocomeni | 114:b11bb96c09f3 | 465 | reset_counter++; |
ocomeni | 114:b11bb96c09f3 | 466 | dbg_printf(LOG, "\r\n ++++++ PROGRAM STARTING -- reset count = %d ++++++ \r\n", reset_counter); |
ocomeni | 115:8054dbadfaa0 | 467 | #ifdef AUTO_START_BLE_MANAGER |
ocomeni | 114:b11bb96c09f3 | 468 | //btle_thread.start(callback(peripheral, &SMDevicePeripheral::run)); |
ocomeni | 114:b11bb96c09f3 | 469 | start_BLE(); |
ocomeni | 114:b11bb96c09f3 | 470 | printWaitAbortKeyPress(120, "Wait after BLE dispatch\r\n"); |
ocomeni | 115:8054dbadfaa0 | 471 | #endif |
ocomeni | 115:8054dbadfaa0 | 472 | //int start = Kernel::get_ms_count(); |
ocomeni | 115:8054dbadfaa0 | 473 | #ifdef AUTO_START_WIFI_MANAGER |
ocomeni | 114:b11bb96c09f3 | 474 | start_WiFi(); |
ocomeni | 114:b11bb96c09f3 | 475 | printWaitAbortKeyPress(120, "Wait after WiFi instantiation\r\n"); |
ocomeni | 115:8054dbadfaa0 | 476 | #endif |
ocomeni | 112:a0999ea4ece0 | 477 | // dispatch atcmd event queue on event thread |
ocomeni | 109:c274780ff609 | 478 | atcmd_evt_thread.start(callback(&eventQueue_atcmd, &EventQueue::dispatch_forever)); |
ocomeni | 103:7b566b522427 | 479 | dbg_printf(LOG, "\r\n++++++ Starting ATCmdmanager ++++++ \r\n"); |
ocomeni | 117:8fd05113efc1 | 480 | ATCmdManager *aTCmdManager = new ATCmdManager(USBTX, USBRX, &app_config.uart_config, |
ocomeni | 109:c274780ff609 | 481 | eventQueue_atcmd, wiFiManager, |
ocomeni | 80:e8f0e92e3ac9 | 482 | &aT2WiFimPool, &aT2WiFiCmdQueue, |
ocomeni | 80:e8f0e92e3ac9 | 483 | &wiFi2ATmPool, &wiFi2ATCmdQueue, |
ocomeni | 80:e8f0e92e3ac9 | 484 | &aT2WiFiDatamPool, &aT2WiFiDataQueue, |
ocomeni | 80:e8f0e92e3ac9 | 485 | &wiFi2ATDatamPool, &wiFi2ATDataQueue, |
ocomeni | 118:8df0e9c2ee3f | 486 | &aT2BleDatamPool, &aT2BleDataQueue, |
ocomeni | 118:8df0e9c2ee3f | 487 | &ble2ATDatamPool, &ble2ATDataQueue, |
ocomeni | 121:ac4f59839e4f | 488 | &app_config.startup_config, false); |
ocomeni | 81:637a87eb8170 | 489 | atcmd_thread.start(callback(aTCmdManager, &ATCmdManager::runMain)); |
ocomeni | 103:7b566b522427 | 490 | dbg_printf(LOG, "\r\n after starting atcmd thread \r\n"); |
ocomeni | 88:7ffa053be662 | 491 | print_memory_info(); |
ocomeni | 115:8054dbadfaa0 | 492 | #ifdef STARTUP_DEBUG_ENABLE |
ocomeni | 115:8054dbadfaa0 | 493 | initialise_debug(NONE); |
ocomeni | 115:8054dbadfaa0 | 494 | #endif |
ocomeni | 108:3c8fb2c6e7bf | 495 | while(1) |
ocomeni | 108:3c8fb2c6e7bf | 496 | { |
ocomeni | 114:b11bb96c09f3 | 497 | switch(mainLoop) |
ocomeni | 114:b11bb96c09f3 | 498 | { |
ocomeni | 114:b11bb96c09f3 | 499 | case MAIN_IDLE: |
ocomeni | 114:b11bb96c09f3 | 500 | break; |
ocomeni | 114:b11bb96c09f3 | 501 | case START_BLE: |
ocomeni | 114:b11bb96c09f3 | 502 | start_BLE(); |
ocomeni | 114:b11bb96c09f3 | 503 | mainLoop = MAIN_IDLE; |
ocomeni | 114:b11bb96c09f3 | 504 | break; |
ocomeni | 114:b11bb96c09f3 | 505 | case START_WIFI: |
ocomeni | 118:8df0e9c2ee3f | 506 | if(!ble_mgr_started) |
ocomeni | 118:8df0e9c2ee3f | 507 | { |
ocomeni | 118:8df0e9c2ee3f | 508 | start_BLE(); |
ocomeni | 118:8df0e9c2ee3f | 509 | } |
ocomeni | 114:b11bb96c09f3 | 510 | start_WiFi(); |
ocomeni | 114:b11bb96c09f3 | 511 | mainLoop = MAIN_IDLE; |
ocomeni | 114:b11bb96c09f3 | 512 | break; |
ocomeni | 114:b11bb96c09f3 | 513 | case STOP_BLE: |
ocomeni | 114:b11bb96c09f3 | 514 | stop_BLE(); |
ocomeni | 114:b11bb96c09f3 | 515 | mainLoop = MAIN_IDLE; |
ocomeni | 114:b11bb96c09f3 | 516 | break; |
ocomeni | 114:b11bb96c09f3 | 517 | case STOP_WIFI: |
ocomeni | 114:b11bb96c09f3 | 518 | stop_WiFi(); |
ocomeni | 114:b11bb96c09f3 | 519 | mainLoop = MAIN_IDLE; |
ocomeni | 114:b11bb96c09f3 | 520 | break; |
ocomeni | 114:b11bb96c09f3 | 521 | default: |
ocomeni | 114:b11bb96c09f3 | 522 | mainLoop = MAIN_IDLE; |
ocomeni | 114:b11bb96c09f3 | 523 | break; |
ocomeni | 114:b11bb96c09f3 | 524 | } |
ocomeni | 126:9bc33f8b57d5 | 525 | wait(1); |
ocomeni | 108:3c8fb2c6e7bf | 526 | } |
ocomeni | 73:6f5021cbe752 | 527 | } |
ocomeni | 73:6f5021cbe752 | 528 | |
ocomeni | 73:6f5021cbe752 | 529 | #endif |