prusa3d / Prusa-ESP-Nic-FW

ESP8266 as generic network interface over UART
15 stars 10 forks source link

Auto-reduce TX power when the ESP can't connect #11

Closed CarlosGS closed 1 year ago

CarlosGS commented 1 year ago

Patch for https://github.com/prusa3d/Prusa-Firmware-Buddy/issues/2303 until Espressif solves https://github.com/espressif/ESP8266_RTOS_SDK/issues/1200 :)

Kept it simple: First connection attempt is at normal power, subsequent ones at a reduced power. In the rare case the first connection was unsuccessful but we needed the full power, this still happens every time the Buddy board resets the ESP (each ~60 seconds until connection success).

Note the reduced TX power looks very low, but this is because the B/G/N standards already have different maximum levels. For example 802.11n is max 14dB, 13dB struggled so I kept 12dB. Special thanks to @TD-er for his invaluable help!

TD-er commented 1 year ago

Very curious if it is the "magical fix" for all units, or maybe you may need to go even a few steps lower on some boards due to tolerances. N.B. As extra tricks you can also force to go 802.11g only, which gives you some extra head room in keeping a stable connection with lower RSSI values.

Switching to 802.11g may also help when you see WiFi connection issues on modern (and more high end) access points which try really hard to evenly distribute WiFi clients among other APs via WiFi mesh.

CarlosGS commented 1 year ago

In this case for tuning TX power I placed a large piece of metal right behind the antenna, tried to make a worse case than mounted on the printer. Really it's a conservative value to solve this in a simple way until Espressif can solve the bug within the SDK. But I agree it would be great if we can confirm this fixes it for all affected users!

CarlosGS commented 1 year ago

Hi Prusa devs! Seeing https://github.com/prusa3d/Prusa-Firmware-Buddy/issues/2781 & https://github.com/prusa3d/Prusa-Firmware-Buddy/issues/2772 it may be better to simply reduce TX power for all users until Espressif patches RTOS SDK.

It would also be possible to add a "low power" manual option, but IMHO the range change isn't that much and we really want to ensure a reliable connection. I think in cases where the router is far away, it is far easier for people to add a repeater than to start scrutinizing ESP8266 modules or tinkering with additional settings.

I've made that PR https://github.com/prusa3d/Prusa-ESP-Nic-FW/pull/12 too so you can choose between either implementations. Looking forward to closing this once and for all! :)

vorner commented 1 year ago

Hello.

First, let me apologize for not noticing the issues and the pull request. Apparently, our internal processes for handing these things from the L1 helpdesk to development needs some improvement. Also, this must be incredibly hard to discover what's happening.

We'll do some testing on our side and see how soon we are able to release it.

TD-er commented 1 year ago

@vorner Please also read the linked issues preceiding this PR as @CarlosGS and I have been discussing these WiFi issues at length, which eventually resulted in this PR.

vorner commented 1 year ago

Yes, I did. That's why I say it must have been hard to discover.

vorner commented 1 year ago

So far we have seen no issues introduced by this (we can't confirm this fixes the original issue, as we didn't encounter it, but seems like multiple users seem to benefit).

Thank you once more for the finding, I'm going to incorporate it properly now (not the ad-hoc way thrown together between the weekend).

CarlosGS commented 1 year ago

Thanks too for looking into this, I hope it helps. And big thanks to @TD-er 😃 Let's see if the affected users confirm it works with the next release!

BTW truly awesome work with wifi and Prusa Connect, I really like the integrated solution, it is very convenient 👍

leitcode commented 1 year ago

I have exactly the same issue as described here. Is there a binary available with this fix, which I can use for testing?

CarlosGS commented 1 year ago

Hi @leitcode, they said it would be merged soon, hopefully it will :) However if you want to try it here are the instructions: https://github.com/prusa3d/Prusa-Firmware-Buddy/issues/2303#issuecomment-1294731222 (note you'll also need to flash the exact version of the beta firmware). That's what I've been using all this time and works perfectly for me. Good luck!

leitcode commented 1 year ago

Hi @CarlosGS thanks a lot for the quick reply. Will test it and give feedback later.