首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从python应用程序通过蓝牙发送AT命令

从python应用程序通过蓝牙发送AT命令
EN

Stack Overflow用户
提问于 2010-01-29 18:49:56
回答 2查看 2.8K关注 0票数 0

哈伊盖兹,

如何从python应用程序通过蓝牙发送AT-command?

操作系统:fedora 8

有没有人能用代码治好我?

我需要导入哪个包?

我可以从哪里下载?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2010-03-10 17:51:44

我觉得这样更好......

代码语言:javascript
复制
import bluetooth 
sockfd = bluetooth.BluetoothSocket(bluetooth.RFCOMM) 
sockfd.connect(('00:24:7E:9E:55:0D', 1)) # BT Address 
sockfd.send('ATZ\r') 
time.sleep(1) 
sockfd.send(chr(26)) 
sockfd.close()
票数 1
EN

Stack Overflow用户

发布于 2010-01-30 01:45:31

要通过蓝牙连接到IP调制解调器,您需要使用蓝牙rfcomm驱动程序:

代码语言:javascript
复制
michael@challenger:~> cat /etc/bluetooth/rfcomm.conf  
rfcomm0 {
        # Automatically bind the device at startup
        bind yes;
        # Bluetooth address of the device
        device 00:1C:CC:XX:XX:XX;
        # RFCOMM channel for the connection
        channel 1;
        # Description of the connection
        comment "Blackberry";
}

这是我使用的设置- YMMV。

代码语言:javascript
复制
michael@challenger:~> cu -l /dev/rfcomm0
Connected.
ATI
Research in Motion BlackBerry IP Modem

OK

一旦拥有了rfcomm0端口,您就可以将该端口作为标准串行端口来使用了。

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

https://stackoverflow.com/questions/2161365

复制
相关文章

相似问题

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