connmanctl 指令笔记

wiki地址:https://wiki.archlinux.org/title/ConnMan

配置文件路径为: /var/lib/connman

路径下目录内容如下图:

wifi_*文件夹内为wifi的配置文件settings和数据文件data,settings内容如下:

复制代码
[wifi_4479a2e30e16_577234225232d3547_managed_psk]
Name=wifi名字
SSID=577234225232d3547
Frequency=5180
Favorite=true
AutoConnect=true
Modified=2024-03-22T01:56:40.680788Z
Passphrase=1234567890
IPv4.method=dhcp
IPv6.method=auto
IPv6.privacy=disabled
IPv4.DHCP.LastAddress=192.168.1.219

connmanctl指令的具体介绍就不说了,先上个help

bash 复制代码
connmanctl> help
state                                 Shows if the system is online or offline
technologies                          Display technologies
clock                                 Get System Clock Properties
enable          <technology>|offline  Enables given technology or offline mode
disable         <technology>|offline  Disables given technology or offline mode
tether          <technology> on|off
            wifi [on|off] <ssid> <passphrase> Enable, disable tethering, set SSID and passphrase for wifi
services        [<service>]           Display services
   --properties      [<service>]      (obsolete)
peers           [peer]                Display peers
scan            <technology>          Scans for new services for given technology
connect         <service/peer>        Connect a given service or peer
disconnect      <service/peer>        Disconnect a given service or peer
move-before     <service> <target service>      Move <service> before <target service>
move-after      <service> <target service>      Move <service> after <target service>
config          <service>             Set service configuration options
   --nameservers     <dns1> [<dns2>] [<dns3>]
   --timeservers     <ntp1> [<ntp2>] [...]
   --domains         <domain1> [<domain2>] [...]
   --ipv6            off|auto [enable|disable|preferred]|
                        manual <address> <prefixlength> <gateway>
   --proxy           direct|auto <URL>|manual <URL1> [<URL2>] [...]
                        [exclude <exclude1> [<exclude2>] [...]]
   --autoconnect     yes|no
   --ipv4            off|dhcp|manual <address> <netmask> <gateway>
   --remove                           Remove service
monitor         [off]                 Monitor signals from interfaces
   --services        [off]            Monitor only services
   --tech            [off]            Monitor only technologies
   --manager         [off]            Monitor only manager interface
   --vpnmanager      [off]            Monitor only VPN manager interface
   --vpnconnection   [off]            Monitor only VPN connections
agent           on|off                Agent mode
vpnconnections  [<connection>]        Display VPN connections
vpnagent        on|off                VPN Agent mode
session         on|off|connect|disconnect|configEnable or disable a session
   --bearers         <technology1> [<technology2> [...]]
   --type            local|internet|any
   --ifname          [<interface_name>]
   --srciprule       yes|no
peer_service    register|unregister <specs> <master>
Where specs are:
        bjr_query <query> bjr_response <response>
        upnp_service <service> upnp_version <version>
        wfd_ies <ies>
(Un)Register a Peer Service
help                                  Show help
exit                                  Exit
quit                                  Quit

简单说一下主要指令

bash 复制代码
# 搜索wifi
scan wifi
# 获取wifi列表
services
# 显示一个wifi状态
services wifi_4479a2e30e16_5445535431363838_managed_psk
# 注册,连接前必须先注册
agent on
# 连接
connect wifi_4479a2e30e16_5445535431363838_managed_psk
# 断开
disconnect wifi_4479a2e30e16_5445535431363838_managed_psk
# 设置自动连接
config wifi_4479a2e30e16_5445535431363838_managed_psk --autoconnect no
config wifi_4479a2e30e16_5445535431363838_managed_psk--autoconnect yes
# 移除
config wifi_4479a2e30e16_5445535431363838_managed_psk --remove

部分指令结果说明

bash 复制代码
connmanctl> services
*AO eeeeeee-0-5G         wifi_4479a2e30e16_5775556786756e2d322d3547_managed_psk
    ZiFiT                wifi_4479a2e30e16_5a69466954_managed_psk
    WYY-IoT              wifi_4479a2e30e16_5759592d496f54_managed_psk
                         wifi_4479a2e30e16_hidden_managed_none
    TEST1688             wifi_4479a2e30e16_5445535431363838_managed_psk
    Xiaomi_ABC7          wifi_4479a2e30e16_5869616f6d695f41424337_managed_psk
    ZSYS                 wifi_4479a2e30e16_5a535953_managed_psk
    360WiFi-9BDFFF       wifi_4479a2e30e16_333630576946692d394244464646_managed_psk
    ChinaUnicom-9D28     wifi_4479a2e30e16_4368696e61556e69636f6d2d39443238_managed_psk
    YP                   wifi_4479a2e30e16_5950_managed_psk
    ChinaNet-3tNs        wifi_4479a2e30e16_4368696e614e65742d33744e73_managed_psk
    ChinaUnicom-9D28-5G  wifi_4479a2e30e16_4368696e61556e69636f6d2d394432382d3547_managed_psk


# 说明
    每行名称前4个字节表示状态
    第1个字母为Favorite状态
    第2个字母为AutoConnect状态
    第3个字母为State状态
    第3个字母为空格,也不排除可能为其他

    Favorite 为True时,第一个字母为 *, False时为空
    AutoConnect 为True时,第二字母为 A, False时为空

    State = idle 时, 为空
    State = association 时,第3个字母为a
    State = configuration 时,第3个字母为c
    State = ready 时,第3个字母为R
    State = online 时,第3个字母为O
bash 复制代码
connmanctl> services wifi_4479a2e30e16_5775597559756e2d322d3547_managed_psk
/net/connman/service/wifi_4479a2e30e16_5775597559756e2d322d3547_managed_psk
  Type = wifi
  Security = [ psk, wps ]
  State = online
  Strength = 71
  Favorite = True
  Immutable = False
  AutoConnect = True
  Name = wifi名字
  Ethernet = [ Method=auto, Interface=wlan0, Address=44:79:A2:E3:0E:16, MTU=1500 ]
  IPv4 = [ Method=dhcp, Address=192.168.1.6, Netmask=255.255.255.0, Gateway=192.168.1.1 ]
  IPv4.Configuration = [ Method=dhcp ]
  IPv6 = [ Method=auto, Address=240e:3b1:f1f1:43e0:4679:a2ff:fee3:e16, PrefixLength=64, Privacy=disabled ]
  IPv6.Configuration = [ Method=auto, Privacy=disabled ]
  Nameservers = [ fe80::1, 192.168.1.1, fe80::1 ]
  Nameservers.Configuration = [  ]
  Timeservers = [ 192.168.1.1 ]
  Timeservers.Configuration = [  ]
  Domains = [  ]
  Domains.Configuration = [  ]
  Proxy = [ Method=direct ]
  Proxy.Configuration = [  ]
  Provider = [  ]


# 说明:
Favorite 使用config ***** --remove 指令修改
AutoConnect 使用config ***** --autoconnect no 指令修改
State 值:association->configuration->ready->online
相关推荐
无心水2 小时前
24、系统架构师论文写作专题 核心考点与学习笔记
笔记·学习·系统架构·架构师·安全架构·软考架构师·软考系统架构设计师
蒸蒸yyyyzwd2 小时前
邓明 Agent 系统面试-意图识别学习笔记
笔记·学习
Zhao-Jichao5 小时前
AI Prompting for Everyone 课程笔记 - P21 总结 Conclusion
人工智能·笔记
欢欢李5 小时前
【LTE L3 笔记 05】LTE同步信号
笔记·无线通信·物理层·lte·空口协议
La Pulga7 小时前
【FreeRTOS源码学习笔记】空闲任务与阻塞延时
笔记·mcu·学习·嵌入式·freertos·实时操作系统
蒸蒸yyyyzwd7 小时前
秋招学习笔记 day106
笔记·学习
小李不想当小白8 小时前
WDG看门狗(STM32标准库学习笔记)
笔记·stm32·单片机·嵌入式硬件·学习·嵌入式
欢欢李8 小时前
【LTE L3 笔记 04】LTE帧结构
笔记·无线通信·物理层·lte·空口协议
Zhao-Jichao11 小时前
AI Prompting for Everyone 课程笔记 - P20 实验与期末项目 Lab and Final Project
前端·人工智能·笔记
Z21-X11 小时前
云原生运维实战笔记:企业网站综合上云部署与云运维服务全景解析
运维·笔记·学习·云原生