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.
Fork of M2XStreamClient by
Diff: M2XStreamClient_template.h
- Revision:
- 13:0d574742208f
- Parent:
- 10:4ce9eba38dbe
- Child:
- 14:205076b587fe
--- a/M2XStreamClient_template.h Fri Sep 26 09:35:10 2014 +0000
+++ b/M2XStreamClient_template.h Tue Dec 09 14:36:16 2014 +0000
@@ -6,10 +6,10 @@
int print_encoded_string(Print* print, const char* str);
template <class T>
-int M2XStreamClient::put(const char* feedId, const char* streamName, T value) {
+int M2XStreamClient::updateStreamValue(const char* deviceId, const char* streamName, T value) {
if (_client->connect(_host, _port)) {
DBGLN("%s", "Connected to M2X server!");
- writePutHeader(feedId, streamName,
+ writePutHeader(deviceId, streamName,
// for {"value": and }
_null_print.print(value) + 10);
_client->print("{\"value\":");
@@ -34,7 +34,7 @@
bytes += print->print(names[i]);
bytes += print->print("\":[");
for (int j = 0; j < counts[i]; j++) {
- bytes += print->print("{\"at\": \"");
+ bytes += print->print("{\"timestamp\": \"");
bytes += print->print(ats[value_index]);
bytes += print->print("\", \"value\": \"");
bytes += print->print(values[value_index]);
@@ -50,16 +50,16 @@
}
template <class T>
-int M2XStreamClient::postMultiple(const char* feedId, int streamNum,
- const char* names[], const int counts[],
- const char* ats[], T values[]) {
+int M2XStreamClient::postDeviceUpdates(const char* deviceId, int streamNum,
+ const char* names[], const int counts[],
+ const char* ats[], T values[]) {
if (_client->connect(_host, _port)) {
DBGLN("%s", "Connected to M2X server!");
int length = write_multiple_values(&_null_print, streamNum, names,
counts, ats, values);
- _client->print("POST /v1/feeds/");
- print_encoded_string(_client, feedId);
- _client->println(" HTTP/1.0");
+ _client->print("POST /v2/devices/");
+ print_encoded_string(_client, deviceId);
+ _client->println("/updates HTTP/1.0");
writeHttpHeader(length);
write_multiple_values(_client, streamNum, names, counts, ats, values);
} else {
@@ -103,7 +103,7 @@
}
template <class T>
-int M2XStreamClient::updateLocation(const char* feedId,
+int M2XStreamClient::updateLocation(const char* deviceId,
const char* name,
T latitude,
T longitude,
@@ -113,8 +113,8 @@
int length = write_location_data(&_null_print, name, latitude, longitude,
elevation);
- _client->print("PUT /v1/feeds/");
- print_encoded_string(_client, feedId);
+ _client->print("PUT /v2/devices/");
+ print_encoded_string(_client, deviceId);
_client->println("/location HTTP/1.0");
writeHttpHeader(length);
