Android::wifi热点问题
来源:互联网 发布:淘宝 百科 编辑:程序博客网 时间:2024/06/07 01:16
现在很多移动设备都提供wifi hostpot功能,使用方便,也省下了原来无线路由器的成本。wifi和wifi hotspot功能是互斥的,即在同一时间里,你只能用其中一种功能。在Android较新版本(2.2之后)中已经实现,本文实现在命令行模式下完成wifi hotspot功能的启动,并简单介绍其中涉及到的相关工具。
0、确保eth0可以访问网络
1、修改framework/base/core/res/res/values/config.xml
- <!-- List of regexpressions describing the interface (if any) that represent tetherable
Wifi interfaces. If the device doesn't want to support tethering over Wifi this
should be empty. An example would be "softap.*" -->
<string-array translatable="false" name="config_tether_wifi_regexs">
<item>"wlap0"</item>
</string-array>
<!-- Dhcp range (min, max) to use for tethering purposes -->
<string-array translatable="false" name="config_tether_dhcp_range">
</string-array>
<!-- Regex array of allowable upstream ifaces for tethering - for example if you want
tethering on a new interface called "foo2" add <item>"foo\\d"</item> to the array -->
<string-array translatable="false" name="config_tether_upstream_regexs">
<item>"eth0"</item>
<item>"ppp0"</item>
<item>"wlan0"</item>
</string-array>
2、加载wifi驱动(我这使用的是atheros)
insmod /system/wifi/ar6000.ko ifname=wlap0
若成功的话,则第3、4、5步自动执行。
3、设置IP地址
/system/bin/ifconfig wlap0 192.168.100.1 netmask 255.255.255.0
4、iptables设置
echo 1 > /proc/sys/net/ipv4/ip_forward
/system/bin/iptables -A FORWARD -i wlap0 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
/system/bin/iptables -A FORWARD -i wlap0 -o eth0 -j ACCEPT
/system/bin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
5、dnsmasq设置
/system/bin/dnsmasq --no-daemon --no-resolv --no-poll --dhcp-range=192.168.100.100,192.168.100.200,100h
当然也可以把相关配置写成文件再执行dnsmasq --conf-file=/*path*/dnsmasq.conf
6、启动hostapd
/system/bin/hostapd_wps -dd /data/misc/wifi/hostapd.conf
出现的问题
1、执行上述命令后,客户端去连接的时候获取不到IP地址,重新启动hostapd就OK?
可以采用如下方法修正
/sytem/bin/ndc softap set eth0 wlap0 djstava open
/system/bin/ndc softap start
/system/bin/ndc/softap startap
Reference:
1、http://hostap.epitest.fi/gitweb/gitweb.cgi?p=hostap.git;a=blob_plain;f=hostapd/hostapd.conf
2、ftp://ftp.rebootcomputers.ca/RTL8188C_8192C_8192D_USB_linux_v3.3.0_2971.20111128/android_reference_codes/realtek_wifi_SDK_for_android.txt
3、http://exain.wordpress.com/2011/03/31/making-a-wifi-hotspot-access-point-using-linux-wifi-lan-cardusb-adapter/
4、http://forum.xda-developers.com/archive/index.php/t-799797.html
- Android::wifi热点问题
- 高通Android wifi移植和wifi热点问题总结
- WIFI热点设置,包括HTC热点问题解决
- wifi无法连接华为Mate8 热点问题
- 银联接入--android热点问题解析
- Android wifi
- Android WIFI
- Android Wifi
- Android WIFI
- Android wifi
- android wifi
- Android Wifi
- android wifi
- Android Wifi
- android wifi
- android wifi
- android wifi
- android wifi
- 管道、FIFO以及共享内存
- Ubuntu下设置adb环境变量
- Java I/O通用api设计 (二)
- 第八周项目2
- 情景模式
- Android::wifi热点问题
- n个元素进栈,共有多少种出栈顺序?
- Gaming Tweak - Disable Nagle's algorithm
- 我为什么开发EasyJS类库-一个更改JS编程风格的类库
- 【windows】套接口编程 - 包含winsock2.h的重定义问题
- hdu 3605 最大流
- Android 解析内存泄漏
- Moving Tables+贪心
- 降低耦合度