Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not message after update OTA #1202

Open
Opticcenter opened this issue Dec 12, 2015 · 10 comments
Open

Not message after update OTA #1202

Opticcenter opened this issue Dec 12, 2015 · 10 comments

Comments

@Opticcenter
Copy link

Opticcenter commented Dec 12, 2015

Sketch code

/**
 * httpUpdate.ino
 *
 *  Created on: 27.11.2015
 *
 */

#include <Arduino.h>

#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>

#include <ESP8266HTTPClient.h>
#include <ESP8266httpUpdate.h>

#define USE_SERIAL Serial

ESP8266WiFiMulti WiFiMulti;

const char* ssid = "*******";
const char* password = "************";


void setup() {

    USE_SERIAL.begin(115200);
    //USE_SERIAL.setDebugOutput(true);

    USE_SERIAL.println();
    USE_SERIAL.println();
    USE_SERIAL.println();

    for(uint8_t t = 4; t > 0; t--) {
        USE_SERIAL.printf("[SETUP] WAIT %d...\n", t);
        USE_SERIAL.flush();
        delay(1000);
    }
    WiFiMulti.addAP(ssid, password);
}

void loop() {
    // wait for WiFi connection
    if((WiFiMulti.run() == WL_CONNECTED)) {

        t_httpUpdate_return ret = ESPhttpUpdate.update("http:https://192.168.1.39/OTA/httpUpdate.cpp.bin");
        //t_httpUpdate_return  ret = ESPhttpUpdate.update("https://server/file.bin");

        //USE_SERIAL.println(ret);

        USE_SERIAL.println("Finish Update");
        USE_SERIAL.println(ret);

        switch(ret) {
            case HTTP_UPDATE_FAILED:
                USE_SERIAL.println("HTTP_UPDATE_FAILED");
                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;
        }
    }
}

output console serial port

[SETUP] WAIT 4...
[SETUP] WAIT 3...
[SETUP] WAIT 2...
[SETUP] WAIT 1...

 ets Jan  8 2013,rst cause:2, boot mode:(3,7)

load 0x4010f000, len 1264, room 16 
tail 0
chksum 0x42
csum 0x42
@cp:0
ld

Why not message 'Update finish' ?

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@Links2004
Copy link
Collaborator

if the update was success the module will be reboot to the new firmware.
I plan to add a option to allow to change this behavior.

@Opticcenter
Copy link
Author

How to receive messages about the status of the update?
Update OK
Not Update
Update Failed
?

@Links2004
Copy link
Collaborator

its only reboots when the update is ok,
if there is no update or it failed you will get the return value.

@yeralin
Copy link

yeralin commented Dec 12, 2015

@Links2004 Little bit off topic. But can you take a look at this issue please? #1156 I've been waiting for response for 7 days already. Thank you

@marvinroger
Copy link
Contributor

@Links2004 yeah, adding an option to not reboot automatically would be great, I need to run some code (EEPROM-related) before rebooting. Furthermore, it is easy to do, as the handleUpdate already have a reboot parameter.

@Links2004
Copy link
Collaborator

yes the handleUpdate reboot change where the preparation for this ;)

@marvinroger
Copy link
Contributor

But where to put the parameter? The update function is already quite-heavy in terms of parameters. After https?

@Links2004
Copy link
Collaborator

i need add it on the end or it will break all existing code.
and yes it will be the ~7 parameter.

@marvinroger
Copy link
Contributor

Great! We will need to update the docs / examples too. Thanks btw ;)

@baruch
Copy link
Contributor

baruch commented Mar 25, 2016

I added a pull request #1817 to add a callback when an update actually starts, i.e. after it was verified that a new file exists and the server says to update the code and just before downloading begins. All other stages except for the pre-reboot can be done easily by printing before and after the function call and during the update all tcp and udp connections besides the one for the update are suspended anyway so progress in the middle cannot be sent.

If restart is not done automatically you can then also send a notification after the function completed and you go on to restart yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants