Autor Tema: Recibir SMS con Sim800  (Leído 1736 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado martinchd

  • PIC12
  • **
  • Mensajes: 78
Recibir SMS con Sim800
« en: 25 de Marzo de 2020, 10:21:50 »
Hola buen dia. Estaría necesitando guardar el numero de teléfono cuando envían un mensaje, para ver que se guarde bien lo estaria mostrando en el display, esto es lo que hice, pero no me funciona.

Código: C
  1. //LCD module connections
  2. #define LCD_RS_PIN PIN_B0
  3. #define LCD_RW_PIN PIN_B1
  4. #define LCD_ENABLE_PIN PIN_B2
  5. #define LCD_DATA4 PIN_B3
  6. #define LCD_DATA5 PIN_B4
  7. #define LCD_DATA6 PIN_B5
  8. #define LCD_DATA7 PIN_B6
  9. //End LCD module connections
  10.  
  11. #include <16F877a.h>
  12. #FUSES XT,NOWDT,NOPROTECT,PUT,NOBROWNOUT,NOLVP    
  13. #use delay(clock=4M)
  14. #use RS232(BAUD=9600,BITS=8,PARITY=N,XMIT=PIN_C6,RCV=PIN_C7)                  
  15. #include <lcd.c>
  16. #define BUFFER_SIZE 60 //Buffer size you can adjust this size
  17.  
  18.  
  19. char  buffer[10]; // Buffer de recepción
  20. int sms=0;
  21. char b=0x00;                     // Primer caracter recibido
  22. int  xbuff=0x00;
  23.  
  24.  
  25.  
  26.  
  27. #int_RDA
  28. RDA_isr()
  29. {
  30. if(kbhit())
  31. {
  32.     b=getc();
  33.     if(b=='+')
  34.      {//Primer caracter del num de tel.
  35.       xbuff=0;//para que comience a escribir a la var buffer desde la 1º posición
  36.      }
  37. buffer[xbuff++]=b;
  38.  
  39.    if(buffer==",") //Caracter despues del numero de telefono.
  40.     {
  41.     sms=1;
  42.     break;
  43.     }
  44. }
  45. return 0;
  46. }
  47.  
  48.  
  49.  
  50. ///////////////////////////////////////////////////////////////////////////////
  51.  
  52.  
  53.  
  54. void main()
  55. {
  56.    
  57.    lcd_init();                            
  58.    printf(LCD_PUTC, "\f     WELCOME  ");
  59.    delay_ms(200);      
  60.    
  61.  
  62.    
  63.    enable_interrupts(global);
  64.    enable_interrupts(int_rda);
  65.  
  66.  
  67.  
  68.    delay_ms(100);
  69.    printf("AT+CMGF=1\r\n"); //Habita el modo texto de los sms
  70.    delay_ms(150);
  71.    printf("AT+CNMI=2,2,0,0,0\r\n");//los sms se envían directamente al puerto serie
  72.    delay_ms(150);
  73.    printf("AT+CMGDA=DEL ALL\r\n"); //BORRAMOS SMS
  74.    delay_ms(150);
  75.  
  76.  
  77. while(true)
  78. {
  79. lcd_gotoxy(1,1);
  80. printf(LCD_PUTC, " Esperando SMS ");
  81. if(sms==1)
  82. {
  83. printf("\f");
  84. lcd_gotoxy(1,2);
  85. printf(LCD_PUTC, "%c",buffer);
  86. delay_ms(1000);
  87. sms=0;
  88. }
  89. delay_ms(100);
  90. }
  91. }


 

anything