wpa_supplicant 使用手冊
本編用於介紹 SylixOS 下的 wpa_supplicant 使用方法。
概述
wpa_supplicant 是一款用於連接 AP 熱點的應用工程,藉助這個程序,可以使 SylixOS 下的無線網卡作爲一個 STA 設備去連接想要連接的熱點。
使用方法
本篇以連接一個 AP 熱點爲例,說明如何使用 wpa_supplicant。這個熱點的信息如下:
ssid: QInf_ACOINFO
密碼:mima8ge8
編譯部署
首先從 git 倉庫中下載好對應的源碼工程,然後導入 IDE 進行編譯。編譯完成後,直接 upload 將編譯好的內容部署到 SylixOS 硬件中。
配置文件
wpa_supplicant 啓動時是需要指定配置文件的。
通過配置文件,可以說明,如何去連接一個 AP 熱點,以下是一個簡單的配置文件 demo
country=CN
network={
ssid="QInf_ACOINFO"
psk="mima8ge8"
}
連接熱點
有了配置文件之後,就可以啓動 wpa_supplicant 去連接配置文件中的 AP 熱點。
啓動 wpa_supplicant 可以跟如下一些參數:
[root@sylixos:/root]# wpa_supplicant
Successfully initialized wpa_supplicant
wpa_supplicant v2.4
Copyright (c) 2003-2015, Jouni Malinen <j@w1.fi> and contributors
This software may be distributed under the terms of the BSD license.
See README for more details.
usage:
wpa_supplicant [-BddhKLqqtvW] [-P<pid file>] [-g<global ctrl>] \
[-G<group>] \
-i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] [-p<driver_param>] \
[-b<br_ifname>] [-e<entropy file>] \
[-o<override driver>] [-O<override ctrl>] \
[-N -i<ifname> -c<conf> [-C<ctrl>] [-D<driver>] \
[-p<driver_param>] [-b<br_ifname>] [-I<config file>] ...]
drivers:
wext = SylixOS wireless extensions (generic)
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
-I = additional configuration file
-d = increase debugging verbosity (-dd even more)
-D = driver name (can be multiple drivers: nl80211,wext)
-e = entropy file
-g = global ctrl_interface
-G = global ctrl_interface group
-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
example:
wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf
其中 -D 表明 wpa_supplicant 使用哪個驅動程序, -i 後面跟對應的無線網卡,-c 跟對應的配置文件。因此上述用例,可以使用如下命令,進行啓動:
wpa_supplicant -Dwext -iwlan0 -c/etc/wpa.conf
此後, wpa_supplicant 就會去自動連接 AP