I am trying to create a WIFI dongle from PI PICO W for that i need to first perform a network scan and identify the networks around me to present a list of network for the user to select from.
The goal of this scan s to select 2 key components of a WIFI connection SSID and Authentication standard. SSID was easy to extract but the Auth standard seemed cryptic. hence this topic is an attempt to discuss the same.
https://github.com/raspberrypi/pico-sdk ... w43_arch.c
cyw43_arch_wifi_connect_bssid_async
cyw43_wifi_join
https://github.com/georgerobotics/cyw43 ... w43_ctrl.ccyw43_ll_wifi_join
https://github.com/georgerobotics/cyw43 ... cyw43_ll.cAs per the above code the following table can be drawn if the wifi scan output => Auth definition needed to connect:-
auth in cyw43_ll_wifi_parse_scan_result => auth in cyw43_arch_wifi_connect_async
0 security = 0 => CYW43_AUTH_OPEN
3 (WEP_PSK security|=1 WPA security|=2) => CYW43_AUTH_WPA_TKIP_PSK
5 (WEP_PSK security|=1 WPA2 security|=4) => CYW43_AUTH_WPA2_AES_PSK
7 (WEP_PSK security|=1 WPA security|=2 WPA2 security|=4) => CYW43_AUTH_WPA2_MIXED_PSK
https://github.com/georgerobotics/cyw43 ... cyw43_ll.c
cyw43_ll_wifi_parse_scan_result
The goal of this scan s to select 2 key components of a WIFI connection SSID and Authentication standard. SSID was easy to extract but the Auth standard seemed cryptic. hence this topic is an attempt to discuss the same.
https://github.com/raspberrypi/pico-sdk ... w43_arch.c
cyw43_arch_wifi_connect_bssid_async
Code:
int cyw43_arch_wifi_connect_async(const char *ssid, const char *pw, uint32_t auth) { return cyw43_arch_wifi_connect_bssid_async(ssid, NULL, pw, auth);int cyw43_arch_wifi_connect_bssid_async(const char *ssid, const uint8_t *bssid, const char *pw, uint32_t auth) { if (!pw) auth = CYW43_AUTH_OPEN; // Connect to wireless return cyw43_wifi_join(&cyw43_state, strlen(ssid), (const uint8_t *)ssid, pw ? strlen(pw) : 0, (const uint8_t *)pw, auth, bssid, CYW43_CHANNEL_NONE);
https://github.com/georgerobotics/cyw43 ... w43_ctrl.c
Code:
int cyw43_wifi_join(cyw43_t *self, size_t ssid_len, const uint8_t *ssid, size_t key_len, const uint8_t *key, uint32_t auth_type, const uint8_t *bssid, uint32_t channel) { CYW43_THREAD_ENTER; if (!CYW43_STA_IS_ACTIVE(self)) { CYW43_THREAD_EXIT; return -CYW43_EPERM; } int ret = cyw43_ensure_up(self); if (ret) { CYW43_THREAD_EXIT; return ret; } ret = cyw43_ll_wifi_join(&self->cyw43_ll, ssid_len, ssid, key_len, key, auth_type, bssid, channel);
https://github.com/georgerobotics/cyw43 ... cyw43_ll.c
Code:
int cyw43_ll_wifi_join(cyw43_ll_t *self_in, size_t ssid_len, const uint8_t *ssid, size_t key_len, const uint8_t *key, uint32_t auth_type, const uint8_t *bssid, uint32_t channel) { cyw43_int_t *self = CYW_INT_FROM_LL(self_in); uint8_t buf[128]; cyw43_write_iovar_u32(self, "ampdu_ba_wsize", 8, WWD_STA_INTERFACE); uint32_t wpa_auth = 0; if (auth_type == CYW43_AUTH_OPEN) { wpa_auth = 0; } else if (auth_type == CYW43_AUTH_WPA2_AES_PSK || auth_type == CYW43_AUTH_WPA2_MIXED_PSK) { wpa_auth = CYW43_WPA2_AUTH_PSK; } else if (auth_type == CYW43_AUTH_WPA_TKIP_PSK) { wpa_auth = CYW43_WPA_AUTH_PSK; } else { // Unsupported auth_type (security) value. return -CYW43_EINVAL; }
auth in cyw43_ll_wifi_parse_scan_result => auth in cyw43_arch_wifi_connect_async
0 security = 0 => CYW43_AUTH_OPEN
3 (WEP_PSK security|=1 WPA security|=2) => CYW43_AUTH_WPA_TKIP_PSK
5 (WEP_PSK security|=1 WPA2 security|=4) => CYW43_AUTH_WPA2_AES_PSK
7 (WEP_PSK security|=1 WPA security|=2 WPA2 security|=4) => CYW43_AUTH_WPA2_MIXED_PSK
https://github.com/georgerobotics/cyw43 ... cyw43_ll.c
cyw43_ll_wifi_parse_scan_result
Code:
static void cyw43_ll_wifi_parse_scan_result(cyw43_async_event_t *ev) { . . . . int security = 0;// OPEN if (ie_rsn != NULL) { // TODO need to parse the IE to check for TKIP, AES and enterprise modes security |= 4;// WPA2; } if (ie_wpa != NULL) { // TODO need to parse the IE to check for TKIP, AES and enterprise modes security |= 2;// WPA; } if (scan_res->bss.capability & DOT11_CAP_PRIVACY) { security |= 1;// WEP_PSK; } ev->u.scan_result.channel &= 0xff; ev->u.scan_result.auth_mode = security; return;}
Statistics: Posted by aayush.deo — Fri Feb 09, 2024 8:02 am — Replies 0 — Views 66