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