WiFi GUI management tool

本文介绍如何使用wpa_supplicant作为Wi-Fi管理守护进程,并通过GUI工具进行配置。主要内容包括配置文件详解、守护进程启动参数说明及如何实现守护进程的平滑重启。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

In my new embedded device,I use wpa_supplicant as the wifi backend management daemon.So,

for user's convenience use,I need to write a GUI configuration tool. I don't want to know more

about the wpa commands. I have a good idea,I dump the WiFi's ssid and password to a config file,

and restart the wpa_supplicant daemon,to let it autoconnect at startup time.To better control,I should

kill the old wpa_supplicant daemon. The wpa_supplicant supplies some useful command arguments

-B

-c

-i

-P pid file

I start the daemon use the following arguments:

wpa_supplicant -i wlan0 -B -c /etc/wpa_supplicant.conf -P /var/run/wpa_supplicant.pid

The config file contains the following parts:

ctrl_interface=/var/run/wpa_supplicant

network={

           ssid="zhangshaoyan"

           psk="yantai"

}

When the user operates in the GUI,then kill the previous daemon with this command:

cat /var/run/wpa_supplicant | kill -9.


yantai:/home/shell.albert/tools # wpa_supplicant

Successfully initialized wpa_supplicant
wpa_supplicant v2.2
Copyright (c) 2003-2014, Jouni Malinen <j@w1.fi> and contributors

This software may be distributed under the terms of the BSD license.
See README for more details.

This product includes software developed by the OpenSSL Project
for use in the OpenSSL Toolkit (http://www.openssl.org/)

usage:
  wpa_supplicant [-BddhKLqqtuvW] [-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>] [-f<debug file>] \
        [-o<override driver>] [-O<override ctrl>] \
        [-N -i<ifname> -c<conf> [-C<ctrl>] [-D<driver>] \
        [-m<P2P Device config file>] \
        [-p<driver_param>] [-b<br_ifname>] [-I<config file>] ...]

drivers:
  nl80211 = Linux nl80211/cfg80211
  wext = Linux wireless extensions (generic)
  wired = Wired Ethernet driver
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
  -f = log output to debug file instead of stdout
  -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)
  -u = enable DBus control interface
  -v = show version
  -W = wait for a control interface monitor before starting
  -m = Configuration file for the P2P Device interface
  -N = start describing new interface
example:
  wpa_supplicant -Dnl80211 -iwlan0 -c/etc/wpa_supplicant.conf
yantai:/home/shell.albert/tools #



必须要跟上-B参数放到后台运行,才会生成PID文件。

yantai:/home/shell.albert # wpa_supplicant  -i wlp5s0 -c /etc/wpa_supplicant/wpa_supplicant.conf -P /home/shell.albert/wpa.pid  -B
Successfully initialized wpa_supplicant
yantai:/home/shell.albert # 

yantai:/home/shell.albert # ls -l *.pid
-rw-r--r-- 1 root root 6 May 26 15:03 wpa.pid
yantai:/home/shell.albert # cat wpa.pid
11727
yantai:/home/shell.albert # ps aux | grep wpa
root       948  0.0  0.0  30836  3772 ?        Ss   08:37   0:00 /usr/sbin/wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -u -f /var/log/wpa_supplicant.log
root     11727  0.0  0.0  31048  2016 ?        Ss   15:03   0:00 wpa_supplicant -i wlp5s0 -c /etc/wpa_supplicant/wpa_supplicant.conf -P /home/shell.albert/wpa.pid -B
root     11743  0.0  0.0  10524  1528 pts/4    S+   15:04   0:00 grep --color=auto wpa
yantai:/home/shell.albert # kill 11727
yantai:/home/shell.albert # ps aux | grep wpa
root       948  0.0  0.0  30836  3772 ?        Ss   08:37   0:00 /usr/sbin/wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -u -f /var/log/wpa_supplicant.log
root     11750  0.0  0.0  10524  1624 pts/4    S+   15:04   0:00 grep --color=auto wpa
yantai:/home/shell.albert #

yantai:/home/shell.albert # kill `cat wpa.pid`
yantai:/home/shell.albert # ps aux | grep wpa
root       948  0.0  0.0  30836  3772 ?        Ss   08:37   0:00 /usr/sbin/wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -u -f /var/log/wpa_supplicant.log
root     11807  0.0  0.0  10524  1624 pts/4    S+   15:06   0:00 grep --color=auto wpa
yantai:/home/shell.albert #





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值