The gateway supports WiFi 2.4G wireless functionality and has a built-in WiFi module, allowing it to connect to other WiFi hotspots.
Preparation
You can use lsusb to see whether the device has been recognized on the USB bus.
root@gw101d512e4:~# lsusb
Bus 002 Device 005: ID a69c:8d81
Bus 002 Device 007: ID 2c7c:6005 Quectel Wireless Solutions Co., Ltd.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 002: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Here, a69c:8d81 is the USB device of the WiFi module.
Check whether the WiFi driver has been loaded successfully and whether there is a wlan0 device.
root@gw101d512e4:~# lsmod | grep aic8800
aic8800_fdrv 524288 0
cfg80211 303104 1 aic8800_fdrv
aic_load_fw 77824 1 aic8800_fdrv
root@gw101d512e4:~# ifconfig wlan0
wlan0 Link encap:Ethernet HWaddr 84:FC:14:65:4B:80
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)
The above two points confirm that the USB WiFi module has been recognized by the system and that the driver is working properly.
Connecting to the Network
The WiFi function can connect to WiFi AP signals. Before connecting, you need to configure the WiFi access information, including the WiFi hotspot name and password. You can conveniently generate the required configuration file using wpa_passphrase. Here is an example where the WiFi name we need to connect to is i2SOM and the password is helloworld.
root@i2x-6ub-gw:~# wpa_passphrase "i2SOM" > wifi.conf
helloworld
Then use the wpa_supplicant command to connect to the WiFi network.
root@i2x-6ub-gw:~# wpa_supplicant -B -c wifi.conf -i wlan0
Successfully initialized wpa_supplicant
Do not run the wpa_supplicant command multiple times. You can use the ps command to check whether a wpa_supplicant command is already running.
root@i2x-6ub-gw:~# ps | grep wpa_supplicant
If there is one, you can use the kill command to terminate the corresponding process.
You can use udhcpc to obtain an IP address from the gateway device of the connected network.
root@i2x-6ub-gw:~# udhcpc -i wlan0
udhcpc: started, v1.29.2
udhcpc: sending discover
udhcpc: sending discover
udhcpc: sending select for 192.168.2.122
udhcpc: lease of 192.168.2.122 obtained, lease time 86400
/etc/udhcpc.d/50default: Adding DNS 192.168.2.1
Now you can use the ping command to test connectivity with other devices in the WiFi network. If you need to access the Internet, you can set the DNS address.
root@i2x-6ub-gw:~# echo "nameserver 114.114.114.114" > /etc/resolv.conf
root@i2x-6ub-gw:~# echo "nameserver 8.8.8.8" >> /etc/resolv.conf
root@i2x-6ub-gw:~# ping baidu.com
PING baidu.com (220.181.38.148) 56(84) bytes of data.
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=1 ttl=52 time=21.2 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=2 ttl=52 time=21.1 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=3 ttl=52 time=21.2 ms
Use systemd to start the wpa_supplicant service.
systemctl enable wpa_supplicant@wlan0
/etc/systemd/system/multi-user.target.wants/wpa_supplicant@wlan0.service
systemctl start wpa_supplicant@wlan0