BLE device not disconnecting

384 Views Asked by At

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.

1

There are 1 best solutions below

5
On

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