BLE GAP Profle through GATT on Linux - linux

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.

Related

How to only allow paired devices to connect?

I'm having a hard time understanding why a Bluetooth connection is able to be made without either pairing or trusting a device. I'm using bluetoothctl and and can connect two devices without pairing them first by using "Scan on" on the central side and "Advertise on" on the peripheral side.
could someone explain why this is happening?

update local gatt characteristic value using bluetoothctl

I have set up a gatt Server on an raspberry pi using bluetoothctl and BlueZ 5.50 (according to this thread: BlueZ: How to set up a GATT server from the command line)
I can connect to the gatt server from an other machine and also read the given value. Now I want to try notify.
The subscription works fine, but how do I update the value on the local gatt server? I can't use select-attribute because my local services an characteristics do not show up in the list that appears when using autocomplete.
Would be nice if someone can help me with this problem.
I too faced the same prob and i found solution for the same.
i am using bluez5.49. whenever notify was enabled in client, notify_io will be created and pipe will be established.
so if you write data in pipe fd, then it will be notified to client.

No GATT characteristics discovered for dual-mode Bluetooth (Smart Ready) device

I'm running some of the Python example code from Bluez using the DBUS interface. I am on Fedora 28, Bluez 5.50. The device I am trying to connect to is a dual-mode Microchip BM78. Both the sample code and bluetoothctl will discover the device, show both the LE and BDEDR services, but neither detect the the GATT characterstics once services are resolved. The GATT characteristics are not resolved, even after the device is paired, trusted and/or connected.
The Bluez DBUS API seems to require that the characterists are first discovered before any attempt to read or write is possible.
I can connect to the device using non-DBUS APIs and access the characteristics just fine.
Is there some way to force characteristic discovery once a service is resolved? Or some way to connect to a known characteristic that has not be discovered using the DBUS interface?

beaglebone black wireless bluetooth AVRCP

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/

Using Bluetooth low energy in linux command line

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.

Resources