Giter Site home page Giter Site logo

scottchiefbaker / esp-webota Goto Github PK

View Code? Open in Web Editor NEW
282.0 14.0 38.0 57 KB

Simple web based Over-the-Air (OTA) updates for ESP based projects

License: MIT License

C++ 100.00%
esp32 esp32-arduino ota arduino-library esp esp8266 esp8266-arduino

esp-webota's People

Contributors

albrechtl avatar jamesfowkes avatar leojz avatar scottchiefbaker 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

esp-webota's Issues

Crash when request "GET /webota"

Hi,

Thanks for your great project!

I integrated your source code into my project https://github.com/AlbrechtL/BTT_TF_Cloud_AFW and I ran into the issue that the ESP8266 is crashing when the Web browser is requesting the page GET /webota HTTP/1.1\r\n.

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Exception (3):
epc1=0x4000bf64 epc2=0x00000000 epc3=0x00000000 excvaddr=0x4024d985 depc=0x00000000

>>>stack>>>

ctx: cont
sp: 3ffffce0 end: 3fffffc0 offset: 0190
3ffffe70:  00000001 00000001 3ffffea0 40212a1c  
3ffffe80:  4024d985 3ffffea0 3ffe942c 40212572  
3ffffe90:  3ffffef0 00000001 3fff1e2c 4020717b  
3ffffea0:  3fff1fac 001e001f 00fffed0 40212355  
3ffffeb0:  3ffffef0 3fff08c4 3fff1dec 401000e1  
3ffffec0:  3fff1dec 3fff08c4 3fff1dec 40204cb0  
3ffffed0:  62657700 0061746f 800069be 80ff0b7c  
3ffffee0:  3fff1dec 3fff08c4 3fff0884 40206d86  
3ffffef0:  6265772f 0061746f 87ff2400 0000005f  
3fffff00:  8000746f 4bc6a7f0 000069be 3fff0b7c  
3fffff10:  3fff08c4 00000000 4bc6a7f0 00000001  
3fffff20:  00000001 3fff1dec 40100462 1810624d  
3fffff30:  00000000 3fff08a8 3fff0884 3fff0b7c  
3fffff40:  00000001 3fff08a8 3fff0884 40206edf  
3fffff50:  3fffdad0 00000000 3fff0990 4020df31  
3fffff60:  007a1200 8548d0a7 3fff0500 4020c446  
3fffff70:  3fffdad0 00000000 3fff0530 40206f8b  
3fffff80:  3fffdad0 00000000 3fff0530 402012bc  
3fffff90:  3fffdad0 00000000 3fff0b3c 40100395  
3fffffa0:  3fffdad0 00000000 3fff0b3c 40213620  
3fffffb0:  feefeffe feefeffe 3ffe8584 401002d9  
<<<stack<<<

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Do you have any idea what can be the problem?

Is there a way to auto-reset?

Is there a way to make the ESP32 automatically reset after uploading a file via the OTA webpage?

The uploading is working great, but the ESP32 doesn't automatically reboot for the new binary to take effect, which kind of defeats the purpose of OTA uploads for me as I hoped I could make changes to the firmware once I placed the ESP32 somewhere out of reach...

Suggestion : Check the right firmware

Hi,

You project is very good and I really liked it.
There is one flaw, that is your code doesn't do any check's for the correct firmware. If will update whichever firmware we provide.

Thanks
Venkat

Use with WiFiManager.h

@scottchiefbaker Can your library somehow be used with WiFiManager.h? On an unattached ESP32 it would be good to update and setup Wifi without tethering to a PC.

Please advise.

P.S. Nice work. Worked on the first try!

Having trouble compiling this

Compiling with Arduino application on OSX. Error is obscure so I'm unsure what might be wrong. I'm trying to compile the Primes.ino example.

Users/cms/Documents/Arduino/libraries/ESP-WebOTA-master/src/WebOTA.cpp: In member function 'int WebOTA::init(unsigned int, const char*)':
/Users/cms/Documents/Arduino/libraries/ESP-WebOTA-master/src/WebOTA.cpp:40:22: error: no matching function for call to 'ESP8266WebServer::begin(const unsigned int&)'
  OTAServer.begin(port);
                      ^
/Users/cms/Documents/Arduino/libraries/ESP-WebOTA-master/src/WebOTA.cpp:40:22: note: candidate is:
In file included from /Users/cms/Documents/Arduino/libraries/ESP-WebOTA-master/src/WebOTA.h:4:0,
                 from /Users/cms/Documents/Arduino/libraries/ESP-WebOTA-master/src/WebOTA.cpp:5:
/Users/cms/Library/Arduino15/packages/esp8266/hardware/esp8266/2.3.0/libraries/ESP8266WebServer/src/ESP8266WebServer.h:69:8: note: void ESP8266WebServer::begin()
   void begin();
        ^
/Users/cms/Library/Arduino15/packages/esp8266/hardware/esp8266/2.3.0/libraries/ESP8266WebServer/src/ESP8266WebServer.h:69:8: note:   candidate expects 0 arguments, 1 provided
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

Connection reset by peer

Hello, I was getting a "connection reset by peer" error when uploading the .bin file using curl. I was able to remove it by using --limit-rate 100k.

I am adding this comment in case others experience the same error.

Error updating thru webota (2 different boards tested)

Firmware update initiated: ESP8266_RF433_HUB.ino.nodemcu.bin

Exception (0):
epc1=0x40202798 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

stack>>>

ctx: cont
sp: 3ffff950 end: 3fffffc0 offset: 01a0
3ffffaf0: 3ffee644 3ffee640 3ffee63c 00000100

BUT ESP8266 > Examples > WebUpdate Works

A couple of warnings

These are the ones I'm getting while compiling the sketch.

lib\ESP-WebOTA\src\WebOTA.cpp: In member function 'int WebOTA::handle()':
lib\ESP-WebOTA\src\WebOTA.cpp:61:14: warning: unused variable 'init_run' [-Wunused-variable]
  static bool init_run = false;
              ^
lib\ESP-WebOTA\src\WebOTA.cpp:72:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
lib\ESP-WebOTA\src\WebOTA.cpp: In member function 'int WebOTA::add_http_routes(WebServer*, const char*)':
lib\ESP-WebOTA\src\WebOTA.cpp:198:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
lib\ESP-WebOTA\src\WebOTA.cpp: In function 'int init_wifi(const char*, const char*, const char*)':
lib\ESP-WebOTA\src\WebOTA.cpp:256:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^

question about updating via curl - terminal

I am using the lib 'ESP-Web OTA' in my project, and when I go to do the firmware update via curl through the linux terminal, I find the following error.

I add the following lines to init_wifi()

IPAddress local_ip(192,168,1,46);
IPAddress getway(168,168,1,1);
IPAddress subnet(255,255,0,0);
IPAddress primaryDNS(8,8,8,8);
IPAddress secondaryDNS(8,8,4,4);
if (!WiFi.config(local_ip, getway, subnet, primaryDNS, secondaryDNS)) ESP.restart();

to be able to get it by changing the ip of eps32.

using code in main

#include <WebOTA.h>
#include <Arduino.h>

void setup() {
Serial.begin(115200);
init_wifi("LAb", "test123", "esp-ota");
}

void loop() {
webota.handle();
}

image

I did several tests and found that it only works if the ip of the esp32 is 192.168.1.* , when changing the ip of the esp32 does not work with the error 'Timeout for connection'.

I would like to know how to fix this in my code, if I'm doing something wrong.

ESP-01 ?

Hi!
I'm using a ESP-01 board with a slightly modified usb-serial adapter like
https://www.amazon.de/AZDelivery-ESP8266-ESP-01-USB-Adapter-Arduino/dp/B078J7LDLY
to upload sketches.

So usually I upload a new firmware by serial connection to a ESP-01 board. After I had some really good experiences with WebOTA on Wemos D1 boards, I also wanted to give it a try on a ESP-01 board. So I made this basic sketch:

`
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <WebOTA.h>

void setup() {
delay(2000);
pinMode(LED_BUILTIN, OUTPUT);
WiFi.mode(WIFI_STA);
WiFi.begin("", ""); //insert your wifi credentials
while (WiFi.status() != WL_CONNECTED) {
digitalWrite(LED_BUILTIN, HIGH);
delay(100);
digitalWrite(LED_BUILTIN, LOW);
delay(100);
}
webota.init(8888, "/update");
}

void loop() {
digitalWrite(LED_BUILTIN, HIGH);
webota.handle();
delay(500);
digitalWrite(LED_BUILTIN, LOW);
webota.handle();
delay(500);
}
`

Now I can access the webOTA interface on :8888/update and upload a new "firmware.bin" . Right after reaching 100% nothing happens anymore. I have to update by the serial interface to make the ESP-01 work again.

I watched the build output for the serial interface saying it's uploading a compressed file:

`Looking for upload port...
Auto-detected: COM7
Uploading .pioenvs\esp01_1m\firmware.bin
esptool.py v2.6
Serial port COM7
Connecting....
Chip is ESP8266EX

Features: WiFi
MAC: b4:e6:2d:29:46:eb
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 1MB
Compressed 318688 bytes to 226708...
Wrote 318688 bytes (226708 compressed) at 0x00000000 in 28.0 seconds (effective 91.0 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
[SUCCESS] Took 33.90 seconds`

Could it be I have to upload a compressed firmware.bin ? I'm really sorry for beeing such a noob :(
Do you have a hint for me?

Kind regards MM82

Use WebOTA in FreeRTOS ?

That's not an issue but a question.
I've used your code in several projects and would like to use it also on a new one I've borrowed around ( an energy monitor for the house ).
Difference this time is that the project use FreeRTOS and works with tasks and not the usual loop.
I was wondering if you or someone has never thougth to use this code in a FreeRTOS environment.

Thanks for your code and thanks for your time :)

Interrupt block update?

Do interrupts block the update? It looks like they do

Could you add noInterrupts and interrupts to your code or provide some form of callback like the ArduinoOTA.onStart ?

Flash config wrong real: 1048576 IDE: 4194304

I have worked on this problem all day today. I have tried different IDE configurations, clearing flash, loading via different methods and non of them solved this issue. It was working fine and now it won't work on any of my devices. The only way I can get code to modify is to use esptool. If you have any suggestions, I am open to anything.

UPDATE

After working on this for another day, I finally found a workaround for it. I compiled and uploaded your basic OTA sketch on one of my RPI. Once that completed successfully I opened a browser and used the OTA and uploaded the bin file that would not load. This worked and now all of my devices are able to perform OTA's. I had two that wouldn't work and the rest where fine. I thought it might be helpful to post this in case someone in the future has the same issue.

TIA
Menu
Chip
Errors

Error in math using millis & delay

See this post someone put on reddit about using math to compare millis():
https://old.reddit.com/r/esp32/comments/g0jqux/being_stupid/fnbznvj/

This function incorrectly uses a signed number for 'last':

void WebOTA::delay(int ms) {
int last = millis();

while ((millis() - last) < ms) {
	OTAServer.handleClient();
	::delay(5);
}

}

The math involving wraparound as millis() increments to its largest possible value and goes back to zero only works if you do math using the exact same size and type of variables as the type and size returned by the function millis();

This can be challenging because you have to know the type and size of the millis(); function and hope it doesn't change between ESP8266 and ESP32 or whatever future platform you reuse this code on.

The best way to do it is to use the C built in method:

decltype(millis()) last = millis();

This ensures 'last' is the same size and type as the return value of millis, and that ensures this comparison always works, even if millis() rolls over to zero and starts counting up again during the interval:
(millis() - last) < ms)

https://en.cppreference.com/w/cpp/language/decltype

[[ Also, while not a bug, it's better to used 'unsigned int' for things that can't be negative. The argument to your delay function is better off as just an 'unsigned int'. ]]

Thanks.

Cannot easily distinguish between WebOTA installations

With several ESP32s running WebOTA on the same network, the only way to distinguish them is by IP address.

It would be useful to have a way to customise the HTML, such that the ESP32 can be identified uniquely by name.

There's lots of ways to do this, I wondered what your thoughts were about the idea, and the best way to implement it, if you think it would be useful.

Identifier on web page

Not really and issue but an enhancement request:

Would it be possible to add some sort of identifier on the web page, so when the WebOTA web page is up, and about to load code to an ESP board, you could identify the particular ESP board you are about to update ?? I have several ESP processors running in a system, and it would be very helpful, in the Arduino IDE, to pass an identifying name to that particular instance of WebOTA. In this way, you would know you are about to update the correct board. TIA !!

Examples won't compile properly with Arduino IDE 2.1.1

Get the following error when compiling examples or my own code (which compiled fine last year):

/Users/darylrm/Documents/Arduino/sketch_jul18b/sketch_jul18b.ino: In function 'void loop()':
/Users/darylrm/Documents/Arduino/sketch_jul18b/sketch_jul18b.ino:36:5: error: 'webota' was not declared in this scope
     webota.handle();
     ^~~~~~

exit status 1

Compilation error: 'webota' was not declared in this scope

ethernet

Hi Scott! I am really impressed with this library and use it in all my projects. Your library only uses wifi connections. is it possible to add ethernet as well?

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.