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_lls.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_lls Link Loss Service |
yihui | 1:a607cd9655d7 | 16 | * @{ |
yihui | 1:a607cd9655d7 | 17 | * @ingroup ble_sdk_srv |
yihui | 1:a607cd9655d7 | 18 | * @brief Link Loss Service module. |
yihui | 1:a607cd9655d7 | 19 | * |
yihui | 1:a607cd9655d7 | 20 | * @details This module implements the Link Loss Service with the Alert Level characteristic. |
yihui | 1:a607cd9655d7 | 21 | * During initialization it adds the Link Loss 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 Link Loss Service |
yihui | 1:a607cd9655d7 | 25 | * events. Using this handler, the service will notify the application when the |
yihui | 1:a607cd9655d7 | 26 | * link has been lost, and which Alert Level has been set. |
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 Link Loss Service |
yihui | 1:a607cd9655d7 | 32 | * module by calling ble_lls_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_LLS_H__ |
yihui | 1:a607cd9655d7 | 40 | #define BLE_LLS_H__ |
yihui | 1:a607cd9655d7 | 41 | |
yihui | 1:a607cd9655d7 | 42 | #include <stdint.h> |
yihui | 1:a607cd9655d7 | 43 | #include "ble.h" |
yihui | 1:a607cd9655d7 | 44 | #include "ble_srv_common.h" |
yihui | 1:a607cd9655d7 | 45 | |
yihui | 1:a607cd9655d7 | 46 | /**@brief Link Loss Service event type. */ |
yihui | 1:a607cd9655d7 | 47 | typedef enum |
yihui | 1:a607cd9655d7 | 48 | { |
yihui | 1:a607cd9655d7 | 49 | BLE_LLS_EVT_LINK_LOSS_ALERT /**< Alert Level Updated event. */ |
yihui | 1:a607cd9655d7 | 50 | } ble_lls_evt_type_t; |
yihui | 1:a607cd9655d7 | 51 | |
yihui | 1:a607cd9655d7 | 52 | /**@brief Link Loss Service event. */ |
yihui | 1:a607cd9655d7 | 53 | typedef struct |
yihui | 1:a607cd9655d7 | 54 | { |
yihui | 1:a607cd9655d7 | 55 | ble_lls_evt_type_t evt_type; /**< Type of event. */ |
yihui | 1:a607cd9655d7 | 56 | union |
yihui | 1:a607cd9655d7 | 57 | { |
yihui | 1:a607cd9655d7 | 58 | uint8_t alert_level; /**< New Alert Level value. */ |
yihui | 1:a607cd9655d7 | 59 | } params; |
yihui | 1:a607cd9655d7 | 60 | } ble_lls_evt_t; |
yihui | 1:a607cd9655d7 | 61 | |
yihui | 1:a607cd9655d7 | 62 | // Forward declaration of the ble_lls_t type. |
yihui | 1:a607cd9655d7 | 63 | typedef struct ble_lls_s ble_lls_t; |
yihui | 1:a607cd9655d7 | 64 | |
yihui | 1:a607cd9655d7 | 65 | /**@brief Link Loss Service event handler type. */ |
yihui | 1:a607cd9655d7 | 66 | typedef void (*ble_lls_evt_handler_t) (ble_lls_t * p_lls, ble_lls_evt_t * p_evt); |
yihui | 1:a607cd9655d7 | 67 | |
yihui | 1:a607cd9655d7 | 68 | /**@brief Link Loss Service init structure. This contains all options and data needed for initialization of the service. */ |
yihui | 1:a607cd9655d7 | 69 | typedef struct |
yihui | 1:a607cd9655d7 | 70 | { |
yihui | 1:a607cd9655d7 | 71 | ble_lls_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Link Loss Service. */ |
yihui | 1:a607cd9655d7 | 72 | ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ |
yihui | 1:a607cd9655d7 | 73 | uint8_t initial_alert_level; /**< Initial value of the Alert Level characteristic. */ |
yihui | 1:a607cd9655d7 | 74 | ble_srv_security_mode_t lls_attr_md; /**< Initial Security Setting for Link Loss Service Characteristics. */ |
yihui | 1:a607cd9655d7 | 75 | } ble_lls_init_t; |
yihui | 1:a607cd9655d7 | 76 | |
yihui | 1:a607cd9655d7 | 77 | /**@brief Link Loss Service structure. This contains various status information for the service. */ |
yihui | 1:a607cd9655d7 | 78 | typedef struct ble_lls_s |
yihui | 1:a607cd9655d7 | 79 | { |
yihui | 1:a607cd9655d7 | 80 | ble_lls_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Link Loss Service. */ |
yihui | 1:a607cd9655d7 | 81 | ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ |
yihui | 1:a607cd9655d7 | 82 | uint16_t service_handle; /**< Handle of Link Loss Service (as provided by the BLE stack). */ |
yihui | 1:a607cd9655d7 | 83 | ble_gatts_char_handles_t alert_level_handles; /**< Handles related to the Alert Level characteristic. */ |
yihui | 1:a607cd9655d7 | 84 | } ble_lls_t; |
yihui | 1:a607cd9655d7 | 85 | |
yihui | 1:a607cd9655d7 | 86 | /**@brief Function for initializing the Link Loss Service. |
yihui | 1:a607cd9655d7 | 87 | * |
yihui | 1:a607cd9655d7 | 88 | * @param[out] p_lls Link Loss Service structure. This structure will have to be supplied by |
yihui | 1:a607cd9655d7 | 89 | * the application. It will be initialized by this function, and will later |
yihui | 1:a607cd9655d7 | 90 | * be used to identify this particular service instance. |
yihui | 1:a607cd9655d7 | 91 | * @param[in] p_lls_init Information needed to initialize the service. |
yihui | 1:a607cd9655d7 | 92 | * |
yihui | 1:a607cd9655d7 | 93 | * @return NRF_SUCCESS on successful initialization of service, otherwise an error code. |
yihui | 1:a607cd9655d7 | 94 | */ |
yihui | 1:a607cd9655d7 | 95 | uint32_t ble_lls_init(ble_lls_t * p_lls, const ble_lls_init_t * p_lls_init); |
yihui | 1:a607cd9655d7 | 96 | |
yihui | 1:a607cd9655d7 | 97 | /**@brief Function for handling the Application's BLE Stack events. |
yihui | 1:a607cd9655d7 | 98 | * |
yihui | 1:a607cd9655d7 | 99 | * @details Handles all events from the BLE stack of interest to the Link Loss Service. |
yihui | 1:a607cd9655d7 | 100 | * |
yihui | 1:a607cd9655d7 | 101 | * @param[in] p_lls Link Loss Service structure. |
yihui | 1:a607cd9655d7 | 102 | * @param[in] p_ble_evt Event received from the BLE stack. |
yihui | 1:a607cd9655d7 | 103 | */ |
yihui | 1:a607cd9655d7 | 104 | void ble_lls_on_ble_evt(ble_lls_t * p_lls, ble_evt_t * p_ble_evt); |
yihui | 1:a607cd9655d7 | 105 | |
yihui | 1:a607cd9655d7 | 106 | /**@brief Function for getting current value of the Alert Level characteristic. |
yihui | 1:a607cd9655d7 | 107 | * |
yihui | 1:a607cd9655d7 | 108 | * @param[in] p_lls Link Loss Service structure. |
yihui | 1:a607cd9655d7 | 109 | * @param[out] p_alert_level Current Alert Level value. |
yihui | 1:a607cd9655d7 | 110 | */ |
yihui | 1:a607cd9655d7 | 111 | uint32_t ble_lls_alert_level_get(ble_lls_t * p_lls, uint8_t * p_alert_level); |
yihui | 1:a607cd9655d7 | 112 | |
yihui | 1:a607cd9655d7 | 113 | #endif // BLE_LLS_H__ |
yihui | 1:a607cd9655d7 | 114 | |
yihui | 1:a607cd9655d7 | 115 | /** @} */ |