0

I am using PyBluez to try to determine the bluetooth transfer speed between a raspberry pi and a phone.

I want to start a timer before socket.send(data) and stop it after the data has been sent, to see how long it took to send the data. However, this does not work as send() is not a blocking function and goes on to the next line of code before it has finished executing. i.e:

start = time.time()
socket.send(data)
end = time.time()
time_taken_to_send = end - start

When I set socket.setblocking(True), it doesn't seem to do change the time it takes to send the data.

I dont have a huge amount of control of the code on the phone side, as this is just a preliminary test to check the bandwidth and Im just using a an app downloaded from the google play store to achieve the bluetooth connection, so I cant time the time it takes to receive the data, even though socket.recv() is a blocking function.

Does anyone know of a way to force socket.send(data) to be a blocking function, where it will only move on to the next line of code after the data has been sent?

mnt
  • 1
  • I don't think this is possible. The socket object is only delivering a block of data to the network stack. To work out the transfer speed you would need some feedback from the remote device. Is it possible to request some data from the phone? – quamrana Mar 29 '18 at 14:20
  • thanks for the reply, I think Im going to investigate a bit more on the android side. Im currently using an app called serial bluetooth terminal which can just send bytes of data to the computer as far as I know. I think Im going to try to find another app which is a bit more versatile which can perhaps sent a photo, or something and Ill time it on the rpi. – mnt Mar 29 '18 at 14:25

0 Answers0