pico-examples icon indicating copy to clipboard operation
pico-examples copied to clipboard

tcp_server example always get bad auth error with WPA2/AES

Open Claghorn opened this issue 1 year ago • 1 comments

I built the tcp_server example (the background version, not the poll version) with double and triple checked SSID and password and the connect always fails with a bad auth error. (I did modify the printf to print the error code, which is how I know it is bad auth).

If I set up a guest network with no security, the example works fine.

Then I tried the micropython code from https://projects.raspberrypi.org/en/projects/get-started-pico-w/2 and it has no problem connecting with WPA2/AES, so somewhere in micropython or picozero.py it knows something the tcp_server.c code doesn't know.

Sure be nice to have a working C code example.

Claghorn avatar Jul 22 '23 19:07 Claghorn

Revelation! The example program is fine, but the cmake stuff (which is totally obscure to me) does not manage to get the environment variables for WIFI_SSID and WIFI_PASSWORD all the way into the program as strings. If I add this near the top of the code, the program then compiles and works perfectly:

#undef WIFI_SSID
#define WIFI_SSID "ExampleSSID"
#undef WIFI_PASSWORD
#define WIFI_PASSWORD "ExamplePassword"

(Substituting the actual ssid and password in the real code).

Claghorn avatar Jul 23 '23 19:07 Claghorn