Android教程:wifi热点问题
2014-01-15 11:20
399 查看
http://www.linuxidc.com/Linux/2012-05/60718.htm
现在很多移动设备都提供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=/*/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
现在很多移动设备都提供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=/*/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
相关文章推荐
- Android WiFi开发教程(三)——WiFi热点数据传输
- 高通Android wifi移植和wifi热点问题总结
- 在Android中扫描wifi热点演示实例教程
- Android wifi通信 开发(wifi列表 +连接具体的wifi热点+socket的获取) 之 解决热点连成功的时延问题
- Android WiFi开发教程(三)——WiFi热点数据传输
- 在Android中扫描wifi热点演示实例教程
- android SDIO error导致wifi无法打开或者连接热点异常的问题
- android -wifi热点设置问题
- Android应用程序创建热点以及自动链接Wifi,我遇到的问题以及我是怎么解决的
- 在Android中扫描wifi热点演示实例教程
- 在Android中扫描wifi热点演示实例教程
- Android::wifi热点问题
- Android开发教程--关于LayoutParams removeRule出错问题的解决
- Windows 7笔记本创建wifi热点供手机上网教程
- 【Android Studio使用教程 7】AndroidStudio问题汇总
- Android开发周围wifi热点和属性的获取
- Android WiFi 扫描和连接热点
- android 代码设置、打开wifi热点及热点的连接
- Android网络连接Wifi和cmnet及cmwap的问题
- android wifi 热点、socket通讯