我一直试图使用各种Python库来使用Connman和dbus,特别是这个示例代码:
https://github.com/liamw9534/pyconnman/blob/master/demo/demo.py
我遇到的问题是,当第一次连接到WPA2访问点时,我总是会收到超时消息。例如:
CONN> list-services
CONN> agent-start /test/agent ssid=myNetwork passphrase=myPassphrase
CONN> service-connect /net/connman/service/wifi_xxxxx__managed_psk最后,这是我从接口收到的消息:
没有收到答复。可能的原因包括:远程应用程序没有发送答复、消息总线安全策略阻止了答复、回复超时过期或网络连接中断。
在这一点上,我可以确认Connman没有连接到wifi网络,也没有获得IP地址。我唯一能做到这一点的方法是使用来自Linux终端的Connman应用程序本身:
connmanctl
connmanctl> agent on
connmanctl> connect wifi_xxxxx__managed_psk
Agent RequestInput wifi_xxxxx__managed_psk
Passphrase = [ Type=psk, Requirement=mandatory ]
Passphrase? myPassword
connmanctl> Connected wifi_xxxxx__managed_psk这将为wifi网络在/var/lib/connman下创建一个设置文件夹。我现在可以使用上面提到的demo.py脚本断开或重新连接。
在很多方面,Connman对我来说仍然是个谜,我不知道为什么我必须第一次使用交互式shell来连接到网络。有什么想法吗?
发布于 2018-03-06 05:42:53
如果您还在寻找答案: Connman需要一个代理来回答安全问题(在WPA2中:这是密码)。您可以运行代理并回答Connman问题,也可以使用正确的键在/var/lib/connman中创建一个文件。见这里。一旦文件被创建或删除,Connman将神奇地自动执行相应的操作(尝试连接或断开连接)。
基本文件如下所示:
service_mywificonfig类型= wifi Security = wpa2 Name = myssid Passphrase = yourpass
https://stackoverflow.com/questions/46436802
复制相似问题