Android::wifi热点问题

现在很多移动设备都提供wifi hostpot功能,使用方便,也省下了原来无线路由器的成本。wifi和wifi hotspot功能是互斥的,即在同一时间里,你只能用其中一种功能。在Android较新版本(2.2之后)中已经实现,本文实现在命令行模式下完成wifi hotspot功能的启动,并简单介绍其中涉及到的相关工具。

0、确保eth0可以访问网络

1、修改framework/base/core/res/res/values/config.xml
  1. <!-- 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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
全志R16平台的android6.0.1系统下的RTL8188EU的配置V1.0 2017/5/31 10:30 1、R:\wyb\rtl8188eu_r16m_20161208\android\device\softwinner\astar-evb30\overlay\frameworks\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>"wlan0"</item> </string-array> RTL8188EU没有BT,需要干掉BT的配置(不要显示): <!-- List of regexpressions describing the interface (if any) that represent tetherable bluetooth interfaces. If the device doesn't want to support tethering over bluetooth this should be empty. --> <!-- default: disable Bluetooth PAN feature --> <string-array translatable="false" name="config_tether_bluetooth_regexs"> <item>"bt-pan"</item> </string-array> 2、 R:\wyb\rtl8188eu_r16m_20161208\android\device\softwinner\astar-evb30\astar_evb30.mk PRODUCT_COPY_FILES += \ frameworks/native/data/etc/android.hardware.camera.xml:system/etc/permissions/android.hardware.camera.xml \ frameworks/native/data/etc/android.hardware.camera.front.xml:system/etc/permissions/android.hardware.camera.front.xml \ frameworks/native/data/etc/android.hardware.ethernet.xml:system/etc/permissions/android.hardware.ethernet.xml \ (干掉BT部分)frameworks/native/data/etc/android.hardware.bluetooth.xml:system/etc/permissions/android.hardware.bluetooth.xml 开启ADB,方便调试: PRODUCT_PROPERTY_OVERRIDES += \ persist.sys.usb.config=mtp \ ro.adb.secure=1 \ ro.sys.mutedrm=true \ rw.logger=0 修改为: PRODUCT_PROPERTY_OVERRIDES += \ persist.sys.usb.config=mass_storage,adb \ ro.adb.secure=0 \ ro.sys.mutedrm=true \ rw.logger=0 3、 R:\wyb\rtl8188eu_r16m_20161208\android\device\softwinner\astar-evb30\BoardConfig.mk # wifi and bt configuration # 1. Wifi Configuration # 1.1 realtek wifi support # 1.1 realtek wifi configuration # BOARD_USR_WIFI: rtl8188eu/rtl8723bs/rtl8723bs_vq0/rtl8723cs (打开realtek这个开关,并配置为rtl8188eu,默认为:rtl8723bs_vq0) BOARD_WIFI_VENDOR := realtek ifeq ($(BOARD_WIFI_VENDOR), realtek) WPA_SUPPLICANT_VERSION := VER_0_8_X BOARD_WPA_SUPPLICANT_DRIVER := NL80211 BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_rtl BOARD_HOSTAPD_DRIVER := NL80211 BOARD_HOSTAPD_PRIVATE_LIB := lib_driver_cmd_rtl #BOARD_USR_WIFI := rtl8723bs_vq0 BOARD_USR_WIFI := rtl8188eu BOARD_WLAN_DEVICE := rtl8188eu include hardware/realtek/wlan/config/config.mk endif # 1.2 broadcom wifi support (关闭) #BOARD_WIFI_VENDOR := broadcom ifeq ($(BOARD_WIFI_VENDOR), broadcom) BOARD_WPA_SUPPLICANT_DRIVER := NL80211 WPA_SUPPLICANT_VERSION := VER_0_8_X BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_bcmdhd BOARD_HOSTAPD_DRIVER := NL80211 BOARD_HOSTAPD_PRIVATE_LIB := lib_driver_cmd_bcmdhd BOARD_WLAN_DEVICE := bcmdhd WIFI_DRIVER_FW_PATH_PARAM := "/sys/module/bcmdhd/parameters/firmware_path" BOARD_USR_WIFI := ap6212 include hardware/broadcom/wlan/bcmdhd/firmware/$(BOARD_USR_WIFI)/device-bcm.mk endif (关闭) ## 2. Bluetooth Configuration ## make sure BOARD_HAVE_BLUETOOTH is true for every bt vendor #BOARD_HAVE_BLUETOOTH := true #BOARD_HAVE_BLUETOOTH_BCM := true #BOARD_HAVE_BLUETOOTH_NAME := ap6212 #BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR := device/softwinner/astar-evb30/bluetooth 4、 R:\wyb\rtl8188eu_r16m_20161208\android\device\softwinner\astar-evb30\init.sun8i.rc # network (关闭博通:AP6212,打开realtek) #insmod /system/vendor/modules/bcmdhd.ko #insmod /system/vendor/modules/bcm_btlpm.ko insmod /system/vendor/modules/8188eu.ko insmod /system/vendor/modules/usbnet.ko insmod /system/vendor/modules/asix.ko insmod /system/vendor/modules/qf9700.ko insmod /system/vendor/modules/mcs7830.ko insmod /system/vendor/modules/smsc95xx.ko insmod /system/vendor/modules/rtl8150.ko insmod /system/vendor/modules/cdc_ether.ko (关闭) ## bluetooth # # UART device # chmod 0660 /dev/ttyS1 # chown bluetooth net_bt_stack /dev/ttyS1 # # # power up/down interface # chmod 0660 /sys/class/rfkill/rfkill0/state # chmod 0660 /sys/class/rfkill/rfkill0/type # chown bluetooth net_bt_stack /sys/class/rfkill/rfkill0/state # chown bluetooth net_bt_stack /sys/class/rfkill/rfkill0/type # # # bluetooth MAC address programming # chown bluetooth net_bt_stack ro.bt.bdaddr_path # chown bluetooth net_bt_stack /system/etc/bluetooth # chown bluetooth net_bt_stack /data/misc/bluetooth # setprop ro.bt.bdaddr_path "/data/misc/bluetooth/bdaddr" # # # bluetooth LPM # chmod 0220 /proc/bluetooth/sleep/lpm # chmod 0220 /proc/bluetooth/sleep/btwrite # chown bluetooth net_bt_stack /proc/bluetooth/sleep/lpm # chown bluetooth net_bt_stack /proc/bluetooth/sleep/btwrite (关闭博通的部分:AP6212) ## broadcom wifi service ## 1 broadcom wifi sta service #service wpa_supplicant /system/bin/wpa_supplicant \ # -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \ # -I/system/etc/wifi/wpa_supplicant_overlay.conf \ # -O/data/misc/wifi/sockets \ # -e/data/misc/wifi/entropy.bin -g@android:wpa_wlan0 # # we will start as root and wpa_supplicant will switch to user wifi # # after setting up the capabilities required for WEXT # # user wifi # # group wifi inet keystore # class main # socket wpa_wlan0 dgram 660 wifi wifi # disabled # oneshot # ## 2 broadcom wifi sta p2p concurrent service #service p2p_supplicant /system/bin/wpa_supplicant \ # -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \ # -I/system/etc/wifi/wpa_supplicant_overlay.conf \ # -O/data/misc/wifi/sockets -N \ # -ip2p0 -Dnl80211 -c/data/misc/wifi/p2p_supplicant.conf \ # -I/system/etc/wifi/p2p_supplicant_overlay.conf \ # -puse_p2p_group_interface=1 -e/data/misc/wifi/entropy.bin \ # -g@android:wpa_wlan0 # # we will start as root and wpa_supplicant will switch to user wifi # # after setting up the capabilities required for WEXT # # user wifi # # group wifi inet keystore # class main # socket wpa_wlan0 dgram 660 wifi wifi # disabled # oneshot (增加rtl8188eu部分) # realtek wifi service service wpa_supplicant /system/bin/logwrapper /system/bin/wpa_supplicant \ -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \ -O/data/misc/wifi/sockets \ -e/data/misc/wifi/entropy.bin -g@android:wpa_wlan0 class main socket wpa_wlan0 dgram 660 wifi wifi disabled oneshot # 1.2 realtek wifi sta p2p concurrent service service p2p_supplicant /system/bin/logwrapper /system/bin/wpa_supplicant \ -ip2p0 -Dnl80211 -c/data/misc/wifi/p2p_supplicant.conf \ -e/data/misc/wifi/entropy.bin -N \ -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \ -O/data/misc/wifi/sockets \ -g@android:wpa_wlan0 class main socket wpa_wlan0 dgram 660 wifi wifi disabled oneshot 5、 R:\wyb\rtl8188eu_r16m_20161208\android\hardware\realtek\bluetooth\firmware\rtlbtfw_cfg.mk $(LOCAL_PATH)/rtl8703b_config:system/etc/firmware/rtl8703bs_config (关闭realtek的BT,否则会编译出错:) #$(TOP_DIR)device/softwinner/$(basename $(TARGET_DEVICE))/bluetooth/rtkbt.conf:system/etc/bluetooth/rtkbt.conf \ make: *** 没有规则可以创建“out/target/product/astar-evb30/system/etc/bluetooth/rtkbt.conf”需要的目标“device/softwinner/astar-evb30/bluetooth/rtkbt.conf”。 停止。 Export includes file: external/sqlite/dist/Android.mk -- out/target/product/astar-evb30/obj/EXECUTABLES/sqlite3_intermediates/export_includes Notice file: external/sqlite/dist/NOTICE -- out/target/product/astar-evb30/obj/NOTICE_FILES/src//system/xbin/sqlite3.txt Import includes file: out/target/product/astar-evb30/obj/EXECUTABLES/strace_intermediates/import_includes Export includes file: external/strace/Android.mk -- out/target/product/astar-evb30/obj/EXECUTABLES/strace_intermediates/export_includes Import includes file: out/target/product/astar-evb30/obj/EXECUTABLES/su_intermediates/import_includes Export includes file: system/extras/su/Android.mk -- out/target/product/astar-evb30/obj/EXECUTABLES/su_intermediates/export_includes Notice file: system/extras/su/NOTICE -- out/target/product/astar-evb30/obj/NOTICE_FILES/src//system/xbin/su.txt Import includes file: out/target/product/astar-evb30/obj/EXECUTABLES/taskstats_intermediates/import_includes Export includes file: system/extras/taskstats/Android.mk -- out/target/product/astar-evb30/obj/EXECUTABLES/taskstats_intermediates/export_includes Notice file: system/extras/taskstats/NOTICE -- out/target/product/astar-evb30/obj/NOTICE_FILES/src//system/xbin/taskstats.txt Import includes file: out/target/product/astar-evb30/obj/EXECUTABLES/tcpdump_intermediates/import_includes Export includes file: external/tcpdump/Android.mk -- out/target/product/astar-evb30/obj/EXECUTABLES/tcpdump_intermediates/export_includes Import includes file: out/target/product/astar-evb30/obj/EXECUTABLES/timeinfo_intermediates/import_includes Export includes file: system/extras/timeinfo/Android.mk -- out/target/product/astar-evb30/obj/EXECUTABLES/timeinfo_intermediates/export_includes Notice file: system/extras/timeinfo/NOTICE -- out/target/product/astar-evb30/obj/NOTICE_FILES/src//system/xbin/timeinfo.txt make: *** 没有规则可以创建“out/target/product/astar-evb30/system/etc/bluetooth/rtkbt.conf”需要的目标“device/softwinner/astar-evb30/bluetooth/rtkbt.conf”。 停止。 make: *** 正在等待未完成的任务.... 12585 unique nodes, 42861 total 注: 某些输入文件使用或覆盖了已过时的 API。 注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。 注: 某些输入文件使用了未经检查或不安全的操作。 注: 有关详细信息, 请使用 -Xlint:unchecked 重新编译。 12585 unique nodes, 42861 total 21515 unique nodes, 102669 total #### make failed to build some targets (01:21 (mm:ss)) #### rootroot@cm-System-Product-Name:/home/rediron/r16m/rtl8188eu_r16m_20161208/android$ grep rtkbt.conf . -R Z:\home\rediron\r16m\rtl8188eu_r16m_20161208\android\hardware\realtek\bluetooth\firmware\rtlbtfw_cfg.mk 6、 R:\wyb\rtl8188eu_r16m_20161208\lichee\tools\pack\chips\sun8iw5p1\configs\evb-30\sys_config.fex (关闭BT) ;-------------------------------------------------------------------------------- ;bluetooth configuration ;bt_used: 0- no used, 1- used ;bt_uard_id: 0- uart0, 1- uart1, 2- uart2 ;bt_rst_n: bt function enable io ;bt_wake: host wake-up bluetooth device ;bt_wak_host: bt device wake-up host ;bt_host_wake_invert: whether bt_host_wake use inverter between ap and module ; 0: not used, 1: used ;-------------------------------------------------------------------------------- [bt_para] bt_used = 0 bt_uart_id = 1 bt_rst_n = port:PL08<1><default><default><0> bt_wake = port:PL10<1><default><default><0> bt_host_wake = port:PL09<4><default><default><0> bt_host_wake_invert = 0 7、配置USB1(接RTL8188EU) rootroot@cm-System-Product-Name:/home/rediron/r16m/rtl8188eu_r16m_20161208$ rootroot@cm-System-Product-Name:/home/rediron/r16m/rtl8188eu_r16m_20161208$ cd lichee/ rootroot@cm-System-Product-Name:/home/rediron/r16m/rtl8188eu_r16m_20161208/lichee$ cd linux-3.4/ rootroot@cm-System-Product-Name:/home/rediron/r16m/rtl8188eu_r16m_20161208/lichee/linux-3.4$ rootroot@cm-System-Product-Name:/home/rediron/r16m/rtl8188eu_r16m_20161208/lichee/linux-3.4$ make ARCH=arm menuconfig Device Drivers ---> [*] USB support ---> <*> SoftWinner SUNXI USB Host Controller support <*> SoftWinner SUNXI USB Host Controller0 <*> SoftWinner SUNXI USB HCI <*> SoftWinner SUNXI USB EHCI0 < > SoftWinner SUNXI USB EHCI1 修改为: <*> SoftWinner SUNXI USB EHCI1 <*> SoftWinner SUNXI USB OHCI0 < > SoftWinner SUNXI USB OHCI1 修改为: <*> SoftWinner SUNXI USB OHCI1 < > SoftWinner SUNXI USB EHCI2 < > SoftWinner SUNXI USB OHCI2 < > SoftWinner SUNXI USB EHCI3 < > SoftWinner SUNXI USB OHCI3 < > SoftWinner SUNXI USB HSIC 不加这里内核报错,但是不影响上网! shell@astar-evb30:/ $ shell@astar-evb30:/ $ [ 30.993687] hci: ERR: not support sunxi_usb_enable_ehci [ 30.999650] hci: ERR: not support sunxi_usb_enable_ohci shell@astar-evb30:/ $ shell@astar-evb30:/ $
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值