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: program.cpp
- Revision:
- 15:0ccf0f530a05
- Parent:
- 13:4045b6ac448d
- Child:
- 16:94d6eae3195a
--- a/program.cpp Tue Feb 18 13:59:21 2014 +0000
+++ b/program.cpp Tue Feb 18 15:36:12 2014 +0000
@@ -44,18 +44,18 @@
"10,105,POST,/measurement/measurements,application/vnd.com.nsn.cumulocity.measurement+json,application/vnd.com.nsn.cumulocity.measurement+json,%%,NOW UNSIGNED NUMBER,\"{\"\"time\"\":\"\"%%\"\",\"\"source\"\":{\"\"id\"\":\"\"%%\"\"},\"\"type\"\":\"\"c8y_TemperatureMeasurement\"\",\"\"c8y_TemperatureMeasurement\"\":{\"\"T\"\":{\"\"value\"\":%%,\"\"unit\"\":\"\"C\"\"}}}\"\r\n"
// Insert measurement
// USAGE: 105,<DEVICE/ID>,<COUNTER>
-"10,106,POST,/measurement/measurements,application/vnd.com.nsn.cumulocity.measurement+json,application/vnd.com.nsn.cumulocity.measurement+json,%%,NOW UNSIGNED UNSIGNED,\"{\"\"time\"\":\"\"%%\"\",\"\"source\"\":{\"\"id\"\":\"\"%%\"\"},\"\"type\"\":\"\"c8y_CountMeasurement\"\",\"c8y_CountMeasurement\":{\"n\":{\"value\":%%,\"unit\":\"\"}}}\"\r\n"
+"10,106,POST,/measurement/measurements,application/vnd.com.nsn.cumulocity.measurement+json,application/vnd.com.nsn.cumulocity.measurement+json,%%,NOW UNSIGNED UNSIGNED,\"{\"\"time\"\":\"\"%%\"\",\"\"source\"\":{\"\"id\"\":\"\"%%\"\"},\"\"type\"\":\"\"c8y_CountMeasurement\"\",\"\"c8y_CountMeasurement\"\":{\"\"n\"\":{\"\"value\"\":%%,\"\"unit\":\"\"\"\"}}}\"\r\n"
// Insert measurement
// USAGE: 105,<DEVICE/ID>,<X>,<Y>,<Z>
"10,107,POST,/measurement/measurements,application/vnd.com.nsn.cumulocity.measurement+json,application/vnd.com.nsn.cumulocity.measurement+json,%%,NOW UNSIGNED NUMBER NUMBER NUMBER,\"{\"\"time\"\":\"\"%%\"\",\"\"source\"\":{\"\"id\"\":\"\"%%\"\"},\"\"type\"\":\"\"c8y_MotionMeasurement\"\",\"\"c8y_MotionMeasurement\"\":{\"\"x\"\":{\"\"value\"\":%%,\"\"unit\"\":\"\"m^2/s\"\"},\"\"y\"\":{\"\"value\"\":%%,\"\"unit\"\":\"\"m^2/s\"\"},\"\"z\"\":{\"\"value\"\":%%,\"\"unit\"\":\"\"m^2/s\"\"}}}\"\r\n"
);
float interval = 120.0; // send measurements every two minutes
-MbedSmartRest client("http://developer.cumulocity.com/s", "vaillant/admin", "klanpi", "com_u-blox_C027_REV-A_0.8");
+MbedSmartRest client("http://developer.cumulocity.com/s", "vaillant/admin", "klanpi", "com_u-blox_C027_REV-A_0.9");
int program(void)
{
- long deviceId; Timer timer;
+ long deviceId = 0; Timer timer;
puts("Hello!");
@@ -248,14 +248,23 @@
Aggregator aggr(5, false, true);
signalMeasurement(deviceId, aggr);
+ if (client.send(aggr) != SMARTREST_SUCCESS) {
+ puts("Send failed.");
+ }
+ client.stop();
+ aggr.clear();
temperatureMeasurement(deviceId, aggr);
countMeasurement(deviceId, aggr);
+ if (client.send(aggr) != SMARTREST_SUCCESS) {
+ puts("Send failed.");
+ }
+ client.stop();
+ aggr.clear();
motionMeasurement(deviceId, aggr);
if (client.send(aggr) != SMARTREST_SUCCESS) {
puts("Send failed.");
}
-
client.stop();
}
