1. wpa_cli -i wlan0 set country [country_code]
2. service call wifi [setCountryCode_CODE] s16 [country_code]
setCountryCode_CODE 是对应代码中IWifiManager.aidl中interface IWifiManager的setCountryCode方法对应的位置(从1计数)。
3. iw reg set [country_code]
在进行wifi信令测试时,常常会报一些信道连接fail的问题。
一般是由国家码导致的,因为当前测试信道该国家码并不支持。
Android手机中,其country code是根据sim卡去配置的,如果没有使用sim卡的话,软件默认国家码是US,即只支持1~11信道。
这时候就需要软件支持,能够设置对应的国家码。当然,可以轻松的修改软件,编译代码,给出支持对应国家码的版本。但这种方式并不灵活。
通过命令修改,就很方便了。
A. 如何查看当前国家码?
1. dmesg | grep country. 比如Qcom平台会有如下log:
wlan: [591:I :HDD] hdd_reg_notifier: 722: country: US, initiator 2, dfs_region: 1
cfg80211: Regulatory domain changed to country: US
2. wpa_cli -i wlan0 get country. 这种方式,有时会查询失败。
# wpa_cli -i wlan0 get country
FAIL //查询失败
# wpa_cli -i wlan0 get country
US //查询