Android Wifi小记 (2)
Hostapd ACS 开关控制
在Android上ACS模式是打开的,ACS打开后会自动选择信道,如果驱动那边不支持可能导致hostapd无法初始化成功。所以可以关闭ACS,使用固定的信道。
public HostapdHal(Context context) {mEnableAcs = context.getResources().getBoolean(R.bool.config_wifi_softap_acs_supported);mEnableIeee80211AC =context.getResources().getBoolean(R.bool.config_wifi_softap_ieee80211ac_supported);}
采用了overlay,覆盖了aosp中设置的值。
// aosp
./frameworks/base/core/res/res/values/config.xml: <bool translatable="false" name="config_wifi_softap_acs_supported">false</bool>
./frameworks/base/core/res/res/values/symbols.xml: <java-symbol type="bool" name="config_wifi_softap_acs_supported" />// overlay
./device/qcom/common/device/overlay/frameworks/base/core/res/res/values/config.xml: <bool translatable="false" name="config_wifi_softap_acs_supported">true</bool>
./device/qcom/common/automotive/device/overlay/frameworks/base/core/res/res/values/config.xml: <bool translatable="false" name="config_wifi_softap_acs_supported">true</bool>
./vendor/qcom/proprietary/resource-overlay/common/Frameworks/res/values/config.xml: <bool translatable="false" name="config_wifi_softap_acs_supported">true</bool>
其中device, automotive 代表手机和车机平台。选择哪个是根据宏定义TARGET_BOARD_AUTO决定的。
//file path: device/qcom/common/base.mk
# enable overlays to use our version of
# source/resources etc.
ifneq ($(strip $(TARGET_BOARD_AUTO)),true)
DEVICE_PACKAGE_OVERLAYS += device/qcom/common/device/overlay
PRODUCT_PACKAGE_OVERLAYS += device/qcom/common/product/overlay
else
DEVICE_PACKAGE_OVERLAYS += device/qcom/common/automotive/device/overlay
PRODUCT_PACKAGE_OVERLAYS += device/qcom/common/automotive/product/overlay
endif
endif//file path device/qcom/msmnile_gvmq/msmnile_gvmq.mk
TARGET_BOARD_AUTO := true
hotspot 开关流程
两个步骤。
- 1 hotspot 开关不是直接操作WifiManage的 startSoftAp()打开的。
- 2 ap 相关的设置是通过WifiManage 更新的。不是随着startSoftAp传进的。
//Setting WifiTetherSettings.java @Overridepublic void onTetherConfigUpdated() {final WifiConfiguration config = buildNewConfig();mPasswordPreferenceController.updateVisibility(config.getAuthType());/*** if soft AP is stopped, bring up* else restart with new config* TODO: update config on a running access point when framework support is added*/if (mWifiManager.getWifiApState() == WifiManager.WIFI_AP_STATE_ENABLED) {Log.d("TetheringSettings","Wifi AP config changed while enabled, stop and restart");mRestartWifiApAfterConfigChange = true;mSwitchBarController.stopTether();}mWifiManager.setWifiApConfiguration(config);}//system_server WifiServiceImpl.java 需要权限private boolean checkNetworkSettingsPermission(int pid, int uid) {return mContext.checkPermission(android.Manifest.permission.NETWORK_SETTINGS, pid, uid)== PackageManager.PERMISSION_GRANTED;}//Setting WifiTetherSwitchBarController.javavoid stopTether() {mSwitchBar.setEnabled(false);mConnectivityManager.stopTethering(TETHERING_WIFI);}void startTether() {mSwitchBar.setEnabled(false);mConnectivityManager.startTethering(TETHERING_WIFI, true /* showProvisioningUi */,mOnStartTetheringCallback, new Handler(Looper.getMainLooper()));}
Wireshark 802.11 相关标签
例如过滤 Beacon / Probe response / association repsone
wlan.fc.type_subtype == 0x8 or wlan.fc.type_subtype == 0x5 or wlan.fc.type_subtype == 0x02
帧类型 | 过滤器语法 |
---|---|
Management frame | wlan.fc.type == 0 |
Control frame | wlan.fc.type == 1 |
Data frame | wlan.fc.type == 2 |
Association request | wlan.fc.type_subtype == 0x00 |
Association response | wlan.fc.type_subtype == 0x01 |
Reassociation request | wlan.fc.type_subtype == 0x02 |
Reassociation response | wlan.fc.type_subtype == 0x03 |
Probe request | wlan.fc.type_subtype == 0x04 |
Probe response | wlan.fc.type_subtype == 0x05 |
Beacon | wlan.fc.type_subtype == 0x08 |
Disassociate | wlan.fc.type_subtype == 0x0A |
Authentication | wlan.fc.type_subtype == 0x0B |
Deauthentication | wlan.fc.type_subtype == 0x0C |
Action frame | wlan.fc.type_subtype == 0x0D |
Block ACK requests | wlan.fc.type_subtype == 0x18 |
Block ACK | wlan.fc.type_subtype == 0x19 |
Power save poll | wlan.fc.type_subtype == 0x1A |
Request to send | wlan.fc.type_subtype == 0x1B |
Clear to send | wlan.fc.type_subtype == 0x1C |
ACK | wlan.fc.type_subtype == 0x1D |
Contention free period end | wlan.fc.type_subtype == 0x1E |
NULL data | wlan.fc.type_subtype == 0x24 |
QoS data | wlan.fc.type_subtype == 0x28 |
Null QoS data | wlan.fc.type_subtype == 0x2C |
Wifi Carplay hostapd.conf 配置
参考:
CarPlay wireless(蓝牙+WiFi)连接方案(Wi-Fi部分)
hostapd.conf 详解
需要配置两部分: Interworking IE & Apple Device IE
- 1 IEEE802.11 Interworking IE.
该IE要求车载设备(AP)支持。该IE中的Access NetWork Option字段用来提供是否CarPlay的车载设备(AP)提供Internet共享服务;Venue info字段用来告知该网络是由车载的设备提供,其Group code值为10(车载的设备)。
在hostapd.conf中相关配置如下:
##### IEEE 802.11u-2011 ######################################################## Enable Interworking service
interworking=1# Access Network Type
# 0 = Private network
# 1 = Private network with guest access
# 2 = Chargeable public network
# 3 = Free public network
# 4 = Personal device network
# 5 = Emergency services only network
# 14 = Test or experimental
# 15 = Wildcard
access_network_type=3# Whether the network provides connectivity to the Internet
# 0 = Unspecified
# 1 = Network provides connectivity to the Internet
internet=1# Additional Step Required for Access
# Note: This is only used with open network, i.e., ASRA shall ne set to 0 if
# RSN is used.
asra=0# Emergency services reachable
esr=0# Unauthenticated emergency service accessible
uesa=0# Venue Info (optional)
# The available values are defined in IEEE Std 802.11u-2011, 7.3.1.34.
# Example values (group,type):
# 0,0 = Unspecified
# 1,7 = Convention Center
# 1,13 = Coffee Shop
# 2,0 = Unspecified Business
# 7,1 Private Residence
venue_group=10
venue_type=1
- 2 Apple Device IE.
该IE是Vendor IE,由Vendor自定义(ID:221(0xDD),Apple的OUI:0x00-0xA0-0x40,Sub_type:0x00),该IE需要添加在车载设备(AP)的Beacon,Probe Response和Association Response帧中。而该IE中最重要的就是其payload部分,由苹果公司自定义,有Flags,Name,Manufacture,dWds,Bluetooth MAC,Device ID等信息,细节可以查看Apple的CarPlay协议中的定义。
在hostapd.conf中相关配置如下:
这个有格式的要求:
id | len | payload |
---|---|---|
1 byte | 1byte |
长度一定要和payload长度对应上,否则无法设置成功。
0xDD 代表苹果
# Additional vendor specific elements for Beacon and Probe Response frames
# This parameter can be used to add additional vendor specific element(s) into
# the end of the Beacon and Probe Response frames. The format for these
# element(s) is a hexdump of the raw information elements (id+len+payload for
# one or more elements)
vendor_elements=dd0411223301# Additional vendor specific elements for (Re)Association Response frames
# This parameter can be used to add additional vendor specific element(s) into
# the end of the (Re)Association Response frames. The format for these
# element(s) is a hexdump of the raw information elements (id+len+payload for
# one or more elements)
assocresp_elements=dd0411223301
使用 wpa_cli 连接一个AP
//在wpa_supplicant 成功运行后,运行wpa_cli,进行交互式命令行
wpa_cli
//执行扫描操作
scan
//获取扫描的结果
scan_result
//先添加一个网络,wpa_supplicant 会返回一个数值,表示第几个槽位。如果之前没有添加过网络则是0。
add_network
//然后设置0 的ssid
set_network 0 ssid "Leo's iPhone"
//设置0的 password
set_network 0 psk "lsw123456"
//使能 0
enable_network 0
//选择 0
select_network 0
//然后,等待ap连接成功。
//----- 另起一个窗口 或者退出当前命令行
//此时执行ifconfig 查看 interface节点信息,发现是没有配置ip的
ifconfig
// 需要执行 dhcp-6.8.2 执行dhcp来分配ip
dhcp-6.8.2 -iwlan0
//ping 网关地址
ping -Iwlan0 172.20.10.1
Android Wifi小记 (2)相关推荐
- Android WiFi开发教程(三)——WiFi热点数据传输
在上一篇文章中介绍了WiFi的搜索和连接,如果你还没阅读过,建议先阅读上一篇Android WiFi开发教程(二)--WiFi的搜索和连接.本篇接着简单介绍手机上如何通过WiFi热点进行数据传输. 跟 ...
- Android Wi-Fi基本操作
2019独角兽企业重金招聘Python工程师标准>>> 从用户角度看,Android Wi-Fi模块自下向上可以看为5层:硬件驱动程序,wpa_suppplicant,JNI,WiF ...
- Android Wi-Fi子系统学习笔记
一.学习目的 了解Android Wi-Fi模组的移植及调试 二.基础知识 1.wifi的两个标志: (1)无线 (2)基于IEEE802.11协议 2.Android wifi模块的三个作用 (1 ...
- Android Wifi开发之WifiConfiguration
最近在写一个和Wifi有关的程序,原来的意图是想去拿到手机当前WIFI连接下的密码.如果是对于有Root过的手机,我们可以从路径:/data/data/com.android.settings/dat ...
- mac android wifi调试
mac android wifi调试 1,用USB连接你的手机: 2,打开命令行输入: adb tcpip 5555; 结果: MacBook-Pro:~ user$ adb tcpip 5555;r ...
- android Wifi开发相关内容
今天,简单讲讲android里如何使用WifiManager. 之前,我看代码时,看到了wifi相关的代码,发现自己对于这个内容的使用还很不熟悉,所以在网上查找资料,最终解决了问题.这里记录一下. 移 ...
- Android开发之Android WIFI ADB(ADB WIFI)无线调试的技巧
老套路线上效果图 以前又adb wifi可以使用,不过那是17年我用的AS2.3版本,并且除了adb wifi这个插件外还得手机安装一个app才可以,特别麻烦. 显示有心插件了->Android ...
- Android wifi驱动的移植 realtek 8188
Android wifi驱动的移植 一般我们拿到的android源代码中wifi应用层部分是好的, 主要是wifi芯片的驱动要移植并添加进去. wifi驱动的移植, 以realtek的8188etv为 ...
- linux wifi开发书籍,Android WIFI开发介绍.pdf
Android WIFI开发介绍: WifiStateTracker 会创建WifiMonitor 接收来自底层的事件,WifiService 和WifiMonitor 是整个模块的核心.WifiSe ...
最新文章
- OPM攻击事件后:我们从中学到了什么?
- 用Go语言建立一个简单的区块链part6(2):交易(2)
- mysql to char 用法_postgresql 中的to_char()常用操作
- 最小生成树练习1(克鲁斯卡尔算法Kruskal)
- 自定义路由匹配和生成
- matlab rgb2ntsc函数,matlab 颜色模型之间的转换
- wireshark linux版本_Wireshark大法-WiFi6无线抓包
- jQuery 事件函数传参异常identifier starts immediately after numeric literal
- Hibernate中常见问题 No row with the given identifier exists问题
- python测试用例队列_Python tornado队列示例-一个并发web爬虫代码分享
- maya怎么导出abc格式_maya导入abc文件到UE4
- NIO编程--聊天室Demo
- 百度搜索正式升级冰桶算法5.0!
- 04、Hadoop框架HDFS NN、SNN、DN工作原理
- 对脚手架的使用的几点建议
- 1.2 Activity 的基本用法大全
- android root 模拟点击,免ROOT实现模拟点击任意位置
- 服务器启动项目抛错 没有到主机的路由
- 硬件SPI控制ST7789V
- 2021-11-28 Misc 杂项略览 一 图片隐写1 直接隐写【T.O.CTF】
热门文章
- 任天堂正式发布 NINTENDO SWITCH OLED,乐得瑞任天堂Switch底座方案
- vue-element-admin 的使用记录(三)
- C# 关于Microsoft.Office.Interop.Word中app.Documents.Add/Open报错
- openwrt - 入门( uHTTPd, opkg, uci, luci, mtd等)
- win7 关闭防火墙
- 程序设计综合实践——京东管理系统(C语言实现)
- 【DockerCE】onlyoffice从7.2 版本开始默认启用JWT
- 2022 春节抖音视频红包系统设计与实现
- 李刚疯狂java抄袭,推荐:疯狂java讲义--李刚著作(3)
- 操作系统篇之Linux命令操作和redis安装以及基本使用