0

I am new to raspberry pi so please forgive me if I ask a silly question. What I am trying to do is send files from my windows 10 laptop to raspberry pi with raspbian OS, I was able to send some data (in characters) successfully using pybluez, but now I want to transfer files (images, videos, audio files etc) using python script and at the same time want to check the file transfer rate for file transfer. Can you please guide me in the right direction? And if possible how to increase the speed of file transfer using bluetooth. Thank you

0

Bluetooth “Classic” (BR/EDR) supports speeds up to about 24Mbps.

I have not used it myself, but for file transfer I suspect the answer is: https://en.wikipedia.org/wiki/OBject_EXchange

I don't have a full answer but you did ask for someone to point you in the right direction...

The deamon doesn't seem to be installed by default so you would need to install it with:

sudo apt install bluez-obexd

And you will have to start it. You can get the full options with:

/usr/lib/bluetooth/obexd -h

I used the following for my test:

/usr/lib/bluetooth/obexd -- --root=/tmp/bluetooth-inbox -l -d

If you do bluetoothctl show there should be extra UUID added e.g:

UUID: OBEX Object Push (00001105-0000-1000-8000-00805f9b34fb)

There is a command line client that might be useful to experiment with and learn how it works:

enter image description here

I used connect, send and quit while having the PC waiting to recieve a file and it seemed to work

enter image description here

When you want to do it with Python, then you will need the BlueZ DBus API docs for OBEX which are at:

https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/obex-api.txt

https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/obex-agent-api.txt

pydbus is a good library to use for the BlueZ DBus API https://pypi.org/project/pydbus/

A quick test I did seemed to work:

import pydbus
from time import sleep

# Setup of device specific values
dev_id = 'DC:71:96:19:D9:66'

ses = pydbus.SessionBus()
obex = ses.get('org.bluez.obex', '/org/bluez/obex')
ses1 = obex.CreateSession('DC:71:96:19:69:D6', {'Target': pydbus.Variant('s', 'OPP')})
ses1_dbus = ses.get('org.bluez.obex', ses1)
props = ses1_dbus.SendFile('/home/pi/.bashrc')
sleep(2)
obex.RemoveSession(ses1)

This is not the most robust code. Needs some logic to test that the PC ready to receive. Also the sleep in there needs to be replaced with some better code to check it has finished transferring.

Hope that points you in the right direction

| improve this answer | |

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