mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-10-26 22:10:45 +00:00
[WiFi] Fix wrong sign check in set TX power (ESP32)
This commit is contained in:
1 parent
050017b2b0
commit
02b8acc73e
1 file changed
+3
-3
@@ -403,8 +403,6 @@ WiFiConnectionProtocol doGetConnectionProtocol()
|
|||||||
void doSetWiFiTXpower(float& dBm)
|
void doSetWiFiTXpower(float& dBm)
|
||||||
{
|
{
|
||||||
if (WiFi.STA.started() || WiFi.AP.started()) {
|
if (WiFi.STA.started() || WiFi.AP.started()) {
|
||||||
int8_t power = std::min(static_cast<int>(dBm * 4), static_cast<int>(WIFI_POWER_21dBm));
|
|
||||||
|
|
||||||
constexpr wifi_power_t options[] = {
|
constexpr wifi_power_t options[] = {
|
||||||
WIFI_POWER_21dBm,
|
WIFI_POWER_21dBm,
|
||||||
WIFI_POWER_20_5dBm,
|
WIFI_POWER_20_5dBm,
|
||||||
@@ -423,8 +421,10 @@ void doSetWiFiTXpower(float& dBm)
|
|||||||
WIFI_POWER_MINUS_1dBm
|
WIFI_POWER_MINUS_1dBm
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int8_t power = std::min(static_cast<int>(dBm * 4), static_cast<int>(options[0]));
|
||||||
|
|
||||||
for (size_t i = 0; i < NR_ELEMENTS(options); ++i) {
|
for (size_t i = 0; i < NR_ELEMENTS(options); ++i) {
|
||||||
if (power <= options[i]) {
|
if (power >= options[i]) {
|
||||||
power = options[i];
|
power = options[i];
|
||||||
esp_wifi_set_max_tx_power(power);
|
esp_wifi_set_max_tx_power(power);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user