From 76f2e3e62bd2bc177a62649bae34b67d9bd2c8b1 Mon Sep 17 00:00:00 2001 From: glenn20 Date: Sun, 31 Jul 2022 18:17:40 +1000 Subject: [PATCH] esp32/network_wlan: Add support to set/get the wifi protocol. Add 'protocol' option to WLAN.config() to support setting/getting the wifi protocol modes: MODE_11G|MODE_11G|MODE_11N. --- ports/esp32/network_wlan.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ports/esp32/network_wlan.c b/ports/esp32/network_wlan.c index 501dc40f27..4f74262afc 100644 --- a/ports/esp32/network_wlan.c +++ b/ports/esp32/network_wlan.c @@ -490,6 +490,10 @@ STATIC mp_obj_t network_wlan_config(size_t n_args, const mp_obj_t *args, mp_map_ esp_exceptions(esp_wifi_set_max_tx_power(power)); break; } + case MP_QSTR_protocol: { + esp_exceptions(esp_wifi_set_protocol(self->if_id, mp_obj_get_int(kwargs->table[i].value))); + break; + } default: goto unknown; } @@ -578,6 +582,12 @@ STATIC mp_obj_t network_wlan_config(size_t n_args, const mp_obj_t *args, mp_map_ val = mp_obj_new_float(power * 0.25); break; } + case MP_QSTR_protocol: { + uint8_t protocol_bitmap; + esp_exceptions(esp_wifi_get_protocol(self->if_id, &protocol_bitmap)); + val = MP_OBJ_NEW_SMALL_INT(protocol_bitmap); + break; + } default: goto unknown; }