dfu_ble_svc.h 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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_ble_svc DFU BLE SVC
  15. * @{
  16. *
  17. * @brief DFU BLE SVC in bootloader. The DFU BLE SuperVisor Calls allow an application to execute
  18. * functions in the installed bootloader.
  19. *
  20. * @details This module implements handling of SuperVisor Calls in the bootloader.
  21. * SuperVisor Calls allow for an application to execute calls into the bootloader.
  22. * Currently, it is possible to exchange bonding information (like keys) from the
  23. * application to a bootloader supporting DFU OTA using BLE, so the update process can be
  24. * done through an already existing bond.
  25. *
  26. * @note The application must make sure that all SuperVisor Calls (SVC) are forwarded to the
  27. * bootloader to ensure correct behavior. Forwarding of SVCs to the bootloader is
  28. * done using the SoftDevice SVC @ref sd_softdevice_vector_table_base_set with the value
  29. * present in @c NRF_UICR->NRFFW[0].
  30. */
  31. #ifndef DFU_BLE_SVC_H__
  32. #define DFU_BLE_SVC_H__
  33. #include "nrf_svc.h"
  34. #include <stdint.h>
  35. #include "ble_gap.h"
  36. #include "nrf.h"
  37. #include "nrf_soc.h"
  38. #include "nrf_error_sdm.h"
  39. #define BOOTLOADER_SVC_BASE 0x0 /**< The number of the lowest SVC number reserved for the bootloader. */
  40. #define SYSTEM_SERVICE_ATT_SIZE 8 /**< Size of the system service attribute length including CRC-16 at the end. */
  41. /**@brief The SVC numbers used by the SVC functions in the SoC library. */
  42. enum BOOTLOADER_SVCS
  43. {
  44. DFU_BLE_SVC_PEER_DATA_SET = BOOTLOADER_SVC_BASE, /**< SVC number for the setting of peer data call. */
  45. BOOTLOADER_SVC_LAST
  46. };
  47. /**@brief DFU Peer data structure.
  48. *
  49. * @details This structure contains peer data needed for connection to a bonded device during DFU.
  50. * The peer data must be provided by the application to the bootloader during buttonless
  51. * update. See @ref dfu_ble_svc_peer_data_set. It contains bond information about the
  52. * desired DFU peer.
  53. */
  54. typedef struct
  55. {
  56. ble_gap_addr_t addr; /**< BLE GAP address of the device that initiated the DFU process. */
  57. ble_gap_irk_t irk; /**< IRK of the device that initiated the DFU process if this device uses Private Resolvable Addresses. */
  58. ble_gap_enc_key_t enc_key; /**< Encryption key structure containing encrypted diversifier and LTK for re-establishing the bond. */
  59. uint8_t sys_serv_attr[SYSTEM_SERVICE_ATT_SIZE]; /**< System service attributes for restoring of Service Changed Indication setting in DFU mode. */
  60. } dfu_ble_peer_data_t;
  61. /**@brief SVC Function for setting peer data containing address, IRK, and LTK to establish bonded
  62. * connection in DFU mode.
  63. *
  64. * @param[in] p_peer_data Pointer to the peer data containing keys for the connection.
  65. *
  66. * @retval NRF_ERROR_NULL If a NULL pointer was provided as argument.
  67. * @retval NRF_SUCCESS If the function completed successfully.
  68. */
  69. SVCALL(DFU_BLE_SVC_PEER_DATA_SET, uint32_t, dfu_ble_svc_peer_data_set(dfu_ble_peer_data_t * p_peer_data));
  70. #endif // DFU_BLE_SVC_H__
  71. /** @} */