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

BT addon upgrade - timeout too short? #3

Closed
benjaminaigner opened this issue Jul 1, 2021 · 9 comments
Closed

BT addon upgrade - timeout too short? #3

benjaminaigner opened this issue Jul 1, 2021 · 9 comments

Comments

@benjaminaigner
Copy link
Collaborator

On some of the ~25 upgraded FABI modules with the ESP32 addon, the update didn't work as expected from the WebGUI:

BT addon update failed because: OTA:$FIN not received.

I think the problem might be a too tight timeout for receiving "OTA:$FIN". Normally, this wouldn't be the problem, but
AT SR is sent immediately after the timeout, which might break the ESP32 update procedure.

@klues I will give you that exact FABI next time.

@klues
Copy link
Contributor

klues commented Jul 2, 2021

Timeout is 15 seconds, defined here: https://github.com/asterics/Addon-Bluetooth-WebGUI/blob/main/webgui/js/communication/ATDevice.js#L206
You can change it, if you want.
I can also change the behaviour so that AT SR is only sent after a successful upgrade.

@benjaminaigner
Copy link
Collaborator Author

👍 THX for the hint, I will have a look!

@klues
Copy link
Contributor

klues commented Jul 5, 2021

Did you test with a longer timeout? Currently I'm sending AT SR in a finally-block, so in any case in order to restore GUI-functionalities that are dependent on live values. So I think we should just increase the timeout and not change the AT SR behaviour.

What timeout should be sufficient?

@benjaminaigner
Copy link
Collaborator Author

What timeout should be sufficient?
Hard to say, it depends on the binary size and even on the chip revision.

I think your implementation with the finally is the correct choice,
maybe we should increase the timeout. 20s seems very long,
but the GUI is not waiting that long if the "FIN" string is received...

@klues
Copy link
Contributor

klues commented Jul 5, 2021

OK, I've increased it to 20s: 1db2bb8 - should already be live. Why can this take so long, whats happening in the background? In my current test it took about 5 seconds, how could it happen that it sometimes takes >15 seconds? Maybe the transmission speed is a littlebit too fast and so sometimes the upgrade fails and waiting for OTA:FIN runs into a timeout?! See the throttling code here: https://github.com/asterics/Addon-Bluetooth-WebGUI/blob/main/webgui/js/adapter/sercomm.js#L93
I'm sending chunks of 2048 bytes and then waiting for 50ms. These values I've just found out by trial and error.

@klues
Copy link
Contributor

klues commented Jul 5, 2021

Hint: for testing purposes you can open the browser console and run logReceived = true in order to get the received raw values logged and see what response is received where "OTA:FIN" is supposed.

@benjaminaigner
Copy link
Collaborator Author

Hint: for testing purposes you can open the browser console and run logReceived = true in order to get the received raw values logged and see what response is received where "OTA:FIN" is supposed.

THX!

Regarding the transmission size: this could be the problem as well.
I'm sending 128Bytes with 10ms delays:
https://github.com/asterics/esp32_addon_bootloader/blob/b803e2d336759a2793094c209ccb36b7a3e2f7d5/update.py#L38

@klues
Copy link
Contributor

klues commented Jul 6, 2021

OK, then I'll adapt this as well. However your speed is 12,8B/ms and mine is 40,96B/ms - much faster and seems to also work for most cases. So maybe we should use something like 30B/ms?! Do you know what's the limiting factor here?

Edit: Ah, just realized that you're using FABIs and I'm testing with the FLipMouse. So we could simply use two different speeds for both...

@klues
Copy link
Contributor

klues commented Jul 12, 2021

Changed BT upgrade speeds to:

  • FLipMouse: 256B chunk / 10ms pause -> 25,6B/ms
  • FABI: 128B chunk / 10ms pause -> 12,8B/ms

Tested both several times and seemed to work.

Additionally added a global variable which can be used to show the upgrade button, even if BT module version is not found or latest:

  1. open browser console and write showUpgradeButton = true;
  2. go to "Tab General" or switch to other tab and go back to "Tab General" in order to let the variable take effect.

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

No branches or pull requests

2 participants