Add ArduinoOTA

This commit is contained in:
mrcory
2020-02-14 17:09:36 -05:00
parent 0fc1cf7bef
commit 157d97a54c
3 changed files with 53 additions and 0 deletions
+3
View File
@@ -119,5 +119,8 @@ int pulseMax = 250; //Max brightness for pulse mode. Max 250 or it wil
#define rtcBlynk false
#define cmds true //After setting up positions, cmdArduino can be disabled
//ArduinoOTA
#define myHostname "Shade"
//How many ms until Blynk.run is triggered
const unsigned long blynkRefresh = 25;
+40
View File
@@ -0,0 +1,40 @@
void setupOTA() {
ArduinoOTA.onError([](ota_error_t error) { ESP.restart(); });
ArduinoOTA.setPassword("admin");
ArduinoOTA.setHostname(myHostname);
ArduinoOTA.onStart([]() {
String type;
if (ArduinoOTA.getCommand() == U_FLASH) {
type = "sketch";
} else { // U_SPIFFS
type = "filesystem";
}
// NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end()
Serial.println("Start updating " + type);
});
ArduinoOTA.onEnd([]() {
Serial.println("\nEnd");
});
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
});
ArduinoOTA.onError([](ota_error_t error) {
Serial.printf("Error[%u]: ", error);
if (error == OTA_AUTH_ERROR) {
Serial.println("Auth Failed");
} else if (error == OTA_BEGIN_ERROR) {
Serial.println("Begin Failed");
} else if (error == OTA_CONNECT_ERROR) {
Serial.println("Connect Failed");
} else if (error == OTA_RECEIVE_ERROR) {
Serial.println("Receive Failed");
} else if (error == OTA_END_ERROR) {
Serial.println("End Failed");
}
});
ArduinoOTA.begin();
}
+10
View File
@@ -27,6 +27,13 @@ long currentDistance = 0;
#include "config.h"
#include "timer.h"
//ArduinoOTA
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include "ota.h"
//FastLED Setup
#include <FastLED.h>
FASTLED_USING_NAMESPACE
@@ -201,7 +208,9 @@ void setup() {
Serial.begin(115200);
Serial.println("");
delay(50);
blynkConfig();
setupOTA();
EEPROM.begin(eepromSize); //Initialize the EEPROM with our selected size
@@ -238,6 +247,7 @@ void loop() {
oldBrightness = ledBrightness;
currentDistance = stepper.distanceToGo();
checkInvert();
ArduinoOTA.handle();
if (ledFeedback == true) {
ledFeedbackf();