Giter Club home page Giter Club logo

elegantota's People

Contributors

anshumanfauzdar avatar ayushsharma82 avatar dependabot[bot] avatar lukepalmer avatar mindsuru avatar peterackermans avatar qistoph avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

elegantota's Issues

Flash encryption

Does this work with a ESP32 that has flash encryption enabled?

credentials.h

I get an eternal loop if I just take the credentials line and put it into a credentials.h file and import it. Is this a user error?

code: output is: "..................."

#include <WiFi.h>
#include <WiFiClient.h>
#include <WebServer.h>
#include <ElegantOTA.h>
#include <credentials.h>

WebServer server(80);


void setup(void) {
  Serial.begin(115200);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  Serial.println("");

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

  server.on("/", []() {
    server.send(200, "text/plain", "Hi! I am ESP32.");
  });

  ElegantOTA.begin(&server);    // Start ElegantOTA
  server.begin();
  Serial.println("HTTP server started");
}

void loop(void) {
  server.handleClient();
}

DOIT esp32 devkit v1 OTA v 2.2.5 not working

After upgrade from version 2.2.4 to 2.2.5 OTA not working.
Board is esp32 DOIT devkit v1. Server is responsing, but on the page is only ElegantOTA header, no checkbox firmware, no checkbox filesystem, no menu choose file.
OTA

OTA don't work with hardware timer

Maybe not an issue !
The use of hardware timer blocks OTA update. This may solved by settings this timer in IRAM with IRAM_ATTR like in this example :

`int16_t tempsRestant = timeToGo;
hw_timer_t *Chrono_timer = NULL;
portMUX_TYPE timerChronoMux = portMUX_INITIALIZER_UNLOCKED;
bool ChronoIsRunning = false;
IRAM_ATTR void Chrono_decremente()
{
portENTER_CRITICAL_ISR(&timerChronoMux);
tempsRestant--;
portEXIT_CRITICAL_ISR(&timerChronoMux);
}

IRAM_ATTR hw_timer_t * Chrono_init(uint16_t time)
{
tempsRestant = time;
Chrono_timer = timerBegin(2, 80, true);
timerAttachInterrupt(Chrono_timer, &Chrono_decremente, true);
timerAlarmWrite(Chrono_timer, 1000000, true);
timerAlarmEnable(Chrono_timer);
return Chrono_timer;
}
`

OTA upload hangs between 25-53%

Here is a really strange bug report. In Linux the OTA works fine. Android phones also work. In Windows 10, the OTA fails with a backtrace telling me:

0x400891d8: invoke_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c line 156
0x40089455: abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c line 171
0x40174634: task_wdt_isr at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/task_wdt.c line 174
0x4008a466: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 143
0x400891d8: invoke_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c line 156
0x40089455: abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c line 171
0x40174634: task_wdt_isr at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/task_wdt.c line 174
0x4008a466: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 143

ElegantOTA writing to serial port

Hi

Thank you for writing this. It is nicely done and "elegant".

However, I do have a suggestion. Can you please disable the writing to the Serial port. There is a message written to the Serial port when using ElegantOTA.

I cannot find where to disable this.

I do not believe that libraries should assume that the serial port is unused.

I have a few applications and projects that use the serial port for a variety of purposes, and having a message that I cannot disable coming from a library causes real issues for my applications/projects. I often start and stop the webserver service, and everytime it starts up I get this annoying message coming from ElegantOTA.

Thank you
Robert

CRUSH ...ayushsharma82 / ElegantOTA :(

Hi there!!!
I was really very excited about a month ago when installed the library. BUT... while working perfectly.... after a few uploads the browser became irresponsive. When I plug the ESP8266 on USB on Serial port there is a long error generated followed by a restart. What kind of mistake am I doing? Please Help me!!!

Security Add on

hi developer, is is possible to have at least some simple password checking , and user need to be key in correctly before allow to upload?

Add a retry button on failed upload.

A few times I had to hit back, then reload OTA page, set filename and click upload again to get the transfer to complete successfully. (low wifi signal probably)

A retry button on a failed upload would be good. :)

Any mechanism to check why an upload errors?

I am receiving an Error on uploading my bin file. I use PlatformIO which creates a .pioenvs/nodemcuv2/firmware.bin file. After upload attempt I see OTA Failed Reason -. Just wondering if there is a way for me to see what the error is.

Getting error when running npm install

When i run "npm install", i am getting this error:

npm WARN deprecated [email protected]: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates.
npm ERR! Linux 4.15.0-153-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! node v8.10.0
npm ERR! npm  v3.5.2
npm ERR! code EMISSINGARG

npm ERR! typeerror Error: Missing required argument #1
npm ERR! typeerror     at andLogAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:31:3)
npm ERR! typeerror     at fetchPackageMetadata (/usr/share/npm/lib/fetch-package-metadata.js:51:22)
npm ERR! typeerror     at resolveWithNewModule (/usr/share/npm/lib/install/deps.js:456:12)
npm ERR! typeerror     at /usr/share/npm/lib/install/deps.js:457:7
npm ERR! typeerror     at /usr/share/npm/node_modules/iferr/index.js:13:50
npm ERR! typeerror     at /usr/share/npm/lib/fetch-package-metadata.js:37:12
npm ERR! typeerror     at addRequestedAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:82:5)
npm ERR! typeerror     at returnAndAddMetadata (/usr/share/npm/lib/fetch-package-metadata.js:117:7)
npm ERR! typeerror     at pickVersionFromRegistryDocument (/usr/share/npm/lib/fetch-package-metadata.js:134:20)
npm ERR! typeerror     at /usr/share/npm/node_modules/iferr/index.js:13:50
npm ERR! typeerror This is an error with npm itself. Please report this error at:
npm ERR! typeerror     <http://github.com/npm/npm/issues>

"Batch" mode

Could you add some functionality to allow us to skip the elegant web page where we already know the bin file path and name, a "batch" update mode. We can then can trigger the update when our application awakes from sleep and we know that it has an update waiting for it

Progress bar fail with IOS 14.2

Using IOS (14.2,) the progress bar immediately flashes to 99% on upload.
Presumably this is something Apple breaks, but can you modify the code to be IOS compatible?
Testing with an older IOS (9.3.6) its worse, and gets stuck on the ElegantOTA update screen (no choose file tabs etc) and you cannot choose files or update.

UI local development: work around /update/identity

Looking into some small modifications, I've found your local development option npm run serve. Which is really easy to setup and run.

However, upon opening the UI served locally I get an error that the JSON in /update/identity is invalid.

Opening that URL directly also shows the UI (HTML), instead of some JSON.

How would I work around that on the local development instance?

Support for SD card files

Hi,
I have a ESP32 system with a SD card that utilizes the FS.h.
This works perfectly and serves up 10 odd webpages from the SD card.

I'm having issues doing the following:

  1. Firmware OTA updates.
  2. General files system updates e.g. update SD card files htm, css, json etc.

How do I do this with the current system or modify the "AsyncElegantOTA.h" to add this support?

Clarification

Hi, I can see a firmware update would be a new BIN file, what is the Filestsyem option for?
Can we update the SPIFFS file folder with this tool?

Update UI

After build for production in UI, what utility do you use to convert to hex to paste into elegantwebpage.h? In the dist folder, i have favicon, index.html and js. How do i merge these to the hex? THank you in advance!

OTA not working on somewhat weaker WIFI strength

As many others I discover that OTA ends with an error message when I do not have good WIFI signal strength. It stops with the message [HTTP ERROR] Bad Request in the update-Webpage.

I use it on an ESP32 and it runs a webserver with a small webpage to control a few switches and it has stable MQTT-Connection to Node-Red. So, generally, communication over the network is working reliable.

Looking at other comments, I feel that ELegantOTY is particularly demanding a very high network quality - As many other services work with much lower WIFI Signal strength (And I use many ESP32 at places with less than ideal signal strength without any problem except that I cant run OTA) I hope that there will be a way to correct this (maybe there is some error correction / checksum thing to da as I am sure that every means to avoid installing a corrupted binary is present :-)

Other than that I am very happy with ElegentOTA

ESP-01 Reset

With the versions 2.2.5 and 2.2.7 the ESP-01 and ESP-01s reset when access the web update ElegantOTA page.

[HTTP Error] Not Found

I used the esp8266 demo as offered, only entering my wifi credentials.

Webserver loads fine. /update takes me to the update page. I navigate to the bin file for upload and click open.

The task bar progress to 100%, but then I get an [HTTP ERROR] Not Found message. The upload has not worked.

I am using a nodemcu 12F board with the latest arduino ide.

What have I done wrong? Thanks.

OTA update via platformio not working and Preferences.h questions

Hi,

I'm using platformio (on VSC) and Win10 for programming of my device.
In my platformio.ini file I have placed the following code:
[env:WiFi]
upload_protocol = espota
upload_port = 10.100.8.60

When I try to build and upload, I get the following error:

Uploading .pio\build\WiFi\firmware.bin
14:18:41 [DEBUG]: Options: {'esp_ip': '10.100.8.60', 'host_ip': '0.0.0.0', 'esp_port': 3232, 'host_port': 48565, 'auth': '', 'image': '.pio\build\WiFi\firmware.bin', 'spiffs': False, 'debug': True, 'progress': True, 'timeout': 10}
14:18:41 [INFO]: Starting on 0.0.0.0:48565
14:18:41 [INFO]: Upload size: 1284432
Sending invitation to 10.100.8.60 ..........
14:18:41 [ERROR]: No response from the ESP
*** [upload] Error 1

If I browse to the device e.g. http://10.100.8.60/update, the ElegantOTA web page is displayed.

Any ideas on how to get this to work through the platformio environment?

I read somewhere on the RNT website that ElegantOTA overwrites the spiffs and Preferences (NVS) flash storage.
In platformio is there a way of limiting where ElegantOTA writes to?

Thanks,
Neil.

Disable Filesystem Upload

Hello, is it possible to disable or hide the filesystem update?

I use LittleFS for my projects so this is not useful for me.
Thanks.

LOGO changes

how to change custom logo instead of ElegantOTA logo...Please help me

Upload status callbacks

Thanks for the lib, it works magnificently right out of box, and what's more important — saves lots of time)

I've got a question about update process statuses callbacks.
E.g., i want to print some data on a screen after file upload is completed.

I went through the source files and found nothing suitable, am i missing something?

Thank you!

Strange error when compiling.

Hello. The following sketch does not compile and throws error 'connect_to_wifi_jb' was not declared in this scope".

However, when I comment out #include <ElegantOTA.h> to //#include <ElegantOTA.h>
then the sketch compiles correctly. I do not have to say that 'connect_to_wifi_jb' is declared correctly...

char* D_Name = "toshiba_ac";
const long FW_VERSION = 19111301;

#include <ESP8266WiFi.h>
//#include <ESP8266mDNS.h>
//#include <WiFiUdp.h>
#include <Ticker.h>
#include <WiFiManager.h> //https://github.com/tzapu/WiFiManager
#include <ElegantOTA.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>

//#include <ESP8266HTTPClient.h>
#include <ESP8266httpUpdate.h>
#include "CTBot.h"
#include "DHTesp.h"

CTBot myBot;
DHTesp dht;
WiFiClient client;

// For DHT
int cycleCount = 50;
int currentCycle = cycleCount + 1; //overrun for first time so Temp is sent immediately
String APIkey = "MPX0....QZ";
const char* TSserver = "api.thingspeak.com";
int DHTIO = 13; // GPIO 15 - D8 right next to 3.3V pin
int DHTGround = 12; // GPIO 5
String st = ""; // temperature declared as global
unsigned int recipient;

// For Toshiba AC control
#include <Arduino.h>
#include <IRremoteESP8266.h> //https://github.com/crankyoldgit/IRremoteESP8266
#include <IRsend.h>
#include <ir_Toshiba.h>
#include <string.h>
const uint16_t kIrLed = 4; // ESP8266 GPIO pin 4 to use. Recommended: 4 (D2).
IRToshibaAC ac(kIrLed); // Set the GPIO to be used for sending messages.

void printState(unsigned int my_telegram_id) {
// Display the settings.
Serial.println("Toshiba A/C remote is in the following state:");
Serial.printf(" %s\n", ac.toString().c_str());
myBot.sendMessage(my_telegram_id, ac.toString().c_str());
myBot.sendMessage(my_telegram_id, "Temp: "+st+" (v."+FW_VERSION+")");
// Display the encoded IR sequence.
unsigned char* ir_code = ac.getRaw();
Serial.print("IR Code: 0x");
for (uint8_t i = 0; i < kToshibaACStateLength; i++)
Serial.printf("%02X", ir_code[i]);
Serial.println();
}
//--------

const char* fwUrlBase = "http://.../files/";
String OldCommand = "";
String newCommand = "";

//String token = "5671.....e3BWiqEwuqgSs"; // REPLACE myToken WITH YOUR TELEGRAM BOT TOKEN
String token = "751573.......VoOdWHvtcZSNCyM"; // REPLACE myToken WITH YOUR TELEGRAM BOT TOKEN
unsigned int my_telegram_id = 123456789;
unsigned int sleep_time = 600000000; //600 seconds
rst_info *xyz;
byte reset_reason;

int valid = 0;

Ticker ticker;

//char* ssid = "";
//char* password = "";

String ssid = "";
String password = "";

// ADC_MODE(ADC_VCC);

#define LED_ESP 2
#define PH_VCC 14
#define PH_GND 12
#define THRESHOLD 900
#define POWER_CYCLE 6
#define WD_RESET 5
#define AFTER_OTA 4

// the setup function runs once when you press reset or power the board
void setup() {

dht.setup(DHTIO, DHTesp::DHT22);
delay(2000);

// For Toshiba AC control
pinMode(LED_BUILTIN, OUTPUT);
ac.begin();
Serial.begin(115200);
delay(200);
//------------

// Set up what we want to send. See ir_Toshiba.cpp for all the options.
Serial.println("Default state of the remote.");
//printState(my_telegram_id);
Serial.println("Setting desired state for A/C.");
ac.on();
// ac.setFan(1);
// ac.setMode(kToshibaAcCool);
ac.setMode(kToshibaAcAuto);
ac.setTemp(25);

// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_ESP, OUTPUT);
Serial.begin(115200);
Serial.println("Starting...");

// Init DHT ground
pinMode(DHTGround, OUTPUT);
digitalWrite(DHTGround, LOW);

Serial.print("Checking Reset reason...");
xyz = ESP.getResetInfoPtr();
reset_reason = (*xyz).reason;
Serial.println(reset_reason);

//if (reset_reason == POWER_CYCLE) {
Serial.print("Connecting to WiFi...");
connect_to_wifi_jb();
Serial.println("connected.");
//int Light = getLght();

//Elegant OTA
//ElegantOTA.begin(&server); // Start ElegantOTA
//server.begin();
//Serial.println("HTTP server started");

//Tbot init
myBot.setTelegramToken(token);

// check if all things are ok
if (myBot.testConnection())
Serial.println("\nBOT testConnection OK");
else
Serial.println("\nBOT testConnection NOK");

myBot.sendMessage(my_telegram_id, "Tady AC, boot, kontroluji update...");
Serial.print("Checking for update...");
checkForUpdates();
Serial.println("checked.");
//}
readAcServer();
OldCommand = newCommand;

}

//################################### START ###############################################xx

// the loop function runs over and over again forever
void loop() {

// Read Temp Humi every 50 cycles (5 minutes)
currentCycle = currentCycle + 1;
if (currentCycle >= cycleCount) {
delay(dht.getMinimumSamplingPeriod());
float humidity = dht.getHumidity();
Serial.println(humidity);
float temperature = dht.getTemperature();
Serial.println(temperature);
st = String(temperature);
String sh = String(humidity);
Serial.println("Temp: "+st+", Humi: "+sh);
currentCycle = 0;
logTS(sh,st);
}

// Read CTbot message
TBMessage msg;
String tms = "";
int cmdsent = 0;

recipient = my_telegram_id;

readAcServer();

Serial.print("Command retrieved: ");
Serial.println(newCommand);

if (newCommand != OldCommand) {
tms = newCommand;
Serial.print("Preparing to send command from server: ");
Serial.println(tms);
myBot.sendMessage(recipient, "Server command: "+newCommand);
}
OldCommand = newCommand;

// if there is an incoming message...
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(20);
digitalWrite(LED_BUILTIN, HIGH);
if (myBot.getNewMessage(msg)) {
// ...forward it to the sender
cmdsent = 1;
tms = msg.text;
tms.toUpperCase();
recipient = msg.sender.id;
myBot.sendMessage(recipient, "Příjem: "+tms);
}

valid = 0;

char tm[50];

tms.toCharArray(tm,50);
char* word1 = strtok(tm," ");
char* word2 = strtok(NULL," ");
String w1 = String(word1);
String w2 = String(word2);
Serial.println("Word1: "+w1+"; Word2: "+w2);

// Now send the IR signal.
#if SEND_TOSHIBA_AC

if (w1 == "POWER") {
  if (w2 == "ON") {
    ac.on();
    valid = 1;
    // OldCommand = "POWER ON";
    }
  if (w2 == "OFF") {
    ac.off();
    valid = 1;
    // OldCommand = "POWER OFF";
    }
  }
if (w1 == "MODE") {
  if (w2 == "AUTO") {
    ac.setMode(kToshibaAcAuto);
    valid = 1;
    }
  if (w2 == "COOL") {
    ac.setMode(kToshibaAcCool);
    valid = 1;
    }
  if (w2 == "HEAT") {
    ac.setMode(kToshibaAcHeat);
    valid = 1;
    }
  }

if (w1 == "FAN") {
  if (w2 == "AUTO") {
    ac.setFan(kToshibaAcFanAuto);
    valid = 1;
    }
  if (w2 == "MIN") {
    ac.setFan(1);
    valid = 1;
    }
  if (w2 == "MAX") {
    ac.setFan(kToshibaAcFanMax);
    valid = 1;
    }
  }

if (w1 == "TEMP") {
  int tem = w2.toInt();
  ac.setTemp(tem);
  valid = 1;
  }

if ((w1 == "RESET") || (w1 == "REBOOT")) {
  myBot.sendMessage(my_telegram_id, "REBOOT!");
  w1="";
  //ESP.restart();
  }     

if (valid == 1) {
Serial.println("Sending IR command to A/C ...");
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000);
ac.send();
digitalWrite(LED_BUILTIN, HIGH);
#endif // SEND_TOSHIBA_AC
printState(my_telegram_id);
//myBot.sendMessage(my_telegram_id, "Příkaz poslán.");
}
else
if (cmdsent == 1) myBot.sendMessage(recipient, "Neznámý příkaz!");

delay(5000);

}

//############################## STOP ##################################xx

void logTS(String param1, String param2) {

int cc = client.connect(TSserver,80);
if (cc) {
// vytvoření zprávy, která bude odeslána na Thingspeak
// každé pole je označeno jako "field" + pořadí pole,
// je nutné každý údaj převést na String
String zprava = APIkey;
zprava +="&field1=";
zprava += param1;
zprava +="&field2=";
zprava += param2;
zprava += "\r\n\r\n";
// po vytvoření celé zprávy ji odešleme na server Thingspeak
// včetně našeho API klíče
client.print("POST /update HTTP/1.1\n");
client.print("Host: api.thingspeak.com\n");
client.print("Connection: close\n");
client.print("X-THINGSPEAKAPIKEY: "+APIkey+"\n");
client.print("Content-Type: application/x-www-form-urlencoded\n");
client.print("Content-Length: ");
client.print(zprava.length());
client.print("\n\n");
client.print(zprava);
// vytištění informací po sériové lince o odeslání na Thingspeak
Serial.print("param1: ");
Serial.print(param1);
Serial.print(" param2: ");
Serial.println(param2);
Serial.println("Udaje odeslany na Thingspeak.");
}
else {
ESP.restart();
}
// ukončení spojení se serverem Thingspeak
client.stop();
}

void readAcServer() {
String mac = String(D_Name);
String fwURL = String( fwUrlBase );
fwURL.concat( mac );
String fwVersionURL = fwURL;
fwVersionURL.concat( ".command" );

Serial.println( "Checking for server command." );
Serial.print( "MAC address: " );
Serial.println( mac );
Serial.print( "Command URL: " );
Serial.println( fwVersionURL );

HTTPClient httpClient;
httpClient.begin( fwVersionURL );
int httpCode = httpClient.GET();
if( httpCode == 200 ) {
newCommand = httpClient.getString();

Serial.print( "Available Command: " );
newCommand.toUpperCase();
Serial.println( newCommand );
}

else {
Serial.print( "Command failed, got HTTP response code " );
Serial.println( httpCode );
}
httpClient.end();
return;
}

void connect_to_wifi_jb() {
Serial.println("Setting WiFi connection...");
delay(100);
pinMode(LED_ESP, OUTPUT);
ticker.attach(0.6, tick);
WiFiManager wifiManager;
wifiManager.setConfigPortalTimeout(300);
wifiManager.setConnectTimeout(60);
wifiManager.setAPCallback(configModeCallback);
if (!wifiManager.autoConnect(D_Name)) {
Serial.println("failed to connect and hit timeout");
ESP.reset();
delay(1000);
}
Serial.println("connected...yeey :)");
ticker.detach();
digitalWrite(LED_ESP, LOW);
delay(3000);
digitalWrite(LED_ESP, HIGH);
Serial.print("WiFi.SSID(): ");
Serial.println(WiFi.SSID());
//WiFi.SSID().toCharArray(ssid, 32);
Serial.print("WiFi.psk(): ");
Serial.println(WiFi.psk());
//WiFi.psk().toCharArray(password, 32);
}

void OTAtick() {
//ArduinoOTA.handle();
}

void delayOTA(int duration) { // Use this loop to keep OTA alive
for (int i=0; i <= duration/1000; i++) {
//ArduinoOTA.handle();
delay(1000);
}
}

void blink_led(int which, int cas1, int cas2, int inverse) {
pinMode(which, OUTPUT);
digitalWrite(which, 1-inverse);
delay(cas1);
digitalWrite(which, inverse);
delay(cas2);
}

void tick() {
//toggle state
int state = digitalRead(LED_ESP); // get the current state of GPIO1 pin
digitalWrite(LED_ESP, !state); // set pin to the opposite state
}

//gets called when WiFiManager enters configuration mode
void configModeCallback (WiFiManager *myWiFiManager) {
Serial.println("Entered config mode");
Serial.println(WiFi.softAPIP());
//if you used auto generated SSID, print it
Serial.println(myWiFiManager->getConfigPortalSSID());
//entered config mode, make led toggle faster
ticker.attach(0.2, tick);
}

void checkForUpdates() {
String mac = String(D_Name);
String fwURL = String( fwUrlBase );
fwURL.concat( mac );
String fwVersionURL = fwURL;
fwVersionURL.concat( ".version" );

Serial.println( "Checking for firmware updates." );
Serial.print( "MAC address: " );
Serial.println( mac );
Serial.print( "Firmware version URL: " );
Serial.println( fwVersionURL );

HTTPClient httpClient;
httpClient.begin( fwVersionURL );
//httpClient.begin("http://79......8/files/ESP_c_1.version");
int httpCode = httpClient.GET();
if( httpCode == 200 ) {
String newFWVersion = httpClient.getString();

Serial.print( "Current firmware version: " );
Serial.println( FW_VERSION );
Serial.print( "Available firmware version: " );
Serial.println( newFWVersion );

long newVersion = newFWVersion.toInt();

if( newVersion > FW_VERSION ) {
  Serial.println( "Preparing to update" );
  myBot.sendMessage(my_telegram_id, "Updating to version "+newFWVersion);
  String fwImageURL = fwURL;
  fwImageURL.concat( ".bin" );
  ticker.attach(0.1, tick);
  t_httpUpdate_return ret = ESPhttpUpdate.update( fwImageURL );
  ticker.detach();

  switch(ret) {
    case HTTP_UPDATE_FAILED:
      Serial.printf("HTTP_UPDATE_FAILD Error (%d): %s", ESPhttpUpdate.getLastError(), ESPhttpUpdate.getLastErrorString().c_str());
      myBot.sendMessage(my_telegram_id, "HTTP_UPDATE_FAILD Error: "+ESPhttpUpdate.getLastErrorString());  //+ESPhttpUpdate.getLastError()+", "
      break;

    case HTTP_UPDATE_NO_UPDATES:
      Serial.println("HTTP_UPDATE_NO_UPDATES");
      myBot.sendMessage(my_telegram_id, "HTTP_UPDATE_NO_UPDATES");
      break;
  }
}
else {
  Serial.println( "Already on latest version" );
  myBot.sendMessage(my_telegram_id, "Already on latest version" );
}

}
else {
Serial.print( "Firmware version check failed, got HTTP response code " );
Serial.println( httpCode );
myBot.sendMessage(my_telegram_id, "Firmware version check failed, got HTTP response code "+String(httpCode));
}
httpClient.end();
}

/*
String getMAC()
{
uint8_t mac[6];
char result[14];

snprintf( result, sizeof( result ), "%02x%02x%02x%02x%02x%02x", mac[ 0 ], mac[ 1 ], mac[ 2 ], mac[ 3 ], mac[ 4 ], mac[ 5 ] );

return String( result );
}

int getLght() {

pinMode(PH_VCC, OUTPUT);
pinMode(PH_GND, OUTPUT);
digitalWrite(PH_VCC, HIGH);
digitalWrite(PH_GND, LOW);

//int Light = 1000; //analogRead(A0);
int Light = analogRead(A0);
Serial.print("Light: ");
Serial.println(Light);
delay(50);
pinMode(PH_VCC, INPUT);
pinMode(PH_GND, INPUT);

return Light;
}
*/

Is that possible tho edit the html page ?

I was taking a look at the library files to see if it's possible to translate the texts and cahnge the logo, but the I have no ideia on how to changing the page that was made using some kind of encoding only with numbers.

So I ask, is there a way to edit it ?

By the way, what a amazing library, only one line to do all the job. I was looking for something like that for days.

Thanks for your very good job.

Sorry about my poor english.

Initial AP mode, then option for .bin URL

If this could provide an AP mode initially to allow a user to set the Wifi credentials and .bin path, this firmware would be great to flash to an ESP prior to soldering (via a programming jig).

New page upload not working in OTA

Please share Elegant OTA Page if possible, & please also clear which option we have to choose in File2Raw
Gzip Compress
or
Use PROGMEM (Arduino)

Source for elegantWebpage.h?

Do you make the source for elegantWebpage.h available? It's hard to work with because it was minified. I want to be able to change some styles to match the rest of my project. I'd also like to pass the file name chosen by the user, for validity testing (if the user mixes up firmware and filesystem, OTA will happily try to program the wrong thing.) Check like this:

                int cmd = (filename.indexOf(F(".spiffs.bin")) > -1 ) ? U_SPIFFS : U_FLASH;
                if (cmd == U_FLASH && !(filename.indexOf(F(".esp32.bin")) > -1) ) {
                  debugMsgln(F("OTA bad filename"),1);
                  return; // wrong image for ESP32
                }

Even better would be to change the "accept:" on the file-input to reflect which file type the user selects.

Breaks multi-tab sketches

Issue: Including ElegantOTA.h breaks cross-tab function calls.

To reproduce, use Arduino IDE 1.8.9 (although I doubt that the exact release matters). For a main sketch, use your example ElegantOTA/examples/ESP8266_Demo/ESP8266_Demo.ino
Immediately after the serial begin, add a call to a function in another tab, for example:

void setup(void) {
   Serial.begin(115200);
   setupXYZ();                  // Add this function call
   WiFi.mode(WIFI_STA);
   WiFi.begin(ssid, password);
   Serial.println("");
   ...

Now, add a tab (via the down arrow at the far right of the same line that contains the name of the main tab) , name it anything (without a dot extension), and declare a function in that tab:

void setupXYZ() {
   Serial.print("Setup of xyz complete.");
}

Now compile. The IDE will tell you that "setupXYZ() was not declared in this scope". In more complex call structures, it seems to break everything that is cross-tab, calling out each one as not declared.

Now comment out the "//#include <ElegantOTA.h>" statement (and the later begin statement). Compile again. This time it works. As it should in the Arduino IDE.

Global Variable implemented in the header

Hi! I noticed that the global variable ElegantOtaClass ElegantOTA is declared and implemented in the header file. Implementing such variable in the header basically forces the user to include it in the main ino file, and only there.

I would have expected the standard extern declaration + implementation in the .cpp for a global variable.

Is there a particular reason to do that? I would have considered this a simple oversight but I noticed that many arduino libraries are following this convention and I'm not a microcontroller developer. What is the benefit of forcing the user to include the library's header with a global object in the main file?

Thank you for your answer and your patience.

setID is not working.

have long time using project with ElegantOTA, it works good on ver 2.2.4
Today have decided to add setID() functionality, and find out /update page became stuck, always spinning the circle under the page header. Micro is still working, no crash. Have removed setID() - /update works again.
btw, have updated to newer versions, esp8266 crashed disregarding with no setID() or without, seems like it is another bug.

Have left my project with old 2.2.4 version without setID().
:-(

Update stops midway.

Hello sir, The example code works properly, but when I append that code in my code, the update sticks mid way. Size of my bin file is 3,92,752 bytes. Is there any size limit to use Elegant OTA?

Don't flash when IDs are set.

Hello,

Thank you for your great job!

I found an issue.

I'm with 2.2.6.

I set ID and password on the /update page with this line : AsyncElegantOTA.begin(&server, "admin", "admin"); // Start ElegantOTA

When I flash with the new firmware the update is not set. If I remove the ID and flash, it's working fine.

Thank you for your support. :)

Cannot run it on ESP32 WiFi_AP mode

Hi there!

Thanks for this promising lib but in my case, i need to do ota through async web server and on AP mode only.
No wifi STA enabled on ESP32.
And in header we can see only ESP8266 management. So can we use it on ESP32?

crash on sart

hi,

I've tried to follow the example on this link on my wroom 32 dev board , however after uploading its continue to crash with the following result
ant help really appreciated

ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1240
load:0x40078000,len:13012
load:0x40080400,len:3648
entry 0x400805f8
[�0���$⸮LW+QW⸮Y.\&⸮KZX⸮K,\]⸮,'⸮LLW⸮⸮Y](\]⸮⸮equencyMhz(): PLL: 480 / 2 = 240 Mhz, APB: 80000000 Hz
[    49][D][WiFiGeneric.cpp:808] _eventCallback(): Arduino Event: 0 - WIFI_READY

Brownout detector was triggered


ESP32

Will this work on the esp32 chips?

Custom title on update page

Hi!
I have several devices locally that runs ElegantOTA, but I always have to think twice that I'm looking at the correct update page for the correct device.
What do you think about showing the hostname on the update page or some other String identifier that can be provided at setup of ElegantOTA?

Add Unique Identifier on webpage

It's really confusing for users with multiple ESP8266s as the ElegantOTA looks same on every module.

To overcome this, I will add a unique identifier to the ElegantOTA webpage which would by default point to the ESP Chip ID or if user wants to modify it then there would a function for it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.