I would like to make a bluetooth communication between a laptop with a bluetooth dongle and windows 7, and my raspberry pi 3.
I found on internet some tutorials which use the Pybluez librairy but this doesn't work for me.
Find below the code for the server part :
import bluetooth
Host = ""
port = 12
HostAddr = (Host, port)
def setupServer():
server_socket=bluetooth.BluetoothSocket( bluetooth.RFCOMM )
print("Socket Created.")
server_socket.bind(HostAddr)
server_socket.listen(1)
print("Socket bind complete")
client_sock, client_info = server_socket.accept()
print("Accepted connection from " , client_info)
try:
while True:
data = client_sock.recv(1024)
if len(data) == 0: break
print("received [%s]" %data)
except IOError:
pass
print("Disconnected")
client_sock.close()
server_socket.close()
print("all done")
setupServer()
This is the output :
Socket Created.
Traceback (most recent call last):
File "path_to_file\Server.py", line 33, in <module>
setupServer()
File "path_to_file\Server.py", line 12, in setupServer
server_socket.bind(HostAddr)
File "C:\Python34\lib\site-packages\bluetooth\msbt.py", line 60, in bind
bt.bind (self._sockfd, addr, port)
OSError
Do you have an idea why i had this error ?