B4R Library esp8266 OTA updater

Discussion in 'B4R Libraries' started by Siam, Jan 11, 2019.

  1. Siam

    Siam Active Member Licensed User

    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.

    Code:
    #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
     

    Attached Files:

    Last edited: Jan 13, 2019
    Pencil3, Erel, rbghongade and 4 others like this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice