nochanges

Dependents:   BLE_Acceleration_Statejudging

Fork of nRF51822 by Nordic Semiconductor

Committer:
Rohit Grover
Date:
Mon Jul 07 13:43:31 2014 +0100
Revision:
37:c29c330d942c
changes required to upgrade to V7 of the soft-device

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Rohit Grover 37:c29c330d942c 1 /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
Rohit Grover 37:c29c330d942c 2 *
Rohit Grover 37:c29c330d942c 3 * The information contained herein is property of Nordic Semiconductor ASA.
Rohit Grover 37:c29c330d942c 4 * Terms and conditions of usage are described in detail in NORDIC
Rohit Grover 37:c29c330d942c 5 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
Rohit Grover 37:c29c330d942c 6 *
Rohit Grover 37:c29c330d942c 7 * Licensees are granted free, non-transferable use of the information. NO
Rohit Grover 37:c29c330d942c 8 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
Rohit Grover 37:c29c330d942c 9 * the file.
Rohit Grover 37:c29c330d942c 10 *
Rohit Grover 37:c29c330d942c 11 */
Rohit Grover 37:c29c330d942c 12
Rohit Grover 37:c29c330d942c 13 /** @file
Rohit Grover 37:c29c330d942c 14 *
Rohit Grover 37:c29c330d942c 15 * @defgroup ble_sdk_srv_ias_c Immediate Alert Service Client
Rohit Grover 37:c29c330d942c 16 * @{
Rohit Grover 37:c29c330d942c 17 * @ingroup ble_sdk_srv
Rohit Grover 37:c29c330d942c 18 * @brief Immediate Alert Service Client module
Rohit Grover 37:c29c330d942c 19 *
Rohit Grover 37:c29c330d942c 20 * @details This module implements the Immediate Alert Service client - locator role of the Find Me
Rohit Grover 37:c29c330d942c 21 * profile. On @ref BLE_GAP_EVT_CONNECTED event, this module starts discovery of the
Rohit Grover 37:c29c330d942c 22 * Immediate Alert Service with Alert Level characteristic at the peer. This module will
Rohit Grover 37:c29c330d942c 23 * indicate the application about a successful service & characteristic discovery using
Rohit Grover 37:c29c330d942c 24 * @ref BLE_IAS_C_EVT_CHAR_DISCOVERED event. The application can use @ref
Rohit Grover 37:c29c330d942c 25 * ble_ias_c_send_alert_level function to signal alerts to the peer.
Rohit Grover 37:c29c330d942c 26 *
Rohit Grover 37:c29c330d942c 27 * @note The application must propagate BLE stack events to this module by calling
Rohit Grover 37:c29c330d942c 28 * ble_ias_c_on_ble_evt() from the from the @ref ble_stack_handler callback function.
Rohit Grover 37:c29c330d942c 29 */
Rohit Grover 37:c29c330d942c 30
Rohit Grover 37:c29c330d942c 31 #ifndef BLE_IAS_C_H__
Rohit Grover 37:c29c330d942c 32 #define BLE_IAS_C_H__
Rohit Grover 37:c29c330d942c 33
Rohit Grover 37:c29c330d942c 34 #include "ble_srv_common.h"
Rohit Grover 37:c29c330d942c 35 #include "ble_gattc.h"
Rohit Grover 37:c29c330d942c 36 #include "ble.h"
Rohit Grover 37:c29c330d942c 37 #include <stdint.h>
Rohit Grover 37:c29c330d942c 38
Rohit Grover 37:c29c330d942c 39 // Forward declaration of the ble_ias_c_t type.
Rohit Grover 37:c29c330d942c 40 typedef struct ble_ias_c_s ble_ias_c_t;
Rohit Grover 37:c29c330d942c 41
Rohit Grover 37:c29c330d942c 42 /**@brief Immediate Alert Service client event type. */
Rohit Grover 37:c29c330d942c 43 typedef enum
Rohit Grover 37:c29c330d942c 44 {
Rohit Grover 37:c29c330d942c 45 BLE_IAS_C_EVT_SRV_DISCOVERED, /**< Event indicating that the Immediate Alert Service is found at the peer. */
Rohit Grover 37:c29c330d942c 46 BLE_IAS_C_EVT_SRV_NOT_FOUND, /**< Event indicating that the Immediate Alert Service is not found at the peer. */
Rohit Grover 37:c29c330d942c 47 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.*/
Rohit Grover 37:c29c330d942c 48 } ble_ias_c_evt_type_t;
Rohit Grover 37:c29c330d942c 49
Rohit Grover 37:c29c330d942c 50 /**@brief Immediate Alert Service client event. */
Rohit Grover 37:c29c330d942c 51 typedef struct
Rohit Grover 37:c29c330d942c 52 {
Rohit Grover 37:c29c330d942c 53 ble_ias_c_evt_type_t evt_type; /**< Type of event. */
Rohit Grover 37:c29c330d942c 54 } ble_ias_c_evt_t;
Rohit Grover 37:c29c330d942c 55
Rohit Grover 37:c29c330d942c 56 /**@brief Immediate Alert Service client event handler type. */
Rohit Grover 37:c29c330d942c 57 typedef void (*ble_ias_c_evt_handler_t) (ble_ias_c_t * p_ias_c, ble_ias_c_evt_t * p_evt);
Rohit Grover 37:c29c330d942c 58
Rohit Grover 37:c29c330d942c 59 /**@brief IAS Client structure. This contains various status information for the client. */
Rohit Grover 37:c29c330d942c 60 typedef struct ble_ias_c_s
Rohit Grover 37:c29c330d942c 61 {
Rohit Grover 37:c29c330d942c 62 ble_ias_c_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Immediate Alert Service client. */
Rohit Grover 37:c29c330d942c 63 ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */
Rohit Grover 37:c29c330d942c 64 uint16_t alert_level_handle; /**< Handle of Alert Level characteristic at peer (as provided by the BLE stack). */
Rohit Grover 37:c29c330d942c 65 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). */
Rohit Grover 37:c29c330d942c 66 } ble_ias_c_t;
Rohit Grover 37:c29c330d942c 67
Rohit Grover 37:c29c330d942c 68 /**@brief IAS Client init structure. This contains all options and data needed for initialization of
Rohit Grover 37:c29c330d942c 69 * the client.*/
Rohit Grover 37:c29c330d942c 70 typedef struct
Rohit Grover 37:c29c330d942c 71 {
Rohit Grover 37:c29c330d942c 72 ble_ias_c_evt_handler_t evt_handler; /**< Event handler to be called for handling events from the Immediate Alert Service client. */
Rohit Grover 37:c29c330d942c 73 ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */
Rohit Grover 37:c29c330d942c 74 } ble_ias_c_init_t;
Rohit Grover 37:c29c330d942c 75
Rohit Grover 37:c29c330d942c 76 /**@brief Function for initializing the Immediate Alert Service client.
Rohit Grover 37:c29c330d942c 77 *
Rohit Grover 37:c29c330d942c 78 * @details This call allows the application to initialize the Immediate Alert Service client.
Rohit Grover 37:c29c330d942c 79 *
Rohit Grover 37:c29c330d942c 80 * @param[out] p_ias_c Immediate Alert Service client structure. This structure will have to
Rohit Grover 37:c29c330d942c 81 * be supplied by the application. It will be initialized by this
Rohit Grover 37:c29c330d942c 82 * function, and will later be used to identify this particular client
Rohit Grover 37:c29c330d942c 83 * instance.
Rohit Grover 37:c29c330d942c 84 * @param[in] p_ias_c_init Information needed to initialize the Immediate Alert Service client.
Rohit Grover 37:c29c330d942c 85 *
Rohit Grover 37:c29c330d942c 86 * @return NRF_SUCCESS on successful initialization of service.
Rohit Grover 37:c29c330d942c 87 */
Rohit Grover 37:c29c330d942c 88 uint32_t ble_ias_c_init(ble_ias_c_t * p_ias_c, const ble_ias_c_init_t * p_ias_c_init);
Rohit Grover 37:c29c330d942c 89
Rohit Grover 37:c29c330d942c 90 /**@brief Function for sending alert level to the peer.
Rohit Grover 37:c29c330d942c 91 *
Rohit Grover 37:c29c330d942c 92 * @details This function allows the application to send an alert to the peer.
Rohit Grover 37:c29c330d942c 93 *
Rohit Grover 37:c29c330d942c 94 * @param[in] p_ias_c Immediate Alert Service client structure.
Rohit Grover 37:c29c330d942c 95 * @param[in] alert_level Required alert level to be sent to the peer.
Rohit Grover 37:c29c330d942c 96 *
Rohit Grover 37:c29c330d942c 97 * @return NRF_SUCCESS on success, otherwise an error code.
Rohit Grover 37:c29c330d942c 98 */
Rohit Grover 37:c29c330d942c 99 uint32_t ble_ias_c_send_alert_level(const ble_ias_c_t * p_ias_c, uint8_t alert_level);
Rohit Grover 37:c29c330d942c 100
Rohit Grover 37:c29c330d942c 101 /**@brief Function for handling the Application's BLE Stack events for Immediate Alert Service client.
Rohit Grover 37:c29c330d942c 102 *
Rohit Grover 37:c29c330d942c 103 * @details Handles all events from the BLE stack of interest to the Immediate Alert Service client.
Rohit Grover 37:c29c330d942c 104 *
Rohit Grover 37:c29c330d942c 105 * @param[in] p_ias_c Immediate Alert Service client structure.
Rohit Grover 37:c29c330d942c 106 * @param[in] p_ble_evt Event received from the BLE stack.
Rohit Grover 37:c29c330d942c 107 */
Rohit Grover 37:c29c330d942c 108 void ble_ias_c_on_ble_evt(ble_ias_c_t * p_ias_c, const ble_evt_t * p_ble_evt);
Rohit Grover 37:c29c330d942c 109
Rohit Grover 37:c29c330d942c 110 /**@brief Function for checking whether the peer's Immediate Alert Service instance and the alert level
Rohit Grover 37:c29c330d942c 111 * characteristic have been discovered.
Rohit Grover 37:c29c330d942c 112 * @param[in] p_ias_c Immediate Alert Service client structure.
Rohit Grover 37:c29c330d942c 113 */
Rohit Grover 37:c29c330d942c 114 static __INLINE bool ble_ias_c_is_ias_discovered(const ble_ias_c_t * p_ias_c)
Rohit Grover 37:c29c330d942c 115 {
Rohit Grover 37:c29c330d942c 116 return (p_ias_c->alert_level_handle != BLE_GATT_HANDLE_INVALID);
Rohit Grover 37:c29c330d942c 117 }
Rohit Grover 37:c29c330d942c 118
Rohit Grover 37:c29c330d942c 119 #endif