Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of BLE_WallbotBLE_Challenge by
ble_ias_c.h
00001 /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 00002 * 00003 * The information contained herein is property of Nordic Semiconductor ASA. 00004 * Terms and conditions of usage are described in detail in NORDIC 00005 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 00006 * 00007 * Licensees are granted free, non-transferable use of the information. NO 00008 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 00009 * the file. 00010 * 00011 */ 00012 00013 /** @file 00014 * 00015 * @defgroup ble_sdk_srv_ias_c Immediate Alert Service Client 00016 * @{ 00017 * @ingroup ble_sdk_srv 00018 * @brief Immediate Alert Service Client module 00019 * 00020 * @details This module implements the Immediate Alert Service client - locator role of the Find Me 00021 * profile. On @ref BLE_GAP_EVT_CONNECTED event, this module starts discovery of the 00022 * Immediate Alert Service with Alert Level characteristic at the peer. This module will 00023 * indicate the application about a successful service & characteristic discovery using 00024 * @ref BLE_IAS_C_EVT_CHAR_DISCOVERED event. The application can use @ref 00025 * ble_ias_c_send_alert_level function to signal alerts to the peer. 00026 * 00027 * @note The application must propagate BLE stack events to this module by calling 00028 * ble_ias_c_on_ble_evt() from the from the @ref ble_stack_handler callback function. 00029 */ 00030 00031 #ifndef BLE_IAS_C_H__ 00032 #define BLE_IAS_C_H__ 00033 00034 #include "ble_srv_common.h " 00035 #include "ble_gattc.h" 00036 #include "ble.h" 00037 #include <stdint.h> 00038 00039 // Forward declaration of the ble_ias_c_t type. 00040 typedef struct ble_ias_c_s ble_ias_c_t; 00041 00042 /**@brief Immediate Alert Service client event type. */ 00043 typedef enum 00044 { 00045 BLE_IAS_C_EVT_SRV_DISCOVERED, /**< Event indicating that the Immediate Alert Service is found at the peer. */ 00046 BLE_IAS_C_EVT_SRV_NOT_FOUND, /**< Event indicating that the Immediate Alert Service is not found at the peer. */ 00047 BLE_IAS_C_EVT_DISCONN_COMPLETE /**< Event indicating that the Immediate Alert Service client module has completed the processing of BLE_GAP_EVT_DISCONNECTED event. This event is raised only if a valid instance of IAS was found at the peer during the discovery phase. This event can be used the application to do clean up related to the IAS Client.*/ 00048 } ble_ias_c_evt_type_t; 00049 00050 /**@brief Immediate Alert Service client event. */ 00051 typedef struct 00052 { 00053 ble_ias_c_evt_type_t evt_type; /**< Type of event. */ 00054 } ble_ias_c_evt_t; 00055 00056 /**@brief Immediate Alert Service client event handler type. */ 00057 typedef void (*ble_ias_c_evt_handler_t) (ble_ias_c_t * p_ias_c, ble_ias_c_evt_t * p_evt); 00058 00059 /**@brief IAS Client structure. This contains various status information for the client. */ 00060 typedef struct ble_ias_c_s 00061 { 00062 ble_ias_c_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Immediate Alert Service client. */ 00063 ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ 00064 uint16_t alert_level_handle; /**< Handle of Alert Level characteristic at peer (as provided by the BLE stack). */ 00065 uint16_t conn_handle; /**< Handle of the current connection (as provided by the BLE stack, is BLE_CONN_HANDLE_INVALID if not in a connection). */ 00066 } ble_ias_c_t; 00067 00068 /**@brief IAS Client init structure. This contains all options and data needed for initialization of 00069 * the client.*/ 00070 typedef struct 00071 { 00072 ble_ias_c_evt_handler_t evt_handler; /**< Event handler to be called for handling events from the Immediate Alert Service client. */ 00073 ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ 00074 } ble_ias_c_init_t; 00075 00076 /**@brief Function for initializing the Immediate Alert Service client. 00077 * 00078 * @details This call allows the application to initialize the Immediate Alert Service client. 00079 * 00080 * @param[out] p_ias_c Immediate Alert Service client structure. This structure will have to 00081 * be supplied by the application. It will be initialized by this 00082 * function, and will later be used to identify this particular client 00083 * instance. 00084 * @param[in] p_ias_c_init Information needed to initialize the Immediate Alert Service client. 00085 * 00086 * @return NRF_SUCCESS on successful initialization of service. 00087 */ 00088 uint32_t ble_ias_c_init(ble_ias_c_t * p_ias_c, const ble_ias_c_init_t * p_ias_c_init); 00089 00090 /**@brief Function for sending alert level to the peer. 00091 * 00092 * @details This function allows the application to send an alert to the peer. 00093 * 00094 * @param[in] p_ias_c Immediate Alert Service client structure. 00095 * @param[in] alert_level Required alert level to be sent to the peer. 00096 * 00097 * @return NRF_SUCCESS on success, otherwise an error code. 00098 */ 00099 uint32_t ble_ias_c_send_alert_level(const ble_ias_c_t * p_ias_c, uint8_t alert_level); 00100 00101 /**@brief Function for handling the Application's BLE Stack events for Immediate Alert Service client. 00102 * 00103 * @details Handles all events from the BLE stack of interest to the Immediate Alert Service client. 00104 * 00105 * @param[in] p_ias_c Immediate Alert Service client structure. 00106 * @param[in] p_ble_evt Event received from the BLE stack. 00107 */ 00108 void ble_ias_c_on_ble_evt(ble_ias_c_t * p_ias_c, const ble_evt_t * p_ble_evt); 00109 00110 /**@brief Function for checking whether the peer's Immediate Alert Service instance and the alert level 00111 * characteristic have been discovered. 00112 * @param[in] p_ias_c Immediate Alert Service client structure. 00113 */ 00114 static __INLINE bool ble_ias_c_is_ias_discovered(const ble_ias_c_t * p_ias_c) 00115 { 00116 return (p_ias_c->alert_level_handle != BLE_GATT_HANDLE_INVALID); 00117 } 00118 00119 #endif
Generated on Tue Jul 12 2022 13:52:30 by
