I would like to use sockets in python 3.9 on Windows 10 to connect to a HC-05 module on an arduino and send/read some characters. However, using the following code, I get this error:
import socket
adapter_addr = '00:21:11:01:FA:1C'
port = 1 # Normal port for rfcomm?
buf_size = 1024
s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM,
socket.BTPROTO_RFCOMM)
s.bind((adapter_addr, port))
s.listen(1)
try:
print('Listening for connection...')
client, address = s.accept()
print(f'Connected to {address}')
while True:
data = client.recv(buf_size)
if data:
print(data)
except Exception as e:
print(f'Something went wrong: {e}')
client.close()
s.close()
line 30, in <module>
s.bind((adapter_addr, port))
OSError: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions
I've also tried using the PyBluez library, but it gives similar errors. Thanks in advance for any help