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.
Dependencies: ublox-cellular-driver-gen gnss ublox-cellular-base ublox-at-cellular-interface-ext
main.cpp@9:da9695394d5f, 2017-06-13 (annotated)
- Committer:
 - rob.meades@u-blox.com
 - Date:
 - Tue Jun 13 01:07:12 2017 +0100
 - Revision:
 - 9:da9695394d5f
 - Parent:
 - 8:11be5eb33196
 - Child:
 - 12:1e1c58088143
 
Update library version
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| rob.meades@u-blox.com | 1:628f51c3511f | 1 | /* mbed Microcontroller Library | 
| rob.meades@u-blox.com | 1:628f51c3511f | 2 | * Copyright (c) 2017 u-blox | 
| rob.meades@u-blox.com | 1:628f51c3511f | 3 | * | 
| rob.meades@u-blox.com | 1:628f51c3511f | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 5 | * you may not use this file except in compliance with the License. | 
| rob.meades@u-blox.com | 1:628f51c3511f | 6 | * You may obtain a copy of the License at | 
| rob.meades@u-blox.com | 1:628f51c3511f | 7 | * | 
| rob.meades@u-blox.com | 1:628f51c3511f | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | 
| rob.meades@u-blox.com | 1:628f51c3511f | 9 | * | 
| rob.meades@u-blox.com | 1:628f51c3511f | 10 | * Unless required by applicable law or agreed to in writing, software | 
| rob.meades@u-blox.com | 1:628f51c3511f | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | 
| rob.meades@u-blox.com | 1:628f51c3511f | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
| rob.meades@u-blox.com | 1:628f51c3511f | 13 | * See the License for the specific language governing permissions and | 
| rob.meades@u-blox.com | 1:628f51c3511f | 14 | * limitations under the License. | 
| rob.meades@u-blox.com | 1:628f51c3511f | 15 | */ | 
| rob.meades@u-blox.com | 1:628f51c3511f | 16 | |
| rob.meades@u-blox.com | 1:628f51c3511f | 17 | #include "mbed.h" | 
| rob.meades@u-blox.com | 1:628f51c3511f | 18 | #include "UbloxATCellularInterfaceExt.h" | 
| rob.meades@u-blox.com | 1:628f51c3511f | 19 | #include "gnss.h" | 
| rob.meades@u-blox.com | 1:628f51c3511f | 20 | |
| rob.meades@u-blox.com | 1:628f51c3511f | 21 | // The credentials of the SIM in the board. If PIN checking is enabled | 
| rob.meades@u-blox.com | 1:628f51c3511f | 22 | // for your SIM card you must set this to the required PIN. | 
| rob.meades@u-blox.com | 1:628f51c3511f | 23 | #define PIN "0000" | 
| rob.meades@u-blox.com | 1:628f51c3511f | 24 | |
| rob.meades@u-blox.com | 1:628f51c3511f | 25 | // Network credentials. You should set this according to your | 
| rob.meades@u-blox.com | 1:628f51c3511f | 26 | // network/SIM card. For C030 boards, leave the parameters as NULL | 
| rob.meades@u-blox.com | 1:628f51c3511f | 27 | // otherwise, if you do not know the APN for your network, you may | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 28 | // either try the fairly common "internet" for the APN (and leave the | 
| rob.meades@u-blox.com | 1:628f51c3511f | 29 | // username and password NULL), or you may leave all three as NULL and then | 
| rob.meades@u-blox.com | 1:628f51c3511f | 30 | // a lookup will be attempted for a small number of known networks | 
| rob.meades@u-blox.com | 1:628f51c3511f | 31 | // (see APN_db.h in mbed-os/features/netsocket/cellular/utils). | 
| rob.meades@u-blox.com | 1:628f51c3511f | 32 | #define APN NULL | 
| rob.meades@u-blox.com | 1:628f51c3511f | 33 | #define USERNAME NULL | 
| rob.meades@u-blox.com | 1:628f51c3511f | 34 | #define PASSWORD NULL | 
| rob.meades@u-blox.com | 1:628f51c3511f | 35 | |
| rob.meades@u-blox.com | 1:628f51c3511f | 36 | // LEDs | 
| rob.meades@u-blox.com | 1:628f51c3511f | 37 | DigitalOut ledRed(LED1, 1); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 38 | DigitalOut ledGreen(LED2, 1); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 39 | DigitalOut ledBlue(LED3, 1); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 40 | |
| rob.meades@u-blox.com | 4:13a84f6cc800 | 41 | // The user button | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 42 | volatile bool buttonPressed = false; | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 43 | |
| rob.meades@u-blox.com | 4:13a84f6cc800 | 44 | static void good() { | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 45 | ledGreen = 0; | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 46 | ledBlue = 1; | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 47 | ledRed = 1; | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 48 | } | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 49 | |
| rob.meades@u-blox.com | 4:13a84f6cc800 | 50 | static void bad() { | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 51 | ledRed = 0; | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 52 | ledGreen = 1; | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 53 | ledBlue = 1; | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 54 | } | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 55 | |
| rob.meades@u-blox.com | 4:13a84f6cc800 | 56 | static void event() { | 
| rob.meades@u-blox.com | 1:628f51c3511f | 57 | ledBlue = 0; | 
| rob.meades@u-blox.com | 1:628f51c3511f | 58 | ledRed = 1; | 
| rob.meades@u-blox.com | 1:628f51c3511f | 59 | ledGreen = 1; | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 60 | } | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 61 | |
| rob.meades@u-blox.com | 4:13a84f6cc800 | 62 | static void pulseEvent() { | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 63 | event(); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 64 | wait_ms(500); | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 65 | good(); | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 66 | } | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 67 | |
| rob.meades@u-blox.com | 4:13a84f6cc800 | 68 | static void ledOff() { | 
| rob.meades@u-blox.com | 1:628f51c3511f | 69 | ledBlue = 1; | 
| rob.meades@u-blox.com | 1:628f51c3511f | 70 | ledRed = 1; | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 71 | ledGreen = 1; | 
| rob.meades@u-blox.com | 1:628f51c3511f | 72 | } | 
| rob.meades@u-blox.com | 1:628f51c3511f | 73 | |
| rob.meades@u-blox.com | 1:628f51c3511f | 74 | static void printCellLocateData(UbloxATCellularInterfaceExt::CellLocData *pData) | 
| rob.meades@u-blox.com | 1:628f51c3511f | 75 | { | 
| rob.meades@u-blox.com | 1:628f51c3511f | 76 | char timeString[25]; | 
| rob.meades@u-blox.com | 1:628f51c3511f | 77 | |
| rob.meades@u-blox.com | 1:628f51c3511f | 78 | printf("Cell Locate data:\n"); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 79 | if (strftime(timeString, sizeof(timeString), "%F %T", (const tm *) &(pData->time)) > 0) { | 
| rob.meades@u-blox.com | 1:628f51c3511f | 80 | printf(" time: %s\n", timeString); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 81 | } | 
| rob.meades@u-blox.com | 1:628f51c3511f | 82 | printf(" longitude: %.6f\n", pData->longitude); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 83 | printf(" latitude: %.6f\n", pData->latitude); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 84 | printf(" altitude: %d metre(s)\n", pData->altitude); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 85 | switch (pData->sensor) { | 
| rob.meades@u-blox.com | 1:628f51c3511f | 86 | case UbloxATCellularInterfaceExt::CELL_LAST: | 
| rob.meades@u-blox.com | 1:628f51c3511f | 87 | printf(" sensor type: last\n"); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 88 | break; | 
| rob.meades@u-blox.com | 1:628f51c3511f | 89 | case UbloxATCellularInterfaceExt::CELL_GNSS: | 
| rob.meades@u-blox.com | 1:628f51c3511f | 90 | printf(" sensor type: GNSS\n"); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 91 | break; | 
| rob.meades@u-blox.com | 1:628f51c3511f | 92 | case UbloxATCellularInterfaceExt::CELL_LOCATE: | 
| rob.meades@u-blox.com | 1:628f51c3511f | 93 | printf(" sensor type: Cell Locate\n"); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 94 | break; | 
| rob.meades@u-blox.com | 1:628f51c3511f | 95 | case UbloxATCellularInterfaceExt::CELL_HYBRID: | 
| rob.meades@u-blox.com | 1:628f51c3511f | 96 | printf(" sensor type: hybrid\n"); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 97 | break; | 
| rob.meades@u-blox.com | 1:628f51c3511f | 98 | default: | 
| rob.meades@u-blox.com | 1:628f51c3511f | 99 | printf(" sensor type: unknown\n"); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 100 | break; | 
| rob.meades@u-blox.com | 1:628f51c3511f | 101 | } | 
| rob.meades@u-blox.com | 1:628f51c3511f | 102 | printf(" uncertainty: %d metre(s)\n", pData->uncertainty); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 103 | printf(" speed: %d metre(s)/second\n", pData->speed); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 104 | printf(" direction: %d degree(s)\n", pData->direction); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 105 | printf(" vertical accuracy: %d metre(s)/second\n", pData->speed); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 106 | printf(" satellite(s) used: %d\n", pData->svUsed); | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 107 | printf("I am here: " | 
| rob.meades@u-blox.com | 1:628f51c3511f | 108 | "https://maps.google.com/?q=%.5f,%.5f\n", pData->latitude, pData->longitude); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 109 | } | 
| rob.meades@u-blox.com | 1:628f51c3511f | 110 | |
| rob.meades@u-blox.com | 4:13a84f6cc800 | 111 | static void cbButton() | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 112 | { | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 113 | buttonPressed = true; | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 114 | pulseEvent(); | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 115 | } | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 116 | |
| rob.meades@u-blox.com | 1:628f51c3511f | 117 | /* This example program for the u-blox C030 and C027 boards instantiates | 
| RobMeades | 5:540b2d19fc5c | 118 | * the UbloxAtCellularInterfaceExt to do FTP, HTTP and CellLocate operations. | 
| RobMeades | 5:540b2d19fc5c | 119 | * It uses the site test.rebex.net for FTP testing and the site | 
| RobMeades | 5:540b2d19fc5c | 120 | * developer.mbed.org for HTTP GET testing. | 
| rob.meades@u-blox.com | 1:628f51c3511f | 121 | * Progress may be monitored with a serial terminal running at 9600 baud. | 
| rob.meades@u-blox.com | 1:628f51c3511f | 122 | * The LED on the C030 board will turn green when this program is | 
| rob.meades@u-blox.com | 1:628f51c3511f | 123 | * operating correctly, pulse blue when an FTP get, HTTP get or CellLocate | 
| rob.meades@u-blox.com | 1:628f51c3511f | 124 | * operation is completed and turn red if there is a failure. | 
| rob.meades@u-blox.com | 1:628f51c3511f | 125 | */ | 
| rob.meades@u-blox.com | 1:628f51c3511f | 126 | |
| rob.meades@u-blox.com | 1:628f51c3511f | 127 | int main() | 
| rob.meades@u-blox.com | 1:628f51c3511f | 128 | { | 
| rob.meades@u-blox.com | 9:da9695394d5f | 129 | UbloxATCellularInterfaceExt *interface = new UbloxATCellularInterfaceExt(); | 
| rob.meades@u-blox.com | 8:11be5eb33196 | 130 | // If you need to debug the cellular interface, comment out the | 
| rob.meades@u-blox.com | 8:11be5eb33196 | 131 | // instantiation above and uncomment the one below. | 
| rob.meades@u-blox.com | 9:da9695394d5f | 132 | // UbloxATCellularInterfaceExt *interface = new UbloxATCellularInterfaceExt(MDMTXD, MDMRXD, | 
| rob.meades@u-blox.com | 9:da9695394d5f | 133 | // MBED_CONF_UBLOX_CELL_BAUD_RATE, | 
| rob.meades@u-blox.com | 9:da9695394d5f | 134 | // true); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 135 | UbloxATCellularInterfaceExt::Error *err; | 
| rob.meades@u-blox.com | 1:628f51c3511f | 136 | UbloxATCellularInterfaceExt::CellLocData data; | 
| rob.meades@u-blox.com | 1:628f51c3511f | 137 | char buf[1024]; | 
| rob.meades@u-blox.com | 1:628f51c3511f | 138 | int httpProfile; | 
| rob.meades@u-blox.com | 1:628f51c3511f | 139 | int numRes; | 
| RobMeades | 5:540b2d19fc5c | 140 | GnssSerial gnssSerial; // This needed purely to power on the GNSS chip in | 
| RobMeades | 5:540b2d19fc5c | 141 | // order that Cell Locate on the module can use it | 
| rob.meades@u-blox.com | 8:11be5eb33196 | 142 | #ifdef TARGET_UBLOX_C027 | 
| rob.meades@u-blox.com | 8:11be5eb33196 | 143 | // No user button on C027 | 
| rob.meades@u-blox.com | 8:11be5eb33196 | 144 | InterruptIn userButton(NC); | 
| rob.meades@u-blox.com | 8:11be5eb33196 | 145 | #else | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 146 | InterruptIn userButton(SW0); | 
| rob.meades@u-blox.com | 8:11be5eb33196 | 147 | #endif | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 148 | |
| rob.meades@u-blox.com | 4:13a84f6cc800 | 149 | // Attach a function to the user button | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 150 | userButton.rise(&cbButton); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 151 | |
| RobMeades | 7:7781212f4bb4 | 152 | // Power up GNSS to assist with the Cell Locate bit | 
| rob.meades@u-blox.com | 1:628f51c3511f | 153 | gnssSerial.init(); | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 154 | good(); | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 155 | printf("Starting up, please wait up to 180 seconds for network registration to complete...\n"); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 156 | if (interface->init(PIN)) { | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 157 | pulseEvent(); | 
| RobMeades | 6:7a33376899e5 | 158 | interface->set_credentials(APN, USERNAME, PASSWORD); | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 159 | printf("Registered, connecting to the packet network...\n"); | 
| RobMeades | 6:7a33376899e5 | 160 | for (int x = 0; interface->connect() != 0; x++) { | 
| rob.meades@u-blox.com | 1:628f51c3511f | 161 | if (x > 0) { | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 162 | bad(); | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 163 | printf("Retrying (have you checked that an antenna is plugged in and your APN is correct?)...\n"); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 164 | } | 
| rob.meades@u-blox.com | 1:628f51c3511f | 165 | } | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 166 | pulseEvent(); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 167 | |
| rob.meades@u-blox.com | 1:628f51c3511f | 168 | // FTP OPERATIONS | 
| rob.meades@u-blox.com | 1:628f51c3511f | 169 | // Reset FTP parameters to default then set things up | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 170 | printf("=== FTP ===\n"); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 171 | interface->ftpResetPar(); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 172 | interface->ftpSetTimeout(60000); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 173 | interface->ftpSetPar(UbloxATCellularInterfaceExt::FTP_SERVER_NAME, "test.rebex.net"); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 174 | interface->ftpSetPar(UbloxATCellularInterfaceExt::FTP_USER_NAME, "demo"); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 175 | interface->ftpSetPar(UbloxATCellularInterfaceExt::FTP_PASSWORD, "password"); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 176 | interface->ftpSetPar(UbloxATCellularInterfaceExt::FTP_MODE, "1"); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 177 | |
| rob.meades@u-blox.com | 1:628f51c3511f | 178 | // Log into the FTP server | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 179 | printf("Logging into FTP server \"test.rebex.net\"...\n"); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 180 | err = interface->ftpCommand(UbloxATCellularInterfaceExt::FTP_LOGIN); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 181 | if (err == NULL) { | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 182 | pulseEvent(); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 183 | // Get a directory listing from the server | 
| rob.meades@u-blox.com | 1:628f51c3511f | 184 | if (interface->ftpCommand(UbloxATCellularInterfaceExt::FTP_LS, | 
| rob.meades@u-blox.com | 1:628f51c3511f | 185 | NULL, NULL, 0, buf, sizeof (buf)) == NULL) { | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 186 | pulseEvent(); | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 187 | printf ("Directory listing of FTP server:\n" | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 188 | "--------------------------------\n%s" | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 189 | "--------------------------------\n", buf); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 190 | } | 
| rob.meades@u-blox.com | 1:628f51c3511f | 191 | // FTP GET a file known to be on test.rebex.net into the module file system | 
| rob.meades@u-blox.com | 1:628f51c3511f | 192 | if (interface->ftpCommand(UbloxATCellularInterfaceExt::FTP_GET_FILE, "readme.txt") == NULL) { | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 193 | pulseEvent(); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 194 | // Read the file from the module file system into buf | 
| rob.meades@u-blox.com | 1:628f51c3511f | 195 | if (interface->readFile("readme.txt", buf, sizeof (buf))) { | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 196 | printf("FTP GET of file \"readme.txt\" completed. The file contained:\n" | 
| RobMeades | 7:7781212f4bb4 | 197 | "------------------------------------------------------------\n%s" | 
| RobMeades | 7:7781212f4bb4 | 198 | "------------------------------------------------------------\n", buf); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 199 | } | 
| rob.meades@u-blox.com | 1:628f51c3511f | 200 | } | 
| rob.meades@u-blox.com | 1:628f51c3511f | 201 | } else { | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 202 | bad(); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 203 | printf ("Unable to log in, error class %d, error code %d.\n", err->eClass, err->eCode); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 204 | } | 
| rob.meades@u-blox.com | 1:628f51c3511f | 205 | |
| rob.meades@u-blox.com | 1:628f51c3511f | 206 | // HTTP OPERATIONS | 
| rob.meades@u-blox.com | 1:628f51c3511f | 207 | // Set up HTTP parameters | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 208 | printf("=== HTTP ===\n"); | 
| RobMeades | 5:540b2d19fc5c | 209 | printf("Performing HTTP GET on \"developer.mbed.org\"...\n"); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 210 | httpProfile = interface->httpAllocProfile(); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 211 | interface->httpSetTimeout(httpProfile, 30000); | 
| RobMeades | 5:540b2d19fc5c | 212 | interface->httpSetPar(httpProfile, UbloxATCellularInterfaceExt::HTTP_SERVER_NAME, "developer.mbed.org"); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 213 | |
| rob.meades@u-blox.com | 1:628f51c3511f | 214 | // Do the HTTP command | 
| rob.meades@u-blox.com | 1:628f51c3511f | 215 | err = interface->httpCommand(httpProfile, UbloxATCellularInterfaceExt::HTTP_GET, | 
| rob.meades@u-blox.com | 1:628f51c3511f | 216 | "/media/uploads/mbed_official/hello.txt", | 
| rob.meades@u-blox.com | 1:628f51c3511f | 217 | NULL, NULL, 0, NULL, | 
| rob.meades@u-blox.com | 1:628f51c3511f | 218 | buf, sizeof (buf)); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 219 | if (err == NULL) { | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 220 | pulseEvent(); | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 221 | printf("HTTP GET of \"/media/uploads/mbed_official/hello.txt\" completed. The response contained:\n" | 
| RobMeades | 7:7781212f4bb4 | 222 | "----------------------------------------------------------------------------------------\n%s" | 
| RobMeades | 7:7781212f4bb4 | 223 | "----------------------------------------------------------------------------------------\n", buf); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 224 | } else { | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 225 | bad(); | 
| RobMeades | 5:540b2d19fc5c | 226 | printf("Unable to get \"/media/uploads/mbed_official/hello.txt\" from \"developer.mbed.org\", " | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 227 | "error class %d, error code %d.\n", err->eClass, err->eCode); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 228 | } | 
| rob.meades@u-blox.com | 1:628f51c3511f | 229 | |
| rob.meades@u-blox.com | 1:628f51c3511f | 230 | // CELL LOCATE OPERATIONS (in a loop) | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 231 | printf("=== Cell Locate ===\n"); | 
| rob.meades@u-blox.com | 8:11be5eb33196 | 232 | printf("Sending Cell Locate requests in a loop (until the user button is pressed on C030 or forever on C027)...\n"); | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 233 | while (!buttonPressed) { | 
| rob.meades@u-blox.com | 1:628f51c3511f | 234 | interface->cellLocSrvUdp(); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 235 | interface->cellLocConfig(1); // Deep scan mode | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 236 | printf("Sending Cell Locate request...\n"); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 237 | if (interface->cellLocRequest(UbloxATCellularInterfaceExt::CELL_HYBRID, 10, 100, | 
| rob.meades@u-blox.com | 1:628f51c3511f | 238 | (UbloxATCellularInterfaceExt::CellRespType) 1, 1)) { | 
| rob.meades@u-blox.com | 1:628f51c3511f | 239 | // Wait for the response | 
| rob.meades@u-blox.com | 1:628f51c3511f | 240 | numRes = 0; | 
| rob.meades@u-blox.com | 1:628f51c3511f | 241 | for (int x = 0; (numRes == 0) && (x < 10); x++) { | 
| rob.meades@u-blox.com | 1:628f51c3511f | 242 | numRes = interface->cellLocGetRes(); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 243 | } | 
| rob.meades@u-blox.com | 1:628f51c3511f | 244 | |
| rob.meades@u-blox.com | 1:628f51c3511f | 245 | if (numRes > 0) { | 
| rob.meades@u-blox.com | 1:628f51c3511f | 246 | interface->cellLocGetData(&data); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 247 | if (data.validData) { | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 248 | pulseEvent(); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 249 | printCellLocateData(&data); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 250 | } | 
| rob.meades@u-blox.com | 1:628f51c3511f | 251 | } else { | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 252 | bad(); | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 253 | printf("No response from Cell Locate server.\n"); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 254 | } | 
| rob.meades@u-blox.com | 1:628f51c3511f | 255 | } | 
| rob.meades@u-blox.com | 1:628f51c3511f | 256 | wait_ms(5000); | 
| RobMeades | 6:7a33376899e5 | 257 | printf("[Checking if user button has been pressed]\n"); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 258 | } | 
| rob.meades@u-blox.com | 1:628f51c3511f | 259 | |
| rob.meades@u-blox.com | 4:13a84f6cc800 | 260 | pulseEvent(); | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 261 | printf("User button was pressed, stopping...\n"); | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 262 | gnssSerial.powerOff(); | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 263 | interface->disconnect(); | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 264 | interface->deinit(); | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 265 | ledOff(); | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 266 | printf("Stopped.\n"); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 267 | } else { | 
| rob.meades@u-blox.com | 4:13a84f6cc800 | 268 | bad(); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 269 | printf("Unable to initialise the interface.\n"); | 
| rob.meades@u-blox.com | 1:628f51c3511f | 270 | } | 
| rob.meades@u-blox.com | 1:628f51c3511f | 271 | } | 
| rob.meades@u-blox.com | 1:628f51c3511f | 272 | |
| rob.meades@u-blox.com | 1:628f51c3511f | 273 | // End Of File |