电工基础

电工基础知识_电工技术-电工最常见电路

gsm模块如何与单片机通信?(3)

时间:2024-04-01 11:57来源:[db:来源] 作者:admin 点击:
//发送bps连机命令 void Send_BPS(void) { SendToTc35(AT_Tc35,3); //”AT+“ SendToTc35(Bps_Tc35,sizeof(Bps_Tc35)-1);//”IPR=19200“ SendASC(OVER); } //设置文本 void

  //发送bps连机命令

  void Send_BPS(void)

  {

  SendToTc35(AT_Tc35,3); //”AT+“

  SendToTc35(Bps_Tc35,sizeof(Bps_Tc35)-1);//”IPR=19200“

  SendASC(OVER);

  }

  //设置文本

  void SetText(void)

  {

  SendToTc35(AT_Tc35,3); //”AT+“

  SendToTc35(Text_tc35,sizeof(Text_tc35)-1);//”IPR=19200“

  SendASC(OVER);

  Delay(100):

  //删除短信息

  unsigned char EraseMsg(unsigned char index)

  {

  unsigned char *p,i=20;

  SendToTc35(AT_Tc35,3); //”AT+“

  SendToTc35(Erase_Tc35,sizeof(Erase_Tc35)-1);//”IPR=19200“

  SendASC(index);

  SendASC(OVER);

  ES=1;

  while(i--)

  {

  Delay(200);

  P=strstr(RsBuf,AT_Code);

  if(P!=NULL) {return 1;}

  }

  return 0;

  }

  //读取短信息

  char code Ask_No[]=”+CMGR:0,,0“;

  char code ERROR{]=”ERROR“;

  char code Ask_Tc35[]=”/“;

  unsigned char ReadMsg(unsigned char index)

  {

  unsigned char *p,i;

  unsigned char Buf[40];

  SendToTc35(AT_Tc35,3); //”AT+“

  SendToTc35(Read_Tc35,sizeof(Read_Tc35)-1);

  SendASC(index);

  SendASC(OVER);

  ES=1; //必须中断

  Delay(600);

  /*-------

  ES=0:

  SendToTc35(RsBuf,99);

  ES=1;

  */|

  p=strstr(RsBuf,ERROR);

  if(P!=NULL)

  {

  Send_AT();return 0;

  p=strstr(RsBuf,Ask_No);//无信息

  if(p!=NULL)return 0;

  p=strstr(RsBuf,Ask_Tc35);//20个字节后是MSG

  if(p==NULL) return 0;

  p=p+21;

  for(i=0;i《sizeof(Buf);i++)

  {

  Buf[i]=*p++;

  }

  if(EraseMsg(index)==0) return 0;

  p=strcpy(RsBuf,Buf); //放回RsBuf

  return 1;

  )

  //发送短信息

  char code SK[]=”》“;

  void SendMsgStart(void)

  {

  unsigned char *p,i=10;

  SendToTc35(AT_Tc35,3); //”AT+“

  SendToTc35(Send_Tc35,sizeof(Send_Tc35)-1);//”IPR=19200“

  SendASC(YinHao); (责任编辑:admin)

织梦二维码生成器
------分隔线----------------------------
栏目列表
推荐内容