| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- #ifndef __OTA_XSP_H__
- #define __OTA_XSP_H__
- #include "stm32f10x.h"
- #define FIRST_UPDATE_TYPE 0x04 //升级类
- #define SECOND_UPDATE_START 0x1003 //启动升级下行
- #define SECOND_UPDATE_CONTINUE 0x1004 //连续包下行
- #define SECOND_UPDATE_RETRA_DOWN 0x1005 //重传包下行
- #define SECOND_UPDATE_OFFLINE_CMD 0x1006 //网关下发开始离线升级指令下行
- #define SECOND_UPDATE_STATE_DOWN 0x1007 //升级状态读取下行
- #define SECOND_UPDATE_RETRA_UP 0x2005 //重传包请求上行
- #define SECOND_UPDATE_STATE_UP 0x2007 //升级状态上行
- //固件类型
- enum {
- FIRM_BT_TYPE = 0x01,
- FIRM_PT_TYPE = 0x02,
- FIRM_MCU_TYPE = 0x03,
- FIRM_LUA_TYPE = 0x04,
- };
- #define OTA_XSP_EACH_MAX_BYTES 128 //单包最大字节数
- #define OTA_XSP_LOSEPAGE 50 //最大丢包百分比 最小为10%,最大为60%
- #define OTA_XSP_UPDATE_PAYLAOA_LEN 128 //升级包每包下发的字节数
- //开始升级指令
- typedef struct _ota_xsp_start_info {
- uint16_t rcv_device_type; //接收设备类型
- uint32_t rcv_device_sn; //接收设备sn
- uint16_t des_device_type; //被升级设备类型
- uint32_t des_device_sn; //被升级设备sn
- uint8_t firmware_type; //固件类型
- uint32_t update_version; //升级包版本
- uint32_t total_bytes; //升级包总长度
- uint16_t each_max_bytes; //单包最大字节数
- uint16_t losepage; //最大丢包百分比 最小为10%,最大为60%
- uint16_t Send_interval; //发送间隔
- }__attribute__((packed)) ota_xsp_start_info_t;
- //连续发包指令
- typedef struct _ota_xsp_continues_info {
- uint16_t rcv_device_type; //接收设备类型
- uint32_t rcv_device_sn; //接收设备sn
- uint16_t des_device_type; //被升级设备类型
- uint32_t des_device_sn; //被升级设备sn
- uint16_t total_pkgs; //总包数
- uint16_t sub_pkg_id; //当前包id
- uint16_t sub_pkg_len; //当前包长度
- uint8_t pkg_content[OTA_XSP_UPDATE_PAYLAOA_LEN]; //数据
- // uint32_t *pkg_content;
- }__attribute__((packed)) ota_xsp_continues_info_t;
- //重传请求
- typedef struct _ota_xsp_retransmit_req {
- uint16_t rcv_device_type; //接收设备类型
- uint32_t rcv_device_sn; //接收设备sn
- uint16_t repeat_devict_type; //发起请求的设备类型
- uint32_t repeat_device_sn; //发起请求的设备sn
- uint16_t repeat_sub_pkg_id; //升级包编号
- }__attribute__((packed)) ota_xsp_retransmit_req_t;
- //升级状态读取下行
- typedef struct _ota_xsp_state_read
- {
- uint16_t rcv_device_type; //接收设备类型
- uint32_t rcv_device_sn; //接收设备sn
- uint16_t des_device_type; //被升级设备类型
- uint32_t des_device_sn; //被升级设备sn
- uint32_t reserve; //预留
- }__attribute__((packed)) ota_xsp_xsp_state_read_t;
- //升级状态上传
- typedef struct _ota_xsp_state_upload
- {
- uint16_t rcv_device_type; //接收设备类型
- uint32_t rcv_device_sn; //接收设备sn
- uint16_t des_device_type; //目标设备类型
- uint32_t des_device_sn; //目标设备sn
- uint32_t des_bt_ver; //被升级设备的bootloader版本
- uint32_t des_pt_ver; //升级目标设备产测版本
- uint32_t des_app_ver; //被升级设备的app版本
- uint8_t update_state; //升级状态码
- uint32_t reserve; //预留
- }__attribute__((packed)) ota_xsp_state_upload_t;
- #define OTA_XSP_START_INFO_LEN sizeof(ota_xsp_start_info_t)
- #define OTA_XSP_CONTINUES_INFO_LEN sizeof(ota_xsp_continues_info_t)
- #define OTA_XSP_RETRNSMIT_INFO_LEN sizeof(ota_xsp_retransmit_req_t)
- void xsp_master_ota_proc(uint8_t *data, uint16_t len);
- void xsp_ota_handle(void);
- #endif
|