-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathglobal.h
97 lines (75 loc) · 1.75 KB
/
global.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// global.h
#ifndef _GLOBAL_h
#define _GLOBAL_h
#if defined(ARDUINO) && ARDUINO >= 100
#include "arduino.h"
#else
#include "WProgram.h"
#endif
#include <Ticker.h>
#include <ESP8266WiFi.h>
#include <NtpClientLib.h>
#include <WebSocketsServer.h>
#include <WebSockets.h>
#include "Config.h"
//#ifdef DEBUG
//#define DEBUG_GLOBALH
//#endif // DEBUG
#define CONFIG_FILE "/config.json"
#define SECRET_FILE "/secret.json"
typedef enum {
FIRST_RUN = 0,
WIFI_STA_CONNECTED,
WIFI_STA_DISCONNECTED,
AP_ONLY
} wifiStatus;
extern Ticker secondTk; // Second - Timer to do periodic tasks
extern boolean secondFlag; // Flag to activate periodic task
extern ntpClient* ntp; // NtpClient instance
extern long wifiDisconnectedSince; // When disconnected, time since this situation has happened
extern wifiStatus currentWifiStatus;
extern WebSocketsServer wsServer; // Socket server to send dynamic data to web browser
/**
* Sets WiFi configuration as config struct
*/
void ConfigureWifi();
/**
* Sets WiFi AP
*/
void ConfigureWifiAP();
/**
* Periodically sets seconfFlag to run secondTask
*/
void secondTick();
/**
* Periodic task to send time data to Web Socket
*/
void secondTask();
/**
* Gets arguments from an URL string
* @param[in] String with URL to decode.
* @param[out] Pointer to ntpClient instance
*/
String urldecode(String input);
/**
* Checks number is in 0-255 range
*/
boolean checkRange(String Value);
/**
* Runs on every WiFi event (connection, disconnection)
*/
void WiFiEvent(WiFiEvent_t event);
/**
* Makes a LED flash n-times
*/
void flashLED(int pin, int times, int delayTime);
/**
* Slowly turn a LED on
*/
void dimLEDon(int pin, int range);
/**
* Sets and start OTA configuration
* @param[in] Password for OTA
*/
void ConfigureOTA(String password="");
#endif