I am working on a project with the beagle bone black wireless, where I need to be able to send music control commands to a phone. Note, I don't want to stream music to my beaglebone. I have spent about a week looking online, and found very little about this.
The OS for the beaglebone is Debian Jessie. I can get things like hci0tool, Bluetoothctl, hciconfig to work. I can detect and pair to a device. It seems though that my connection only lasts for the pairing process, and fails every time afterwards.
My current process is executing:
sudo su
bluetoothctl
power on
agent on
default-agent
scan on
I get the mac address
scan off
pair <MAC Address>
trust <MAC Address>
connect <MAC Address>
As of now pairing and trust succeed, though the connection ends after pairing finishes. And I have no idea of where to start for sending a command to a phone.
Connect call on Device1 interface will tries to connect all the profiles supported between the device and adapter. This happens by negotiating or exchanging the supported profiles.
Connection may not be possible when Adapter doesn't support the minimal requirement of profiles which is needed by the Device. In this case, you may need A2DP provider in adapter end to get connection successful. Yes, this is contradictory to this statement.
If you don't want to connect with all the profiles between Device and Adapter, then you can use ConnectProfile method in Device1 interface.
But bluetoothctl doesn't provide commands to achieve neither ConnectProfile nor you AVRCP commands.
You need to use D-Bus calls to get the communication with Bluetoothd. If your application is command line/shell based, you can use dbus-send/gdbus commands to address the D-Bus interface.
Although bluez-tools implements media control AVRCP commands, it doesn't provide any utility which uses it. Either you can compile bluez-tools as library and develop application using the media control API or use dbus-send/gdbus.
I have started with some samples using GDBUS, but not yet for AVRCP controls. See here : https://gist.github.com/parthitce
and Documentation here: https://www.linumiz.com/category/blog/
Related
I'm trying to pair from a Linux host (ARM based, Angstrom distribution) to a MCU driven embedded device using BLE Just Works Secure Connection. As a device I'm currently using an ESP32 dev kit flashed with the GATT security example. However, so far my tries weren't successful and I failed to find the according documentation, either.
I managed to pair my Android smartphone with the device, so pairing on the device side, in general, seems to work. I also tried to conduct the pairing without a Secure Connection (setting Authorization Request to SP_LE_AUTH_BOND) which worked with bluetoothctl or btmgmt.
I'm grateful for any documentation pointer how to perform pairing from the command line, Python scripting or any C/C++ code.
Have a look at the answer below and the included references; these cover pairing using BlueZ/Linux:-
Raspberry Pi BLE Encryption/Pairing
If this still doesn't work, please launch "btmon" on another terminal before starting the pairing process as that will give you an indication as to what is going wrong.
I hope this helps.
We've got a use case in which a BLE connection is used to do the basic configuration of an embedded device via an Android app (later also via an iPhone app). The embedded device runs Linux and thus uses BlueZ as Bluetooth stack.
Using the DBus-API of BlueZ, bonding is made possible by making the device pairable, discoverable, and activating advertising. After bonding the apps can access the GATT services and characteristics
(which require bonding to be read/written) on the embedded device.
After the setup is done the bonding of the device (running the app) that managed the setup process, is supposed to be removed. In order to do that we call RemoveDevice() of org.bluez.Adapter1.
The BlueZ documentation states the following
void RemoveDevice(object device)
This removes the remote device object at the given
path. It will remove also the pairing information.
Still the app is able to access the GATT characteristics afterwards.
If bluetoothctl is used to check the list of paired devices, the list is not containing that device anymore though. Before calling RemoveDevice() the bonded device was visible there.
If bluetootd is stopped and restarted the app is no longer able to read/write the GATT characteristics, but needs to re-bonded before doing so.
I can neither find any further information in the BlueZ documentation nor can I find anything about this topic searching anywhere else.
Is this intended behavior or is this a bug? Does "remove pairing information" also mean "remove bonding information"? If this is intended behavior, how do we properly terminate bonding with a device?
Should I use the BlueZ Management API instead of the BlueZ API? I'm not sure about this as multiple source state that the DBus-API is the way to go.
RemoveDevice() indeed removes the bonding information as well. So you have to disconnect first and then call RemoveDevice(). The next time you connect the bonding information will be gone.
However, note that if you only make use of encrypted characteristics, you can still connect and discover services. Only once you start reading/writing the encrypted characteristics will Bluez check if you are bonded.
I am working on BLE using BlueZ-4.101 stack,i have been able to port all the necessary binaries,and able to connect two devices.
I am creating connection using command:
gatttool -i hci0 -b -I
connect
i.e opening the interactive mode and connect through it.
When I try to discover primary services of the other connected device , it shows
Discover all primary services failed: A timeout Occured
Where I am going wrong ,can anyone point out ? How can we check primary services of our own device ?
Actually Device Information Service has to be implemented with this stack,can anyone list out the steps on this?
You can try pairing to the remote device before connecting to it through gatttool.
For pairing you can use simple-agent or bt-device utilities.
To implement the DIS, you can look how the GATT and GAP are implemented, similar way you can add the attributes and handles for the DIS characteristics.
I hope it will be helpful.
I have been using a 3G dongle on cubieboard for internet connection. I have installed usb_modeswitch which basically switched dongle from USB storage mode to USB modem mode. I verified that the switching automatically happens after boot (usb_modeswitch is working fine). After switching takes place, system adds /dev/ttyUSB* dev names for modem. After this happens, I need to run model script to dial and connect to internet. In order to automate the process, I wanted to know if there is any event trigger for creation of /dev/ttyUSB* so that after that, I can automatically run dial script?
A general approach is to use udev to listen for events and then to react according to your own logic.
I am working on using the Bluetooth low energy modem with Linux. I am using the command line option for that i.e. hcitool . I am able to the find the devices using the command: $ hcitool scan
It is working fine for me, also I am able to broadcast my device using :
sudo hciconfig hci0 leadv
It is also working fine. But I want to add the services and characteristic to the modem device which can be detected by other device. I have tried sdptool add but it is not working for me. Does anyone know how to add the services and characteristics to the peripheral using the command line tools in ubuntu?
Edit: My modem is broadcasting but not able to explore the services and characteristic to the other BLE device. Now I am able to set the name of device using hcio name command
Edit: Now I am able to render the services and characteristic, by simultaneously running sudo hcidump command. But I am not able to track from where I am getting those services and characteristics. One definite observation is those services are rendering from the machine.
SDP is absent in BLE. Broadcast/advertise frame and GATT client/server are used instead.
Several links:
BlueZ gatttool: command line tool to run common GATT procedures
BlueZ GATT's ready profiles
hint: DBUS
GATT and DBUS example
How can I connect to the FitBit Zip over Bluetooth 4.0 LE on Linux with bluez?
Bluetooth Low Energy: listening for notifications/indications in linux
http://comments.gmane.org/gmane.linux.bluez.kernel/29547
I used to broadcast BT services by following this article. This page not only shouws you how to advertise a profile, but also gives you an example on how to implement the HSP profile.
To know the bt class you need to announce, you can check this other page.