WiFi开启热点冲突

OS:Linux3.18 + Android4.4
问题点: 开发板已经接入4G模块,可以正常上网,现在要通过开启Wifi热点共享网络,在设置里开启AP模式时,wifi一直在不停的开关,不能打开热点。
原本不加4G模块,ap功能是正常的,添加后不能用,以为是4g模块和wifi驱动冲突,看kernel和logcat,一点点找,iptables这部分存在问题。
具体的natcontroller功能及runcmd功能列表看Android系统中iptables的应用(三)NatController,
这时候看logcat

09-18 09:49:02.853 D/Tethering( 2130): TetheredState.processMessage what=12
09-18 09:49:02.853 V/NatController( 1429): enableNat(intIface=<wlan0>, extIface=<usb0>)
09-18 09:49:02.863 D/MobileDataStateTracker( 2130): hipri: Broadcast received: android.intent.action.ANY_DATA_STATE apnType=hipri
09-18 09:49:02.863 D/MobileDataStateTracker( 2130): hipri: Received state=DISCONNECTED, old=CONNECTED, reason=dataDisabled
09-18 09:49:02.863 D/MobileDataStateTracker( 2130): hipri: setDetailed state, old =CONNECTED and new state=DISCONNECTED
09-18 09:49:02.863 D/ConnectivityService( 2130): ConnectivityChange for mobile_hipri: DISCONNECTED/DISCONNECTED
09-18 09:49:02.913 V/NatController( 1429): runCmd(/system/bin/ip route flush cache) res=0
09-18 09:49:02.923 V/NatController( 1429): runCmd(/system/bin/iptables -t nat -A natctrl_nat_POSTROUTING -o usb0 -j MASQUERADE) res=3
09-18 09:49:02.923 E/NatController( 1429): Error seting postroute rule: iface=usb0
09-18 09:49:02.933 D/dalvikvm( 2130): GC_CONCURRENT freed 773K, 15% free 6215K/7236K, paused 4ms+9ms, total 61ms
09-18 09:49:02.973 V/NatController( 1429): runCmd(/system/bin/ip route flush cache) res=0
09-18 09:49:02.993 V/NatController( 1429): runCmd(/system/bin/iptables -F natctrl_FORWARD) res=0
09-18 09:49:02.993 V/NatController( 1429): runCmd(/system/bin/iptables -A natctrl_FORWARD -j DROP) res=0
09-18 09:49:03.003 V/NatController( 1429): runCmd(/system/bin/iptables -t nat -F natctrl_nat_POSTROUTING) res=3
09-18 09:49:03.003 E/Tethering( 2130): Exception enabling Nat: java.lang.IllegalStateException: command '129 nat enable wlan0 usb0 2 fe80::/64 192.168.43.0/24' failed with '400 129 Nat operation failed (Cannot assign requested address)'
09-18 09:49:03.023 D/TetherController( 1429): untetherInterface(wlan0)
09-18 09:49:03.033 D/BluetoothAdapter( 2651): 1099669424: getState() :  mService = null. Returning STATE_OFF

runCmd(/system/bin/iptables -t nat -A natctrl_nat_POSTROUTING -o usb0 -j MASQUERADE) res=3这行已经错误,正常res=0,尝试在开发板串口输入

iptables -t nat -A natctrl_nat_POSTROUTING -o usb0 -j MASQUERADE

会出现

iptables v1.4.11.1: can't initialize iptables table `nat': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.

这时候已经明白原因,Linux内核没有添加nat模块,在内核添加nat后,ap热点可以正常使用。

看到了Android KitKat 4.4 Wifi移植AP模式和网络共享的调试日志,原来也是一样的问题

你可能感兴趣的:(驱动,#,WiFi)