GATT Service Client module.
More...
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:
#define NRF_BLE_GATTS_C_ARRAY_DEF |
( |
|
_name, |
|
|
|
_cnt |
|
) |
| |
Macro for defining multiple nrf_ble_gatts_c instances.
- Parameters
-
_name | Name of the array of instances. |
_cnt | Number of instances to define. |
#define NRF_BLE_GATTS_C_DEF |
( |
|
_name | ) |
|
Macro for defining a nrf_ble_gatts_c instance.
- Parameters
-
_name | Name of the instance. |
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 for enabling remote indication.
- Parameters
-
[in,out] | p_gatts_c | Pointer to the Service Changed Client structure. |
[in] | enable | True to enable Service Changed remote indication; false to disable. |
- Return values
-
NRF_SUCCESS | Operation success. |
err_code | Otherwise, this API propagates the error code returned by function nrf_ble_gq_item_add. |
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_c | Pointer to the GATT Service Client structure instance for associating the link. |
[in] | conn_handle | Connection handle to be associated with the given GATT Service Client instance. |
[in] | p_peer_handles | Attribute handles on the GATT Service server that you want this GATT Service Client to interact with. |
- Return values
-
NRF_SUCCESS | If the connection handle was successfully stored in the GATT Service instance. |
NRF_ERROR_NULL | If any of the input parameters are NULL. |
err_code | Otherwise, this API propagates the error code returned by function nrf_ble_gq_item_add. |
Function for initializing the Service Changed client module.
- Parameters
-
[in,out] | p_gatts_c | Pointer to the GATT Service Client structure instance. |
[in] | p_gatts_c_init | Init parameters containing the event handler that is called by the Service Changed Client module when any related event occurs. |
- Return values
-
NRF_SUCCESS | If the service was initialized successfully. |
NRF_ERROR_NULL | If any of the input parameters are NULL. |
err_code | If 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_evt | Event received from the BLE stack. |
[in] | p_context | Context. |
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_c | Pointer to the GATT Service Client structure instance. |
[in] | p_evt | Pointer to the event received from the Database Discovery module. |