8000 esp32/network_wlan: Add missing WLAN security constants. · micropython/micropython@275b3af · GitHub
[go: up one dir, main page]

Skip to content

Commit 275b3af

Browse files
committed
esp32/network_wlan: Add missing WLAN security constants.
These were added to the `network` module but not the `network.WLAN` class, which is the new home for such constants. Also: - Mark the WLAN constants in the `network` module as deprecated, to be removed in MicroPython 2.0. - Move the static assert to the WLAN source code, to be close to where it relates to. Signed-off-by: Damien George <damien@micropython.org>
1 parent d278ba5 commit 275b3af

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

ports/esp32/modnetwork_globals.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
{ MP_ROM_QSTR(MP_QSTR_phy_mode), MP_ROM_PTR(&esp_network_phy_mode_obj) },
1414
{ MP_ROM_QSTR(MP_QSTR_ipconfig), MP_ROM_PTR(&esp_network_ipconfig_obj) },
1515

16-
#if MICROPY_PY_NETWORK_WLAN
16+
// These WLAN constants are now in the WLAN class and remain here only for backwards compatibility.
17+
#if !MICROPY_PREVIEW_VERSION_2 && MICROPY_PY_NETWORK_WLAN
1718
{ MP_ROM_QSTR(MP_QSTR_STA_IF), MP_ROM_INT(WIFI_IF_STA)},
1819
{ MP_ROM_QSTR(MP_QSTR_AP_IF), MP_ROM_INT(WIFI_IF_AP)},
1920

ports/esp32/network_common.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -337,11 +337,3 @@ static mp_obj_t esp_phy_mode(size_t n_args, const mp_obj_t *args) {
337337
return mp_const_none;
338338
}
339339
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(esp_network_phy_mode_obj, 0, 1, esp_phy_mode);
340-
341-
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 2, 0)
342-
_Static_assert(WIFI_AUTH_MAX == 13, "Synchronize WIFI_AUTH_XXX constants with the ESP-IDF. Look at esp-idf/components/esp_wifi/include/esp_wifi_types.h");
343-
#elif ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 5) && ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 1, 0) || ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 2)
344-
_Static_assert(WIFI_AUTH_MAX == 11, "Synchronize WIFI_AUTH_XXX constants with the ESP-IDF. Look at esp-idf/components/esp_wifi/include/esp_wifi_types.h");
345-
#else
346-
_Static_assert(WIFI_AUTH_MAX == 10, "Synchronize WIFI_AUTH_XXX constants with the ESP-IDF. Look at esp-idf/components/esp_wifi/include/esp_wifi_types.h");
347-
#endif

ports/esp32/network_wlan.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,13 +744,28 @@ static const mp_rom_map_elem_t wlan_if_locals_dict_table[] = {
744744
{ MP_ROM_QSTR(MP_QSTR_SEC_WPA2_WPA3), MP_ROM_INT(WIFI_AUTH_WPA2_WPA3_PSK) },
745745
{ MP_ROM_QSTR(MP_QSTR_SEC_WAPI), MP_ROM_INT(WIFI_AUTH_WAPI_PSK) },
746746
{ MP_ROM_QSTR(MP_QSTR_SEC_OWE), MP_ROM_INT(WIFI_AUTH_OWE) },
747+
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 5) && ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 1, 0) || ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 2)
748+
{ MP_ROM_QSTR(MP_QSTR_SEC_WPA3_ENT_192), MP_ROM_INT(WIFI_AUTH_WPA3_ENT_192) },
749+
#endif
750+
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 2, 0)
751+
{ MP_ROM_QSTR(MP_QSTR_SEC_WPA3_EXT_PSK), MP_ROM_INT(WIFI_AUTH_WPA3_EXT_PSK) },
752+
{ MP_ROM_QSTR(MP_QSTR_SEC_WPA3_EXT_PSK_MIXED_MODE), MP_ROM_INT(WIFI_AUTH_WPA3_EXT_PSK_MIXED_MODE) },
753+
#endif
747754

748755
{ MP_ROM_QSTR(MP_QSTR_PM_NONE), MP_ROM_INT(WIFI_PS_NONE) },
749756
{ MP_ROM_QSTR(MP_QSTR_PM_PERFORMANCE), MP_ROM_INT(WIFI_PS_MIN_MODEM) },
750757
{ MP_ROM_QSTR(MP_QSTR_PM_POWERSAVE), MP_ROM_INT(WIFI_PS_MAX_MODEM) },
751758
};
752759
static MP_DEFINE_CONST_DICT(wlan_if_locals_dict, wlan_if_locals_dict_table);
753760

761+
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 2, 0)
762+
_Static_assert(WIFI_AUTH_MAX == 13, "Synchronize WIFI_AUTH_XXX constants with the ESP-IDF. Look at esp-idf/components/esp_wifi/include/esp_wifi_types.h");
763+
#elif ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 5) && ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 1, 0) || ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 2)
764+
_Static_assert(WIFI_AUTH_MAX == 11, "Synchronize WIFI_AUTH_XXX constants with the ESP-IDF. Look at esp-idf/components/esp_wifi/include/esp_wifi_types.h");
765+
#else
766+
_Static_assert(WIFI_AUTH_MAX == 10, "Synchronize WIFI_AUTH_XXX constants with the ESP-IDF. Look at esp-idf/components/esp_wifi/include/esp_wifi_types.h");
767+
#endif
768+
754769
MP_DEFINE_CONST_OBJ_TYPE(
755770
esp_network_wlan_type,
756771
MP_QSTR_WLAN,

0 commit comments

Comments
 (0)
0