Nordic nrf51 sdk sources. Mirrored from https://github.com/ARMmbed/nrf51-sdk.

Dependents:   nRF51822 nRF51822

Committer:
vcoubard
Date:
Thu Apr 07 17:37:56 2016 +0100
Revision:
28:041dac1366b2
Parent:
20:a90c48eb1d30
Child:
29:286940b7ee5a
Synchronized with git rev 012b8118
Author: Liyou Zhou
Pull in files from sdk 10.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vcoubard 28:041dac1366b2 1 /* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved.
vcoubard 28:041dac1366b2 2 *
vcoubard 28:041dac1366b2 3 * The information contained herein is property of Nordic Semiconductor ASA.
vcoubard 28:041dac1366b2 4 * Terms and conditions of usage are described in detail in NORDIC
vcoubard 28:041dac1366b2 5 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
vcoubard 28:041dac1366b2 6 *
vcoubard 28:041dac1366b2 7 * Licensees are granted free, non-transferable use of the information. NO
vcoubard 28:041dac1366b2 8 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
vcoubard 28:041dac1366b2 9 * the file.
vcoubard 28:041dac1366b2 10 *
vcoubard 1:ebc0e0ef0a11 11 */
vcoubard 1:ebc0e0ef0a11 12
vcoubard 1:ebc0e0ef0a11 13 /** @file
vcoubard 1:ebc0e0ef0a11 14 *
vcoubard 1:ebc0e0ef0a11 15 * @defgroup nrf_dfu_app_handler DFU BLE packet handling in application
vcoubard 1:ebc0e0ef0a11 16 * @{
vcoubard 1:ebc0e0ef0a11 17 *
vcoubard 1:ebc0e0ef0a11 18 * @brief Handling of DFU BLE packets in the application.
vcoubard 1:ebc0e0ef0a11 19 *
vcoubard 1:ebc0e0ef0a11 20 * @details This module implements the handling of DFU packets for switching
vcoubard 1:ebc0e0ef0a11 21 * from an application to the bootloader and start DFU mode. The DFU
vcoubard 1:ebc0e0ef0a11 22 * packets are transmitted over BLE.
vcoubard 1:ebc0e0ef0a11 23 * This module handles only the StartDFU packet, which allows a BLE
vcoubard 1:ebc0e0ef0a11 24 * application to expose support for the DFU Service.
vcoubard 1:ebc0e0ef0a11 25 * The actual DFU Service runs in a dedicated environment after a BLE
vcoubard 28:041dac1366b2 26 * disconnect and reset of the \nRFXX device.
vcoubard 1:ebc0e0ef0a11 27 * The host must reconnect and continue the update procedure with
vcoubard 1:ebc0e0ef0a11 28 * access to the full DFU Service.
vcoubard 1:ebc0e0ef0a11 29 *
vcoubard 1:ebc0e0ef0a11 30 * @note The application must propagate DFU events to this module by calling
vcoubard 1:ebc0e0ef0a11 31 * @ref dfu_app_on_dfu_evt from the @ref ble_dfu_evt_handler_t callback.
vcoubard 1:ebc0e0ef0a11 32 */
vcoubard 1:ebc0e0ef0a11 33
vcoubard 1:ebc0e0ef0a11 34 #ifndef DFU_APP_HANDLER_H__
vcoubard 1:ebc0e0ef0a11 35 #define DFU_APP_HANDLER_H__
vcoubard 1:ebc0e0ef0a11 36
vcoubard 1:ebc0e0ef0a11 37 #include "ble_dfu.h"
vcoubard 1:ebc0e0ef0a11 38 #include "nrf_svc.h"
vcoubard 1:ebc0e0ef0a11 39 #include "bootloader_types.h"
vcoubard 1:ebc0e0ef0a11 40 #include "device_manager.h"
vcoubard 1:ebc0e0ef0a11 41
vcoubard 1:ebc0e0ef0a11 42 #define DFU_APP_ATT_TABLE_POS 0 /**< Position for the ATT table changed setting. */
vcoubard 1:ebc0e0ef0a11 43 #define DFU_APP_ATT_TABLE_CHANGED 1 /**< Value indicating that the ATT table might have changed. This value will be set in the application-specific context in Device Manager when entering DFU mode. */
vcoubard 1:ebc0e0ef0a11 44
vcoubard 1:ebc0e0ef0a11 45 /**@brief DFU application reset_prepare function. This function is a callback that allows the
vcoubard 1:ebc0e0ef0a11 46 * application to prepare for an upcoming application reset.
vcoubard 1:ebc0e0ef0a11 47 */
vcoubard 1:ebc0e0ef0a11 48 typedef void (*dfu_app_reset_prepare_t)(void);
vcoubard 1:ebc0e0ef0a11 49
vcoubard 1:ebc0e0ef0a11 50 /**@brief Function for handling events from the DFU Service.
vcoubard 1:ebc0e0ef0a11 51 *
vcoubard 1:ebc0e0ef0a11 52 * @details The application must inject this function into the DFU Service or propagate DFU events
vcoubard 1:ebc0e0ef0a11 53 * to the dfu_app_handler module by calling this function in the application-specific DFU event
vcoubard 1:ebc0e0ef0a11 54 * handler.
vcoubard 1:ebc0e0ef0a11 55 *
vcoubard 1:ebc0e0ef0a11 56 * @param[in] p_dfu Pointer to the DFU Service structure to which the include event relates.
vcoubard 1:ebc0e0ef0a11 57 * @param[in] p_evt Pointer to the DFU event.
vcoubard 1:ebc0e0ef0a11 58 */
vcoubard 1:ebc0e0ef0a11 59 void dfu_app_on_dfu_evt(ble_dfu_t * p_dfu, ble_dfu_evt_t * p_evt);
vcoubard 1:ebc0e0ef0a11 60
vcoubard 1:ebc0e0ef0a11 61 /**@brief Function for registering a function to prepare a reset.
vcoubard 1:ebc0e0ef0a11 62 *
vcoubard 1:ebc0e0ef0a11 63 * @details The provided function is executed before resetting the system into bootloader/DFU
vcoubard 1:ebc0e0ef0a11 64 * mode. By registering this function, the caller is notified before the reset and can
vcoubard 1:ebc0e0ef0a11 65 * thus prepare the application for reset. For example, the application can gracefully
vcoubard 1:ebc0e0ef0a11 66 * disconnect any peers on BLE, turn of LEDS, ensure that all pending flash operations
vcoubard 1:ebc0e0ef0a11 67 * have completed, and so on.
vcoubard 1:ebc0e0ef0a11 68 *
vcoubard 1:ebc0e0ef0a11 69 * @param[in] reset_prepare_func Function to be executed before a reset.
vcoubard 1:ebc0e0ef0a11 70 */
vcoubard 1:ebc0e0ef0a11 71 void dfu_app_reset_prepare_set(dfu_app_reset_prepare_t reset_prepare_func);
vcoubard 1:ebc0e0ef0a11 72
vcoubard 1:ebc0e0ef0a11 73 /**@brief Function for setting the Device Manager application instance.
vcoubard 1:ebc0e0ef0a11 74 *
vcoubard 1:ebc0e0ef0a11 75 * @details This function allows to set the @ref dm_application_instance_t value that is returned by the
vcoubard 1:ebc0e0ef0a11 76 * Device Manager when the application registers using @ref dm_register.
vcoubard 1:ebc0e0ef0a11 77 * If this function is not called, it is not be possible to share bonding information
vcoubard 1:ebc0e0ef0a11 78 * from the application to the bootloader/DFU when entering DFU mode.
vcoubard 1:ebc0e0ef0a11 79 *
vcoubard 1:ebc0e0ef0a11 80 * @param[in] app_instance Value for the application instance in use.
vcoubard 1:ebc0e0ef0a11 81 */
vcoubard 1:ebc0e0ef0a11 82 void dfu_app_dm_appl_instance_set(dm_application_instance_t app_instance);
vcoubard 1:ebc0e0ef0a11 83
vcoubard 1:ebc0e0ef0a11 84 #endif // DFU_APP_HANDLER_H__
vcoubard 1:ebc0e0ef0a11 85
vcoubard 1:ebc0e0ef0a11 86 /** @} */