Request for an asynchronous connection to a single service.


#include <btapi/btgatt.h>
int bt_gatt_connect_service(const char *bdaddr, const char *service, bt_gatt_scan_parm_t *scanParm, bt_gatt_conn_parm_t *connParm, void *userData)


BlackBerry 10.0.0



The Bluetooth MAC address of the remote device.


The single service to be connected. This can be either a 128-bit or a 16-bit universally unique identifier (UUID). The UUID is represented as a NULL-terminated string value. An example of the string representation for GATT services is 0x1435. The 128-bit UUID is traditionally represented as 0xF0000000-0451-4000-B000-000000000000.

(Optional) The requested link connection scan parameters. Use this argument only when specific scan parameters are required for the service, otherwise set to NULL to use default values. Use this argument only for low energy devices. These are the default values:
  • interval1 = 30ms
  • interval12 = 60ms
  • window1 = 30ms
  • time1 = 30sec
  • interval2 = 1.28sec
  • window2 = 11.25ms
  • time2 = 30sec
(Optional) The requested link connection parameters. Use this argument when you require specific connection parameters for the service, set it to NULL to use default values otherwise. Use this argument only for low-energy devices. These are the default values:
  • minConn = 30ms
  • maxConn = 50ms
  • superTimeout = 100ms
  • latency = 0

(Optional) A pointer to user data that will be passed back during connection/disconnection callbacks.


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


After a connection attempt has completed, the bt_gatt_service_connected_cb function is called.


EOK on successful registration of the service connection requestor, -1 with the errno set otherwise. Some of the possible error codes that can be returned are as follows:
  • EAGAIN: The link to the Bluetooth stack is unavailable. You can try again.
  • EBUSY: The requested service is already in use.
  • EDEADLK: A potential deadlock has been avoided.
  • EINVAL: Invalid stack parameters or connection to the remote Bluetooth-enabled device is not available.
  • ENODEV: The requested Bluetooth-enabled device could not be found in the paired/known device list.
  • ENOMEM: Sufficient memory is not available to perform the request.
  • ENOTSUP: The requested service is not supported by the device.
  • ENOSYS: Could not create a connection to the device.
  • ESRVRFAULT: An internal error has occurred.
  • ETIMEOUT: The connection attempt timed out.

Last modified: 2014-09-30

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

comments powered by Disqus