⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gsmcs.lst

📁 GSM短信收发
💻 LST
📖 第 1 页 / 共 3 页
字号:
 444   2       //     SendData(0xf4);
 445   2          timer_S_cnt=0;
 446   2          //while(timer_S_cnt<2) watch_dog_clear;
 447   2          Send_AT_Command(SMSS_ID);
 448   2              //      timer_S_cnt=0; while(timer_S_cnt<2&&(AT_Command_Status==COMMAND_WAIT)) watch_dog_clear;
 449   2              timer_S_cnt=0;
 450   2              //while(timer_S_cnt<10) watch_dog_clear;
 451   2        }
 452   1              Send_AT_Command(SIM_ID);
 453   1              Send_AT_Command(AT_IPR);
 454   1              Send_AT_Command(REQUEST_MOD);
 455   1      //  if(strsearch("TC35\x0d\x0a")==0){
 456   1      //        Send_AT_Command(SMSS_ID); TC35_bit=0;
 457   1      //      }
 458   1      //  else TC35_bit=1;
 459   1          timer_S_cnt=0; 
 460   1      //      while(timer_S_cnt<8) watch_dog_clear;
 461   1      }
 462          
 463          
 464          //======================================================================
 465          //================进行SIM卡的电话本读======================================================
 466          //======================================================================
 467          uchar PHONE_RD( ){      //read_tmp=0x30+i;  要读的电话号码
 468   1        uchar j;
 469   1        Send_AT_Command(PHONE_READ);
 470   1        send_count=0;
 471   1        timer_S_cnt=0; 
 472   1      //  while(timer_S_cnt<1&&(AT_Command_Status==COMMAND_WAIT)) watch_dog_clear;
 473   1        if(j=strsearch("+CPBR:")){    //+CPBW: 1,"13818120592",129,"chia"
 474   2          j=j+9;
 475   2          do{
 476   3                para_temp[TMP_BUF++]= uart_buff[j++];
 477   3                if( uart_buff[j]=='"'){       //para_temp[t++]=';';para_temp[t++]=0x0d;para_temp[t++]=0x00;
 478   4                      return(TMP_BUF);
 479   4                }
 480   3          }while(j<=24);
 481   2        }
 482   1        else if(uart_buff[1]==0x0d&&uart_buff[0]==0x34){
 483   2        return(FALSE);
 484   2        }
 485   1        else return(FALSE);
 486   1      }
 487          
 488          void rdnumber(uchar u){ // 发短中文短信前设置。 P0.2灯闪,同时蜂鸣器长叫一声 
 489   1        read_tmp=0x30+u; 
C51 COMPILER V7.06   GSMCS                                                                 04/12/2009 16:41:11 PAGE 9   

 490   1        TMP_BUF=0;    //读电话本1
 491   1        PHONE_RD(); 
 492   1        para_temp[TMP_BUF++]=0x0d;
 493   1        para_temp[TMP_BUF++]=0x00;
 494   1        TMP_BUF=0;   // 将读出的电话号码转存起来,做发送对方号码
 495   1        do{
 496   2              TEL_temp[TMP_BUF]=para_temp[TMP_BUF];  TMP_BUF++;
 497   2        }while( TMP_BUF<=18);
 498   1        sms_tmp=smss_break;
 499   1        send_sms();
 500   1      }
 501          
 502          
 503          void start(void)
 504          {     
 505   1              if(chinit==1)   LED1=0;  //初始化成功
 506   1              else  LED2=0;
 507   1              if(chping==1)   LED3=0;  //SIM卡初始化成功
 508   1              else  LED4=0;
 509   1      } 
 510          
 511          /***********主程序***************/
 512          void main (void)
 513          {
 514   1              system_server=SYS_SMSR;   
 515   1              LED1=1;LED2=1;LED3=1;LED4=1;    
 516   1              Sys_Init();     
 517   1              Initialize_Model(); 
 518   1              start();
 519   1              while(1)
 520   1          {
 521   2              if(system_server==SYS_SMSR){                    //读1-20条短信
 522   3                    Send_AT_Command(SIM_ID);
 523   3                Send_AT_Command(SMSS_ID);
 524   3                    read_sms();                               //timer_S_cnt=0;   
 525   3              }
 526   2              if(system_server==SYS_ALARM){
 527   3                    sms_tmp=smss_para;
 528   3                system_server=SYS_SMSS;
 529   3              }
 530   2              else if(system_server==SYS_TEL){    
 531   3                        sms_tmp=smss_tel;
 532   3                        system_server=SYS_SMSS;
 533   3              }
 534   2                      else if(system_server==SYS_NUMSAVE){    
 535   3                        sms_tmp=smss_save;
 536   3                        system_server=SYS_SMSS;
 537   3              }       
 538   2                      if(system_server==SYS_SMSS){       //发送信息      
 539   3                        system_server=SYS_SMSR; 
 540   3                        send_sms();    
 541   3              } 
 542   2          }
 543   1      }
 544          
 545          void  Int_Timer0(void) interrupt 1 using 3{
 546   1        TH0 = 0xB8;
 547   1        TL0 = 0x00; //20ms的时钟基准
 548   1        //watch_dog_clear;************************************************
 549   1        timer_1S_cnt++;  
 550   1        timer_tmp++;
 551   1        if(timer_1S_cnt==50){    //20×50=1000MS  =1S
C51 COMPILER V7.06   GSMCS                                                                 04/12/2009 16:41:11 PAGE 10  

 552   2          timer_10S_cnt++;
 553   2          timer_1S_cnt=0;
 554   2          timer_S_cnt++;
 555   2      //      LED=~LED;
 556   2        }                              //1秒=1000毫秒
 557   1        if(timer_10S_cnt==10){   //10S
 558   2          timer_10S_cnt=0;
 559   2              timercount++;
 560   2        }
 561   1      }
 562          
 563          /*****************************************************************************
 564           *                   TC35 的命令列表,与中断服务程序                          *
 565           *****************************************************************************/
 566          void  Int_Uart(void) interrupt 4 using 3{  //串口的中断程序
 567   1        if(TI){//数据模式与命令方式共用               
 568   2        //  LED2=0;
 569   2          TI=0;
 570   2          if(send_count>=MAX_TM-5)  send_count=0;
 571   2          if((uart_buff[send_count]==0)){ //应该检测命令结束代码,检测到时结束通信
 572   3                at_send_bit=1;
 573   3            send_count=0xff;
 574   3            for(F=0;F<20;F++){
 575   4                      uart_buff[F]=0;         
 576   4                }
 577   3              //清除接收缓冲区
 578   3            receive_count=0;
 579   3            return;
 580   3          }
 581   2          else{   
 582   3                if(uart_buff[send_count]<=0xB0)  //0xff
 583   3                SBUF=uart_buff[send_count++];
 584   3            if((uart_buff[send_count]==0)){  //应该检测命令结束代码,检测到时结束通信
 585   4                  at_send_bit=1;
 586   4              send_count=0xff;
 587   4              for(F=0;F<20;F++){
 588   5                        uart_buff[F]=0;               
 589   5                  }           //清除接收缓冲区
 590   4              receive_count=0;    return;
 591   4            }
 592   3          }
 593   2          receive_count=0;
 594   2        }
 595   1        if(RI){ //命令方式
 596   2        //    LED1=0;
 597   2                RI=0;
 598   2            if(at_send_bit==0)      return;
 599   2            if((send_count==0xff)&&(receive_count<MAX_TM-5)){//没有发送时才能进行接收 所有的命令返回都是处于 0x0
             -A [Result] 0x0D 之间,其他命令,不会出现这种情况
 600   3              uart_buff[receive_count++]=SBUF;
 601   3                }
 602   2            else{//ACC=SBUF;
 603   3              return;
 604   3            }
 605   2            if(receive_count>=MAX_TM-5){  
 606   3              if(AT_Command_Type==SMS_CMGR)    
 607   3                        receive_count=0;
 608   3              else if(AT_Command_Type==SMONC_ID){     
 609   4                        AT_Command_Status=COMMAND_OK;
 610   4                return;  
 611   4                      }
 612   3              else{   
C51 COMPILER V7.06   GSMCS                                                                 04/12/2009 16:41:11 PAGE 11  

 613   4                        receive_count=0;
 614   4                        AT_Command_Status=COMMAND_OK;
 615   4                return;
 616   4                      }
 617   3                  receive_count=0;
 618   3                }
 619   2            if((receive_count==2)&&(uart_buff[1]==0x0d))//没有包含为其他信息的命令返回
 620   2            { //接收到一个命令回应,可能为,0-OK  1-CONNECT 2-RING 3-NO CARRIER 4-ERROR
 621   3                              //只返回OK
 622   3               uart_buff[receive_count]=0;
 623   3               if(uart_buff[0]=='0'){
 624   4                 AT_Command_Status=COMMAND_OK;  //txd_rxd_bit=1;
 625   4               }
 626   3               if(uart_buff[0]=='2'){    
 627   4                 AT_Command_Status=COMMAND_OK;  //txd_rxd_bit=1;
 628   4                 ES=1;                        //设置发送指针
 629   4                 receive_count=0;
 630   4                         send_count=0xff;
 631   4               }
 632   3               else if(uart_buff[0]=='4'||uart_buff[0]=='3'){  
 633   4                         AT_Command_Status=COMMAND_ERROR;
 634   4                       }
 635   3               else AT_Command_Status=COMMAND_UNKNOW;
 636   3                       txd_rxd_bit=1;
 637   3               uart_buff[receive_count]=0;
 638   3               return;
 639   3                 }
 640   2             else if((uart_buff[receive_count-1]==0x0d)
 641   2                                &&(receive_count>=3)
 642   2                                &&(uart_buff[receive_count-3]==0x0a)
 643   2                            &&((uart_buff[receive_count-2]=='0'))){  ///可能是包含为其他信息的命令返回
 644   3               uart_buff[receive_count]=0;//RECEIV OK ANSWER, with some message
 645   3               AT_Command_Status=COMMAND_OK;     
 646   3                       txd_rxd_bit=1;
 647   3             }
 648   2             else if((AT_Command_Type==SMS_CMGS||AT_Command_Type==AT_COMMAND)&&uart_buff[2]=='>'){    
 649   3                   AT_Command_Status=COMMAND_OK;    
 650   3                       txd_rxd_bit=1;
 651   3               return;
 652   3             }
 653   2         }//End of if(RI)
 654   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   2953    ----
   CONSTANT SIZE    =    203    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =     94      11
   IDATA SIZE       =     88    ----
   BIT SIZE         =      3    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -