
The micro controler used was the STM32F746ZG
Revision 0:d14c82c59346, committed 2018-02-06
- Comitter:
- juansparra
- Date:
- Tue Feb 06 22:38:06 2018 +0000
- Commit message:
- Used with the Sim808
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r d14c82c59346 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Feb 06 22:38:06 2018 +0000 @@ -0,0 +1,420 @@ +#include "mbed.h" + +char CtrlZ = 0x1A; +char buffer[256],buffer_GPS[256],posbuffer=5,posbufferinterrup=0,imprima=0; +Serial sim808(PE_8,PE_7);//Serial xxxx(SERIAL_TX, SERIAL_RX); + +Serial pc(SERIAL_TX, SERIAL_RX); + + +void obtener(){ + + char ob = sim808.getc(); + if(ob==13||ob==10) + {imprima=1; + posbuffer=posbufferinterrup; + posbufferinterrup=0; + } + else + {buffer[posbufferinterrup]=ob; + posbufferinterrup++; + } + + } +DigitalIn mybutton(USER_BUTTON); +DigitalOut myled(LED1); + + + +int main() { + sim808.baud(9600); + sim808.attach(&obtener); + while(1) { + if (mybutton == 1) { // Button is pressed + myled = !myled; // Toggle the LED state + wait(2); // 200 ms + //myled = !myled; // Toggle the LED state + //wait(2); // 200 ms + + + + + do + { + imprima=0; + posbuffer=0; + sim808.printf("AT+CGPSPWR=1"); + pc.printf("AT+CGPSPWR=1"); + sim808.putc(13); + wait(.9); + while(imprima==0) + {} + pc.putc(13); + pc.putc(10); + for(imprima=0;imprima<posbuffer;imprima++) + {pc.putc(imprima+48); + pc.putc(buffer[imprima]); + } + + if((buffer[0]=='O')and(buffer[1]=='K')) + imprima=1; + + }while(imprima==0); + + + + do + { + imprima=0; + posbuffer=0; + sim808.printf("AT+CGPSSTATUS?"); + pc.printf("AT+CGPSSTATUS?"); + sim808.putc(13); + wait(.9); + while(imprima==0) + {} + pc.putc(13); + pc.putc(10); + for(imprima=0;imprima<posbuffer;imprima++) + {pc.putc(imprima+48); + pc.putc(buffer[imprima]); + } + + if((buffer[24]=='D')or(buffer[23]=='D')) + imprima=1; + + }while(imprima==0); + + + + do + { + imprima=0; + posbuffer=0; + sim808.printf("AT+CGNSSEQ?"); + pc.printf("AT+CGNSSEQ?"); + sim808.putc(13); + wait(.9); + while(imprima==0) + {} + pc.putc(13); + pc.putc(10); + for(imprima=0;imprima<posbuffer;imprima++) + {pc.putc(imprima+48); + pc.putc(buffer[imprima]); + } + + if((buffer[12]=='C')or(buffer[13]=='C')) + imprima=1; + + }while(imprima==0); + + + + do + { + imprima=0; + posbuffer=0; + sim808.printf("AT+CGNSURC?"); + pc.printf("AT+CGNSURC?"); + sim808.putc(13); + wait(.9); + while(imprima==0) + {} + pc.putc(13); + pc.putc(10); + for(imprima=0;imprima<posbuffer;imprima++) + {pc.putc(imprima+48); + pc.putc(buffer[imprima]); + } + + if((buffer[8]=='C')or(buffer[7]=='C')) + imprima=1; + + }while(imprima==0); + + + + + + + do + { + imprima=0; + posbuffer=0; + sim808.printf("AT+CGNSINF"); + pc.printf("AT+CGNSINF"); + sim808.putc(13); + wait(.9); + while(imprima==0) + {} + pc.putc(13); + pc.putc(10); + for(imprima=0;imprima<52;imprima++) + {buffer_GPS[imprima]=buffer[imprima]; + pc.putc(imprima+48); + pc.putc(buffer[imprima]); + } + + if((buffer[7]=='N')or(buffer[8]=='N')) + imprima=1; + + }while(imprima==0); + + + + + + + + + + do + { + imprima=0; + posbuffer=0; + sim808.printf("AT+CIPSHUT"); + pc.printf("shut"); + sim808.putc(13); + wait(.9); + while(imprima==0) + {} + pc.putc(13); + pc.putc(10); + for(imprima=0;imprima<posbuffer;imprima++) + {pc.putc(imprima+48); + pc.putc(buffer[imprima]); + } + + if((buffer[0]=='S')and(buffer[1]=='H')) + imprima=1; + + }while(imprima==0); + + + + do + { + imprima=0; + posbuffer=0; + sim808.printf("AT+CIPMUX=0"); + pc.printf("AT+CIPMUX=0"); + sim808.putc(13); + wait(.9); + while(imprima==0) + {} + pc.putc(13); + pc.putc(10); + for(imprima=0;imprima<posbuffer;imprima++) + pc.putc(buffer[imprima]); + + if((buffer[0]=='O')and(buffer[1]=='K')) + imprima=1; + else + imprima=0; + }while(imprima==0); + + myled = !myled; // Toggle the LED state + wait(2); // 200 ms + myled = !myled; // Toggle the LED state + wait(2); // 200 ms + + + do + { + imprima=0; + posbuffer=0; + sim808.printf("AT+CGATT=1"); + pc.printf("AT+CGATT=1"); + sim808.putc(13); + wait(.9); + while(imprima==0) + {} + pc.putc(13); + pc.putc(10); + for(imprima=0;imprima<posbuffer;imprima++) + pc.putc(buffer[imprima]); + if((buffer[0]=='O')and(buffer[1]=='K')) + imprima=1; + else + imprima=0; + }while(imprima==0); + + + + do + { + imprima=0; + posbuffer=0; + sim808.printf("AT+CSTT="); + sim808.putc(34); + sim808.printf("internet.comcel.com.co"); + sim808.putc(34); + sim808.putc(44); + sim808.putc(34); + sim808.putc(34); + sim808.putc(44); + sim808.putc(34); + sim808.putc(34); + + pc.printf("AT+CSTT=internet"); + sim808.putc(13); + wait(.9); + while(imprima==0) + {} + pc.putc(13); + pc.putc(10); + for(imprima=0;imprima<posbuffer;imprima++) + pc.putc(buffer[imprima]); + if((buffer[0]=='O')and(buffer[1]=='K')) + imprima=1; + else + imprima=0; + }while(imprima==0); + + + + + do + { + imprima=0; + posbuffer=0; + sim808.printf("AT+CIICR"); + pc.printf("AT+CIICR"); + sim808.putc(13); + wait(.9); + while(imprima==0) + {} + pc.putc(13); + pc.putc(10); + for(imprima=0;imprima<posbuffer;imprima++) + {pc.putc(imprima+48); + pc.putc(buffer[imprima]); + } + + if((buffer[0]=='O')and(buffer[1]=='K')) + imprima=1; + else + imprima=0; + + }while(imprima==0); + + + + + do + { + imprima=0; + posbuffer=0; + sim808.printf("AT+CIFSR"); + pc.printf("AT+CIFSR"); + sim808.putc(13); + wait(.9); + while(imprima==0) + {} + pc.putc(13); + pc.putc(10); + for(imprima=0;imprima<posbuffer;imprima++) + pc.putc(buffer[imprima]); + if((buffer[0]>='1')and(buffer[1]>='0')) + imprima=1; + else + imprima=0; + }while(imprima==0); + + + + + + + + + do + { + imprima=0; + posbuffer=0; + sim808.printf("AT+CIPSTART="); + sim808.putc(34); + sim808.printf("TCP"); + sim808.putc(34); + sim808.putc(44); + sim808.putc(34); + sim808.printf("200.93.168.133"); // + + + sim808.putc(34); + sim808.putc(44); + sim808.putc(34); + sim808.printf("10800"); + + sim808.putc(34); + + pc.printf("CIPSTART=TCP"); + sim808.putc(13); + wait(.9); + while(imprima==0) + {} + pc.putc(13); + pc.putc(10); + for(imprima=0;imprima<posbuffer;imprima++) + pc.putc(buffer[imprima]); + if((buffer[0]=='O')and(buffer[1]=='K')) + imprima=1; + else + imprima=0; + }while(imprima==0); + + + + + + do + { + imprima=0; + posbuffer=0; + sim808.printf("AT+CIPSEND"); + pc.printf("AT+CIPSEND"); + sim808.putc(13); + wait(.9); + while(imprima==0) + {} + pc.putc(13); + pc.putc(10); + for(imprima=0;imprima<posbuffer;imprima++) + pc.putc(buffer[imprima]); + if(buffer[0]=='>') + imprima=1; + else + imprima=0; + }while(imprima==0); + + + do + { + imprima=0; + posbuffer=0; + sim808.printf("porfin desde el mbed."); + + for(imprima=0;imprima<52;imprima++) + {sim808.putc(buffer_GPS[imprima]); + } + sim808.putc(0x1a); + wait(3); + + imprima=1; + }while(imprima==0); + + + myled = !myled; // Toggle the LED state + wait(6); // 200 ms + myled = !myled; // Toggle the LED state + wait(1); // 200 ms + myled = !myled; // Toggle the LED state + wait(6); // 200 ms + myled = !myled; // Toggle the LED state + wait(1); // 200 ms + + } + } +} + \ No newline at end of file
diff -r 000000000000 -r d14c82c59346 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Feb 06 22:38:06 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/e7ca05fa8600 \ No newline at end of file