311 lines
11 KiB
C
Executable File
311 lines
11 KiB
C
Executable File
/****************************************************************************
|
|
|
|
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
|
|
|
|
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
|
|
be copied by any method or incorporated into another program without
|
|
the express written consent of Aerospace C.Power. This Information or any portion
|
|
thereof remains the property of Aerospace C.Power. The Information contained herein
|
|
is believed to be accurate and Aerospace C.Power assumes no responsibility or
|
|
liability for its use in any way and conveys no license or title under
|
|
any patent or copyright and makes no representation or warranty that this
|
|
Information is free from patent or copyright infringement.
|
|
|
|
****************************************************************************/
|
|
#ifndef IOT_GR_UPGRADE_H
|
|
#define IOT_GR_UPGRADE_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define IOT_GREE_MAX_STA_FW_SIZE ((444 + 64) * 1024)
|
|
|
|
/** define the gree upgrade data recv max length */
|
|
#define GREE_UPGRADE_FRM_MAX_LEN 417
|
|
#define GREE_UPGRADE_DATA_PACKET_LEN 400
|
|
#define GREE_UPGRADE_CMD_CONTROL_MIN 0x90
|
|
#define GREE_UPGRADE_CMD_CONTROL_MAX 0x98
|
|
/** define the gree upgrade data recv control code */
|
|
#define GREE_UPGRADE_DATA_CONTROL 0x9A
|
|
#define GREE_UPGRADE_DATA_FRM_MIN_LEN 17
|
|
/** the position of gree upgrade length low byte */
|
|
#define GREE_UPGRADE_DATA_FRM_LEN_LOW_BYTE 13
|
|
/** the position of gree upgrade length high byte */
|
|
#define GREE_UPGRADE_DATA_FRM_LEN_HIG_BYTE 14
|
|
|
|
#define GREE_UPGRADE_DATA_FRM_CTL_LEN 8
|
|
/** cco receive sta upgrade data max progress */
|
|
#define GREE_CCO_RECV_STA_UPGRADE_DATA_MAX_PROGRESS 20
|
|
/** cco remote sta upgrade data max progress */
|
|
#define GREE_CCO_BROADCAST_UPGRADE_DATA_MAX_PROGRESS 80
|
|
/** remote sta request recv upgrade data max progress */
|
|
#define GREE_STA_RECV_UPGRADE_DATA_MAX_PROGRESS 50
|
|
|
|
/** cco receive cco upgrade data max progress */
|
|
#define GREE_CCO_RECV_CCO_UPGRADE_DATA_MAX_PROGRESS 85
|
|
/** cco upgrade successful progress */
|
|
#define GREE_CCO_UPGRADE_SUCC_PROGRESS 100
|
|
|
|
/** for response sta upgrade state count */
|
|
#define RESP_UPGRADE_STATE_CNT_MAX 120
|
|
/** define sync upgrade address max count */
|
|
#define GE_UPGRADE_REMOTE_ADDR_NUM 50
|
|
|
|
/** GE command use 6 byte mac */
|
|
#define UPGRADE_MAC_BYTE MAC_ADDR_LEN_6BYTE
|
|
typedef uint16_t GE_UPGRADE_UNITBIT;
|
|
|
|
/** check gree upgrade command */
|
|
#define GREE_CHECK_UPGRADE_CMD(control) ((control >= \
|
|
GREE_UPGRADE_CMD_CONTROL_MIN && control <= GREE_UPGRADE_CMD_CONTROL_MAX) || \
|
|
(control == GREE_UPGRADE_DATA_CONTROL))
|
|
#define GREE_ACQUIRE_UPGRADE_CMD_LEN(control) (control - \
|
|
GREE_UPGRADE_CMD_CONTROL_MIN)
|
|
|
|
/* dl cmd ack result */
|
|
#define GREE_UPGRADE_CMD_SUCCESS 0
|
|
#define GREE_UPGRADE_CMD_FAILUR 1
|
|
#define GREE_UPGRADE_CMD_DATA_INDEXERROR 2
|
|
#define GREE_UPGRADE_CMD_PARAM_INVALID 3
|
|
#define GREE_UPGRADE_CMD_UGTYPE_NONSUPPORT 4
|
|
#define GREE_UPGRADE_CMD_CCO_IS_GROUPNETING 5
|
|
#define GREE_UPGRADE_CMD_LENGTH_CHECK_ERR 6
|
|
|
|
/* ul event */
|
|
#define GREE_REPORT_UPGRADE_INVALID 0
|
|
#define GREE_REPORT_UPGRADE_CRC_OK 1
|
|
#define GREE_REPORT_UPGRADE_CRC_ERROR 2
|
|
#define GREE_REPORT_UPGRADE_RESET_CHIP 3
|
|
#define GREE_REPORT_UPGRADE_FILE_INVALID 4
|
|
#define GREE_REPORT_UPGRADE_UGTYPE_MISMATCH 5
|
|
#define GREE_REPORT_UPGRADE_FILE_COMPLETED 6
|
|
|
|
/* type of gree upgrading */
|
|
#define IOT_GREE_UPGRADE_INVALID 0
|
|
#define IOT_GREE_UPGRADE_LOCAL 1
|
|
#define IOT_GREE_UPGRADE_ALL 2
|
|
#define IOT_GREE_UPGRADE_STA_LIST 3
|
|
#define IOT_GREE_UPGRADE_P2P 4
|
|
|
|
/** remote sta upgrading state */
|
|
#define IOT_PLC_REMOTE_UPGRADE_INIT 0
|
|
#define IOT_PLC_REMOTE_UPGRADE_STARTING 1
|
|
#define IOT_PLC_REMOTE_UPGRADE_STARTED 2
|
|
#define IOT_PLC_REMOTE_UPGRADE_TRANSFERRED 3
|
|
#define IOT_PLC_REMOTE_UPGRADE_FAILED 4
|
|
#define IOT_PLC_REMOTE_UPGRADE_STOPED 5
|
|
#define IOT_PLC_REMOTE_UPGRADE_START_FAIL 6
|
|
#define IOT_PLC_REMOTE_UPGRADE_LISTEN 7
|
|
#define IOT_PLC_REMOTE_UPGRADE_RESET 8
|
|
|
|
enum proto_upgrade_dl_subfn_e {
|
|
PROTO_UPGRADE_DATA = 0x1,
|
|
PROTO_UPGRADE_QUERY_STATUS = 0x2,
|
|
PROTO_UPGRADE_STOP = 0x3,
|
|
PROTO_UPGRADE_START_NODE = 0x4,
|
|
};
|
|
|
|
enum proto_upgrade_ul_subfn_e {
|
|
PROTO_UPGRADE_DATA_ACK = 0x1,
|
|
PROTO_UPGRADE_DATA_RESULT = 0x2,
|
|
PROTO_UPGRADE_COMPLETE = 0x3,
|
|
PROTO_UPGRADE_STATUS_RESP = 0x4,
|
|
PROTO_UPGRADE_STOP_ACK = 0x5,
|
|
PROTO_UPGRADE_START_NODE_ACK = 0x6,
|
|
};
|
|
|
|
enum proto_upgrade_status_e {
|
|
UPGRADE_STATUS_IDLE = 0x0,
|
|
UPGRADE_STATUS_DATA_RECVING = 0x1,
|
|
UPGRADE_STATUS_DATA_RECV_CMP = 0x2,
|
|
UPGRADE_STATUS_DATA_BRST = 0x3,
|
|
UPGRADE_STATUS_DATA_BRST_CMP = 0x4,
|
|
UPGRADE_STATUS_COMPLETE = 0x5,
|
|
UPGRADE_STATUS_IDX_ERR = 0x6,
|
|
UPGRADE_STATUS_TYPE_ERR = 0x7,
|
|
UPGRADE_STATUS_CRC_ERR = 0x8,
|
|
UPGRADE_STATUS_FILE_ERR = 0x9,
|
|
UPGRADE_STATUS_REMOTE_ERR = 0xA,
|
|
UPGRADE_STATUS_NO_IN_WHT_ERR = 0xB,
|
|
UPGRADE_STATUS_STA_QUERY = 0xC,
|
|
};
|
|
|
|
#pragma pack(push) // save the pack status
|
|
#pragma pack(1) // 1 byte align
|
|
|
|
/* gree upgrade data */
|
|
typedef struct _gree_frame_fn250_subfn01_t {
|
|
ge_extend_fn_hdr_t hdr;
|
|
uint8_t resv0;
|
|
uint8_t resv1;
|
|
uint8_t seq;
|
|
uint8_t upgrade_type;
|
|
uint16_t total_seg_cnt;
|
|
uint16_t seg_index;
|
|
uint16_t data_len;
|
|
uint8_t data[GREE_UPGRADE_DATA_PACKET_LEN];
|
|
ge_frm_tail_t tail;
|
|
}gree_frame_fn250_subfn01_t;
|
|
|
|
/* query upgrade status */
|
|
typedef struct _gree_frame_fn250_subfn02_t {
|
|
ge_extend_fn_hdr_t hdr;
|
|
uint8_t resv0;
|
|
uint8_t resv1;
|
|
uint8_t seq;
|
|
uint8_t mac[UPGRADE_MAC_BYTE];
|
|
ge_frm_tail_t tail;
|
|
} gree_frame_fn250_subfn02_t;
|
|
|
|
/* stop upgrade */
|
|
typedef struct _gree_frame_fn250_subfn03_t {
|
|
ge_extend_fn_hdr_t hdr;
|
|
uint8_t resv0;
|
|
uint8_t resv1;
|
|
uint8_t seq;
|
|
ge_frm_tail_t tail;
|
|
} gree_frame_fn250_subfn03_t;
|
|
|
|
/* start node upgrade */
|
|
typedef struct _gree_frame_fn250_subfn04_t {
|
|
ge_extend_fn_hdr_t hdr;
|
|
uint8_t resv0;
|
|
uint8_t resv1;
|
|
uint8_t seq;
|
|
uint16_t total;
|
|
uint16_t index;
|
|
uint8_t mac[UPGRADE_MAC_BYTE];
|
|
ge_frm_tail_t tail;
|
|
} gree_frame_fn250_subfn04_t;
|
|
|
|
/* gree upgrade data ack */
|
|
typedef struct _gree_frame_fn251_subfn01_t {
|
|
ge_extend_fn_hdr_t hdr;
|
|
uint8_t resv0;
|
|
uint8_t resv1;
|
|
uint8_t seq;
|
|
uint8_t result;
|
|
uint16_t seg_index;
|
|
ge_frm_tail_t tail;
|
|
} gree_frame_fn251_subfn01_t;
|
|
|
|
/* gree upgrade data result */
|
|
typedef struct _gree_frame_fn251_subfn02_t {
|
|
ge_extend_fn_hdr_t hdr;
|
|
uint8_t resv0;
|
|
uint8_t resv1;
|
|
uint8_t seq;
|
|
uint8_t result;
|
|
uint8_t reason;
|
|
ge_frm_tail_t tail;
|
|
} gree_frame_fn251_subfn02_t;
|
|
|
|
/* gree upgrade completed */
|
|
typedef struct _gree_frame_fn251_subfn03_t {
|
|
ge_extend_fn_hdr_t hdr;
|
|
uint8_t resv0;
|
|
uint8_t resv1;
|
|
uint8_t seq;
|
|
ge_frm_tail_t tail;
|
|
} gree_frame_fn251_subfn03_t;
|
|
|
|
/* response query gree upgrade status */
|
|
typedef struct _gree_frame_fn251_subfn04_t {
|
|
ge_extend_fn_hdr_t hdr;
|
|
uint8_t resv0;
|
|
uint8_t resv1;
|
|
uint8_t seq;
|
|
uint16_t total;
|
|
uint16_t index;
|
|
uint8_t mac[UPGRADE_MAC_BYTE];
|
|
uint8_t status;
|
|
uint8_t progress;
|
|
ge_frm_tail_t tail;
|
|
} gree_frame_fn251_subfn04_t;
|
|
|
|
/* stop upgrade ack */
|
|
typedef struct _gree_frame_fn251_subfn05_t {
|
|
ge_extend_fn_hdr_t hdr;
|
|
uint8_t resv0;
|
|
uint8_t resv1;
|
|
uint8_t seq;
|
|
uint8_t result;
|
|
uint8_t reason;
|
|
ge_frm_tail_t tail;
|
|
} gree_frame_fn251_subfn05_t;
|
|
|
|
/* start upgrade node ack */
|
|
typedef struct _gree_frame_fn251_subfn06_t {
|
|
ge_extend_fn_hdr_t hdr;
|
|
uint8_t resv0;
|
|
uint8_t resv1;
|
|
uint8_t seq;
|
|
uint8_t result;
|
|
uint8_t reason;
|
|
ge_frm_tail_t tail;
|
|
} gree_frame_fn251_subfn06_t;
|
|
|
|
#pragma pack(pop) // restore the pack status
|
|
|
|
/** cco local upgrade info */
|
|
typedef struct _gree_cco_upgrade_info_t {
|
|
uint32_t len;
|
|
uint8_t *file_data;
|
|
uint16_t expect_seg_index;
|
|
uint8_t upgrade_type;
|
|
uint8_t upgrade_status;
|
|
/** cco recv data and broadcast data progress */
|
|
uint8_t data_progress;
|
|
/** sta upgrade average progress*/
|
|
uint8_t sta_upgrade_prg;
|
|
/** stop upgrade flag */
|
|
bool_t stop_upgrade_flag;
|
|
/** sta upgrade count */
|
|
uint16_t sta_upgrade_cnt;
|
|
/** upgrade_id */
|
|
uint32_t upgrade_id;
|
|
} gree_cco_upgrade_info_t;
|
|
|
|
/** sta remote network upgrade info */
|
|
typedef struct _gree_sta_upgrade_info_t {
|
|
uint8_t mac[UPGRADE_MAC_BYTE];
|
|
uint8_t status;
|
|
uint8_t progress;
|
|
} gree_sta_upgrade_info_t;
|
|
|
|
/* Gree upgrade fn code handle. */
|
|
typedef void(*PROTO_UPGRADE_FN_HANDLE)(uint8_t *data, uint16_t len);
|
|
|
|
/* Gree upgrade fn table */
|
|
typedef struct _proto_upgrade_fnhdl_tbl_t
|
|
{
|
|
/*gree function code*/
|
|
uint32_t cmdid;
|
|
/*each code handler*/
|
|
PROTO_UPGRADE_FN_HANDLE cmd_handle_fn;
|
|
}proto_upgrade_fnhdl_tbl_t;
|
|
|
|
/**
|
|
* @brief iot_proto_upgrade_fn_handler - handle gree upgrade fn cmd
|
|
* @param data: data for upgrade cmd
|
|
* @param len: data len
|
|
*/
|
|
void iot_proto_upgrade_fn_handler(uint8_t *data, uint16_t len);
|
|
|
|
/**
|
|
* @brief iot_proto_upgrade_initialize - proto upgrade initialize
|
|
*/
|
|
void iot_proto_upgrade_initialize();
|
|
|
|
/**
|
|
* @brief iot_proto_update_sta_upgrade_status - proto update upgrade state
|
|
*/
|
|
void iot_proto_update_sta_upgrade_status(void);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|