Support for WPA2 EAP networks.

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
chibill
Posts: 25
Joined: Thu Oct 31, 2019 10:44 pm

Support for WPA2 EAP networks.

Post by chibill » Thu Nov 07, 2019 8:22 pm

I wanted to connect to a WPA2 EAP network (Eduroam) and found that micropython could not Because I was able to from C I knew I could write a new function into the network library to set up WPA EAP.

Right now my function is definitely a very dirty hack as I don't bother checking the types of the mp_objects I also don't know what sort of state information might be worth saving.

I will most the code for the function when I get home. While I would definitely not want to put that function into micropython as it stands it could start as a base for someone who knows their way around micropython's internals more.

chibill
Posts: 25
Joined: Thu Oct 31, 2019 10:44 pm

Re: Support for WPA2 EAP networks.

Post by chibill » Thu Nov 07, 2019 8:35 pm

Code: Select all

//Set up EAP
STATIC mp_obj_t esp_seteap(mp_obj_t self_in,mp_obj_t username,mp_obj_t password){
    size_t Ilen;
    size_t Plen;
    const char *EAP_IDENTITY = mp_obj_str_get_data(username,&Ilen);
    const char *EAP_PASSWORD = mp_obj_str_get_data(password,&Plen);
    ESP_EXCEPTIONS(esp_wifi_sta_wpa2_ent_set_identity((uint8_t *)EAP_IDENTITY, strlen(EAP_IDENTITY)));
    ESP_EXCEPTIONS(esp_wifi_sta_wpa2_ent_set_username((uint8_t *)EAP_IDENTITY, strlen(EAP_IDENTITY)));
    //ESP_EXCEPTIONS(esp_wifi_sta_wpa2_ent_set_new_password((uint8_t *)EAP_PASSWORD, strlen(EAP_PASSWORD)));
    ESP_EXCEPTIONS(esp_wifi_sta_wpa2_ent_set_password((uint8_t *)EAP_PASSWORD, strlen(EAP_PASSWORD)));
    ESP_EXCEPTIONS(esp_wifi_sta_wpa2_ent_enable());
    return mp_const_none;
}

STATIC MP_DEFINE_CONST_FUN_OBJ_3(esp_seteap_obj, esp_seteap);
then add

Code: Select all

{ MP_ROM_QSTR(MP_QSTR_seteap), MP_ROM_PTR(&esp_seteap_obj) },
to the wlan_if_locals_dict_table

It makes a new function that takes your username and password that are used for connecting. I am not sure exactly when you would call it to connect but I have had success calling it both before and after activating the interface but always before trying to connect.

chibill
Posts: 25
Joined: Thu Oct 31, 2019 10:44 pm

Re: Support for WPA2 EAP networks.

Post by chibill » Wed Feb 26, 2020 9:55 pm

Want to bring attention back up to this. As adding PEAP support would help micropython be used in some academic environments more easily.

Also I would submit a PR but I don't know how to add the proper checks around the inputs yet.

PM-TPI
Posts: 31
Joined: Fri Jun 28, 2019 3:09 pm

Re: Support for WPA2 EAP networks.

Post by PM-TPI » Wed Oct 07, 2020 8:05 pm

We have a project in development that is now required to have WPA2-Enterprise encryption.
I see the Arduino, Pycom and CircuitPython have this ability.
Has anyone ever seen a library available for micropython?
This is required for most commercial networks and I would hope that micropython would including this connectivity.
Attachments
2020-10-07 16_01_50-adafruit_esp32spi — Adafruit ESP32SPI Library 1.0 documentation.png
2020-10-07 16_01_50-adafruit_esp32spi — Adafruit ESP32SPI Library 1.0 documentation.png (47.35 KiB) Viewed 206 times

Post Reply