nochanges

Dependents:   BLE_Acceleration_Statejudging

Fork of nRF51822 by Nordic Semiconductor

Committer:
MonroeLee
Date:
Thu Jun 09 05:15:47 2016 +0000
Revision:
638:6efcf74f000d
Parent:
37:c29c330d942c
no changes

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 /** @file
Rohit Grover 37:c29c330d942c 13 *
Rohit Grover 37:c29c330d942c 14 * @defgroup ble_sdk_srv_ans_c Alert Notification Service Client
Rohit Grover 37:c29c330d942c 15 * @{
Rohit Grover 37:c29c330d942c 16 * @ingroup ble_sdk_srv
Rohit Grover 37:c29c330d942c 17 * @brief Alert Notification module.
Rohit Grover 37:c29c330d942c 18 *
Rohit Grover 37:c29c330d942c 19 * @details This module implements the Alert Notification Client according to the
Rohit Grover 37:c29c330d942c 20 * Alert Notification Profile.
Rohit Grover 37:c29c330d942c 21 *
Rohit Grover 37:c29c330d942c 22 * @note The application must propagate BLE stack events to the Alert Notification Client module
Rohit Grover 37:c29c330d942c 23 * by calling ble_ans_c_on_ble_evt() from the from the @ref ble_stack_handler callback.
Rohit Grover 37:c29c330d942c 24 *
Rohit Grover 37:c29c330d942c 25 * @note Attention!
Rohit Grover 37:c29c330d942c 26 * To maintain compliance with Nordic Semiconductor ASA Bluetooth profile
Rohit Grover 37:c29c330d942c 27 * qualification listings, this section of source code must not be modified.
Rohit Grover 37:c29c330d942c 28 */
Rohit Grover 37:c29c330d942c 29 #ifndef BLE_ANS_C_H__
Rohit Grover 37:c29c330d942c 30 #define BLE_ANS_C_H__
Rohit Grover 37:c29c330d942c 31
Rohit Grover 37:c29c330d942c 32 #include "ble.h"
Rohit Grover 37:c29c330d942c 33 #include "ble_gatts.h"
Rohit Grover 37:c29c330d942c 34 #include "ble_types.h"
Rohit Grover 37:c29c330d942c 35 #include "ble_srv_common.h"
Rohit Grover 37:c29c330d942c 36 #include "device_manager.h"
Rohit Grover 37:c29c330d942c 37
Rohit Grover 37:c29c330d942c 38 #define ANS_NB_OF_CHARACTERISTICS 5 /**< Number of characteristics as defined by Alert Notification Service specification. */
Rohit Grover 37:c29c330d942c 39 #define ANS_NB_OF_SERVICES 1 /**< Number of services supported in one central. */
Rohit Grover 37:c29c330d942c 40 #define INVALID_SERVICE_HANDLE_BASE 0xF0 /**< Base for indicating invalid service handle. */
Rohit Grover 37:c29c330d942c 41 #define INVALID_SERVICE_HANDLE (INVALID_SERVICE_HANDLE_BASE + 0x0F) /**< Indication that the current service handle is invalid. */
Rohit Grover 37:c29c330d942c 42 #define INVALID_SERVICE_HANDLE_DISC (INVALID_SERVICE_HANDLE_BASE + 0x0E) /**< Indication that the current service handle is invalid but the service has been discovered. */
Rohit Grover 37:c29c330d942c 43 #define BLE_ANS_INVALID_HANDLE 0xFF /**< Indication that the current service handle is invalid. */
Rohit Grover 37:c29c330d942c 44
Rohit Grover 37:c29c330d942c 45 // Forward declaration of the ble_ans_c_t type.
Rohit Grover 37:c29c330d942c 46 typedef struct ble_ans_c_s ble_ans_c_t;
Rohit Grover 37:c29c330d942c 47
Rohit Grover 37:c29c330d942c 48 /** Alerts types as defined in the alert category id; UUID: 0x2A43. */
Rohit Grover 37:c29c330d942c 49 typedef enum
Rohit Grover 37:c29c330d942c 50 {
Rohit Grover 37:c29c330d942c 51 ANS_TYPE_SIMPLE_ALERT = 0, /**< General text alert or non-text alert.*/
Rohit Grover 37:c29c330d942c 52 ANS_TYPE_EMAIL = 1, /**< Alert when email messages arrives.*/
Rohit Grover 37:c29c330d942c 53 ANS_TYPE_NEWS = 2, /**< News feeds such as RSS, Atom.*/
Rohit Grover 37:c29c330d942c 54 ANS_TYPE_NOTIFICATION_CALL = 3, /**< Incoming call.*/
Rohit Grover 37:c29c330d942c 55 ANS_TYPE_MISSED_CALL = 4, /**< Missed call.*/
Rohit Grover 37:c29c330d942c 56 ANS_TYPE_SMS_MMS = 5, /**< SMS/MMS message arrives.*/
Rohit Grover 37:c29c330d942c 57 ANS_TYPE_VOICE_MAIL = 6, /**< Voice mail.*/
Rohit Grover 37:c29c330d942c 58 ANS_TYPE_SCHEDULE = 7, /**< Alert occurred on calendar, planner.*/
Rohit Grover 37:c29c330d942c 59 ANS_TYPE_HIGH_PRIORITIZED_ALERT = 8, /**< Alert that should be handled as high priority.*/
Rohit Grover 37:c29c330d942c 60 ANS_TYPE_INSTANT_MESSAGE = 9, /**< Alert for incoming instant messages.*/
Rohit Grover 37:c29c330d942c 61 ANS_TYPE_ALL_ALERTS = 0xFF /**< Identifies All Alerts. */
Rohit Grover 37:c29c330d942c 62 } ble_ans_category_id_t;
Rohit Grover 37:c29c330d942c 63
Rohit Grover 37:c29c330d942c 64 /** Alerts notification control point commands as defined in the Alert Notification Specification;
Rohit Grover 37:c29c330d942c 65 * UUID: 0x2A44.
Rohit Grover 37:c29c330d942c 66 */
Rohit Grover 37:c29c330d942c 67 typedef enum
Rohit Grover 37:c29c330d942c 68 {
Rohit Grover 37:c29c330d942c 69 ANS_ENABLE_NEW_INCOMING_ALERT_NOTIFICATION = 0, /**< Enable New Incoming Alert Notification.*/
Rohit Grover 37:c29c330d942c 70 ANS_ENABLE_UNREAD_CATEGORY_STATUS_NOTIFICATION = 1, /**< Enable Unread Category Status Notification.*/
Rohit Grover 37:c29c330d942c 71 ANS_DISABLE_NEW_INCOMING_ALERT_NOTIFICATION = 2, /**< Disable New Incoming Alert Notification.*/
Rohit Grover 37:c29c330d942c 72 ANS_DISABLE_UNREAD_CATEGORY_STATUS_NOTIFICATION = 3, /**< Disable Unread Category Status Notification.*/
Rohit Grover 37:c29c330d942c 73 ANS_NOTIFY_NEW_INCOMING_ALERT_IMMEDIATELY = 4, /**< Notify New Incoming Alert immediately.*/
Rohit Grover 37:c29c330d942c 74 ANS_NOTIFY_UNREAD_CATEGORY_STATUS_IMMEDIATELY = 5, /**< Notify Unread Category Status immediately.*/
Rohit Grover 37:c29c330d942c 75 } ble_ans_command_id_t;
Rohit Grover 37:c29c330d942c 76
Rohit Grover 37:c29c330d942c 77 /**@brief Alert Notification Event types that are passed from client to application on an event. */
Rohit Grover 37:c29c330d942c 78 typedef enum
Rohit Grover 37:c29c330d942c 79 {
Rohit Grover 37:c29c330d942c 80 BLE_ANS_C_EVT_DISCOVER_COMPLETE, /**< A successful connection has been established and the characteristics of the server has been fetched. */
Rohit Grover 37:c29c330d942c 81 BLE_ANS_C_EVT_DISCOVER_FAILED, /**< It was not possible to discover service or characteristics of the connected peer. */
Rohit Grover 37:c29c330d942c 82 BLE_ANS_C_EVT_RECONNECT, /**< A re-connection to a known and previously discovered central has occurred. */
Rohit Grover 37:c29c330d942c 83 BLE_ANS_C_EVT_DISCONN_COMPLETE, /**< The connection has been taken down. */
Rohit Grover 37:c29c330d942c 84 BLE_ANS_C_EVT_NOTIFICATION, /**< A valid Alert Notification has been received from the server.*/
Rohit Grover 37:c29c330d942c 85 BLE_ANS_C_EVT_READ_RESP, /**< A read response has been received from the server.*/
Rohit Grover 37:c29c330d942c 86 BLE_ANS_C_EVT_WRITE_RESP /**< A write response has been received from the server.*/
Rohit Grover 37:c29c330d942c 87 } ble_ans_c_evt_type_t;
Rohit Grover 37:c29c330d942c 88
Rohit Grover 37:c29c330d942c 89 /**@brief Alert Notification Control Point structure. */
Rohit Grover 37:c29c330d942c 90 typedef struct
Rohit Grover 37:c29c330d942c 91 {
Rohit Grover 37:c29c330d942c 92 ble_ans_command_id_t command; /**< The command to be written to the control point, see @ref ble_ans_command_id_t. */
Rohit Grover 37:c29c330d942c 93 ble_ans_category_id_t category; /**< The category for the control point for which the command applies, see @ref ble_ans_category_id_t. */
Rohit Grover 37:c29c330d942c 94 } ble_ans_control_point_t;
Rohit Grover 37:c29c330d942c 95
Rohit Grover 37:c29c330d942c 96 /**@brief Alert Notification Setting structure containing the supported alerts in the service.
Rohit Grover 37:c29c330d942c 97 *
Rohit Grover 37:c29c330d942c 98 *@details
Rohit Grover 37:c29c330d942c 99 * The structure contains bit fields describing which alerts that are supported:
Rohit Grover 37:c29c330d942c 100 * 0 = Unsupported
Rohit Grover 37:c29c330d942c 101 * 1 = Supported
Rohit Grover 37:c29c330d942c 102 */
Rohit Grover 37:c29c330d942c 103 typedef struct
Rohit Grover 37:c29c330d942c 104 {
Rohit Grover 37:c29c330d942c 105 uint8_t ans_simple_alert_support : 1; /**< Support for General text alert or non-text alert.*/
Rohit Grover 37:c29c330d942c 106 uint8_t ans_email_support : 1; /**< Support for Alert when email messages arrives.*/
Rohit Grover 37:c29c330d942c 107 uint8_t ans_news_support : 1; /**< Support for News feeds such as RSS, Atom.*/
Rohit Grover 37:c29c330d942c 108 uint8_t ans_notification_call_support : 1; /**< Support for Incoming call.*/
Rohit Grover 37:c29c330d942c 109 uint8_t ans_missed_call_support : 1; /**< Support for Missed call.*/
Rohit Grover 37:c29c330d942c 110 uint8_t ans_sms_mms_support : 1; /**< Support for SMS/MMS message arrives.*/
Rohit Grover 37:c29c330d942c 111 uint8_t ans_voice_mail_support : 1; /**< Support for Voice mail.*/
Rohit Grover 37:c29c330d942c 112 uint8_t ans_schedule_support : 1; /**< Support for Alert occurred on calendar, planner.*/
Rohit Grover 37:c29c330d942c 113 uint8_t ans_high_prioritized_alert_support : 1; /**< Support for Alert that should be handled as high priority.*/
Rohit Grover 37:c29c330d942c 114 uint8_t ans_instant_message_support : 1; /**< Support for Alert for incoming instant messages.*/
Rohit Grover 37:c29c330d942c 115 uint8_t reserved : 6; /**< Reserved for future use. */
Rohit Grover 37:c29c330d942c 116 } ble_ans_alert_settings_t;
Rohit Grover 37:c29c330d942c 117
Rohit Grover 37:c29c330d942c 118 /**@brief Alert Notification structure
Rohit Grover 37:c29c330d942c 119 */
Rohit Grover 37:c29c330d942c 120 typedef struct
Rohit Grover 37:c29c330d942c 121 {
Rohit Grover 37:c29c330d942c 122 uint8_t alert_category; /**< Alert category to which this alert belongs.*/
Rohit Grover 37:c29c330d942c 123 uint8_t alert_category_count; /**< Number of alerts in the category. */
Rohit Grover 37:c29c330d942c 124 uint32_t alert_msg_length; /**< Length of optional text message send by the server. */
Rohit Grover 37:c29c330d942c 125 uint8_t * p_alert_msg_buf; /**< Pointer to buffer containing the optional text message. */
Rohit Grover 37:c29c330d942c 126 } ble_ans_alert_notification_t;
Rohit Grover 37:c29c330d942c 127
Rohit Grover 37:c29c330d942c 128 /**@brief Alert Notification Event structure
Rohit Grover 37:c29c330d942c 129 *
Rohit Grover 37:c29c330d942c 130 * @details The structure contains the event that should be handled, as well as
Rohit Grover 37:c29c330d942c 131 * additional information.
Rohit Grover 37:c29c330d942c 132 */
Rohit Grover 37:c29c330d942c 133 typedef struct
Rohit Grover 37:c29c330d942c 134 {
Rohit Grover 37:c29c330d942c 135 ble_ans_c_evt_type_t evt_type; /**< Type of event. */
Rohit Grover 37:c29c330d942c 136 ble_uuid_t uuid; /**< UUID of the event in case of an alert or notification. */
Rohit Grover 37:c29c330d942c 137 union
Rohit Grover 37:c29c330d942c 138 {
Rohit Grover 37:c29c330d942c 139 ble_ans_alert_settings_t settings; /**< Setting returned from server on read request. */
Rohit Grover 37:c29c330d942c 140 ble_ans_alert_notification_t alert; /**< Alert Notification data sent by the server. */
Rohit Grover 37:c29c330d942c 141 uint32_t error_code; /**< Additional status/error code if the event was caused by a stack error or gatt status, e.g. during service discovery. */
Rohit Grover 37:c29c330d942c 142 } data;
Rohit Grover 37:c29c330d942c 143 } ble_ans_c_evt_t;
Rohit Grover 37:c29c330d942c 144
Rohit Grover 37:c29c330d942c 145 /**@brief Alert Notification event handler type. */
Rohit Grover 37:c29c330d942c 146 typedef void (*ble_ans_c_evt_handler_t) (ble_ans_c_evt_t * p_evt);
Rohit Grover 37:c29c330d942c 147
Rohit Grover 37:c29c330d942c 148 /**@brief Alert Notification structure. This contains various status information for the client. */
Rohit Grover 37:c29c330d942c 149 typedef struct ble_ans_c_s
Rohit Grover 37:c29c330d942c 150 {
Rohit Grover 37:c29c330d942c 151 ble_ans_c_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Alert Notification Client Application. */
Rohit Grover 37:c29c330d942c 152 ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */
Rohit Grover 37:c29c330d942c 153 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 154 uint8_t central_handle; /**< Handle for the currently connected central if peer is bonded. */
Rohit Grover 37:c29c330d942c 155 uint8_t service_handle; /**< Handle to the service in the database to use for this instance. */
Rohit Grover 37:c29c330d942c 156 uint32_t message_buffer_size; /**< Size of message buffer to hold the additional text messages received on notifications. */
Rohit Grover 37:c29c330d942c 157 uint8_t * p_message_buffer; /**< Pointer to the buffer to be used for additional text message handling. */
Rohit Grover 37:c29c330d942c 158 } ble_ans_c_t;
Rohit Grover 37:c29c330d942c 159
Rohit Grover 37:c29c330d942c 160 /**@brief Alert Notification init structure. This contains all options and data needed for
Rohit Grover 37:c29c330d942c 161 * initialization of the client.*/
Rohit Grover 37:c29c330d942c 162 typedef struct
Rohit Grover 37:c29c330d942c 163 {
Rohit Grover 37:c29c330d942c 164 ble_ans_c_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Battery Service. */
Rohit Grover 37:c29c330d942c 165 ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */
Rohit Grover 37:c29c330d942c 166 uint32_t message_buffer_size; /**< Size of buffer to handle messages. */
Rohit Grover 37:c29c330d942c 167 uint8_t * p_message_buffer; /**< Pointer to buffer for passing messages. */
Rohit Grover 37:c29c330d942c 168 } ble_ans_c_init_t;
Rohit Grover 37:c29c330d942c 169
Rohit Grover 37:c29c330d942c 170
Rohit Grover 37:c29c330d942c 171 /**@brief Function for handling the Application's BLE Stack events.
Rohit Grover 37:c29c330d942c 172 *
Rohit Grover 37:c29c330d942c 173 * @details Handles all events from the BLE stack of interest to the Alert Notification Client.
Rohit Grover 37:c29c330d942c 174 *
Rohit Grover 37:c29c330d942c 175 * @param[in] p_ans Alert Notification Client structure.
Rohit Grover 37:c29c330d942c 176 * @param[in] p_ble_evt Event received from the BLE stack.
Rohit Grover 37:c29c330d942c 177 */
Rohit Grover 37:c29c330d942c 178 void ble_ans_c_on_ble_evt(ble_ans_c_t * p_ans, const ble_evt_t * p_ble_evt);
Rohit Grover 37:c29c330d942c 179
Rohit Grover 37:c29c330d942c 180
Rohit Grover 37:c29c330d942c 181 /**@brief Function for handling the Alert Notification Client - Device Manager Event.
Rohit Grover 37:c29c330d942c 182 *
Rohit Grover 37:c29c330d942c 183 * @details Handles all events from the Bond Manager of interest to the Alert Notification Client.
Rohit Grover 37:c29c330d942c 184 * The Alert Notification Client will use the events of re-connection to existing central
Rohit Grover 37:c29c330d942c 185 * and creation of new bonds for handling of service discovery and writing of the Alert
Rohit Grover 37:c29c330d942c 186 * Notification Control Point for re-send of New Alert and Unread Alert notifications.
Rohit Grover 37:c29c330d942c 187 *
Rohit Grover 37:c29c330d942c 188 * @param[in] p_ans Alert Notification Client structure.
Rohit Grover 37:c29c330d942c 189 * @param[in] p_bond_mgmr_evt Event received from the Bond Manager.
Rohit Grover 37:c29c330d942c 190 */
Rohit Grover 37:c29c330d942c 191 void ble_ans_c_on_device_manager_evt(ble_ans_c_t * p_ans,
Rohit Grover 37:c29c330d942c 192 dm_handle_t const * p_handle,
Rohit Grover 37:c29c330d942c 193 dm_event_t const * p_dm_evt);
Rohit Grover 37:c29c330d942c 194
Rohit Grover 37:c29c330d942c 195
Rohit Grover 37:c29c330d942c 196 /**@brief Function for initializing the Alert Notification Client.
Rohit Grover 37:c29c330d942c 197 *
Rohit Grover 37:c29c330d942c 198 * @param[out] p_ans Alert Notification Client structure. This structure will have to be
Rohit Grover 37:c29c330d942c 199 * supplied by the application. It will be initialized by this function,
Rohit Grover 37:c29c330d942c 200 * and will later be used to identify this particular client instance.
Rohit Grover 37:c29c330d942c 201 * @param[in] p_ans_init Information needed to initialize the client.
Rohit Grover 37:c29c330d942c 202 *
Rohit Grover 37:c29c330d942c 203 * @return NRF_SUCCESS on successful initialization of client, otherwise an error code.
Rohit Grover 37:c29c330d942c 204 */
Rohit Grover 37:c29c330d942c 205 uint32_t ble_ans_c_init(ble_ans_c_t * p_ans, const ble_ans_c_init_t * p_ans_init);
Rohit Grover 37:c29c330d942c 206
Rohit Grover 37:c29c330d942c 207
Rohit Grover 37:c29c330d942c 208 /**@brief Function for writing the to CCCD to enable new alert notifications from the Alert Notification Service.
Rohit Grover 37:c29c330d942c 209 *
Rohit Grover 37:c29c330d942c 210 * @param[in] p_ans Alert Notification structure. This structure will have to be supplied by
Rohit Grover 37:c29c330d942c 211 * the application. It identifies the particular client instance to use.
Rohit Grover 37:c29c330d942c 212 *
Rohit Grover 37:c29c330d942c 213 * @return NRF_SUCCESS on successful writing of the CCCD, otherwise an error code.
Rohit Grover 37:c29c330d942c 214 */
Rohit Grover 37:c29c330d942c 215 uint32_t ble_ans_c_enable_notif_new_alert(const ble_ans_c_t * p_ans);
Rohit Grover 37:c29c330d942c 216
Rohit Grover 37:c29c330d942c 217
Rohit Grover 37:c29c330d942c 218 /**@brief Function for writing to the CCCD to enable unread alert notifications from the Alert Notification Service.
Rohit Grover 37:c29c330d942c 219 *
Rohit Grover 37:c29c330d942c 220 * @param[in] p_ans Alert Notification structure. This structure will have to be supplied by
Rohit Grover 37:c29c330d942c 221 * the application. It identifies the particular client instance to use.
Rohit Grover 37:c29c330d942c 222 *
Rohit Grover 37:c29c330d942c 223 * @return NRF_SUCCESS on successful writing of the CCCD, otherwise an error code.
Rohit Grover 37:c29c330d942c 224 */
Rohit Grover 37:c29c330d942c 225 uint32_t ble_ans_c_enable_notif_unread_alert(const ble_ans_c_t * p_ans);
Rohit Grover 37:c29c330d942c 226
Rohit Grover 37:c29c330d942c 227
Rohit Grover 37:c29c330d942c 228 /**@brief Function for writing to the CCCD to disable new alert notifications from the Alert Notification Service.
Rohit Grover 37:c29c330d942c 229 *
Rohit Grover 37:c29c330d942c 230 * @param[in] p_ans Alert Notification structure. This structure will have to be supplied by
Rohit Grover 37:c29c330d942c 231 * the application. It identifies the particular client instance to use.
Rohit Grover 37:c29c330d942c 232 *
Rohit Grover 37:c29c330d942c 233 * @return NRF_SUCCESS on successful writing of the CCCD, otherwise an error code.
Rohit Grover 37:c29c330d942c 234 */
Rohit Grover 37:c29c330d942c 235 uint32_t ble_ans_c_disable_notif_new_alert(const ble_ans_c_t * p_ans);
Rohit Grover 37:c29c330d942c 236
Rohit Grover 37:c29c330d942c 237
Rohit Grover 37:c29c330d942c 238 /**@brief Function for writing to the CCCD to disable unread alert notifications from the Alert Notification Service.
Rohit Grover 37:c29c330d942c 239 *
Rohit Grover 37:c29c330d942c 240 * @param[in] p_ans Alert Notification structure. This structure will have to be supplied by
Rohit Grover 37:c29c330d942c 241 * the application. It identifies the particular client instance to use.
Rohit Grover 37:c29c330d942c 242 *
Rohit Grover 37:c29c330d942c 243 * @return NRF_SUCCESS on successful writing of the CCCD, otherwise an error code.
Rohit Grover 37:c29c330d942c 244 */
Rohit Grover 37:c29c330d942c 245 uint32_t ble_ans_c_disable_notif_unread_alert(const ble_ans_c_t * p_ans);
Rohit Grover 37:c29c330d942c 246
Rohit Grover 37:c29c330d942c 247
Rohit Grover 37:c29c330d942c 248 /**@brief Function for writing to the Alert Notification Control Point to specify alert notification behavior in the
Rohit Grover 37:c29c330d942c 249 * Alert Notification Service on the Central.
Rohit Grover 37:c29c330d942c 250 *
Rohit Grover 37:c29c330d942c 251 * @param[in] p_ans Alert Notification structure. This structure will have to be
Rohit Grover 37:c29c330d942c 252 * supplied by the application. It identifies the particular client
Rohit Grover 37:c29c330d942c 253 * instance to use.
Rohit Grover 37:c29c330d942c 254 * @param[in] p_control_point Alert Notification Control Point structure. This structure
Rohit Grover 37:c29c330d942c 255 * specifies the values to write to the Alert Notification Control
Rohit Grover 37:c29c330d942c 256 * Point, UUID 0x2A44.
Rohit Grover 37:c29c330d942c 257 *
Rohit Grover 37:c29c330d942c 258 * @return NRF_SUCCESS on successful writing of the Control Point, otherwise an error code.
Rohit Grover 37:c29c330d942c 259 */
Rohit Grover 37:c29c330d942c 260 uint32_t ble_ans_c_control_point_write(const ble_ans_c_t * p_ans,
Rohit Grover 37:c29c330d942c 261 const ble_ans_control_point_t * p_control_point);
Rohit Grover 37:c29c330d942c 262
Rohit Grover 37:c29c330d942c 263
Rohit Grover 37:c29c330d942c 264 /**@brief Function for reading the Supported New Alert characteristic value of the service.
Rohit Grover 37:c29c330d942c 265 * The value describes the alerts supported in the central.
Rohit Grover 37:c29c330d942c 266 *
Rohit Grover 37:c29c330d942c 267 * @param[in] p_ans Alert Notification structure. This structure will have to be supplied by
Rohit Grover 37:c29c330d942c 268 * the application. It identifies the particular client instance to use.
Rohit Grover 37:c29c330d942c 269 *
Rohit Grover 37:c29c330d942c 270 * @return NRF_SUCCESS on successful transmission of the read request, otherwise an error code.
Rohit Grover 37:c29c330d942c 271 */
Rohit Grover 37:c29c330d942c 272 uint32_t ble_ans_c_new_alert_read(const ble_ans_c_t * p_ans);
Rohit Grover 37:c29c330d942c 273
Rohit Grover 37:c29c330d942c 274
Rohit Grover 37:c29c330d942c 275 /**@brief Function for reading the Supported Unread Alert characteristic value of the service.
Rohit Grover 37:c29c330d942c 276 * The value describes the alerts supported in the central.
Rohit Grover 37:c29c330d942c 277 *
Rohit Grover 37:c29c330d942c 278 * @param[in] p_ans Alert Notification structure. This structure will have to be supplied by
Rohit Grover 37:c29c330d942c 279 * the application. It identifies the particular client instance to use.
Rohit Grover 37:c29c330d942c 280 *
Rohit Grover 37:c29c330d942c 281 * @return NRF_SUCCESS on successful transmission of the read request, otherwise an error code.
Rohit Grover 37:c29c330d942c 282 */
Rohit Grover 37:c29c330d942c 283 uint32_t ble_ans_c_unread_alert_read(const ble_ans_c_t * p_ans);
Rohit Grover 37:c29c330d942c 284
Rohit Grover 37:c29c330d942c 285
Rohit Grover 37:c29c330d942c 286 /**@brief Function for requesting the peer to notify the New Alert characteristics immediately.
Rohit Grover 37:c29c330d942c 287 *
Rohit Grover 37:c29c330d942c 288 * @param[in] p_ans Alert Notification structure. This structure will have to be supplied by
Rohit Grover 37:c29c330d942c 289 * the application. It identifies the particular client instance to use.
Rohit Grover 37:c29c330d942c 290 * @param[in] category The category ID for which the peer should notify the client.
Rohit Grover 37:c29c330d942c 291 *
Rohit Grover 37:c29c330d942c 292 * @return NRF_SUCCESS on successful transmission of the read request, otherwise an error code.
Rohit Grover 37:c29c330d942c 293 */
Rohit Grover 37:c29c330d942c 294 uint32_t ble_ans_c_new_alert_notify(const ble_ans_c_t * p_ans, ble_ans_category_id_t category);
Rohit Grover 37:c29c330d942c 295
Rohit Grover 37:c29c330d942c 296
Rohit Grover 37:c29c330d942c 297 /**@brief Function for requesting the peer to notify the Unread Alert characteristics immediately.
Rohit Grover 37:c29c330d942c 298 *
Rohit Grover 37:c29c330d942c 299 * @param[in] p_ans Alert Notification structure. This structure will have to be supplied by
Rohit Grover 37:c29c330d942c 300 * the application. It identifies the particular client instance to use.
Rohit Grover 37:c29c330d942c 301 * @param[in] category The category ID for which the peer should notify the client.
Rohit Grover 37:c29c330d942c 302 *
Rohit Grover 37:c29c330d942c 303 * @return NRF_SUCCESS on successful transmission of the read request, otherwise an error code.
Rohit Grover 37:c29c330d942c 304 */
Rohit Grover 37:c29c330d942c 305 uint32_t ble_ans_c_unread_alert_notify(const ble_ans_c_t * p_ans, ble_ans_category_id_t category);
Rohit Grover 37:c29c330d942c 306
Rohit Grover 37:c29c330d942c 307
Rohit Grover 37:c29c330d942c 308 /**@brief Function for loading previous discovered service and characteristic handles for bonded centrals from
Rohit Grover 37:c29c330d942c 309 * flash into RAM.
Rohit Grover 37:c29c330d942c 310 *
Rohit Grover 37:c29c330d942c 311 * @details Read the database of all discovered service and characteristic handles from flash.
Rohit Grover 37:c29c330d942c 312 * If the flash does not contain any valid data, the array of discovered service handles in
Rohit Grover 37:c29c330d942c 313 * RAM will be empty.
Rohit Grover 37:c29c330d942c 314 *
Rohit Grover 37:c29c330d942c 315 * @param[in] p_ans Alert Notification structure. This structure will have to be supplied by the
Rohit Grover 37:c29c330d942c 316 * application. It identifies the particular client instance to use.
Rohit Grover 37:c29c330d942c 317 *
Rohit Grover 37:c29c330d942c 318 * @note Currently the Alert Notification Client uses only one page in flash.
Rohit Grover 37:c29c330d942c 319 *
Rohit Grover 37:c29c330d942c 320 * @return NRF_SUCCESS if all operations went successfully, an error_code otherwise.
Rohit Grover 37:c29c330d942c 321 */
Rohit Grover 37:c29c330d942c 322 uint32_t ble_ans_c_service_load(const ble_ans_c_t * p_ans);
Rohit Grover 37:c29c330d942c 323
Rohit Grover 37:c29c330d942c 324
Rohit Grover 37:c29c330d942c 325 /**@brief Function for storing discovered service and characteristic handles for bonded centrals into flash memory.
Rohit Grover 37:c29c330d942c 326 *
Rohit Grover 37:c29c330d942c 327 * @details This function will erase the flash page (if the data to store
Rohit Grover 37:c29c330d942c 328 * are diferent than the one already stored) and then write into flash. Those
Rohit Grover 37:c29c330d942c 329 * operations could prevent the radio to run.
Rohit Grover 37:c29c330d942c 330 *
Rohit Grover 37:c29c330d942c 331 * @note Do not call this function while in a connection or when advertising. If you do, the
Rohit Grover 37:c29c330d942c 332 * behavior is undefined.
Rohit Grover 37:c29c330d942c 333 *
Rohit Grover 37:c29c330d942c 334 * @return NRF_SUCCESS if all operations went successfully, an error_code otherwise.
Rohit Grover 37:c29c330d942c 335 */
Rohit Grover 37:c29c330d942c 336 uint32_t ble_ans_c_service_store(void);
Rohit Grover 37:c29c330d942c 337
Rohit Grover 37:c29c330d942c 338
Rohit Grover 37:c29c330d942c 339 /**@brief Function for deleting the Alert Notification Client database from flash.
Rohit Grover 37:c29c330d942c 340 *
Rohit Grover 37:c29c330d942c 341 * @details After calling this function you should call ble_ans_c_init(...) to re-initialize
Rohit Grover 37:c29c330d942c 342 * the RAM database.
Rohit Grover 37:c29c330d942c 343 *
Rohit Grover 37:c29c330d942c 344 * @return NRF_SUCCESS if all operations went successfully.
Rohit Grover 37:c29c330d942c 345 */
Rohit Grover 37:c29c330d942c 346 uint32_t ble_ans_c_service_delete(void);
Rohit Grover 37:c29c330d942c 347
Rohit Grover 37:c29c330d942c 348 #endif // BLE_ANS_C_H__
Rohit Grover 37:c29c330d942c 349
Rohit Grover 37:c29c330d942c 350 /** @} */
Rohit Grover 37:c29c330d942c 351