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

发布于 2024-08-19 05:53:07 字数 129 浏览 6 评论 0原文

hai Guyz,

我如何从Python应用程序通过蓝牙发送AT命令?

操作系统:fedora 8

有人请用代码帮助我吗?

我需要导入哪个包?

我可以从哪里下载它?

hai guyz,

how can i send AT-command through bluetooth from a python application?

OS:fedora 8

Any one please healp me with the code?

which package i need to import?

from where can i download it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

岁月静好 2024-08-26 05:53:07

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

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。

michael@challenger:~> cu -l /dev/rfcomm0
Connected.
ATI
Research in Motion BlackBerry IP Modem

OK

获得 rfcomm0 端口后,您可以将该端口视为标准串行端口,然后就可以开始使用了。

To get a connection over bluetooth to your IP modem, you want to use the bluetooth
rfcomm driver:

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";
}

This is the setup I use for mine - YMMV.

michael@challenger:~> cu -l /dev/rfcomm0
Connected.
ATI
Research in Motion BlackBerry IP Modem

OK

Once you have the rfcomm0 port, you treat the port as a standard serial port and you're good to go.

逆夏时光 2024-08-26 05:53:07

我觉得这个比较好......

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()

I think this is better.......

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()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文