#ifndef __SOFT_UPDATE_H
#define __SOFT_UPDATE_H
#include "common.h"

enum vk_update_device
{
    // Update_buf 元素地址
    HEAD = 0,
    LEN = 1,
    TOTAL_PACK_NUM = 2,
    DEVICE = 4,
    UPDATE_STEP = 5,
    PACK_NUM = 6,
    PAYLOAD = 8,

    //更新步骤
    UPDATE_START = 200,
    UPDATE_ING = 201,
    UPDATE_END = 202,

    //设备ID
    UPDATE_OBS_F = 0x11,
    UPDATE_OBS_B = 0x12,
    UPDATE_TERAIN = 0x56,
    UPDATE_OBS360 = 0x78,
    UPDATE_SEED = 0xDA,
    UPDATE_FLOW = 0xDB,
    UPDATE_BMS = 0XDC,
    UPDATE_DISTOR = 0XDD,
    UPDATE_WEIGHT = 0xDE,
};


typedef struct 
{
    bool update_flag;
    uint8_t step;
    uint8_t node_id;
    uint32_t adr_offset;

    uint8_t frame_pci;
    uint8_t frame_len;

    uint8_t pack_content;
}ez_update;
extern ez_update EZup_par;

enum EZ_UPDATE
{
    STEP_DEFAULT = 0,
    STEP_FIND_NODE = 1, //发送125次寻找设备节点ID
    STEP_JUMP_BOOT = 2, //跳转boot
    STEP_EASER_FLASH = 3,//擦除FLASH
    STEP_SET_OFFSET_ADR = 4,//设置偏移地址
    STEP_SEND_DATE = 5, //发送升级数据
    STEP_ENDING = 6, //升级结束
    STEP_WAIT = 7,//等待

    PACK_HEAD = 10, //包头
    PACK_CONT = 11, //内容
    PACK_TAIL = 12, //包尾
    PACK_CRC = 13, //校验
    PACK_WAIT = 14, //等待雷达写flash
};

void Vk_Update_Device_Protocol(void);
void Update_Dev_Bootversion_Function(uint8_t data[]);
void mimo_obs_update_func(void);
void EZ_Radar_UpdateCanRecvHookFunction(uint32_t CanID, uint8_t data[], uint8_t len);
#endif

