consolidate sketches
This commit is contained in:
37
libraries/KlubhausCore/src/NetManager.h
Normal file
37
libraries/KlubhausCore/src/NetManager.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#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;
|
||||
};
|
||||
Reference in New Issue
Block a user