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: C027_Support mbed-dev
Fork of C027_SupportTest_coapp by
Diff: main.cpp
- Revision:
- 29:16f1037626e3
- Parent:
- 28:334263983fcd
- Child:
- 31:a07d0f76dc81
diff -r 334263983fcd -r 16f1037626e3 main.cpp
--- a/main.cpp Fri Dec 12 07:54:19 2014 +0000
+++ b/main.cpp Wed Nov 18 16:07:01 2015 +0000
@@ -31,6 +31,8 @@
#define PASSWORD NULL
//------------------------------------------------------------------------------------
+//#define CELLOCATE
+
int main(void)
{
int ret;
@@ -184,9 +186,25 @@
unsigned int i = 0xFFFFFFFF;
const int wait = 100;
bool abort = false;
+#ifdef CELLOCATE
+ const int sensorMask = 3; // Hybrid: GNSS + CellLocate
+ const int timeoutMargin = 5; // seconds
+ const int submitPeriod = 60; // 1 minutes in seconds
+ const int targetAccuracy = 1; // meters
+ unsigned int j = submitPeriod * 1000/wait;
+ bool cellLocWait = false;
+ MDMParser::CellLocData loc;
+
+ //Token can be released from u-blox site, when you got one replace "TOKEN" below
+ if (!mdm.cellLocSrvHttp("TOKEN"))
+ mdm.cellLocSrvUdp();
+ mdm.cellLocConfigSensor(1); // Deep scan mode
+ //mdm.cellUnsolIndication(1);
+#endif
//DigitalOut led(LED1);
while (!abort) {
// led = !led;
+#ifndef CELLOCATE
while ((ret = gps.getMessage(buf, sizeof(buf))) > 0)
{
int len = LENGTH(ret);
@@ -219,6 +237,27 @@
}
}
}
+#endif
+#ifdef CELLOCATE
+ if (mdmOk && (j++ == submitPeriod * 1000/wait)) {
+ j=0;
+ printf("CellLocate Request\r\n");
+ mdm.cellLocRequest(sensorMask, submitPeriod-timeoutMargin, targetAccuracy);
+ cellLocWait = true;
+ }
+ if (cellLocWait && mdm.cellLocGet(&loc)){
+ cellLocWait = false;
+ printf("CellLocate position received, sensor_used: %d, \r\n", loc.sensorUsed );
+ printf(" latitude: %0.5f, longitude: %0.5f, altitute: %d\r\n", loc.latitue, loc.longitude, loc.altitutude);
+ if (loc.sensorUsed == 1)
+ 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);
+ if (loc.sensorUsed == 1 || loc.sensorUsed == 2)
+ sprintf(link, "I am here!\n"
+ "https://maps.google.com/?q=%.5f,%.5f", loc.latitue, loc.longitude);
+ }
+ if (cellLocWait && (j%100 == 0 ))
+ printf("Waiting for CellLocate...\r\n");
+#endif
if (mdmOk && (i++ == 5000/wait)) {
i = 0;
// check the network status
