mbed 5.4 with sleep mode

Dependencies:  

Committer:
mazgch
Date:
Thu Aug 11 07:09:44 2016 +0000
Revision:
32:b838fcaba45e
Parent:
31:a07d0f76dc81
Child:
33:e27f40fada64
.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lawliet 0:4e3cb26f6019 1 #include "mbed.h"
mazgch 9:26f694bc31b4 2
mazgch 19:f022ff746eb8 3 //------------------------------------------------------------------------------------
mazgch 11:b8505cbbd55c 4 /* This example was tested on C027-U20 and C027-G35 with the on board modem.
mazgch 11:b8505cbbd55c 5
mazgch 18:50e6c4ed8a4a 6 Additionally it was tested with a shield where the SARA-G350/U260/U270 RX/TX/PWRON
mazgch 11:b8505cbbd55c 7 is connected to D0/D1/D4 and the GPS SCL/SDA is connected D15/D15. In this
mazgch 11:b8505cbbd55c 8 configuration the following platforms were tested (it is likely that others
mazgch 11:b8505cbbd55c 9 will work as well)
mazgch 19:f022ff746eb8 10 - U-BLOX: C027-G35, C027-U20, C027-C20 (for shield set define C027_FORCE_SHIELD)
mazgch 18:50e6c4ed8a4a 11 - NXP: LPC1549v2, LPC4088qsb
mazgch 18:50e6c4ed8a4a 12 - Freescale: FRDM-KL05Z, FRDM-KL25Z, FRDM-KL46Z, FRDM-K64F
mazgch 12:96c7b62c7aaf 13 - STM: NUCLEO-F401RE, NUCLEO-F030R8
mazgch 18:50e6c4ed8a4a 14 mount resistors SB13/14 1k, SB62/63 0R
mazgch 11:b8505cbbd55c 15 */
mazgch 19:f022ff746eb8 16 #include "GPS.h"
mazgch 19:f022ff746eb8 17 #include "MDM.h"
mazgch 19:f022ff746eb8 18 //------------------------------------------------------------------------------------
mazgch 19:f022ff746eb8 19 // You need to configure these cellular modem / SIM parameters.
mazgch 19:f022ff746eb8 20 // These parameters are ignored for LISA-C200 variants and can be left NULL.
mazgch 19:f022ff746eb8 21 //------------------------------------------------------------------------------------
mazgch 19:f022ff746eb8 22 //! Set your secret SIM pin here (e.g. "1234"). Check your SIM manual.
mazgch 19:f022ff746eb8 23 #define SIMPIN NULL
mazgch 19:f022ff746eb8 24 /*! The APN of your network operator SIM, sometimes it is "internet" check your
mazgch 19:f022ff746eb8 25 contract with the network operator. You can also try to look-up your settings in
mazgch 19:f022ff746eb8 26 google: https://www.google.de/search?q=APN+list */
mazgch 21:a090a5043e23 27 #define APN NULL
mazgch 19:f022ff746eb8 28 //! Set the user name for your APN, or NULL if not needed
mazgch 19:f022ff746eb8 29 #define USERNAME NULL
mazgch 19:f022ff746eb8 30 //! Set the password for your APN, or NULL if not needed
mazgch 19:f022ff746eb8 31 #define PASSWORD NULL
mazgch 19:f022ff746eb8 32 //------------------------------------------------------------------------------------
lawliet 0:4e3cb26f6019 33
msinig 29:16f1037626e3 34 //#define CELLOCATE
msinig 29:16f1037626e3 35
lawliet 0:4e3cb26f6019 36 int main(void)
lawliet 0:4e3cb26f6019 37 {
mazgch 2:b77151f111a9 38 int ret;
mazgch 19:f022ff746eb8 39 #ifdef LARGE_DATA
mazgch 16:43f6de7bc38b 40 char buf[2048] = "";
mazgch 17:c293780a40ac 41 #else
mazgch 17:c293780a40ac 42 char buf[512] = "";
mazgch 17:c293780a40ac 43 #endif
lawliet 0:4e3cb26f6019 44
mazgch 19:f022ff746eb8 45 // Create the GPS object
mazgch 19:f022ff746eb8 46 #if 1 // use GPSI2C class
mazgch 19:f022ff746eb8 47 GPSI2C gps;
mazgch 19:f022ff746eb8 48 #else // or GPSSerial class
mazgch 19:f022ff746eb8 49 GPSSerial gps;
mazgch 10:d2da2028a233 50 #endif
mazgch 10:d2da2028a233 51 // Create the modem object
mazgch 32:b838fcaba45e 52 MDMSerial mdm; // use mdm(D1,D0) if you connect the cellular shield to a C027
mazgch 28:334263983fcd 53 //mdm.setDebug(4); // enable this for debugging issues
mazgch 2:b77151f111a9 54 // initialize the modem
mazgch 19:f022ff746eb8 55 MDMParser::DevStatus devStatus = {};
mazgch 19:f022ff746eb8 56 MDMParser::NetStatus netStatus = {};
mazgch 10:d2da2028a233 57 bool mdmOk = mdm.init(SIMPIN, &devStatus);
mazgch 19:f022ff746eb8 58 mdm.dumpDevStatus(&devStatus);
mazgch 19:f022ff746eb8 59 if (mdmOk) {
mazgch 20:52f0e5de8c3d 60 #if 0
mazgch 20:52f0e5de8c3d 61 // file system API
mazgch 19:f022ff746eb8 62 const char* filename = "File";
mazgch 19:f022ff746eb8 63 char buf[] = "Hello World";
mazgch 19:f022ff746eb8 64 printf("writeFile \"%s\"\r\n", buf);
mazgch 19:f022ff746eb8 65 if (mdm.writeFile(filename, buf, sizeof(buf)))
mazgch 19:f022ff746eb8 66 {
mazgch 19:f022ff746eb8 67 memset(buf, 0, sizeof(buf));
mazgch 19:f022ff746eb8 68 int len = mdm.readFile(filename, buf, sizeof(buf));
mazgch 24:81f5b43a6585 69 if (len >= 0)
mazgch 19:f022ff746eb8 70 printf("readFile %d \"%.*s\"\r\n", len, len, buf);
mazgch 19:f022ff746eb8 71 mdm.delFile(filename);
mazgch 19:f022ff746eb8 72 }
mazgch 20:52f0e5de8c3d 73 #endif
mazgch 20:52f0e5de8c3d 74
mazgch 20:52f0e5de8c3d 75 // wait until we are connected
mazgch 20:52f0e5de8c3d 76 mdmOk = mdm.registerNet(&netStatus);
mazgch 20:52f0e5de8c3d 77 mdm.dumpNetStatus(&netStatus);
mazgch 20:52f0e5de8c3d 78 }
mazgch 20:52f0e5de8c3d 79 if (mdmOk)
mazgch 20:52f0e5de8c3d 80 {
mazgch 19:f022ff746eb8 81 // http://www.geckobeach.com/cellular/secrets/gsmcodes.php
mazgch 19:f022ff746eb8 82 // http://de.wikipedia.org/wiki/USSD-Codes
mazgch 19:f022ff746eb8 83 const char* ussd = "*130#"; // You may get answer "UNKNOWN APPLICATION"
mazgch 19:f022ff746eb8 84 printf("Ussd Send Command %s\r\n", ussd);
mazgch 19:f022ff746eb8 85 ret = mdm.ussdCommand(ussd, buf);
mazgch 19:f022ff746eb8 86 if (ret > 0)
mazgch 19:f022ff746eb8 87 printf("Ussd Got Answer: \"%*s\"\r\n", ret, buf);
mazgch 19:f022ff746eb8 88
mazgch 4:90ab1ec64b0e 89 // join the internet connection
mazgch 19:f022ff746eb8 90 MDMParser::IP ip = mdm.join(APN,USERNAME,PASSWORD);
mazgch 32:b838fcaba45e 91 if (ip == NOIP)
mazgch 32:b838fcaba45e 92 printf("Not able to join network");
mazgch 32:b838fcaba45e 93 else
mazgch 2:b77151f111a9 94 {
mazgch 19:f022ff746eb8 95 mdm.dumpIp(ip);
mazgch 19:f022ff746eb8 96 printf("Make a Http Post Request\r\n");
mazgch 4:90ab1ec64b0e 97 int socket = mdm.socketSocket(MDMParser::IPPROTO_TCP);
mazgch 4:90ab1ec64b0e 98 if (socket >= 0)
mazgch 2:b77151f111a9 99 {
mazgch 16:43f6de7bc38b 100 mdm.socketSetBlocking(socket, 10000);
mazgch 4:90ab1ec64b0e 101 if (mdm.socketConnect(socket, "mbed.org", 80))
mazgch 4:90ab1ec64b0e 102 {
mazgch 4:90ab1ec64b0e 103 const char http[] = "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\r\n\r\n";
mazgch 4:90ab1ec64b0e 104 mdm.socketSend(socket, http, sizeof(http)-1);
mazgch 4:90ab1ec64b0e 105
mazgch 19:f022ff746eb8 106 ret = mdm.socketRecv(socket, buf, sizeof(buf)-1);
mazgch 19:f022ff746eb8 107 if (ret > 0)
mazgch 19:f022ff746eb8 108 printf("Socket Recv \"%*s\"\r\n", ret, buf);
mazgch 4:90ab1ec64b0e 109 mdm.socketClose(socket);
mazgch 4:90ab1ec64b0e 110 }
mazgch 4:90ab1ec64b0e 111 mdm.socketFree(socket);
mazgch 4:90ab1ec64b0e 112 }
mazgch 2:b77151f111a9 113
mazgch 16:43f6de7bc38b 114 int port = 7;
mazgch 16:43f6de7bc38b 115 const char* host = "echo.u-blox.com";
mazgch 16:43f6de7bc38b 116 MDMParser::IP ip = mdm.gethostbyname(host);
mazgch 16:43f6de7bc38b 117 char data[] = "\r\nxxx Socket Hello World\r\n"
mazgch 19:f022ff746eb8 118 #ifdef LARGE_DATA
mazgch 17:c293780a40ac 119 "00 0123456789 0123456789 0123456789 0123456789 0123456789 \r\n"
mazgch 17:c293780a40ac 120 "01 0123456789 0123456789 0123456789 0123456789 0123456789 \r\n"
mazgch 17:c293780a40ac 121 "02 0123456789 0123456789 0123456789 0123456789 0123456789 \r\n"
mazgch 17:c293780a40ac 122 "03 0123456789 0123456789 0123456789 0123456789 0123456789 \r\n"
mazgch 17:c293780a40ac 123 "04 0123456789 0123456789 0123456789 0123456789 0123456789 \r\n"
mazgch 17:c293780a40ac 124
mazgch 17:c293780a40ac 125 "05 0123456789 0123456789 0123456789 0123456789 0123456789 \r\n"
mazgch 17:c293780a40ac 126 "06 0123456789 0123456789 0123456789 0123456789 0123456789 \r\n"
mazgch 17:c293780a40ac 127 "07 0123456789 0123456789 0123456789 0123456789 0123456789 \r\n"
mazgch 17:c293780a40ac 128 "08 0123456789 0123456789 0123456789 0123456789 0123456789 \r\n"
mazgch 17:c293780a40ac 129 "09 0123456789 0123456789 0123456789 0123456789 0123456789 \r\n"
mazgch 16:43f6de7bc38b 130
mazgch 17:c293780a40ac 131 "10 0123456789 0123456789 0123456789 0123456789 0123456789 \r\n"
mazgch 17:c293780a40ac 132 "11 0123456789 0123456789 0123456789 0123456789 0123456789 \r\n"
mazgch 17:c293780a40ac 133 "12 0123456789 0123456789 0123456789 0123456789 0123456789 \r\n"
mazgch 17:c293780a40ac 134 "13 0123456789 0123456789 0123456789 0123456789 0123456789 \r\n"
mazgch 17:c293780a40ac 135 "14 0123456789 0123456789 0123456789 0123456789 0123456789 \r\n"
mazgch 17:c293780a40ac 136
mazgch 17:c293780a40ac 137 "15 0123456789 0123456789 0123456789 0123456789 0123456789 \r\n"
mazgch 17:c293780a40ac 138 "16 0123456789 0123456789 0123456789 0123456789 0123456789 \r\n"
mazgch 17:c293780a40ac 139 "17 0123456789 0123456789 0123456789 0123456789 0123456789 \r\n"
mazgch 17:c293780a40ac 140 "18 0123456789 0123456789 0123456789 0123456789 0123456789 \r\n"
mazgch 17:c293780a40ac 141 "19 0123456789 0123456789 0123456789 0123456789 0123456789 \r\n"
mazgch 16:43f6de7bc38b 142 #endif
mazgch 17:c293780a40ac 143 "End\r\n";
mazgch 16:43f6de7bc38b 144
mazgch 19:f022ff746eb8 145 printf("Testing TCP sockets with ECHO server\r\n");
mazgch 16:43f6de7bc38b 146 socket = mdm.socketSocket(MDMParser::IPPROTO_TCP);
mazgch 16:43f6de7bc38b 147 if (socket >= 0)
mazgch 16:43f6de7bc38b 148 {
mazgch 16:43f6de7bc38b 149 mdm.socketSetBlocking(socket, 10000);
mazgch 16:43f6de7bc38b 150 if (mdm.socketConnect(socket, host, port)) {
mazgch 16:43f6de7bc38b 151 memcpy(data, "\r\nTCP", 5);
mazgch 16:43f6de7bc38b 152 ret = mdm.socketSend(socket, data, sizeof(data)-1);
mazgch 16:43f6de7bc38b 153 if (ret == sizeof(data)-1) {
mazgch 19:f022ff746eb8 154 printf("Socket Send %d \"%s\"\r\n", ret, data);
mazgch 16:43f6de7bc38b 155 }
mazgch 16:43f6de7bc38b 156 ret = mdm.socketRecv(socket, buf, sizeof(buf)-1);
mazgch 16:43f6de7bc38b 157 if (ret >= 0) {
mazgch 19:f022ff746eb8 158 printf("Socket Recv %d \"%.*s\"\r\n", ret, ret, buf);
mazgch 16:43f6de7bc38b 159 }
mazgch 16:43f6de7bc38b 160 mdm.socketClose(socket);
mazgch 16:43f6de7bc38b 161 }
mazgch 16:43f6de7bc38b 162 mdm.socketFree(socket);
mazgch 16:43f6de7bc38b 163 }
mazgch 16:43f6de7bc38b 164
mazgch 19:f022ff746eb8 165 printf("Testing UDP sockets with ECHO server\r\n");
mazgch 16:43f6de7bc38b 166 socket = mdm.socketSocket(MDMParser::IPPROTO_UDP, port);
mazgch 16:43f6de7bc38b 167 if (socket >= 0)
mazgch 16:43f6de7bc38b 168 {
mazgch 16:43f6de7bc38b 169 mdm.socketSetBlocking(socket, 10000);
mazgch 16:43f6de7bc38b 170 memcpy(data, "\r\nUDP", 5);
mazgch 16:43f6de7bc38b 171 ret = mdm.socketSendTo(socket, ip, port, data, sizeof(data)-1);
mazgch 16:43f6de7bc38b 172 if (ret == sizeof(data)-1) {
mazgch 19:f022ff746eb8 173 printf("Socket SendTo %s:%d " IPSTR " %d \"%s\"\r\n", host, port, IPNUM(ip), ret, data);
mazgch 16:43f6de7bc38b 174 }
mazgch 16:43f6de7bc38b 175 ret = mdm.socketRecvFrom(socket, &ip, &port, buf, sizeof(buf)-1);
mazgch 16:43f6de7bc38b 176 if (ret >= 0) {
mazgch 19:f022ff746eb8 177 printf("Socket RecvFrom " IPSTR ":%d %d \"%.*s\" \r\n", IPNUM(ip),port, ret, ret,buf);
mazgch 16:43f6de7bc38b 178 }
mazgch 16:43f6de7bc38b 179 mdm.socketFree(socket);
mazgch 16:43f6de7bc38b 180 }
mazgch 16:43f6de7bc38b 181
mazgch 4:90ab1ec64b0e 182 // disconnect
mazgch 4:90ab1ec64b0e 183 mdm.disconnect();
mazgch 2:b77151f111a9 184 }
mazgch 10:d2da2028a233 185 }
mazgch 19:f022ff746eb8 186 printf("SMS and GPS Loop\r\n");
mazgch 10:d2da2028a233 187 char link[128] = "";
mazgch 10:d2da2028a233 188 unsigned int i = 0xFFFFFFFF;
mazgch 10:d2da2028a233 189 const int wait = 100;
mazgch 10:d2da2028a233 190 bool abort = false;
msinig 29:16f1037626e3 191 #ifdef CELLOCATE
msinig 29:16f1037626e3 192 const int sensorMask = 3; // Hybrid: GNSS + CellLocate
msinig 29:16f1037626e3 193 const int timeoutMargin = 5; // seconds
msinig 29:16f1037626e3 194 const int submitPeriod = 60; // 1 minutes in seconds
msinig 29:16f1037626e3 195 const int targetAccuracy = 1; // meters
msinig 29:16f1037626e3 196 unsigned int j = submitPeriod * 1000/wait;
msinig 29:16f1037626e3 197 bool cellLocWait = false;
msinig 29:16f1037626e3 198 MDMParser::CellLocData loc;
msinig 29:16f1037626e3 199
msinig 29:16f1037626e3 200 //Token can be released from u-blox site, when you got one replace "TOKEN" below
msinig 29:16f1037626e3 201 if (!mdm.cellLocSrvHttp("TOKEN"))
msinig 29:16f1037626e3 202 mdm.cellLocSrvUdp();
msinig 29:16f1037626e3 203 mdm.cellLocConfigSensor(1); // Deep scan mode
msinig 29:16f1037626e3 204 //mdm.cellUnsolIndication(1);
msinig 29:16f1037626e3 205 #endif
mazgch 11:b8505cbbd55c 206 //DigitalOut led(LED1);
mazgch 10:d2da2028a233 207 while (!abort) {
mazgch 19:f022ff746eb8 208 // led = !led;
msinig 29:16f1037626e3 209 #ifndef CELLOCATE
mazgch 10:d2da2028a233 210 while ((ret = gps.getMessage(buf, sizeof(buf))) > 0)
mazgch 10:d2da2028a233 211 {
mazgch 10:d2da2028a233 212 int len = LENGTH(ret);
mazgch 19:f022ff746eb8 213 //printf("NMEA: %.*s\r\n", len-2, msg);
mazgch 19:f022ff746eb8 214 if ((PROTOCOL(ret) == GPSParser::NMEA) && (len > 6))
mazgch 4:90ab1ec64b0e 215 {
mazgch 27:fe3b383dd4ec 216 // talker is $GA=Galileo $GB=Beidou $GL=Glonass $GN=Combined $GP=GPS
mazgch 27:fe3b383dd4ec 217 if ((buf[0] == '$') || buf[1] == 'G') {
mazgch 27:fe3b383dd4ec 218 #define _CHECK_TALKER(s) ((buf[3] == s[0]) && (buf[4] == s[1]) && (buf[5] == s[2]))
mazgch 27:fe3b383dd4ec 219 if (_CHECK_TALKER("GLL")) {
mazgch 27:fe3b383dd4ec 220 double la = 0, lo = 0;
mazgch 27:fe3b383dd4ec 221 char ch;
mazgch 27:fe3b383dd4ec 222 if (gps.getNmeaAngle(1,buf,len,la) &&
mazgch 27:fe3b383dd4ec 223 gps.getNmeaAngle(3,buf,len,lo) &&
mazgch 27:fe3b383dd4ec 224 gps.getNmeaItem(6,buf,len,ch) && ch == 'A')
mazgch 27:fe3b383dd4ec 225 {
mazgch 27:fe3b383dd4ec 226 printf("GPS Location: %.5f %.5f\r\n", la, lo);
mazgch 27:fe3b383dd4ec 227 sprintf(link, "I am here!\n"
mazgch 27:fe3b383dd4ec 228 "https://maps.google.com/?q=%.5f,%.5f", la, lo);
mazgch 27:fe3b383dd4ec 229 }
mazgch 27:fe3b383dd4ec 230 } else if (_CHECK_TALKER("GGA") || _CHECK_TALKER("GNS") ) {
mazgch 27:fe3b383dd4ec 231 double a = 0;
mazgch 27:fe3b383dd4ec 232 if (gps.getNmeaItem(9,buf,len,a)) // altitude msl [m]
mazgch 27:fe3b383dd4ec 233 printf("GPS Altitude: %.1f\r\n", a);
mazgch 27:fe3b383dd4ec 234 } else if (_CHECK_TALKER("VTG")) {
mazgch 27:fe3b383dd4ec 235 double s = 0;
mazgch 27:fe3b383dd4ec 236 if (gps.getNmeaItem(7,buf,len,s)) // speed [km/h]
mazgch 27:fe3b383dd4ec 237 printf("GPS Speed: %.1f\r\n", s);
mazgch 19:f022ff746eb8 238 }
mazgch 4:90ab1ec64b0e 239 }
mazgch 4:90ab1ec64b0e 240 }
mazgch 10:d2da2028a233 241 }
msinig 29:16f1037626e3 242 #endif
msinig 29:16f1037626e3 243 #ifdef CELLOCATE
msinig 29:16f1037626e3 244 if (mdmOk && (j++ == submitPeriod * 1000/wait)) {
msinig 29:16f1037626e3 245 j=0;
msinig 29:16f1037626e3 246 printf("CellLocate Request\r\n");
msinig 29:16f1037626e3 247 mdm.cellLocRequest(sensorMask, submitPeriod-timeoutMargin, targetAccuracy);
msinig 29:16f1037626e3 248 cellLocWait = true;
msinig 29:16f1037626e3 249 }
msinig 29:16f1037626e3 250 if (cellLocWait && mdm.cellLocGet(&loc)){
msinig 29:16f1037626e3 251 cellLocWait = false;
msinig 29:16f1037626e3 252 printf("CellLocate position received, sensor_used: %d, \r\n", loc.sensorUsed );
msinig 29:16f1037626e3 253 printf(" latitude: %0.5f, longitude: %0.5f, altitute: %d\r\n", loc.latitue, loc.longitude, loc.altitutude);
msinig 29:16f1037626e3 254 if (loc.sensorUsed == 1)
msinig 29:16f1037626e3 255 printf(" uncertainty: %d, speed: %d, direction: %d, vertical_acc: %d, satellite used: %d \r\n", loc.uncertainty,loc.speed,loc.direction,loc.verticalAcc,loc.svUsed);
msinig 29:16f1037626e3 256 if (loc.sensorUsed == 1 || loc.sensorUsed == 2)
msinig 29:16f1037626e3 257 sprintf(link, "I am here!\n"
msinig 29:16f1037626e3 258 "https://maps.google.com/?q=%.5f,%.5f", loc.latitue, loc.longitude);
msinig 29:16f1037626e3 259 }
msinig 29:16f1037626e3 260 if (cellLocWait && (j%100 == 0 ))
msinig 29:16f1037626e3 261 printf("Waiting for CellLocate...\r\n");
msinig 29:16f1037626e3 262 #endif
mazgch 19:f022ff746eb8 263 if (mdmOk && (i++ == 5000/wait)) {
mazgch 10:d2da2028a233 264 i = 0;
mazgch 10:d2da2028a233 265 // check the network status
mazgch 15:ea10b6cf8c85 266 if (mdm.checkNetStatus(&netStatus)) {
mazgch 19:f022ff746eb8 267 mdm.dumpNetStatus(&netStatus, fprintf, stdout);
mazgch 15:ea10b6cf8c85 268 }
mazgch 10:d2da2028a233 269
mazgch 10:d2da2028a233 270 // checking unread sms
mazgch 10:d2da2028a233 271 int ix[8];
mazgch 10:d2da2028a233 272 int n = mdm.smsList("REC UNREAD", ix, 8);
mazgch 10:d2da2028a233 273 if (8 < n) n = 8;
mazgch 10:d2da2028a233 274 while (0 < n--)
mazgch 10:d2da2028a233 275 {
mazgch 10:d2da2028a233 276 char num[32];
mazgch 19:f022ff746eb8 277 printf("Unread SMS at index %d\r\n", ix[n]);
mazgch 10:d2da2028a233 278 if (mdm.smsRead(ix[n], num, buf, sizeof(buf))) {
mazgch 19:f022ff746eb8 279 printf("Got SMS from \"%s\" with text \"%s\"\r\n", num, buf);
mazgch 19:f022ff746eb8 280 printf("Delete SMS at index %d\r\n", ix[n]);
mazgch 10:d2da2028a233 281 mdm.smsDelete(ix[n]);
mazgch 10:d2da2028a233 282 // provide a reply
mazgch 10:d2da2028a233 283 const char* reply = "Hello my friend";
mazgch 10:d2da2028a233 284 if (strstr(buf, /*w*/"here are you"))
mazgch 10:d2da2028a233 285 reply = *link ? link : "I don't know"; // reply wil location link
mazgch 19:f022ff746eb8 286 else if (strstr(buf, /*s*/"hutdown"))
mazgch 19:f022ff746eb8 287 abort = true, reply = "bye bye";
mazgch 19:f022ff746eb8 288 printf("Send SMS reply \"%s\" to \"%s\"\r\n", reply, num);
mazgch 10:d2da2028a233 289 mdm.smsSend(num, reply);
mazgch 4:90ab1ec64b0e 290 }
mazgch 4:90ab1ec64b0e 291 }
mazgch 9:26f694bc31b4 292 }
mazgch 31:a07d0f76dc81 293 #ifdef RTOS_H
mazgch 31:a07d0f76dc81 294 Thread::wait(wait);
mazgch 31:a07d0f76dc81 295 #else
mazgch 31:a07d0f76dc81 296 ::wait_ms(wait);
mazgch 31:a07d0f76dc81 297 #endif
lawliet 0:4e3cb26f6019 298 }
mazgch 19:f022ff746eb8 299 gps.powerOff();
mazgch 10:d2da2028a233 300 mdm.powerOff();
lawliet 0:4e3cb26f6019 301 return 0;
lawliet 0:4e3cb26f6019 302 }