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