38 lines
891 B
C++
38 lines
891 B
C++
#pragma once
|
|
#include <Arduino.h>
|
|
#include <WiFi.h>
|
|
#include <WiFiMulti.h>
|
|
#include <WiFiClientSecure.h>
|
|
#include <HTTPClient.h>
|
|
#include <NTPClient.h>
|
|
#include <WiFiUdp.h>
|
|
#include "Config.h"
|
|
|
|
class NetManager {
|
|
public:
|
|
void begin(const WiFiCred* creds, int count);
|
|
bool checkConnection();
|
|
bool isConnected();
|
|
|
|
String getSSID();
|
|
String getIP();
|
|
int getRSSI();
|
|
|
|
bool syncNTP();
|
|
String getTimeStr();
|
|
|
|
bool dnsCheck(const char* host);
|
|
bool tlsCheck(const char* host);
|
|
|
|
/// HTTPS GET; writes body into `response`. Returns HTTP status code.
|
|
int httpGet(const char* url, String& response);
|
|
/// HTTPS POST with text/plain body. Returns HTTP status code.
|
|
int httpPost(const char* url, const String& body);
|
|
|
|
private:
|
|
WiFiMulti _multi;
|
|
WiFiUDP _udp;
|
|
NTPClient* _ntp = nullptr;
|
|
bool _ntpReady = false;
|
|
};
|