source: azure_iot_hub_f767zi/trunk/asp_baseplatform/gdic/ble_shield2.1/utility/dfu.h@ 457

Last change on this file since 457 was 457, checked in by coas-nagasima, 4 years ago

ファイルを追加

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr;charset=UTF-8
File size: 4.6 KB
Line 
1#ifndef DFU_H_
2#define DFU_H_
3
4#define ST_IDLE 0
5#define ST_INIT_ERROR 1
6#define ST_RDY 2
7#define ST_RX_INIT_PKT 3
8#define ST_RX_DATA_PKT 4
9#define ST_FW_VALID 5
10#define ST_FW_INVALID 6
11#define ST_ANY 255
12
13#define EV_ANY 255
14
15#define PIPE_DEVICE_FIRMWARE_UPDATE_BLE_SERVICE_DFU_PACKET_RX 8
16#define PIPE_DEVICE_FIRMWARE_UPDATE_BLE_SERVICE_DFU_CONTROL_POINT_TX 9
17#define PIPE_DEVICE_FIRMWARE_UPDATE_BLE_SERVICE_DFU_CONTROL_POINT_RX_ACK_AUTO 10
18
19/**@brief DFU Event type.
20 *
21 * @details This enumeration contains the types of events that will be received from the DFU Service.
22 */
23typedef enum
24{
25 BLE_DFU_START = 1, /**< The event indicating that the peer wants the application to prepare for a new firmware update. */
26 BLE_DFU_RECEIVE_INIT_DATA = 2, /**< The event indicating that the peer wants the application to prepare to receive init parameters. */
27 BLE_DFU_RECEIVE_APP_DATA = 3, /**< The event indicating that the peer wants the application to prepare to receive the new firmware image. */
28 BLE_DFU_VALIDATE = 4, /**< The event indicating that the peer wants the application to validate the newly received firmware image. */
29 BLE_DFU_ACTIVATE_N_RESET = 5, /**< The event indicating that the peer wants the application to undergo activate new firmware and restart with new valid application */
30 BLE_DFU_SYS_RESET = 6, /**< The event indicating that the peer wants the application to undergo a reset and start the currently valid application image.*/
31 BLE_DFU_PKT_RCPT_NOTIF_ENABLED = 7, /**< 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.*/
32 BLE_DFU_PKT_RCPT_NOTIF_DISABLED = 8, /**< The event indicating that the peer has disabled the packet receipt notifications.*/
33 BLE_DFU_PACKET_WRITE = 9, /**< 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_pkt_write element contained within @ref ble_dfu_evt_t.*/
34 BLE_DFU_BYTES_RECEIVED_SEND = 10 /**< 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. */
35} ble_dfu_evt_type_t;
36
37/**@brief DFU Procedure type.
38 *
39 * @details This enumeration contains the types of DFU procedures.
40 */
41typedef enum
42{
43 BLE_DFU_START_PROCEDURE = 1, /**< DFU Start procedure.*/
44 BLE_DFU_INIT_PROCEDURE = 2, /**< DFU Initialization procedure.*/
45 BLE_DFU_RECEIVE_APP_PROCEDURE = 3, /**< Firmware receiving procedure.*/
46 BLE_DFU_VALIDATE_PROCEDURE = 4, /**< Firmware image validation procedure .*/
47 BLE_DFU_PKT_RCPT_REQ_PROCEDURE = 8 /**< Packet receipt notification request procedure. */
48} ble_dfu_procedure_t;
49
50/**@brief DFU Response value type.
51 */
52typedef enum
53{
54 BLE_DFU_RESP_VAL_SUCCESS = 1, /**< Success.*/
55 BLE_DFU_RESP_VAL_INVALID_STATE = 2, /**< Invalid state.*/
56 BLE_DFU_RESP_VAL_NOT_SUPPORTED = 3, /**< Operation not supported.*/
57 BLE_DFU_RESP_VAL_DATA_SIZE = 4, /**< Data size exceeds limit.*/
58 BLE_DFU_RESP_VAL_CRC_ERROR = 5, /**< CRC Error.*/
59 BLE_DFU_RESP_VAL_OPER_FAILED = 6, /**< Operation failed.*/
60} ble_dfu_resp_val_t;
61
62/**
63 * @brief FSM transition
64 *
65 * Struct that describes a transition in the FSM.
66 */
67typedef struct
68{ /**
69 * @brief State
70 */
71 uint8_t st;
72
73 /**
74 * @brief Event
75 */
76 uint8_t ev;
77
78 /**
79 * @brief Transition function
80 */
81 uint8_t (*fn)(aci_state_t *aci_state, aci_evt_t *aci_evt);
82} dfu_transition_t;
83
84void dfu_initialize (void);
85void dfu_update (aci_state_t *aci_state, aci_evt_t *aci_evt);
86
87#endif /* DFU_H_ */
Note: See TracBrowser for help on using the repository browser.