使用python和蓝牙进行通讯
我正在尝试编写一个简单的程序来在RPi和蓝牙手机之间进行通信。我使用了该教程:用于RPi的Bluetooth Python教程, 能够连接到手机,并且绑定正确。然后我写了这个python脚本: #! /usr/bin/python import serial from protocol import * from MotorControllerP import * def startBluetoothServer(): bluetoothSerial = serial.Serial("/dev/rfcomm1",baudrate=9600) print("Bluetooth connected") try: while 1: data = bluetoothSerial.readLine() if not data: break data = data.decode() print("Data received: "+data) if data[:3] == Client.INIT_HEY: print("Initiallizing connection") bluetoothSerial.write((Server.INIT_OK+"\n").enc$ print("Connection initiallized") elif data[:3] == …