123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249 |
- #ifndef BLE_DFU_H__
- #define BLE_DFU_H__
- #include <stdint.h>
- #include "ble_srv_common.h"
- #include "nrf_sdh_ble.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- #define BLE_DFU_SOC_OBSERVER_PRIO 1
- #define BLE_DFU_BUTTONLESS_CHAR_UUID (0x0003)
- #define BLE_DFU_BUTTONLESS_BONDED_CHAR_UUID (0x0004)
- #define BLE_NORDIC_VENDOR_BASE_UUID \
- {{ \
- 0x50, 0xEA, 0xDA, 0x30, 0x88, 0x83, 0xB8, 0x9F, \
- 0x60, 0x4F, 0x15, 0xF3, 0x00, 0x00, 0xC9, 0x8E \
- }}
- typedef enum
- {
- BLE_DFU_EVT_BOOTLOADER_ENTER_PREPARE,
- BLE_DFU_EVT_BOOTLOADER_ENTER,
- BLE_DFU_EVT_BOOTLOADER_ENTER_FAILED,
- BLE_DFU_EVT_RESPONSE_SEND_ERROR,
- } ble_dfu_buttonless_evt_type_t;
- typedef void (*ble_dfu_buttonless_evt_handler_t) (ble_dfu_buttonless_evt_type_t p_evt);
- typedef enum
- {
- DFU_RSP_INVALID = 0x00,
- DFU_RSP_SUCCESS = 0x01,
- DFU_RSP_OP_CODE_NOT_SUPPORTED = 0x02,
- DFU_RSP_OPERATION_FAILED = 0x04,
- DFU_RSP_ADV_NAME_INVALID = 0x05,
- DFU_RSP_BUSY = 0x06,
- DFU_RSP_NOT_BONDED = 0x07,
- } ble_dfu_buttonless_rsp_code_t;
- typedef enum
- {
- DFU_OP_RESERVED = 0x00,
- DFU_OP_ENTER_BOOTLOADER = 0x01,
- DFU_OP_SET_ADV_NAME = 0x02,
- DFU_OP_RESPONSE_CODE = 0x20
- } ble_dfu_buttonless_op_code_t;
- typedef struct
- {
- uint8_t uuid_type;
- uint16_t service_handle;
- uint16_t conn_handle;
- ble_gatts_char_handles_t control_point_char;
- uint32_t peers_count;
- ble_dfu_buttonless_evt_handler_t evt_handler;
- bool is_waiting_for_reset;
- bool is_waiting_for_svci;
- } ble_dfu_buttonless_t;
- typedef struct
- {
- ble_dfu_buttonless_evt_handler_t evt_handler;
- } ble_dfu_buttonless_init_t;
- uint32_t ble_dfu_buttonless_init(const ble_dfu_buttonless_init_t * p_dfu_init);
- uint32_t ble_dfu_buttonless_async_svci_init(void);
- uint32_t ble_dfu_buttonless_backend_init(ble_dfu_buttonless_t * p_dfu);
- uint32_t ble_dfu_buttonless_char_add(ble_dfu_buttonless_t * p_dfu);
- uint32_t ble_dfu_buttonless_resp_send(ble_dfu_buttonless_op_code_t op_code, ble_dfu_buttonless_rsp_code_t rsp_code);
- void ble_dfu_buttonless_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context);
- void ble_dfu_buttonless_on_ctrl_pt_write(ble_gatts_evt_write_t const * p_evt_write);
- uint32_t ble_dfu_buttonless_bootloader_start_prepare(void);
- uint32_t ble_dfu_buttonless_bootloader_start_finalize(void);
- #ifdef __cplusplus
- }
- #endif
- #endif
|