petzval
Posts: 34
Joined: Sat Aug 10, 2013 12:15 pm

Bluetooth interface

Tue Feb 23, 2021 12:55 pm

Here is a Bluetooth interface that can connect simultaneously to multiple Classic and LE servers, and also to a mesh network of other Pis running the same software.
There is a library of functions and a program (btferret) that implements most of the interface features such as connecting to other devices, operating as a client or server, exchanging data (including a file transfer routine) and display of information - it is a bit like a super bluetoothctl that won't drive you mad. It has a verbose print mode that displays the HCI Bluetooth traffic with details of the packets that are exchanged. Also included is the code for a simple mesh network procedure.
The documentation has a reference section with a detailed description of the HCI Bluetooth interface, the packet formats and how they are constructed, and the sequence of instructions needed to establish connections and exchange data. This information is difficult to extract in a coherent form from the Bluetooth specification documents. There is also a brief guide to writing server code for other machines.
This interface is programmed at the HCI level and bypasses higher-level bluez functions, so it does not use the Pi's Bluetooth service, which can be stopped. It will connect to Windows/Android/HC-05 devices when bluez often has problems.

https://github.com/petzval/btferret

User avatar
Douglas6
Posts: 4994
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Bluetooth interface

Tue Feb 23, 2021 2:22 pm

This looks fantastic. It inspires me (again) to learn C. Well documented; it could be a useful resource for anyone learning Bluetooth and HCI.

petzval
Posts: 34
Joined: Sat Aug 10, 2013 12:15 pm

Re: Bluetooth interface

Tue Feb 23, 2021 3:29 pm

Thanks for your comments. This has come out of many months struggling with the vagaries of bluez and the Bluetooth documentation.

Return to “Networking and servers”