The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
Dependents: hello SerialTestv11 SerialTestv12 Sierpinski ... more
mbed 2
This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.
TARGET_SDT51822B/TOOLCHAIN_ARM_STD/dfu_app_handler.h@172:65be27845400, 2019-02-20 (annotated)
- Committer:
- AnnaBridge
- Date:
- Wed Feb 20 20:53:29 2019 +0000
- Revision:
- 172:65be27845400
- Parent:
- 171:3a7713b1edbc
mbed library release version 165
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Kojto | 148:fd96258d940d | 1 | /* |
Kojto | 148:fd96258d940d | 2 | * Copyright (c) 2014 Nordic Semiconductor ASA |
Kojto | 148:fd96258d940d | 3 | * All rights reserved. |
Kojto | 148:fd96258d940d | 4 | * |
Kojto | 148:fd96258d940d | 5 | * Redistribution and use in source and binary forms, with or without modification, |
Kojto | 148:fd96258d940d | 6 | * are permitted provided that the following conditions are met: |
Kojto | 148:fd96258d940d | 7 | * |
Kojto | 148:fd96258d940d | 8 | * 1. Redistributions of source code must retain the above copyright notice, this list |
Kojto | 148:fd96258d940d | 9 | * of conditions and the following disclaimer. |
Kojto | 148:fd96258d940d | 10 | * |
Kojto | 148:fd96258d940d | 11 | * 2. Redistributions in binary form, except as embedded into a Nordic Semiconductor ASA |
Kojto | 148:fd96258d940d | 12 | * integrated circuit in a product or a software update for such product, must reproduce |
Kojto | 148:fd96258d940d | 13 | * the above copyright notice, this list of conditions and the following disclaimer in |
Kojto | 148:fd96258d940d | 14 | * the documentation and/or other materials provided with the distribution. |
Kojto | 148:fd96258d940d | 15 | * |
Kojto | 148:fd96258d940d | 16 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of its contributors may be |
Kojto | 148:fd96258d940d | 17 | * used to endorse or promote products derived from this software without specific prior |
Kojto | 148:fd96258d940d | 18 | * written permission. |
Kojto | 148:fd96258d940d | 19 | * |
Kojto | 148:fd96258d940d | 20 | * 4. This software, with or without modification, must only be used with a |
Kojto | 148:fd96258d940d | 21 | * Nordic Semiconductor ASA integrated circuit. |
Kojto | 148:fd96258d940d | 22 | * |
Kojto | 148:fd96258d940d | 23 | * 5. Any software provided in binary or object form under this license must not be reverse |
Kojto | 148:fd96258d940d | 24 | * engineered, decompiled, modified and/or disassembled. |
Kojto | 148:fd96258d940d | 25 | * |
Kojto | 148:fd96258d940d | 26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
Kojto | 148:fd96258d940d | 27 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
Kojto | 148:fd96258d940d | 28 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
Kojto | 148:fd96258d940d | 29 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
Kojto | 148:fd96258d940d | 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
Kojto | 148:fd96258d940d | 31 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
Kojto | 148:fd96258d940d | 32 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
Kojto | 148:fd96258d940d | 33 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
Kojto | 148:fd96258d940d | 34 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
Kojto | 148:fd96258d940d | 35 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Kojto | 148:fd96258d940d | 36 | * |
Kojto | 148:fd96258d940d | 37 | */ |
Kojto | 148:fd96258d940d | 38 | |
Kojto | 148:fd96258d940d | 39 | |
Kojto | 148:fd96258d940d | 40 | /** @file |
Kojto | 148:fd96258d940d | 41 | * |
Kojto | 148:fd96258d940d | 42 | * @defgroup nrf_dfu_app_handler DFU BLE packet handling in application |
Kojto | 148:fd96258d940d | 43 | * @{ |
Kojto | 148:fd96258d940d | 44 | * |
Kojto | 148:fd96258d940d | 45 | * @brief Handling of DFU BLE packets in the application. |
Kojto | 148:fd96258d940d | 46 | * |
Kojto | 148:fd96258d940d | 47 | * @details This module implements the handling of DFU packets for switching |
Kojto | 148:fd96258d940d | 48 | * from an application to the bootloader and start DFU mode. The DFU |
Kojto | 148:fd96258d940d | 49 | * packets are transmitted over BLE. |
Kojto | 148:fd96258d940d | 50 | * This module handles only the StartDFU packet, which allows a BLE |
Kojto | 148:fd96258d940d | 51 | * application to expose support for the DFU Service. |
Kojto | 148:fd96258d940d | 52 | * The actual DFU Service runs in a dedicated environment after a BLE |
Kojto | 148:fd96258d940d | 53 | * disconnect and reset of the \nRFXX device. |
Kojto | 148:fd96258d940d | 54 | * The host must reconnect and continue the update procedure with |
Kojto | 148:fd96258d940d | 55 | * access to the full DFU Service. |
Kojto | 148:fd96258d940d | 56 | * |
Kojto | 148:fd96258d940d | 57 | * @note The application must propagate DFU events to this module by calling |
Kojto | 148:fd96258d940d | 58 | * @ref dfu_app_on_dfu_evt from the @ref ble_dfu_evt_handler_t callback. |
Kojto | 148:fd96258d940d | 59 | */ |
Kojto | 148:fd96258d940d | 60 | |
Kojto | 148:fd96258d940d | 61 | #ifndef DFU_APP_HANDLER_H__ |
Kojto | 148:fd96258d940d | 62 | #define DFU_APP_HANDLER_H__ |
Kojto | 148:fd96258d940d | 63 | |
Kojto | 148:fd96258d940d | 64 | #include "ble_dfu.h" |
Kojto | 148:fd96258d940d | 65 | #include "nrf_svc.h" |
Kojto | 148:fd96258d940d | 66 | #include "bootloader_types.h" |
Kojto | 148:fd96258d940d | 67 | #include "device_manager.h" |
Kojto | 148:fd96258d940d | 68 | |
Kojto | 148:fd96258d940d | 69 | #define DFU_APP_ATT_TABLE_POS 0 /**< Position for the ATT table changed setting. */ |
Kojto | 148:fd96258d940d | 70 | #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. */ |
Kojto | 148:fd96258d940d | 71 | |
Kojto | 148:fd96258d940d | 72 | /**@brief DFU application reset_prepare function. This function is a callback that allows the |
Kojto | 148:fd96258d940d | 73 | * application to prepare for an upcoming application reset. |
Kojto | 148:fd96258d940d | 74 | */ |
Kojto | 148:fd96258d940d | 75 | typedef void (*dfu_app_reset_prepare_t)(void); |
Kojto | 148:fd96258d940d | 76 | |
Kojto | 148:fd96258d940d | 77 | /**@brief Function for handling events from the DFU Service. |
Kojto | 148:fd96258d940d | 78 | * |
Kojto | 148:fd96258d940d | 79 | * @details The application must inject this function into the DFU Service or propagate DFU events |
Kojto | 148:fd96258d940d | 80 | * to the dfu_app_handler module by calling this function in the application-specific DFU event |
Kojto | 148:fd96258d940d | 81 | * handler. |
Kojto | 148:fd96258d940d | 82 | * |
Kojto | 148:fd96258d940d | 83 | * @param[in] p_dfu Pointer to the DFU Service structure to which the include event relates. |
Kojto | 148:fd96258d940d | 84 | * @param[in] p_evt Pointer to the DFU event. |
Kojto | 148:fd96258d940d | 85 | */ |
Kojto | 148:fd96258d940d | 86 | void dfu_app_on_dfu_evt(ble_dfu_t * p_dfu, ble_dfu_evt_t * p_evt); |
Kojto | 148:fd96258d940d | 87 | |
Kojto | 148:fd96258d940d | 88 | /**@brief Function for registering a function to prepare a reset. |
Kojto | 148:fd96258d940d | 89 | * |
Kojto | 148:fd96258d940d | 90 | * @details The provided function is executed before resetting the system into bootloader/DFU |
Kojto | 148:fd96258d940d | 91 | * mode. By registering this function, the caller is notified before the reset and can |
Kojto | 148:fd96258d940d | 92 | * thus prepare the application for reset. For example, the application can gracefully |
Kojto | 148:fd96258d940d | 93 | * disconnect any peers on BLE, turn of LEDS, ensure that all pending flash operations |
Kojto | 148:fd96258d940d | 94 | * have completed, and so on. |
Kojto | 148:fd96258d940d | 95 | * |
Kojto | 148:fd96258d940d | 96 | * @param[in] reset_prepare_func Function to be executed before a reset. |
Kojto | 148:fd96258d940d | 97 | */ |
Kojto | 148:fd96258d940d | 98 | void dfu_app_reset_prepare_set(dfu_app_reset_prepare_t reset_prepare_func); |
Kojto | 148:fd96258d940d | 99 | |
Kojto | 148:fd96258d940d | 100 | /**@brief Function for setting the Device Manager application instance. |
Kojto | 148:fd96258d940d | 101 | * |
Kojto | 148:fd96258d940d | 102 | * @details This function allows to set the @ref dm_application_instance_t value that is returned by the |
Kojto | 148:fd96258d940d | 103 | * Device Manager when the application registers using @ref dm_register. |
Kojto | 148:fd96258d940d | 104 | * If this function is not called, it is not be possible to share bonding information |
Kojto | 148:fd96258d940d | 105 | * from the application to the bootloader/DFU when entering DFU mode. |
Kojto | 148:fd96258d940d | 106 | * |
Kojto | 148:fd96258d940d | 107 | * @param[in] app_instance Value for the application instance in use. |
Kojto | 148:fd96258d940d | 108 | */ |
Kojto | 148:fd96258d940d | 109 | void dfu_app_dm_appl_instance_set(dm_application_instance_t app_instance); |
Kojto | 148:fd96258d940d | 110 | |
Kojto | 148:fd96258d940d | 111 | #endif // DFU_APP_HANDLER_H__ |
Kojto | 148:fd96258d940d | 112 | |
Kojto | 148:fd96258d940d | 113 | /** @} */ |