📄 smsrecv.c
字号:
Write_Byte_Stream(cardtype);
Write_Code_Stream(save.simcard[cardtype].MyNumb,'F',_Strlen(save.simcard[cardtype].MyNumb,14),14);
break;
case 0x1751:
Write_Byte_Stream(cardtype);
Write_Byte_Stream(index);
if(cardtype ==0)
{
Write_Code_Stream(save.phonenumber.User0Limit[index],'F',_Strlen(save.phonenumber.User0Limit[index],14),14);
}
else
{
Write_Code_Stream(save.phonenumber.User1Limit[index],'F',_Strlen(save.phonenumber.User1Limit[index],14),14);
}
break;
case 0x2151:
Write_Ptr_Stream((uchar *)&save.basevalue.max_speed,2);
break;
case 0x2251:
temp1 = (save.basevalue.low_voltage-9)*2+192;
Write_Word_Stream(temp1);
break;
case 0x2351:
Write_Byte_Stream(save.basevalue.interval);
break;
case 0x3251:
Write_Byte_Stream(alarmtype);
switch(Cntermsg->data[0])
{
case 0x04:
Write_Byte_Stream(save.alarmtime.voltage);
break;
case 0x05:
Write_Byte_Stream(save.alarmtime.accerr);
break;
case 0x06:
Write_Byte_Stream(save.alarmtime.powererr);
break;
case 0x07:
Write_Byte_Stream(save.alarmtime.overarea);
break;
case 0x09:
Write_Byte_Stream(save.alarmtime.overspeed);
break;
case 0x0a:
Write_Byte_Stream(save.alarmtime.sos);
break;
case 0x0b:
Write_Byte_Stream(save.alarmtime.burgle);
break;
case 0x0c:
Write_Byte_Stream(save.alarmtime.rop);
break;
case 0x0d:
Write_Byte_Stream(save.alarmtime.gpserr);
break;
case 0x0e:
Write_Byte_Stream(save.alarmtime.gpserr);
break;
case 0x0f:
Write_Byte_Stream(save.alarmtime.remoteerr);
break;
case 0x10:
Write_Byte_Stream(save.alarmtime.remotealarm);
break;
}
break;
case 0x4151:
Write_Byte_Stream(cardtype);
Write_Code_Stream(save.simcard[cardtype].IpAddr,'F',_Strlen(save.simcard[cardtype].IpAddr,15),15);
Write_Code_Stream(save.simcard[cardtype].SocketPort,'F',_Strlen(save.simcard[cardtype].SocketPort,5),5);
break;
case 0x4251:
Write_Byte_Stream(cardtype);
Write_Code_Stream(save.simcard[cardtype].Apn,'F',_Strlen(save.simcard[cardtype].Apn,20),20);
break;
case 0x4351:
Write_Byte_Stream(save.basevalue.gprs_time/1000);
break;
case 0x4451: //modified by leon 051013
Write_Byte_Stream(index);
Write_Ptr_Stream((uchar *)&save.simsel.judge_port[index].mainland_port.top_left.lati,48);
break;
case 0x4551:
Write_Word_Stream(save.basevalue.fixtime);
break;
case 0x4651:
Write_Byte_Stream(save.basevalue.mode.bit.consume);
break;
case 0x4751:
Write_Code_Stream(soft.sn,0,_Strlen(soft.sn,16),16);
Write_Code_Stream(TYPEINFO,0,_stringlen(TYPEINFO),15);
break;
case 0x4851:
Write_Ptr_Stream(save.psw.handpsw,8);
break;
}
if(gsmstatus.gprsdata == TRUE) //added by leon 050913
Assemble_Gprs_Tail();
else
Assemble_Sms_Tail(_SMS_COMMON);
}
void Handle_1051msg(void)
{
Center_Read(0x1051,0,0,0);
}
void Handle_1151msg(void)
{
Center_Read(0x1151,0,0,0);
}
void Handle_1251msg(void)
{
Center_Read(0x1251,0,0,0);
}
void Handle_1351msg(void)
{
Center_Read(0x1351,0,0,0);
}
void Handle_5151msg(void) //added by leon 050923 for read Manage Number of Card 1
{
uchar temp =0;
if(Cntermsg->data[0])
{
temp =1;
}
Center_Read(0x5151,temp,0,0);
}
void Handle_5251msg(void) //added by leon 050923 for read Message Number of Card 1
{
uchar temp =0;
if(Cntermsg->data[0])
{
temp =1;
}
Center_Read(0x5251,temp,0,0);
}
void Handle_5351msg(void) //added by leon 050923 for read Listen Number of Card 1
{
uchar temp =0;
if(Cntermsg->data[0])
{
temp =1;
}
Center_Read(0x5351,temp,0,0);
}
void Handle_1551msg(void)
{
uchar temp =0;
if(Cntermsg->data[0]){
temp = 1;
}
Center_Read(0x1551,temp,0,0);
}
void Handle_1751msg(void)
{
uchar temp =0;
if(Cntermsg->data[0]){
temp = 1;
}
if(Cntermsg->data[1]>9)return;
Center_Read(0x1751,temp,0,Cntermsg->data[1]);
}
void Handle_2151msg(void)
{
Center_Read(0x2151,0,0,0);
}
void Handle_2251msg(void)
{
Center_Read(0x2251,0,0,0);
}
void Handle_2351msg(void)
{
Center_Read(0x2351,0,0,0);
}
void Handle_3251msg(void)
{
Center_Read(0x3251,0,Cntermsg->data[0],0);
}
void Handle_4151msg(void)
{
uchar temp =0;
if(Cntermsg->data[0]){
temp = 1;
}
Center_Read(0x4151,temp,0,0);
}
void Handle_4251msg(void)
{
uchar temp =0;
if(Cntermsg->data[0]){
temp = 1;
}
Center_Read(0x4251,temp,0,0);
}
void Handle_4351msg(void)
{
Center_Read(0x4351,0,0,0);
}
void Handle_4451msg(void) //modified by leon 051013
{
if(Cntermsg->data[0]>=MAX_PORT_AREA) return;
Center_Read(0x4451,0,0,Cntermsg->data[0]);
}
void Handle_4551msg(void)
{
Center_Read(0x4551,0,0,0);
}
void Handle_4651msg(void)
{
Center_Read(0x4651,0,0,0);
}
void Handle_4751msg(void)
{
Center_Read(0x4751,0,0,0);
}
void Handle_4851msg(void)
{
Center_Read(0x4851,0,0,0);
}
void Handle_0347msg(void)//报警解除//
{
if(Get_Char_Bit(Cntermsg->data,4))alarm_remove(_ROP_ALM);
if(Get_Char_Bit(Cntermsg->data,5))alarm_remove(_GUAD_ALM);
if(Get_Char_Bit(Cntermsg->data+1,0))alarm_remove(_GPSEER_ALM);
if(Get_Char_Bit(Cntermsg->data+1,3))alarm_remove(_GPSEER_ALM);
if(Get_Char_Bit(Cntermsg->data+1,4))alarm_remove(_OVERAREA_ALM);
if(Get_Char_Bit(Cntermsg->data+1,5))alarm_remove(_OVERLINE_ALM);
//if(Get_Char_Bit(Cntermsg->data+1,6))alarm_remove(_OVERSPEED_ALM); //remarked by leon
if(Get_Char_Bit(Cntermsg->data+1,7))alarm_remove(_GPSEER_ALM);
if(Get_Char_Bit(Cntermsg->data+2,0))alarm_remove(_POWER_ALM);
if(Get_Char_Bit(Cntermsg->data+2,1))alarm_remove(_ACC_ALM);
if(Get_Char_Bit(Cntermsg->data+2,2))alarm_remove(_VOLTAGE_ALM);
if(Get_Char_Bit(Cntermsg->data+2,3))alarm_remove(_GPSEER_ALM);
if(Get_Char_Bit(Cntermsg->data+2,5))alarm_remove(_REMOTEERR_ALM);
if(Get_Char_Bit(Cntermsg->data+2,6))alarm_remove(_REMOTE_ALM);
if(Get_Char_Bit(Cntermsg->data+2,7))alarm_remove(_BAK_ALM);
if(Get_Char_Bit(Cntermsg->data+3,1))alarm_remove(_ENGINE_ALM);
if(Get_Char_Bit(Cntermsg->data+3,2))alarm_remove(_BROKE_ALM);
if(Get_Char_Bit(Cntermsg->data+3,4))alarm_remove(_DRAG_ALM);
Assemble_Sms_Head(0x0348);
if(gsmstatus.gprsdata == TRUE) //added by leon 050913
Assemble_Gprs_Tail();
else
Assemble_Sms_Tail(_SMS_COMMON);
}
void Handle_5145msg(void)//add by lxo 122614
{
uchar temp;
temp = Cntermsg->data[0];
#ifdef DEBUG_AT
Uart1Send("Handle 5145 the flag is :");
Uart1Word(temp);
#endif
if(temp==0)
{
Stop_Timer(Custom_supervise_timer);
}
else
{
Custom_supervise_proc();
}
}
void Handle_0341msg(void)//add by lxo 122624
{
FixedDistance= (dword)(*((uint *)Cntermsg->data))*10*100;
FixedDistance_times= (*(uint *)(Cntermsg->data+2));
#ifdef DEBUG_AT
Uart1Send("Handle 0341 the Distance(cm) and Times is :");
Uart1Word(FixedDistance);
Uart1Word(FixedDistance_times);
#endif
FixedDistanceTemp=0x00;
if(FixedDistance_times==0)
ParaSet.FixedDistanceReport=0;
else
ParaSet.FixedDistanceReport=1;
}
void Sms_Recv(void)
{
uchar len;
uchar *ptr;
uchar flag;
uchar temp1;
uchar temp2;
uchar simid; //added by leon 050923
gsc.Gprs_Simcard_bits.isrecvingsms = 1;
simid = save.basevalue.mode.bit.simid; //added by leon 050923
flag = 0;
len = Current_Tskmsg->msgptr[0];
ptr = &Current_Tskmsg->msgptr[1];
Msg_Sms.TPUD_len = 0;
gsmDecodePdu(ptr,&Msg_Sms);
Cntermsg = (_STRUCT_CETER *)Msg_Sms.TP_UD;
if(Msg_Sms.TPUD_len==0)return;
if(Msg_Sms.TPUD_len>=15)
{
if(crc_check(Msg_Sms.TP_UD,Msg_Sms.TPUD_len-2)&&(Cntermsg->flag[0]=='@')&&(Cntermsg->flag[1]=='@'))
{
#ifdef DEBUG_SMS
Uart1Send("CRC Check Success!");
Uart1Send(save.phonenumber.ManageCentreNumb[simid]);
Uart1Send(Msg_Sms.TPA);
#endif
temp1=0; temp2=0;
if(save.phonenumber.ManageCentreNumb[simid][0]=='8'&&save.phonenumber.ManageCentreNumb[simid][1]=='6')
{
temp1=2;
}
if(Msg_Sms.TPA[0]=='8'&&Msg_Sms.TPA[1]=='6')
{
temp2=2;
}
if(Str_Cmp(save.phonenumber.ManageCentreNumb[simid]+temp1,Msg_Sms.TPA+temp2,(_Strlen(save.phonenumber.ManageCentreNumb[simid],15)-temp1)))
{
flag = 1;
}
else if(Cntermsg->type==0x1143||Cntermsg->type==0x1243)
{
flag = 1;
}
}
}
#ifdef DEBUG_SMS
Uart1Word(temp1);
Uart1Word(temp2);
Uart1Word(flag);
#endif
if(save.basevalue.need_service==1)
{
#ifdef DEBUG_SMS
Uart1Send("need_service!");
#endif
if(flag ==1)
{
if(Cntermsg->type!=0x0445)flag = 0;
}
}
if(flag ==0 ) //普通短信
{
#ifdef DEBUG_SMS
Uart1Send("recv common sms");
hand_send(Msg_Sms.TPA,Msg_Sms.TPALEN);
hand_send(Msg_Sms.TP_UD,Msg_Sms.TPUD_len);
#endif
Send_H08Msg(Msg_Sms.TP_UD,Msg_Sms.TPUD_len,Msg_Sms.TPA,Msg_Sms.TPALEN);
}
else if(flag ==1)
{
#ifdef DEBUG_SMS
Uart1Send("recv a SYS sms");
Uart1Word(Cntermsg->type);
Uart1Send("form tel");
hand_send(Msg_Sms.TPA,Msg_Sms.TPALEN);
Uart1Send("form SMS");
hand_send(Msg_Sms.TP_UD,Msg_Sms.TPUD_len);
#endif
Find_Part_Proc(SMSENTRYPROC,Cntermsg->type,sizeof(SMSENTRYPROC)/sizeof(PART_ENTRY_PROC));
}
gsc.Gprs_Simcard_bits.isrecvingsms = 0;
}
void Gprs_Recv(void)
{
Cntermsg = (_STRUCT_CETER *)Current_Tskmsg->msgptr;
if(crc_check((uchar *)&Cntermsg->flag[0],Cntermsg->len-2)&&(Cntermsg->flag[0]=='@')&&(Cntermsg->flag[1]=='@'))
{
if(save.basevalue.need_service==1) //遥毙
{
if(Cntermsg->type!=0x0445)
return;
}
Find_Part_Proc(SMSENTRYPROC,Cntermsg->type,sizeof(SMSENTRYPROC)/sizeof(PART_ENTRY_PROC));
}
else
{
#ifdef DEBUG_AT
Uart1Send("BAD DATA");
#endif
clr_watchdog();
//Send_Gpsdata(0x0140,_SMS_SUCCESS,0);
if(Str_Find(Current_Tskmsg->msgptr,Cntermsg->len,"WaitingForData")) //added by leon 050928
Send_Gpsdata(0x0140,_SMS_SUCCESS,0);
else if(Str_Find(Current_Tskmsg->msgptr,Cntermsg->len,"#CME ERROR: 37122")) //added by leon 050928
Send_Gpsdata(0x0140,_SMS_SUCCESS,0);
else if(Str_Find(Current_Tskmsg->msgptr,Cntermsg->len,"ERROR")) //added by leon 050928
{
SwitchToAtCmd();
gsmstatus.gprsdata = FALSE;
gsmstatus.mode |= INIT_OK;
Start_Timer(Gprs_Service_Timer,20,SECOND);
}
}
}
//Added by lxo 06081118 for none-signal-region-supplement condition compile
#if SUPPLEMENT == SUPPLEMENTENABLE
void BufferInitial(void)//added by lxo 1227021
{
InformationBuffer.IndexIn=0;
InformationBuffer.IndexOut=0;
InformationBuffer.Sum=0;
}
void InformationPushIn(uchar *data,uchar len)//added by lxo 1227022
{
#ifdef DEBUG_AT
Uart1Send("In InformationPushIn1 ");
Uart1Word(InformationBuffer.Sum);
Uart1Word(InformationBuffer.IndexIn);
Uart1Word(InformationBuffer.IndexOut);
#endif
if(InformationBuffer.Sum==InformationMax)
{
if(++InformationBuffer.IndexOut==InformationMax)
InformationBuffer.IndexOut=0;
InformationBuffer.Sum--;
}
InformationBuffer.Buffer[InformationBuffer.IndexIn].Len=len;
_Memcpy(InformationBuffer.Buffer[InformationBuffer.IndexIn].Information, data, len);
InformationBuffer.Sum++;
if(++InformationBuffer.IndexIn==InformationMax)
InformationBuffer.IndexIn=0;
#ifdef DEBUG_AT
Uart1Send("In InformationPushIn and Sum is");
Uart1Word(InformationBuffer.Sum);
Uart1Word(InformationBuffer.IndexIn);
Uart1Word(InformationBuffer.IndexOut);
Uart1SendHex(data,len);
#endif
}
void Resend_proc(void)//added by lxo 1227052
{
if(InformationBuffer.Sum!=0&&gsmstatus.gprsdata==TRUE)
{
#ifdef DEBUG_AT
Uart1Send("In Resend_proc1");
Uart1Word(InformationBuffer.Sum);
Uart1Word(InformationBuffer.IndexIn);
Uart1Word(InformationBuffer.IndexOut);
Uart1SendHex(InformationBuffer.Buffer[InformationBuffer.IndexOut].Information,InformationBuffer.Buffer[InformationBuffer.IndexOut].Len);
#endif
Send_Gprsdata(InformationBuffer.Buffer[InformationBuffer.IndexOut].Information,InformationBuffer.Buffer[InformationBuffer.IndexOut].Len);
if(++InformationBuffer.IndexOut==InformationMax)
InformationBuffer.IndexOut=0;
InformationBuffer.Sum--;
if(InformationBuffer.Sum!=0)
Start_Timer(Resend_timer,1,HMSEL);
#ifdef DEBUG_AT
Uart1Send("In Resend_proc2");
Uart1Word(InformationBuffer.Sum);
Uart1Word(InformationBuffer.IndexIn);
Uart1Word(InformationBuffer.IndexOut);
#endif
}
}
void InformationSave(uint type, uchar attrib,uchar need_sos)//added by lxo 122711
{
Assemble_Sms_Head(type);
Write_Gps_Data(type,need_sos);
// Assemble_Gprs_Tail();
Write_Absword_Stream(2,Get_Stream_Len()+4);
write_crc_stream();
Write_Byte_Stream(0x0d);
Write_Byte_Stream(0x0a);
// Send_Gprsdata(Get_Stream_Headptr(),Get_Stream_Len());
InformationPushIn(Get_Stream_Headptr(),Get_Stream_Len());
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -