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_IAR/ble_dfu.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) 2013 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 ble_sdk_srv_dfu Device Firmware Update Service |
Kojto | 148:fd96258d940d | 43 | * @{ |
Kojto | 148:fd96258d940d | 44 | * @ingroup ble_sdk_srv |
Kojto | 148:fd96258d940d | 45 | * @brief Device Firmware Update Service |
Kojto | 148:fd96258d940d | 46 | * |
Kojto | 148:fd96258d940d | 47 | * @details The Device Firmware Update (DFU) service is a GATT based service that can be used for |
Kojto | 148:fd96258d940d | 48 | * performing firmware updates over BLE. Note that this implementation uses vendor |
Kojto | 148:fd96258d940d | 49 | * specific UUIDs for service and characteristics and is intended to demonstrate the |
Kojto | 148:fd96258d940d | 50 | * firmware updates over BLE. Refer @ref bledfu_transport_bleservice and @ref |
Kojto | 148:fd96258d940d | 51 | * bledfu_transport_bleprofile for more information on the service and profile respectively. |
Kojto | 148:fd96258d940d | 52 | */ |
Kojto | 148:fd96258d940d | 53 | |
Kojto | 148:fd96258d940d | 54 | #ifndef BLE_DFU_H__ |
Kojto | 148:fd96258d940d | 55 | #define BLE_DFU_H__ |
Kojto | 148:fd96258d940d | 56 | |
Kojto | 148:fd96258d940d | 57 | #include <stdint.h> |
Kojto | 148:fd96258d940d | 58 | #include "nrf_ble_gatts.h" |
Kojto | 148:fd96258d940d | 59 | #include "nrf_ble_gap.h" |
Kojto | 148:fd96258d940d | 60 | #include "nrf_ble.h" |
Kojto | 148:fd96258d940d | 61 | #include "ble_srv_common.h" |
Kojto | 148:fd96258d940d | 62 | |
Kojto | 148:fd96258d940d | 63 | #define BLE_DFU_SERVICE_UUID 0x1530 /**< The UUID of the DFU Service. */ |
Kojto | 148:fd96258d940d | 64 | #define BLE_DFU_PKT_CHAR_UUID 0x1532 /**< The UUID of the DFU Packet Characteristic. */ |
Kojto | 148:fd96258d940d | 65 | #define BLE_DFU_CTRL_PT_UUID 0x1531 /**< The UUID of the DFU Control Point. */ |
Kojto | 148:fd96258d940d | 66 | #define BLE_DFU_STATUS_REP_UUID 0x1533 /**< The UUID of the DFU Status Report Characteristic. */ |
Kojto | 148:fd96258d940d | 67 | #define BLE_DFU_REV_CHAR_UUID 0x1534 /**< The UUID of the DFU Revision Characteristic. */ |
Kojto | 148:fd96258d940d | 68 | |
Kojto | 148:fd96258d940d | 69 | /**@brief DFU Event type. |
Kojto | 148:fd96258d940d | 70 | * |
Kojto | 148:fd96258d940d | 71 | * @details This enumeration contains the types of events that will be received from the DFU Service. |
Kojto | 148:fd96258d940d | 72 | */ |
Kojto | 148:fd96258d940d | 73 | typedef enum |
Kojto | 148:fd96258d940d | 74 | { |
Kojto | 148:fd96258d940d | 75 | BLE_DFU_START, /**< The event indicating that the peer wants the application to prepare for a new firmware update. */ |
Kojto | 148:fd96258d940d | 76 | BLE_DFU_RECEIVE_INIT_DATA, /**< The event indicating that the peer wants the application to prepare to receive init parameters. */ |
Kojto | 148:fd96258d940d | 77 | BLE_DFU_RECEIVE_APP_DATA, /**< The event indicating that the peer wants the application to prepare to receive the new firmware image. */ |
Kojto | 148:fd96258d940d | 78 | BLE_DFU_VALIDATE, /**< The event indicating that the peer wants the application to validate the newly received firmware image. */ |
Kojto | 148:fd96258d940d | 79 | 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 */ |
Kojto | 148:fd96258d940d | 80 | BLE_DFU_SYS_RESET, /**< The event indicating that the peer wants the application to undergo a reset and start the currently valid application image.*/ |
Kojto | 148:fd96258d940d | 81 | 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.*/ |
Kojto | 148:fd96258d940d | 82 | BLE_DFU_PKT_RCPT_NOTIF_DISABLED, /**< The event indicating that the peer has disabled the packet receipt notifications.*/ |
Kojto | 148:fd96258d940d | 83 | 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.*/ |
Kojto | 148:fd96258d940d | 84 | 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. */ |
Kojto | 148:fd96258d940d | 85 | } ble_dfu_evt_type_t; |
Kojto | 148:fd96258d940d | 86 | |
Kojto | 148:fd96258d940d | 87 | /**@brief DFU Procedure type. |
Kojto | 148:fd96258d940d | 88 | * |
Kojto | 148:fd96258d940d | 89 | * @details This enumeration contains the types of DFU procedures. |
Kojto | 148:fd96258d940d | 90 | */ |
Kojto | 148:fd96258d940d | 91 | typedef enum |
Kojto | 148:fd96258d940d | 92 | { |
Kojto | 148:fd96258d940d | 93 | BLE_DFU_START_PROCEDURE = 1, /**< DFU Start procedure.*/ |
Kojto | 148:fd96258d940d | 94 | BLE_DFU_INIT_PROCEDURE = 2, /**< DFU Initialization procedure.*/ |
Kojto | 148:fd96258d940d | 95 | BLE_DFU_RECEIVE_APP_PROCEDURE = 3, /**< Firmware receiving procedure.*/ |
Kojto | 148:fd96258d940d | 96 | BLE_DFU_VALIDATE_PROCEDURE = 4, /**< Firmware image validation procedure .*/ |
Kojto | 148:fd96258d940d | 97 | BLE_DFU_PKT_RCPT_REQ_PROCEDURE = 8 /**< Packet receipt notification request procedure. */ |
Kojto | 148:fd96258d940d | 98 | } ble_dfu_procedure_t; |
Kojto | 148:fd96258d940d | 99 | |
Kojto | 148:fd96258d940d | 100 | /**@brief DFU Response value type. |
Kojto | 148:fd96258d940d | 101 | */ |
Kojto | 148:fd96258d940d | 102 | typedef enum |
Kojto | 148:fd96258d940d | 103 | { |
Kojto | 148:fd96258d940d | 104 | BLE_DFU_RESP_VAL_SUCCESS = 1, /**< Success.*/ |
Kojto | 148:fd96258d940d | 105 | BLE_DFU_RESP_VAL_INVALID_STATE, /**< Invalid state.*/ |
Kojto | 148:fd96258d940d | 106 | BLE_DFU_RESP_VAL_NOT_SUPPORTED, /**< Operation not supported.*/ |
Kojto | 148:fd96258d940d | 107 | BLE_DFU_RESP_VAL_DATA_SIZE, /**< Data size exceeds limit.*/ |
Kojto | 148:fd96258d940d | 108 | BLE_DFU_RESP_VAL_CRC_ERROR, /**< CRC Error.*/ |
Kojto | 148:fd96258d940d | 109 | BLE_DFU_RESP_VAL_OPER_FAILED /**< Operation failed.*/ |
Kojto | 148:fd96258d940d | 110 | } ble_dfu_resp_val_t; |
Kojto | 148:fd96258d940d | 111 | |
Kojto | 148:fd96258d940d | 112 | |
Kojto | 148:fd96258d940d | 113 | /**@brief DFU Packet structure. |
Kojto | 148:fd96258d940d | 114 | * |
Kojto | 148:fd96258d940d | 115 | * @details This structure contains the value of the DFU Packet characteristic as written by the |
Kojto | 148:fd96258d940d | 116 | * peer and the length of the value written. It will be filled by the DFU Service when the |
Kojto | 148:fd96258d940d | 117 | * peer writes to the DFU Packet characteristic. |
Kojto | 148:fd96258d940d | 118 | */ |
Kojto | 148:fd96258d940d | 119 | typedef struct |
Kojto | 148:fd96258d940d | 120 | { |
Kojto | 148:fd96258d940d | 121 | uint8_t * p_data; /**< Pointer to the received packet. This will point to a word aligned memory location.*/ |
Kojto | 148:fd96258d940d | 122 | uint8_t len; /**< Length of the packet received. */ |
Kojto | 148:fd96258d940d | 123 | } ble_dfu_pkt_write_t; |
Kojto | 148:fd96258d940d | 124 | |
Kojto | 148:fd96258d940d | 125 | /**@brief Packet receipt notification request structure. |
Kojto | 148:fd96258d940d | 126 | * |
Kojto | 148:fd96258d940d | 127 | * @details This structure contains the contents of the packet receipt notification request |
Kojto | 148:fd96258d940d | 128 | * sent by the DFU Controller. |
Kojto | 148:fd96258d940d | 129 | */ |
Kojto | 148:fd96258d940d | 130 | typedef struct |
Kojto | 148:fd96258d940d | 131 | { |
Kojto | 148:fd96258d940d | 132 | 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. */ |
Kojto | 148:fd96258d940d | 133 | } ble_pkt_rcpt_notif_req_t; |
Kojto | 148:fd96258d940d | 134 | |
Kojto | 148:fd96258d940d | 135 | /**@brief DFU Event structure. |
Kojto | 148:fd96258d940d | 136 | * |
Kojto | 148:fd96258d940d | 137 | * @details This structure contains the event generated by the DFU Service based on the data |
Kojto | 148:fd96258d940d | 138 | * received from the peer. |
Kojto | 148:fd96258d940d | 139 | */ |
Kojto | 148:fd96258d940d | 140 | typedef struct |
Kojto | 148:fd96258d940d | 141 | { |
Kojto | 148:fd96258d940d | 142 | ble_dfu_evt_type_t ble_dfu_evt_type; /**< Type of the event.*/ |
Kojto | 148:fd96258d940d | 143 | union |
Kojto | 148:fd96258d940d | 144 | { |
Kojto | 148:fd96258d940d | 145 | 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.*/ |
Kojto | 148:fd96258d940d | 146 | 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.*/ |
Kojto | 148:fd96258d940d | 147 | } evt; |
Kojto | 148:fd96258d940d | 148 | } ble_dfu_evt_t; |
Kojto | 148:fd96258d940d | 149 | |
Kojto | 148:fd96258d940d | 150 | // Forward declaration of the ble_dfu_t type. |
Kojto | 148:fd96258d940d | 151 | typedef struct ble_dfu_s ble_dfu_t; |
Kojto | 148:fd96258d940d | 152 | |
Kojto | 148:fd96258d940d | 153 | /**@brief DFU Service event handler type. */ |
Kojto | 148:fd96258d940d | 154 | typedef void (*ble_dfu_evt_handler_t) (ble_dfu_t * p_dfu, ble_dfu_evt_t * p_evt); |
Kojto | 148:fd96258d940d | 155 | |
Kojto | 148:fd96258d940d | 156 | /**@brief DFU service structure. |
Kojto | 148:fd96258d940d | 157 | * |
Kojto | 148:fd96258d940d | 158 | * @details This structure contains status information related to the service. |
Kojto | 148:fd96258d940d | 159 | */ |
Kojto | 148:fd96258d940d | 160 | struct ble_dfu_s |
Kojto | 148:fd96258d940d | 161 | { |
Kojto | 148:fd96258d940d | 162 | uint16_t conn_handle; /**< Handle of the current connection (as provided by the SoftDevice). This will be BLE_CONN_HANDLE_INVALID when not in a connection. */ |
Kojto | 148:fd96258d940d | 163 | uint16_t revision; /**< Handle of DFU Service (as provided by the SoftDevice). */ |
Kojto | 148:fd96258d940d | 164 | uint16_t service_handle; /**< Handle of DFU Service (as provided by the SoftDevice). */ |
Kojto | 148:fd96258d940d | 165 | uint8_t uuid_type; /**< UUID type assigned for DFU Service by the SoftDevice. */ |
Kojto | 148:fd96258d940d | 166 | ble_gatts_char_handles_t dfu_pkt_handles; /**< Handles related to the DFU Packet characteristic. */ |
Kojto | 148:fd96258d940d | 167 | ble_gatts_char_handles_t dfu_ctrl_pt_handles; /**< Handles related to the DFU Control Point characteristic. */ |
Kojto | 148:fd96258d940d | 168 | ble_gatts_char_handles_t dfu_status_rep_handles; /**< Handles related to the DFU Status Report characteristic. */ |
Kojto | 148:fd96258d940d | 169 | ble_gatts_char_handles_t dfu_rev_handles; /**< Handles related to the DFU Revision characteristic. */ |
Kojto | 148:fd96258d940d | 170 | ble_dfu_evt_handler_t evt_handler; /**< The event handler to be called when an event is to be sent to the application.*/ |
Kojto | 148:fd96258d940d | 171 | ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ |
Kojto | 148:fd96258d940d | 172 | }; |
Kojto | 148:fd96258d940d | 173 | |
Kojto | 148:fd96258d940d | 174 | /**@brief DFU service initialization structure. |
Kojto | 148:fd96258d940d | 175 | * |
Kojto | 148:fd96258d940d | 176 | * @details This structure contains the initialization information for the DFU Service. The |
Kojto | 148:fd96258d940d | 177 | * application needs to fill this structure and pass it to the DFU Service using the |
Kojto | 148:fd96258d940d | 178 | * @ref ble_dfu_init function. |
Kojto | 148:fd96258d940d | 179 | */ |
Kojto | 148:fd96258d940d | 180 | typedef struct |
Kojto | 148:fd96258d940d | 181 | { |
Kojto | 148:fd96258d940d | 182 | uint16_t revision; /**< Revision number to be exposed by the DFU service. */ |
Kojto | 148:fd96258d940d | 183 | ble_dfu_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Device Firmware Update Service. */ |
Kojto | 148:fd96258d940d | 184 | ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ |
Kojto | 148:fd96258d940d | 185 | } ble_dfu_init_t; |
Kojto | 148:fd96258d940d | 186 | |
Kojto | 148:fd96258d940d | 187 | /**@brief Function for handling a BLE event. |
Kojto | 148:fd96258d940d | 188 | * |
Kojto | 148:fd96258d940d | 189 | * @details The DFU service expects the application to call this function each time an event |
Kojto | 148:fd96258d940d | 190 | * is received from the SoftDevice. This function processes the event, if it is |
Kojto | 148:fd96258d940d | 191 | * relevant for the DFU service and calls the DFU event handler of the application if |
Kojto | 148:fd96258d940d | 192 | * necessary. |
Kojto | 148:fd96258d940d | 193 | * |
Kojto | 148:fd96258d940d | 194 | * @param[in] p_dfu Pointer to the DFU service structure. |
Kojto | 148:fd96258d940d | 195 | * @param[in] p_ble_evt Pointer to the event received from SoftDevice. |
Kojto | 148:fd96258d940d | 196 | */ |
Kojto | 148:fd96258d940d | 197 | void ble_dfu_on_ble_evt(ble_dfu_t * p_dfu, ble_evt_t * p_ble_evt); |
Kojto | 148:fd96258d940d | 198 | |
Kojto | 148:fd96258d940d | 199 | /**@brief Function for initializing the DFU service. |
Kojto | 148:fd96258d940d | 200 | * |
Kojto | 148:fd96258d940d | 201 | * @param[out] p_dfu Device Firmware Update service structure. This structure will have to be |
Kojto | 148:fd96258d940d | 202 | * supplied by the application. It will be initialized by this function, |
Kojto | 148:fd96258d940d | 203 | * and will later be used to identify the service instance. |
Kojto | 148:fd96258d940d | 204 | * @param[in] p_dfu_init Information needed to initialize the service. |
Kojto | 148:fd96258d940d | 205 | * |
Kojto | 148:fd96258d940d | 206 | * @return NRF_SUCCESS if the DFU service and its characteristics were successfully added to the |
Kojto | 148:fd96258d940d | 207 | * SoftDevice. Otherwise an error code. |
Kojto | 148:fd96258d940d | 208 | * This function returns NRF_ERROR_NULL if the value of evt_handler in p_dfu_init |
Kojto | 148:fd96258d940d | 209 | * structure provided is NULL or if the pointers supplied as input are NULL. |
Kojto | 148:fd96258d940d | 210 | */ |
Kojto | 148:fd96258d940d | 211 | uint32_t ble_dfu_init(ble_dfu_t * p_dfu, ble_dfu_init_t * p_dfu_init); |
Kojto | 148:fd96258d940d | 212 | |
Kojto | 148:fd96258d940d | 213 | /**@brief Function for sending response to a control point command. |
Kojto | 148:fd96258d940d | 214 | * |
Kojto | 148:fd96258d940d | 215 | * @details This function will encode a DFU Control Point response using the given input |
Kojto | 148:fd96258d940d | 216 | * parameters and will send a notification of the same to the peer. |
Kojto | 148:fd96258d940d | 217 | * |
Kojto | 148:fd96258d940d | 218 | * @param[in] p_dfu Pointer to the DFU service structure. |
Kojto | 148:fd96258d940d | 219 | * @param[in] dfu_proc Procedure for which this response is to be sent. |
Kojto | 148:fd96258d940d | 220 | * @param[in] resp_val Response value. |
Kojto | 148:fd96258d940d | 221 | * |
Kojto | 148:fd96258d940d | 222 | * @return NRF_SUCCESS if the DFU Service has successfully requested the SoftDevice to |
Kojto | 148:fd96258d940d | 223 | * send the notification. Otherwise an error code. |
Kojto | 148:fd96258d940d | 224 | * This function returns NRF_ERROR_INVALID_STATE if the device is not connected to a |
Kojto | 148:fd96258d940d | 225 | * peer or if the DFU service is not initialized or if the notification of the DFU |
Kojto | 148:fd96258d940d | 226 | * Status Report characteristic was not enabled by the peer. It returns NRF_ERROR_NULL |
Kojto | 148:fd96258d940d | 227 | * if the pointer p_dfu is NULL. |
Kojto | 148:fd96258d940d | 228 | */ |
Kojto | 148:fd96258d940d | 229 | uint32_t ble_dfu_response_send(ble_dfu_t * p_dfu, |
Kojto | 148:fd96258d940d | 230 | ble_dfu_procedure_t dfu_proc, |
Kojto | 148:fd96258d940d | 231 | ble_dfu_resp_val_t resp_val); |
Kojto | 148:fd96258d940d | 232 | |
Kojto | 148:fd96258d940d | 233 | /**@brief Function for notifying the peer about the number of bytes of firmware data received. |
Kojto | 148:fd96258d940d | 234 | * |
Kojto | 148:fd96258d940d | 235 | * @param[in] p_dfu Pointer to the DFU service structure. |
Kojto | 148:fd96258d940d | 236 | * @param[in] num_of_firmware_bytes_rcvd Number of bytes. |
Kojto | 148:fd96258d940d | 237 | * |
Kojto | 148:fd96258d940d | 238 | * @return NRF_SUCCESS if the DFU Service has successfully requested the SoftDevice to send |
Kojto | 148:fd96258d940d | 239 | * the notification. Otherwise an error code. |
Kojto | 148:fd96258d940d | 240 | * This function returns NRF_ERROR_INVALID_STATE if the device is not connected to a |
Kojto | 148:fd96258d940d | 241 | * peer or if the DFU service is not initialized or if the notification of the DFU |
Kojto | 148:fd96258d940d | 242 | * Status Report characteristic was not enabled by the peer. It returns NRF_ERROR_NULL |
Kojto | 148:fd96258d940d | 243 | * if the pointer p_dfu is NULL. |
Kojto | 148:fd96258d940d | 244 | */ |
Kojto | 148:fd96258d940d | 245 | uint32_t ble_dfu_bytes_rcvd_report(ble_dfu_t * p_dfu, uint32_t num_of_firmware_bytes_rcvd); |
Kojto | 148:fd96258d940d | 246 | |
Kojto | 148:fd96258d940d | 247 | /**@brief Function for sending Packet Receipt Notification to the peer. |
Kojto | 148:fd96258d940d | 248 | * |
Kojto | 148:fd96258d940d | 249 | * This function will encode the number of bytes received as input parameter into a |
Kojto | 148:fd96258d940d | 250 | * notification of the control point characteristic and send it to the peer. |
Kojto | 148:fd96258d940d | 251 | * |
Kojto | 148:fd96258d940d | 252 | * @param[in] p_dfu Pointer to the DFU service structure. |
Kojto | 148:fd96258d940d | 253 | * @param[in] num_of_firmware_bytes_rcvd Number of bytes of firmware image received. |
Kojto | 148:fd96258d940d | 254 | * |
Kojto | 148:fd96258d940d | 255 | * @return NRF_SUCCESS if the DFU Service has successfully requested the SoftDevice to send |
Kojto | 148:fd96258d940d | 256 | * the notification. Otherwise an error code. |
Kojto | 148:fd96258d940d | 257 | * This function returns NRF_ERROR_INVALID_STATE if the device is not connected to a |
Kojto | 148:fd96258d940d | 258 | * peer or if the DFU service is not initialized or if the notification of the DFU |
Kojto | 148:fd96258d940d | 259 | * Status Report characteristic was not enabled by the peer. It returns NRF_ERROR_NULL |
Kojto | 148:fd96258d940d | 260 | * if the pointer p_dfu is NULL. |
Kojto | 148:fd96258d940d | 261 | */ |
Kojto | 148:fd96258d940d | 262 | uint32_t ble_dfu_pkts_rcpt_notify(ble_dfu_t * p_dfu, uint32_t num_of_firmware_bytes_rcvd); |
Kojto | 148:fd96258d940d | 263 | |
Kojto | 148:fd96258d940d | 264 | #endif // BLE_DFU_H__ |
Kojto | 148:fd96258d940d | 265 | |
Kojto | 148:fd96258d940d | 266 | /** @} */ |