-
-
Notifications
You must be signed in to change notification settings - Fork 107
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
fix WiFi TxPower, plus a ton of other refactoring #1615
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a lot of code moved within the change commits, difficult to find and review the new code.
The tx-auto seems to give very low results, i get on the router rssi < -70 dbM receive from ems-esp with datarate <10Mbit/s. . log is Recommended set WiFi Tx Power (set_power 4, new power 8, rssi -530, threshold -690
I think we should set the auto to tx-power resulting in ~-65dBm (or higher) in the router to have 150mBit/s connection. (For me this needs ~ 11dBm tx-power ( giving rssi -67dBm, 135 mBit/s).
p = WIFI_POWER_7dBm; | ||
else if (set_power >= 5) | ||
p = WIFI_POWER_5dBm; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This table set a too low value, e.g. if calculated min is 12.5dBm it sets 11, this results in very low connection rates.
It should set 11dBm for calculate of >8.5 <=11, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that would explain the low values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, partly. I tested now with:
int threshold = WIFI_SENSITIVITY_n + 70; // Margin in dBm * 10 on top of threshold
(goal -65 dBm -> threshold 650)
and
wifi_power_t p = WIFI_POWER_2dBm;
if (min_tx_pwr > 185)
p = WIFI_POWER_19_5dBm;
else if (min_tx_pwr > 170)
p = WIFI_POWER_18_5dBm;
else if (min_tx_pwr > 150)
p = WIFI_POWER_17dBm;
else if (min_tx_pwr > 130)
p = WIFI_POWER_15dBm;
else if (min_tx_pwr > 110)
p = WIFI_POWER_13dBm;
else if (min_tx_pwr > 85)
p = WIFI_POWER_11dBm;
else if (min_tx_pwr > 70)
p = WIFI_POWER_8_5dBm;
else if (min_tx_pwr > 50)
p = WIFI_POWER_7dBm;
else if (min_tx_pwr > 20)
p = WIFI_POWER_5dBm;
(using min_tx_power for the limits with decimals)
now i get tx_power 11 dBm and connection rate of 80-130 MBit/s, so i think lower limit of usefll setting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I'll make those changes and test locally.
I noticed I broke the eventStreaming so will need to look into that |
fixed. |
with the latest changes a few days ago I managed to squeeze out 3-4KB extra heap, now it seems to have gone back. So now I need to trace back in the code what caused it. When that's done I'll merge this PR |
added harcoded dBm values into Web's Network Settings page along with an extra setting called Auto which picks the lowest Wifi TX power based on the RSSI value. This is calculated and set after the WiFi has connected (STA); as before, it was never called. The idea is to save on power and reduce interference in noisy areas. Not sure if it's needed or if it works, but I stole the idea from Tasmota and ESPEasy.
I also fixed a bug where settings did not persist when a Restart was required.
-- EDIT --
I should really have done this in a new PR, but anyway...I've added a few more changes inspired by @kam821
thanks to @kam821. Changes taken from:
kam821@d265ab8
kam821@ed3ea06
kam821@2225aa4