Added ssl and plato

This commit is contained in:
Magnus Persson
2022-01-18 23:01:10 +01:00
parent 10163f3aa7
commit ddb34e129d
27 changed files with 556 additions and 315 deletions

View File

@ -26,16 +26,24 @@ SOFTWARE.
// Include
#include <Arduino.h>
#include <ESP8266WiFi.h>
// tcp cleanup, to avoid memory crash.
struct tcp_pcb;
extern struct tcp_pcb* tcp_tw_pcbs;
extern "C" void tcp_abort(struct tcp_pcb* pcb);
// classes
class WifiConnection {
private:
// WIFI
WiFiClient _client;
WiFiClientSecure _secureClient;
// OTA
bool newFirmware = false;
bool parseFirmwareVersionString(int (&num)[3], const char *version);
void downloadFile(const char *fname);
bool parseFirmwareVersionString(int (&num)[3], const char* version);
void downloadFile(const char* fname);
void connectAsync();
bool waitForConnection(int maxTime = 20);
@ -53,6 +61,16 @@ class WifiConnection {
void startPortal();
void loop();
WiFiClient& getWifiClient() { return _client; }
WiFiClientSecure& getWifiClientSecure() { return _secureClient; }
void closeWifiClient() {
_client.stopAll();
_secureClient.stopAll();
// Cleanup memory allocated by open tcp connetions.
while (tcp_tw_pcbs) tcp_abort(tcp_tw_pcbs);
}
// OTA
bool updateFirmware();
bool checkFirmwareVersion();