hostapd启动失败问题排查

hostapd启动失败,第一反应是配置文件配的不对,从hostapd的启动日志或许能看出点猫腻。

hostapd的config文件如下:

#cat /data/misc/wifi/hostapd.conf                                               <
interface=wlan0
driver=nl80211
ctrl_interface=/data/misc/wifi/hostapd
ssid=MyAP
channel=13
ieee80211n=1
hw_mode=ad
ht_capab=[SHORT-GI-20][SHORT-GI-40][HT40+]
ignore_broadcast_ssid=0
wowlan_triggers=any
#

 报错日志如下:

I/hostapd (15503): wlan0: IEEE 802.11 ---------Configured channel (13) not found from the channel list of current mode (1) IEEE 802.11g
W/hostapd (15503): wlan0: IEEE 802.11 ---------Configured channel (13) not found from the channel list of current mode (1) IEEE 802.11g
I/hostapd (15503): wlan0: IEEE 802.11 Hardware does not support configured channel
W/hostapd (15503): wlan0: IEEE 802.11 Hardware does not support configured channel
E/hostapd (15503): Could not select hw_mode and channel. (-3)
I/hostapd (15503): wlan0: interface state UNINITIALIZED->DISABLED
I/hostapd (15503): wlan0: AP-DISABLED 
E/hostapd (15503): wlan0: Unable to setup interface.

从报错看是不支持13信道,第一反应是网卡国家码不对。

iw reg get查看国家码是US,确实不支持13信道。重新配置网卡国家码为CN:iw reg set CN,配置失败,设置后会重新变回US,看来网卡驱动的配置是以环境的AP来配置国家码的。

重新设置网卡的WCNSS_qcom_cfg.ini文件以支持手动配置国家码,并强制关闭环境AP的配置:

gStaCountryCode=CN    //默认sta的国家码为CN
gAPCntryCode=CN       //默认AP的国家码为CN
g11dSupportEnabled=0  //关闭国家码从环境获取

这个文件一开始以为是kernel中生效的,但是改了后重新安装网卡驱动并没有生效,最后才发现此init生效是在启动hostapd或者wpa_supplicant时动态加载的,所以尝试调整网卡参数时可直接在设备上修改这个文件[/system/lib/qcom.ini]。

好了,国家码能正常设置了,但是启动hostapd还是直接退出了,报错还是不支持13信道。

没办法,就去看了一下hostapd报错的位置的代码。

static int hostapd_is_usable_chans(struct hostapd_iface *iface)
{
       if (!hostapd_is_usable_chan(iface, iface->conf->channel, 1)) 
              return 0;

       if (!iface->conf->secondary_channel)
              return 1;

       return hostapd_is_usable_chan(iface, iface->conf->channel +
                                  iface->conf->secondary_channel * 4, 0); 
}

原来,配置文件中指定的启动HT40[即信道带宽是40MHz]时,要求辅信道也必须在支持的信道内。HT40+是指辅信道是主信道+4,17信道是不支持的,因此配置失败了。

同样,5G信道也有一些配置是不允许的,除非查看代码,不然也搞不懂失败的原因。

5G时设置hostapd失败打印:

I/hostapd (  661): wlan0: interface state UNINITIALIZED->HT_SCAN
E/hostapd (  661): HT40 channel pair (153, 1) not allowed
I/hostapd (  661): Fallback to 20 MHz
E/hostapd (  661): Interface initialization failed
I/hostapd (  661): wlan0: interface state HT_SCAN->DISABLED
I/hostapd (  661): wlan0: AP-DISABLED 
E/hostapd (  661): hostapd_free_hapd_data: Interface wlan0 wasn't started

而代码中指定要求5G时hostapd的信道只能有以下几个:

int allowed[] = { 36, 44, 52, 60, 100, 108, 116, 124, 132, 140,
                  149, 157, 184, 192 };

 

  • 4
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值