Python UWP蓝牙连接到Raspberry Pi的异步错误。未找到元素

Python UWP蓝牙连接到Raspberry Pi的异步错误。未找到元素,python,bluetooth,uwp,raspberry-pi,windows-applications,Python,Bluetooth,Uwp,Raspberry Pi,Windows Applications,我正在制作一个Windows UWP应用程序,它使用RFCOMM与Raspberry Pi通信。我的Windows笔记本电脑和Raspberry Pi都已连接并配对(手动)。我知道Raspberry Pi的蓝牙地址及其使用的通道,这些值被硬编码到ConnectAsync(…)的参数中 调用ConnectAsync(…)时,Raspberry Pi确实接收到一个连接,并打印行“accepted connection from('Windows bluetooth address',1)。但是,在m

我正在制作一个Windows UWP应用程序,它使用RFCOMM与Raspberry Pi通信。我的Windows笔记本电脑和Raspberry Pi都已连接并配对(手动)。我知道Raspberry Pi的蓝牙地址及其使用的通道,这些值被硬编码到ConnectAsync(…)的参数中

调用ConnectAsync(…)时,Raspberry Pi确实接收到一个连接,并打印行“accepted connection from('Windows bluetooth address',1)。但是,在mscorlib.ni.dll中出现了异常“类型为'System.exception'的异常”,但未在用户代码中处理。其他信息:未找到元素。(HRESULT的异常:0x80070490)“发生在调用ConnectAsync(…)的位置,并且消息从未传递到Raspberry Pi

Windows代码(作为客户端,尝试向Raspberry Pi发送消息):

Raspberry Pi(作为Python服务器):

当我用bluetoothAddress替换ConnectAsync(…)中的“1”时,会出现“值不在预期范围内”异常。

方法的第二个参数“remoteServiceName”
socket.ConnectAsync()
应为
RfcommDeviceService.ConnectionServiceName

有关更多信息,请参考

StreamSocket socket = new StreamSocket();
await socket.ConnectAsync(new HostName(bluetoothAddress), "1"); // the format of bluetoothAddress is 'AB:CD:AB:CD:AB:CD'

Stream streamOut = socket.OutputStream.AsStreamForWrite();
StreamWriter writer = new StreamWriter(streamOut);
await writer.WriteLineAsync(message);
await writer.FlushAsync();
import bluetooth

server_sock=bluetooth.BluetoothSocket( bluetooth.RFCOMM )

port = 1
server_sock.bind(("",port))
server_sock.listen(1)

client_sock,address = server_sock.accept()
print("Accepted connection from ",address)

data = client_sock.recv(1024)
print("received [%s]" % data)