テスト用です。

Dependencies:   mbed

Committer:
jksoft
Date:
Tue Oct 11 11:09:42 2016 +0000
Revision:
0:8468a4403fea
SB??ver;

Who changed what in which revision?

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