ota toegevoegd, altijd beginnen op wit

This commit is contained in:
Daan Meijer 2025-09-10 23:50:17 +02:00
parent 8e410e616e
commit b200b97f1a
7 changed files with 63 additions and 2 deletions

View File

@ -48,3 +48,9 @@ monitor_filters =
lib_deps =
fastled/FastLED@^3.7.0
knolleary/PubSubClient@^2.8
[env:esp32c3_supermini_network]
extends = env:esp32c3_supermini
upload_protocol = espota
upload_port = 10.206.0.101

View File

@ -179,6 +179,10 @@ bool Hanglamp::isOn(){
void Hanglamp::turnOn(){
if(!this->on){
this->colorIndex = 1;
setColor(colorTable[1]);
FastLED.setBrightness(this->brightness);
FastLED.show();
this->setOn(true);

View File

@ -10,7 +10,7 @@ PubSubClient client(espClient);
std::vector<SubscribedChannel> * channels = new std::vector<SubscribedChannel>();
char mqtt_server[40] = "manus";
char mqtt_server[40] = "10.206.0.175";
char mqtt_port[6] = "1883";

44
src/OTA.cpp Normal file
View File

@ -0,0 +1,44 @@
#include "OTA.h"
#include <ArduinoOTA.h>
void OTA_setup(){
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);
})
.onEnd([]() {
Serial.println("\nEnd");
})
.onProgress([](unsigned int progress, unsigned int total) {
Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
})
.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 OTA_loop(){
ArduinoOTA.handle();
}

2
src/OTA.h Normal file
View File

@ -0,0 +1,2 @@
void OTA_loop();
void OTA_setup();

View File

@ -2,7 +2,7 @@
#define INCLUDE_LED
#define ENABLE_MQTT
// #define ENABLE_OTA
#define ENABLE_OTA
#define ENABLE_WIFI
// #define ENABLE_FS
// #define ENABLE_PINFINDER

View File

@ -16,6 +16,11 @@
#include "Wifi.h"
#endif
#ifdef ENABLE_OTA
#include "OTA.h"
#endif
#ifdef ENABLE_MQTT
#include "MQTT.h"
#endif