GSM_GPRS_TX_RX

Dependencies:   TextLCD mbed

Fork of gprs1 by Harshitha K

main.cpp

Committer:
Lakshmikumar
Date:
2015-04-25
Revision:
1:d6d00af5f72f
Parent:
0:a540c6fcb19b

File content as of revision 1:d6d00af5f72f:

#include "mbed.h"
#include "Serial.h"
#include "TextLCD.h"
TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5);
Serial RFID(PTA2, PTA1);
char  a=0x1A,e=0x22,c=0x0d;
char *s1,*str,*s2;
char num[] = "9972237269";
int cou=0,t1=1;
char n1[25];
char char1;
//long int p1=25864;
long int rfidno;
int b1;
Serial GPRS(PTE22,PTE23);
  // tx, rx
Serial pc(USBTX,USBRX);
void flush(void); 
void barrer_set();
void gprs1_set(long int);

///////////////////////////////////////////////////////////////////
void flush(void)
{
char char1 = 0; 
    while (GPRS.readable())
     { char1 = GPRS.getc(); } 
     return;
      }
//////////////////////////////////////////////////////////////////////////////////////////////////
void barrer_set()
{   char *f;
    GPRS.printf("AT+SAPBR=0,1\r\n");
   wait(2);
   GPRS.printf("AT+SAPBR=3,1,\"Contype\",\"GPRS\"\r\n");
   wait(2);
   GPRS.printf("AT+SAPBR=3,1,\"APN\",\"AIRTELGPRS.COM\"\r\n");
   wait(2);
   flush();
   GPRS.printf("AT+SAPBR=1,1\r\n");
   GPRS.scanf("%s",f);
   GPRS.scanf("%s",f);
   wait(2);
   if(f[0]!='O' && f[1]!='K')
   barrer_set();
    }
    
////////////////////////////////////////////////////////////////////////////////////////// 
void gprs1_set(long int rfidno)
{
      char *f;
      GPRS.printf("AT+HTTPINIT\r\n");
      wait(5);
      GPRS.printf("AT+HTTPPARA=\"CID\",1\r\n");
      wait(5);
      GPRS.printf("AT+HTTPPARA=\"URL\",\"http://www.abtsystem.netai.net/view.php?rfidno=%ld\"\r\n",rfidno);
      wait(5);
      GPRS.printf("AT+HTTPDATA=1000,5000\r\n");
      wait(2);
      GPRS.printf("AT+HTTPACTION=1\r\n");
      wait(6);
      barrer_set();
      GPRS.printf("AT+HTTPPARA=\"CID\",1\r\n");
      wait(5);
      GPRS.printf("AT+HTTPPARA=\"URL\",\"http://www.abtsystem.netai.net/view.php?rfidno=%ld\"\r\n",rfidno);
      wait(5);
      GPRS.printf("AT+HTTPACTION=0\r\n");
      wait(5);
      flush();
      GPRS.printf("AT+HTTPREAD\r\n");
      GPRS.scanf("%s",str);
      GPRS.scanf("%s",str);
      s1=str;
      pc.printf("%s",s1);
      lcd.printf("%s",s1);
      GPRS.scanf("%s",str);
      s2=str;
      pc.printf("%s",s2);
      lcd.printf("%s",s2);   
          }
////////////////////////////////////////////////////////////////////////////////////////////////////////
int main()
   {
        GPRS.baud(9600);
        lcd.cls();
        lcd.printf("Swipe >>       ");// 
        RFID.scanf("%d", &rfidno);
        lcd.locate(0,0);
        lcd.printf("%d  ",rfidno);
        wait(4);
        pc.printf("%d",rfidno);
        pc.printf("\r \n");
        wait(0.3);
        
        lcd.cls();
        lcd.locate(0,0);
        
        barrer_set();
        gprs1_set(rfidno);
   }
////////////////////////////////////////////////////////////////////////////////////////////