nRF5 SDK v17.1.0
Modules | Data Structures | Macros | Typedefs | Enumerations | Functions
GATT Service Client

GATT Service Client module. More...

Modules

 GATT Service Client configuration
 

Data Structures

struct  nrf_ble_gatts_c_evt_t
 Structure containing the event from the Service Changed client module to the application. More...
 
struct  nrf_ble_gatts_c_t
 Structure for holding the information related to the Service Changed indication at the server. More...
 
struct  nrf_ble_gatts_c_init_t
 Initialization parameters. These must be supplied when calling nrf_ble_gatts_c_init. More...
 

Macros

#define NRF_BLE_GATTS_C_DEF(_name)
 Macro for defining a nrf_ble_gatts_c instance. More...
 
#define NRF_BLE_GATTS_C_ARRAY_DEF(_name, _cnt)
 Macro for defining multiple nrf_ble_gatts_c instances. More...
 

Typedefs

typedef void(* nrf_ble_gatts_c_evt_handler_t )(nrf_ble_gatts_c_evt_t *p_evt)
 Service Changed handler type.
 

Enumerations

enum  nrf_ble_gatts_c_evt_type_t {
  NRF_BLE_GATTS_C_EVT_DISCOVERY_COMPLETE,
  NRF_BLE_GATTS_C_EVT_DISCOVERY_FAILED,
  NRF_BLE_GATTS_C_EVT_DISCONN_COMPLETE,
  NRF_BLE_GATTS_C_EVT_SRV_CHANGED
}
 Type of the GATT Service client event. More...
 

Functions

ret_code_t nrf_ble_gatts_c_init (nrf_ble_gatts_c_t *p_gatts_c, nrf_ble_gatts_c_init_t *p_gatts_c_init)
 Function for initializing the Service Changed client module. More...
 
ret_code_t nrf_ble_gatts_c_enable_indication (nrf_ble_gatts_c_t *p_gatts_c, bool enable)
 Function for enabling remote indication. More...
 
void nrf_ble_gatts_c_on_db_disc_evt (nrf_ble_gatts_c_t const *p_gatts_c, ble_db_discovery_evt_t *p_evt)
 Function for handling events from the Database Discovery module. More...
 
void nrf_ble_gatts_c_on_ble_evt (ble_evt_t const *p_ble_evt, void *p_context)
 Function for handling BLE events. More...
 
ret_code_t nrf_ble_gatts_c_handles_assign (nrf_ble_gatts_c_t *p_gatts_c, uint16_t conn_handle, ble_gatt_db_char_t const *p_peer_handles)
 Function for assigning handles to a GATT Service Client instance. More...
 

Detailed Description

GATT Service Client module.

This module implements a client for the Generic Attribute Profile (GATT) Service. It subscribes to indications from the Service Changed characteristic (0x2A05).

Note
The application must register this module as a BLE event observer with the NRF_SDH_BLE_OBSERVER macro. Example:
ble_gatts_t instance;
NRF_SDH_BLE_OBSERVER(anything, BLE_GATTS_BLE_OBSERVER_PRIO,

Macro Definition Documentation

#define NRF_BLE_GATTS_C_ARRAY_DEF (   _name,
  _cnt 
)

Macro for defining multiple nrf_ble_gatts_c instances.

Parameters
_nameName of the array of instances.
_cntNumber of instances to define.
#define NRF_BLE_GATTS_C_DEF (   _name)

Macro for defining a nrf_ble_gatts_c instance.

Parameters
_nameName of the instance.

Enumeration Type Documentation

Type of the GATT Service client event.

Enumerator
NRF_BLE_GATTS_C_EVT_DISCOVERY_COMPLETE 

Event indicating that the GATT Service and Service Changed characteristic have been found on the peer.

NRF_BLE_GATTS_C_EVT_DISCOVERY_FAILED 

Event indicating that the Service Changed characteristic has not been found on the peer.

NRF_BLE_GATTS_C_EVT_DISCONN_COMPLETE 

Event indicating that the GATT Service client module finished processing the BLE_GAP_EVT_DISCONNECTED event. The application can use this event to do a cleanup related to the GATT Service client.

NRF_BLE_GATTS_C_EVT_SRV_CHANGED 

Event indicating that a Service Changed indication has been received.

Function Documentation

ret_code_t nrf_ble_gatts_c_enable_indication ( nrf_ble_gatts_c_t p_gatts_c,
bool  enable 
)

Function for enabling remote indication.

Parameters
[in,out]p_gatts_cPointer to the Service Changed Client structure.
[in]enableTrue to enable Service Changed remote indication; false to disable.
Return values
NRF_SUCCESSOperation success.
err_codeOtherwise, this API propagates the error code returned by function nrf_ble_gq_item_add.
ret_code_t nrf_ble_gatts_c_handles_assign ( nrf_ble_gatts_c_t p_gatts_c,
uint16_t  conn_handle,
ble_gatt_db_char_t const *  p_peer_handles 
)

Function for assigning handles to a GATT Service Client instance.

Call this function when a link has been established with a peer to associate the link to an instance of the module. This makes it possible to handle several links and associate each link with a particular instance of the GATT Service Client module. The connection handle and attribute handles will be provided from the discovery event NRF_BLE_GATTS_C_EVT_DISCOVERY_COMPLETE.

Parameters
[in,out]p_gatts_cPointer to the GATT Service Client structure instance for associating the link.
[in]conn_handleConnection handle to be associated with the given GATT Service Client instance.
[in]p_peer_handlesAttribute handles on the GATT Service server that you want this GATT Service Client to interact with.
Return values
NRF_SUCCESSIf the connection handle was successfully stored in the GATT Service instance.
NRF_ERROR_NULLIf any of the input parameters are NULL.
err_codeOtherwise, this API propagates the error code returned by function nrf_ble_gq_item_add.
ret_code_t nrf_ble_gatts_c_init ( nrf_ble_gatts_c_t p_gatts_c,
nrf_ble_gatts_c_init_t p_gatts_c_init 
)

Function for initializing the Service Changed client module.

Parameters
[in,out]p_gatts_cPointer to the GATT Service Client structure instance.
[in]p_gatts_c_initInit parameters containing the event handler that is called by the Service Changed Client module when any related event occurs.
Return values
NRF_SUCCESSIf the service was initialized successfully.
NRF_ERROR_NULLIf any of the input parameters are NULL.
err_codeIf functions from other modules return errors to this function, the SoftDevice Global Error Codes are propagated.
void nrf_ble_gatts_c_on_ble_evt ( ble_evt_t const *  p_ble_evt,
void *  p_context 
)

Function for handling BLE events.

Parameters
[in]p_ble_evtEvent received from the BLE stack.
[in]p_contextContext.
void nrf_ble_gatts_c_on_db_disc_evt ( nrf_ble_gatts_c_t const *  p_gatts_c,
ble_db_discovery_evt_t p_evt 
)

Function for handling events from the Database Discovery module.

This function handles an event from the Database Discovery module, and determines whether it relates to the discovery of Service Changed characteristics at the peer. If it does, the function calls the application's event handler to indicate that the Service Changed characteristic has been discovered at the peer.

Parameters
[in,out]p_gatts_cPointer to the GATT Service Client structure instance.
[in]p_evtPointer to the event received from the Database Discovery module.

Documentation feedback | Developer Zone | Subscribe | Updated