'Bluetooth bluez accept connection
I would like to accept Bluetooth pairing on an embedded device running the bluez stack without d-bus. With the following commands, the device can be seen from an Android phone:
hciconfig hci0 up
hciconfig hci0 sspmode 1
hciconfig hci0 piscan
If I run bluetoothd with d-bus active, it can accept pairing without any password or keycode. But I cannot afford to run d-bus on this device so I would like to develop a small daemon that can be notified of a pairing request and can communicate. bluetoothd seems to exit all the time if d-bus is not running. Is there any sample code somewhere to do that?
EDIT: I'm using this tutorial http://people.csail.mit.edu/albert/bluez-intro/x502.html. On the embedded device, after the piscan, I run the rfcomm-server.c part. On a Linux PC, I can see the embedded device through "hcitool scan" and then I use the client side rfcomm-client.c with the right mac address. After a few seconds, the connect call in rfcomm-client.c returns "Operation now in progress". Any idea?
Solution 1:[1]
Allow me to shamelessly introduce you to Direct-BT, implemented in C++17 and having a Java binding. It uses the BlueZ/Kernel API without D-Bus and supports embedded systems.
Goals are high performance and full access to all data and events etc. It is fully event driven and concurrency allows handling multiple client connections.
You may find the connection related code in (bottom -> up) HCIHandler, BTAdapter and ultimately BTDevice.
Perhaps you can find the examples helpful.
Server and client mode is supported.
Hope it helps a little.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Sven Gothel |