Example program for the UbloxCellularDriverGen class, providing SMS, USSD and module file system support. This program may be used on the C027 and C030 (non N2xx-flavour) boards.
Dependencies: ublox-cellular-driver-gen ublox-cellular-base
main.cpp@13:4d0483c50f30, 2017-08-11 (annotated)
- Committer:
- rob.meades@u-blox.com
- Date:
- Fri Aug 11 14:56:32 2017 +0100
- Revision:
- 13:4d0483c50f30
- Parent:
- 7:414c52e89560
Update ublox-cellular-base library version.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rob.meades@u-blox.com | 1:ecc6c175bd7c | 1 | /* mbed Microcontroller Library |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 2 | * Copyright (c) 2017 u-blox |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 3 | * |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 5 | * you may not use this file except in compliance with the License. |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 6 | * You may obtain a copy of the License at |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 7 | * |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 9 | * |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 10 | * Unless required by applicable law or agreed to in writing, software |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 13 | * See the License for the specific language governing permissions and |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 14 | * limitations under the License. |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 15 | */ |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 16 | |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 17 | #include "mbed.h" |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 18 | #include "UbloxCellularDriverGen.h" |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 19 | |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 20 | // The credentials of the SIM in the board. If PIN checking is enabled |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 21 | // for your SIM card you must set this to the required PIN. |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 22 | #define PIN "0000" |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 23 | |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 24 | // Network credentials. You should set this according to your |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 25 | // network/SIM card. For C030 boards, leave the parameters as NULL |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 26 | // otherwise, if you do not know the APN for your network, you may |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 27 | // either try the fairly common "internet" for the APN (and leave the |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 28 | // username and password NULL), or you may leave all three as NULL and then |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 29 | // a lookup will be attempted for a small number of known networks |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 30 | // (see APN_db.h in mbed-os/features/netsocket/cellular/utils). |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 31 | #define APN NULL |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 32 | #define USERNAME NULL |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 33 | #define PASSWORD NULL |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 34 | |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 35 | // If you wish, you may add a mobile phone number here, e.g. |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 36 | // #define DESTINATION_SMS_NUMBER "+441234567901" |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 37 | // Note: no spaces are allowed. |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 38 | // If you do so this program will send a text message to that |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 39 | // number and then wait for a reply |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 40 | #define DESTINATION_SMS_NUMBER "" |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 41 | |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 42 | // LEDs |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 43 | DigitalOut ledRed(LED1, 1); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 44 | DigitalOut ledGreen(LED2, 1); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 45 | DigitalOut ledBlue(LED3, 1); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 46 | |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 47 | // The user button |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 48 | volatile bool buttonPressed = false; |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 49 | |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 50 | static void good() { |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 51 | ledGreen = 0; |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 52 | ledBlue = 1; |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 53 | ledRed = 1; |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 54 | } |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 55 | |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 56 | static void bad() { |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 57 | ledRed = 0; |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 58 | ledGreen = 1; |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 59 | ledBlue = 1; |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 60 | } |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 61 | |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 62 | static void event() { |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 63 | ledBlue = 0; |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 64 | ledRed = 1; |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 65 | ledGreen = 1; |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 66 | } |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 67 | |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 68 | static void pulseEvent() { |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 69 | event(); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 70 | wait_ms(500); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 71 | good(); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 72 | } |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 73 | |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 74 | static void ledOff() { |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 75 | ledBlue = 1; |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 76 | ledRed = 1; |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 77 | ledGreen = 1; |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 78 | } |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 79 | |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 80 | // See section 12.1 of the u-blox-ATCommands_Manual_(UBX-13002752).pdf |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 81 | static void printCallForwardingResponse(char * buf) |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 82 | { |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 83 | int numValues, a, b; |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 84 | char number[32]; |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 85 | |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 86 | numValues = sscanf(buf, "+CCFC: %d,%d,\"%32[^\"][\"]", &a, &b, number); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 87 | if (numValues > 0) { |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 88 | if (a > 0) { |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 89 | printf("Calling Forwarding is active"); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 90 | } else { |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 91 | printf("Calling Forwarding is not active"); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 92 | } |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 93 | if (numValues > 1) { |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 94 | if (b > 0) { |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 95 | if (b & 0x01) { |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 96 | printf(" for voice"); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 97 | } |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 98 | if (b & 0x02) { |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 99 | printf(" for data"); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 100 | } |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 101 | if (b & 0x04) { |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 102 | printf(" for fax"); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 103 | } |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 104 | if (b & 0x08) { |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 105 | printf(" for SMS"); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 106 | } |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 107 | if (b & 0x10) { |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 108 | printf(" for data circuit sync"); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 109 | } |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 110 | if (b & 0x20) { |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 111 | printf(" for data circuit async"); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 112 | } |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 113 | if (b & 0x40) { |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 114 | printf(" for dedicated packet access"); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 115 | } |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 116 | if (b & 0x80) { |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 117 | printf(" for dedicated PAD access"); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 118 | } |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 119 | } |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 120 | } |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 121 | if (numValues > 2) { |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 122 | printf(" for %s.\n", number); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 123 | } else { |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 124 | printf(".\n"); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 125 | } |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 126 | } |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 127 | } |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 128 | |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 129 | static void cbButton() |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 130 | { |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 131 | buttonPressed = true; |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 132 | pulseEvent(); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 133 | } |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 134 | |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 135 | /* This example program for the u-blox C030 and C027 boards instantiates |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 136 | * the UbloxCellularDriverGen to do SMS, USSD and module file system operations. |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 137 | * Progress may be monitored with a serial terminal running at 9600 baud. |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 138 | * The LED on the C030 board will turn green when this program is |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 139 | * operating correctly, pulse blue when a USSD action is performed, |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 140 | * an SMS is sent or received or a file operation is completed, |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 141 | * and will turn red on a failure condition. |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 142 | */ |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 143 | |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 144 | int main() |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 145 | { |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 146 | UbloxCellularDriverGen *driver = new UbloxCellularDriverGen(); |
rob.meades@u-blox.com | 5:77134c30d863 | 147 | // If you need to debug the cellular driver, comment out the |
rob.meades@u-blox.com | 4:39208ab9cc04 | 148 | // instantiation above and uncomment the one below. |
rob.meades@u-blox.com | 4:39208ab9cc04 | 149 | // UbloxCellularDriverGen *driver = new UbloxCellularDriverGen(MDMTXD, MDMRXD, |
rob.meades@u-blox.com | 4:39208ab9cc04 | 150 | // MBED_CONF_UBLOX_CELL_BAUD_RATE, |
rob.meades@u-blox.com | 4:39208ab9cc04 | 151 | // true); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 152 | char buf[1024]; |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 153 | int x; |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 154 | int index[8]; |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 155 | char number[32]; |
rob.meades@u-blox.com | 5:77134c30d863 | 156 | #ifdef TARGET_UBLOX_C027 |
rob.meades@u-blox.com | 5:77134c30d863 | 157 | // No user button on C027 |
rob.meades@u-blox.com | 5:77134c30d863 | 158 | InterruptIn userButton(NC); |
rob.meades@u-blox.com | 5:77134c30d863 | 159 | #else |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 160 | InterruptIn userButton(SW0); |
rob.meades@u-blox.com | 5:77134c30d863 | 161 | #endif |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 162 | |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 163 | // Attach a function to the user button |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 164 | userButton.rise(&cbButton); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 165 | |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 166 | good(); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 167 | printf ("Starting up, please wait up to 180 seconds for network registration to complete...\n"); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 168 | if (driver->init(PIN)) { |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 169 | pulseEvent(); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 170 | |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 171 | // USSD OPERATIONS |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 172 | printf("=== USSD ===\n"); |
rob.meades@u-blox.com | 7:414c52e89560 | 173 | printf("Sending *100#...\n"); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 174 | if (driver->ussdCommand("*100#", buf, sizeof (buf))) { |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 175 | pulseEvent(); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 176 | printf("Answer was %s.\n", buf); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 177 | } |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 178 | printf("Getting the status of call forwarding...\n"); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 179 | if (driver->ussdCommand("*#21#", buf, sizeof (buf))) { |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 180 | pulseEvent(); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 181 | printf("Answer was \"%s\", which means:\n", buf); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 182 | printCallForwardingResponse(buf); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 183 | } |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 184 | |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 185 | // FILE SYSTEM OPERATIONS |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 186 | printf("=== Module File System ===\n"); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 187 | strcpy (buf, "Hello world!"); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 188 | x = strlen(buf); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 189 | printf("Writing \"%s\" (%d byte(s)) to file \"test.txt\" on the module's file system...\n", buf, x); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 190 | x = driver->writeFile("test.txt", buf, strlen(buf)); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 191 | printf("%d byte(s) written.\n", x); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 192 | if (x == (int) strlen(buf)) { |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 193 | pulseEvent(); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 194 | *buf = 0; |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 195 | printf("Reading the file back from the module's file system...\n"); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 196 | x = driver->readFile("test.txt", buf, sizeof(buf)); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 197 | printf("%d byte(s) read.\n", x); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 198 | if (x > 0) { |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 199 | pulseEvent(); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 200 | printf("File \"test.txt\" contained \"%s\".\n", buf); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 201 | } |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 202 | printf("Deleting the file...\n"); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 203 | if (driver->delFile("test.txt")) { |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 204 | pulseEvent(); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 205 | printf("File deleted.\n"); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 206 | } |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 207 | } |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 208 | |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 209 | // SMS OPERATIONS |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 210 | printf("=== SMS ===\n"); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 211 | if (strlen(DESTINATION_SMS_NUMBER) > 0) { |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 212 | printf("Sending a text message to %s...\n", DESTINATION_SMS_NUMBER); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 213 | if (driver->smsSend(DESTINATION_SMS_NUMBER, "This is your u-blox mbed board calling.")) { |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 214 | pulseEvent(); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 215 | printf("Text message sent.\n"); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 216 | } |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 217 | } else { |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 218 | printf("No destination SMS number has been defined (edit DESTINATION_SMS_NUMBER in this file to add one).\n"); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 219 | } |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 220 | |
rob.meades@u-blox.com | 7:414c52e89560 | 221 | printf("Waiting for SMS messages to arrive in a loop (until the user button is pressed on C030 or forever on C027)...\n"); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 222 | while (!buttonPressed) { |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 223 | x = driver->smsList("REC UNREAD", index, sizeof(index)); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 224 | for (int y = 0; y < x; y++) { |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 225 | *number = 0; |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 226 | if (driver->smsRead(index[y], number, buf, sizeof (buf))) { |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 227 | pulseEvent(); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 228 | printf("Received text message from %s: \"%s\"\n", number, buf); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 229 | printf("Replying...\n"); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 230 | if (driver->smsSend(number, "mbed board responding: hello there!")) { |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 231 | pulseEvent(); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 232 | printf("Reply sent.\n"); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 233 | } |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 234 | printf("Deleting text message from SIM...\n"); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 235 | if (driver->smsDelete(index[y])) { |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 236 | pulseEvent(); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 237 | printf("Message deleted.\n"); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 238 | } |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 239 | } |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 240 | } |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 241 | wait_ms(2500); |
rob.meades@u-blox.com | 5:77134c30d863 | 242 | #ifndef TARGET_UBLOX_C027 |
RobMeades | 3:26dc68582d21 | 243 | printf("[Checking if user button has been pressed]\n"); |
rob.meades@u-blox.com | 5:77134c30d863 | 244 | #endif |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 245 | } |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 246 | |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 247 | pulseEvent(); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 248 | printf("User button was pressed, stopping...\n"); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 249 | driver->deinit(); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 250 | ledOff(); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 251 | printf("Stopped.\n"); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 252 | } else { |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 253 | bad(); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 254 | printf("Unable to initialise the driver.\n"); |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 255 | } |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 256 | } |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 257 | |
rob.meades@u-blox.com | 1:ecc6c175bd7c | 258 | // End Of File |