The callback prototype to indicate a service has been connected or a connection attempt has failed.
Synopsis:
#include <btapi/btgatt.h>
typedef void(* bt_gatt_service_connected_cb)(const char *bdaddr, const char *service, int instance, int err, uint16_t connInt, uint16_t latency, uint16_t superTimeout, void *userData);
Library:
libbtapi (For the qcc command, use the -l btapi
option to link against this library)
Description:
The connInt, latency, and superTimeout are only required for low energy devices.
The arguments for the prototype are as follows:
- bdaddr
- The address of the Bluetooth-enabled device.
- service
- The service that has been connected. This can be either 128-bit or 16-bit
Universally Unique Identifiers (UUIDs). The UUID is represented as a string
value.
- instance
- An identifier used to reference the service connection.
- err
-
EOK indicates a successful service connection, otherwise an error
code indicates reason for the connection failure. The following error codes can be
returned:
-
EACCES: An authentication or pairing failure occurred.
-
EBUSY: The stack was busy and could not complete the
request.
-
ECONNREFUSED: The connection was refused due because of the
provided connection parameters.
-
ECONNRESET: The remote party terminated connection.
-
EINVAL: Invalid stack parameters or connection to the
remote Bluetooth-enabled device is not available.
-
EMLINK: There were too many active connections.
-
ENETUNREACH: A page timeout occurred.
-
ENOENT: The service was not available on device.
-
ENOMEM: Insufficient memory to perform the request.
-
ENOSYS: The operation failed at the stack level.
-
EPROTO: The operation failed because the response from
the remote Bluetooth-enabled device had a protocol error.
-
ETIMEOUT: The connection attempt timed out.
- connInt
- The negotiated connection interval for the service. Use this argument only for
low energy devices. For BR/EDR devices this value is zero.
- latency
- The negotiated latency for the service. Use this argument only for low energy
devices. For BR/EDR devices this value is zero.
- superTimeout
- The negotiated supervisor timeout for the connection. Use this argument only
for low energy devices. For BR/EDR devices this value is zero.
- userData
- Pointer to user data passed in during the connection request.