Perform a Generic Attribute (GATT) call to read a value from a provided handle.


#include <btapi/btgatt.h>
int bt_gatt_read_value(int instance, uint16_t handle, uint16_t offset, uint8_t *data, uint16_t size, uint8_t *more)


BlackBerry 10.0.0



The identifier used to reference the connected primary service.


The handle of the value to be read.


The offset to begin reading from.


A pointer to the array to be populated with the data that is read.


The size of the array passed that is passed to the function.


(Optional) Use a value of 1 to indicate that there is more data to read and a value of 0 to explicitly indicate that there is no more data to be read.


libbtapi (For the qcc command, use the -l btapi option to link against this library)


You can use the optional more argument to indicate there is more data to read. If you do not provide the value, the function does indicate whether there is more data to be read. The reason being that in most cases, the size of the data is defined by the specifications of the protocol.


The number of bytes that have been read when the function is successfully completed, -1 with the errno set otherwise. The error codes that can be returned are as follows:
  • EACCESS: Insufficient authentication or authorization.
  • EBUSY: The stack was busy performing another operation. You can try again later.
  • EDEADLK: A potential deadlock has been avoided.
  • EINVAL: The arguments passed are invalid or the connection to the remote Bluetooth-enabled device is unavailable.
  • ENODEV: Unable to find the service connection defined by the instance argument.
  • ENOENT: An invalid handle was provided for the GATT server.
  • ENOMEM: Insufficient memory to perform the request.
  • ENOSYS: The operation failed at the stack level.
  • ENXIO: An unknown handle value was provided for a service.
  • EPERM: An attribute could not be read.
  • EPROTO: The operation failed because the response from remote Bluetooth-enabled device had a protocol error.
  • ESRCH: The service connection was not available.
  • ESRVRFAULT: An internal error has occurred.

Last modified: 2014-05-14

Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus