2

I am trying the develop a program (in python 3) in which it is possible to transfer a certain amount of data from a computer to another with bluetooth (using pybluez). After a client connects to the device, for some reason, the server side of the application raises a BluetoothError exception after around 30 seconds. It raises the following exception:

bluetooth.btcommon.BluetoothError: (103, 'Software caused connection abort')

I thought that I could be something in my code, so I decided to do a simpler version, in order to test it. I got the exact same error.

The following code is the simpler version I talked about previously.

This is the server side

from bluetooth import *

x = BluetoothSocket(RFCOMM)
print("bind")
x.bind(("", 1))
print("listen")
x.listen(1)
print("accepting")
conn, _ = x.accept()
print("reading")
print(conn.recv(256).decode('utf-8'))
print("closing")
conn.close()
x.close()

This is the client side

from bluetooth import * 
x = BluetoothSocket(RFCOMM)
x.connect((<addr>,1))

NOTE: the client side is not executed from a file, but writen directly in the python shell

After putting the server side script running on a regular computer and the client side script on a raspberry pi 3 with raspbian I get the BluetoothError after 30 seconds. The exception is raised on the line:

print(conn.recv(256).decode('utf-8'))

During this time I am able to send messages from one side to another. No matter what I do, after 30 seconds, the exception is raised.

I have no idea of what is happening. I am going to try with another computer with the client script, but it is getting complicated (windows, am I right :p).

David Martins
  • 63
  • 2
  • 7
  • I am facing this problem too, have you had some luck resolving this issue. I found another [unresolved thread](https://www.spinics.net/lists/linux-bluetooth/msg14798.html) – Besi Jan 11 '20 at 16:21
  • I ended up giving up on this issue. I do believe it is a problem with the rpi bluetooth module itself (I have heard that it is giving some problems). This kind of problem does not occur with other computers... – David Martins Jan 16 '20 at 11:35
  • You could try updating bluez to a newer version. However I ended up using a UART Bluetooth LE profile for exchanging data between the pi and an iPhone App. https://scribles.net/updating-bluez-on-raspberry-pi-from-5-43-to-5-50/ – Besi Jan 20 '20 at 00:21

0 Answers0