2

I'm trying to set up a Bluetooth link between a Raspberry Pi and an Arduino (Megapi). These are both mounted on a robot for a wireless robotics project. While running the Bluetooth server/listener on the Pi, I get the Invalid Exchange socket error. The troublesome code is shown below-

    self.host = "00:0D:19:EA:28:52"
    self.port = 3
    self.sock = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM, socket.BTPROTO_RFCOMM)
    self.sock.connect((self.host, self.port))

The fourth line is where the error pops up-

File "Client.py", line 21, in __init__
  self.sock.connect((self.host, self.port))
File "/usr/lib/python2.7/socket.py", line 224, in meth
  return getattr(self._sock,name)(*args)
socket.error: [Errno 52] Invalid exchange

Unfortunately, there appears to be very little documentation on socket errors available on the internet, other than one/two word descriptions of what the error codes mean. I was hoping you can help!

1 Answer 1

2

https://github.com/torvalds/linux/blob/v4.10/net/bluetooth/lib.c#L68 translates Bluetooth errors into C errnos. EBADE (errno 52) is mapped to Bluetooth error code 0x06, defined as "Key Missing".

2
  • What does "Key Missing" tell me about the problem? I can't seem to find where the bug actually is! Commented Mar 30, 2017 at 2:52
  • Could be a pairing problem.
    – Klaus D.
    Commented Mar 30, 2017 at 3:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.