Okundu Omeni
/
wifi-https-ble-sm-uart-atcmd-5-13-1
this is using the mbed os version 5-13-1
source/WiFiManager.h
- Committer:
- ocomeni
- Date:
- 2019-03-29
- Revision:
- 87:99b37d26ff2a
- Parent:
- 84:7c7add00f4bf
- Child:
- 88:7ffa053be662
File content as of revision 87:99b37d26ff2a:
#ifndef __WIFI_MANAGER_H__ #define __WIFI_MANAGER_H__ #ifndef __MBED_H__ #define __MBED_H__ #include "mbed.h" #endif #include "mbed_trace.h" #include "https_request.h" #include "http_request.h" /* List of trusted root CA certificates * currently two: GlobalSign, the CA for os.mbed.com and Let's Encrypt, the CA for httpbin.org * * To add more root certificates, just concatenate them. */ #include "https_certificates.h" #include "common_types.h" extern void print_memory_info(); class WiFiManager { public: WiFiManager(wifi_config_t wifi_config, WiFiInterface *wifi, MemoryPool<wifi_cmd_message_t, 16> *aT2WiFimPool, Queue<wifi_cmd_message_t, 16> *aT2WiFiCmdQueue, MemoryPool<at_resp_message_t, 16> *wiFi2ATmPool, Queue<at_resp_message_t, 16> *wiFi2ATCmdQueue, MemoryPool<wifi_data_msg_t, PQDSZ> *aT2WiFiDatamPool, Queue<wifi_data_msg_t, PQDSZ> *aT2WiFiDataQueue, MemoryPool<at_data_msg_t, PQDSZ> *wiFi2ATDatamPool, Queue<at_data_msg_t, PQDSZ> *wiFi2ATDataQueue); ~WiFiManager(); void runMain(); void status_callback(nsapi_event_t status, intptr_t param); private: wifi_config_t wifi_config; internet_config_t internet_config; WiFiInterface *network; HttpsRequest* https_request; HttpRequest* http_request; HttpResponse* http_response; http_request_t *http_req_cfg; nsapi_size_or_error_t lastScanCount; wifi_cmd_t wifiCmd; //at_data_msg_t *at_data_resp; int chunkNum; /* Queue and memory pool for AT to Wifi commands */ MemoryPool<wifi_cmd_message_t, 16> *_aT2WiFimPool; Queue<wifi_cmd_message_t, 16> *_aT2WiFiCmdQueue; /* Queue and memory pool for WiFi to AT commands */ MemoryPool<at_resp_message_t, 16> *_wiFi2ATmPool; Queue<at_resp_message_t, 16> *_wiFi2ATCmdQueue; /* Queue and memory pool for AT to WiFi data */ MemoryPool<wifi_data_msg_t, PQDSZ> *_aT2WiFiDatamPool; Queue<wifi_data_msg_t, PQDSZ> *_aT2WiFiDataQueue; wifi_data_msg_t *data_msg; /* Queue and memory pool for WiFi to AT data */ MemoryPool<at_data_msg_t, PQDSZ> *_wiFi2ATDatamPool; Queue<at_data_msg_t, PQDSZ> *_wiFi2ATDataQueue; bool is_connected; nsapi_size_or_error_t scanNetworks(); nsapi_size_or_error_t getAvailableAPs(nsapi_size_t count); void set_WIFI_SSID(char * wifi_ssid); void set_WIFI_PASSWORD(char * wifi_pass); void set_WIFI_SECURITY(nsapi_security_t wifi_security); void set_WIFI_CONFIG(); void set_internet_config(); nsapi_error_t connect(); nsapi_error_t disconnect(); void createHttpsRequest(); void createHttpRequest(http_method method, const char* url, Callback<void(const char *at, uint32_t length)> body_callback = 0 ); void setHttpHeader(string key, string value); void setHttpsHeader(string key, string value); void sendHttpsRequest(const char * body, int bodyLen); void sendHttpRequest(const char * body, int bodyLen); bool setNextCommand(wifi_cmd_t cmd); bool dequeueWiFiCommands(); bool queueATresponse(at_cmd_resp_t resp); bool dequeueATdataResponse(); bool queueWiFiDataResponse(at_data_msg_t at_resp); const char * sec2str(nsapi_security_t sec); void free_DataMsg(); void body_callback(const char *at, uint32_t length); void return_response(HttpResponse* res); /** * Allows timeout to be changed between commands * * @param timeout_ms timeout of the connection */ //void set_timeout(uint32_t timeout_ms = UBLOX_ODIN_W2_MISC_TIMEOUT); }; #endif // __WIFI_MANAGER_H__