-
Notifications
You must be signed in to change notification settings - Fork 0
/
ota.cpp
35 lines (26 loc) · 783 Bytes
/
ota.cpp
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
// ==========================================================
/*
To upload through terminal you can use: curl -F "image=@firmware.bin" esp8266-webupdate.local/update
*/
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <ESP8266WebServer.h>
#include <WiFiUdp.h>
#include <WiFiClient.h>
#include <ArduinoOTA.h>
#include <ESP8266HTTPUpdateServer.h>
#include "dolores.h"
#include "secrets.h"
ESP8266WebServer httpServer(80);
ESP8266HTTPUpdateServer httpUpdater;
void otaSetup() {
MDNS.begin(node_id);
httpUpdater.setup(&httpServer);
httpServer.begin();
MDNS.addService("http", "tcp", 80);
Serial.printf("HTTPUpdateServer ready! Open http://%s.local/update in your browser\n", node_id);
}
void otaLoop(void) {
httpServer.handleClient();
MDNS.update();
}