l2cap (113, 'No route to host')

Navneet Garg Source

I am using following code in rapsberry pi zero with bluetooth l2cap protocol. My client code always give me same error

Error :

Traceback (most recent call last):
File "l2cap-client.py", line 11, in <module>
sock.connect((bd_addr, port))
File "<string>", line 5, in connect
bluetooth.btcommon.BluetoothError: (113, 'No route to host')

Server Code :

import bluetooth
server_sock=bluetooth.BluetoothSocket( bluetooth.L2CAP )
port = 0x1001
server_sock.bind(("00:1B:DC:06:C1:AD",port))
server_sock.listen(1)
print(server_sock.getsockname())
client_sock,address = server_sock.accept()
print "Accepted connection from ",address
data = client_sock.recv(1024)
print "received [%s]" % data
client_sock.close()
server_sock.close()

Client Code :

import bluetooth
sock=bluetooth.BluetoothSocket(bluetooth.L2CAP)
bd_addr = "00:1B:DC:06:C1:AD"
port = 0X1001
#print(sock.getsockname())
sock.connect((bd_addr, port))
print(sock.getsockname())
sock.send("hello!!")
sock.close()
pythonbluetoothraspberry-pil2cap

Answers

comments powered by Disqus