dfu_app_handler.h 3.8 KB

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