Could someone implement a C function for connecing to WLAN with Python?
-
- Posts: 13
- Joined: Thu Oct 11, 2018 4:52 pm
Could someone implement a C function for connecing to WLAN with Python?
Hi,
I was thinking that it would be cool if someone could work on the C function available for connecting to a WPA2 Enterprise network?
i can do a regular WLAN connection over Python, no problem, or, use C as my language to connect to Eduroam, but getting connected to Eduroam over Python would suit my purposes much better. I haven't found a Python way of doing this, but a C function made available for Python would work really well.
Any takers? I am not too well versed in stuff like this and could use a hand in this.
Cheers,
-h.
I was thinking that it would be cool if someone could work on the C function available for connecting to a WPA2 Enterprise network?
i can do a regular WLAN connection over Python, no problem, or, use C as my language to connect to Eduroam, but getting connected to Eduroam over Python would suit my purposes much better. I haven't found a Python way of doing this, but a C function made available for Python would work really well.
Any takers? I am not too well versed in stuff like this and could use a hand in this.
Cheers,
-h.
Re: Could someone implement a C function for connecing to WLAN with Python?
Your request is too vague.
Sent from my iPhone using Tapatalk Pro
Sent from my iPhone using Tapatalk Pro
-
- Posts: 13
- Joined: Thu Oct 11, 2018 4:52 pm
Re: Could someone implement a C function for connecing to WLAN with Python?
Okay, sorry - I was looking for someone to work with over this, but I will explain.
The following code connects ESP32 using the Arduino IDE. I would love to have the code available as a function in Python. I am such a beginner in this that I thought someone probably has done this already.
+++++++++++++++
#include "esp_wpa2.h"
#include <WiFi.h>
const char* ssid = "MY_SSID"; // your ssid
#define EAP_ID "MY_EAP_ID"
#define EAP_USERNAME "MY_EAP_USERNAME"
#define EAP_PASSWORD "MY_EAP_PASSWD"
void setup() {
Serial.begin(115200);
delay(10);
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
// WPA2 enterprise magic starts here
WiFi.disconnect(true);
esp_wifi_sta_wpa2_ent_set_identity((uint8_t *)EAP_ID, strlen(EAP_ID));
esp_wifi_sta_wpa2_ent_set_username((uint8_t *)EAP_USERNAME, strlen(EAP_USERNAME));
esp_wifi_sta_wpa2_ent_set_password((uint8_t *)EAP_PASSWORD, strlen(EAP_PASSWORD));
esp_wpa2_config_t config = WPA2_CONFIG_INIT_DEFAULT();
esp_wifi_sta_wpa2_ent_enable(&config);
// WPA2 enterprise magic ends here
WiFi.begin(ssid);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
++++++++++++++++
So, how does one turn this into a Python module?
Many thanks in advance!
The following code connects ESP32 using the Arduino IDE. I would love to have the code available as a function in Python. I am such a beginner in this that I thought someone probably has done this already.
+++++++++++++++
#include "esp_wpa2.h"
#include <WiFi.h>
const char* ssid = "MY_SSID"; // your ssid
#define EAP_ID "MY_EAP_ID"
#define EAP_USERNAME "MY_EAP_USERNAME"
#define EAP_PASSWORD "MY_EAP_PASSWD"
void setup() {
Serial.begin(115200);
delay(10);
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
// WPA2 enterprise magic starts here
WiFi.disconnect(true);
esp_wifi_sta_wpa2_ent_set_identity((uint8_t *)EAP_ID, strlen(EAP_ID));
esp_wifi_sta_wpa2_ent_set_username((uint8_t *)EAP_USERNAME, strlen(EAP_USERNAME));
esp_wifi_sta_wpa2_ent_set_password((uint8_t *)EAP_PASSWORD, strlen(EAP_PASSWORD));
esp_wpa2_config_t config = WPA2_CONFIG_INIT_DEFAULT();
esp_wifi_sta_wpa2_ent_enable(&config);
// WPA2 enterprise magic ends here
WiFi.begin(ssid);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
++++++++++++++++
So, how does one turn this into a Python module?
Many thanks in advance!
Re: Could someone implement a C function for connecing to WLAN with Python?
If you just need to wrap this existing code and make it available in .py, there's plenty of examples on how to do that.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Could someone implement a C function for connecing to WLAN with Python?
@heikki.hietala What is the aim in rewriting working Python code in C? Performance is almost certainly limited by the network.
So I assume your aim is security. I don't think there is a solution to an attacker with unrestricted access to the hardware. A very limited degree of obfuscation may be achieved by freezing the Python bytecode. This would flummox the average twelve year old; but not a clever one. Even C code will have the credentials stored in plaintext unless you go to lengths to avoid it.
The issue of hiding Python source is a FAQ and a forum search will be informative.
So I assume your aim is security. I don't think there is a solution to an attacker with unrestricted access to the hardware. A very limited degree of obfuscation may be achieved by freezing the Python bytecode. This would flummox the average twelve year old; but not a clever one. Even C code will have the credentials stored in plaintext unless you go to lengths to avoid it.
The issue of hiding Python source is a FAQ and a forum search will be informative.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
-
- Posts: 13
- Joined: Thu Oct 11, 2018 4:52 pm
Re: Could someone implement a C function for connecing to WLAN with Python?
Thanks for the reply. My point is that I have not been able to find a working implementation of Python in connecting to WPA 2 Enterprise network, but this C code does that.
My apologies if this is a null query, but I am stumbling on this now.
My apologies if this is a null query, but I am stumbling on this now.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
How to connect to a WPA2 Enterprise network?
Sorry, I misunderstood. I assumed you'd translated working Python code into C. I think a first step is to ask if anyone has managed to do this in MicroPython. I do wonder whether many people here are in a position to test this.
The alternative is to follow the approach suggested by @jickster.
The alternative is to follow the approach suggested by @jickster.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
-
- Posts: 13
- Joined: Thu Oct 11, 2018 4:52 pm
Re: Could someone implement a C function for connecing to WLAN with Python?
Thanks Peter, I am now checking out the wrapping method and if I crack it, I'll post in github. It seems doable even for a n00b like me.
Re: Could someone implement a C function for connecing to WLAN with Python?
Has this been achieved yet???
-
- Posts: 13
- Joined: Thu Oct 11, 2018 4:52 pm
Re: Could someone implement a C function for connecing to WLAN with Python?
Not by me in any case, I resorted to another network hotspot.