raspberrypi / pico-examples

BSD 3-Clause "New" or "Revised" License
2.62k stars 779 forks source link

tcp_server example always get bad auth error with WPA2/AES #408

Open Claghorn opened 11 months ago

Claghorn commented 11 months ago

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 commented 11 months ago

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).