HDG2L-IOT-EU V2.2 板载 WiFi如图
WiFi模块工作模式分为AP与STA模式,AP就是无线接入点,是一个无线网络的创建者,常见的AP设备就是WiFi路由器,而STA 就是作为连入热点的设备,利用 WiFi 热点进行网络通讯,常见的STA设备就是手机。
WIFI AP模式具体操作:
配置 hostap
使用/etc/hostapd.conf 作为默认配置文件,也可手动建立该配置文件:
root@g2liot:~# mv /etc/hostapd.conf /etc/hostapd.conf.bak
root@g2liot:~# vi /etc/hostapd.conf
"/etc/hostapd.conf“配置如下
nterface=wlan0
driver=nl80211
ctrl_interface=/var/run/hostapd
ssid=zhiyinnitaimei
channel=6
hw_mode=g
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=12345678
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP
完成后按“ESC”、“:”,再输入“wq”保存并退出。
其次进行DHCP地址配置
HD-G2L-IOT开发板预装udhcpd来进行ip地址分配,DHCP服务是Linux系统中常见的给从机分配IP的服务,用户可建立/etc/udhcpd.conf 文件作为配置文件:
root@g2liot:~# vi /etc/hostapd.conf
# the start and end of the IP lease block
start 192.168.5.10
end 192.168.5.254
# the interface that udhcpd will use
interface wlan0
option subnet 255.255.255.0
opt router 192.168.1.9 ############将此处地址改为与wlan0相同
opt dns 114.114.114.114
option domain local
option lease 864000
测试WIFI AP网络配置
在完成对udhcpd.conf文件以及hostapd.conf的修改后,可以在命令行下使能udhcpd和hostapd功能,在使能hostapd功能前需确保wifi接口(此处为 wlan0)可用,若之前wlan0工作在stattion 模式则需将wpa_supplicant进程关闭,若之前wlan0处于down模式,则需更改为up,可以使用如下命令来完成 hostap功能的开启
root@g2liot:~# killall wpa_supplicant
killall: wpa_supplicant: no process killed
root@g2liot:~# ifconfig wlan0 up 192.168.1.9 ##########此处也与wlan0相同
root@g2liot:~# udhcpd &
[5] 514
root@g2liot:~# hostapd -B /etc/hostapd.conf
成功连接