kl25zgsmgprs

Dependencies:   TextLCD mbed

Revision:
0:a540c6fcb19b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Apr 25 11:23:43 2015 +0000
@@ -0,0 +1,104 @@
+#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);
+int main()
+   {
+       pc.baud(9600);
+       GPRS.baud(9600);
+        
+        
+        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.locate(0,0);
+        lcd.cls();
+    barrer_set();
+     gprs1_set(rfidno);
+    
+   
+  
+   }
+void barrer_set()
+{
+    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);
+   char *f;
+   flush();
+   GPRS.printf("AT+SAPBR=1,1\r\n");
+   while(!GPRS.readable())
+   {}
+   GPRS.scanf("%s",f);
+    GPRS.scanf("%s",f);
+   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);
+     GPRS.printf("AT+HTTPPARA=\"CID\",1\r\n");
+      wait(5);
+      flush();
+   GPRS.printf("AT+SAPBR=1,1\r\n");
+   while(!GPRS.readable())
+   {}
+   GPRS.scanf("%s",f);
+    GPRS.scanf("%s",f);
+   if(f[0]!='O' && f[1]!='K' )
+   wait(4);
+    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);
+    GPRS.printf("AT+HTTPREAD\r\n");
+    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);   
+        }
+void flush(void)
+{
+char char1 = 0; 
+    while (GPRS.readable())
+     { char1 = GPRS.getc(); } 
+     return;
+      }