I’m trying to setup a project which I can update OTA by automatically downloading a new version of the firmware that I will compile and upload to the project repo on my GitHub, is this possible with HTTPUpdate? I keep running into errors saying HTTP connection refused when I try to point the ESP to either raw format of the bin file on Github or the same on SourceForge and I’m not sure if it’s because they might be using redirects or if there’s something I’m doing wrong.
FYI, I changed the update URL to generic “username” and “projectrepo” because my repo is private, but in the code I’ve uploaded to my board, those point to the proper repo.
I’m using an ESP8266 as my hardware and here’s the relevant code:
#include "globals.h"
void setup() {
Serial.begin(115200);
FastLED.addLeds<CHIPSET, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);
setupStripedPalette( CRGB::Red, CRGB::Red, CRGB::White, CRGB::White); //for CANDY CANE
gPal = HeatColors_p; //for FIRE
setup_wifi();
Serial.println("Ready");
Serial.print("IP Address: ");
Serial.println(WiFi.localIP());
client.setServer(mqtt_server, mqtt_port);
client.setCallback(callback);
}
/********************************** START MAIN LOOP****************************************/
void loop() {
if (!client.connected()) {
//reconnect();
}
if (WiFi.status() != WL_CONNECTED) {
delay(1);
Serial.print("WIFI Disconnected. Attempting reconnection.");
setup_wifi();
return;
}
if((WiFiMulti.run() == WL_CONNECTED)) {
t_httpUpdate_return ret = ESPhttpUpdate.update("http://github.com/username/projectrepo/blob/master/firmware.bin?raw=true");
//t_httpUpdate_return ret = ESPhttpUpdate.update("https://server/file.bin");
switch(ret) {
case HTTP_UPDATE_FAILED:
USE_SERIAL.printf("HTTP_UPDATE_FAILD Error (%d): %s", ESPhttpUpdate.getLastError(), ESPhttpUpdate.getLastErrorString().c_str());
break;
case HTTP_UPDATE_NO_UPDATES:
USE_SERIAL.println("HTTP_UPDATE_NO_UPDATES");
break;
case HTTP_UPDATE_OK:
USE_SERIAL.println("HTTP_UPDATE_OK");
break;
}
}
client.loop();
if (effectString == "bpm") {bpmFunc();}
if (effectString == "candy cane") {candyCane();}
if (effectString == "confetti" ) {confetti();}
if (effectString == "cyclone rainbow") {cycloneRainbow();}
if (effectString == "dots") {dots();}
if (effectString == "fire") {fire();}
if (effectString == "glitter") {glitter();}
if (effectString == "juggle" ) {juggle();}
if (effectString == "lightning") {lightning();}
if (effectString == "police all") {policeAll();}
if (effectString == "police one") {policeOne();}
if (effectString == "rainbow") {rainbow();}
if (effectString == "rainbow with glitter") {rainbowGlitter();}
if (effectString == "sinelon") {sinelon();}
if (effectString == "twinkle") {twinkle();}
if (effectString == "christmas alternate") {xmasAlternate();}
if (effectString == "random stars") {randomStars();}
if (effectString == "sine hue") {sineHue();}
EVERY_N_MILLISECONDS(10){
nblendPaletteTowardPalette(currentPalette, targetPalette, maxChanges);
{gHue++;}
if (effectString == "noise") {noise();}
if (effectString == "ripple") {ripple();}
}
EVERY_N_SECONDS(5) {targetPalette = CRGBPalette16(CHSV(random8(), 255, random8(128, 255)), CHSV(random8(), 255, random8(128, 255)), CHSV(random8(), 192, random8(128, 255)), CHSV(random8(), 255, random8(128, 255)));}
if (flash) {flashFunc();}
if (startFade && effectString == "solid") {noFade();}
if (inFade) {fade();}
}
Edit:
Also, here’s the relevant stuff from globals.h (didn’t include the whole project because it’s long and most of it is tested and functional, just this feature has issues:
#include <ESP8266WiFiMulti.h>
#include <ESP8266HTTPClient.h>
#include <ESP8266httpUpdate.h>
#define USE_SERIAL Serial
ESP8266WiFiMulti WiFiMulti;