本文以飞凌嵌入式FCU2303(5G智能网关3.0)为基础讲解,本节主要介绍5G智能网关WIFI功能的测试。关于FCU2303(5G智能网关3.0)如果想将4G/5G模块的流量通过以太网或者wifi AP模式分享出去的方式在《5G智能网关功能测试第一章4G/5G 上网测试》中已经有所设计,此章节就不在赘述。
一、FCU2303(5G智能网关3.0)WiFi测试
5G智能网关WiFi天线在外壳上的标识为:
1、板载WiFi 测试
FCU2303(5G智能网关3.0)上可以通过m.2Type2230接口,即E KEY标准接口默认外接INTEL 3168NGW模块。
系统上电前将模块插入底板相应卡槽,上电后启动linux后,通过lspci可以看到对应设备枚举成功。
root@localhost:~# lspci
0000:00:00.0 PCI bridge: Freescale Semiconductor Inc Device 81c0 (rev 10)
0001:00:00.0 PCI bridge: Freescale Semiconductor Inc Device 81c0 (rev 10)
0001:01:00.0 Network controller: Intel Corporation Device 24fb (rev 10)
0002:00:00.0 PCI bridge: Freescale Semiconductor Inc Device 81c0 (rev 10)
2、配置WiFi上网
输入ifconfig wlP1p1s0命令查看WiFi网络节点:
root@localhost:~# ifconfig wlP1p1s0
wlP1p1s0: flags=4098<BROADCAST,MULTICAST> mtu 1500
ether d8:3b:bf:b9:dd:27 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Ubuntu18 中 wifi 的名称不再是wlan0类似的命名方式,而是采用固件版本的形式,如上所示INTEL 3168NGW的名称为 wlP1p1s0。
注意:在FCU2303(5G智能网关3.0)中,WiFi模块已经配置成AP热点功能并加入网桥br0中,Wifi热点名称为wifi_test,密码为12345678,Wifi热点的配置文件为:
root@localhost:~# cat /etc/hostapd/hostapd.conf
interface=wlP1p1s0
driver=nl80211
ssid=wifi_test
channel=9
hw_mode=g
macaddr_acl=0
ignore_broadcast_ssid=0
auth_algs=1
wpa=3
wpa_passphrase=12345678
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
如果客户想关闭掉WiFi模块的AP热点功能,用作STA模式,并将WiFi模块从网桥中去除,可以执行以下命令:
root@localhost:~# rm /etc/systemd/system/multi-user.target.wants/hostapd.service
root@localhost:~# rm /etc/systemd/network/wlan0.network
二、STA模式测试
1、使用简易脚本测试
为了方便客户能够更快速验证功能,我们提供了wifi连接的脚本,首先查看wifi_connect.sh的使用说明,如下表:
参数 | 说明 |
---|---|
-s | 准备连接的WIFI的名称 |
-p | 准备连接的WIFI的密码,如果没有加密请使用-p NONE |
-a | 是否随开机自动启动,如果是则为ON,如果不是则为OFF,如果没有此项则保持原有设置 |
举例如下,连接 WIFI 的名称为 resona 密码为 23456789 的 WIFI:
root@localhost:~# /root/Net_Tools/wifi_connect.sh -s resona -p 23456789
Begain Wireless connect ...
-----------------------
SSID: resona
PASW: 23456789
-----------------------
Wireless point is wlP1p1s0
Wireless status is DISCONNECTED
Wireless status is SCANNING
Wireless status is COMPLETED
-----------------------
Wireless connect status
bssid=2a:9a:7d:5f:4e:bb
freq=2462
ssid=resona
id=0
mode=station
pairwise_cipher=CCMP
group_cipher=CCMP
key_mgmt=WPA2-PSK
wpa_state=COMPLETED
address=28:7f:cf:ca:89:9c
uuid=2d6ba737-00d3-55c6-ab0b-b10df8ef1d1d
-----------------------
Wireless connect done !!!
Auto start setting not change
此步完成以后则Wifi连接成功
2、使用命令逐步操作测试:
下面的方法为使用命令连接wifi的详细方法,供客户后期开发程序使用
首先使用 wifi_wpa.sh 脚本生成 wpa_supplicant 配置文件,首先查看wifi_wpa.sh的使用说明,如下表:
参数 | 说明 |
---|---|
-s | 准备连接的WIFI的名称 |
-p | 准备连接的WIFI的密码,如果没有加密请使用-p NONE |
举例如下,连接 WIFI 的名称为 resona 密码为 23456789 的 WIFI:
root@localhost:~# /root/Net_Tools/wifi_wpa.sh -s resona -p 23456789
ssid resona
pasw 23456789
生成的配置文件为:/etc/wpa_supplicant.conf
root@localhost:~# cat /etc/wpa_supplicant.conf
#PSK/TKIP
ctrl_interface=/var/run/wpa_supplicant
p2p_disabled=1
network={
ssid="resona"
scan_ssid=1
psk="23456789"
key_mgmt=WPA-EAP WPA-PSK IEEE8021X NONE
group=CCMP TKIP WEP104 WEP40
}
连接测试:
root@localhost:~# wpa_supplicant -B -c /etc/wpa_supplicant.conf -i wlP1p1s0 &
[1] 5173
Successfully initialized wpa_supplicant
查看连接状态
root@localhost:~# wpa_cli status -i wlP1p1s0
bssid=b6:24:1e:e8:9b:82
freq=2462
ssid=resona
id=0
mode=station
pairwise_cipher=CCMP
group_cipher=CCMP
key_mgmt=WPA2-PSK
wpa_state=COMPLETED
address=d8:3b:bf:b9:dd:27
uuid=ada8b469-9fb8-5e6d-890a-daf96422b26c
获取IP地址:
root@localhost:~# dhclient -i wlP1p1s0
测试WiFi
测试WiFi,ping 域名或者IP。
root@localhost:~# dhclient -i wlP1p1s0
root@localhost:~# ping www.forlinx.com -c 3 -I wlP1p1s0
PING www.a.shifen.com (61.135.169.125) from 192.168.43.143 wlP1p1s0: 56(84) bytes of data.
64 bytes from 61.135.169.125 (61.135.169.125): icmp_seq=1 ttl=53 time=39.2 ms
64 bytes from 61.135.169.125 (61.135.169.125): icmp_seq=2 ttl=53 time=58.2 ms
64 bytes from 61.135.169.125 (61.135.169.125): icmp_seq=3 ttl=53 time=48.9 ms
--- www.a.shifen.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 39.216/48.822/58.282/7.784 ms