bt_gatt_write_value()

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

Synopsis:

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

Since:

BlackBerry 10.0.0

Arguments:

instance

The identifier used to reference the connected primary service.

handle

The to the value to be written.

offset

The offset to begin writing from.

data

An array of data to be written.

size

The size of the array to be written.

Library:

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

Description:

This function writes values and expects a response from the remote Bluetooth-enabled device. The size of the value to be written cannot be larger than ATT_MTU - 3 bytes.

Returns:

EOK when data writing is successfully completed, -1 with the errno set otherwise. The error codes that can be returned are as follows:
  • E2BIG: The requested write size is larger than ATT_MTU - 3 bytes.
  • 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 written to.
  • EPROTO: The operation failed because the response from the remote Bluetooth-enabled device had a protocol error.
  • ESRCH: The service connection was not available.
  • ESRVRFAULT: An internal error has occurred.