dotstack API Reference  1.10.37
Data Structures | Macros | Typedefs | Functions
GATT Server

This module describes functions and data structures used to implement a GATT server (peripheral). More...

Data Structures

struct  bt_gatt_listener_t
 GATT server listener. More...
 
struct  bt_gatt_evt_header_t
 Common to all event parameters header. More...
 
struct  bt_gatt_evt_client_config_changed_t
 Parameter to GATT_SERVER_EVT_CLIENT_CONFIG_CHANGED event. More...
 
struct  bt_gatt_evt_server_config_changed_t
 Parameter to GATT_SERVER_EVT_SERVER_CONFIG_CHANGED event. More...
 
struct  bt_gatt_evt_ext_properties_changed_t
 Parameter to GATT_SERVER_EVT_EXTENDED_PROPERTIES_CHANGED event. More...
 
struct  bt_gatt_evt_value_changed_t
 Parameter to GATT_SERVER_EVT_VALUE_CHANGED event. More...
 
struct  bt_gatt_evt_value_read_t
 Parameter to GATT_SERVER_EVT_VALUE_READ event. More...
 

Macros

#define bt_gatt_server_start(att_var_db, att_var_db_len, att_const_db, att_const_db_len)   bt_gatt_server_start_ex(att_var_db, att_var_db_len, att_const_db, att_const_db_len, BT_FALSE)
 Start GATT server. More...
 
#define bt_gatt_server_write_char_value(service_type, service_id, characteristic_type, value, value_len, offset)   bt_gatt_server_write_char_value_ex(service_type, service_id, characteristic_type, value, value_len, offset, NULL)
 Write characteristic's value (16-bit). More...
 
#define bt_gatt_server_write_char_value_80(service_type, service_id, characteristic_type, value, value_len, offset)   bt_gatt_server_write_char_value_80_ex(service_type, service_id, characteristic_type, value, value_len, offset, NULL)
 Write characteristic's value (128-bit). More...
 
#define bt_gatt_server_authorize_access(session, attr, opcode, authorize)   bt_att_server_authorize_access(session, attr, opcode, authorize)
 Authorize access to an attribute. More...
 

Typedefs

typedef void(* bt_gatt_server_callback_fp) (bt_int evt, void *evt_param, void *param)
 GATT server listener callback. More...
 

Functions

bt_bool bt_gatt_server_start_ex (bt_byte *att_var_db, bt_uint att_var_db_len, const bt_byte *att_const_db, bt_uint att_const_db_len, bt_bool listen_on_dynamic_channel)
 Start GATT server (extended version) More...
 
bt_bool bt_gatt_server_stop (void)
 Stop GATT server. More...
 
void bt_gatt_server_register_callback (bt_gatt_server_callback_fp callback, void *param)
 Register a GATT application callback. More...
 
bt_bool bt_gatt_server_register_listener (bt_gatt_listener_t *listener)
 Register a GATT event listener. More...
 
void bt_gatt_server_unregister_listener (bt_gatt_listener_t *listener)
 Unregister a GATT event listener. More...
 
bt_byte bt_gatt_server_write_char_value_ex (bt_uuid16 service_type, bt_uuid16 service_id, bt_uuid16 characteristic_type, const bt_byte *value, bt_uint value_len, bt_uint offset, bt_att_session_t *session)
 Write characteristic's value (16-bit). More...
 
bt_byte bt_gatt_server_write_char_value_80_ex (const bt_uuid_t *service_type, const bt_uuid_t *service_id, const bt_uuid_t *characteristic_type, const bt_byte *value, bt_uint value_len, bt_uint offset, bt_att_session_t *session)
 Write characteristic's value (128-bit). More...
 
bt_byte bt_gatt_server_notify_char_value (bt_uuid16 service_type, bt_uuid16 service_id, bt_uuid16 characteristic_type)
 Notify characteristic's value (16-bit). More...
 
bt_byte bt_gatt_server_notify_char_value_80 (bt_uuid_t *service_type, bt_uuid_t *service_id, bt_uuid_t *characteristic_type)
 Notify characteristic's value (128-bit). More...
 
bt_byte bt_gatt_server_indicate_char_value (bt_uuid16 service_type, bt_uuid16 service_id, bt_uuid16 characteristic_type)
 Indicate characteristic's value (16-bit). More...
 
bt_byte bt_gatt_server_indicate_char_value_80 (bt_uuid_t *service_type, bt_uuid_t *service_id, bt_uuid_t *characteristic_type)
 Indicate characteristic's value (128-bit). More...
 

Events

#define GATT_SERVER_EVT_SESSION_CONNECTED   ATT_SERVER_EVT_SESSION_CONNECTED
 A client connected to the server.
 
#define GATT_SERVER_EVT_SESSION_DISCONNECTED   ATT_SERVER_EVT_SESSION_DISCONNECTED
 A client disconnected from the server.
 
#define GATT_SERVER_EVT_ATTR_VALUE_NOTIFIED   ATT_SERVER_EVT_ATTR_VALUE_NOTIFIED
 A value notification has bee sent to the client.
 
#define GATT_SERVER_EVT_ATTR_VALUE_INDICATED   ATT_SERVER_EVT_ATTR_VALUE_INDICATED
 A value indication has been sent to the client.
 
#define GATT_SERVER_EVT_AUTHORIZATION_REQUESTED   ATT_SERVER_EVT_AUTHORIZATION_REQUESTED
 Authorization is required in order to access the attribute's value.
 
#define GATT_SERVER_EVT_CLIENT_CONFIG_CHANGED   100
 Characteristic's client configuration changed.
 
#define GATT_SERVER_EVT_EXTENDED_PROPERTIES_CHANGED   101
 Characteristic's extended properties changed.
 
#define GATT_SERVER_EVT_SERVER_CONFIG_CHANGED   102
 Characteristic's server configuration changed.
 
#define GATT_SERVER_EVT_VALUE_CHANGED   103
 Characteristic's value changed.
 
#define GATT_SERVER_EVT_VALUE_READ   104
 Characteristic's value has been read.
 

Detailed Description

This module describes functions and data structures used to implement a GATT server (peripheral).

Macro Definition Documentation

#define bt_gatt_server_authorize_access (   session,
  attr,
  opcode,
  authorize 
)    bt_att_server_authorize_access(session, attr, opcode, authorize)

Authorize access to an attribute.

If an attribute requires authorization before its value can be read or written, GATT generates a GATT_SERVER_EVT_AUTHORIZATION_REQUESTED event. In response to this event the application should obtain authorization (how this is done is implementation specific) and call bt_gatt_server_authorize_access.

Parameters
sessionATT session.
attrAttribute.
opcodeAttribute Opcode. The opcode that requires authorization is passed in the ATT_SERVER_EVT_AUTHORIZATION_REQUESTED event. The application should use the passed opcode when calling bt_att_server_authorize_access. The opcode can be one the following values:
  • ATT_OPCODE_READ_REQUEST
  • ATT_OPCODE_READ_BLOB_REQUEST
  • ATT_OPCODE_READ_BY_TYPE_REQUEST
  • ATT_OPCODE_READ_BY_GROUP_TYPE_REQUEST
  • ATT_OPCODE_READ_MULTIPLE_REQUEST
  • ATT_OPCODE_WRITE_REQUEST
  • ATT_OPCODE_PREPARE_WRITE_REQUEST
authorizeSpecifies whether access to the attribute has been authorized or not.
#define bt_gatt_server_start (   att_var_db,
  att_var_db_len,
  att_const_db,
  att_const_db_len 
)    bt_gatt_server_start_ex(att_var_db, att_var_db_len, att_const_db, att_const_db_len, BT_FALSE)

Start GATT server.

This function starts the GATT server. This function start the server only on LE links.

Parameters
att_var_dbA pointer to ATT database that holds writable attributes.
att_var_db_lenThe length of the writable ATT database.
att_const_dbA pinter to ATT database that holds read-only attributes.
att_const_db_lenThe length of the read-only ATT database.
listen_on_dynamic_channelSpecifies whether ATT server should accept connections on BR/EDR links.
Returns
  • TRUE if the function succeeds.
  • FALSE otherwise.
#define bt_gatt_server_write_char_value (   service_type,
  service_id,
  characteristic_type,
  value,
  value_len,
  offset 
)    bt_gatt_server_write_char_value_ex(service_type, service_id, characteristic_type, value, value_len, offset, NULL)

Write characteristic's value (16-bit).

This function updates characteristic's value. If the client configured characteristic to be notified or indicated this function sends new value to the client. If multiple clients are connected notification/indication will be sent to all connected clients.

Parameters
service_type16-bit service type UUID.
service_id16-bit service type UUID.
characteristic_type16-bit characteristic type UUID.
valuepointer to a buffer containing a value to be written to the characteristic.
value_lenthe length of the value.
offsetthe offset to the characteristic's value from which the value is to be written. offset + value_len should not exceed the maximum length of the characteristic value. Otherwise the call will fail.
Returns
Error code. This can be one of the following values:
  • ATT_ERROR_SUCCESS
  • ATT_ERROR_INVALID_HANDLE
  • ATT_ERROR_READ_NOT_PERMITTED
  • ATT_ERROR_WRITE_NOT_PERMITTED
  • ATT_ERROR_INVALID_PDU
  • ATT_ERROR_INSUFFICIENT_AUTHENTICATION
  • ATT_ERROR_REQUEST_NOT_SUPPORTED
  • ATT_ERROR_INVALID_OFFSET
  • ATT_ERROR_INSUFFICIENT_AUTHORIZATION
  • ATT_ERROR_PREPARE_QUEUE_FULL
  • ATT_ERROR_ATTRIBUTE_NOT_FOUND
  • ATT_ERROR_ATTRIBUTE_NOT_LONG
  • ATT_ERROR_INSUFFICIENT_ENCRYPTION_KEY_SIZE
  • ATT_ERROR_INVALID_ATTRIBUTE_VALUE_LENGTH
  • ATT_ERROR_UNLIKELY_ERROR
  • ATT_ERROR_INSUFFICIENT_ENCRYPTION
  • ATT_ERROR_UNSUPPORTED_GROUP_TYPE
  • ATT_ERROR_INSUFFICIENT_RESOURCES
#define bt_gatt_server_write_char_value_80 (   service_type,
  service_id,
  characteristic_type,
  value,
  value_len,
  offset 
)    bt_gatt_server_write_char_value_80_ex(service_type, service_id, characteristic_type, value, value_len, offset, NULL)

Write characteristic's value (128-bit).

This function updates characteristic's value. If the client configured characteristic to be notified or indicated this function sends new value to the client. If multiple clients are connected notification/indication will be sent to all connected clients. In order to use standard 16-bit UUIDs with this function they have to be converted to 128-bit UUID by combining with a base UUID which is 00000000 (this part is replaced with 16-bit UUID) - 00001000 - 80000080 - 5F9B34FB.

Parameters
service_type128-bit service type UUID.
service_id128-bit service type UUID.
characteristic_type128-bit characteristic type UUID.
valuepointer to a buffer containing a value to be written to the characteristic.
value_lenthe length of the value.
offsetthe offset to the characteristic's value from which the value is to be written. offset + value_len should not exceed the maximum length of the characteristic value. Otherwise the call will fail.
Returns
Error code. This can be one of the following values:
  • ATT_ERROR_SUCCESS
  • ATT_ERROR_INVALID_HANDLE
  • ATT_ERROR_READ_NOT_PERMITTED
  • ATT_ERROR_WRITE_NOT_PERMITTED
  • ATT_ERROR_INVALID_PDU
  • ATT_ERROR_INSUFFICIENT_AUTHENTICATION
  • ATT_ERROR_REQUEST_NOT_SUPPORTED
  • ATT_ERROR_INVALID_OFFSET
  • ATT_ERROR_INSUFFICIENT_AUTHORIZATION
  • ATT_ERROR_PREPARE_QUEUE_FULL
  • ATT_ERROR_ATTRIBUTE_NOT_FOUND
  • ATT_ERROR_ATTRIBUTE_NOT_LONG
  • ATT_ERROR_INSUFFICIENT_ENCRYPTION_KEY_SIZE
  • ATT_ERROR_INVALID_ATTRIBUTE_VALUE_LENGTH
  • ATT_ERROR_UNLIKELY_ERROR
  • ATT_ERROR_INSUFFICIENT_ENCRYPTION
  • ATT_ERROR_UNSUPPORTED_GROUP_TYPE
  • ATT_ERROR_INSUFFICIENT_RESOURCES

Typedef Documentation

typedef void(* bt_gatt_server_callback_fp) (bt_int evt, void *evt_param, void *param)

GATT server listener callback.

In order to be notified of various events a user's application has to register at least one listener. The stack will call the callback function specified in the listener whenever a new event has been generated.

Parameters
evtEvent ID.
evt_paramEvent parameter.
callback_paramA pointer to an arbitrary data set by a call to bt_gatt_server_register_listener().

Function Documentation

bt_byte bt_gatt_server_indicate_char_value ( bt_uuid16  service_type,
bt_uuid16  service_id,
bt_uuid16  characteristic_type 
)

Indicate characteristic's value (16-bit).

This function sends current characteristic's value to the client. The value is sent regardless of characteristic's client configuration. GATT_SERVER_EVT_ATTR_VALUE_INDICATED event is generated after receiving confirmation from the client.

Parameters
service_type16-bit service type UUID.
service_id16-bit service type UUID.
characteristic_type16-bit characteristic type UUID.
Returns
Error code. This can be one of the following values:
  • ATT_ERROR_SUCCESS
  • ATT_ERROR_INVALID_HANDLE
  • ATT_ERROR_READ_NOT_PERMITTED
  • ATT_ERROR_WRITE_NOT_PERMITTED
  • ATT_ERROR_INVALID_PDU
  • ATT_ERROR_INSUFFICIENT_AUTHENTICATION
  • ATT_ERROR_REQUEST_NOT_SUPPORTED
  • ATT_ERROR_INVALID_OFFSET
  • ATT_ERROR_INSUFFICIENT_AUTHORIZATION
  • ATT_ERROR_PREPARE_QUEUE_FULL
  • ATT_ERROR_ATTRIBUTE_NOT_FOUND
  • ATT_ERROR_ATTRIBUTE_NOT_LONG
  • ATT_ERROR_INSUFFICIENT_ENCRYPTION_KEY_SIZE
  • ATT_ERROR_INVALID_ATTRIBUTE_VALUE_LENGTH
  • ATT_ERROR_UNLIKELY_ERROR
  • ATT_ERROR_INSUFFICIENT_ENCRYPTION
  • ATT_ERROR_UNSUPPORTED_GROUP_TYPE
  • ATT_ERROR_INSUFFICIENT_RESOURCES
bt_byte bt_gatt_server_indicate_char_value_80 ( bt_uuid_t *  service_type,
bt_uuid_t *  service_id,
bt_uuid_t *  characteristic_type 
)

Indicate characteristic's value (128-bit).

This function sends current characteristic's value to the client. The value is sent regardless of characteristic's client configuration. GATT_SERVER_EVT_ATTR_VALUE_INDICATED event is generated after receiving confirmation from the client. In order to use standard 16-bit UUIDs with this function they have to be converted to 128-bit UUID by combining with a base UUID which is 00000000 (this part is replaced with 16-bit UUID) - 00001000 - 80000080 - 5F9B34FB.

Parameters
service_type128-bit service type UUID.
service_id128-bit service type UUID.
characteristic_type128-bit characteristic type UUID.
Returns
Error code. This can be one of the following values:
  • ATT_ERROR_SUCCESS
  • ATT_ERROR_INVALID_HANDLE
  • ATT_ERROR_READ_NOT_PERMITTED
  • ATT_ERROR_WRITE_NOT_PERMITTED
  • ATT_ERROR_INVALID_PDU
  • ATT_ERROR_INSUFFICIENT_AUTHENTICATION
  • ATT_ERROR_REQUEST_NOT_SUPPORTED
  • ATT_ERROR_INVALID_OFFSET
  • ATT_ERROR_INSUFFICIENT_AUTHORIZATION
  • ATT_ERROR_PREPARE_QUEUE_FULL
  • ATT_ERROR_ATTRIBUTE_NOT_FOUND
  • ATT_ERROR_ATTRIBUTE_NOT_LONG
  • ATT_ERROR_INSUFFICIENT_ENCRYPTION_KEY_SIZE
  • ATT_ERROR_INVALID_ATTRIBUTE_VALUE_LENGTH
  • ATT_ERROR_UNLIKELY_ERROR
  • ATT_ERROR_INSUFFICIENT_ENCRYPTION
  • ATT_ERROR_UNSUPPORTED_GROUP_TYPE
  • ATT_ERROR_INSUFFICIENT_RESOURCES
bt_byte bt_gatt_server_notify_char_value ( bt_uuid16  service_type,
bt_uuid16  service_id,
bt_uuid16  characteristic_type 
)

Notify characteristic's value (16-bit).

This function sends current characteristic's value to the client. The value is sent regardless of characteristic's client configuration. GATT_SERVER_EVT_ATTR_VALUE_NOTIFIED is generated right after the value has been sent.

Parameters
service_type16-bit service type UUID.
service_id16-bit service type UUID.
characteristic_type16-bit characteristic type UUID.
Returns
Error code. This can be one of the following values:
  • ATT_ERROR_SUCCESS
  • ATT_ERROR_INVALID_HANDLE
  • ATT_ERROR_READ_NOT_PERMITTED
  • ATT_ERROR_WRITE_NOT_PERMITTED
  • ATT_ERROR_INVALID_PDU
  • ATT_ERROR_INSUFFICIENT_AUTHENTICATION
  • ATT_ERROR_REQUEST_NOT_SUPPORTED
  • ATT_ERROR_INVALID_OFFSET
  • ATT_ERROR_INSUFFICIENT_AUTHORIZATION
  • ATT_ERROR_PREPARE_QUEUE_FULL
  • ATT_ERROR_ATTRIBUTE_NOT_FOUND
  • ATT_ERROR_ATTRIBUTE_NOT_LONG
  • ATT_ERROR_INSUFFICIENT_ENCRYPTION_KEY_SIZE
  • ATT_ERROR_INVALID_ATTRIBUTE_VALUE_LENGTH
  • ATT_ERROR_UNLIKELY_ERROR
  • ATT_ERROR_INSUFFICIENT_ENCRYPTION
  • ATT_ERROR_UNSUPPORTED_GROUP_TYPE
  • ATT_ERROR_INSUFFICIENT_RESOURCES
bt_byte bt_gatt_server_notify_char_value_80 ( bt_uuid_t *  service_type,
bt_uuid_t *  service_id,
bt_uuid_t *  characteristic_type 
)

Notify characteristic's value (128-bit).

This function sends current characteristic's value to the client. The value is sent regardless of characteristic's client configuration. GATT_SERVER_EVT_ATTR_VALUE_NOTIFIED is generated right after the value has been sent. In order to use standard 16-bit UUIDs with this function they have to be converted to 128-bit UUID by combining with a base UUID which is 00000000 (this part is replaced with 16-bit UUID) - 00001000 - 80000080 - 5F9B34FB.

Parameters
service_type128-bit service type UUID.
service_id128-bit service type UUID.
characteristic_type128-bit characteristic type UUID.
Returns
Error code. This can be one of the following values:
  • ATT_ERROR_SUCCESS
  • ATT_ERROR_INVALID_HANDLE
  • ATT_ERROR_READ_NOT_PERMITTED
  • ATT_ERROR_WRITE_NOT_PERMITTED
  • ATT_ERROR_INVALID_PDU
  • ATT_ERROR_INSUFFICIENT_AUTHENTICATION
  • ATT_ERROR_REQUEST_NOT_SUPPORTED
  • ATT_ERROR_INVALID_OFFSET
  • ATT_ERROR_INSUFFICIENT_AUTHORIZATION
  • ATT_ERROR_PREPARE_QUEUE_FULL
  • ATT_ERROR_ATTRIBUTE_NOT_FOUND
  • ATT_ERROR_ATTRIBUTE_NOT_LONG
  • ATT_ERROR_INSUFFICIENT_ENCRYPTION_KEY_SIZE
  • ATT_ERROR_INVALID_ATTRIBUTE_VALUE_LENGTH
  • ATT_ERROR_UNLIKELY_ERROR
  • ATT_ERROR_INSUFFICIENT_ENCRYPTION
  • ATT_ERROR_UNSUPPORTED_GROUP_TYPE
  • ATT_ERROR_INSUFFICIENT_RESOURCES
void bt_gatt_server_register_callback ( bt_gatt_server_callback_fp  callback,
void *  param 
)

Register a GATT application callback.

In order to be notified of various events a consumer of the GATT layer has to register a callback function. The stack will call this function whenever a new event has been generated passing the code of the event as the first parameter. The event can be one of the following values:

  • GATT_SERVER_EVT_SESSION_CONNECTED A client connected to the server.
  • GATT_SERVER_EVT_SESSION_DISCONNECTED A client disconnected from the server.
  • GATT_SERVER_EVT_ATTR_VALUE_NOTIFIED A value notification has bee sent to the client.
  • GATT_SERVER_EVT_ATTR_VALUE_INDICATED A value indication has been sent to the client.
  • GATT_SERVER_EVT_AUTHORIZATION_REQUESTED Authorization is required in order to access the attribute's value.
  • GATT_SERVER_EVT_CLIENT_CONFIG_CHANGED Characteristic's client configuration changed
  • GATT_SERVER_EVT_EXTENDED_PROPERTIES_CHANGED Characteristic's extended properties changed
  • GATT_SERVER_EVT_SERVER_CONFIG_CHANGED Characteristic's server configuration changed
  • GATT_SERVER_EVT_VALUE_CHANGED Characteristic's value changed
Parameters
callbackThe callback function that will be called when GATT generates an event.
callback_paramA pointer to arbitrary data to be passed to the callback callback.
bt_bool bt_gatt_server_register_listener ( bt_gatt_listener_t listener)

Register a GATT event listener.

In order to be notified of various events a consumer of the GATT layer may register an event listener. The listener is a structure that contains a pointer to a callback and callback parameter - a pointer to arbitrary data to be passed to the callback . The stack will call the callback whenever a new event has been generated passing the code of the event as the first parameter. The event can be one of the following values:

  • GATT_SERVER_EVT_SESSION_CONNECTED A client connected to the server.
  • GATT_SERVER_EVT_SESSION_DISCONNECTED A client disconnected from the server.
  • GATT_SERVER_EVT_ATTR_VALUE_NOTIFIED A value notification has bee sent to the client.
  • GATT_SERVER_EVT_ATTR_VALUE_INDICATED A value indication has been sent to the client.
  • GATT_SERVER_EVT_AUTHORIZATION_REQUESTED Authorization is required in order to access the attribute's value.
  • GATT_SERVER_EVT_CLIENT_CONFIG_CHANGED Characteristic's client configuration changed
  • GATT_SERVER_EVT_EXTENDED_PROPERTIES_CHANGED Characteristic's extended properties changed
  • GATT_SERVER_EVT_SERVER_CONFIG_CHANGED Characteristic's server configuration changed
  • GATT_SERVER_EVT_VALUE_CHANGED Characteristic's value changed
Parameters
listenerListener.
bt_bool bt_gatt_server_start_ex ( bt_byte *  att_var_db,
bt_uint  att_var_db_len,
const bt_byte *  att_const_db,
bt_uint  att_const_db_len,
bt_bool  listen_on_dynamic_channel 
)

Start GATT server (extended version)

This function starts the GATT server. This function can be used to start the server on BR/EDR links.

Parameters
att_var_dbA pointer to ATT database that holds writable attributes.
att_var_db_lenThe length of the writable ATT database.
att_const_dbA pinter to ATT database that holds read-only attributes.
att_const_db_lenThe length of the read-only ATT database.
listen_on_dynamic_channelSpecifies whether ATT server should accept connections on BR/EDR links.
Returns
  • TRUE if the function succeeds.
  • FALSE otherwise.
bt_bool bt_gatt_server_stop ( void  )

Stop GATT server.

This function stops the GATT server. After this call the GATT will not accept and respond to request from remote devices.

Returns
  • TRUE if the function succeeds.
  • FALSE otherwise.
void bt_gatt_server_unregister_listener ( bt_gatt_listener_t listener)

Unregister a GATT event listener.

Remove a listener previosuly registered with bt_gatt_server_register_listener.

Parameters
listenerListener.
bt_byte bt_gatt_server_write_char_value_80_ex ( const bt_uuid_t *  service_type,
const bt_uuid_t *  service_id,
const bt_uuid_t *  characteristic_type,
const bt_byte *  value,
bt_uint  value_len,
bt_uint  offset,
bt_att_session_t *  session 
)

Write characteristic's value (128-bit).

This function updates characteristic's value. If the client configured characteristic to be notified or indicated this function sends new value to the client.If multiple clients are connected and session parameter is NULL, notification/indication will be sent to all connected clients. If session is not NULL, only the client corresponding to the session will be notified/indicated. In order to use standard 16-bit UUIDs with this function they have to be converted to 128-bit UUID by combining with a base UUID which is 00000000 (this part is replaced with 16-bit UUID) - 00001000 - 80000080 - 5F9B34FB.

Parameters
service_type128-bit service type UUID.
service_id128-bit service type UUID.
characteristic_type128-bit characteristic type UUID.
valuepointer to a buffer containing a value to be written to the characteristic.
value_lenthe length of the value.
offsetthe offset to the characteristic's value from which the value is to be written. offset + value_len should not exceed the maximum length of the characteristic value. Otherwise the call will fail.
sessionthe ATT session to be notified/indicated about the value change.
Returns
Error code. This can be one of the following values:
  • ATT_ERROR_SUCCESS
  • ATT_ERROR_INVALID_HANDLE
  • ATT_ERROR_READ_NOT_PERMITTED
  • ATT_ERROR_WRITE_NOT_PERMITTED
  • ATT_ERROR_INVALID_PDU
  • ATT_ERROR_INSUFFICIENT_AUTHENTICATION
  • ATT_ERROR_REQUEST_NOT_SUPPORTED
  • ATT_ERROR_INVALID_OFFSET
  • ATT_ERROR_INSUFFICIENT_AUTHORIZATION
  • ATT_ERROR_PREPARE_QUEUE_FULL
  • ATT_ERROR_ATTRIBUTE_NOT_FOUND
  • ATT_ERROR_ATTRIBUTE_NOT_LONG
  • ATT_ERROR_INSUFFICIENT_ENCRYPTION_KEY_SIZE
  • ATT_ERROR_INVALID_ATTRIBUTE_VALUE_LENGTH
  • ATT_ERROR_UNLIKELY_ERROR
  • ATT_ERROR_INSUFFICIENT_ENCRYPTION
  • ATT_ERROR_UNSUPPORTED_GROUP_TYPE
  • ATT_ERROR_INSUFFICIENT_RESOURCES
bt_byte bt_gatt_server_write_char_value_ex ( bt_uuid16  service_type,
bt_uuid16  service_id,
bt_uuid16  characteristic_type,
const bt_byte *  value,
bt_uint  value_len,
bt_uint  offset,
bt_att_session_t *  session 
)

Write characteristic's value (16-bit).

This function updates characteristic's value. If the client configured characteristic to be notified or indicated this function sends new value to the client. If multiple clients are connected and session parameter is NULL, notification/indication will be sent to all connected clients. If session is not NULL, only the client corresponding to the session will be notified/indicated.

Parameters
service_type16-bit service type UUID.
service_id16-bit service type UUID.
characteristic_type16-bit characteristic type UUID.
valuepointer to a buffer containing a value to be written to the characteristic.
value_lenthe length of the value.
offsetthe offset to the characteristic's value from which the value is to be written. offset + value_len should not exceed the maximum length of the characteristic value. Otherwise the call will fail.
sessionthe ATT session to be notified/indicated about the value change.
Returns
Error code. This can be one of the following values:
  • ATT_ERROR_SUCCESS
  • ATT_ERROR_INVALID_HANDLE
  • ATT_ERROR_READ_NOT_PERMITTED
  • ATT_ERROR_WRITE_NOT_PERMITTED
  • ATT_ERROR_INVALID_PDU
  • ATT_ERROR_INSUFFICIENT_AUTHENTICATION
  • ATT_ERROR_REQUEST_NOT_SUPPORTED
  • ATT_ERROR_INVALID_OFFSET
  • ATT_ERROR_INSUFFICIENT_AUTHORIZATION
  • ATT_ERROR_PREPARE_QUEUE_FULL
  • ATT_ERROR_ATTRIBUTE_NOT_FOUND
  • ATT_ERROR_ATTRIBUTE_NOT_LONG
  • ATT_ERROR_INSUFFICIENT_ENCRYPTION_KEY_SIZE
  • ATT_ERROR_INVALID_ATTRIBUTE_VALUE_LENGTH
  • ATT_ERROR_UNLIKELY_ERROR
  • ATT_ERROR_INSUFFICIENT_ENCRYPTION
  • ATT_ERROR_UNSUPPORTED_GROUP_TYPE
  • ATT_ERROR_INSUFFICIENT_RESOURCES