#ifndef UWATER_FRAME_FUNC_REPLAY_JIANGSHUI_H
#define	UWATER_FRAME_FUNC_REPLAY_JIANGSHUI_H

#include "sys_config.h"
#ifdef PRODUCT_JS
//////////////////////////////////////////积成规约控制字/////////////////////////////////////////////////////////

//深水上传数据报文
#define SS_UPLOAD_CTRL                          0x67            
#define SS_ACK_UPLOAD_CTRL                      0xD6            
#define SS_UPLOAD_CTRL_ID0                      0x43          
#define SS_UPLOAD_CTRL_ID1                      0xA1           
#define SS_UPLOAD_CTRL_UDP_ID0                  0x31  //UDP上报数据数据标识        

//深水登录帧
#define SS_SIGN_IN_CTRL                         0x8f          
#define SS_ACK_SIGN_IN_CTRL                     0xe8         
#define SS_SIGN_IN_CTRL_ID0                     0x55           
#define SS_SIGN_IN_CTRL_ID1                     0xa1            

//清除失败次数
#define SS_CLEAR_FAIL_TIMES_CTRL                0x94            
#define SS_ACK_CLEAR_FAIL_TIMES_CTRL            0xEC
#define SS_CLEAR_FAIL_TIMES_CTRL_DI0            0x59 
#define SS_CLEAR_FAIL_TIMES_CTRL_DI1            0xA1 

//******************************************江西水务定制规约-NB***********************************/
//设置密集存储间隔
#define FM_SET_MJJI_SPACE_TIME_CTRL               0x5A        
#define FM_SET_MJJI_SPACE_TIME_REPLY_CTRL         0xCA
#define FM_SET_MJJI_SPACE_TIME_DI0                0x48
#define FM_SET_MJJI_SPACE_TIME_DI1                0xA0

//读取密集存储间隔
#define FM_RED_MJJI_SPACE_TIME_CTRL               0x5B        
#define FM_RED_MJJI_SPACE_TIME_REPLY_CTRL         0xCB
#define FM_RED_MJJI_SPACE_TIME_DI0                0x49
#define FM_RED_MJJI_SPACE_TIME_DI1                0xA0

//设置采样频率  
#define FM_SET_SAMPLING_FREQUENCY_CTRL               0x5D        
#define FM_SET_SAMPLING_FREQUENCY_REPLY_CTRL         0xCD
#define FM_SET_SAMPLING_FREQUENCY_DI0                0x50
#define FM_SET_SAMPLING_FREQUENCY_DI1                0xA0

//读取采样频率
#define FM_READ_SAMPLING_FREQUENCY_CTRL               0x5E        
#define FM_READ_SAMPLING_FREQUENCY_REPLY_CTRL         0xCE
#define FM_READ_SAMPLING_FREQUENCY_DI0                0x51
#define FM_READ_SAMPLING_FREQUENCY_DI1                0xA0

//设置NB模组为PSM或断电模式
#define FM_SET_PSM_PWDOWN_CTRL               0x85        
#define FM_SET_PSM_PWDOWN_REPLY_CTRL         0x05
#define FM_SET_PSM_PWDOWN_DI0                0x04
#define FM_SET_PSM_PWDOWN_DI1                0xA0


/////////////////////////////////////////////////积成规约数据结构///////////////////////////////////////////////
/**************************规约应答相关函数**********************************/
u8 up_deal_code_JiangShui(void);
u8 crack_frame_JiangShui(u16 frame_lenth,u8 *frame_buffer);
void Frame_ResetDealState_JiangShui(void);
void Frame_ack_JiangShui(u8* p_send_buf, u16* p_send_len);
/**************************上报相关函数***************************************/
#define JX_ONE_PACKET_COUNTS   45 //每包数据的间隔量条数
#define PACK_NUM_GPRS_TOTAL    378//江西水务规约上报数据字节数

void GetUploadDataResetState_JX(void);
u8 GetUploadDataCheckIdle_JX(void);
u8 GetUploadDataCheckTask_JX(void);
void GetUploadDataMachine_JX(u8 data_step, u8* p_send_buf, u16* p_send_len);

u16 GetUploadConnectTime_JX(u8 type);
/**************************存储相关函数***************************************/
void DataStoreInit(void);
void DataStoreMachine(void);
u8 DataStoreIfIdle(void);
/*****************************************************************************/
#define MAIN_CONNECT_TYPE      NBIOT_CONNECT_COAP
#define MAIN_SEND_TYPE         SEND_TYPE_COAP
#define SLAVE_CONNECT_TYPE     NBIOT_CONNECT_UDP1
#define SLAVE_SEND_TYPE        SEND_TYPE_UDP1
//主上报10秒，副上报5秒
#define COAP_UPLOAD_WAIT_ACK_TIME  100   
#define UDP_UPLOAD_WAIT_ACK_TIME   50 
#define NB_ONLINE_KEEP_TIME  50

#endif

#endif	


