Request for an asynchronous connection to the remote device.
Synopsis:
#include <btapi/btgatt.h>
int bt_gatt_connect_services(const char *bdaddr, const char **services, bt_gatt_scan_parm_t *scanParm, bt_gatt_conn_parm_t *connParm, void *userData)
Arguments:
- bdaddr
-
The MAC address of the remote Bluetooth-enabled device.
- services
-
A NULL-terminated string list of services to be connected to. This can be represented as 128-bit or 16-bit Universally Unique Identifiers (UUIDs). The UUID is represented as a 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.
- scanParm
-
(Optional) The requested link connection scan parameters. Use this argument when you require specific connection parameters for the service, set to NULL to use default values otherwise. 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
- connParm
-
(Optional) The requested link connection parameters. Use this argument when you require specific connection parameters for the service, set to NULL to use default values otherwise. Only use this argument for low-energy devices. These are the default values.
- connMin = 30ms
- connMax = 60ms
- interval = 30ms
- superTimeout = 30sec
- userData
-
(Optional) A pointer to user data that will be passed back during connection/disconnection callbacks.
Library:
libbtapi (For the qcc command, use the -l btapi option to link against this library)
Description:
When the connection completes, the bt_gatt_service_connected_cb is called.
Returns:
EOK on successful registration of a service connection request,
-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.
- EDEADLK: A potential deadlock has been avoided.
- EBUSY: One of the requested services is currently in use.
- EINVAL: The passed arguments are invalid.
- ENODEV: The requested Bluetooth-enabled device could not be found in the paired/known device list.
- ENOMEM: Insufficient memory to perform the request.
- ENOSYS: Could not create a connection to the device.
- ENOTSUP: The requested service is not supported by the device.
- ESRVRFAULT: An internal error has occurred.