BLE FOTA APP

Dependencies:   BLE_API mbed

It doesn't work with the default FOTA bootloader. It use NVIC_SystemReset() to enter a bootloader.

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?

UserRevisionLine numberNew 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 Immediate Alert Service
yihui 1:a607cd9655d7 16 * @{
yihui 1:a607cd9655d7 17 * @ingroup ble_sdk_srv
yihui 1:a607cd9655d7 18 * @brief Immediate Alert Service module.
yihui 1:a607cd9655d7 19 *
yihui 1:a607cd9655d7 20 * @details This module implements the Immediate Alert Service with the Alert Level characteristic.
yihui 1:a607cd9655d7 21 * During initialization it adds the Immediate Alert Service and Alert Level characteristic
yihui 1:a607cd9655d7 22 * to the BLE stack database.
yihui 1:a607cd9655d7 23 *
yihui 1:a607cd9655d7 24 * The application must supply an event handler for receiving Immediate Alert Service
yihui 1:a607cd9655d7 25 * events. Using this handler, the service will notify the application when the
yihui 1:a607cd9655d7 26 * Alert Level characteristic value changes.
yihui 1:a607cd9655d7 27 *
yihui 1:a607cd9655d7 28 * The service also provides a function for letting the application poll the current
yihui 1:a607cd9655d7 29 * value of the Alert Level characteristic.
yihui 1:a607cd9655d7 30 *
yihui 1:a607cd9655d7 31 * @note The application must propagate BLE stack events to the Immediate Alert Service
yihui 1:a607cd9655d7 32 * module by calling ble_ias_on_ble_evt() from the @ref ble_stack_handler callback.
yihui 1:a607cd9655d7 33 *
yihui 1:a607cd9655d7 34 * @note Attention!
yihui 1:a607cd9655d7 35 * To maintain compliance with Nordic Semiconductor ASA Bluetooth profile
yihui 1:a607cd9655d7 36 * qualification listings, this section of source code must not be modified.
yihui 1:a607cd9655d7 37 */
yihui 1:a607cd9655d7 38
yihui 1:a607cd9655d7 39 #ifndef BLE_IAS_H__
yihui 1:a607cd9655d7 40 #define BLE_IAS_H__
yihui 1:a607cd9655d7 41
yihui 1:a607cd9655d7 42 #include <stdint.h>
yihui 1:a607cd9655d7 43 #include "ble.h"
yihui 1:a607cd9655d7 44
yihui 1:a607cd9655d7 45 /**@brief Immediate Alert Service event type. */
yihui 1:a607cd9655d7 46 typedef enum
yihui 1:a607cd9655d7 47 {
yihui 1:a607cd9655d7 48 BLE_IAS_EVT_ALERT_LEVEL_UPDATED /**< Alert Level Updated event. */
yihui 1:a607cd9655d7 49 } ble_ias_evt_type_t;
yihui 1:a607cd9655d7 50
yihui 1:a607cd9655d7 51 /**@brief Immediate Alert Service event. */
yihui 1:a607cd9655d7 52 typedef struct
yihui 1:a607cd9655d7 53 {
yihui 1:a607cd9655d7 54 ble_ias_evt_type_t evt_type; /**< Type of event. */
yihui 1:a607cd9655d7 55 union
yihui 1:a607cd9655d7 56 {
yihui 1:a607cd9655d7 57 uint8_t alert_level; /**< New Alert Level value. */
yihui 1:a607cd9655d7 58 } params;
yihui 1:a607cd9655d7 59 } ble_ias_evt_t;
yihui 1:a607cd9655d7 60
yihui 1:a607cd9655d7 61 // Forward declaration of the ble_ias_t type.
yihui 1:a607cd9655d7 62 typedef struct ble_ias_s ble_ias_t;
yihui 1:a607cd9655d7 63
yihui 1:a607cd9655d7 64 /**@brief Immediate Alert Service event handler type. */
yihui 1:a607cd9655d7 65 typedef void (*ble_ias_evt_handler_t) (ble_ias_t * p_ias, ble_ias_evt_t * p_evt);
yihui 1:a607cd9655d7 66
yihui 1:a607cd9655d7 67 /**@brief Immediate Alert Service init structure. This contains all options and data needed for
yihui 1:a607cd9655d7 68 * initialization of the service. */
yihui 1:a607cd9655d7 69 typedef struct
yihui 1:a607cd9655d7 70 {
yihui 1:a607cd9655d7 71 ble_ias_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Immediate Alert Service. */
yihui 1:a607cd9655d7 72 } ble_ias_init_t;
yihui 1:a607cd9655d7 73
yihui 1:a607cd9655d7 74 /**@brief Immediate Alert Service structure. This contains various status information for the
yihui 1:a607cd9655d7 75 * service. */
yihui 1:a607cd9655d7 76 typedef struct ble_ias_s
yihui 1:a607cd9655d7 77 {
yihui 1:a607cd9655d7 78 ble_ias_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Immediate Alert Service. */
yihui 1:a607cd9655d7 79 uint16_t service_handle; /**< Handle of Immediate Alert Service (as provided by the BLE stack). */
yihui 1:a607cd9655d7 80 ble_gatts_char_handles_t alert_level_handles; /**< Handles related to the Alert Level characteristic. */
yihui 1:a607cd9655d7 81 } ble_ias_t;
yihui 1:a607cd9655d7 82
yihui 1:a607cd9655d7 83 /**@brief Function for initializing the Immediate Alert Service.
yihui 1:a607cd9655d7 84 *
yihui 1:a607cd9655d7 85 * @param[out] p_ias Immediate Alert Service structure. This structure will have to be
yihui 1:a607cd9655d7 86 * supplied by the application. It will be initialized by this function,
yihui 1:a607cd9655d7 87 * and will later be used to identify this particular service instance.
yihui 1:a607cd9655d7 88 * @param[in] p_ias_init Information needed to initialize the service.
yihui 1:a607cd9655d7 89 *
yihui 1:a607cd9655d7 90 * @return NRF_SUCCESS on successful initialization of service, otherwise an error code.
yihui 1:a607cd9655d7 91 */
yihui 1:a607cd9655d7 92 uint32_t ble_ias_init(ble_ias_t * p_ias, const ble_ias_init_t * p_ias_init);
yihui 1:a607cd9655d7 93
yihui 1:a607cd9655d7 94 /**@brief Function for handling the Application's BLE Stack events.
yihui 1:a607cd9655d7 95 *
yihui 1:a607cd9655d7 96 * @details Handles all events from the BLE stack of interest to the Immediate Alert Service.
yihui 1:a607cd9655d7 97 *
yihui 1:a607cd9655d7 98 * @param[in] p_ias Immediate Alert Service structure.
yihui 1:a607cd9655d7 99 * @param[in] p_ble_evt Event received from the BLE stack.
yihui 1:a607cd9655d7 100 */
yihui 1:a607cd9655d7 101 void ble_ias_on_ble_evt(ble_ias_t * p_ias, ble_evt_t * p_ble_evt);
yihui 1:a607cd9655d7 102
yihui 1:a607cd9655d7 103 /**@brief Function for getting current value of the Alert Level characteristic.
yihui 1:a607cd9655d7 104 *
yihui 1:a607cd9655d7 105 * @param[in] p_ias Immediate Alert Service structure.
yihui 1:a607cd9655d7 106 * @param[out] p_alert_level Current Alert Level value.
yihui 1:a607cd9655d7 107 */
yihui 1:a607cd9655d7 108 uint32_t ble_ias_alert_level_get(ble_ias_t * p_ias, uint8_t * p_alert_level);
yihui 1:a607cd9655d7 109
yihui 1:a607cd9655d7 110 #endif // BLE_IAS_H__
yihui 1:a607cd9655d7 111
yihui 1:a607cd9655d7 112 /** @} */