Skip to content

Commit

Permalink
esp32/network_wlan: Support setting/getting txpower in WLAN.config().
Browse files Browse the repository at this point in the history
  • Loading branch information
wemos authored and dpgeorge committed Apr 22, 2022
1 parent 2a08e38 commit ff28d2e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ports/esp32/network_wlan.c
Expand Up @@ -461,6 +461,11 @@ STATIC mp_obj_t network_wlan_config(size_t n_args, const mp_obj_t *args, mp_map_
conf_wifi_sta_reconnects = (reconnects == -1) ? 0 : reconnects + 1;
break;
}
case MP_QSTR_txpower: {
int8_t power = (mp_obj_get_float(kwargs->table[i].value) * 4);
esp_exceptions(esp_wifi_set_max_tx_power(power));
break;
}
default:
goto unknown;
}
Expand Down Expand Up @@ -537,6 +542,12 @@ STATIC mp_obj_t network_wlan_config(size_t n_args, const mp_obj_t *args, mp_map_
int rec = conf_wifi_sta_reconnects - 1;
val = MP_OBJ_NEW_SMALL_INT(rec);
break;
case MP_QSTR_txpower: {
int8_t power;
esp_exceptions(esp_wifi_get_max_tx_power(&power));
val = mp_obj_new_float(power * 0.25);
break;
}
default:
goto unknown;
}
Expand Down

0 comments on commit ff28d2e

Please sign in to comment.