Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 #include "mbed.h" 00002 #include <string.h> 00003 #include "GPS.h" 00004 00005 GPS gps(p9,p10); 00006 Serial gsm(p28,p27); 00007 Serial pc(USBTX,USBRX); 00008 00009 int main() { 00010 00011 gsm.baud(115200); 00012 pc.baud(115200); 00013 00014 char buf[40]; 00015 char buf1[40]; 00016 char buf2= 0x1A; 00017 00018 gsm.printf("AT\r\n"); 00019 gsm.scanf("%s",buf); 00020 pc.printf("%s\n",buf); 00021 gsm.scanf("%s",buf1); 00022 pc.printf("%s\n",buf1); 00023 00024 gsm.printf("AT+CSMP=17,167,0,0\r\n"); 00025 gsm.scanf("%s",buf); 00026 gsm.scanf("%s",buf1); 00027 pc.printf("%s\n",buf); 00028 pc.printf("%s\n",buf1); 00029 00030 gsm.printf("AT+CMGF=1\r\n"); 00031 gsm.scanf("%s",buf); 00032 gsm.scanf("%s",buf1); 00033 pc.printf("%s\n",buf); 00034 pc.printf("%s\n",buf1); 00035 00036 while (1) { 00037 if (gps.sample()) { 00038 //if (gps.latitude!=0.0 && gps.longitude!=0.0) { 00039 pc.printf("message sent"); 00040 gsm.printf("AT+CMGS=\"16782450426\"\r\n"); 00041 gsm.scanf("%s",buf); 00042 gsm.scanf("%s",buf1); 00043 pc.printf("%s\n",buf); 00044 pc.printf("%s\n",buf1); 00045 00046 gsm.printf("latitude = %f longitude = %f %c\r\n",gps.latitude,gps.longitude,buf2); 00047 gsm.scanf("%s",buf); 00048 gsm.scanf("%s",buf1); 00049 pc.printf("%s\n",buf); 00050 pc.printf("%s\n",buf1); 00051 00052 break; 00053 } 00054 pc.printf("LATITUDE = %f LONGITUDE = %f",gps.latitude,gps.longitude); 00055 wait(1); 00056 } 00057 pc.printf("end of operation"); 00058 00059 return 0; 00060 }
Generated on Wed Jul 13 2022 03:06:36 by
1.7.2