OTA configuration
This commit is contained in:
parent
5d0e8fb56a
commit
2506afdf28
@ -12,3 +12,8 @@
|
|||||||
platform = espressif32
|
platform = espressif32
|
||||||
board = esp32dev
|
board = esp32dev
|
||||||
framework = arduino
|
framework = arduino
|
||||||
|
|
||||||
|
; OTA
|
||||||
|
; https://docs.platformio.org/en/latest/platforms/espressif8266.html#over-the-air-ota-update
|
||||||
|
upload_protocol = espota
|
||||||
|
upload_port = Hexapod
|
||||||
|
35
src/main.cpp
35
src/main.cpp
@ -3,7 +3,7 @@
|
|||||||
#include "Vbat.h"
|
#include "Vbat.h"
|
||||||
#include "body.h"
|
#include "body.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include <Arduino.h>
|
#include <ArduinoOTA.h>
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@ -85,6 +85,38 @@ void setup() {
|
|||||||
remote->registerCallback(testRemoteCallback);
|
remote->registerCallback(testRemoteCallback);
|
||||||
|
|
||||||
sweepLeg();
|
sweepLeg();
|
||||||
|
|
||||||
|
// OTA
|
||||||
|
ArduinoOTA.setHostname("Hexapod");
|
||||||
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
@ -93,4 +125,5 @@ void loop() {
|
|||||||
remote->loop();
|
remote->loop();
|
||||||
|
|
||||||
body.healthCheck();
|
body.healthCheck();
|
||||||
|
ArduinoOTA.handle();
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user