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