-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFramework.h
75 lines (61 loc) · 2.38 KB
/
Framework.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
* ESPixelStick.h
*
* Project: ESPixelStick - An ESP8266 and E1.31 based pixel driver
* Copyright (c) 2016 Shelby Merrick
* http://www.forkineye.com
*
* This program is provided free for you to use in any way that you wish,
* subject to the laws and regulations where you are using it. Due diligence
* is strongly suggested before using this code. Please give credit where due.
*
* The Author makes no warranty of any kind, express or implied, with regard
* to this program or the documentation contained in this document. The
* Author shall not be liable in any event for incidental or consequential
* damages in connection with, or arising out of, the furnishing, performance
* or use of these programs.
*
*/
#ifndef FRAMEWORK_H_
#define FRAMEWORK_H_
#include <ESP8266WiFi.h>
#include <ESPAsyncTCP.h>
#include <ESPAsyncUDP.h>
#include <ESPAsyncWebServer.h>
#include <ArduinoJson.h>
// Configuration structure
typedef struct {
/* Network */
bool useWifi; /* Connect to WiFi? */
String ssid;
String passphrase;
String hostname;
uint8_t ip[4];
uint8_t netmask[4];
uint8_t gateway[4];
bool dhcp; /* Use DHCP? */
bool ap_fallback; /* Fallback to AP if fail to associate? */
uint32_t sta_timeout; /* Timeout when connection as client (station) */
uint32_t ap_timeout; /* How long to wait in AP mode with no connection before rebooting */
} config_t;
// Status for display on the OLED display.
enum ConnectionStatus { CONNSTAT_CONNECTING, CONNSTAT_CONNECTED, CONNSTAT_LOCALAP, CONNSTAT_NONE};
typedef struct {
enum ConnectionStatus status;
String ssid;
IPAddress ourLocalIP;
IPAddress ourSubnetMask;
int signalStrength;
} connection_status_t;
// Implemented by user code.
// Update the status -- called when wifi status changes.
extern void updateStatus(const connection_status_t & connectionStatus);
// Save/load status data to flash memory and web interface.
void saveState(const JsonObject & jsonObject);
void loadState(const JsonObject & jsonObject);
// Implemented by framework.
// Setup the framework.
extern AsyncWebServer * framework_setup(bool forceAccessPoint);
// Called from loop.
extern void framework_loop();
#endif // FRAMEWORK_H_