thebigpotatoe / Super-Simple-RGB-WiFi-Lamp

A project based on the ESP8266 and WS2812b
MIT License
66 stars 28 forks source link

OTA #5

Closed StefaanVanDooren closed 4 years ago

StefaanVanDooren commented 4 years ago

I added the ability to update the lamp firmware over the air. NEw OTA.ino

void ota_Init() { ArduinoOTA.onStart([]() { Serial.println("Start"); }); 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(); Serial.println("Ready"); Serial.print("IP address: "); Serial.println(WiFi.localIP()); }

and then in the setup I added

ota_Init();

after websocketsInit();

Finally ArduinoOTA.handle();

as the first instruction in the loop.

It makes it so much easier to play around with the code, without removing the lamp from the wall everytime.

First time you need to update via serial connection, after that it works OTA

thebigpotatoe commented 4 years ago

Well this is embarassing.

OTA is in the code already but I completely forgot to mention that it was. Entirely my fault for not doing so. I will jump on the documentation asap to make it aware. You can upload to the board a new binary file by heading to the ip address with the endpoint /update.

I also use the espUpdateServer library for this as well not the one you are using since I haven't had much luck with it.

As a tip you can use code encased in two sets of ``` to put it into a code block for easier reading. You can also clone and push the updates with GitHub and I can read them inline if you are up for that.

StefaanVanDooren commented 4 years ago

I still have a lot to learn on Github.... And the code being allready there, you may close this issue....

thebigpotatoe commented 4 years ago

Updated the readme to state that OTA is supported out of the box. Thanks for pointing this out.