Harshitha K / Mbed 2 deprecated gprs1

Dependencies:   TextLCD mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "Serial.h"
00003 #include "TextLCD.h"
00004 TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5);
00005 Serial RFID(PTA2, PTA1);
00006 char  a=0x1A,e=0x22,c=0x0d;
00007 char *s1,*str,*s2;
00008 char num[] = "9972237269";
00009 int cou=0,t1=1;
00010 char n1[25];
00011 char char1;
00012 //long int p1=25864;
00013 long int rfidno;
00014 int b1;
00015 Serial GPRS(PTE22,PTE23);
00016   // tx, rx
00017 Serial pc(USBTX,USBRX);
00018 void flush(void); 
00019 void barrer_set();
00020 void gprs1_set(long int);
00021 int main()
00022    {
00023        pc.baud(9600);
00024        GPRS.baud(9600);
00025         
00026         
00027         lcd.printf("Swipe >>       ");// 
00028         RFID.scanf("%d", &rfidno);
00029         lcd.locate(0,0);
00030         lcd.printf("%d  ",rfidno);
00031         wait(4);
00032         pc.printf("%d",rfidno);
00033         pc.printf("\r \n");
00034         wait(0.3);
00035         lcd.locate(0,0);
00036         lcd.cls();
00037     barrer_set();
00038      gprs1_set(rfidno);
00039     
00040    
00041   
00042    }
00043 void barrer_set()
00044 {
00045     GPRS.printf("AT+SAPBR=0,1\r\n");
00046    wait(2);
00047    GPRS.printf("AT+SAPBR=3,1,\"Contype\",\"GPRS\"\r\n");
00048    wait(2);
00049    GPRS.printf("AT+SAPBR=3,1,\"APN\",\"AIRTELGPRS.COM\"\r\n");
00050    wait(2);
00051    char *f;
00052    flush();
00053    GPRS.printf("AT+SAPBR=1,1\r\n");
00054    while(!GPRS.readable())
00055    {}
00056    GPRS.scanf("%s",f);
00057     GPRS.scanf("%s",f);
00058    if(f[0]!='O' && f[1]!='K' )
00059    barrer_set();
00060     }
00061     void gprs1_set(long int rfidno)
00062     {
00063         char *f;
00064         GPRS.printf("AT+HTTPINIT\r\n");
00065       wait(5);
00066       GPRS.printf("AT+HTTPPARA=\"CID\",1\r\n");
00067       wait(5);
00068     GPRS.printf("AT+HTTPPARA=\"URL\",\"http://www.abtsystem.netai.net/view.php?rfidno=%ld\"r\n",rfidno);
00069     wait(5);
00070        GPRS.printf("AT+HTTPDATA=1000,5000\r\n");
00071        wait(2);
00072    GPRS.printf("AT+HTTPACTION=1\r\n");
00073     wait(6);
00074      GPRS.printf("AT+HTTPPARA=\"CID\",1\r\n");
00075       wait(5);
00076       flush();
00077    GPRS.printf("AT+SAPBR=1,1\r\n");
00078    while(!GPRS.readable())
00079    {}
00080    GPRS.scanf("%s",f);
00081     GPRS.scanf("%s",f);
00082    if(f[0]!='O' && f[1]!='K' )
00083    wait(4);
00084     GPRS.printf("AT+HTTPPARA=\"URL\",\"http://www.abtsystem.netai.net/view.php?rfidno=%ld\"r\n",rfidno);
00085     wait(5);
00086     GPRS.printf("AT+HTTPACTION=0\r\n");
00087     wait(5);
00088     GPRS.printf("AT+HTTPREAD\r\n");
00089     GPRS.scanf("%s",str);
00090     s1=str;
00091     pc.printf("%s",s1);
00092     lcd.printf("%s",s1);
00093     GPRS.scanf("%s",str);
00094     s2=str;
00095     pc.printf("%s",s2);
00096      lcd.printf("%s",s2);   
00097         }
00098 void flush(void)
00099 {
00100 char char1 = 0; 
00101     while (GPRS.readable())
00102      { char1 = GPRS.getc(); } 
00103      return;
00104       }