From bfe80edff6ebc19e0aa2719e24e4802ab4cb7446 Mon Sep 17 00:00:00 2001 From: Laurens Valk Date: Thu, 7 May 2020 11:36:02 +0200 Subject: [PATCH] ev3/snippets/bluetooth_pc: run client as python3 Even though our main example will have the PC as the server, make it possible to use it as client as well. Now, it works just like the EV3s. The only difference is that you must enter the full address instead of the name if the EV3 is the server you are connecting to. --- snippets/ev3/bluetooth_pc/pybricks/bluetooth.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/snippets/ev3/bluetooth_pc/pybricks/bluetooth.py b/snippets/ev3/bluetooth_pc/pybricks/bluetooth.py index 29f4381..613315b 100644 --- a/snippets/ev3/bluetooth_pc/pybricks/bluetooth.py +++ b/snippets/ev3/bluetooth_pc/pybricks/bluetooth.py @@ -111,12 +111,7 @@ class RFCOMMClient: self.socket = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM) def handle_request(self): - addr_data = bytearray(sizeof(sockaddr_rc)) - addr = struct(addressof(addr_data), sockaddr_rc) - addr.rc_family = AF_BLUETOOTH - str2ba(self.client_address[0], addr.rc_bdaddr) - addr.rc_channel = self.client_address[1] - self.socket.connect(addr_data) + self.socket.connect((self.client_address[0], self.client_address[1])) try: self.process_request(self.socket, self.client_address) except: