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 C027_Support mbed mbed-rtos MbedSmartRest LM75B MMA7660 C12832
Fork of MbedSmartRestTest by
Diff: program.cpp
- Revision:
- 34:8a0556f39161
- Parent:
- 33:b7d7e6fc421e
diff -r b7d7e6fc421e -r 8a0556f39161 program.cpp
--- a/program.cpp Thu Jun 12 14:33:04 2014 +0000
+++ b/program.cpp Thu Jul 03 18:43:50 2014 +0000
@@ -224,7 +224,8 @@
lcd_status("Checking device existance...");
puts("Checking for device existance...");
- newMoRec.add(IntegerValue(100)).add(CharValue(imei()));
+ if ((!newMoRec.add(IntegerValue(100))) || (!newMoRec.add(CharValue(imei()))))
+ return 0;
if (client.send(newMoRec) != SMARTREST_SUCCESS) {
puts("Send failed.");
@@ -267,7 +268,8 @@
lcd_status("Creating device...");
puts("Creating device...");
- newMoRec.add(IntegerValue(101)).add(CharValue(imei()));
+ if ((!newMoRec.add(IntegerValue(101))) || (!newMoRec.add(CharValue(imei()))))
+ return 0;
if (client.send(newMoRec) != SMARTREST_SUCCESS) {
puts("Send failed.");
@@ -304,7 +306,8 @@
puts("Adding global identifier...");
- newMoRec.add(IntegerValue(102)).add(IntegerValue(deviceId)).add(CharValue(imei()));
+ if ((!newMoRec.add(IntegerValue(102))) || (!newMoRec.add(IntegerValue(deviceId))) || (!newMoRec.add(CharValue(imei()))))
+ return 0;
if (client.send(newMoRec) != SMARTREST_SUCCESS) {
puts("Sending failed.");
@@ -342,7 +345,8 @@
lcd_status("Updating device object...");
puts("Updating device data...");
- newMoRec.add(IntegerValue(103)).add(IntegerValue(deviceId)).add(CharValue(imei())).add(CharValue(cellId())).add(CharValue(iccid()));
+ if ((!newMoRec.add(IntegerValue(103))) || (!newMoRec.add(IntegerValue(deviceId))) || (!newMoRec.add(CharValue(imei()))) || (!newMoRec.add(CharValue(cellId()))) || (!newMoRec.add(CharValue(iccid()))))
+ return false;
if (client.send(newMoRec) != SMARTREST_SUCCESS) {
puts("Send failed.");
@@ -375,7 +379,7 @@
void loop(long deviceId)
{
- Aggregator aggr(8, false, true);
+ Aggregator aggr(true);
lcd_status("Sending measurements...");
temperatureMeasurement(deviceId, aggr);
@@ -401,7 +405,8 @@
IntegerValue devId(deviceId);
FloatValue rssi(sq->rssi, 0);
IntegerValue ber(sq->ber);
- measurement.add(msgId).add(devId).add(rssi).add(ber);
+ if ((!measurement.add(msgId)) || (!measurement.add(devId)) || (!measurement.add(rssi)) || (!measurement.add(ber)))
+ return;
aggr.add(measurement);
}
@@ -411,7 +416,8 @@
IntegerValue msgId(105);
IntegerValue devId(deviceId);
FloatValue temp(temperature(), 1);
- measurement.add(msgId).add(devId).add(temp);
+ if ((!measurement.add(msgId)) || (!measurement.add(devId)) || (!measurement.add(temp)))
+ return;
aggr.add(measurement);
}
@@ -424,7 +430,8 @@
IntegerValue devId(deviceId);
IntegerValue an0(analog0);
IntegerValue an1(analog1);
- measurement.add(msgId).add(devId).add(an0).add(an1);
+ if ((!measurement.add(msgId)) || (!measurement.add(devId)) || (!measurement.add(an0)) || (!measurement.add(an1)))
+ return;
aggr.add(measurement);
}
@@ -437,6 +444,7 @@
FloatValue x(acc.x, 2);
FloatValue y(acc.y, 2);
FloatValue z(acc.z, 2);
- measurement.add(msgId).add(devId).add(x).add(y).add(z);
+ if ((!measurement.add(msgId)) || (!measurement.add(devId)) || (!measurement.add(x)) || (!measurement.add(y)) || (!measurement.add(z)))
+ return;
aggr.add(measurement);
}
