mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-12 01:53:07 +03:00
OTA support encapsulated to ArduinoOTA class
This commit is contained in:
31
libraries/ArduinoOTA/examples/BasicOTA/BasicOTA.ino
Normal file
31
libraries/ArduinoOTA/examples/BasicOTA/BasicOTA.ino
Normal file
@ -0,0 +1,31 @@
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESP8266mDNS.h>
|
||||
#include <WiFiUdp.h>
|
||||
#include <ArduinoOTA.h>
|
||||
|
||||
const char* ssid = "...";
|
||||
const char* password = "...";
|
||||
|
||||
ArduinoOTA ota_server;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
Serial.println("Booting");
|
||||
WiFi.mode(WIFI_STA);
|
||||
|
||||
/* try the flash stored password first */
|
||||
WiFi.begin();
|
||||
|
||||
while (WiFi.waitForConnectResult() != WL_CONNECTED){
|
||||
WiFi.begin(ssid, password);
|
||||
Serial.println("Retrying connection...");
|
||||
}
|
||||
ota_server.setup();
|
||||
Serial.println("Ready");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
ota_server.handle();
|
||||
yield();
|
||||
}
|
Reference in New Issue
Block a user