MT2523 API Reference  LinkIt SDK v4
GATT Server

This section introduces the GATT server's database including terms and acronyms, supported features, details on how to use this driver, GATT server's function groups, enums, structures and functions. More...

Overview

This section introduces the GATT server's database including terms and acronyms, supported features, details on how to use this driver, GATT server's function groups, enums, structures and functions.

GATT server's database is divided into three levels, from the top to the bottom, the server, the services and the records. A server can have more than one service. A service can have more than one record with a type of bt_gatts_service_rec_t.

Terms and Acronyms

Terms Details
GATTS GATT Server, is the device that accepts incoming commands and requests from the GATT client.
ACL Asynchronous Connectionless Link. For more information, please refer to B. A. Forouzan, Data Communications and Networking, Fourth Edition. Wireless LANs, Chapter 14, p. 439, McGraw-Hill Professional, 2007.
MTU Maximum Transmission Unit, specifies the maximum size of a packet to send.

How to use this module

GATTS is composed of bt_gatts_service_rec_t.

In this example, a server is created with two services bt_if_gap_service and bt_if_gatt_service.

Typedefs

typedef uint8_t bt_atts_rec_perm_t
 Bt_atts_rec_perm_t is a member of bt_gatts_service_rec_t. More...
 
typedef uint32_t(* bt_gatts_rec_callback_t) (const uint8_t rw, uint16_t handle, void *data, uint16_t size, uint16_t offset)
 This function is the record's callback called by the GATTS to read or write the record's attribute value. More...
 

Functions

const bt_gatts_service_t ** bt_get_gatt_server (void)
 This function is a callback API called by the GATTS to get the application's GATTS database. More...
 
bt_status_t bt_gatts_send_charc_value_notification_indication (bt_handle_t connection_handle, bt_gattc_charc_value_notification_indication_t *req)
 This function sends a characteristic value notification or indication. More...
 
bt_status_t bt_gatts_set_max_mtu (uint16_t max_mtu)
 This function sets the maximum MTU supported by the application. More...
 
bt_status_t bt_gatts_get_authorization_check_result (bt_gatts_authorization_check_req_t *req)
 This user defined API, invoked by the GATTS process, should be implemented by the application. More...
 
bt_status_t bt_gatts_get_execute_write_result (bt_gatts_execute_write_req_t *req)
 This user defined API, invoked by the GATTS process, should be implemented by the application. More...
 

Variables

const bt_uuid_t BT_GATT_UUID_PRIMARY_SERVICE
 UUID for GATT primary service. More...
 
const bt_uuid_t BT_GATT_UUID_SECONDARY_SERVICE
 UUID for GATT secondary primary service. More...
 
const bt_uuid_t BT_GATT_UUID_INCLUDED_SERVICE
 UUID for GATT included service. More...
 
const bt_uuid_t BT_GATT_UUID_CHARC
 UUID for GATT characteristic. More...
 
const bt_uuid_t BT_GATT_UUID_CHARC_EXTENDED_PROPERTIES
 UUID for GATT characteristic extended properties. More...
 
const bt_uuid_t BT_GATT_UUID_CHARC_USER_DESCRIPTION
 UUID for GATT characteristic user description. More...
 
const bt_uuid_t BT_GATT_UUID_CLIENT_CHARC_CONFIG
 UUID for GATT client characteristic configuration. More...
 
const bt_uuid_t BT_GATT_UUID_SERVER_CHARC_CONFIG
 UUID for GATT server characteristic configuration. More...
 
const bt_uuid_t BT_GATT_UUID_CHARC_FORMAT
 UUID for GATT characteristic presentation format. More...
 
const bt_uuid_t BT_GATT_UUID_CHARC_AGGREGATE_FORMAT
 UUID for GATT characteristic aggregate format. More...
 

Modules

 Define
 This section defines the macros for the GATTS.
 
 Struct
 This section defines the basic data structures for the GATTS.
 

Typedef Documentation

typedef uint8_t bt_atts_rec_perm_t

Bt_atts_rec_perm_t is a member of bt_gatts_service_rec_t.

It is used to store the record's read or write security permission.

typedef uint32_t(* bt_gatts_rec_callback_t) (const uint8_t rw, uint16_t handle, void *data, uint16_t size, uint16_t offset)

This function is the record's callback called by the GATTS to read or write the record's attribute value.

If GATTS calls with BT_GATTS_CALLBACK_READ and with the size of 0, it is a request to query the length of the attribute value.

Parameters
[in]rwis BT_GATTS_CALLBACK_READ, BT_GATTS_CALLBACK_WRITE, BT_GATTS_CALLBACK_PREPARE_WRITE, BT_GATTS_CALLBACK_EXECUTE_WRITE_CANCEL or BT_GATTS_CALLBACK_EXECUTE_WRITE_WRITE.
[in]handleis the ACL connection handle.
[in]datais the data buffer.
[in]sizeis the number of bytes in the data buffer.
[in]offsetis the offset of the attribute value. The read or write starts from the start address of attribute value plus the offset.
Returns

Function Documentation

bt_status_t bt_gatts_get_authorization_check_result ( bt_gatts_authorization_check_req_t req)

This user defined API, invoked by the GATTS process, should be implemented by the application.

It is used to ask user whether to give authorization for specified attribute handle.

Parameters
[in]reqis the GATT authorization request to be checked by the application.
Returns
If application accepts peer access to this attribute, the returned value is BT_STATUS_SUCCESS; otherwise the returned value is BT_STATUS_UNSUPPORTED.
bt_status_t bt_gatts_get_execute_write_result ( bt_gatts_execute_write_req_t req)

This user defined API, invoked by the GATTS process, should be implemented by the application.

It is used to execute the write request and check whether the execution is successful.

Parameters
[in]reqis the request to the GATTS to execute the write request.
Returns
If the write request was executed successfully, the returned value is BT_STATUS_SUCCESS; otherwise the returned value is BT_ATT_ERRCODE_XXXX.
bt_status_t bt_gatts_send_charc_value_notification_indication ( bt_handle_t  connection_handle,
bt_gattc_charc_value_notification_indication_t req 
)

This function sends a characteristic value notification or indication.

Parameters
[in]connection_handleis the connection handle.
[in]reqis the GATT characteristic value notification or indication structure.
Returns
BT_STATUS_SUCCESS, the operation completed successfully. BT_STATUS_FAIL, the operation has failed. BT_STATUS_OUT_OF_MEMORY, out of memory. BT_STATUS_CONNECTION_IN_USE, an ongoing request.
bt_status_t bt_gatts_set_max_mtu ( uint16_t  max_mtu)

This function sets the maximum MTU supported by the application.

This value will be used in GATTS MTU exchange response and GATTC MTU exchange request or other BT_STATUS_XXX.

Parameters
[in]max_mtuis the maximum MTU size in the range from 23 to 512 bytes.
Returns
If the value is accepted, the returned value is BT_STATUS_SUCCESS; otherwise the returned value is BT_STATUS_FAIL.
const bt_gatts_service_t** bt_get_gatt_server ( void  )

This function is a callback API called by the GATTS to get the application's GATTS database.

Returns
The application's GATTS database or null, if application does not provide GATTS database.

Variable Documentation

const bt_uuid_t BT_GATT_UUID_CHARC

UUID for GATT characteristic.

const bt_uuid_t BT_GATT_UUID_CHARC_AGGREGATE_FORMAT

UUID for GATT characteristic aggregate format.

const bt_uuid_t BT_GATT_UUID_CHARC_EXTENDED_PROPERTIES

UUID for GATT characteristic extended properties.

const bt_uuid_t BT_GATT_UUID_CHARC_FORMAT

UUID for GATT characteristic presentation format.

const bt_uuid_t BT_GATT_UUID_CHARC_USER_DESCRIPTION

UUID for GATT characteristic user description.

const bt_uuid_t BT_GATT_UUID_CLIENT_CHARC_CONFIG

UUID for GATT client characteristic configuration.

const bt_uuid_t BT_GATT_UUID_INCLUDED_SERVICE

UUID for GATT included service.

const bt_uuid_t BT_GATT_UUID_PRIMARY_SERVICE

UUID for GATT primary service.

const bt_uuid_t BT_GATT_UUID_SECONDARY_SERVICE

UUID for GATT secondary primary service.

const bt_uuid_t BT_GATT_UUID_SERVER_CHARC_CONFIG

UUID for GATT server characteristic configuration.