Bluetooth is interoperable by having common ways to interact defined by the Bluetooth SIG. There is a list of these profiles at:
https://www.bluetooth.com/specifications/profiles-overview/
The list of profiles supported by BlueZ (the official Bluetooth stack on Linux) is documented at: http://www.bluez.org/profiles/
I suspect from your question, one of the two following profiles are most likely to do what you want:
- OPP Object Push Profile
- PAN Personal Area Networking Profile
There first one is probably most likely to be helpful. Often referred to as OBEX
The daemon 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 an extra UUID added e.g:
UUID: OBEX Object Push (00001105-0000-1000-8000-00805f9b34fb)
There is a command line client called obexctl
that might be useful to help explore the functionality.
The BlueZ API for this functionality is documented at the following depending if you want a server or client:
https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/obex-agent-api.txt
https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/obex-api.txt
If you wanted to use personal area network profile, then that API is documented at:
https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/network-api.txt
As a footnote, when using Raspberry Pi OS lite
it has been found that user pi is not necessarily a member of the bluetooth group. This can be cured as follows:
$ sudo usermod -G bluetooth -a pi
Adding pi
to this group means that your Bluetooth program doesn't need to be run as root.