当前位置: 代码迷 >> 综合 >> 网络:wpa_supplicant | wpa_cli
  详细解决方案

网络:wpa_supplicant | wpa_cli

热度:15   发布时间:2023-12-16 12:15:34.0

想让我的wlan1配置成station模式,wps上级路由,使板子可以上网

我的做法:在开机启动脚本里

dnsmasq -C /system/etc/dnsmasq.conf #配置好dnswpa_supplicant -B -i wlan1 -c /config/wpa_supplicant.conf  udhcpc -i wlan1 -b #配置dhcp

以下转:
https://blog.csdn.net/u011975319/article/details/89301849?utm_medium=distribute.pc_relevant.none-task-blog-baidujs-2

wpa_supplicant的帮助文档

usage:
wpa_supplicant [-BddhKLqqstuvW] [-P] [-g]
-i -c [-C] [-D] [-p<driver_param>]
[-b<br_ifname>] [-f] [-e]
[-o] [-O]
[-N -i -c [-C] [-D]
[-p<driver_param>] [-b<br_ifname>] …]

drivers:
nl80211 = Linux nl80211/cfg80211
options:
-b = optional bridge interface name
-B = run daemon in the background
-c = Configuration file
-C = ctrl_interface parameter (only used if -c is not)
-i = interface name
-d = increase debugging verbosity (-dd even more)
-D = driver name (can be multiple drivers: nl80211,wext)
-e = entropy file
-g = global ctrl_interface
-K = include keys (passwords, etc.) in debug output
-t = include timestamp in debug messages
-h = show this help text
-L = show license (BSD)
-o = override driver parameter for new interfaces
-O = override ctrl_interface parameter for new interfaces
-p = driver parameters
-P = PID file
-q = decrease debugging verbosity (-qq even less)
-v = show version
-W = wait for a control interface monitor before starting
-N = start describing new interface

 wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf

-D:驱动名称,有wext和nl80211
-i:网口名称
-c:指定wpa_supplicant.conf 配置文件
-B:后台运行
-d:增加调试信息。

wpa_supplicant -Dnl80211 -iwlan0 -c/data/wlan/wpa_supplicant.conf -d -B

wpa_supplicant.conf:

ctrl_interface = /var/run/wpa_supplicant   //wpa_supplicant 和 wpa_cli通信的套接子,个人理解
update_config=1	//自动更新wpa_cli操作所保存的数据
network={
    
ssid="wanyee"
psk="#wanyee*123"
}
。。。。还可以配置其他的配置,如果wifi的信息,wifi连接的优先级等等

wpa_cli 的部分帮助文档

wpa_cli [-p] [-i] [-hvB] [-a]
[-P] [-g] [-G] [command…]
-h = help (show this usage text)
-v = shown version information
-a = run in daemon mode executing the action file based on events from
wpa_supplicant
-B = run a daemon in the background
default path: /data/system/wpa_supplicant //注意:该地址为套接字的地址,如果wpa_supplicant.conf 没有把ctrl_interface指向这里,则需要使用-p指定套接字wlan0的路径。
default interface: first interface found in socket path

比如:
之前我将ctrl_interface = /data/misc/wifi/wpa_supplicant设置为该地址,
则使用wpa_cli 时就得指定-p /data/misc/wifi/wpa_supplicant 进行配置,否则会出现

Could not connect to wpa_supplicant: wlan0 - re-trying
的错误。