Wi-Fi Network Testing

The QuecPi Alpha single-board computer supports the QCA1023 SDIO WiFi module. This document describes how to connect to a Wi-Fi hotspot with wpa_supplicant, a user-space program for managing Wi-Fi connections on Linux systems. This document demonstrates connections to two different types of hotspots with wpa_supplicant: an open hotspot and a WPA2-encrypted hotspot.

Network Configuration

Connection with an Open Hotspot

Generally, the configuration file of wpa_supplicant is /etc/wpa_supplicant.conf. Configure /etc/wpa_supplicant.conf according to your Wi-Fi network type. After that, please save the configuration.

ctrl_interface=/var/run/wpa_supplicant 
update_config=1 
network={
    ssid="Your_SSID"  
    key_mgmt=NONE  
}  

Next, execute the wpa_supplicant command to connect to the hotspot.

wpa_supplicant -D nl80211 -c /etc/wpa_supplicant.conf -i wlan0 &

Then, verify the connection status with the wpa_cli command. If the connection is successful, the following information is displayed.

root@qcm6490-idp:~# wpa_cli status
Selected interface 'wlan0'
bssid=f8:5e:3c:01:f8:18
freq=2462
ssid=Your_SSID
id=0
mode=station
wifi_generation=4
pairwise_cipher=NONE
group_cipher=NONE
key_mgmt=NONE
wpa_state=COMPLETED
ip_address=192.168.31.137
p2p_device_address=ce:a2:4c:65:b1:7e
address=00:03:7f:50:00:01
uuid=c6a00688-ca5e-53f5-981e-6f507c5c2820

Obtain IP via DHCP with the udhcpc command.

udhcpc -i wlan0

If the connection is successful, the following information is displayed.

root@qcm6490-idp:~# udhcpc -i wlan0
udhcpc: started, v1.35.0
udhcpc: broadcasting discover
udhcpc: broadcasting select for 192.168.31.137, server 192.168.31.1
udhcpc: lease of 192.168.31.137 obtained from 192.168.31.1, lease time 43200
/etc/udhcpc.d/50default: Adding DNS 192.168.31.1

Connection with an Encrypted Hotspot

Generally, the configuration file of wpa_supplicant is /etc/wpa_supplicant.conf. Configure /etc/wpa_supplicant.conf according to your Wi-Fi network type. After that, please save the configuration.

ctrl_interface=/var/run/wpa_supplicant 
update_config=1 
network={
    ssid="Your_SSID"  
    psk="Your_Password"  
    key_mgmt=WPA-PSK  
}  

Next, execute the wpa_supplicant command to connect to the hotspot.

wpa_supplicant -D nl80211 -c /etc/wpa_supplicant.conf -i wlan0 & 

Then, verify the connection status with the wpa_cli command. If the connection is successful, the following information is displayed.

root@qcm6490-idp:~# wpa_cli status
Selected interface 'wlan0'
bssid=c6:df:30:c2:09:14
freq=5745
ssid=Your_SSID
id=0
mode=station
wifi_generation=5
pairwise_cipher=CCMP
group_cipher=CCMP
key_mgmt=WPA2-PSK
wpa_state=COMPLETED
ip_address=192.168.253.211
p2p_device_address=00:03:7f:50:00:01
address=00:03:7f:50:00:01
uuid=639ce5ef-b620-596c-a9e2-6af204e0ee6f
ieee80211ac=1

Obtain IP via DHCP with the udhcpc command.

udhcpc -i wlan0  

If the connection is successful, the following information is displayed.

root@qcm6490-idp:~# udhcpc -i wlan0 
udhcpc: started, v1.35.0
udhcpc: broadcasting discover
udhcpc: broadcasting select for 192.168.253.211, server 192.168.253.178
udhcpc: lease of 192.168.253.211 obtained from 192.168.253.178, lease time 3599
/etc/udhcpc.d/50default: Adding DNS 192.168.253.178

Check network interface IP address with ifconfig:

root@qcm6490-idp:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 32:C0:A2:09:FE:40  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:167 Base address:0x1000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:75 errors:0 dropped:0 overruns:0 frame:0
          TX packets:75 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:6301 (6.1 KiB)  TX bytes:6301 (6.1 KiB)

p2p0      Link encap:Ethernet  HWaddr 02:03:7F:D6:00:01  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wlan0     Link encap:Ethernet  HWaddr 00:03:7F:50:00:01  
          inet addr:192.168.253.211  Bcast:192.168.253.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3421 errors:0 dropped:0 overruns:0 frame:0
          TX packets:61 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3000 
          RX bytes:151273 (147.7 KiB)  TX bytes:7300 (7.1 KiB)

It can be seen that wlan0 has obtained the IP address.

Network Testing

Execute the ping command to test the network connection:

  • ping 192.168.1.1 → If the IP address can be pinged successfully, it shows a successful network connection (replace the gateway IP with actual values).
  • ping 114.114.114.114 → If the address can be pinged successfully, it shows a successful external network connection.
  • ping baidu.com → If the address can be pinged successfully, it shows a successful DNS resolution and external network connection.