fota_proc.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #ifndef _FOTA_PROC_H
  2. #define _FOTA_PROC_H
  3. #define FOT_STA_INIT BIT(0)
  4. #define FOT_STA_START BIT(1)
  5. #define FOT_STA_PAUSE BIT(2)
  6. #define FOT_FLAG_UPDATE_OK BIT(0)
  7. #define FOT_FLAG_SYS_RESET BIT(1)
  8. #define FOT_FLAG_APP_CONNECT BIT(2)
  9. #define FOT_FLAG_CLK_SET BIT(3)
  10. #define FOT_FLAG_UPDATE_EXIT BIT(4)
  11. #define FOT_NOTIFY_STA 0x90
  12. #define FOT_GET_INFO 0x91
  13. #define FOT_GET_INFO_TLV 0x92
  14. #define FOT_OUT_DATA_START 0xA0
  15. #define FOT_OUT_DATA_CONTINUE 0x20
  16. #define FOT_CMD_POS 0
  17. #define FOT_SEQ_POS 1
  18. #define FOT_ADDR_POS 2
  19. #define FOT_DATA_LEN_POS 6
  20. #define DATA_START_POS 10
  21. #define DATA_CONTINUE_POS 2
  22. #define FOT_BLOCK_LEN 512
  23. /* Format: Ver. 2.3 => 0x0203 */
  24. #define FOT_PROTOCOL_VERSION 0x0200
  25. /* Unsigned Integer: 2Bytes */
  26. #define FOT_FEAT_DEFINITION ((0/* TWS */ << 0)|\
  27. (AB_FOT_EN << 1)|\
  28. (0/* Other */ << 15))
  29. typedef enum {
  30. FOTA_CHL_BLE,
  31. FOTA_CHL_USB,
  32. FOTA_CHL_MAX,
  33. } FOTA_CHL_TYPEDEF;
  34. typedef enum {
  35. INFO_DEV_VER = 1,
  36. INFO_UPDATE_REQ,
  37. INFO_DEV_FEATURE,
  38. INFO_DEV_CONNECT_STA,
  39. INFO_EDR_ADDR,
  40. INFO_DEV_CHANNEL,
  41. INFO_PROTOCOL_VER,
  42. } DEV_INFO_E;
  43. typedef struct PACKED {
  44. uint8_t seq;
  45. uint8_t remote_seq;
  46. uint8_t sta;
  47. uint8_t flag;
  48. uint16_t con_sta;
  49. uint16_t dev_ver;
  50. uint16_t remote_ver;
  51. uint32_t total_len;
  52. uint32_t remain_len;
  53. uint32_t hash;
  54. uint16_t data_pos;
  55. uint8_t recv_ok;
  56. uint32_t addr;
  57. uint32_t tick;
  58. } fot_s;
  59. typedef struct {
  60. int (* fota_send_packet_handle) (uint8_t *buf, uint16_t size);
  61. int (* fota_mtu_check_handle) (uint32_t *mtu);
  62. } ab_fota_cb_t;
  63. typedef struct PACKED {
  64. uint16_t version;
  65. uint32_t hash;
  66. uint32_t fw_size;
  67. } ab_fota_req_upgrade_t;
  68. void fota_init(ab_fota_cb_t *param, uint8_t chl);
  69. void fota_process(void);
  70. void fota_connected_handle(uint8_t chl);
  71. void fota_disconnected_handle(uint8_t chl);
  72. void fota_recv_packet_handle(uint8_t *buf, uint16_t size, uint8_t chl);
  73. void fota_pause(void);
  74. void fota_continue(void);
  75. bool fota_is_start(void);
  76. #endif // _FOTA_PROC_H