-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmDNS.ino
56 lines (43 loc) · 1.41 KB
/
mDNS.ino
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
#include <Arduino.h>
#include <WiFi.h>
#include <ESPmDNS.h>
#include <PrettyOTA.h>
const char* WIFI_SSID = "YOUR_SSID";
const char* WIFI_PASSWORD = "YOUR_WIFI_PASSWORD";
const char* DNS_ADDRESS = "myesp"; // http://myesp.local
AsyncWebServer server(80); // Server on port 80 (HTTP)
PrettyOTA OTAUpdates;
void setup()
{
Serial.begin(115200);
// Initialize WiFi
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
// Wait for successful WiFi connection
while (WiFi.waitForConnectResult() != WL_CONNECTED)
{
Serial.println("[WiFi] Connection failed! Rebooting...");
delay(3000);
ESP.restart();
}
// Print address and IP
Serial.println("PrettyOTA can be accessed at: http://" + String(DNS_ADDRESS) + ".local/update");
Serial.println("And at: http://" + WiFi.localIP().toString() + "/update");
// Setup mDNS
// You must call "MDNS.begin()" BEFORE "OTAUpdates.Begin()"
MDNS.begin(DNS_ADDRESS);
// Initialize PrettyOTA
OTAUpdates.Begin(&server);
// Set unique Hardware-ID for your hardware/board
OTAUpdates.SetHardwareID("UniqueBoard1");
// Set firmware version to 1.0.0
OTAUpdates.OverwriteAppVersion("1.0.0");
// Set current build time and date
PRETTY_OTA_SET_CURRENT_BUILD_TIME_AND_DATE();
// Start web server
server.begin();
}
void loop()
{
// Give CPU time to other running tasks
delay(100);
}