Okundu Omeni
/
wifi-https-ble-sm-uart-atcmd-5-13-1
this is using the mbed os version 5-13-1
Diff: source/WiFiManager.h
- Revision:
- 79:a2187bbfa407
- Parent:
- 78:07bb86e3ce14
- Child:
- 80:e8f0e92e3ac9
--- a/source/WiFiManager.h Sat Mar 16 13:05:52 2019 +0000 +++ b/source/WiFiManager.h Wed Mar 20 21:02:47 2019 +0000 @@ -1,26 +1,65 @@ #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" + class WiFiManager { public: - WiFiManager(wifi_config_t wifi_config, WiFiInterface *wifi); + WiFiManager(wifi_config_t wifi_config, WiFiInterface *wifi, + MemoryPool<wifi_cmd_message_t, 16> *aT2WiFimPool, + Queue<wifi_cmd_message_t, 16> *aT2WiFiCmdQueue); ~WiFiManager(); - void scanChannels(); - void getAvailableAPs(); - void set_WIFI_SSID(char * wifi_ssid); - void set_WIFI_PASSWORD(char * wifi_pass); - void set_WIFI_SECURITY(nsapi_security_t wifi_security); - void connect(); - void disconnect(); - void sendHttpsRequest(); - void sendHttpRequest(); - + nsapi_size_or_error_t scanNetworks(); + nsapi_size_or_error_t getAvailableAPs(WiFiAccessPoint * res, + 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); + nsapi_error_t connect(); + nsapi_error_t disconnect(); + void createHttpsRequest(http_method method, + const char* url, + Callback<void(const char *at, uint32_t length)> body_callback = 0 + ); + 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(); + void runMain(); + private: wifi_config_t wifi_config; WiFiInterface *network; + HttpsRequest* https_request; + HttpRequest* http_request; + HttpResponse* http_response; + nsapi_size_or_error_t lastScanCount; + wifi_cmd_t wifiCmd; + MemoryPool<wifi_cmd_message_t, 16> *_aT2WiFimPool; + Queue<wifi_cmd_message_t, 16> *_aT2WiFiCmdQueue; + /** * Allows timeout to be changed between commands *