Sandesh G
/
gprs1
GSM_GPRS_TX_RX
Fork of gprs1 by
main.cpp@1:d6d00af5f72f, 2015-04-25 (annotated)
- Committer:
- Lakshmikumar
- Date:
- Sat Apr 25 15:38:19 2015 +0000
- Revision:
- 1:d6d00af5f72f
- Parent:
- 0:a540c6fcb19b
gsmgrpstxrx
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Harshithanagaraju | 0:a540c6fcb19b | 1 | #include "mbed.h" |
Harshithanagaraju | 0:a540c6fcb19b | 2 | #include "Serial.h" |
Harshithanagaraju | 0:a540c6fcb19b | 3 | #include "TextLCD.h" |
Harshithanagaraju | 0:a540c6fcb19b | 4 | TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5); |
Harshithanagaraju | 0:a540c6fcb19b | 5 | Serial RFID(PTA2, PTA1); |
Harshithanagaraju | 0:a540c6fcb19b | 6 | char a=0x1A,e=0x22,c=0x0d; |
Harshithanagaraju | 0:a540c6fcb19b | 7 | char *s1,*str,*s2; |
Harshithanagaraju | 0:a540c6fcb19b | 8 | char num[] = "9972237269"; |
Harshithanagaraju | 0:a540c6fcb19b | 9 | int cou=0,t1=1; |
Harshithanagaraju | 0:a540c6fcb19b | 10 | char n1[25]; |
Harshithanagaraju | 0:a540c6fcb19b | 11 | char char1; |
Harshithanagaraju | 0:a540c6fcb19b | 12 | //long int p1=25864; |
Harshithanagaraju | 0:a540c6fcb19b | 13 | long int rfidno; |
Harshithanagaraju | 0:a540c6fcb19b | 14 | int b1; |
Harshithanagaraju | 0:a540c6fcb19b | 15 | Serial GPRS(PTE22,PTE23); |
Harshithanagaraju | 0:a540c6fcb19b | 16 | // tx, rx |
Harshithanagaraju | 0:a540c6fcb19b | 17 | Serial pc(USBTX,USBRX); |
Harshithanagaraju | 0:a540c6fcb19b | 18 | void flush(void); |
Harshithanagaraju | 0:a540c6fcb19b | 19 | void barrer_set(); |
Harshithanagaraju | 0:a540c6fcb19b | 20 | void gprs1_set(long int); |
Lakshmikumar | 1:d6d00af5f72f | 21 | |
Lakshmikumar | 1:d6d00af5f72f | 22 | /////////////////////////////////////////////////////////////////// |
Lakshmikumar | 1:d6d00af5f72f | 23 | void flush(void) |
Lakshmikumar | 1:d6d00af5f72f | 24 | { |
Lakshmikumar | 1:d6d00af5f72f | 25 | char char1 = 0; |
Lakshmikumar | 1:d6d00af5f72f | 26 | while (GPRS.readable()) |
Lakshmikumar | 1:d6d00af5f72f | 27 | { char1 = GPRS.getc(); } |
Lakshmikumar | 1:d6d00af5f72f | 28 | return; |
Lakshmikumar | 1:d6d00af5f72f | 29 | } |
Lakshmikumar | 1:d6d00af5f72f | 30 | ////////////////////////////////////////////////////////////////////////////////////////////////// |
Lakshmikumar | 1:d6d00af5f72f | 31 | void barrer_set() |
Lakshmikumar | 1:d6d00af5f72f | 32 | { char *f; |
Lakshmikumar | 1:d6d00af5f72f | 33 | GPRS.printf("AT+SAPBR=0,1\r\n"); |
Lakshmikumar | 1:d6d00af5f72f | 34 | wait(2); |
Lakshmikumar | 1:d6d00af5f72f | 35 | GPRS.printf("AT+SAPBR=3,1,\"Contype\",\"GPRS\"\r\n"); |
Lakshmikumar | 1:d6d00af5f72f | 36 | wait(2); |
Lakshmikumar | 1:d6d00af5f72f | 37 | GPRS.printf("AT+SAPBR=3,1,\"APN\",\"AIRTELGPRS.COM\"\r\n"); |
Lakshmikumar | 1:d6d00af5f72f | 38 | wait(2); |
Lakshmikumar | 1:d6d00af5f72f | 39 | flush(); |
Lakshmikumar | 1:d6d00af5f72f | 40 | GPRS.printf("AT+SAPBR=1,1\r\n"); |
Lakshmikumar | 1:d6d00af5f72f | 41 | GPRS.scanf("%s",f); |
Lakshmikumar | 1:d6d00af5f72f | 42 | GPRS.scanf("%s",f); |
Lakshmikumar | 1:d6d00af5f72f | 43 | wait(2); |
Lakshmikumar | 1:d6d00af5f72f | 44 | if(f[0]!='O' && f[1]!='K') |
Lakshmikumar | 1:d6d00af5f72f | 45 | barrer_set(); |
Lakshmikumar | 1:d6d00af5f72f | 46 | } |
Lakshmikumar | 1:d6d00af5f72f | 47 | |
Lakshmikumar | 1:d6d00af5f72f | 48 | ////////////////////////////////////////////////////////////////////////////////////////// |
Lakshmikumar | 1:d6d00af5f72f | 49 | void gprs1_set(long int rfidno) |
Lakshmikumar | 1:d6d00af5f72f | 50 | { |
Lakshmikumar | 1:d6d00af5f72f | 51 | char *f; |
Lakshmikumar | 1:d6d00af5f72f | 52 | GPRS.printf("AT+HTTPINIT\r\n"); |
Lakshmikumar | 1:d6d00af5f72f | 53 | wait(5); |
Lakshmikumar | 1:d6d00af5f72f | 54 | GPRS.printf("AT+HTTPPARA=\"CID\",1\r\n"); |
Lakshmikumar | 1:d6d00af5f72f | 55 | wait(5); |
Lakshmikumar | 1:d6d00af5f72f | 56 | GPRS.printf("AT+HTTPPARA=\"URL\",\"http://www.abtsystem.netai.net/view.php?rfidno=%ld\"\r\n",rfidno); |
Lakshmikumar | 1:d6d00af5f72f | 57 | wait(5); |
Lakshmikumar | 1:d6d00af5f72f | 58 | GPRS.printf("AT+HTTPDATA=1000,5000\r\n"); |
Lakshmikumar | 1:d6d00af5f72f | 59 | wait(2); |
Lakshmikumar | 1:d6d00af5f72f | 60 | GPRS.printf("AT+HTTPACTION=1\r\n"); |
Lakshmikumar | 1:d6d00af5f72f | 61 | wait(6); |
Lakshmikumar | 1:d6d00af5f72f | 62 | barrer_set(); |
Lakshmikumar | 1:d6d00af5f72f | 63 | GPRS.printf("AT+HTTPPARA=\"CID\",1\r\n"); |
Lakshmikumar | 1:d6d00af5f72f | 64 | wait(5); |
Lakshmikumar | 1:d6d00af5f72f | 65 | GPRS.printf("AT+HTTPPARA=\"URL\",\"http://www.abtsystem.netai.net/view.php?rfidno=%ld\"\r\n",rfidno); |
Lakshmikumar | 1:d6d00af5f72f | 66 | wait(5); |
Lakshmikumar | 1:d6d00af5f72f | 67 | GPRS.printf("AT+HTTPACTION=0\r\n"); |
Lakshmikumar | 1:d6d00af5f72f | 68 | wait(5); |
Lakshmikumar | 1:d6d00af5f72f | 69 | flush(); |
Lakshmikumar | 1:d6d00af5f72f | 70 | GPRS.printf("AT+HTTPREAD\r\n"); |
Lakshmikumar | 1:d6d00af5f72f | 71 | GPRS.scanf("%s",str); |
Lakshmikumar | 1:d6d00af5f72f | 72 | GPRS.scanf("%s",str); |
Lakshmikumar | 1:d6d00af5f72f | 73 | s1=str; |
Lakshmikumar | 1:d6d00af5f72f | 74 | pc.printf("%s",s1); |
Lakshmikumar | 1:d6d00af5f72f | 75 | lcd.printf("%s",s1); |
Lakshmikumar | 1:d6d00af5f72f | 76 | GPRS.scanf("%s",str); |
Lakshmikumar | 1:d6d00af5f72f | 77 | s2=str; |
Lakshmikumar | 1:d6d00af5f72f | 78 | pc.printf("%s",s2); |
Lakshmikumar | 1:d6d00af5f72f | 79 | lcd.printf("%s",s2); |
Lakshmikumar | 1:d6d00af5f72f | 80 | } |
Lakshmikumar | 1:d6d00af5f72f | 81 | //////////////////////////////////////////////////////////////////////////////////////////////////////// |
Harshithanagaraju | 0:a540c6fcb19b | 82 | int main() |
Harshithanagaraju | 0:a540c6fcb19b | 83 | { |
Lakshmikumar | 1:d6d00af5f72f | 84 | GPRS.baud(9600); |
Lakshmikumar | 1:d6d00af5f72f | 85 | lcd.cls(); |
Harshithanagaraju | 0:a540c6fcb19b | 86 | lcd.printf("Swipe >> ");// |
Harshithanagaraju | 0:a540c6fcb19b | 87 | RFID.scanf("%d", &rfidno); |
Harshithanagaraju | 0:a540c6fcb19b | 88 | lcd.locate(0,0); |
Harshithanagaraju | 0:a540c6fcb19b | 89 | lcd.printf("%d ",rfidno); |
Harshithanagaraju | 0:a540c6fcb19b | 90 | wait(4); |
Harshithanagaraju | 0:a540c6fcb19b | 91 | pc.printf("%d",rfidno); |
Harshithanagaraju | 0:a540c6fcb19b | 92 | pc.printf("\r \n"); |
Harshithanagaraju | 0:a540c6fcb19b | 93 | wait(0.3); |
Lakshmikumar | 1:d6d00af5f72f | 94 | |
Harshithanagaraju | 0:a540c6fcb19b | 95 | lcd.cls(); |
Lakshmikumar | 1:d6d00af5f72f | 96 | lcd.locate(0,0); |
Lakshmikumar | 1:d6d00af5f72f | 97 | |
Lakshmikumar | 1:d6d00af5f72f | 98 | barrer_set(); |
Lakshmikumar | 1:d6d00af5f72f | 99 | gprs1_set(rfidno); |
Harshithanagaraju | 0:a540c6fcb19b | 100 | } |
Lakshmikumar | 1:d6d00af5f72f | 101 | //////////////////////////////////////////////////////////////////////////////////////////// |
Lakshmikumar | 1:d6d00af5f72f | 102 |