从python应用程序通过蓝牙发送ATcommand

2024-04-27 05:23:42 发布

您现在位置:Python中文网/ 问答频道 /正文

海古兹

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

OS:软呢帽8

有谁能告诉我密码吗?在

我需要导入哪个包?在

从哪里可以下载?在


Tags: 命令应用程序密码osat呢帽
2条回答

我觉得这样更好。。。。。。。在

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

要通过蓝牙连接到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。在

^{2}$

一旦你有了rfcomm0端口,你就把这个端口当作一个标准的串行端口,你就可以开始了。在

相关问题 更多 >