598 lines
17 KiB
C
598 lines
17 KiB
C
|
#include "sys_config.h"
|
|||
|
|
|||
|
#if PRODUCT_SHTCP
|
|||
|
#include "sys_processor.h"
|
|||
|
#include "UWater_eeprom_driver.h"
|
|||
|
#include "UWater_timer1us_driver.h"
|
|||
|
#include "UWater_rtcc_app.h"
|
|||
|
#include "UWater_power_app.h"
|
|||
|
#include "UWater_gp22_app.h"
|
|||
|
#include "UWater_pt_app.h"
|
|||
|
#include "UWater_valve_app.h"
|
|||
|
#include "UWater_DataTools_App.h"
|
|||
|
#include "UWater_QZ_Store_App.h"
|
|||
|
#include "UWater_frame_func_ReplyNB.h"
|
|||
|
#include "UWater_frame_func_ReplyShangHe.h"
|
|||
|
|
|||
|
|
|||
|
static u8 task_complete_sh = PTL_PACK_FAIL;
|
|||
|
static STRUCT_FRAME_SH s_frame_struct_SH; //<2F><>Լ<EFBFBD><D4BC>Ϣ
|
|||
|
static u8 up_deal_stat_sh = UP_DEAL_S0;
|
|||
|
|
|||
|
static u16 g_frame_temp_len_sh=0;
|
|||
|
static u8 g_frame_temp_send_buf_sh[UP_DATA_BUF_SIZE_SH]; //<2F><><EFBFBD>ݲ<EFBFBD><DDB2>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
/*******<2A><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><D8B1><EFBFBD>*****************************************/
|
|||
|
static STRU_TCP_UPLOAD_FRAME tcp_upload_frame;
|
|||
|
static u8 upload_frame_stat_sh=0; //<2F><><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD><CFB1><EFBFBD>֡״̬
|
|||
|
static u8 upload_task_complete_sh = PTL_PACK_FAIL;
|
|||
|
static u8* new_message_data_rev_sh;
|
|||
|
static u8 temp_upload_step=0;
|
|||
|
static u8 upload_frame_retry_times=0;
|
|||
|
//<2F>ط<EFBFBD>
|
|||
|
static void frame_func_reply_TCP_ValveControl(void)
|
|||
|
{
|
|||
|
g_frame_temp_len_sh = 0;
|
|||
|
if(*(new_message_data_rev_sh) == 0x55)//<2F><><EFBFBD><EFBFBD>
|
|||
|
{
|
|||
|
FrameSetMsgApp(ValveOpenMsg);
|
|||
|
}
|
|||
|
else if(*(new_message_data_rev_sh) == 0x99)//<2F>ط<EFBFBD>
|
|||
|
{
|
|||
|
FrameSetMsgApp(ValveCloseMsg);
|
|||
|
}
|
|||
|
up_deal_stat_sh = up_deal_stat_sh;
|
|||
|
task_complete_sh = PTL_PACK_SUCCESS;
|
|||
|
}
|
|||
|
static void frame_func_reply_TCP_AckUpload(void)
|
|||
|
{
|
|||
|
g_frame_temp_len_sh = 0;
|
|||
|
if(*(new_message_data_rev_sh) == 0x01)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
{
|
|||
|
FrameSetMsgApp(MsgNbUpload_OffLine);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
}
|
|||
|
FrameSetMsgApp(MsgNbUplaod_AckOk);
|
|||
|
task_complete_sh = PTL_PACK_FAIL;
|
|||
|
}
|
|||
|
|
|||
|
//<2F><><EFBFBD>̺<EFBFBD>ˮ<EFBFBD><CBAE><EFBFBD><EFBFBD>Լ
|
|||
|
u8 crack_frame_SHTCP(u16 frame_lenth,u8 *frame_buffer)
|
|||
|
{
|
|||
|
u16 tmp_i = 0;
|
|||
|
u16 tmp_j = 0;
|
|||
|
u8 tmp_check = 0;
|
|||
|
for (tmp_i = 0; tmp_i < frame_lenth; tmp_i++)
|
|||
|
{
|
|||
|
if (FM_HEAD_MARK == *(frame_buffer + tmp_i))
|
|||
|
{
|
|||
|
if ((MET_TYPE_TCP == *(frame_buffer + tmp_i + 1))&&(UP_SOURCE_NB == frame_get_datasource()))
|
|||
|
{
|
|||
|
s_frame_struct_SH.met_type = MET_TYPE_TCP;
|
|||
|
s_frame_struct_SH.head_site = tmp_i; //<2F><>¼֡ͷ
|
|||
|
s_frame_struct_SH.len = *(frame_buffer + tmp_i + 10);//<2F><><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
|||
|
s_frame_struct_SH.end_site = s_frame_struct_SH.head_site + 10 + s_frame_struct_SH.len + 2;
|
|||
|
s_frame_struct_SH.check_len = s_frame_struct_SH.end_site - s_frame_struct_SH.head_site - 1;
|
|||
|
if(FM_END_MARK == *(frame_buffer + s_frame_struct_SH.end_site))
|
|||
|
{
|
|||
|
//<2F><><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD>
|
|||
|
tmp_check = 0;
|
|||
|
for (tmp_j = s_frame_struct_SH.head_site; tmp_j < (s_frame_struct_SH.end_site - 1); tmp_j++)
|
|||
|
{
|
|||
|
tmp_check += *(frame_buffer + tmp_j);
|
|||
|
}
|
|||
|
if (tmp_check == *(frame_buffer + s_frame_struct_SH.end_site - 1))
|
|||
|
{
|
|||
|
u8 check_addr[7];
|
|||
|
for (tmp_j = 0; tmp_j < 7; tmp_j++)
|
|||
|
{
|
|||
|
check_addr[tmp_j] = Sys_data_object.P1.met_addr[tmp_j];
|
|||
|
}
|
|||
|
s_frame_struct_SH.ctrl = *(frame_buffer + s_frame_struct_SH.head_site + 9);
|
|||
|
s_frame_struct_SH.DI0 = *(frame_buffer + s_frame_struct_SH.head_site + 11);
|
|||
|
s_frame_struct_SH.DI1 = *(frame_buffer + s_frame_struct_SH.head_site + 12);
|
|||
|
s_frame_struct_SH.serial_num0 = *(frame_buffer + s_frame_struct_SH.head_site + 13);
|
|||
|
new_message_data_rev_sh = (frame_buffer + s_frame_struct_SH.head_site + 14);
|
|||
|
switch(s_frame_struct_SH.ctrl)
|
|||
|
{
|
|||
|
case VALVE_CONTROL_TCP_CTRL:
|
|||
|
{
|
|||
|
check_addr[0] = check_addr[0]-1;//<2F><>ַΪ<D6B7>豸<EFBFBD><E8B1B8>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һλΪ 0<><30>8
|
|||
|
}
|
|||
|
break;
|
|||
|
default:
|
|||
|
{
|
|||
|
}
|
|||
|
break;
|
|||
|
}
|
|||
|
if(SUCCESS == check_apply_addr(frame_buffer + s_frame_struct_SH.head_site + 2, check_addr))
|
|||
|
{
|
|||
|
return SUCCESS_IES;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
return ERROR_IES;
|
|||
|
}
|
|||
|
|
|||
|
//<2F><>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD>
|
|||
|
u8 up_deal_code_sh(void)
|
|||
|
{
|
|||
|
task_complete_sh = PTL_PACK_BUSY;
|
|||
|
switch(s_frame_struct_SH.ctrl)
|
|||
|
{
|
|||
|
case VALVE_CONTROL_TCP_CTRL:
|
|||
|
{
|
|||
|
frame_func_reply_TCP_ValveControl();
|
|||
|
s_frame_struct_SH.ack_ctrl = ACK_VALVE_CONTROL_TCP_CTRL;
|
|||
|
}
|
|||
|
break;
|
|||
|
case FM_TCP_UPLOAD_REPLAY_CTRL:
|
|||
|
{
|
|||
|
frame_func_reply_TCP_AckUpload();
|
|||
|
s_frame_struct_SH.ack_ctrl = FM_TCP_UPLOAD_CTRL;
|
|||
|
}
|
|||
|
break;
|
|||
|
default:
|
|||
|
{
|
|||
|
up_deal_stat_sh = UP_DEAL_S0;
|
|||
|
task_complete_sh = PTL_PACK_FAIL;
|
|||
|
}
|
|||
|
break;
|
|||
|
}
|
|||
|
return task_complete_sh;
|
|||
|
}
|
|||
|
|
|||
|
void Frame_ResetDealState_SH(void)
|
|||
|
{
|
|||
|
up_deal_stat_sh = UP_DEAL_S0;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
void Frame_CreatCs_AckSH(u8* p_send_buf, u16* p_send_len)
|
|||
|
{
|
|||
|
int i=0;
|
|||
|
//<2F><>Ӧ<EFBFBD><D3A6>֡ͷ
|
|||
|
p_send_buf[0] = 0xFE;
|
|||
|
p_send_buf[1] = 0xFE;
|
|||
|
p_send_buf[2] = FM_HEAD_MARK;
|
|||
|
p_send_buf[3] = MET_TYPE;
|
|||
|
for (i = 0; i < 7; i++)
|
|||
|
{
|
|||
|
p_send_buf[4 + i] = Sys_data_object.P1.mac_addr[i];
|
|||
|
}
|
|||
|
p_send_buf[11] = s_frame_struct_SH.ack_ctrl;
|
|||
|
p_send_buf[12] = (3+g_frame_temp_len_sh);
|
|||
|
p_send_buf[13] = s_frame_struct_SH.DI0;
|
|||
|
p_send_buf[14] = s_frame_struct_SH.DI1;
|
|||
|
p_send_buf[15] = s_frame_struct_SH.serial_num0;
|
|||
|
for(i=0;i<g_frame_temp_len_sh;i++)
|
|||
|
{
|
|||
|
p_send_buf[16+i] = g_frame_temp_send_buf_sh[i];
|
|||
|
}
|
|||
|
p_send_buf[16+g_frame_temp_len_sh] = check_cs(&p_send_buf[2], (p_send_buf[12] + 11));
|
|||
|
p_send_buf[17+g_frame_temp_len_sh] = FM_END_MARK;
|
|||
|
*p_send_len = (18+g_frame_temp_len_sh);
|
|||
|
}
|
|||
|
|
|||
|
/****************************************************************<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD><CFB1><EFBFBD><EFBFBD>ݵĴ<DDB5><C4B4><EFBFBD>*********************************************/
|
|||
|
static void Register_TcpFrameData(u8 *p_send_buf, u16 *p_send_len)
|
|||
|
{
|
|||
|
u8 i=0;
|
|||
|
char imei_buf[16];
|
|||
|
|
|||
|
NbiotGetIMEI(imei_buf);
|
|||
|
|
|||
|
for(i=0;i<15;i++)
|
|||
|
{
|
|||
|
*p_send_buf++ = imei_buf[i];
|
|||
|
}
|
|||
|
*p_send_len = 15;
|
|||
|
}
|
|||
|
static void Ping_TcpFrameData(u8 *p_send_buf, u16 *p_send_len)
|
|||
|
{
|
|||
|
u8 i=0;
|
|||
|
|
|||
|
for(i=0;i<3;i++)
|
|||
|
{
|
|||
|
*p_send_buf++ = '0';
|
|||
|
}
|
|||
|
*p_send_len = 3;
|
|||
|
}
|
|||
|
//TCP<43>ϱ<EFBFBD><CFB1><EFBFBD><EFBFBD><EFBFBD>֡
|
|||
|
static void Upload_TcpFrameData(u8* p_send_buf, u16* p_send_len)
|
|||
|
{
|
|||
|
u8 i=0;
|
|||
|
UNION_4U8TOU32 tmp_datas_buf;
|
|||
|
u8 temp_data=0;
|
|||
|
TCP_STATE tcp_stat;
|
|||
|
MET_STATE temp_state;
|
|||
|
Fram_To_Float tmp_float;
|
|||
|
DateTime tempRtccTime;
|
|||
|
UNION_2U8TOU16 temp_bat_val;
|
|||
|
|
|||
|
tcp_upload_frame.data.HeadBuf[0] = 0xFE;
|
|||
|
tcp_upload_frame.data.HeadBuf[1] = 0xFE;
|
|||
|
tcp_upload_frame.data.HeadBuf[2] = 0x68;
|
|||
|
tcp_upload_frame.data.HeadBuf[3] = 0x20;
|
|||
|
for (int i = 0; i < 7; i++)
|
|||
|
{
|
|||
|
tcp_upload_frame.data.Addr[i] = Sys_data_object.P1.met_addr[i];
|
|||
|
}
|
|||
|
tcp_upload_frame.data.Ctrl = 0x81;
|
|||
|
tcp_upload_frame.data.Num = 0;//59;
|
|||
|
tcp_upload_frame.data.DataFlag[0] = 0x90;
|
|||
|
tcp_upload_frame.data.DataFlag[1] = 0x1F;
|
|||
|
tcp_upload_frame.data.Ser = 0x00;
|
|||
|
tcp_upload_frame.data.Data1Buf[0] = 1;
|
|||
|
tcp_upload_frame.data.Data1Buf[1] = 1;
|
|||
|
tcp_upload_frame.data.Data1Buf[2] = 1;
|
|||
|
tcp_upload_frame.data.Data1Buf[3] = 1;
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
tcp_upload_frame.data.Data2Buf[0] = Sys_data_object.P1.met_addr[0];
|
|||
|
tcp_upload_frame.data.Data2Buf[1] = Sys_data_object.P1.met_addr[1];
|
|||
|
tcp_upload_frame.data.Data2Buf[2] = Sys_data_object.P1.met_addr[2];
|
|||
|
tcp_upload_frame.data.Data2Buf[3] = Sys_data_object.P1.met_addr[3];
|
|||
|
//ʣ<><CAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
tcp_upload_frame.data.Data2Buf[4] = 0x00;//С<><D0A1>λ
|
|||
|
tcp_upload_frame.data.Data2Buf[5] = 0x01;
|
|||
|
tcp_upload_frame.data.Data2Buf[6] = 0x00;
|
|||
|
tcp_upload_frame.data.Data2Buf[7] = 0x00;
|
|||
|
//<2F>ۼ<EFBFBD><DBBC><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
tmp_float.gp22_u32 = Gp30CheckDataApp(2);
|
|||
|
tmp_datas_buf.datas = HexToBcd32((u32)(tmp_float.gp22_float));
|
|||
|
tcp_upload_frame.data.Data2Buf[8] = tmp_datas_buf.data_buf[0];//С<><D0A1>λ
|
|||
|
tcp_upload_frame.data.Data2Buf[9] = tmp_datas_buf.data_buf[1];
|
|||
|
tcp_upload_frame.data.Data2Buf[10] = tmp_datas_buf.data_buf[2];
|
|||
|
tcp_upload_frame.data.Data2Buf[11] = tmp_datas_buf.data_buf[3];//С<><D0A1>λ
|
|||
|
//˲ʱ<CBB2><CAB1><EFBFBD><EFBFBD>
|
|||
|
tmp_datas_buf.datas = Gp30CheckDataApp(GP30_APP_INS_FLOW); //˲ʱ<CBB2><CAB1><EFBFBD><EFBFBD>(<28><>λС<CEBB><D0A1><EFBFBD><EFBFBD><EFBFBD>Ŵ<EFBFBD>100000<30><30>)//BCD
|
|||
|
tmp_datas_buf.datas = Gp30DataToBcd(tmp_datas_buf.datas, 10);
|
|||
|
tcp_upload_frame.data.Data2Buf[12] = tmp_datas_buf.data_buf[0];
|
|||
|
tcp_upload_frame.data.Data2Buf[13] = tmp_datas_buf.data_buf[1];
|
|||
|
tcp_upload_frame.data.Data2Buf[14] = tmp_datas_buf.data_buf[2];//С<><D0A1>λ
|
|||
|
tcp_upload_frame.data.Data2Buf[15] = tmp_datas_buf.data_buf[3];
|
|||
|
//<2F>¶<EFBFBD>
|
|||
|
float tmep = TempCheckValueApp(); //
|
|||
|
if(tmep <0)
|
|||
|
{
|
|||
|
tmp_datas_buf.datas = (u32)(tmep*(-100));
|
|||
|
tmp_datas_buf.datas &= 0x0FFFF;
|
|||
|
tmp_datas_buf.datas |= 0x80000;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
tmp_datas_buf.datas = (u32)(tmep*(100));
|
|||
|
tmp_datas_buf.datas &= 0x7FFFF;
|
|||
|
}
|
|||
|
tcp_upload_frame.data.Data2Buf[16] = tmp_datas_buf.datas_map.data0;
|
|||
|
tcp_upload_frame.data.Data2Buf[17] = tmp_datas_buf.datas_map.data1;
|
|||
|
tcp_upload_frame.data.Data2Buf[18] = tmp_datas_buf.datas_map.data2;//С<><D0A1>λ
|
|||
|
//<2F>ۼƹ<DBBC><C6B9><EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
tmp_datas_buf.datas = RtccGetWorkHourApp();
|
|||
|
tmp_datas_buf.datas = HexToBcd32(tmp_datas_buf.datas);
|
|||
|
tcp_upload_frame.data.Data2Buf[19] = tmp_datas_buf.datas_map.data0;
|
|||
|
tcp_upload_frame.data.Data2Buf[20] = tmp_datas_buf.datas_map.data1;
|
|||
|
tcp_upload_frame.data.Data2Buf[21] = tmp_datas_buf.datas_map.data2;
|
|||
|
//״̬<D7B4><CCAC>ת<EFBFBD><D7AA>
|
|||
|
temp_state = FrameGetByte();
|
|||
|
tcp_stat.statTCP1 = 0;
|
|||
|
tcp_stat.statTCP2 = 0;
|
|||
|
tcp_stat.statTcp1bits.reverse = temp_state.stat1bits.reverse;
|
|||
|
tcp_stat.statTcp1bits.low_flow_rate = temp_state.stat1bits.low_flow_rate;
|
|||
|
tcp_stat.statTcp1bits.valve_state = temp_state.stat1bits.valve_state;
|
|||
|
if(temp_state.stat0bits.transducer_aging)
|
|||
|
{
|
|||
|
tcp_stat.statTcp2bits.amplitude = 0;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
tcp_stat.statTcp2bits.amplitude = 3;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
}
|
|||
|
tcp_stat.statTcp2bits.low_power = temp_state.stat1bits.low_battery_voltage;
|
|||
|
|
|||
|
tcp_upload_frame.data.Data2Buf[22] = tcp_stat.statTCP1;
|
|||
|
tcp_upload_frame.data.Data2Buf[23] = tcp_stat.statTCP2;
|
|||
|
#if defined(VALVE)
|
|||
|
temp_data = ValveGetStateApp();
|
|||
|
if(temp_data == 0x01)//<2F><><EFBFBD>Ź<EFBFBD>
|
|||
|
{
|
|||
|
tcp_upload_frame.data.Data2Buf[22] |= 0x40;
|
|||
|
}
|
|||
|
else//<2F><><EFBFBD><EFBFBD><EFBFBD>쳣
|
|||
|
{
|
|||
|
tcp_upload_frame.data.Data2Buf[22] |= 0xC0;
|
|||
|
}
|
|||
|
#endif
|
|||
|
//<2F>ź<EFBFBD>ǿ<EFBFBD><C7BF>
|
|||
|
NbiotGetCSQ(&temp_data);
|
|||
|
tcp_upload_frame.data.Data3Buf[0] = 0;
|
|||
|
tcp_upload_frame.data.Data3Buf[1] = temp_data;
|
|||
|
|
|||
|
//ά<><CEAC>//37.30907
|
|||
|
tcp_upload_frame.data.Data3Buf[2] = 0x03;
|
|||
|
tcp_upload_frame.data.Data3Buf[3] = 0x7F;
|
|||
|
tcp_upload_frame.data.Data3Buf[4] = 0x30;
|
|||
|
tcp_upload_frame.data.Data3Buf[5] = 0x90;
|
|||
|
tcp_upload_frame.data.Data3Buf[6] = 0x70;
|
|||
|
//<2F><><EFBFBD><EFBFBD>//117.1571
|
|||
|
tcp_upload_frame.data.Data3Buf[7] = 0x11;
|
|||
|
tcp_upload_frame.data.Data3Buf[8] = 0x7F;
|
|||
|
tcp_upload_frame.data.Data3Buf[9] = 0x15;
|
|||
|
tcp_upload_frame.data.Data3Buf[10] = 0x71;
|
|||
|
tcp_upload_frame.data.Data3Buf[11]= 0x00;
|
|||
|
//̫<><CCAB><EFBFBD>ܵ<EFBFBD>ѹ
|
|||
|
tcp_upload_frame.data.Data3Buf[12]= 0x00;
|
|||
|
tcp_upload_frame.data.Data3Buf[13]= 0x00;//С<><D0A1>λ
|
|||
|
//<2F><><EFBFBD>ص<EFBFBD>ѹ
|
|||
|
//<2F><>ȡ<EFBFBD><C8A1>ѹֵ
|
|||
|
temp_bat_val.datas =HexToBcd16(PowerCheckValueSys());
|
|||
|
tcp_upload_frame.data.Data3Buf[14]= temp_bat_val.datas&0xFF;//С<><D0A1>λ
|
|||
|
tcp_upload_frame.data.Data3Buf[15]= (temp_bat_val.datas>>8)&0xFF;
|
|||
|
//ѹ<><D1B9>
|
|||
|
tcp_upload_frame.data.Data3Buf[16]= 0x00;
|
|||
|
tcp_upload_frame.data.Data3Buf[17]= 0x00;
|
|||
|
//<2F>汾<EFBFBD><E6B1BE>
|
|||
|
tcp_upload_frame.data.Data3Buf[18]= (FrameCheckParaApp(FramePara_ProgVersion)>>16)&0xFF;
|
|||
|
tcp_upload_frame.data.Data3Buf[19]= (FrameCheckParaApp(FramePara_ProgVersion)>>24)&0xFF;
|
|||
|
//<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
RtccGetDateTime(&tempRtccTime);//<2F>ϱ<EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
tcp_upload_frame.data.Data3Buf[20] = tempRtccTime.s.second;
|
|||
|
tcp_upload_frame.data.Data3Buf[21] = tempRtccTime.s.minute;
|
|||
|
tcp_upload_frame.data.Data3Buf[22] = tempRtccTime.s.hour;
|
|||
|
tcp_upload_frame.data.Data3Buf[23] = tempRtccTime.s.day;
|
|||
|
tcp_upload_frame.data.Data3Buf[24] = tempRtccTime.s.month;
|
|||
|
tcp_upload_frame.data.Data3Buf[25] = tempRtccTime.s.year;
|
|||
|
tcp_upload_frame.data.Data3Buf[26] = 0x20;
|
|||
|
//״̬
|
|||
|
tcp_upload_frame.data.Data3Buf[27] = 0x00;
|
|||
|
//У<><D0A3><EFBFBD><EFBFBD>
|
|||
|
tcp_upload_frame.data.Cs = 0;
|
|||
|
for(i=2;i<72;i++)
|
|||
|
{
|
|||
|
tcp_upload_frame.data.Cs += tcp_upload_frame.buf[i];
|
|||
|
}
|
|||
|
tcp_upload_frame.data.End = 0x16;
|
|||
|
|
|||
|
for(i=0;i<74;i++)
|
|||
|
{
|
|||
|
*p_send_buf++ = tcp_upload_frame.buf[i];
|
|||
|
}
|
|||
|
*p_send_len = 74;
|
|||
|
}
|
|||
|
|
|||
|
void GetUploadDataResetState_SH(void)
|
|||
|
{
|
|||
|
upload_frame_stat_sh =UP_DEAL_S0;
|
|||
|
upload_task_complete_sh = PTL_PACK_BUSY;
|
|||
|
}
|
|||
|
u8 GetUploadDataCheckIdle_SH(void)
|
|||
|
{
|
|||
|
if(UP_DEAL_S0 == upload_frame_stat_sh)
|
|||
|
{
|
|||
|
return TASK_IDLE;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
return TASK_BUSY;
|
|||
|
}
|
|||
|
}
|
|||
|
u8 GetUploadDataCheckTask_SH(void)
|
|||
|
{
|
|||
|
return upload_task_complete_sh;
|
|||
|
}
|
|||
|
|
|||
|
void GetUploadDataMachine_SH(u8 data_step, u8* p_send_buf, u16* p_send_len)
|
|||
|
{
|
|||
|
switch(upload_frame_stat_sh)
|
|||
|
{
|
|||
|
case UP_DEAL_S0:
|
|||
|
{
|
|||
|
if(data_step == UPLOAD_FRAME_REQUEST_NEW)
|
|||
|
{
|
|||
|
temp_upload_step = 0;
|
|||
|
upload_frame_retry_times = 0;
|
|||
|
upload_frame_stat_sh = UP_DEAL_S1;//<2F><><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>
|
|||
|
}
|
|||
|
else if(data_step == UPLOAD_FRAME_UPLOAD_OK)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳɹ<DDB3>,<2C><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
{
|
|||
|
SystemClearUploadAgain();//<2F>ش<EFBFBD><D8B4><EFBFBD>0
|
|||
|
upload_frame_stat_sh = UP_DEAL_S3;//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
}
|
|||
|
else if(data_step == UPLOAD_FRAME_UPLOAD_RETRY)//<2F>ط<EFBFBD><D8B7><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>
|
|||
|
{
|
|||
|
if(temp_upload_step == UP_DEAL_S1)//ע<><D7A2><EFBFBD><EFBFBD>
|
|||
|
{
|
|||
|
upload_frame_stat_sh = UP_DEAL_S20;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD>
|
|||
|
}
|
|||
|
else if(temp_upload_step == UP_DEAL_S20)//<2F><><EFBFBD>ݰ<EFBFBD>
|
|||
|
{
|
|||
|
upload_frame_stat_sh = UP_DEAL_S21;//<2F><><EFBFBD><EFBFBD>
|
|||
|
}
|
|||
|
else if(temp_upload_step == UP_DEAL_S3)//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
{
|
|||
|
upload_frame_stat_sh = UP_DEAL_S4;//<2F>ٴ<EFBFBD><D9B4><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
}
|
|||
|
else//<2F>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
{
|
|||
|
upload_task_complete_sh = PTL_PACK_FAIL;
|
|||
|
upload_frame_stat_sh = UP_DEAL_S0;
|
|||
|
}
|
|||
|
}
|
|||
|
else if(data_step == UPLOAD_FRAME_ONLINE_FAIL) //<2F><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>
|
|||
|
{
|
|||
|
if(UPLOAD_TYPE_FIX_TIME == GetEventUploadType()||
|
|||
|
(UPLOAD_TYPE_RETRY_AGAIN == GetEventUploadType()))//<2F><>ʱ<EFBFBD>ϴ<EFBFBD>
|
|||
|
{
|
|||
|
SystemAddUploadAgain();//<2F>ش<EFBFBD><D8B4><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
}
|
|||
|
upload_task_complete_sh = PTL_PACK_FAIL;
|
|||
|
upload_frame_stat_sh = UP_DEAL_S0;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
upload_task_complete_sh = PTL_PACK_FAIL;
|
|||
|
upload_frame_stat_sh = UP_DEAL_S0;
|
|||
|
}
|
|||
|
}
|
|||
|
break;
|
|||
|
case UP_DEAL_S1://<2F><>ע<EFBFBD><D7A2>֡
|
|||
|
{
|
|||
|
if(EepIfIdle())
|
|||
|
{
|
|||
|
temp_upload_step = UP_DEAL_S1;
|
|||
|
Register_TcpFrameData(p_send_buf, p_send_len);
|
|||
|
upload_task_complete_sh = PTL_PACK_SUCCESS;//<2F>ɹ<EFBFBD>
|
|||
|
upload_frame_stat_sh = UP_DEAL_S0;
|
|||
|
}
|
|||
|
}
|
|||
|
break;
|
|||
|
case UP_DEAL_S20://<2F><><EFBFBD>ϱ<EFBFBD>֡
|
|||
|
{
|
|||
|
temp_upload_step = UP_DEAL_S20;
|
|||
|
Upload_TcpFrameData(p_send_buf, p_send_len);
|
|||
|
upload_task_complete_sh = PTL_PACK_SUCCESS;//<2F>ɹ<EFBFBD>
|
|||
|
upload_frame_stat_sh = UP_DEAL_S0;
|
|||
|
}
|
|||
|
break;
|
|||
|
case UP_DEAL_S21://<2F><><EFBFBD><EFBFBD>
|
|||
|
{
|
|||
|
if(upload_frame_retry_times < 3)
|
|||
|
{
|
|||
|
upload_frame_retry_times++;
|
|||
|
upload_frame_stat_sh = UP_DEAL_S20;
|
|||
|
}
|
|||
|
else//<2F><><EFBFBD>·<EFBFBD><C2B7><EFBFBD>ʧ<EFBFBD><CAA7>3<EFBFBD>εĴ<CEB5><C4B4><EFBFBD>
|
|||
|
{
|
|||
|
if((UPLOAD_TYPE_FIX_TIME == GetEventUploadType())|| //<2F>ش<EFBFBD>
|
|||
|
(UPLOAD_TYPE_RETRY_AGAIN == GetEventUploadType()))//<2F><>ʱ<EFBFBD>ϴ<EFBFBD>
|
|||
|
{
|
|||
|
SystemAddUploadAgain();//<2F>ش<EFBFBD><D8B4><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
}
|
|||
|
upload_task_complete_sh = PTL_PACK_FAIL;
|
|||
|
upload_frame_stat_sh = UP_DEAL_S0;
|
|||
|
}
|
|||
|
}
|
|||
|
break;
|
|||
|
|
|||
|
case UP_DEAL_S3://<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
|
|||
|
{
|
|||
|
temp_upload_step = UP_DEAL_S3;
|
|||
|
Ping_TcpFrameData(p_send_buf, p_send_len);
|
|||
|
upload_task_complete_sh = PTL_PACK_SUCCESS;//<2F>ɹ<EFBFBD>
|
|||
|
upload_frame_stat_sh = UP_DEAL_S0;
|
|||
|
}
|
|||
|
break;
|
|||
|
case UP_DEAL_S4://<2F><><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD>ٷ<EFBFBD><D9B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
{
|
|||
|
temp_upload_step = UP_DEAL_S4;
|
|||
|
Ping_TcpFrameData(p_send_buf, p_send_len);
|
|||
|
Set100msTimer(TIMER_100MS_UPLOAD_MONITOR, 600);//<2F><>ʱ60<36><30>
|
|||
|
upload_frame_stat_sh = UP_DEAL_S5;
|
|||
|
}
|
|||
|
break;
|
|||
|
case UP_DEAL_S5://<2F>ȴ<EFBFBD><C8B4><EFBFBD>ʱʱ<CAB1>䵽
|
|||
|
{
|
|||
|
if(0 == Check100msTimer(TIMER_100MS_UPLOAD_MONITOR))
|
|||
|
{
|
|||
|
upload_task_complete_sh = PTL_PACK_SUCCESS;//<2F>ɹ<EFBFBD>
|
|||
|
upload_frame_stat_sh = UP_DEAL_S0;
|
|||
|
}
|
|||
|
if(FrameCheckMsgApp(MsgNbUpload_OffLine)) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|||
|
{
|
|||
|
FrameClearMsgApp(MsgNbUpload_OffLine);
|
|||
|
upload_task_complete_sh = PTL_PACK_FAIL;//<2F><><EFBFBD><EFBFBD>
|
|||
|
upload_frame_stat_sh = UP_DEAL_S0;
|
|||
|
}
|
|||
|
}
|
|||
|
break;
|
|||
|
|
|||
|
default:
|
|||
|
{
|
|||
|
upload_task_complete_sh = PTL_PACK_FAIL;
|
|||
|
upload_frame_stat_sh = UP_DEAL_S0;
|
|||
|
}
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
/*******************************************************************************
|
|||
|
* @fun_name:NB_SS_Control_GetPara
|
|||
|
* @brief :
|
|||
|
* @param[in] :<EFBFBD><EFBFBD>ȡ<EFBFBD>ϱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @param[out]: None
|
|||
|
* @retval : None
|
|||
|
* @other :
|
|||
|
******************************************************************************/
|
|||
|
u8 NB_SS_Control_GetPara(NB_SS_ControlParaTypeDef paraType)
|
|||
|
{
|
|||
|
switch(paraType)
|
|||
|
{
|
|||
|
case NB_HistroyReadIndex://<2F><>ʷ<EFBFBD><CAB7><EFBFBD>ݵĶ<DDB5>ָ<EFBFBD><D6B8>
|
|||
|
{
|
|||
|
return Sys_data_object.P1.histroy_w;
|
|||
|
}
|
|||
|
case NB_UploadFailTimes://ʧ<>ܴ<EFBFBD><DCB4><EFBFBD>
|
|||
|
{
|
|||
|
u8 temp_fail_times=0;
|
|||
|
for(int i = 0; i < 32; i++)
|
|||
|
{
|
|||
|
if(((Sys_data_object.P1.Supplemental_send_flag.datas >> i) & 0x00000001) == 0x00000001)
|
|||
|
{
|
|||
|
temp_fail_times += 1;
|
|||
|
}
|
|||
|
}
|
|||
|
return temp_fail_times;
|
|||
|
}
|
|||
|
default:
|
|||
|
break;
|
|||
|
}
|
|||
|
return 0;
|
|||
|
}
|
|||
|
/*******************************************************************************
|
|||
|
* @fun_name:NB_SS_Control_SetPara
|
|||
|
* @brief :
|
|||
|
* @param[in] :<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @param[out]: None
|
|||
|
* @retval : None
|
|||
|
* @other :
|
|||
|
******************************************************************************/
|
|||
|
void NB_SS_Control_SetPara(NB_SS_ControlParaTypeDef paraType, u8 data)
|
|||
|
{
|
|||
|
switch(paraType)
|
|||
|
{
|
|||
|
case NB_HistroyReadIndex://<2F><>ʷ<EFBFBD><CAB7><EFBFBD>ݵĶ<DDB5>ָ<EFBFBD><D6B8>
|
|||
|
{
|
|||
|
Sys_data_object.P1.histroy_w = data;
|
|||
|
break;
|
|||
|
}
|
|||
|
default:
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
//<2F><>Լ<EFBFBD><D4BC><EFBFBD>ݴ洢<DDB4><E6B4A2><EFBFBD>ֳ<EFBFBD>ʼ<EFBFBD><CABC>
|
|||
|
void DataStoreInit(void)
|
|||
|
{
|
|||
|
Quanzhou_Store_InitApp();
|
|||
|
}
|
|||
|
//<2F><>Լ<EFBFBD><D4BC><EFBFBD>ݴ洢״̬<D7B4><CCAC>
|
|||
|
void DataStoreMachine(void)
|
|||
|
{
|
|||
|
Quanzhou_Store_Machine();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ洢
|
|||
|
}
|
|||
|
//<2F><>Լ<EFBFBD><D4BC><EFBFBD>ݴ洢<DDB4><E6B4A2><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
u8 DataStoreIfIdle(void)
|
|||
|
{
|
|||
|
if(QuanzhouStore_IfSleep()==TRUE)
|
|||
|
{
|
|||
|
return TRUE;
|
|||
|
}
|
|||
|
return FALSE;
|
|||
|
}
|
|||
|
|
|||
|
#endif
|
|||
|
|
|||
|
|
|||
|
|