-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWiFiHelper.h
37 lines (31 loc) · 939 Bytes
/
WiFiHelper.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef WIFIHELPER_H_
#define WIFIHELPER_H_
#include <WiFi.h>
#include <PubSubClient.h>
#include <HTTPClient.h>
#include <FS.h>
#include <NTPClient.h>
class WiFiHelper
{
public:
WiFiHelper(String ssid, String password);
IPAddress connect(void);
bool connected();
bool mqtt_connect(String mqttServer, int mqttPort, String mqttUser, String mqttPassword);
bool mqtt_connected();
bool mqtt_publish(String topic, String payload);
bool mqtt_subscribe(String topic);
bool downloadFile(fs::FS &fs, String uri, String sdFilePath);
// NTP
String getFormattedTime();
unsigned long getEpochTime();
private:
String _ssid;
String _password;
WiFiClient *client;
WiFiUDP *ntpUdpClient;
NTPClient *timeClient;
PubSubClient *mqttClient;
static void MQTTCallback(char *topic, byte *payload, unsigned int length);
};
#endif /* WIFIHELPER_H_ */