Nordic nrf51 sdk sources. Mirrored from https://github.com/ARMmbed/nrf51-sdk.

Dependents:   nRF51822 nRF51822

Committer:
vcoubard
Date:
Thu Apr 07 17:37:49 2016 +0100
Revision:
24:2aea0c1c57ee
Parent:
22:67a8d2c0bbbf
Child:
27:0fe148f1bca3
Synchronized with git rev 709d3cdb
Author: Liyou Zhou
Change version number in README

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vcoubard 20:a90c48eb1d30 1 /*
vcoubard 20:a90c48eb1d30 2 * Copyright (c) Nordic Semiconductor ASA
vcoubard 20:a90c48eb1d30 3 * All rights reserved.
vcoubard 20:a90c48eb1d30 4 *
vcoubard 20:a90c48eb1d30 5 * Redistribution and use in source and binary forms, with or without modification,
vcoubard 20:a90c48eb1d30 6 * are permitted provided that the following conditions are met:
vcoubard 20:a90c48eb1d30 7 *
vcoubard 20:a90c48eb1d30 8 * 1. Redistributions of source code must retain the above copyright notice, this
vcoubard 20:a90c48eb1d30 9 * list of conditions and the following disclaimer.
vcoubard 20:a90c48eb1d30 10 *
vcoubard 20:a90c48eb1d30 11 * 2. Redistributions in binary form must reproduce the above copyright notice, this
vcoubard 20:a90c48eb1d30 12 * list of conditions and the following disclaimer in the documentation and/or
vcoubard 20:a90c48eb1d30 13 * other materials provided with the distribution.
vcoubard 20:a90c48eb1d30 14 *
vcoubard 20:a90c48eb1d30 15 * 3. Neither the name of Nordic Semiconductor ASA nor the names of other
vcoubard 20:a90c48eb1d30 16 * contributors to this software may be used to endorse or promote products
vcoubard 20:a90c48eb1d30 17 * derived from this software without specific prior written permission.
vcoubard 20:a90c48eb1d30 18 *
vcoubard 20:a90c48eb1d30 19 *
vcoubard 20:a90c48eb1d30 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
vcoubard 20:a90c48eb1d30 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
vcoubard 20:a90c48eb1d30 22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
vcoubard 20:a90c48eb1d30 23 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
vcoubard 20:a90c48eb1d30 24 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
vcoubard 20:a90c48eb1d30 25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
vcoubard 20:a90c48eb1d30 26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
vcoubard 20:a90c48eb1d30 27 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
vcoubard 20:a90c48eb1d30 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
vcoubard 20:a90c48eb1d30 29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
vcoubard 20:a90c48eb1d30 30 *
Vincent Coubard 0:f2542974c862 31 */
Vincent Coubard 0:f2542974c862 32
Vincent Coubard 0:f2542974c862 33 /**@file
Vincent Coubard 0:f2542974c862 34 *
Vincent Coubard 0:f2542974c862 35 * @defgroup ble_sdk_srv_dfu Device Firmware Update Service
Vincent Coubard 0:f2542974c862 36 * @{
Vincent Coubard 0:f2542974c862 37 * @ingroup ble_sdk_srv
Vincent Coubard 0:f2542974c862 38 * @brief Device Firmware Update Service
Vincent Coubard 0:f2542974c862 39 *
Vincent Coubard 0:f2542974c862 40 * @details The Device Firmware Update (DFU) service is a GATT based service that can be used for
Vincent Coubard 0:f2542974c862 41 * performing firmware updates over BLE. Note that this implementation uses vendor
Vincent Coubard 0:f2542974c862 42 * specific UUIDs for service and characteristics and is intended to demonstrate the
vcoubard 1:ebc0e0ef0a11 43 * firmware updates over BLE. Refer @ref bledfu_transport_bleservice and @ref
vcoubard 1:ebc0e0ef0a11 44 * bledfu_transport_bleprofile for more information on the service and profile respectively.
Vincent Coubard 0:f2542974c862 45 */
Vincent Coubard 0:f2542974c862 46
Vincent Coubard 0:f2542974c862 47 #ifndef BLE_DFU_H__
Vincent Coubard 0:f2542974c862 48 #define BLE_DFU_H__
Vincent Coubard 0:f2542974c862 49
Vincent Coubard 0:f2542974c862 50 #include <stdint.h>
Vincent Coubard 0:f2542974c862 51 #include "ble_gatts.h"
Vincent Coubard 0:f2542974c862 52 #include "ble_gap.h"
Vincent Coubard 0:f2542974c862 53 #include "ble.h"
Vincent Coubard 0:f2542974c862 54 #include "ble_srv_common.h"
Vincent Coubard 0:f2542974c862 55
Vincent Coubard 0:f2542974c862 56 #define BLE_DFU_SERVICE_UUID 0x1530 /**< The UUID of the DFU Service. */
Vincent Coubard 0:f2542974c862 57 #define BLE_DFU_PKT_CHAR_UUID 0x1532 /**< The UUID of the DFU Packet Characteristic. */
Vincent Coubard 0:f2542974c862 58 #define BLE_DFU_CTRL_PT_UUID 0x1531 /**< The UUID of the DFU Control Point. */
Vincent Coubard 0:f2542974c862 59 #define BLE_DFU_STATUS_REP_UUID 0x1533 /**< The UUID of the DFU Status Report Characteristic. */
Vincent Coubard 0:f2542974c862 60 #define BLE_DFU_REV_CHAR_UUID 0x1534 /**< The UUID of the DFU Revision Characteristic. */
Vincent Coubard 0:f2542974c862 61
Vincent Coubard 0:f2542974c862 62 /**@brief DFU Event type.
Vincent Coubard 0:f2542974c862 63 *
Vincent Coubard 0:f2542974c862 64 * @details This enumeration contains the types of events that will be received from the DFU Service.
Vincent Coubard 0:f2542974c862 65 */
Vincent Coubard 0:f2542974c862 66 typedef enum
Vincent Coubard 0:f2542974c862 67 {
Vincent Coubard 0:f2542974c862 68 BLE_DFU_START, /**< The event indicating that the peer wants the application to prepare for a new firmware update. */
Vincent Coubard 0:f2542974c862 69 BLE_DFU_RECEIVE_INIT_DATA, /**< The event indicating that the peer wants the application to prepare to receive init parameters. */
Vincent Coubard 0:f2542974c862 70 BLE_DFU_RECEIVE_APP_DATA, /**< The event indicating that the peer wants the application to prepare to receive the new firmware image. */
Vincent Coubard 0:f2542974c862 71 BLE_DFU_VALIDATE, /**< The event indicating that the peer wants the application to validate the newly received firmware image. */
Vincent Coubard 0:f2542974c862 72 BLE_DFU_ACTIVATE_N_RESET, /**< The event indicating that the peer wants the application to undergo activate new firmware and restart with new valid application */
Vincent Coubard 0:f2542974c862 73 BLE_DFU_SYS_RESET, /**< The event indicating that the peer wants the application to undergo a reset and start the currently valid application image.*/
Vincent Coubard 0:f2542974c862 74 BLE_DFU_PKT_RCPT_NOTIF_ENABLED, /**< The event indicating that the peer has enabled packet receipt notifications. It is the responsibility of the application to call @ref ble_dfu_pkts_rcpt_notify each time the number of packets indicated by num_of_pkts field in @ref ble_dfu_evt_t is received.*/
Vincent Coubard 0:f2542974c862 75 BLE_DFU_PKT_RCPT_NOTIF_DISABLED, /**< The event indicating that the peer has disabled the packet receipt notifications.*/
Vincent Coubard 0:f2542974c862 76 BLE_DFU_PACKET_WRITE, /**< The event indicating that the peer has written a value to the 'DFU Packet' characteristic. The data received from the peer will be present in the @ref BLE_DFU_PACKET_WRITE element contained within @ref ble_dfu_evt_t.*/
Vincent Coubard 0:f2542974c862 77 BLE_DFU_BYTES_RECEIVED_SEND /**< The event indicating that the peer is requesting for the number of bytes of firmware data last received by the application. It is the responsibility of the application to call @ref ble_dfu_pkts_rcpt_notify in response to this event. */
Vincent Coubard 0:f2542974c862 78 } ble_dfu_evt_type_t;
Vincent Coubard 0:f2542974c862 79
Vincent Coubard 0:f2542974c862 80 /**@brief DFU Procedure type.
Vincent Coubard 0:f2542974c862 81 *
Vincent Coubard 0:f2542974c862 82 * @details This enumeration contains the types of DFU procedures.
Vincent Coubard 0:f2542974c862 83 */
Vincent Coubard 0:f2542974c862 84 typedef enum
Vincent Coubard 0:f2542974c862 85 {
Vincent Coubard 0:f2542974c862 86 BLE_DFU_START_PROCEDURE = 1, /**< DFU Start procedure.*/
Vincent Coubard 0:f2542974c862 87 BLE_DFU_INIT_PROCEDURE = 2, /**< DFU Initialization procedure.*/
Vincent Coubard 0:f2542974c862 88 BLE_DFU_RECEIVE_APP_PROCEDURE = 3, /**< Firmware receiving procedure.*/
Vincent Coubard 0:f2542974c862 89 BLE_DFU_VALIDATE_PROCEDURE = 4, /**< Firmware image validation procedure .*/
Vincent Coubard 0:f2542974c862 90 BLE_DFU_PKT_RCPT_REQ_PROCEDURE = 8 /**< Packet receipt notification request procedure. */
Vincent Coubard 0:f2542974c862 91 } ble_dfu_procedure_t;
Vincent Coubard 0:f2542974c862 92
Vincent Coubard 0:f2542974c862 93 /**@brief DFU Response value type.
Vincent Coubard 0:f2542974c862 94 */
Vincent Coubard 0:f2542974c862 95 typedef enum
Vincent Coubard 0:f2542974c862 96 {
Vincent Coubard 0:f2542974c862 97 BLE_DFU_RESP_VAL_SUCCESS = 1, /**< Success.*/
Vincent Coubard 0:f2542974c862 98 BLE_DFU_RESP_VAL_INVALID_STATE, /**< Invalid state.*/
Vincent Coubard 0:f2542974c862 99 BLE_DFU_RESP_VAL_NOT_SUPPORTED, /**< Operation not supported.*/
Vincent Coubard 0:f2542974c862 100 BLE_DFU_RESP_VAL_DATA_SIZE, /**< Data size exceeds limit.*/
Vincent Coubard 0:f2542974c862 101 BLE_DFU_RESP_VAL_CRC_ERROR, /**< CRC Error.*/
Vincent Coubard 0:f2542974c862 102 BLE_DFU_RESP_VAL_OPER_FAILED /**< Operation failed.*/
Vincent Coubard 0:f2542974c862 103 } ble_dfu_resp_val_t;
Vincent Coubard 0:f2542974c862 104
Vincent Coubard 0:f2542974c862 105
Vincent Coubard 0:f2542974c862 106 /**@brief DFU Packet structure.
Vincent Coubard 0:f2542974c862 107 *
Vincent Coubard 0:f2542974c862 108 * @details This structure contains the value of the DFU Packet characteristic as written by the
Vincent Coubard 0:f2542974c862 109 * peer and the length of the value written. It will be filled by the DFU Service when the
Vincent Coubard 0:f2542974c862 110 * peer writes to the DFU Packet characteristic.
Vincent Coubard 0:f2542974c862 111 */
Vincent Coubard 0:f2542974c862 112 typedef struct
Vincent Coubard 0:f2542974c862 113 {
vcoubard 24:2aea0c1c57ee 114 uint8_t * p_data; /**< Pointer to the received packet. This will point to a word aligned memory location.*/
vcoubard 22:67a8d2c0bbbf 115 uint8_t len; /**< Length of the packet received. */
Vincent Coubard 0:f2542974c862 116 } ble_dfu_pkt_write_t;
Vincent Coubard 0:f2542974c862 117
Vincent Coubard 0:f2542974c862 118 /**@brief Packet receipt notification request structure.
Vincent Coubard 0:f2542974c862 119 *
Vincent Coubard 0:f2542974c862 120 * @details This structure contains the contents of the packet receipt notification request
Vincent Coubard 0:f2542974c862 121 * sent by the DFU Controller.
Vincent Coubard 0:f2542974c862 122 */
Vincent Coubard 0:f2542974c862 123 typedef struct
Vincent Coubard 0:f2542974c862 124 {
Vincent Coubard 0:f2542974c862 125 uint16_t num_of_pkts; /**< The number of packets of firmware data to be received by application before sending the next Packet Receipt Notification to the peer. */
Vincent Coubard 0:f2542974c862 126 } ble_pkt_rcpt_notif_req_t;
Vincent Coubard 0:f2542974c862 127
Vincent Coubard 0:f2542974c862 128 /**@brief DFU Event structure.
Vincent Coubard 0:f2542974c862 129 *
Vincent Coubard 0:f2542974c862 130 * @details This structure contains the event generated by the DFU Service based on the data
Vincent Coubard 0:f2542974c862 131 * received from the peer.
Vincent Coubard 0:f2542974c862 132 */
Vincent Coubard 0:f2542974c862 133 typedef struct
Vincent Coubard 0:f2542974c862 134 {
Vincent Coubard 0:f2542974c862 135 ble_dfu_evt_type_t ble_dfu_evt_type; /**< Type of the event.*/
Vincent Coubard 0:f2542974c862 136 union
Vincent Coubard 0:f2542974c862 137 {
Vincent Coubard 0:f2542974c862 138 ble_dfu_pkt_write_t ble_dfu_pkt_write; /**< The DFU packet received. This field is when the @ref ble_dfu_evt_type field is set to @ref BLE_DFU_PACKET_WRITE.*/
Vincent Coubard 0:f2542974c862 139 ble_pkt_rcpt_notif_req_t pkt_rcpt_notif_req; /**< Packet receipt notification request. This field is when the @ref ble_dfu_evt_type field is set to @ref BLE_DFU_PKT_RCPT_NOTIF_ENABLED.*/
Vincent Coubard 0:f2542974c862 140 } evt;
Vincent Coubard 0:f2542974c862 141 } ble_dfu_evt_t;
Vincent Coubard 0:f2542974c862 142
Vincent Coubard 0:f2542974c862 143 // Forward declaration of the ble_dfu_t type.
Vincent Coubard 0:f2542974c862 144 typedef struct ble_dfu_s ble_dfu_t;
Vincent Coubard 0:f2542974c862 145
Vincent Coubard 0:f2542974c862 146 /**@brief DFU Service event handler type. */
Vincent Coubard 0:f2542974c862 147 typedef void (*ble_dfu_evt_handler_t) (ble_dfu_t * p_dfu, ble_dfu_evt_t * p_evt);
Vincent Coubard 0:f2542974c862 148
Vincent Coubard 0:f2542974c862 149 /**@brief DFU service structure.
Vincent Coubard 0:f2542974c862 150 *
Vincent Coubard 0:f2542974c862 151 * @details This structure contains status information related to the service.
Vincent Coubard 0:f2542974c862 152 */
Vincent Coubard 0:f2542974c862 153 struct ble_dfu_s
Vincent Coubard 0:f2542974c862 154 {
Vincent Coubard 0:f2542974c862 155 uint16_t conn_handle; /**< Handle of the current connection (as provided by the S110 SoftDevice). This will be BLE_CONN_HANDLE_INVALID when not in a connection. */
Vincent Coubard 0:f2542974c862 156 uint16_t revision; /**< Handle of DFU Service (as provided by the S110 SoftDevice). */
Vincent Coubard 0:f2542974c862 157 uint16_t service_handle; /**< Handle of DFU Service (as provided by the S110 SoftDevice). */
Vincent Coubard 0:f2542974c862 158 uint8_t uuid_type; /**< UUID type assigned for DFU Service by the S110 SoftDevice. */
Vincent Coubard 0:f2542974c862 159 ble_gatts_char_handles_t dfu_pkt_handles; /**< Handles related to the DFU Packet characteristic. */
Vincent Coubard 0:f2542974c862 160 ble_gatts_char_handles_t dfu_ctrl_pt_handles; /**< Handles related to the DFU Control Point characteristic. */
Vincent Coubard 0:f2542974c862 161 ble_gatts_char_handles_t dfu_status_rep_handles; /**< Handles related to the DFU Status Report characteristic. */
Vincent Coubard 0:f2542974c862 162 ble_gatts_char_handles_t dfu_rev_handles; /**< Handles related to the DFU Revision characteristic. */
Vincent Coubard 0:f2542974c862 163 ble_dfu_evt_handler_t evt_handler; /**< The event handler to be called when an event is to be sent to the application.*/
Vincent Coubard 0:f2542974c862 164 ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */
Vincent Coubard 0:f2542974c862 165 };
Vincent Coubard 0:f2542974c862 166
Vincent Coubard 0:f2542974c862 167 /**@brief DFU service initialization structure.
Vincent Coubard 0:f2542974c862 168 *
Vincent Coubard 0:f2542974c862 169 * @details This structure contains the initialization information for the DFU Service. The
Vincent Coubard 0:f2542974c862 170 * application needs to fill this structure and pass it to the DFU Service using the
Vincent Coubard 0:f2542974c862 171 * @ref ble_dfu_init function.
Vincent Coubard 0:f2542974c862 172 */
Vincent Coubard 0:f2542974c862 173 typedef struct
Vincent Coubard 0:f2542974c862 174 {
Vincent Coubard 0:f2542974c862 175 uint16_t revision; /**< Revision number to be exposed by the DFU service. */
Vincent Coubard 0:f2542974c862 176 ble_dfu_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Device Firmware Update Service. */
Vincent Coubard 0:f2542974c862 177 ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */
Vincent Coubard 0:f2542974c862 178 } ble_dfu_init_t;
Vincent Coubard 0:f2542974c862 179
Vincent Coubard 0:f2542974c862 180 /**@brief Function for handling a BLE event.
Vincent Coubard 0:f2542974c862 181 *
Vincent Coubard 0:f2542974c862 182 * @details The DFU service expects the application to call this function each time an event
Vincent Coubard 0:f2542974c862 183 * is received from the S110 SoftDevice. This function processes the event, if it is
Vincent Coubard 0:f2542974c862 184 * relevant for the DFU service and calls the DFU event handler of the application if
Vincent Coubard 0:f2542974c862 185 * necessary.
Vincent Coubard 0:f2542974c862 186 *
Vincent Coubard 0:f2542974c862 187 * @param[in] p_dfu Pointer to the DFU service structure.
Vincent Coubard 0:f2542974c862 188 * @param[in] p_ble_evt Pointer to the event received from S110 SoftDevice.
Vincent Coubard 0:f2542974c862 189 */
Vincent Coubard 0:f2542974c862 190 void ble_dfu_on_ble_evt(ble_dfu_t * p_dfu, ble_evt_t * p_ble_evt);
Vincent Coubard 0:f2542974c862 191
Vincent Coubard 0:f2542974c862 192 /**@brief Function for initializing the DFU service.
Vincent Coubard 0:f2542974c862 193 *
Vincent Coubard 0:f2542974c862 194 * @param[out] p_dfu Device Firmware Update service structure. This structure will have to be
Vincent Coubard 0:f2542974c862 195 * supplied by the application. It will be initialized by this function,
Vincent Coubard 0:f2542974c862 196 * and will later be used to identify the service instance.
Vincent Coubard 0:f2542974c862 197 * @param[in] p_dfu_init Information needed to initialize the service.
Vincent Coubard 0:f2542974c862 198 *
Vincent Coubard 0:f2542974c862 199 * @return NRF_SUCCESS if the DFU service and its characteristics were successfully added to the
Vincent Coubard 0:f2542974c862 200 * S110 SoftDevice. Otherwise an error code.
Vincent Coubard 0:f2542974c862 201 * This function returns NRF_ERROR_NULL if the value of evt_handler in p_dfu_init
Vincent Coubard 0:f2542974c862 202 * structure provided is NULL or if the pointers supplied as input are NULL.
Vincent Coubard 0:f2542974c862 203 */
Vincent Coubard 0:f2542974c862 204 uint32_t ble_dfu_init(ble_dfu_t * p_dfu, ble_dfu_init_t * p_dfu_init);
Vincent Coubard 0:f2542974c862 205
Vincent Coubard 0:f2542974c862 206 /**@brief Function for sending response to a control point command.
Vincent Coubard 0:f2542974c862 207 *
Vincent Coubard 0:f2542974c862 208 * @details This function will encode a DFU Control Point response using the given input
Vincent Coubard 0:f2542974c862 209 * parameters and will send a notification of the same to the peer.
Vincent Coubard 0:f2542974c862 210 *
Vincent Coubard 0:f2542974c862 211 * @param[in] p_dfu Pointer to the DFU service structure.
Vincent Coubard 0:f2542974c862 212 * @param[in] dfu_proc Procedure for which this response is to be sent.
Vincent Coubard 0:f2542974c862 213 * @param[in] resp_val Response value.
Vincent Coubard 0:f2542974c862 214 *
Vincent Coubard 0:f2542974c862 215 * @return NRF_SUCCESS if the DFU Service has successfully requested the S110 SoftDevice to
Vincent Coubard 0:f2542974c862 216 * send the notification. Otherwise an error code.
Vincent Coubard 0:f2542974c862 217 * This function returns NRF_ERROR_INVALID_STATE if the device is not connected to a
Vincent Coubard 0:f2542974c862 218 * peer or if the DFU service is not initialized or if the notification of the DFU
Vincent Coubard 0:f2542974c862 219 * Status Report characteristic was not enabled by the peer. It returns NRF_ERROR_NULL
Vincent Coubard 0:f2542974c862 220 * if the pointer p_dfu is NULL.
Vincent Coubard 0:f2542974c862 221 */
Vincent Coubard 0:f2542974c862 222 uint32_t ble_dfu_response_send(ble_dfu_t * p_dfu,
Vincent Coubard 0:f2542974c862 223 ble_dfu_procedure_t dfu_proc,
Vincent Coubard 0:f2542974c862 224 ble_dfu_resp_val_t resp_val);
Vincent Coubard 0:f2542974c862 225
Vincent Coubard 0:f2542974c862 226 /**@brief Function for notifying the peer about the number of bytes of firmware data received.
Vincent Coubard 0:f2542974c862 227 *
Vincent Coubard 0:f2542974c862 228 * @param[in] p_dfu Pointer to the DFU service structure.
Vincent Coubard 0:f2542974c862 229 * @param[in] num_of_firmware_bytes_rcvd Number of bytes.
Vincent Coubard 0:f2542974c862 230 *
Vincent Coubard 0:f2542974c862 231 * @return NRF_SUCCESS if the DFU Service has successfully requested the S110 SoftDevice to send
Vincent Coubard 0:f2542974c862 232 * the notification. Otherwise an error code.
Vincent Coubard 0:f2542974c862 233 * This function returns NRF_ERROR_INVALID_STATE if the device is not connected to a
Vincent Coubard 0:f2542974c862 234 * peer or if the DFU service is not initialized or if the notification of the DFU
Vincent Coubard 0:f2542974c862 235 * Status Report characteristic was not enabled by the peer. It returns NRF_ERROR_NULL
Vincent Coubard 0:f2542974c862 236 * if the pointer p_dfu is NULL.
Vincent Coubard 0:f2542974c862 237 */
Vincent Coubard 0:f2542974c862 238 uint32_t ble_dfu_bytes_rcvd_report(ble_dfu_t * p_dfu, uint32_t num_of_firmware_bytes_rcvd);
Vincent Coubard 0:f2542974c862 239
Vincent Coubard 0:f2542974c862 240 /**@brief Function for sending Packet Receipt Notification to the peer.
Vincent Coubard 0:f2542974c862 241 *
Vincent Coubard 0:f2542974c862 242 * This function will encode the number of bytes received as input parameter into a
Vincent Coubard 0:f2542974c862 243 * notification of the control point characteristic and send it to the peer.
Vincent Coubard 0:f2542974c862 244 *
Vincent Coubard 0:f2542974c862 245 * @param[in] p_dfu Pointer to the DFU service structure.
Vincent Coubard 0:f2542974c862 246 * @param[in] num_of_firmware_bytes_rcvd Number of bytes of firmware image received.
Vincent Coubard 0:f2542974c862 247 *
Vincent Coubard 0:f2542974c862 248 * @return NRF_SUCCESS if the DFU Service has successfully requested the S110 SoftDevice to send
Vincent Coubard 0:f2542974c862 249 * the notification. Otherwise an error code.
Vincent Coubard 0:f2542974c862 250 * This function returns NRF_ERROR_INVALID_STATE if the device is not connected to a
Vincent Coubard 0:f2542974c862 251 * peer or if the DFU service is not initialized or if the notification of the DFU
Vincent Coubard 0:f2542974c862 252 * Status Report characteristic was not enabled by the peer. It returns NRF_ERROR_NULL
Vincent Coubard 0:f2542974c862 253 * if the pointer p_dfu is NULL.
Vincent Coubard 0:f2542974c862 254 */
Vincent Coubard 0:f2542974c862 255 uint32_t ble_dfu_pkts_rcpt_notify(ble_dfu_t * p_dfu, uint32_t num_of_firmware_bytes_rcvd);
Vincent Coubard 0:f2542974c862 256
Vincent Coubard 0:f2542974c862 257 #endif // BLE_DFU_H__
Vincent Coubard 0:f2542974c862 258
vcoubard 1:ebc0e0ef0a11 259 /** @} */