mirror of
https://github.com/pybricks/pybricks-projects.git
synced 2026-09-14 10:33:09 +00:00
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.
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user