B4R Library esp8266 OTA updater

Hello,

here is my next attempt to write a lib for B4R ;)

The Lib based on the following Libraries (you have to install this bevor you can use this lib):

https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266httpUpdate


i have Testet with the ESP8266 board

regards

Andy

attention: This is a non working example you have to add some code for the versions check and maybe with a timer which will check vor new updates once a day or every hour

You find the .bin file in the folder ..../Objects/bin/ upload this to your webserver.

B4X:
#Region Project Attributes
    #AutoFlushLogs: True
    #CheckArrayBounds: True
    #StackBufferSize: 300
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    Public Serial1 As Serial
    Public ota As ESP8266OTA
    Public wifi As ESP8266WiFi
    
End Sub

Private Sub AppStart
    Serial1.Initialize(115200)
    Log("AppStart")
    wifi.Connect2("<yourssid>","<yourpassword>")
   
    'add here a versioncheck maybe with httpjob and a version.txt file on the server
    dim result as string
    result=ota.HTTPUpdate2("siam-online.de",80,"/dummy/src.ino.bin",True)
    If result <> "success" Then
        Log ("Error: ",result)
    End If


    'add here a versioncheck maybe with httpjob and a version.txt file on the server
    dim result as string
    result=ota.HTTPUpdate("http://siam-online.de/dummy/src.ino.bin",False)
    If result <> "success" Then
        Log ("Error: ",result)
    else
    'you can send here a notification and then restart your esp8266
    ota.ESPRestart
    End If
   
   
End Sub
 

Attachments

  • rESP8266OTA.zip
    1.9 KB · Views: 946
Last edited:

Robert Valentino

Well-Known Member
Licensed User
Longtime User
Want to thank for this library. Works GR8

Only thing would be nicer would be to provide a userid / password to log on before download (but I can live without it)
 

hatzisn

Expert
Licensed User
Longtime User
Hi, @Siam
I tried today for the first time to use your library and I get the error as seen in the attached file...
 

Attachments

  • ErrorOTA20210817.txt
    55.4 KB · Views: 390

peacemaker

Expert
Licensed User
Longtime User
the error as seen in the attached file

Yes, as mine, thanks for test:
B4X:
rESP8266OTA.cpp: In member function 'B4R::B4RString* B4R::B4RESP8266OTA::HTTPUpdate(B4R::B4RString*, bool)':
rESP8266OTA.cpp:15:66: error: no matching function for call to 'ESP8266HTTPUpdate::update(const char*&)'
 

hatzisn

Expert
Licensed User
Longtime User
I have fixed this myself. Here is the new library.
 

Attachments

  • rESP8266OTA.zip
    2 KB · Views: 406

peacemaker

Expert
Licensed User
Longtime User
I have fixed this myself. Here is the new library.

WOW, thanks ! Indeded now compilation is OK.
Latest question - why was it broken (what changed recently) ?
 

hatzisn

Expert
Licensed User
Longtime User
All I did was open the Arduino Example and see how it works. It just needed to declare a WiFiClient object and pass this as first argument in the appropriate function in the voids that @Siam has created.
 
Last edited:

Digitek

Member
Hi, I get the following error:
B4X:
ESP8266httpUpdate.cpp:235:46: error: 'FS_end' was not declared in this scope; did you mean 'va_end'?
  235 |                 size_t spiffsSize = ((size_t)FS_end - (size_t)FS_start);
      |                                              ^~~~~~
      |                                              va_end
ESP8266httpUpdate.cpp:235:63: error: 'FS_start' was not declared in this scope; did you mean 'va_start'?
  235 |                 size_t spiffsSize = ((size_t)FS_end - (size_t)FS_start);
      |                                                               ^~~~~~~~
      |                                                               va_start
 

Digitek

Member
Resolved.
I removed the library suggested in post #1 (ESP8266httpUpdate) leaving the one that comes by default with Arduino.
That library doesn't work.
Thanks for the correction to the B4R library.
 

peacemaker

Expert
Licensed User
Longtime User
Fixed the lib to v.1.2 (no lib version before).
Arduino 2.x compiler is more strict and the non-void C-subs must return corresponding values for sure.
 

Attachments

  • rESP8266OTA_v1.2.zip
    1.9 KB · Views: 111
Top