Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: hello SerialTestv11 SerialTestv12 Sierpinski ... more
TARGET_NRF51_DONGLE/TARGET_NORDIC/TARGET_NRF5/sdk/ble/ble_services/ble_dfu/ble_dfu.h@129:0ab6a29f35bf, 2016-11-08 (annotated)
- Committer:
- <>
- Date:
- Tue Nov 08 17:28:34 2016 +0000
- Revision:
- 129:0ab6a29f35bf
- Parent:
- 128:9bcdf88f62b0
Release 129 of the mbed library
Ports for Upcoming Targets
3011: Add u-blox Sara-N target. https://github.com/ARMmbed/mbed-os/pull/3011
3099: MAX32625 https://github.com/ARMmbed/mbed-os/pull/3099
3151: Add support for FRDM-K82F https://github.com/ARMmbed/mbed-os/pull/3151
3177: New mcu k22512 fixing pr 3136 https://github.com/ARMmbed/mbed-os/pull/3177
Fixes and Changes
3008: NUCLEO_F072RB: Fix wrong timer channel number on pwm PB_5 pin https://github.com/ARMmbed/mbed-os/pull/3008
3013: STM32xx - Change how the ADC internal pins are checked before pinmap_ https://github.com/ARMmbed/mbed-os/pull/3013
3041: [nRF5] - added implementation of API of serial port flow control configuration. https://github.com/ARMmbed/mbed-os/pull/3041
3084: [nrf5] fix in Digital I/O : a gpioe pin was uninitialized badly https://github.com/ARMmbed/mbed-os/pull/3084
3009: TRNG enabled. TRNG APIs implemented. REV A/B/C/D flags removed. Warnings removed https://github.com/ARMmbed/mbed-os/pull/3009
3074: Target stm init gcc alignement https://github.com/ARMmbed/mbed-os/pull/3074
2988: Update of can_api.c fixing #2987 https://github.com/ARMmbed/mbed-os/pull/2988
3173: [Exporters] Add a device_name to microbit entry in targets.json https://github.com/ARMmbed/mbed-os/pull/3173
2969: [nRF52] - switch irq priorities of driver handlers to the lowest level https://github.com/ARMmbed/mbed-os/pull/2969
3184: #3183 Compiler warning in trng_api.c with K64F https://github.com/ARMmbed/mbed-os/pull/3184
3104: [NuMaker] Support CAN and fix PWM CLK error https://github.com/ARMmbed/mbed-os/pull/3104
3186: MultiTech mDot - add back SPI3 pins https://github.com/ARMmbed/mbed-os/pull/3186
3075: nsapi - Add standardized return types for size and errors https://github.com/ARMmbed/mbed-os/pull/3075
3221: u-blox odin w2 drivers update https://github.com/ARMmbed/mbed-os/pull/3221
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| <> | 128:9bcdf88f62b0 | 1 | /* |
| <> | 128:9bcdf88f62b0 | 2 | * Copyright (c) 2013 Nordic Semiconductor ASA |
| <> | 128:9bcdf88f62b0 | 3 | * All rights reserved. |
| <> | 128:9bcdf88f62b0 | 4 | * |
| <> | 128:9bcdf88f62b0 | 5 | * Redistribution and use in source and binary forms, with or without modification, |
| <> | 128:9bcdf88f62b0 | 6 | * are permitted provided that the following conditions are met: |
| <> | 128:9bcdf88f62b0 | 7 | * |
| <> | 128:9bcdf88f62b0 | 8 | * 1. Redistributions of source code must retain the above copyright notice, this list |
| <> | 128:9bcdf88f62b0 | 9 | * of conditions and the following disclaimer. |
| <> | 128:9bcdf88f62b0 | 10 | * |
| <> | 128:9bcdf88f62b0 | 11 | * 2. Redistributions in binary form, except as embedded into a Nordic Semiconductor ASA |
| <> | 128:9bcdf88f62b0 | 12 | * integrated circuit in a product or a software update for such product, must reproduce |
| <> | 128:9bcdf88f62b0 | 13 | * the above copyright notice, this list of conditions and the following disclaimer in |
| <> | 128:9bcdf88f62b0 | 14 | * the documentation and/or other materials provided with the distribution. |
| <> | 128:9bcdf88f62b0 | 15 | * |
| <> | 128:9bcdf88f62b0 | 16 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of its contributors may be |
| <> | 128:9bcdf88f62b0 | 17 | * used to endorse or promote products derived from this software without specific prior |
| <> | 128:9bcdf88f62b0 | 18 | * written permission. |
| <> | 128:9bcdf88f62b0 | 19 | * |
| <> | 128:9bcdf88f62b0 | 20 | * 4. This software, with or without modification, must only be used with a |
| <> | 128:9bcdf88f62b0 | 21 | * Nordic Semiconductor ASA integrated circuit. |
| <> | 128:9bcdf88f62b0 | 22 | * |
| <> | 128:9bcdf88f62b0 | 23 | * 5. Any software provided in binary or object form under this license must not be reverse |
| <> | 128:9bcdf88f62b0 | 24 | * engineered, decompiled, modified and/or disassembled. |
| <> | 128:9bcdf88f62b0 | 25 | * |
| <> | 128:9bcdf88f62b0 | 26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| <> | 128:9bcdf88f62b0 | 27 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| <> | 128:9bcdf88f62b0 | 28 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| <> | 128:9bcdf88f62b0 | 29 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
| <> | 128:9bcdf88f62b0 | 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| <> | 128:9bcdf88f62b0 | 31 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| <> | 128:9bcdf88f62b0 | 32 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
| <> | 128:9bcdf88f62b0 | 33 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| <> | 128:9bcdf88f62b0 | 34 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| <> | 128:9bcdf88f62b0 | 35 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| <> | 128:9bcdf88f62b0 | 36 | * |
| <> | 128:9bcdf88f62b0 | 37 | */ |
| <> | 128:9bcdf88f62b0 | 38 | |
| <> | 128:9bcdf88f62b0 | 39 | |
| <> | 128:9bcdf88f62b0 | 40 | /**@file |
| <> | 128:9bcdf88f62b0 | 41 | * |
| <> | 128:9bcdf88f62b0 | 42 | * @defgroup ble_sdk_srv_dfu Device Firmware Update Service |
| <> | 128:9bcdf88f62b0 | 43 | * @{ |
| <> | 128:9bcdf88f62b0 | 44 | * @ingroup ble_sdk_srv |
| <> | 128:9bcdf88f62b0 | 45 | * @brief Device Firmware Update Service |
| <> | 128:9bcdf88f62b0 | 46 | * |
| <> | 128:9bcdf88f62b0 | 47 | * @details The Device Firmware Update (DFU) service is a GATT based service that can be used for |
| <> | 128:9bcdf88f62b0 | 48 | * performing firmware updates over BLE. Note that this implementation uses vendor |
| <> | 128:9bcdf88f62b0 | 49 | * specific UUIDs for service and characteristics and is intended to demonstrate the |
| <> | 128:9bcdf88f62b0 | 50 | * firmware updates over BLE. Refer @ref bledfu_transport_bleservice and @ref |
| <> | 128:9bcdf88f62b0 | 51 | * bledfu_transport_bleprofile for more information on the service and profile respectively. |
| <> | 128:9bcdf88f62b0 | 52 | */ |
| <> | 128:9bcdf88f62b0 | 53 | |
| <> | 128:9bcdf88f62b0 | 54 | #ifndef BLE_DFU_H__ |
| <> | 128:9bcdf88f62b0 | 55 | #define BLE_DFU_H__ |
| <> | 128:9bcdf88f62b0 | 56 | |
| <> | 128:9bcdf88f62b0 | 57 | #include <stdint.h> |
| <> | 128:9bcdf88f62b0 | 58 | #include "nrf_ble_gatts.h" |
| <> | 128:9bcdf88f62b0 | 59 | #include "nrf_ble_gap.h" |
| <> | 128:9bcdf88f62b0 | 60 | #include "nrf_ble.h" |
| <> | 128:9bcdf88f62b0 | 61 | #include "ble_srv_common.h" |
| <> | 128:9bcdf88f62b0 | 62 | |
| <> | 128:9bcdf88f62b0 | 63 | #define BLE_DFU_SERVICE_UUID 0x1530 /**< The UUID of the DFU Service. */ |
| <> | 128:9bcdf88f62b0 | 64 | #define BLE_DFU_PKT_CHAR_UUID 0x1532 /**< The UUID of the DFU Packet Characteristic. */ |
| <> | 128:9bcdf88f62b0 | 65 | #define BLE_DFU_CTRL_PT_UUID 0x1531 /**< The UUID of the DFU Control Point. */ |
| <> | 128:9bcdf88f62b0 | 66 | #define BLE_DFU_STATUS_REP_UUID 0x1533 /**< The UUID of the DFU Status Report Characteristic. */ |
| <> | 128:9bcdf88f62b0 | 67 | #define BLE_DFU_REV_CHAR_UUID 0x1534 /**< The UUID of the DFU Revision Characteristic. */ |
| <> | 128:9bcdf88f62b0 | 68 | |
| <> | 128:9bcdf88f62b0 | 69 | /**@brief DFU Event type. |
| <> | 128:9bcdf88f62b0 | 70 | * |
| <> | 128:9bcdf88f62b0 | 71 | * @details This enumeration contains the types of events that will be received from the DFU Service. |
| <> | 128:9bcdf88f62b0 | 72 | */ |
| <> | 128:9bcdf88f62b0 | 73 | typedef enum |
| <> | 128:9bcdf88f62b0 | 74 | { |
| <> | 128:9bcdf88f62b0 | 75 | BLE_DFU_START, /**< The event indicating that the peer wants the application to prepare for a new firmware update. */ |
| <> | 128:9bcdf88f62b0 | 76 | BLE_DFU_RECEIVE_INIT_DATA, /**< The event indicating that the peer wants the application to prepare to receive init parameters. */ |
| <> | 128:9bcdf88f62b0 | 77 | BLE_DFU_RECEIVE_APP_DATA, /**< The event indicating that the peer wants the application to prepare to receive the new firmware image. */ |
| <> | 128:9bcdf88f62b0 | 78 | BLE_DFU_VALIDATE, /**< The event indicating that the peer wants the application to validate the newly received firmware image. */ |
| <> | 128:9bcdf88f62b0 | 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 */ |
| <> | 128:9bcdf88f62b0 | 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.*/ |
| <> | 128:9bcdf88f62b0 | 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.*/ |
| <> | 128:9bcdf88f62b0 | 82 | BLE_DFU_PKT_RCPT_NOTIF_DISABLED, /**< The event indicating that the peer has disabled the packet receipt notifications.*/ |
| <> | 128:9bcdf88f62b0 | 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.*/ |
| <> | 128:9bcdf88f62b0 | 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. */ |
| <> | 128:9bcdf88f62b0 | 85 | } ble_dfu_evt_type_t; |
| <> | 128:9bcdf88f62b0 | 86 | |
| <> | 128:9bcdf88f62b0 | 87 | /**@brief DFU Procedure type. |
| <> | 128:9bcdf88f62b0 | 88 | * |
| <> | 128:9bcdf88f62b0 | 89 | * @details This enumeration contains the types of DFU procedures. |
| <> | 128:9bcdf88f62b0 | 90 | */ |
| <> | 128:9bcdf88f62b0 | 91 | typedef enum |
| <> | 128:9bcdf88f62b0 | 92 | { |
| <> | 128:9bcdf88f62b0 | 93 | BLE_DFU_START_PROCEDURE = 1, /**< DFU Start procedure.*/ |
| <> | 128:9bcdf88f62b0 | 94 | BLE_DFU_INIT_PROCEDURE = 2, /**< DFU Initialization procedure.*/ |
| <> | 128:9bcdf88f62b0 | 95 | BLE_DFU_RECEIVE_APP_PROCEDURE = 3, /**< Firmware receiving procedure.*/ |
| <> | 128:9bcdf88f62b0 | 96 | BLE_DFU_VALIDATE_PROCEDURE = 4, /**< Firmware image validation procedure .*/ |
| <> | 128:9bcdf88f62b0 | 97 | BLE_DFU_PKT_RCPT_REQ_PROCEDURE = 8 /**< Packet receipt notification request procedure. */ |
| <> | 128:9bcdf88f62b0 | 98 | } ble_dfu_procedure_t; |
| <> | 128:9bcdf88f62b0 | 99 | |
| <> | 128:9bcdf88f62b0 | 100 | /**@brief DFU Response value type. |
| <> | 128:9bcdf88f62b0 | 101 | */ |
| <> | 128:9bcdf88f62b0 | 102 | typedef enum |
| <> | 128:9bcdf88f62b0 | 103 | { |
| <> | 128:9bcdf88f62b0 | 104 | BLE_DFU_RESP_VAL_SUCCESS = 1, /**< Success.*/ |
| <> | 128:9bcdf88f62b0 | 105 | BLE_DFU_RESP_VAL_INVALID_STATE, /**< Invalid state.*/ |
| <> | 128:9bcdf88f62b0 | 106 | BLE_DFU_RESP_VAL_NOT_SUPPORTED, /**< Operation not supported.*/ |
| <> | 128:9bcdf88f62b0 | 107 | BLE_DFU_RESP_VAL_DATA_SIZE, /**< Data size exceeds limit.*/ |
| <> | 128:9bcdf88f62b0 | 108 | BLE_DFU_RESP_VAL_CRC_ERROR, /**< CRC Error.*/ |
| <> | 128:9bcdf88f62b0 | 109 | BLE_DFU_RESP_VAL_OPER_FAILED /**< Operation failed.*/ |
| <> | 128:9bcdf88f62b0 | 110 | } ble_dfu_resp_val_t; |
| <> | 128:9bcdf88f62b0 | 111 | |
| <> | 128:9bcdf88f62b0 | 112 | |
| <> | 128:9bcdf88f62b0 | 113 | /**@brief DFU Packet structure. |
| <> | 128:9bcdf88f62b0 | 114 | * |
| <> | 128:9bcdf88f62b0 | 115 | * @details This structure contains the value of the DFU Packet characteristic as written by the |
| <> | 128:9bcdf88f62b0 | 116 | * peer and the length of the value written. It will be filled by the DFU Service when the |
| <> | 128:9bcdf88f62b0 | 117 | * peer writes to the DFU Packet characteristic. |
| <> | 128:9bcdf88f62b0 | 118 | */ |
| <> | 128:9bcdf88f62b0 | 119 | typedef struct |
| <> | 128:9bcdf88f62b0 | 120 | { |
| <> | 128:9bcdf88f62b0 | 121 | uint8_t * p_data; /**< Pointer to the received packet. This will point to a word aligned memory location.*/ |
| <> | 128:9bcdf88f62b0 | 122 | uint8_t len; /**< Length of the packet received. */ |
| <> | 128:9bcdf88f62b0 | 123 | } ble_dfu_pkt_write_t; |
| <> | 128:9bcdf88f62b0 | 124 | |
| <> | 128:9bcdf88f62b0 | 125 | /**@brief Packet receipt notification request structure. |
| <> | 128:9bcdf88f62b0 | 126 | * |
| <> | 128:9bcdf88f62b0 | 127 | * @details This structure contains the contents of the packet receipt notification request |
| <> | 128:9bcdf88f62b0 | 128 | * sent by the DFU Controller. |
| <> | 128:9bcdf88f62b0 | 129 | */ |
| <> | 128:9bcdf88f62b0 | 130 | typedef struct |
| <> | 128:9bcdf88f62b0 | 131 | { |
| <> | 128:9bcdf88f62b0 | 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. */ |
| <> | 128:9bcdf88f62b0 | 133 | } ble_pkt_rcpt_notif_req_t; |
| <> | 128:9bcdf88f62b0 | 134 | |
| <> | 128:9bcdf88f62b0 | 135 | /**@brief DFU Event structure. |
| <> | 128:9bcdf88f62b0 | 136 | * |
| <> | 128:9bcdf88f62b0 | 137 | * @details This structure contains the event generated by the DFU Service based on the data |
| <> | 128:9bcdf88f62b0 | 138 | * received from the peer. |
| <> | 128:9bcdf88f62b0 | 139 | */ |
| <> | 128:9bcdf88f62b0 | 140 | typedef struct |
| <> | 128:9bcdf88f62b0 | 141 | { |
| <> | 128:9bcdf88f62b0 | 142 | ble_dfu_evt_type_t ble_dfu_evt_type; /**< Type of the event.*/ |
| <> | 128:9bcdf88f62b0 | 143 | union |
| <> | 128:9bcdf88f62b0 | 144 | { |
| <> | 128:9bcdf88f62b0 | 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.*/ |
| <> | 128:9bcdf88f62b0 | 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.*/ |
| <> | 128:9bcdf88f62b0 | 147 | } evt; |
| <> | 128:9bcdf88f62b0 | 148 | } ble_dfu_evt_t; |
| <> | 128:9bcdf88f62b0 | 149 | |
| <> | 128:9bcdf88f62b0 | 150 | // Forward declaration of the ble_dfu_t type. |
| <> | 128:9bcdf88f62b0 | 151 | typedef struct ble_dfu_s ble_dfu_t; |
| <> | 128:9bcdf88f62b0 | 152 | |
| <> | 128:9bcdf88f62b0 | 153 | /**@brief DFU Service event handler type. */ |
| <> | 128:9bcdf88f62b0 | 154 | typedef void (*ble_dfu_evt_handler_t) (ble_dfu_t * p_dfu, ble_dfu_evt_t * p_evt); |
| <> | 128:9bcdf88f62b0 | 155 | |
| <> | 128:9bcdf88f62b0 | 156 | /**@brief DFU service structure. |
| <> | 128:9bcdf88f62b0 | 157 | * |
| <> | 128:9bcdf88f62b0 | 158 | * @details This structure contains status information related to the service. |
| <> | 128:9bcdf88f62b0 | 159 | */ |
| <> | 128:9bcdf88f62b0 | 160 | struct ble_dfu_s |
| <> | 128:9bcdf88f62b0 | 161 | { |
| <> | 128:9bcdf88f62b0 | 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. */ |
| <> | 128:9bcdf88f62b0 | 163 | uint16_t revision; /**< Handle of DFU Service (as provided by the SoftDevice). */ |
| <> | 128:9bcdf88f62b0 | 164 | uint16_t service_handle; /**< Handle of DFU Service (as provided by the SoftDevice). */ |
| <> | 128:9bcdf88f62b0 | 165 | uint8_t uuid_type; /**< UUID type assigned for DFU Service by the SoftDevice. */ |
| <> | 128:9bcdf88f62b0 | 166 | ble_gatts_char_handles_t dfu_pkt_handles; /**< Handles related to the DFU Packet characteristic. */ |
| <> | 128:9bcdf88f62b0 | 167 | ble_gatts_char_handles_t dfu_ctrl_pt_handles; /**< Handles related to the DFU Control Point characteristic. */ |
| <> | 128:9bcdf88f62b0 | 168 | ble_gatts_char_handles_t dfu_status_rep_handles; /**< Handles related to the DFU Status Report characteristic. */ |
| <> | 128:9bcdf88f62b0 | 169 | ble_gatts_char_handles_t dfu_rev_handles; /**< Handles related to the DFU Revision characteristic. */ |
| <> | 128:9bcdf88f62b0 | 170 | ble_dfu_evt_handler_t evt_handler; /**< The event handler to be called when an event is to be sent to the application.*/ |
| <> | 128:9bcdf88f62b0 | 171 | ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ |
| <> | 128:9bcdf88f62b0 | 172 | }; |
| <> | 128:9bcdf88f62b0 | 173 | |
| <> | 128:9bcdf88f62b0 | 174 | /**@brief DFU service initialization structure. |
| <> | 128:9bcdf88f62b0 | 175 | * |
| <> | 128:9bcdf88f62b0 | 176 | * @details This structure contains the initialization information for the DFU Service. The |
| <> | 128:9bcdf88f62b0 | 177 | * application needs to fill this structure and pass it to the DFU Service using the |
| <> | 128:9bcdf88f62b0 | 178 | * @ref ble_dfu_init function. |
| <> | 128:9bcdf88f62b0 | 179 | */ |
| <> | 128:9bcdf88f62b0 | 180 | typedef struct |
| <> | 128:9bcdf88f62b0 | 181 | { |
| <> | 128:9bcdf88f62b0 | 182 | uint16_t revision; /**< Revision number to be exposed by the DFU service. */ |
| <> | 128:9bcdf88f62b0 | 183 | ble_dfu_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Device Firmware Update Service. */ |
| <> | 128:9bcdf88f62b0 | 184 | ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ |
| <> | 128:9bcdf88f62b0 | 185 | } ble_dfu_init_t; |
| <> | 128:9bcdf88f62b0 | 186 | |
| <> | 128:9bcdf88f62b0 | 187 | /**@brief Function for handling a BLE event. |
| <> | 128:9bcdf88f62b0 | 188 | * |
| <> | 128:9bcdf88f62b0 | 189 | * @details The DFU service expects the application to call this function each time an event |
| <> | 128:9bcdf88f62b0 | 190 | * is received from the SoftDevice. This function processes the event, if it is |
| <> | 128:9bcdf88f62b0 | 191 | * relevant for the DFU service and calls the DFU event handler of the application if |
| <> | 128:9bcdf88f62b0 | 192 | * necessary. |
| <> | 128:9bcdf88f62b0 | 193 | * |
| <> | 128:9bcdf88f62b0 | 194 | * @param[in] p_dfu Pointer to the DFU service structure. |
| <> | 128:9bcdf88f62b0 | 195 | * @param[in] p_ble_evt Pointer to the event received from SoftDevice. |
| <> | 128:9bcdf88f62b0 | 196 | */ |
| <> | 128:9bcdf88f62b0 | 197 | void ble_dfu_on_ble_evt(ble_dfu_t * p_dfu, ble_evt_t * p_ble_evt); |
| <> | 128:9bcdf88f62b0 | 198 | |
| <> | 128:9bcdf88f62b0 | 199 | /**@brief Function for initializing the DFU service. |
| <> | 128:9bcdf88f62b0 | 200 | * |
| <> | 128:9bcdf88f62b0 | 201 | * @param[out] p_dfu Device Firmware Update service structure. This structure will have to be |
| <> | 128:9bcdf88f62b0 | 202 | * supplied by the application. It will be initialized by this function, |
| <> | 128:9bcdf88f62b0 | 203 | * and will later be used to identify the service instance. |
| <> | 128:9bcdf88f62b0 | 204 | * @param[in] p_dfu_init Information needed to initialize the service. |
| <> | 128:9bcdf88f62b0 | 205 | * |
| <> | 128:9bcdf88f62b0 | 206 | * @return NRF_SUCCESS if the DFU service and its characteristics were successfully added to the |
| <> | 128:9bcdf88f62b0 | 207 | * SoftDevice. Otherwise an error code. |
| <> | 128:9bcdf88f62b0 | 208 | * This function returns NRF_ERROR_NULL if the value of evt_handler in p_dfu_init |
| <> | 128:9bcdf88f62b0 | 209 | * structure provided is NULL or if the pointers supplied as input are NULL. |
| <> | 128:9bcdf88f62b0 | 210 | */ |
| <> | 128:9bcdf88f62b0 | 211 | uint32_t ble_dfu_init(ble_dfu_t * p_dfu, ble_dfu_init_t * p_dfu_init); |
| <> | 128:9bcdf88f62b0 | 212 | |
| <> | 128:9bcdf88f62b0 | 213 | /**@brief Function for sending response to a control point command. |
| <> | 128:9bcdf88f62b0 | 214 | * |
| <> | 128:9bcdf88f62b0 | 215 | * @details This function will encode a DFU Control Point response using the given input |
| <> | 128:9bcdf88f62b0 | 216 | * parameters and will send a notification of the same to the peer. |
| <> | 128:9bcdf88f62b0 | 217 | * |
| <> | 128:9bcdf88f62b0 | 218 | * @param[in] p_dfu Pointer to the DFU service structure. |
| <> | 128:9bcdf88f62b0 | 219 | * @param[in] dfu_proc Procedure for which this response is to be sent. |
| <> | 128:9bcdf88f62b0 | 220 | * @param[in] resp_val Response value. |
| <> | 128:9bcdf88f62b0 | 221 | * |
| <> | 128:9bcdf88f62b0 | 222 | * @return NRF_SUCCESS if the DFU Service has successfully requested the SoftDevice to |
| <> | 128:9bcdf88f62b0 | 223 | * send the notification. Otherwise an error code. |
| <> | 128:9bcdf88f62b0 | 224 | * This function returns NRF_ERROR_INVALID_STATE if the device is not connected to a |
| <> | 128:9bcdf88f62b0 | 225 | * peer or if the DFU service is not initialized or if the notification of the DFU |
| <> | 128:9bcdf88f62b0 | 226 | * Status Report characteristic was not enabled by the peer. It returns NRF_ERROR_NULL |
| <> | 128:9bcdf88f62b0 | 227 | * if the pointer p_dfu is NULL. |
| <> | 128:9bcdf88f62b0 | 228 | */ |
| <> | 128:9bcdf88f62b0 | 229 | uint32_t ble_dfu_response_send(ble_dfu_t * p_dfu, |
| <> | 128:9bcdf88f62b0 | 230 | ble_dfu_procedure_t dfu_proc, |
| <> | 128:9bcdf88f62b0 | 231 | ble_dfu_resp_val_t resp_val); |
| <> | 128:9bcdf88f62b0 | 232 | |
| <> | 128:9bcdf88f62b0 | 233 | /**@brief Function for notifying the peer about the number of bytes of firmware data received. |
| <> | 128:9bcdf88f62b0 | 234 | * |
| <> | 128:9bcdf88f62b0 | 235 | * @param[in] p_dfu Pointer to the DFU service structure. |
| <> | 128:9bcdf88f62b0 | 236 | * @param[in] num_of_firmware_bytes_rcvd Number of bytes. |
| <> | 128:9bcdf88f62b0 | 237 | * |
| <> | 128:9bcdf88f62b0 | 238 | * @return NRF_SUCCESS if the DFU Service has successfully requested the SoftDevice to send |
| <> | 128:9bcdf88f62b0 | 239 | * the notification. Otherwise an error code. |
| <> | 128:9bcdf88f62b0 | 240 | * This function returns NRF_ERROR_INVALID_STATE if the device is not connected to a |
| <> | 128:9bcdf88f62b0 | 241 | * peer or if the DFU service is not initialized or if the notification of the DFU |
| <> | 128:9bcdf88f62b0 | 242 | * Status Report characteristic was not enabled by the peer. It returns NRF_ERROR_NULL |
| <> | 128:9bcdf88f62b0 | 243 | * if the pointer p_dfu is NULL. |
| <> | 128:9bcdf88f62b0 | 244 | */ |
| <> | 128:9bcdf88f62b0 | 245 | uint32_t ble_dfu_bytes_rcvd_report(ble_dfu_t * p_dfu, uint32_t num_of_firmware_bytes_rcvd); |
| <> | 128:9bcdf88f62b0 | 246 | |
| <> | 128:9bcdf88f62b0 | 247 | /**@brief Function for sending Packet Receipt Notification to the peer. |
| <> | 128:9bcdf88f62b0 | 248 | * |
| <> | 128:9bcdf88f62b0 | 249 | * This function will encode the number of bytes received as input parameter into a |
| <> | 128:9bcdf88f62b0 | 250 | * notification of the control point characteristic and send it to the peer. |
| <> | 128:9bcdf88f62b0 | 251 | * |
| <> | 128:9bcdf88f62b0 | 252 | * @param[in] p_dfu Pointer to the DFU service structure. |
| <> | 128:9bcdf88f62b0 | 253 | * @param[in] num_of_firmware_bytes_rcvd Number of bytes of firmware image received. |
| <> | 128:9bcdf88f62b0 | 254 | * |
| <> | 128:9bcdf88f62b0 | 255 | * @return NRF_SUCCESS if the DFU Service has successfully requested the SoftDevice to send |
| <> | 128:9bcdf88f62b0 | 256 | * the notification. Otherwise an error code. |
| <> | 128:9bcdf88f62b0 | 257 | * This function returns NRF_ERROR_INVALID_STATE if the device is not connected to a |
| <> | 128:9bcdf88f62b0 | 258 | * peer or if the DFU service is not initialized or if the notification of the DFU |
| <> | 128:9bcdf88f62b0 | 259 | * Status Report characteristic was not enabled by the peer. It returns NRF_ERROR_NULL |
| <> | 128:9bcdf88f62b0 | 260 | * if the pointer p_dfu is NULL. |
| <> | 128:9bcdf88f62b0 | 261 | */ |
| <> | 128:9bcdf88f62b0 | 262 | uint32_t ble_dfu_pkts_rcpt_notify(ble_dfu_t * p_dfu, uint32_t num_of_firmware_bytes_rcvd); |
| <> | 128:9bcdf88f62b0 | 263 | |
| <> | 128:9bcdf88f62b0 | 264 | #endif // BLE_DFU_H__ |
| <> | 128:9bcdf88f62b0 | 265 | |
| <> | 128:9bcdf88f62b0 | 266 | /** @} */ |


