Page 1 of 1

Support for WPA2 EAP networks.

Posted: Thu Nov 07, 2019 8:22 pm
by chibill
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.

Re: Support for WPA2 EAP networks.

Posted: Thu Nov 07, 2019 8:35 pm
by chibill

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.