Get BLE data notifications in ubuntu - bluetooth-lowenergy

I defined custom service (NRF51822,S110) to send sensor data. In that I enabled notifications for new data. I can able to receive data, if I enabled notification in NRFconnect app in Android and windows. But I am not able to enable notification in ubuntu 16.04 . I am using bluez gatttool. To get notification I send this command "char-write-req 0x000e 0100" from command line. Please Help me to fix this issue.

In order to receive notifications from a gatt server, you need to write to the CCCD (0x2902) descriptor and use the --listen option. Assuming that the handle of the descriptor is 0x000e, the command you need is as follows:-
gatttool -b 00:11:22:33:44:55 --char-write-req --handle=0x000e --value=0100 --listen
Please see the answers below:-
Bluetooth Low Energy: listening for notifications/indications in linux
Reading Thermometer Data with Bluez Bluetooth Low Energy
I hope this helps.

Sorry. handle 0x000f is correct. But I written as 0x000e. Now issue solved. Thank you.

Related

BLE device not disconnecting

I am working with BLE devices. and using nrf controller with bluez 5.4 code.
I am customizing gatttool source code so that multiple devices can connect and disconnect.
My focus part for now is how to disconnect ble device using gatttool apis.
I had found one solution in code that we can use:
g_io_channel_shutdown();
g_io_channel_unref();
These 2 APIs are use to disconnect ble device.
I am using nrf connect application in my mobile to connect generate dummy ble device so that I can perform operations.
When I use this for disconnecting device any other formalities are needed in between or only these APIs are ok?
I am not able to disconnect using these APIs.Some time it is give effect and some time it is not working.
If any one have idea abut this please respond.
Thanks in advance.
Do you mean Bluez 5.4 or Bluez 5.40? Either way, they are quite old releases.
gatttool is one of the BlueZ tools that has been deprecated in BlueZ.
Ideally you would be using the BlueZ DBus API to interact with BlueZ.
Not sure if you are creating a GATT Server (peripheral device) or GATT client (Central Device) but there are examples of both in the BlueZ source:
https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/test/example-gatt-server
https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/test/example-gatt-client
These examples are in Python, but most languages have DBus libraries to help access the API which are documented at:
https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/adapter-api.txt
https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/device-api.txt
https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/gatt-api.txt

GATT API bluez - MI band 2

I have been trying for a few weeks to connect to the MI Band 2 watch, and read the heart rate characteristic value, but without luck.
I am a little unsure what the procedure is, when we are talking about GATT.
For the API https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/gatt-api.txt I was thinking about using the org.bluez.GattCharacteristic1 interface to read a value out.
I can connect and pair the watch, and get all UUIDs (services, descriptors and characteristics). The heart rate measurement has the following info:
Characteristic
/org/bluez/hci0/dev_CD_1D_69_25_19_5E/service0027/char0028
00002a37-0000-1000-8000-00805f9b34fb
I have tried using the bluetoothctl program to read the value, but getting a "not permitted" feedback.
What is the procedure to read out a characteristic value, using the GATT API.
Your device is using the adopted Heart Rate profile, seeing that 0x2A37 is the adopted characteristic UUID for heart rate measurement. I would recommend that you use the BlueZ command line tools as follows:-
1. Find the handle of the heart rate characteristic using:-
gatttool -b 00:11:22:33:44:55 --characteristics
Replace 00:11:22:33:44:55 with the Bluetooth address of your device. You basically want to find the uuid that contains 2a37 and note down its corresponding 'char value handle'.
2. Find the descriptors at that handle using:-
gatttool -b 00:11:22:33:44:55 char-desc --handle=0xXX
Where XX is the char value handle that you noted down earlier. You should be able to see a couple of characteristic descriptors at that handle. Note down the char handle with uuid 2902.
3- Enable notifications by writing '0100' at that handle using:-
gatttool -b 00:11:22:33:44:55 --sec-level=high --char-write --handle=0xYYYY --value=0100
Where 0xYYYY is the handle of the CCCD descriptor that you noted in step 2. Once this happens, you should start getting indication data, which you can decipher using the temperature data structure found here.
You can find more information about using the BlueZ commands at the following links:-
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
Using Bluetooth low energy in linux command line
I hope this helps.
Maybe you could try the shell program gatttool or use app like nRF Connect to read.

Is running HM10 on a soft-serial enable the Low Energy charecteristics ? If so, how can the UUIDs and GATT profiles be tweaked in this case ?

I've been tinkering with the HM-10 board for a few weeks now, trying to push data from phone to module and vice-versa. The ultimate goal was to enable the BLE mode and tweak with the characteristics and GATT profiles. I'm pretty new to this domain so can anyone help me out ?
And is there any way we can interface the HM-10 with the hardware rx-tx channel instead of soft-serial ?
Your question is still not very clear, but i think you mean sending AT-commands over BLE-radio.
To make this possible you have to change the MODE using serial connection.
In standard mode the device can only be configured over the serial connection (pins RXD and TXD) using AT commands.
AT+MODE0: It only accepts AT-commands over the serial connection (RXD/TXD)
until a central device connects to the module.
AT+MODE1: Same as MODE0, once a connection is established,
AT-commands can be sent over BLE and manipulate some PIO pins on
the device.
AT+MODE2: Same as MODE0, once a connection is established,
AT-commands can be sent over BLE.
To test it just send a string to hm-10 as "AT\r\n" and it will respond with OK.
Update:
You cannot change the services and characteristics with AT-commands.
There are a lot of other things you can change,like advertising, setup a beacon and change a lot of settings.
For a full list of AT commands and more see the official data sheet:
http://www.jnhuamao.cn/bluetooth41_en.zip

BLE pairing failure when changing MAC address using HCI command

I'm engaging in dev. project which uses BlueZ v5.26 and TI CC2564 chip.
Recently there needs to change BT MAC address to be in the range of that customer owns. To meet, I used hci command as chip maker guides in the following link. And, I also tried with 'bdaddr' tool in bluez.
http://processors.wiki.ti.com/index.php/CC256x_VS_HCI_Commands#HCI_VS_Write_BD_Addr_.280xFC06.29
It looks controller MAC address is changed, but Bluetooth daemon still keeps chip original MAC address. Bluetoothctl shows original address. When trying to pair with BLE device, authentication failure happens at the moment. I guess it's because of this address mismatch in the daemon. Is there any way to make bluetooth daemon to use revised address after updating MAC with HCi command?
Thank you for the answer in advance.

GATTService interface doesn't appear

My goal is to activate a notification on a Bluetooth Low Energy device to receive data using the DBus Interface so I downloaded the last Bluez version (5.33).
I read the README file and I used the --enable-experimental options
during the configuration.
Now I can only scan for the LE device and connect with it using the Adpeter1 and Device1 interfaces. In the next step I need to connect to the GATTService interface on the device but using d-feet I can't see this interface.
You need to start bluetoothd with the -E (experimental) option.

Resources