Bluetooth On Modern Linux - 0
Bluetooth On Modern Linux - 0
Bluetooth On Modern Linux - 0
Szymon Janc
[email protected]
/* Connect to remote */
addr.l2_bdaddr = REMOTE_ADDR;
addr.l2_psm = 0x80;
connect(sk, (struct sockaddr *) &addr, sizeof(addr))
6LoWPAN over BT LE
● Available since kernel 3.16
● No stable interface yet, need to use debugfs
● But simple to use
○ modprobe bluetooth_6lowpan
○ echo “1” > /sys/kernel/debug/bluetooth/6lowpan_enable
○ echo "connect 00:1B:DC:E0:36:BD 1" > /sys/kernel/debug/bluetooth/6lowpan_control
○ bt0 interface is created
○ ping6 -I bt0 fe80::21b:dcff:fee0:36bd
Custom solutions
● Don’t want/need full bluetoothd for your tiny custom app?
● src/shared folder in bluez.git contains LGPL licenced components
○ Used by bluetoothd and other BlueZ tools
○ Library like C API
○ Easy to integrate
○ MGMT, ATT, GATT, crypto, advertising, ECC, GAP, HFP and more
○ No API stability guaranteed
● Ideal for beacons or simple peripheral applications
○ peripheral/ folder for peripheral example (LGPL)
● User channel
○ Gives HCI exclusive access to user space application
○ Sample in tools/eddystone.c (GPL)
Tips
● Use D-Bus API (documentation in doc/)
● Python D-Bus examples in test/
● Don’t use hcitool unless you really know what you are doing
○ Use bluetoothctl or btmgmt instead
● For HCI traces use btmon instead of hcidump
● Stuck with ancient kernel?
○ Use Linux Backports project https://backports.wiki.kernel.org/
○ Example https://bluez-android.github.io/
● Extra kernel configuration via sysfs
○ /sys/class/bluetooth
● Extra kernel informations and experimental features via debugfs
○ /sys/kernel/debug/bluetooth
Tips (II)
● Bluetoothd configuration
○ /etc/bluetooth/main.conf (input.conf, network.conf)
● Want to contribute?
○ Join #bluez on irc.freenode.net
○ [email protected] mailing list for patches
○ Read HACKING file
● Reporting a bug?
○ #bluez-users on irc.freenode.net or [email protected] list
○ Provide HCI traces
○ Enable bluetoothd debug logs (‘bluetoothd -n -d -E’ or SIGUSR2)
Future work
● Improving support for dual-mode devices
○ New DeviceLE1 and DeviceBR1 interfaces (RFC)
○ Extending Adapter1 interface
● Management API for BT 6LoWPAN
● Deduplicating BlueZ and BfA code
Questions?
Bluetooth on modern Linux
Szymon Janc
[email protected]