Immediate Alert Service Client module.
More...
Immediate Alert Service Client module.
This module implements the Immediate Alert Service client - the locator role of the Find Me profile. On BLE_GAP_EVT_CONNECTED event, this module starts discovery of the Immediate Alert Service with Alert Level characteristic at the peer. This module will inform the application about the successful service and characteristic discovery with the BLE_IAS_C_EVT_DISCOVERY_COMPLETE event. The application can use ble_ias_c_send_alert_level function to signal alerts to the peer.
- Note
- The application must register this module as the BLE event observer by using the NRF_SDH_BLE_OBSERVER macro. Example:
#define BLE_IAS_C_ARRAY_DEF |
( |
|
_name, |
|
|
|
_cnt |
|
) |
| |
Macro for defining multiple ble_ias_c instances.
- Parameters
-
_name | Name of the array of instances. |
_cnt | Number of instances to define. |
#define BLE_IAS_C_DEF |
( |
|
_name | ) |
|
Macro for defining a ble_ias_c instance.
- Parameters
-
_name | Name of the instance. |
Immediate Alert Service client event type.
Enumerator |
---|
BLE_IAS_C_EVT_DISCOVERY_COMPLETE |
Event indicating that the Immediate Alert Service is found at the peer.
|
BLE_IAS_C_EVT_DISCOVERY_FAILED |
Event indicating that the Immediate Alert Service is not found at the peer.
|
BLE_IAS_C_EVT_DISCONN_COMPLETE |
Event indicating that the Immediate Alert Service Client module completed the processing of BLE_GAP_EVT_DISCONNECTED event. This event is triggered only if a valid instance of IAS was found at the peer during the discovery phase. The application can use this event to do a cleanup related to the IAS Client.
|
uint32_t ble_ias_c_handles_assign |
( |
ble_ias_c_t * |
p_ias_c, |
|
|
uint16_t |
conn_handle, |
|
|
uint16_t |
alert_level_handle |
|
) |
| |
Function for assigning handles to an instance of ias_c.
Call this function when a link has been established with a peer to associate the link to this instance of the module. This makes it possible to handle several links and associate each link to a particular instance of this module. The connection handle and attribute handles are provided from the discovery event BLE_IAS_C_EVT_DISCOVERY_COMPLETE.
- Parameters
-
[in] | p_ias_c | Pointer to the IAS client structure instance for associating the link. |
[in] | conn_handle | Connection handle to associated with the given IAS instance. |
[in] | alert_level_handle | Attribute handle on the IAS server that you want this IAS_C client to interact with. |
- Return values
-
NRF_SUCCESS | If the operation was successful. |
NRF_ERROR_NULL | If a p_ias_c was a NULL pointer. |
err_code | Otherwise, this API propagates the error code returned by function nrf_ble_gq_conn_handle_register. |
Function for initializing the Immediate Alert Service client.
This call allows the application to initialize the Immediate Alert Service client.
- Parameters
-
[out] | p_ias_c | Immediate Alert Service client structure. This structure must be supplied by the application. It is initialized by this function, and is later used to identify this particular client instance. |
[in] | p_ias_c_init | Information needed to initialize the Immediate Alert Service client. |
- Returns
- NRF_SUCCESS on successful initialization of service.
static __INLINE bool ble_ias_c_is_discovered |
( |
ble_ias_c_t const * |
p_ias_c | ) |
|
|
static |
Function for checking whether the peer's Immediate Alert Service instance and the Alert Level characteristic have been discovered.
- Parameters
-
[in] | p_ias_c | Immediate Alert Service client structure. |
- Returns
- True, if a handle is assigned to alert_level_handle, meaning it must have been discovered.
-
False, if the handle is invalid.
void ble_ias_c_on_ble_evt |
( |
ble_evt_t const * |
p_ble_evt, |
|
|
void * |
p_context |
|
) |
| |
Function for handling the Application's BLE Stack events for Immediate Alert Service client.
Handles all events from the BLE stack of interest to the Immediate Alert Service client.
- Parameters
-
[in] | p_ble_evt | Event received from the BLE stack. |
[in] | p_context | Immediate Alert Service client structure. |
Function for handling events from the Database Discovery module.
Call this function when you get a callback event from the Database Discovery module. This function handles an event from the Database Discovery module, and determines whether it relates to the discovery of Immediate Alert Service at the peer. If it does, the function calls the application's event handler to indicate that the Immediate Alert Service was discovered at the peer. The function also populates the event with service-related information before providing it to the application.
- Parameters
-
[in] | p_ias_c | Pointer to the Immediate Alert client structure instance that will handle the discovery. |
[in] | p_evt | Pointer to the event received from the Database Discovery module. |
uint32_t ble_ias_c_send_alert_level |
( |
ble_ias_c_t const * |
p_ias_c, |
|
|
uint8_t |
alert_level |
|
) |
| |
Function for sending alert level to the peer.
This function allows the application to send an alert to the peer.
- Parameters
-
[in] | p_ias_c | Immediate Alert Service client structure. |
[in] | alert_level | Required alert level to be sent to the peer. |
- Return values
-
NRF_SUCCESS | On success. |
err_code | Otherwise, this API propagates the error code returned by function nrf_ble_gq_item_add. |