forked from fmueller/esp8266-led-marquee-sign-controller
Initial commit
This commit is contained in:
52
src/main.cpp
Normal file
52
src/main.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
#include <ESP8266WiFiMulti.h>
|
||||
#include <ESP8266mDNS.h>
|
||||
#include <ESP8266WebServer.h>
|
||||
|
||||
#include "credentials.h"
|
||||
#include "webserver.h"
|
||||
#include "util.h"
|
||||
|
||||
static ESP8266WiFiMulti wifiMulti;
|
||||
|
||||
void setup() {
|
||||
// serial console, for use via USB (also exposed to TXD0/RXD0 GPIOs)
|
||||
Serial.begin(115200);
|
||||
|
||||
// transmit-only UART port, used for communication with the LED sign
|
||||
// the BAUD rate was deducued from the communication sent to the USB 12V UART adapter by the available Windows
|
||||
// software
|
||||
Serial1.begin(9600);
|
||||
|
||||
// configure WiFi and connect to the network
|
||||
wifiMulti.addAP(credentials::ssid.c_str(), credentials::psk.c_str());
|
||||
Serial.println("Connecting to Wi-Fi network...");
|
||||
while (wifiMulti.run() != WL_CONNECTED) {
|
||||
delay(1000);
|
||||
Serial.print(".");
|
||||
}
|
||||
Serial.println();
|
||||
Serial.print("Connected to ");
|
||||
Serial.print(WiFi.SSID());
|
||||
Serial.print(", IP address: ");
|
||||
Serial.println(WiFi.localIP());
|
||||
|
||||
// might be handy to have the IP written on the sign
|
||||
sendTextToSign(WiFi.localIP().toString());
|
||||
|
||||
// publish this service using mDNS so that it's easy to find it in the LAN
|
||||
if (MDNS.begin(credentials::mdnsHostname)) {
|
||||
Serial.println("mDNS started up successfully");
|
||||
} else {
|
||||
Serial.println("Error: failed to start mDNS");
|
||||
}
|
||||
|
||||
// configure HTTP endpoints
|
||||
configureWebServer();
|
||||
|
||||
// don't forget to start the webserver!
|
||||
webServer.begin();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
webServer.handleClient();
|
||||
}
|
||||
Reference in New Issue
Block a user