Skip to contentSkip to conversation

Exchanging data over Bluetooth Classic

DISCUSSION Dario Teixeira 2 participants 3 messages Jan 26, 2017 – Feb 6, 2017 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

Hi,

Here's the situation: I want to use a smart phone to communicate with a small embedded device (ED). Unfortunately the ED is running a very old kernel (3.10.93) which does not support Bluetooth Low Energy. Therefore, if I am to use Bluetooth it will have to be BT Classic.

The communication is pretty straightforward: just a couple of RPC calls using JSON. Both the requests and the replies are reasonably short. The entire exchange can be summarised as follows:

Phone: Here's request #1 (JSON text).
ED: Okay, here's reply #1 (JSON text).
Phone: Here's request #2 (JSON text).
ED: Okay, here's reply #2 (JSON text).

Now, I have a couple of related questions:

a) I presume there's no other option than using RFCOMM, right?

b) I know that the first Google hit for "Bluetooth programming" is hopelessly out of date [1], because Bluez now uses DBus. However, where's the Bluez documentation for RFCOMM via DBus? I could only find this page for Bluez documentation [2], but RFCOMM is not mentioned.

Thanks in advance for your time!
Best regards,
Dario Teixeira

[1] https://people.csail.mit.edu/albert/bluez-intro/
[2] http://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc

maintainer
#1 lore raw

Hi Dario,

Quoted 16 lines

Here's the situation: I want to use a smart phone to communicate with a small embedded device (ED). Unfortunately the ED is running a very old kernel (3.10.93) which does not support Bluetooth Low Energy. Therefore, if I am to use Bluetooth it will have to be BT Classic.

The communication is pretty straightforward: just a couple of RPC calls using JSON. Both the requests and the replies are reasonably short. The entire exchange can be summarised as follows:

Phone: Here's request #1 (JSON text).
ED: Okay, here's reply #1 (JSON text).
Phone: Here's request #2 (JSON text).
ED: Okay, here's reply #2 (JSON text).

Now, I have a couple of related questions:

Quoted 7 lines

a) I presume there's no other option than using RFCOMM, right?

b) I know that the first Google hit for "Bluetooth programming" is hopelessly out of date [1], because Bluez now uses DBus. However, where's the Bluez documentation for RFCOMM via DBus? I could only find this page for Bluez documentation [2], but RFCOMM is not mentioned.

you can use L2CAP or RFCOMM sockets to transfer data. Or you can use OBEX as provided by obexd if it is more file related transfer you are after.

Regards

Marcel

#2 lore raw

Hi,

Quoted 3 lines

you can use L2CAP or RFCOMM sockets to transfer data. Or you can use OBEX as provided by obexd if it is more file related transfer you are after.

Thanks for the reply. What is the most convenient way to programatically use L2CAP or RFCOMM? There is one guide [1], but I reckon it's out of date since Bluez made the transition to DBUS. I heard it's possible to create a character device for RFCOMM sockets; using them programatically them reduces to the usual open/read/write/close of a file descriptor. Is this still possible? (Mind you, Bluez docs are laconic in the extreme!)

Best regards,
Dario Teixeira

[1] https://people.csail.mit.edu/albert/bluez-intro/