GATT module

nRF5 SDK v12.2.0

Module for negotiating and keeping track of the maximum ATT_MTU size. More...

Data Structures

struct nrf_ble_gatt_evt_t
GATT module event. More...
struct nrf_ble_gatt_link_t
GATT information for each link. More...
struct nrf_ble_gatt_s
GATT structure that contains status information for the GATT module. More...

Macros

#define NRF_BLE_GATT_MAX_MTU_SIZE GATT_MTU_SIZE_DEFAULT
Default maximum ATT_MTU size. More...
#define NRF_BLE_CENTRAL_LINK_COUNT 1
Default maximum number of peripheral links. More...
#define NRF_BLE_PERIPHERAL_LINK_COUNT 1
Default maximum number of central links. More...
#define NRF_BLE_GATT_LINK_COUNT ( NRF_BLE_PERIPHERAL_LINK_COUNT + NRF_BLE_CENTRAL_LINK_COUNT )
The maximum number of peripheral and central links combined.

Typedefs

typedef struct nrf_ble_gatt_s nrf_ble_gatt_t
typedef void(* nrf_ble_gatt_evt_handler_t )( nrf_ble_gatt_t *p_gatt, nrf_ble_gatt_evt_t *p_evt)
GATT module event handler type. More...

Functions

ret_code_t nrf_ble_gatt_init ( nrf_ble_gatt_t *p_gatt, nrf_ble_gatt_evt_handler_t evt_handler)
Function for initializing the GATT module. More...
ret_code_t nrf_ble_gatt_att_mtu_periph_set ( nrf_ble_gatt_t *p_gatt, uint16_t desired_mtu)
Function for setting the ATT_MTU size for the next link that is established as peripheral. More...
ret_code_t nrf_ble_gatt_att_mtu_central_set ( nrf_ble_gatt_t *p_gatt, uint16_t desired_mtu)
Function for setting the ATT_MTU size for the next link that is established as central. More...
void nrf_ble_gatt_on_ble_evt ( nrf_ble_gatt_t *p_gatt, ble_evt_t *p_ble_evt)
Function for handling BLE stack events. More...
uint16_t nrf_ble_gatt_eff_mtu_get ( nrf_ble_gatt_t *p_gatt, uint16_t conn_handle)
Function for getting the current ATT_MTU size for a connection handle. More...

Detailed Description

Module for negotiating and keeping track of the maximum ATT_MTU size.

Macro Definition Documentation

#define NRF_BLE_CENTRAL_LINK_COUNT   1

Default maximum number of peripheral links.

To override this default value, define the maximum number of peripheral links in your module.

#define NRF_BLE_GATT_MAX_MTU_SIZE GATT_MTU_SIZE_DEFAULT

Default maximum ATT_MTU size.

This define specifies a fallback value for the case where NRF_BLE_GATT_MAX_MTU_SIZE is not set in the GATT module configuration .

#define NRF_BLE_PERIPHERAL_LINK_COUNT   1

Default maximum number of central links.

To override this default value, define the maximum number of central links in your module.

Typedef Documentation

typedef void(* nrf_ble_gatt_evt_handler_t)( nrf_ble_gatt_t *p_gatt, nrf_ble_gatt_evt_t *p_evt)

GATT module event handler type.

The GATT module calls a function of this type when the ATT_MTU value is changed.

Function Documentation

ret_code_t nrf_ble_gatt_att_mtu_central_set ( nrf_ble_gatt_t * p_gatt ,
uint16_t desired_mtu
)

Function for setting the ATT_MTU size for the next link that is established as central.

Parameters
[in] p_gatt Pointer to the GATT structure.
[in] desired_mtu Requested ATT_MTU size.
Return values
NRF_SUCCESS If the operation was successful.
NRF_ERROR_NULL If the pointer to p_gatt is NULL.
NRF_ERROR_INVALID_PARAM If the size of desired_mtu is bigger than NRF_BLE_GATT_MAX_MTU_SIZE or smaller than GATT_MTU_SIZE_DEFAULT .
ret_code_t nrf_ble_gatt_att_mtu_periph_set ( nrf_ble_gatt_t * p_gatt ,
uint16_t desired_mtu
)

Function for setting the ATT_MTU size for the next link that is established as peripheral.

Parameters
[in] p_gatt Pointer to the GATT structure.
[in] desired_mtu Requested ATT_MTU size.
Return values
NRF_SUCCESS If the operation was successful.
NRF_ERROR_NULL If the pointer to p_gatt is NULL.
NRF_ERROR_INVALID_PARAM If the size of desired_mtu is bigger than NRF_BLE_GATT_MAX_MTU_SIZE or smaller than GATT_MTU_SIZE_DEFAULT .
uint16_t nrf_ble_gatt_eff_mtu_get ( nrf_ble_gatt_t * p_gatt ,
uint16_t conn_handle
)

Function for getting the current ATT_MTU size for a connection handle.

Parameters
[in] p_gatt Pointer to the GATT structure.
[in] conn_handle Connection handle of the link.
Returns
ATT_MTU size for the given link.
Return values
0 If the pointer to p_gatt is NULL or if conn_handle is larger than the supported maximum number of connections.
ret_code_t nrf_ble_gatt_init ( nrf_ble_gatt_t * p_gatt ,
nrf_ble_gatt_evt_handler_t evt_handler
)

Function for initializing the GATT module.

Parameters
[in] evt_handler Event handler.
[out] p_gatt Pointer to the GATT structure.
Return values
NRF_SUCCESS If the operation was successful.
NRF_ERROR_NULL If the pointer to p_gatt is NULL.
void nrf_ble_gatt_on_ble_evt ( nrf_ble_gatt_t * p_gatt ,
ble_evt_t * p_ble_evt
)

Function for handling BLE stack events.

This function handles all events from the BLE stack that are of interest to the GATT module.

Parameters
[in] p_gatt Pointer to the GATT structure.
[in] p_ble_evt Event received from the BLE stack.