当前位置:   article > 正文

wpa_cli、wpa_supplicant连接热点_wpa_supplicant + wpa_cli

wpa_supplicant + wpa_cli

需要将rtl8821cs.ko、wpa_cli、wpa_supplicant等移植到板子上,wpa_supplicant包含两个主要的可执行工具:wpa_supplicant和wpa_cli。wpa_supplicant是核心程序,它和wpa_cli的关系就是服务和客户端的关系:后台运行wpa_supplicant,使用wpa_cli来搜索、设置、和连接网络。
在wpa_cli交互模式下可以执行很多命令,列表如下:

Full commandShort commandDescription
statusstatdisplays the current connection status
disconnectdiscprevents wpa_supplicant from connecting to any access point
quitqexits wpa_cli
terminatetermkills wpa_supplicant
reconfigurereconreloads wpa_supplicant with the configuration file supplied (-c parameter)
scanscanscans for available access points (only scans it, doesn‘t display anything)
scan_resultscan_rdisplays the results of the last scan
list_networkslist_ndisplays a list of configured networks and their status (active or not, enabled or disabled)
select_networkselect_nselect a network among those defined to initiate a connection (ie select_network 0)
enable_networkenable_nmakes a configured network available for selection (ie enable_network 0)
disable_networkdisable_nmakes a configured network unavailable for selection (ie disable_network 0)
remove_networkremove_nremoves a network and its configuration from the list (ie remove_network 0)
add_networkadd_nadds a new network to the list. Its id will be created automatically
set_networkset_nshows a very short list of available options to configure a network when supplied with no parameters.
See next section for a list of extremely useful parameters to be used with set_network and get_network.
get_networkget_ndisplays the required parameter for the specified network. See nextsection for a list of parameters
save_configsave_csaves the configuration

以下命令安装驱动,启动wpa_supplicant:

insmod /root/wifi/rtl8821cs.ko
wpa_supplicant -Dnl80211 -iwlan0 -cwpa.conf -B
  • 1
  • 2

执行 scan 扫描热点后,执行 scan_results 查看结果:
在这里插入图片描述
记住 ssid 并根据热点密码设置连接信息,执行 add_network 添加网络获取添加的网络号,根据此号使用 set_network 热点名和密码,使用 select_network 选择即可,正常情况下就能连接到热点了。
在这里插入图片描述
状态变为 CTRL-EVENT-CONNECTED 就连接成功了:
在这里插入图片描述
要使用wifi作为AP,让其他设备能连接到此设备,则还需要hostapd、dhcpd等。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/163563
推荐阅读
相关标签
  

闽ICP备14008679号