Okundu Omeni
/
wifi-https-ble-sm-uart-atcmd-5-13-1
this is using the mbed os version 5-13-1
source/ATCmdManager.h@79:a2187bbfa407, 2019-03-20 (annotated)
- Committer:
- ocomeni
- Date:
- Wed Mar 20 21:02:47 2019 +0000
- Revision:
- 79:a2187bbfa407
- Parent:
- 78:07bb86e3ce14
- Child:
- 80:e8f0e92e3ac9
now have working mechanism for comms between threads using memory pool and queue.; Next stage expand this for data.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ocomeni | 74:f26e846adfe9 | 1 | #ifndef __ATCMD_MANAGER_H__ |
ocomeni | 74:f26e846adfe9 | 2 | #define __ATCMD_MANAGER_H__ |
ocomeni | 79:a2187bbfa407 | 3 | #include <events/mbed_events.h> |
ocomeni | 74:f26e846adfe9 | 4 | #include <mbed.h> |
ocomeni | 74:f26e846adfe9 | 5 | #include "ATCmdParser.h" |
ocomeni | 78:07bb86e3ce14 | 6 | #include "BleManager.h" |
ocomeni | 78:07bb86e3ce14 | 7 | #include "WiFiManager.h" |
ocomeni | 74:f26e846adfe9 | 8 | |
ocomeni | 75:08eff6258e1b | 9 | #define MAIN_LOOP_WAIT_TIME_MS 1000 // milliseconds |
ocomeni | 75:08eff6258e1b | 10 | #define NUM_UART_OPTIONS 6 |
ocomeni | 74:f26e846adfe9 | 11 | #ifndef UBLOX_ODIN_W2_MISC_TIMEOUT |
ocomeni | 74:f26e846adfe9 | 12 | #define UBLOX_ODIN_W2_MISC_TIMEOUT 2000 |
ocomeni | 74:f26e846adfe9 | 13 | #endif |
ocomeni | 74:f26e846adfe9 | 14 | |
ocomeni | 74:f26e846adfe9 | 15 | |
ocomeni | 74:f26e846adfe9 | 16 | class ATCmdManager { |
ocomeni | 74:f26e846adfe9 | 17 | public: |
ocomeni | 78:07bb86e3ce14 | 18 | ATCmdManager(PinName tx, PinName rx, SMDevicePeripheral *blePeripheral, |
ocomeni | 79:a2187bbfa407 | 19 | events::EventQueue &event_queue, WiFiManager *wifi, |
ocomeni | 79:a2187bbfa407 | 20 | MemoryPool<wifi_cmd_message_t, 16> *aT2WiFimPool, |
ocomeni | 79:a2187bbfa407 | 21 | Queue<wifi_cmd_message_t, 16> *aT2WiFiCmdQueue, |
ocomeni | 79:a2187bbfa407 | 22 | bool debug = false); |
ocomeni | 74:f26e846adfe9 | 23 | public: |
ocomeni | 74:f26e846adfe9 | 24 | void runMain(); |
ocomeni | 74:f26e846adfe9 | 25 | |
ocomeni | 74:f26e846adfe9 | 26 | |
ocomeni | 74:f26e846adfe9 | 27 | |
ocomeni | 74:f26e846adfe9 | 28 | private: |
ocomeni | 74:f26e846adfe9 | 29 | // UART settings |
ocomeni | 74:f26e846adfe9 | 30 | UARTSerial _serial; |
ocomeni | 74:f26e846adfe9 | 31 | Mutex _smutex; // Protect serial port access |
ocomeni | 74:f26e846adfe9 | 32 | Mutex _rmutex; // Reset protection |
ocomeni | 79:a2187bbfa407 | 33 | // define event queue |
ocomeni | 79:a2187bbfa407 | 34 | events::EventQueue &_event_queue; |
ocomeni | 74:f26e846adfe9 | 35 | // AT Command Parser |
ocomeni | 74:f26e846adfe9 | 36 | ATCmdParser _parser; |
ocomeni | 78:07bb86e3ce14 | 37 | SMDevicePeripheral *blePeripheral; |
ocomeni | 79:a2187bbfa407 | 38 | WiFiManager *wiFiManager; |
ocomeni | 79:a2187bbfa407 | 39 | MemoryPool<wifi_cmd_message_t, 16> *_aT2WiFimPool; |
ocomeni | 79:a2187bbfa407 | 40 | Queue<wifi_cmd_message_t, 16> *_aT2WiFiCmdQueue; |
ocomeni | 74:f26e846adfe9 | 41 | // OOB processing |
ocomeni | 74:f26e846adfe9 | 42 | void _process_oob(uint32_t timeout, bool all); |
ocomeni | 74:f26e846adfe9 | 43 | // OOB message handlers |
ocomeni | 74:f26e846adfe9 | 44 | void _oob_startup_hdlr(); |
ocomeni | 74:f26e846adfe9 | 45 | void _oob_bleRole_hdlr(); |
ocomeni | 74:f26e846adfe9 | 46 | void _oob_wifiMode_err(); |
ocomeni | 74:f26e846adfe9 | 47 | void _oob_conn_already(); |
ocomeni | 74:f26e846adfe9 | 48 | void _oob_err(); |
ocomeni | 75:08eff6258e1b | 49 | void _oob_echo_off(); |
ocomeni | 75:08eff6258e1b | 50 | void _oob_uart_setup(); |
ocomeni | 75:08eff6258e1b | 51 | void _oob_echo_on(); |
ocomeni | 75:08eff6258e1b | 52 | void _oob_data_mode(); |
ocomeni | 75:08eff6258e1b | 53 | void _oob_get_mac_addr(); |
ocomeni | 75:08eff6258e1b | 54 | void _oob_get_ble_role(); |
ocomeni | 75:08eff6258e1b | 55 | void _oob_ena_ble_peri(); |
ocomeni | 75:08eff6258e1b | 56 | void _oob_reboot(); |
ocomeni | 75:08eff6258e1b | 57 | void _oob_get_fw_ver(); |
ocomeni | 79:a2187bbfa407 | 58 | void _oob_scanWiFiNetworks(); |
ocomeni | 79:a2187bbfa407 | 59 | void _oob_connect2WiFiNetwork(); |
ocomeni | 79:a2187bbfa407 | 60 | void _oob_disconnectWiFiNetwork(); |
ocomeni | 79:a2187bbfa407 | 61 | const char * sec2str(nsapi_security_t sec); |
ocomeni | 79:a2187bbfa407 | 62 | bool queueWiFiCommand(wifi_cmd_t cmd); |
ocomeni | 74:f26e846adfe9 | 63 | |
ocomeni | 74:f26e846adfe9 | 64 | /** |
ocomeni | 74:f26e846adfe9 | 65 | * Allows timeout to be changed between commands |
ocomeni | 74:f26e846adfe9 | 66 | * |
ocomeni | 74:f26e846adfe9 | 67 | * @param timeout_ms timeout of the connection |
ocomeni | 74:f26e846adfe9 | 68 | */ |
ocomeni | 74:f26e846adfe9 | 69 | void set_timeout(uint32_t timeout_ms = UBLOX_ODIN_W2_MISC_TIMEOUT); |
ocomeni | 74:f26e846adfe9 | 70 | }; |
ocomeni | 74:f26e846adfe9 | 71 | #endif // __ATCMD_MANAGER_H__ |