-
Notifications
You must be signed in to change notification settings - Fork 192
view OTA update status #325
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
Comments
There is no proper way to know that in the current AutoConnect version. |
oks, thanks Hieromon |
@lucho512 I have staged the changes to enhance/v130 branch to help with your wishes, and You can start the evaluation. Also, PageBuilder v1.5.0 is required for evaluation, and I hope you will update the PageBuilder library from the development branch. The sequence for checking OTA status is following:
Addition: Once OTA is started, control does not return from AutoConnect::handleClient to the user sketch until the update is complete. The update process is blocked by the requestHandler of the WebServer class, so the start of the upload process cannot be detected in the usual way. I have another specific proposals. The AutoConnectOTA class is a derivative of AutoConnectAUX, so it is itself a requestHandler for the WebServer class. Since the AutoConnectOTA class can detect the status change of the upload process by the WebServer class, it is possible to call back the function of the user sketch. It is expected to have the following specifications.
AutoConnect::onOTAStatusChange(std::function<void(const AutoConnectOTA::AC_OTAStatus_t)>);
void OTAStatusChanged(const AutoConnectOTA::AC_OTAStatus_t status) {
if (status == AutoConnectOTA::OTA_START) {
// Mask interruption
}
if (status == AutoConnectOTA::OTA_SUCCESS || status == AutoConnectOTA::OTA_FAIL) {
// Unmask interruption
}
}
AutoConnect portal;
AutoConnectConfig config;
...
void OTAStatusChanged(const AutoConnectOTA::AC_OTAStatus_t status) {
if (status == AutoConnectOTA::OTA_START) {
// Mask interruption
}
if (status == AutoConnectOTA::OTA_SUCCESS || status == AutoConnectOTA::OTA_FAIL) {
// Unmask interruption
}
}
void setup() {
config.ota = AC_OTA_BUILTIN;
portal.config(config);
portal.onOTAStatusChange(OTAStatusChanged);
portal.begin();
}
void loop() {
portal.handleClient();
} The API for this callback technique has not yet been implemented, but it may be a more effective approach than the |
Thank you very much Hieromon, I will try it ... Congratulations on the excellent work |
@lucho512 In addition to the getOTA function mentioned above, I have added a new API for callbacks that notify OTA status. You can evaluate it in the development branch as enhance/v130.
If you have no objection to this specification, I will officially release it in AutoConnect v1.3.0. |
@lucho512 I have changed the API for OTA status notifications. It is formed similar to the ArduinoOTA class and has the following interfaces: typedef std::function<void(void)> OTAStartExit_ft;
typedef std::function<void(void)> OTAEndExit_ft;
typedef std::function<void(uint8_t)> OTAErrorExit_ft;
typedef std::function<void(unsigned int, unsigned int)> OTAProgressExit_ft;
void AutoConnect::onOTAStart(OTAStartExit_ft fn);
void AutoConnect::onOTAEnd(OTAEndExit_ft fn);
void AutoConnect::onOTAError(OTAErrorExit_ft fn);
void AutoConnect::onOTAProgress(OTAProgressExit_ft fn); Typical sequence AutoConnet portal;
AutoConnectConfig config;
...
void OTAStart() {
Serial.println("Start updating");
}
void OTAEnd() {
Serial.println("\nEnd");
}
void OTAProgess(unsigned int progress, unsigned int total) {
Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
}
void OTAError(unsigned int error) {
Serial.printf("Error[%u]: ", error);
}
void setup() {
config.ota = AC_OTA_BUILTIN;
portal.config(config);
portal.onOTAStart(OTAStart);
portal.onOTAEnd(OTAEnd);
portal.onOTAProgress(OTAProgress);
portal.onOTAError(OTAError);
portal.begin();
}
void loop() {
portal.handleClient();
} You can evaluate new API with enhance/v130 branch. (Need to PageBuilder v1.5.0) |
Is there a trick or other setting to get I have it set up exactly like you have in the example above, but the OTA... callbacks are never called during a firmware update. Thank you. |
@HankLloydRight The implementation of the exit routine call for OTA in AutoConnect V130 is not sufficient. Until v134, the exit routine is not called during the OTA update. It is a bug. This problem is resolved in AutoConnect v135. I will release it soon, and you can evaluate it with the development branch as enhance/v135. |
Hi @Hieromon,
Also, even more unfortunate, when I compile with 1.3.5, the OTA updates no longer work. At the very end of the update, I get an error message on the HTML update page:
I've attached the DCORE_DEBUG_LEVEL=9 log below at the end of the update. You can see at line 32 (not sure if this is the problem).
I have to do an over-the-wire USB update back to v.1.3.4 to get OTA updates to work again. It's entirely the same code, just one version has Thank you! |
Hello @HankLloydRight ,
Ahh, so the phenomenon has occurred...Sorry to disappoint you. I experienced this phenomenon too during the v1.3.5 test. But, the test location had a weak wireless signal (RSSI about 40%), and when we changed access points, it stopped the phenomenon. Then I stopped finding the cause. I begin a rigorous investigation. Thank you for notifying me. So I have one favor to ask: the arduino core release is 2.0.4, which is ahead, but the latest release of PlatformIO's framework-espressif32, 5.0.0, is still arduino core 2.0.3. The most significant difference between the two is that the revision of ESP-IDF has increased. So, can you verify the same situation where you encountered the problem using arduino core 2.0.4 in the Arduino IDE environment? |
Hi @Hieromon, Processing lolin32 (platform: [email protected]; board: lolin_d32; framework: arduino)
|
@HankLloydRight Thanks for the detailed log. The update process in v1.3.4 was redundant and I thought I had optimized it for the v1.3.5 enhancement. At this time, I had forgotten one thing: the ESP32 TCP stack sometimes behaves strangely. It may be escaped from the event loop with the packet still in the buffer when an incoming interrupt occurs. In that case, the HTTP request handler behaves as if it received empty content. Then, AutoConnect will assume that the update data was interrupted and immediately begin error handling. It was a mistake. I staged a patch to patches/v136 branch. This fix is common to AutoConnectOTA and AutoConnectUpdate. Perhaps you see the consequences of this fix and will feel that the update has slowed down. But it is normal behavior. I would like you to evaluate this fix. In that case, both AutoConnectOTA and AutoConnectUpdate use cases will be more effective for verification. If the results are good, I will release it as v1.3.6. Thank you for your contribution. |
I’m happy to test the v136 patch, but could you please let me know how to tell Platform.io how to select that version? Thank you. |
The following
platform = [email protected]
framework = arduino
board = lolin_d32
lib_extra_dirs = ~/Documents/Arduino/libraries
lib_deps = https://github.com/Hieromon/AutoConnect.git#patches/v136
lib_ldf_mode = chain+
build_flags =
-DAC_DEBUG
-DAC_USE_SPIFFS
-DPB_USE_SPIFFS
-DCORE_DEBUG_LEVEL=4
board_build.filesystem = spiffs
board_build.partitions = min_spiffs.csv
upload_port = COMn
monitor_port = COMn
upload_speed = 921600
monitor_speed = 115200
monitor_filters = esp32_exception_decoder, colorize |
That worked, thank you. And now the OTA firmware updates also are working again with v1.3.6 I still can not get the OTA update/processing functions to work, but that's a super minor, non-critical, issue. Thank you. |
@HankLloydRight Thank you for testing.
Which one still does not work AutoConnectOTA or AutoConnectUpdate? |
I'm not sure how to answer your question. I'm using the code exactly as posted in #325 (comment) |
@HankLloydRight, Roger that. My hasty mistake. I assumed you were using the Update Server together. |
By "update server" I assume you mean the python script? Yes I am totally using that! edit: Ok, totally my misunderstanding. I am using I now understand the difference between the two. And now see the code sample above is only for AutoConnectOTA and not AutoConnectUpdate. I'm very sorry. Is there a way to get this same function, but with AutoConnectUpdate instead?
|
Well...I just checked the AutoConnect documentation and it doesn't mention the description of the AutoConnectUpdate exit routine. Oops. AutoConnect portal(server);
AutoConnectUpdate update;
void exitOTAStart() {
Serial.println("OTA started");
}
void exitOTAProgress(unsigned int amount, unsigned int sz) {
Serial.printf("OTA in progress: received %d bytes, total %d bytes\n", sz, amount);
}
void exitOTAEnd() {
Serial.println("OTA ended");
}
void exitOTAError(uint8_t err) {
Serial.printf("OTA error occurred %d\n", err);
}
void setup() {
Serial.begin(115200);
// Register OTA exit routines
update.onOTAStart(exitOTAStart);
update.onOTAEnd(exitOTAEnd);
update.onOTAProgress(exitOTAProgress);
update.onOTAError(exitOTAError);
update.attach(portal);
portal.begin();
}
void loop() {
} NOTES |
As long as I can use But if you do decide to make the exitOTAProgress function usable without disabling the progress bar on the web page, that would be icing on the cake, but not necessary. Thank you. |
Hi @Hieromon, |
Oh, sorry, @HankLloydRight. It slipped my mind. The AutoConnectUpdate class was implemented by inheriting the HTTPUpdate class from the ESP32 Arduino core; it is HTTPUpdate library that actually calls back the OTA exit routine. AutoConnectUpdate does not trigger a callback. AutoConnectUpdate can support its own exit routine for users like you who stay on ESP Core 1.0.6. But conversely, it is an unintended overridden function for users who have already migrated to ESP Core 2.0.0. It is possible to use the C++ SNIFAE mechanism to determine if the HTTPUpdate class owns members for the OTA exit function and suppress the override by the AutoConnectUpdate class at compile time. This would be my work. Another way is for you to modify the HTTPUpdate library in ESP32 Arduino Core 1.0.6 to implement the equivalent of the callback on OTA exit that the HTTPUpdate class in ESP32 2.0.0 or later has. The implementation of the HTTPUpdate class is not too difficult and I am sure you are skilled enough to make it work. Of course, you could clone and modify the espressif/ardiuno-esp32 repository, but I would not recommend it; it is more reliable to modify the package source carried by PlatformIO directly. They are usually located on the following path: |
Ok, I now see the issue, and yeah, I can't upgrade to Arduino core 2.0.0. I'll dive into this to modify the code when I want a break from "real work" LOL. I'd like to get it working, but as I mentioned, it's not critical. All the best. |
@HankLloydRight I found one mistake too. update.on |
Hi, how can I get the update status, in the program loop
I need to be able to disable interrupts since they block the update
Thanks!!!
The text was updated successfully, but these errors were encountered: