-
Notifications
You must be signed in to change notification settings - Fork 0
/
ArduinoAQIData.h
56 lines (49 loc) · 1.36 KB
/
ArduinoAQIData.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef ArduinoAQIData_h
#define ArduinoAQIData_h
#include <EEPROM.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <ThingSpeak.h>
#include <Arduino_JSON.h>
#include "src/WiFiManager/WiFiManager.h"
#include "private/config.h"
#ifndef ACCESS_POINT_PASSWORD
# define ACCESS_POINT_PASSWORD NULL
#endif
struct Credentials {
String ssid;
String password;
};
class ArduinoAQIData {
public:
ArduinoAQIData();
int numRegisteredDevices = 1;
void begin();
void restart();
void disconnectAndRestart(bool clearCredentials);
void resetWifi();
String getMacAddress();
bool isConnected();
bool write(float number1, float number2, float number3, float number4);
void setAPCallback( void (*func)(WiFiManager*) );
Credentials getSavedCredentials();
private:
WiFiClient _client;
WiFiManager _wifiManager;
int _connectionAttempts = 0;
bool _isRegistered = false;
String _thingspeakWriteKey = "";
unsigned long _thingspeakChannelId = 0;
void _onWifiConnect();
void _clearEEPROMCredentials();
void _reconnectWifi();
void _saveWifiCredentials();
void _loadThingspeakConfig();
bool _fetchThingspeakConfig();
void _setDefaultThingspeakConfig();
bool _setThingspeakConfig(String json);
bool _isNull(int loc);
};
#endif