Initial release

Fork of nrf51-sdk by Lancaster University

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers dfu_app_handler.h Source File

dfu_app_handler.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) Nordic Semiconductor ASA
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without modification,
00006  * are permitted provided that the following conditions are met:
00007  *
00008  *   1. Redistributions of source code must retain the above copyright notice, this
00009  *   list of conditions and the following disclaimer.
00010  *
00011  *   2. Redistributions in binary form must reproduce the above copyright notice, this
00012  *   list of conditions and the following disclaimer in the documentation and/or
00013  *   other materials provided with the distribution.
00014  *
00015  *   3. Neither the name of Nordic Semiconductor ASA nor the names of other
00016  *   contributors to this software may be used to endorse or promote products
00017  *   derived from this software without specific prior written permission.
00018  *
00019  *
00020  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00021  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00022  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00023  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
00024  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00025  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00026  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
00027  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00028  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00029  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00030  *
00031  */
00032   
00033 /** @file
00034  *
00035  * @defgroup nrf_dfu_app_handler DFU BLE packet handling in application
00036  * @{
00037  *
00038  * @brief Handling of DFU BLE packets in the application.
00039  *
00040  * @details This module implements the handling of DFU packets for switching 
00041  *          from an application to the bootloader and start DFU mode. The DFU
00042  *          packets are transmitted over BLE. 
00043  *          This module handles only the StartDFU packet, which allows a BLE 
00044  *          application to expose support for the DFU Service.
00045  *          The actual DFU Service runs in a dedicated environment after a BLE 
00046  *          disconnect and reset of the \nRFXX device. 
00047  *          The host must reconnect and continue the update procedure with 
00048  *          access to the full DFU Service.
00049  *
00050  * @note The application must propagate DFU events to this module by calling
00051  *       @ref dfu_app_on_dfu_evt from the @ref ble_dfu_evt_handler_t callback.
00052  */
00053  
00054 #ifndef DFU_APP_HANDLER_H__
00055 #define DFU_APP_HANDLER_H__
00056 
00057 #include "ble_dfu.h "
00058 #include "nrf_svc.h"
00059 #include "bootloader_types.h "
00060 #include "device_manager.h "
00061 
00062 #define DFU_APP_ATT_TABLE_POS     0                     /**< Position for the ATT table changed setting. */
00063 #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. */
00064 
00065 /**@brief DFU application reset_prepare function. This function is a callback that allows the 
00066  *        application to prepare for an upcoming application reset. 
00067  */
00068 typedef void (*dfu_app_reset_prepare_t)(void);
00069 
00070 /**@brief   Function for handling events from the DFU Service. 
00071  *
00072  * @details The application must inject this function into the DFU Service or propagate DFU events 
00073  *          to the dfu_app_handler module by calling this function in the application-specific DFU event 
00074  *          handler.
00075  * 
00076  * @param[in] p_dfu  Pointer to the DFU Service structure to which the include event relates.
00077  * @param[in] p_evt  Pointer to the DFU event.
00078  */
00079 void dfu_app_on_dfu_evt(ble_dfu_t * p_dfu, ble_dfu_evt_t * p_evt);
00080 
00081 /**@brief Function for registering a function to prepare a reset.
00082  *
00083  * @details The provided function is executed before resetting the system into bootloader/DFU
00084  *          mode. By registering this function, the caller is notified before the reset and can
00085  *          thus prepare the application for reset. For example, the application can gracefully
00086  *          disconnect any peers on BLE, turn of LEDS, ensure that all pending flash operations
00087  *          have completed, and so on.
00088  *
00089  * @param[in] reset_prepare_func  Function to be executed before a reset.
00090  */
00091 void dfu_app_reset_prepare_set(dfu_app_reset_prepare_t reset_prepare_func);
00092 
00093 /**@brief Function for setting the Device Manager application instance.
00094  *
00095  * @details This function allows to set the @ref dm_application_instance_t value that is returned by the 
00096  *          Device Manager when the application registers using @ref dm_register.
00097  *          If this function is not called, it is not be possible to share bonding information
00098  *          from the application to the bootloader/DFU when entering DFU mode.
00099  *
00100  * @param[in] app_instance Value for the application instance in use.
00101  */
00102 void dfu_app_dm_appl_instance_set(dm_application_instance_t app_instance);
00103 
00104 #endif // DFU_APP_HANDLER_H__
00105 
00106 /** @} */