rfkill - RF kill switch support (翻译)

1、介绍

          rfkill子系统在系统对于禁止无线设备工作提供了一个通用的接口,当无线设备被阻止工作时,它就不会在消耗功率。这个子系统在用户开关按钮上提供了一个方法去阻止某种无线设备的工作。这是用于某些环境下(比如飞机) ,无线设备就必须被关闭。子系统有硬件和软件模块的概念。在概念上这些意义很小,关于在于它能否被改变。

2、实现细节
       rfkill核心为内核驱动提供了API,这是为了在内核中注册这些无线设备。这种方法的打开或者关闭 是为了让系统知道硬件设备的工作状态。当设备是硬件模块(可以被rfkill_set_hw_state() 或者from query_hw_block调用),set_block()可以被其他的软件模块调用,驱动程序忽视这个方法的调用,他们可以用rfkill_set_hw_state()的返回值去同步软件的状态而不是一直在调用set_block(),实际上,驱动程序应该用rfkill_set_hw_state()的返回值,除非硬件实际上一直保持软件和硬件的独立。

3、内核API
      无线设备的驱动基本上实现了rfkill的驱动。如果rfkill开关只是一个按钮,平台驱动可能实现输入设备驱动。这个开关影响硬件的工作,所以你需要实现rfkill的驱动。平台需要提供一个方法去开(关)设备的方法。当一个状态改变的时候,除非他们分配了poll_hw_block()回调,rfkill_set_hw_state()就会被调用。

 4、userspace 支持
        被推荐使用的用户接口是/dev/rfkill,这是一个混合的字符设备,他允许用户空间使用和设置rfkill设备的状态。这也通知用户空间关于设备的增加和移除。在linux/rfkill.h中的API也就是一般简单的读/写API,对于打开或者关闭的过渡时期,ioctl需要传入关闭的状态。
      除了ioctl,和内核通信通过read()和write(),而不是struct rfkill_event。在这个结构体中,软件和硬件模块被分开。用户空间在系统中能得到rfkill驱动的状态。当然rfkill驱动的状态同事也得更新默认热插设备的状态。当一个应用打开/dev/rfkill,他可以读取到当前所有设备的状态。通过查询设备变化的消息和监听rfkill core发出的uevent,设备状态的变化可以被获得。另外,每个 rfkill的设备在sysfs和 emits uevents 中被注册。

   

展开阅读全文

求助!使用wpa_supplicant连接WIFI问题

11-08
公司有个项目需要手机同时打开wifi+4g wifi链接专用设备, 4G与外网通信 (众所周知,手机打开wifi后,4g将自动关闭) 研发阶段用的 红米手机,通过如下方法能实现 adb命令: 挂载wifi网卡 insmod /system/lib/modules/wlan.ko 开启wifi网卡 netcfg wlan0 up 后台链接wifi wpa_supplicant -iwlan0 -c/data/misc/wifi/wpa_supplicant.conf -B dhcp自动获取ip dhcpcd wlan0 设置路由 ip route add 192.0.0.0/8 dev wlan0 临上线客户选用了mate s 手机,机子采购回来以后,先root然后adb执行如上命令,到wpa_supplicant -iwlan0 -c/data/misc/wifi/wpa_supplicant.conf -B这句的时候 logcat显示 11-08 20:09:08.338 13647-13647/? E/wpa_supplicant: interface wlan0 11-08 20:09:08.582 13647-13647/? I/wpa_supplicant: rfkill: Cannot open RFKILL control device 11-08 20:09:08.338 13647-13647/? E/wpa_supplicant: WIFI_lib_init WIFI_lib_init WIFI_lib_init WIFI_lib_init 11-08 20:09:08.341 13647-13647/? I/wpa_supplicant: nl80211: Could not re-add multicast membership for vendor events: -2 (No such file or directory) 11-08 20:09:08.470 13647-13647/? E/wpa_supplicant: Own WAPI MAC address: dc:ee:06:f0:00:30 11-08 20:09:08.582 13647-13647/? E/wpa_supplicant: interface p2p-dev-wlan0 11-08 20:09:08.582 13647-13647/? I/wpa_supplicant: rfkill: Cannot open RFKILL control device 11-08 20:09:08.582 13647-13647/? E/wpa_supplicant: Could not read interface p2p-dev-wlan0 flags: No such device 11-08 20:09:08.588 13647-13647/? I/wpa_supplicant: nl80211: Could not re-add multicast membership for vendor events: -2 (No such file or directory) 11-08 20:09:08.588 13647-13647/? E/wpa_supplicant: Own WAPI MAC address: 00:00:00:00:00:00 后面dhcp的就卡住不会执行了..... 看样子是没有链接上wlan 已经折腾了一周多了,google,baidu相关的资料很少. 有没有高手知道这个问题大概出在什么地方呢?求大师指条明路, 另外,华为机子里没有wifi模块/system/lib/modules/wlan.ko 但是关闭wifi后模块不会被卸载所以没有执行/system/lib/modules/wlan.ko,不知道有没有影响

开发板使用wpa_cli连接wifi出问题!

12-07
wifi 配置如下: sudo wpa_passphrase G-STAR2 G-STAR1211 > /etc/wpa_supplicant.conf 运行如下: sudo wpa_supplicant -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf 终端显示: a_supplicant/wpa_supplicant.confplicant$ sudo wpa_supplicant -i wlan0 -c /etc/wpa ioctl[SIOCSIWENCODEEXT]: Invalid argument ioctl[SIOCSIWENCODEEXT]: Invalid argument ioctl[SIOCSIWSCAN]: Device or resource busy wlan0: Failed to initiate AP scan ioctl[SIOCSIWSCAN]: Device or resource busy wlan0: Failed to initiate AP scan wlan0: Trying to associate with a0:63:91:34:b1:63 (SSID='G-STAR2' freq=2472 MHz) ioctl[SIOCSIWFREQ]: Device or resource busy ioctl[SIOCSIWESSID]: Device or resource busy wlan0: Association request to the driver failed wlan0: Associated with a0:63:91:34:b1:63 wlan0: WPA: Key negotiation completed with a0:63:91:34:b1:63 [PTK=CCMP GTK=CCMP] wlan0: CTRL-EVENT-CONNECTED - Connection to a0:63:91:34:b1:63 completed (auth) [id=0 id_str=] wlan0: CTRL-EVENT-DISCONNECTED bssid=a0:63:91:34:b1:63 reason=0 ioctl[SIOCSIWENCODEEXT]: Invalid argument ioctl[SIOCSIWENCODEEXT]: Invalid argument wlan0: Trying to associate with a0:63:91:34:b1:63 (SSID='G-STAR2' freq=2472 MHz) ioctl[SIOCSIWFREQ]: Device or resource busy wlan0: Association request to the driver failed wlan0: Associated with a0:63:91:34:b1:63 wlan0: WPA: Key negotiation completed with a0:63:91:34:b1:63 [PTK=CCMP GTK=CCMP] wlan0: CTRL-EVENT-CONNECTED - Connection to a0:63:91:34:b1:63 completed (reauth) [id=0 id_str=] wlan0: CTRL-EVENT-DISCONNECTED bssid=a0:63:91:34:b1:63 reason=0 ioctl[SIOCSIWENCODEEXT]: Invalid argument ioctl[SIOCSIWENCODEEXT]: Invalid argument wlan0: Trying to associate with a0:63:91:34:b1:63 (SSID='G-STAR2' freq=2472 MHz) ioctl[SIOCSIWFREQ]: Device or resource busy wlan0: Association request to the driver failed wlan0: Associated with a0:63:91:34:b1:63 wlan0: WPA: Key negotiation completed with a0:63:91:34:b1:63 [PTK=CCMP GTK=CCMP] wlan0: CTRL-EVENT-CONNECTED - Connection to a0:63:91:34:b1:63 completed (reauth) [id=0 id_str=] wlan0: CTRL-EVENT-DISCONNECTED bssid=a0:63:91:34:b1:63 reason=0 ioctl[SIOCSIWENCODEEXT]: Invalid argument ioctl[SIOCSIWENCODEEXT]: Invalid argument wlan0: Trying to associate with a0:63:91:34:b1:63 (SSID='G-STAR2' freq=2472 MHz) ioctl[SIOCSIWFREQ]: Device or resource busy wlan0: Association request to the driver failed wlan0: Associated with a0:63:91:34:b1:63 wlan0: WPA: Key negotiation completed with a0:63:91:34:b1:63 [PTK=CCMP GTK=CCMP] wlan0: CTRL-EVENT-CONNECTED - Connection to a0:63:91:34:b1:63 completed (reauth) [id=0 id_str=] wlan0: CTRL-EVENT-DISCONNECTED bssid=a0:63:91:34:b1:63 reason=0 ioctl[SIOCSIWENCODEEXT]: Invalid argument 反正我发现,就是一时连上一时又连不上,退出后 ifconfig ,发现wlan0没有up上. 求大神解答!!
©️2020 CSDN 皮肤主题: 大白 设计师: CSDN官方博客 返回首页
实付0元
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值