最近遇到个问题,客户用我们的平板开启WiFi热点当做主设备分享WiFi,他们的产品作从设备。如果WiFi的信道是13的话从设备就无法连接,研究了下原来是WiFi国家码配置成US了,把WiFi国家码配置成CN完美解决这个问题。调试的时候从网络上找到一些不错的WiFi信道相关的adb命令,粘贴出来以免下次花是时间去找
获取国家码
adb shell cmd wifi get-country-code
查看支持能力
adb shell iw list
打开热点
adb shell cmd wifi start-softap 12:f7:c9:f3:81:8f(ssid) open -b(band) 5
更改热点信道为8
adb shell hostapd_cli set channel 8 && adb shell hostapd_cli disable && adb shell hostapd_cli enable
查看热点状态
adb shell hostapd_cli status
Selected interface 'ap0'
state=ENABLED
phy=phy1
freq=2412 # 频点
channel=1 # 信道号
edmg_enable=0
edmg_channel=0
secondary_channel=0
ieee80211n=1
ieee80211ac=1
ieee80211ax=0
beacon_int=100
dtim_period=2
ht_caps_info=000c
ht_mcs_bitmask=ff000000000000000000
supported_rates=02 04 0b 16 0c 12 18 24 30 48 60 6c
max_txpower=20
bss[0]=ap0
bssid[0]=fa:19:8a:c1:30:f4
ssid[0]=moto g22_9134
num_sta[0]=0
频点–信道表格
# A mapping of frequency to channel number. This includes some
# frequencies used outside the US.
US_CHANNELS_2G = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
US_CHANNELS_5G = [
36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128,
132, 136, 140, 144, 149, 153, 157, 161, 165
]
CHANNEL_MAP = {
2412: 1,
2417: 2,
2422: 3,
2427: 4,
2432: 5,
2437: 6,
2442: 7,
2447: 8,
2452: 9,
2457: 10,
2462: 11,
# 12, 13 are only legitimate outside the US.
2467: 12,
2472: 13,
# 14 is for Japan, DSSS and CCK only.
2484: 14,
# 34 valid in Japan.
5170: 34,
# 36-116 valid in the US, except 38, 42, and 46, which have
# mixed international support.
5180: 36,
5190: 38,
5200: 40,
5210: 42,
5220: 44,
5230: 46,
5240: 48,
# DFS channels.
5260: 52,
5280: 56,
5300: 60,
5320: 64,
5500: 100,
5520: 104,
5540: 108,
5560: 112,
5580: 116,
# 120, 124, 128 valid in Europe/Japan.
5600: 120,
5620: 124,
5640: 128,
# 132+ valid in US.
5660: 132,
5680: 136,
5700: 140,
# 144 is supported by a subset of WiFi chips
# (e.g. bcm4354, but not ath9k).
5720: 144,
# End DFS channels.
5745: 149,
5755: 151,
5765: 153,
5775: 155,
5795: 159,
5785: 157,
5805: 161,
5825: 165
}