Hello Sylvain, On Tue, 9 Oct 2018 at 20:50, Sylvain Leroux <sylvain@xxxxxxxxxxx> wrote: > > Hi everyone, > > I'm trying to establish a serial communication between two hosts over > Bluetooth. > > Things go well if I start the `bluetoothd` on the server in > _compatibility mode_. That way, I can attach the "serial port" profile > to the channel. Then, using `rfcomm watch` and `rfcomm connect` to > establish the connection between the server and the client, I can > receive "raw" data sent by the server: > > ---- > # Server side > /usr/lib/bluetooth/bluetoothd -C > sdptool add --channel=1 SP > rfcomm watch hci0 1 bash -c 'cat somefile > /dev/rfcomm0' > ---- > > ---- > #Client side > sudo rfcomm connect /dev/rfcomm0 BB:CC:DD:EE:FF:11 1 > sudo cat /dev/rfcomm0 > ----- > > If I do _not_ run the `bluetoothd` server in compatibility mode, SDP is > no longer supported and the data I receive seems to modified by the BT > stack, leading to my data being mixed with garbage--exactly like when I > don't set the "serial port" profile while running in compatibility mode. > > > I don't like the idea of depending on a deprecated interface. And from > what I read, I understand the new way to go is to use the DBus API. Any > solution using bluetoothctl, busctl, dbus-send or similar tools would do > the trick. But I can't manage to understand the sequence of operations > required to transmit raw data between the server and the client *from a > shell script* using that new API. > > Could you give me some example or point me to the relevant documentation? You might want to take a look at the Bluedot library that has used the DBus API to communicate over the Serial Port Profile. Server: https://github.com/martinohanlon/BlueDot/blob/master/bluedot/btcomm.py#L141 Client: https://github.com/martinohanlon/BlueDot/blob/master/bluedot/btcomm.py#L466 The main section using DBus is in: https://github.com/martinohanlon/BlueDot/blob/master/bluedot/utils.py Hope that helps. > > Regards, > - Sylvain Leroux