/****************************************************************************
 *
 * Copy right:   2017-, Copyrigths of EigenComm Ltd.
 * File name:    app.h
 * Description:  EC616 onenet demo entry header file
 * History:      Rev1.0   2018-07-12
 *
 ****************************************************************************/
#include "commontypedef.h"
#ifndef  APP_H
#define  APP_H
#ifdef __cplusplus
extern "C" {
#endif
//全局定义声明区
#define BMS_MANUFACTURE (1) //BMS制造商表示1-超力源,2-美顺
#define DATA_MODULE_TYPE (1) //1表示NB模块,2表示4G cat1
#define BAT4830
//#define BAT6060
#ifdef  BAT4830
    #define BATT_CELL_VOL_NUM  (14)
    #define BATT_TEMP_NUM  (3)
    #define BMS_INFO  (1)      //1BMS信息表示4830
    #define BATT_OTHER_TEMP_NUM  (2)
#elif defined BAT6060
    #define BATT_CELL_VOL_NUM  (17)
    #define BATT_TEMP_NUM  (5)
    #define BMS_INFO  (2)       //2-BMS信息表示6060
    #define BATT_OTHER_TEMP_NUM  (2)
#endif
#define BATT_CELL_VOL_NUM_2 (BATT_CELL_VOL_NUM*2)
#define BATT_SN_LEN           17
 
#define HWVERSION		    0x0102    //硬件主版本,现为V1.2板
#define	BLSWVERSION		0x01020000    //BootLoader版本号V1.2.0.0
#define	DRVSWVERSION		0x01030000     //驱动层版本号V1.3.0.0
#define	APPSWVERSION		0x01020101      
#define APP_CONFIG_FILE_LATEST_VERSION 0
#define APP_CONFIG_FILE_NAME  "qxappconfig.nvm"
//--------------------------------------------------------------------------------
typedef struct AppNVMDataType
{	
    BOOL   appDataModify;		//数据更改标志位
	UINT8  battSN[BATT_SN_LEN]; //电池SN号码
   	BOOL   isBattLocked;		//0:not locked;	1:locked
    UINT8  chargEndWorkTime;   //the unit is min
    UINT8  wakeupWorkTime;     //the unit is min
    UINT8  sleepTime;
    UINT16 HwVersion;
    UINT32 BLSwVersion;
    UINT32 DrvSwVersion;
    UINT32 AppSwVersion;
}AppNVMDataType;

typedef struct AppConfigHeader
{
    UINT16 fileBodySize; //file body size, not include size of header;
    UINT8  version;
    UINT8  checkSum;
}AppConfigHeader;
typedef struct _UartAnswerMsg
{
	bool UartFlag;
    UINT8 dataPtr[8];
    UINT16 len;
}UartAnswerMsgType;

typedef enum
{
    APP_INIT_STATE,
    APP_DEACTIVE_STATE,
    APP_IPREADY_STATE,
    APP_REPORT_STATE,
    APP_IDLE_STATE,
    APP_WAIT_STATE
} appRunningState_t;
//uint8_t* Uart_Receive_func(Uart_Receive_Type Uart_Receive_Msg,uint8_t* Uart_Rece_buffer,uint8_t Data_Len);

#ifdef __cplusplus
}
#endif
#endif /* APP_H */