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_lib_conn_params Connection Parameters Negotiation
yihui 1:a607cd9655d7 16 * @{
yihui 1:a607cd9655d7 17 * @ingroup ble_sdk_lib
yihui 1:a607cd9655d7 18 * @brief Module for initiating and executing a connection parameters negotiation procedure.
yihui 1:a607cd9655d7 19 */
yihui 1:a607cd9655d7 20
yihui 1:a607cd9655d7 21 #ifndef BLE_CONN_PARAMS_H__
yihui 1:a607cd9655d7 22 #define BLE_CONN_PARAMS_H__
yihui 1:a607cd9655d7 23
yihui 1:a607cd9655d7 24 #include <stdint.h>
yihui 1:a607cd9655d7 25 #include "ble.h"
yihui 1:a607cd9655d7 26 #include "ble_srv_common.h"
yihui 1:a607cd9655d7 27
yihui 1:a607cd9655d7 28 #ifdef __cplusplus
yihui 1:a607cd9655d7 29 extern "C" {
yihui 1:a607cd9655d7 30 #endif // #ifdef __cplusplus
yihui 1:a607cd9655d7 31
yihui 1:a607cd9655d7 32 /**@brief Connection Parameters Module event type. */
yihui 1:a607cd9655d7 33 typedef enum
yihui 1:a607cd9655d7 34 {
yihui 1:a607cd9655d7 35 BLE_CONN_PARAMS_EVT_FAILED , /**< Negotiation procedure failed. */
yihui 1:a607cd9655d7 36 BLE_CONN_PARAMS_EVT_SUCCEEDED /**< Negotiation procedure succeeded. */
yihui 1:a607cd9655d7 37 } ble_conn_params_evt_type_t;
yihui 1:a607cd9655d7 38
yihui 1:a607cd9655d7 39 /**@brief Connection Parameters Module event. */
yihui 1:a607cd9655d7 40 typedef struct
yihui 1:a607cd9655d7 41 {
yihui 1:a607cd9655d7 42 ble_conn_params_evt_type_t evt_type; /**< Type of event. */
yihui 1:a607cd9655d7 43 } ble_conn_params_evt_t;
yihui 1:a607cd9655d7 44
yihui 1:a607cd9655d7 45 /**@brief Connection Parameters Module event handler type. */
yihui 1:a607cd9655d7 46 typedef void (*ble_conn_params_evt_handler_t) (ble_conn_params_evt_t * p_evt);
yihui 1:a607cd9655d7 47
yihui 1:a607cd9655d7 48 /**@brief Connection Parameters Module init structure. This contains all options and data needed for
yihui 1:a607cd9655d7 49 * initialization of the connection parameters negotiation module. */
yihui 1:a607cd9655d7 50 typedef struct
yihui 1:a607cd9655d7 51 {
yihui 1:a607cd9655d7 52 ble_gap_conn_params_t * p_conn_params; /**< Pointer to the connection parameters desired by the application. When calling ble_conn_params_init, if this parameter is set to NULL, the connection parameters will be fetched from host. */
yihui 1:a607cd9655d7 53 uint32_t first_conn_params_update_delay; /**< Time from initiating event (connect or start of notification) to first time sd_ble_gap_conn_param_update is called (in number of timer ticks). */
yihui 1:a607cd9655d7 54 uint32_t next_conn_params_update_delay; /**< Time between each call to sd_ble_gap_conn_param_update after the first (in number of timer ticks). Recommended value 30 seconds as per BLUETOOTH SPECIFICATION Version 4.0. */
yihui 1:a607cd9655d7 55 uint8_t max_conn_params_update_count; /**< Number of attempts before giving up the negotiation. */
yihui 1:a607cd9655d7 56 uint16_t start_on_notify_cccd_handle; /**< If procedure is to be started when notification is started, set this to the handle of the corresponding CCCD. Set to BLE_GATT_HANDLE_INVALID if procedure is to be started on connect event. */
yihui 1:a607cd9655d7 57 bool disconnect_on_fail; /**< Set to TRUE if a failed connection parameters update shall cause an automatic disconnection, set to FALSE otherwise. */
yihui 1:a607cd9655d7 58 ble_conn_params_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Connection Parameters. */
yihui 1:a607cd9655d7 59 ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */
yihui 1:a607cd9655d7 60 } ble_conn_params_init_t;
yihui 1:a607cd9655d7 61
yihui 1:a607cd9655d7 62
yihui 1:a607cd9655d7 63 /**@brief Function for initializing the Connection Parameters module.
yihui 1:a607cd9655d7 64 *
yihui 1:a607cd9655d7 65 * @note If the negotiation procedure should be triggered when notification/indication of
yihui 1:a607cd9655d7 66 * any characteristic is enabled by the peer, then this function must be called after
yihui 1:a607cd9655d7 67 * having initialized the services.
yihui 1:a607cd9655d7 68 *
yihui 1:a607cd9655d7 69 * @param[in] p_init This contains information needed to initialize this module.
yihui 1:a607cd9655d7 70 *
yihui 1:a607cd9655d7 71 * @return NRF_SUCCESS on successful initialization, otherwise an error code.
yihui 1:a607cd9655d7 72 */
yihui 1:a607cd9655d7 73 uint32_t ble_conn_params_init(const ble_conn_params_init_t * p_init);
yihui 1:a607cd9655d7 74
yihui 1:a607cd9655d7 75 /**@brief Function for stopping the Connection Parameters module.
yihui 1:a607cd9655d7 76 *
yihui 1:a607cd9655d7 77 * @details This function is intended to be used by the application to clean up the connection
yihui 1:a607cd9655d7 78 * parameters update module. This will stop the connection parameters update timer if
yihui 1:a607cd9655d7 79 * running, thereby preventing any impending connection parameters update procedure. This
yihui 1:a607cd9655d7 80 * function must be called by the application when it needs to clean itself up (for
yihui 1:a607cd9655d7 81 * example, before disabling the bluetooth SoftDevice) so that an unwanted timer expiry
yihui 1:a607cd9655d7 82 * event can be avoided.
yihui 1:a607cd9655d7 83 *
yihui 1:a607cd9655d7 84 * @return NRF_SUCCESS on successful initialization, otherwise an error code.
yihui 1:a607cd9655d7 85 */
yihui 1:a607cd9655d7 86 uint32_t ble_conn_params_stop(void);
yihui 1:a607cd9655d7 87
yihui 1:a607cd9655d7 88 /**@brief Function for changing the current connection parameters to a new set.
yihui 1:a607cd9655d7 89 *
yihui 1:a607cd9655d7 90 * @details Use this function to change the connection parameters to a new set of parameter
yihui 1:a607cd9655d7 91 * (ie different from the ones given at init of the module).
yihui 1:a607cd9655d7 92 * This function is usefull for scenario where most of the time the application
yihui 1:a607cd9655d7 93 * needs a relatively big connection interval, and just sometimes, for a temporary
yihui 1:a607cd9655d7 94 * period requires shorter connection interval, for example to transfer a higher
yihui 1:a607cd9655d7 95 * amount of data.
yihui 1:a607cd9655d7 96 * If the given parameters does not match the current connection's parameters
yihui 1:a607cd9655d7 97 * this function initiates a new negotiation.
yihui 1:a607cd9655d7 98 *
yihui 1:a607cd9655d7 99 * @param[in] new_params This contains the new connections parameters to setup.
yihui 1:a607cd9655d7 100 *
yihui 1:a607cd9655d7 101 * @return NRF_SUCCESS on successful initialization, otherwise an error code.
yihui 1:a607cd9655d7 102 */
yihui 1:a607cd9655d7 103 uint32_t ble_conn_params_change_conn_params(ble_gap_conn_params_t *new_params);
yihui 1:a607cd9655d7 104
yihui 1:a607cd9655d7 105 /**@brief Function for handling the Application's BLE Stack events.
yihui 1:a607cd9655d7 106 *
yihui 1:a607cd9655d7 107 * @details Handles all events from the BLE stack that are of interest to this module.
yihui 1:a607cd9655d7 108 *
yihui 1:a607cd9655d7 109 * @param[in] p_ble_evt The event received from the BLE stack.
yihui 1:a607cd9655d7 110 */
yihui 1:a607cd9655d7 111 void ble_conn_params_on_ble_evt(ble_evt_t * p_ble_evt);
yihui 1:a607cd9655d7 112
yihui 1:a607cd9655d7 113 #endif // BLE_CONN_PARAMS_H__
yihui 1:a607cd9655d7 114
yihui 1:a607cd9655d7 115 /** @} */
yihui 1:a607cd9655d7 116
yihui 1:a607cd9655d7 117 #ifdef __cplusplus
yihui 1:a607cd9655d7 118 }
yihui 1:a607cd9655d7 119 #endif // #ifdef __cplusplus