#ifndef __IAP_UPGRADE_H__
#define __IAP_UPGRADE_H__

#include <main.h>

#define UPGRADE_TIMEOUT_MS  60000  // 数据帧间隔超时时间：60秒



void send_upgrade_start_response(uint8_t func_code, uint16_t reg_addr, uint8_t status_code, uint16_t sliceCount);
void send_upgrade_data_response(uint8_t func_code, uint16_t reg_addr, uint8_t status_code, uint16_t sliceCount);
void send_upgrade_end_response(uint8_t func_code, uint16_t reg_addr, uint8_t status_code, uint16_t sliceCount);

uint32_t get_backup_app_addr(void);
void reset_upgrade_state(void);
void check_upgrade_data4001_timeout(void);
void handle_upgrade_start_frame(uint8_t *data);
void handle_upgrade_data_frame(uint8_t *data);
void handle_upgrade_end_frame(void);
void handle_rollback_request(void);
void app_jump_check_and_jump(void);
bool JumpToApp(uint32_t app_address);
#endif

