我正在尝试使用python3dbus包在嵌入式Linux目标(mips MT7628,如果有必要的话)上控制无线
系统很可能设置正确,因为我已经在这个嵌入式目标上安装并运行了iwd+dhclient
我可以通过eth0和wlan0进行连接
我还可以通过iwctl控制iwd。到目前为止还不错
我现在需要从python3控制iwd;具体地说,我需要能够通过串行线发送扫描结果(与我的开发板相反,RealTarget将是无头的)
我无法使用dbus接口。首先我需要一些例子
我尝试了一些类似的方法:
# python
Python 3.8.1 (default, Feb 21 2020, 11:13:38)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dbus
>>> bus = dbus.SystemBus()
>>> wlan0 = bus.get_object('net.connman.iwd', '/net/connman/iwd/phy1/1')
>>> p = wlan0.Properties(dbus_interface='net.connman.iwd.Station')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.8/site-packages/dbus/proxies.py", line 72, in __call__
File "/usr/lib/python3.8/site-packages/dbus/proxies.py", line 141, in __call__
File "/usr/lib/python3.8/site-packages/dbus/connection.py", line 652, in call_blocking
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NotFound: No matching method found
>>> p = wlan0.Scan(dbus_interface='net.connman.iwd.Station')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.8/site-packages/dbus/proxies.py", line 141, in __call__
File "/usr/lib/python3.8/site-packages/dbus/connection.py", line 652, in call_blocking
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NotFound: No matching method found
>>>
当WiFi工作时,请执行以下操作:
# iwctl
[iwd]# adapter list
Adapters *
--------------------------------------------------------------------------------
Name Powered Vendor Model
--------------------------------------------------------------------------------
phy1 on --
[iwd]# device list
Devices *
--------------------------------------------------------------------------------
Name Address Powered Adapter Mode
--------------------------------------------------------------------------------
wlan1 42:c1:f8:85:67:ba on phy1 station
[iwd]# station list
Devices in Station Mode *
--------------------------------------------------------------------------------
Name State Scanning
--------------------------------------------------------------------------------
wlan1 connected
[iwd]#
。。。但我显然遗漏了一些非常基本的东西
有人能给我指一下正确的方向吗
回答我自己的问题,帮助那些在这里绊倒的人:
事实证明,iwd和connman存储库在子目录“test”中都有完整的python3示例
事实证明,根据我的具体需要调整这些内容是微不足道的
相关目录可在here (iwd)和here (connman)找到
我的具体问题的解决方案如下:scan-for-networks和list-known-networks
扫描网络:
列出已知网络:
相关问题 更多 >
编程相关推荐