首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Python蓝牙发送Passkey

Python蓝牙发送Passkey
EN

Stack Overflow用户
提问于 2018-02-09 23:47:09
回答 1查看 266关注 0票数 0

在python中,我正在尝试通过蓝牙连接设备。我还想自动发送蓝牙密钥。我尝试了一个使用子进程的方法,但是我得到了一个错误。

代码

代码语言:javascript
复制
import subprocess

from bluetooth import *

print "performing inquiry..."

nearby_devices = discover_devices(lookup_names = True)

print "found %d devices" % len(nearby_devices)

for name, addr in nearby_devices:
 print " %s - %s" % (addr, name)


# kill any "bluetooth-agent" process that is already running
subprocess.call("kill -9 `pidof bluetooth-agent`",shell=True)

# Start a new "bluetooth-agent" process where XXXX is the passkey
status = subprocess.call("bluetooth-agent 9999 &",shell=True)

# Now, connect in the same way as always with PyBlueZ
# Create the client socket
client_socket=BluetoothSocket( RFCOMM )

client_socket.connect(("08:3D:88:1D:61:41", 3))

错误

代码语言:javascript
复制
'kill' is not recognized as an internal or external command,
operable program or batch file.
'bluetooth-agent' is not recognized as an internal or external command,
operable program or batch file.
EN

回答 1

Stack Overflow用户

发布于 2018-02-10 01:38:38

进行调用,处理这样的进程还有其他问题,但最明显的,也是导致失败的一个问题是,你正在运行windows版本的python (显然是用cmd.exe执行的),并试图执行类似U*X的命令(并使用类似sh的语法)。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48709432

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档