-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path\
78 lines (61 loc) · 1.84 KB
/
\
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
/*********
Rui Santos
Complete instructions at https://RandomNerdTutorials.com/esp32-wi-fi-manager-asyncwebserver/
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*********/
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESPAsyncWebServer.h>
#include <ESPAsyncTCP.h>
#include <stdlib.h>
#include <EEPROM.h>
#define EEPROM_SIZE 130
// Config
#define DEBUG
//Variables to save values from HTML form
String ssid;
String password;
String ip;
String gateway;
struct WifiData {
char ssid[33];
char password[64];
char ip[16];
char gateway[16];
};
#include "api/pwm_controller_commands.h"
#include "common/pwm_controller_esp.h"
#include "common/pwm_controller_user.h"
#include "html.h"
#include "PwmControllerWebUserControl.h"
#include "WifiSetupWebUserControl.h"
void pwm_controller_setup() {
// Load saved WiFi Data
WifiData savedWifiData;
EEPROM.get(0, savedWifiData);
ssid = savedWifiData.ssid;
password = savedWifiData.password;
ip = savedWifiData.ip;
gateway = savedWifiData.gateway;
// Start Web Server
WebUserControl* webServer;
if(setupWiFi()) {
DBGLOG("Connected successfully. Starting web server");
webServer = new PwmControllerWebUserControl();
} else {
DBGLOG("Setting AP");
WiFi.softAP("ESP-WIFI-MANAGER", NULL);
DBGLOG("Starting Web Server");
webServer = new WifiSetupWebUserControl();
}
webServer->start();
DBGLOG("TEST");
pwmSerial.println("TEST123");
}
void pwm_controller_loop() {
digitalWrite(LED_BUILTIN, LED_LOW);
delay(1000);
digitalWrite(LED_BUILTIN, LED_HIGH);
DBGLOG("TEST");
}