Okundu Omeni
/
wifi-https-ble-sm-uart-atcmd-5-13-1
this is using the mbed os version 5-13-1
source/WiFiManager.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 | 78:07bb86e3ce14 | 1 | #ifndef __WIFI_MANAGER_H__ |
ocomeni | 78:07bb86e3ce14 | 2 | #define __WIFI_MANAGER_H__ |
ocomeni | 79:a2187bbfa407 | 3 | #ifndef __MBED_H__ |
ocomeni | 79:a2187bbfa407 | 4 | #define __MBED_H__ |
ocomeni | 79:a2187bbfa407 | 5 | #include "mbed.h" |
ocomeni | 79:a2187bbfa407 | 6 | #endif |
ocomeni | 79:a2187bbfa407 | 7 | |
ocomeni | 79:a2187bbfa407 | 8 | #include "mbed_trace.h" |
ocomeni | 79:a2187bbfa407 | 9 | #include "https_request.h" |
ocomeni | 79:a2187bbfa407 | 10 | #include "http_request.h" |
ocomeni | 79:a2187bbfa407 | 11 | /* List of trusted root CA certificates |
ocomeni | 79:a2187bbfa407 | 12 | * currently two: GlobalSign, the CA for os.mbed.com and Let's Encrypt, the CA for httpbin.org |
ocomeni | 79:a2187bbfa407 | 13 | * |
ocomeni | 79:a2187bbfa407 | 14 | * To add more root certificates, just concatenate them. |
ocomeni | 79:a2187bbfa407 | 15 | */ |
ocomeni | 79:a2187bbfa407 | 16 | #include "https_certificates.h" |
ocomeni | 78:07bb86e3ce14 | 17 | #include "common_types.h" |
ocomeni | 78:07bb86e3ce14 | 18 | |
ocomeni | 79:a2187bbfa407 | 19 | |
ocomeni | 78:07bb86e3ce14 | 20 | class WiFiManager { |
ocomeni | 78:07bb86e3ce14 | 21 | public: |
ocomeni | 79:a2187bbfa407 | 22 | WiFiManager(wifi_config_t wifi_config, WiFiInterface *wifi, |
ocomeni | 79:a2187bbfa407 | 23 | MemoryPool<wifi_cmd_message_t, 16> *aT2WiFimPool, |
ocomeni | 79:a2187bbfa407 | 24 | Queue<wifi_cmd_message_t, 16> *aT2WiFiCmdQueue); |
ocomeni | 78:07bb86e3ce14 | 25 | ~WiFiManager(); |
ocomeni | 79:a2187bbfa407 | 26 | nsapi_size_or_error_t scanNetworks(); |
ocomeni | 79:a2187bbfa407 | 27 | nsapi_size_or_error_t getAvailableAPs(WiFiAccessPoint * res, |
ocomeni | 79:a2187bbfa407 | 28 | nsapi_size_t count); |
ocomeni | 79:a2187bbfa407 | 29 | void set_WIFI_SSID(char * wifi_ssid); |
ocomeni | 79:a2187bbfa407 | 30 | void set_WIFI_PASSWORD(char * wifi_pass); |
ocomeni | 79:a2187bbfa407 | 31 | void set_WIFI_SECURITY(nsapi_security_t wifi_security); |
ocomeni | 79:a2187bbfa407 | 32 | nsapi_error_t connect(); |
ocomeni | 79:a2187bbfa407 | 33 | nsapi_error_t disconnect(); |
ocomeni | 79:a2187bbfa407 | 34 | void createHttpsRequest(http_method method, |
ocomeni | 79:a2187bbfa407 | 35 | const char* url, |
ocomeni | 79:a2187bbfa407 | 36 | Callback<void(const char *at, uint32_t length)> body_callback = 0 |
ocomeni | 79:a2187bbfa407 | 37 | ); |
ocomeni | 79:a2187bbfa407 | 38 | void createHttpRequest(http_method method, |
ocomeni | 79:a2187bbfa407 | 39 | const char* url, |
ocomeni | 79:a2187bbfa407 | 40 | Callback<void(const char *at, uint32_t length)> body_callback = 0 |
ocomeni | 79:a2187bbfa407 | 41 | ); |
ocomeni | 79:a2187bbfa407 | 42 | void setHttpHeader(string key, string value); |
ocomeni | 79:a2187bbfa407 | 43 | void setHttpsHeader(string key, string value); |
ocomeni | 79:a2187bbfa407 | 44 | void sendHttpsRequest(const char * body, int bodyLen); |
ocomeni | 79:a2187bbfa407 | 45 | void sendHttpRequest(const char * body, int bodyLen); |
ocomeni | 79:a2187bbfa407 | 46 | bool setNextCommand(wifi_cmd_t cmd); |
ocomeni | 79:a2187bbfa407 | 47 | bool dequeueWiFiCommands(); |
ocomeni | 79:a2187bbfa407 | 48 | void runMain(); |
ocomeni | 79:a2187bbfa407 | 49 | |
ocomeni | 78:07bb86e3ce14 | 50 | |
ocomeni | 78:07bb86e3ce14 | 51 | |
ocomeni | 78:07bb86e3ce14 | 52 | private: |
ocomeni | 78:07bb86e3ce14 | 53 | wifi_config_t wifi_config; |
ocomeni | 78:07bb86e3ce14 | 54 | WiFiInterface *network; |
ocomeni | 79:a2187bbfa407 | 55 | HttpsRequest* https_request; |
ocomeni | 79:a2187bbfa407 | 56 | HttpRequest* http_request; |
ocomeni | 79:a2187bbfa407 | 57 | HttpResponse* http_response; |
ocomeni | 79:a2187bbfa407 | 58 | nsapi_size_or_error_t lastScanCount; |
ocomeni | 79:a2187bbfa407 | 59 | wifi_cmd_t wifiCmd; |
ocomeni | 79:a2187bbfa407 | 60 | MemoryPool<wifi_cmd_message_t, 16> *_aT2WiFimPool; |
ocomeni | 79:a2187bbfa407 | 61 | Queue<wifi_cmd_message_t, 16> *_aT2WiFiCmdQueue; |
ocomeni | 79:a2187bbfa407 | 62 | |
ocomeni | 78:07bb86e3ce14 | 63 | /** |
ocomeni | 78:07bb86e3ce14 | 64 | * Allows timeout to be changed between commands |
ocomeni | 78:07bb86e3ce14 | 65 | * |
ocomeni | 78:07bb86e3ce14 | 66 | * @param timeout_ms timeout of the connection |
ocomeni | 78:07bb86e3ce14 | 67 | */ |
ocomeni | 78:07bb86e3ce14 | 68 | //void set_timeout(uint32_t timeout_ms = UBLOX_ODIN_W2_MISC_TIMEOUT); |
ocomeni | 78:07bb86e3ce14 | 69 | }; |
ocomeni | 78:07bb86e3ce14 | 70 | #endif // __WIFI_MANAGER_H__ |