Doing Bluetooth Low Energy on Linux
Why Stack Overflow recommends it
Stack Overflow users link it as a source for how the BlueZ stack is structured and why its high-level D-Bus APIs are the recommended way to do BLE work on Linux.
Recommended by 2 people across 2 different months, 2018 to 2023.
What it is
A Linux Foundation conference talk by Szymon Janc of CODECOUP on how Linux supports Bluetooth, with a guided tour of the BlueZ 5 stack architecture and its Bluetooth Low Energy support. It also covers newer features such as LE Connection Oriented Channels, BT6LowPAN and LE Secure Connections for IoT use.
What people said
Recommends VeRo · 2018-10 · Stack Overflow · on “Check battery level of connected Bluetooth device on Linux”
This is such a great question, ahead of development and tools that are available at the moment. The short answer (in October 2018) you have to write it yourself! It won't be a one liner in the terminal. I am going to write this for myself in Python, but C has a little more documentation, so if you are skilled with C go for it. The long answer , but it's more a recommended starting point: Tony D: Raspberry Pi and Bluetooth LE, part 1 with Tony D [LINK] (1 h 17 min 24 secs) managed to use bluetoothctl to read attributes and send data to a Bluetooth device. Definitely check the video information; you will find great links and references in Introduction to Bluetooth Low Energy [LINK] . Szymon Ja
Recommends Chris Sidi · 2019-06 · Stack Overflow · on “Utilizing bluetooth LE on Raspberry Pi using .Net Core”
Background BlueZ is the Bluetooth stack on Linux. The BlueZ developers encourage the use of their high-level D-Bus APIs [LINK] . (Source: [this video] or [LINK] , slide 22.) D-Bus lets you control all sorts of system services, and there are D-Bus bindings/packages for lots of platforms including .Net Core. So it should be somewhat simple to write a GATT client or GATT server using .Net targeting Linux (e.g. Raspbian Lite). Solution For .Net Core you can use Tmds.DBus [LINK] to access D-Bus. Tmds.DBus comes with a tool to generate the C# interfaces for a D-Bus service. I used bluetoothctl , the BlueZ interactive command-line tool, to scan and connect to a BLE peripheral, and then used dotnet dbus
Cites ukBaz · 2022-04 · Stack Overflow · on “Change the default scan filter policy bluetooth linux”
If I use the bluetoothctl tool (which uses the D-Bus API) to connect to a device with the following command: [bluetooth]# connect E5:10:5E:37:11:2D Then looking in the btmon log I see that the device is added to the white list and the filter policy is set to 01 < HCI Command: LE Add Device To White List (0x08|0x0011) plen 7 #89 [hci0] 27.585652 Address type: Random (0x01) Address: E5:10:5E:37:11:2D (Static) > HCI Event: Command Complete (0x0e) plen 4 #90 [hci0] 27.586456 LE Add Device To White List (0x08|0x0011) ncmd 1 Status: Success (0x00) < HCI Command: LE Set Scan Parameters (0x08|0x000b) plen 7 #91 [hci0] 27.586526 Type: Passive (0x00) Interval: 60.000 msec (0x0060) Window: 60.000 msec
Cites ukBaz · 2023-02 · Stack Overflow · on “Bluez: where can i find all the definitions documented in /doc?”
BlueZ is the Bluetooth stack for Linux and it has a few API's for people to use. Below is a list of the possible API’s starting from lowest level and going to the highest. For most people, the higher the better. Raw HCI This bypasses the BlueZ bluetoothd that is running on a Linux system that is used to coordinate interactions with the Bluetooth hardware. This API is outside of the BlueZ infrastructure so is not documented by the BlueZ project. All the information is available in the Bluetooth Core Specification which runs to about 3,256 pages for the 5.2 version of the spec. If using this level it is a good idea to stop the Bluetooth service from starting the Bluetooth daemon so they are no