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:
- 74:ca3001991fdc
- Parent:
- 73:313975bfec96
- Child:
- 76:b07effe83fb8
--- a/measurement/LocationUpdate.cpp Tue Feb 17 16:31:30 2015 +0000
+++ b/measurement/LocationUpdate.cpp Wed Feb 18 10:17:29 2015 +0000
@@ -52,22 +52,28 @@
if (!_gpsTracker.position(&position)) {
aError("No GPS data available.\r\n");
- return true;
+ return false;
}
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};
- snprintf(tenant, 25, "Tenant: %s", _bootstrap.username());
+ 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);
char signal[25] = {0};
- snprintf(signal, 25, "Network: %d dBm", _deviceInfo.signalQuality()->rssi);
+ if (_deviceInfo.signalQuality())
+ snprintf(signal, 25, "Network: %d dBm", _deviceInfo.signalQuality()->rssi);
+ else
+ strncpy(signal, "Network: ? dBm", 25);
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) {
if (sendingTimer.read() < TIME_LIMIT_LOC) {
+ _io.lcdPrint(tenant, signal);
aDebug("Similar location readings found, no sending!\r\n");
- _io.lcdPrint(tenant, signal);
return true;
} else {
aDebug("Sending timer of location sensor timed out at %f s, a sending is forced.\r\n", sendingTimer.read());
@@ -100,7 +106,7 @@
}
float t_end = sendingTimer.read();
_client.stop();
- aInfo("Acceleration readings sent in %.1f.\r\n", t_end-t_start);
+ aInfo("GPS readings sent in %.1f.\r\n", t_end-t_start);
oldValues[0] = data[0];
oldValues[1] = data[1];
oldValues[2] = data[2];

Cumulocity