Android系统中对于WIFI的设置集成到了“设置”中,其实跟手动设置差不多。这里介绍下如何手动连接WIFI,以方便以后调试WIFI。
第一步要做的就是要加载WIFI模块驱动了。当然如果你的WIFI是编译到内核里面的,就不需要的。我们的WIFI芯片用的是BCM4330,编译为模块。
insmod /system/lib/modules/kernel/drivers/net/wireless/bcm4330/bcm4330.ko firmware_path=/system/vendor/firmware/bcm4330.bin \ nvram_path=/system/vendor/firmware/nvram.txt
这样驱动模块加载后,需要启动wpa_supplicant
root@android:/ # wpa_supplicant -Dwext -iwlan0 -C/data/system/wpa_supplicant -c/data/misc/wifi/wpa_supplicant.conf &
然后ps|grep wpa看看有没有起来,在wifi工作过程中,这个进程要始终都在的。
接着启动客户端wpa_cli进行配置并连接wifi热点
130|root@android:/ # wpa_cli -p/data/system/wpa_supplicant -iwlan0
wpa_cli v0.8.x
Copyright (c) 2004-2011, Jouni Malinen <j@w1.fi> and contributors
This program is free software. You can distribute it and/or modify it
under the terms of the GNU General Public License version 2.
Alternatively, this software may be distributed under the terms of the
BSD license. See README and COPYING for more details.
Interactive mode
>
其中/data/system/wpa_supplicant 是刚刚启动wpa_supplicant的时候创建的一个套接字
接着进行搜索wifi
> scan
OK
<3>CTRL-EVENT-SCAN-RESULTS
查看搜到的有哪些热点
> scan_result
bssid / frequency / signal level / flags / ssid
40:16:9f:67:0f:00 2462 -42 [WPA-PSK-TKIP+CCMP][WPA2-PSK-TKIP+CCMP][WPS][ESS] HHCN-NET
b0:48:7a:49:44:68 2437 -58 [WPA2-PSK-CCMP][WPS][ESS] HHTech.Arch
e0:05:c5:97:d8:5a 241