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.
Support for WPA2 EAP networks.
Re: Support for WPA2 EAP networks.
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);
Code: Select all
{ MP_ROM_QSTR(MP_QSTR_seteap), MP_ROM_PTR(&esp_seteap_obj) },
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.
Re: Support for WPA2 EAP networks.
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.
Also I would submit a PR but I don't know how to add the proper checks around the inputs yet.
Re: Support for WPA2 EAP networks.
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.
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 (47.35 KiB) Viewed 5398 times
Re: Support for WPA2 EAP networks.
Unfortunately no library exists. I was going to try and make a library using the new features that allow C modules to be compiled as libraries but unfortunately they can't use ESP IDF functions not defined in the one table. So your stuck with modifying Micropython itself.
Re: Support for WPA2 EAP networks.
In a previews build (v4.0?) we were able to build using chbill modifications to the modnetwork.c
file and were able to connect using a username and password pair without a certificate.
But are getting build errors....
Not at all proficient with C and help would be appreciated!!
PYCOM has the ability to connect to Enterprise networks...
https://docs.pycom.io/tutorials/network ... se-network
scroll down to... Connecting to a WPA2-Enterprise network
They have the ability to connect using (or not using) CA certificates.
QUESTION....
Does micropython have plans in adding WPA2-Enterprise support any time soon ???
file and were able to connect using a username and password pair without a certificate.
We are now trying to build using... esp-idf v4.2, lv_micropython dev using micropython v1.14.
But are getting build errors....
Code: Select all
o-old-style-declaration -D_GNU_SOURCE -DIDF_VER=\"v4.2\" -DLV_KCONFIG_IGNORE -DLV_COLOR_DEPTH=16 -DLV_COLOR_16_SWAP=1 -DESP_PLATFORM -Wno-clobbered -Wno-deprecated-declarations -Wno-missing-field-initializers -MD -MT esp-idf/main/CMakeFiles/__idf_main.dir/__/modnetwork.c.obj -MF esp-idf/main/CMakeFiles/__idf_main.dir/__/modnetwork.c.obj.d -o esp-idf/main/CMakeFiles/__idf_main.dir/__/modnetwork.c.obj -c ../modnetwork.c
../modnetwork.c: In function 'esp_seteap':
../modnetwork.c:379:20: error: implicit declaration of function 'esp_wifi_sta_wpa2_ent_set_identity'; did you mean 'esp_wifi_sta_get_ap_info'? [-Werror=implicit-function-declaration]
ESP_EXCEPTIONS(esp_wifi_sta_wpa2_ent_set_identity((uint8_t *)EAP_IDENTITY, strlen(EAP_IDENTITY))); // identity==username
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../modnetwork.c:116:47: note: in definition of macro 'ESP_EXCEPTIONS'
#define ESP_EXCEPTIONS(x) do { esp_exceptions(x); } while (0);
^
../modnetwork.c:380:20: error: implicit declaration of function 'esp_wifi_sta_wpa2_ent_set_username'; did you mean 'esp_wifi_set_storage'? [-Werror=implicit-function-declaration]
ESP_EXCEPTIONS(esp_wifi_sta_wpa2_ent_set_username((uint8_t *)EAP_IDENTITY, strlen(EAP_IDENTITY)));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../modnetwork.c:116:47: note: in definition of macro 'ESP_EXCEPTIONS'
#define ESP_EXCEPTIONS(x) do { esp_exceptions(x); } while (0);
^
../modnetwork.c:382:20: error: implicit declaration of function 'esp_wifi_sta_wpa2_ent_set_password'; did you mean 'esp_wifi_set_max_tx_power'? [-Werror=implicit-function-declaration]
ESP_EXCEPTIONS(esp_wifi_sta_wpa2_ent_set_password((uint8_t *)EAP_PASSWORD, strlen(EAP_PASSWORD)));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../modnetwork.c:116:47: note: in definition of macro 'ESP_EXCEPTIONS'
#define ESP_EXCEPTIONS(x) do { esp_exceptions(x); } while (0);
^
../modnetwork.c:383:20: error: implicit declaration of function 'esp_wifi_sta_wpa2_ent_enable'; did you mean 'esp_wifi_set_event_mask'? [-Werror=implicit-function-declaration]
ESP_EXCEPTIONS(esp_wifi_sta_wpa2_ent_enable());
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../modnetwork.c:116:47: note: in definition of macro 'ESP_EXCEPTIONS'
#define ESP_EXCEPTIONS(x) do { esp_exceptions(x); } while (0);
^
cc1: some warnings being treated as errors
[1241/1371] Building C object esp-idf/main/CMakeFiles/__idf_main.dir/__/mpthreadport.c.obj
ninja: build stopped: subcommand failed.
ninja failed with exit code 1
make: *** [Makefile:24: all] Error 2
make: Leaving directory '/home/rich/2021-Frimware/lv_micropython/ports/esp32'
PYCOM has the ability to connect to Enterprise networks...
https://docs.pycom.io/tutorials/network ... se-network
scroll down to... Connecting to a WPA2-Enterprise network
They have the ability to connect using (or not using) CA certificates.
QUESTION....
Does micropython have plans in adding WPA2-Enterprise support any time soon ???
Re: Support for WPA2 EAP networks.
Okay so I found that for some reason I can't include "esp_wpa2.h" which has to be included for this to work. For some reason CMake can't find the file thats inside of the ESP-IDF.
I am going to hunt around and figure it out, I will even move those files to the build path maybe if I have to.
I am going to hunt around and figure it out, I will even move those files to the build path maybe if I have to.
Re: Support for WPA2 EAP networks.
Did you get this to work