Once I'm connected to a bluetooth device I try to read and write a request by handle or uuid (I tried both) with no success.

I'm using this library gattlib-master which works for the examples of ble_scan and discover with little changes.

The problem is that the example read_write, never fills the buffer used in both functions gattlib_read_char_by_uuid(connection, &g_uuid, buffer, sizeof(buffer)); and gattlib_write_char_by_handle(connection, handle, buffer, sizeof(buffer));

Any idea of were could the problem be? If not, can anyone tell me where could I find read/write examples with Bluez for Linux in C/C++?

Thanks in advance.

  • You have to post a code sample reproducing the issue if you want help with your code. You say you made "little changes" to the library, do you expect people to guess what those changes are? Oct 6, 2016 at 8:31

1 Answer 1


I am the author of gattlib. I have sign-in to try to help you with your issue.
Unfortunately, my reputation is not high enough to leave a comment to your initial message. You can also leave your issue on Github, maybe someone will have the same issue as you.

Feel free to contribute to Gattlib. I will be happy to review your changes and integrate them back to the repository.

To come back on your issue, can you connect to your BLE device with gatttool and read the characteristic. It would be something like that?

gatttool -b <your-ble-address> -I connect char-read-uuid <uuid-of-your-characteristic>

  • Yes I am able to do it, but when I compile the read/write functions they do not work correctly as the buffer where the information should be written is always empty. However, the scan function works perfectly. @Olivier
    – D. Mellow
    Aug 22, 2016 at 9:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.