iOSのBLEコントローラアプリ「RCBController」と接続し、コントローラの操作を取得するサンプルプログラムです。 mbed HRM1017で動作を確認しています。 2014.08.20時点でのBLEライブラリに対応しました。

Dependencies:   BLE_API mbed

Fork of BLE_RCBController by Junichi Katsu

Committer:
jksoft
Date:
Wed Aug 20 13:41:01 2014 +0000
Revision:
4:ebda47d22091
Parent:
nRF51822/nordic/nrf-sdk/ble/ble_services/ble_ans_c.h@1:48f6e08a3ac2
?????????

Who changed what in which revision?

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