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 C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed
Fork of MbedSmartRestMain by
Diff: measurement/LocationUpdate.cpp
- Revision:
- 77:f6717e4eccc4
- Parent:
- 76:b07effe83fb8
- Child:
- 82:ca7430f50b2b
--- a/measurement/LocationUpdate.cpp Wed Feb 25 10:06:11 2015 +0000
+++ b/measurement/LocationUpdate.cpp Tue Mar 03 14:10:09 2015 +0000
@@ -48,26 +48,31 @@
bool LocationUpdate::run()
{
- GPSTracker::Position position;
-
+ GPSTracker::Position position;
if (!_gpsTracker.position(&position)) {
aError("No GPS data available.\r\n");
return false;
}
+ static char tenant[25];
+ static bool firstTime = true;
+ if (firstTime) {
+ firstTime = false;
+ const char* user= _bootstrap.username();
+ int len = strchr(user, '/')-user+1+8; // 8: length of "Tenant: "
+ len = len <= 25 ? len : 25;
+ snprintf(tenant, len, "Tenant: %s", user);
+ }
float data[3] = { 0.0, 0.0, 0.0 };
data[0] = position.altitude;
data[1] = position.latitude;
data[2] = position.longitude;
- char tenant[25] = {0};
- const char* user= _bootstrap.username();
- int len = strchr(user, '/')-user+1+8; // 8: length of "Tenant: ";
- len = len <= 25 ? len : 25;
- snprintf(tenant, len, "Tenant: %s", user);
+ DeviceInfo::SignalQuality *p = _deviceInfo.signalQuality(false);
char signal[25] = {0};
- if (_deviceInfo.signalQuality())
- snprintf(signal, 25, "Network: %d dBm", _deviceInfo.signalQuality()->rssi);
+ if (p && p->rssi)
+ snprintf(signal, sizeof(signal), "Network: %d dBm", p->rssi);
else
- strncpy(signal, "Network: ? dBm", 25);
+ strncpy(signal, "Network: no coverage", sizeof(signal));
+
if (abs(oldValues[0]-data[0]) <= abs(oldValues[0])*THRESHOLD_PERCENT_LOC &&
abs(oldValues[1]-data[1]) <= abs(oldValues[1])*THRESHOLD_PERCENT_LOC &&
abs(oldValues[2]-data[2]) <= abs(oldValues[2])*THRESHOLD_PERCENT_LOC) {
@@ -76,7 +81,7 @@
aDebug("Similar location readings found, no sending!\r\n");
return true;
} else {
- aDebug("Sending timer of location sensor timed out at %f s, a sending is forced.\r\n", sendingTimer.read());
+ aDebug("Location sensor timed out at %f s, a sending is forced.\r\n", sendingTimer.read());
}
}
char status[27] = {0};

Cumulocity