Added function deleteLocations to delete the location history.
Dependents: WNCInterface_M2Xdemo ATT_WNCInterface_Info WNCInterface_HTTP_example Public_IoT_M2X_Cellular_Demo
Fork of M2XStreamClient by
Diff: M2XStreamClient.h
- Revision:
- 13:0d574742208f
- Parent:
- 10:4ce9eba38dbe
- Child:
- 14:205076b587fe
diff -r debf4b2f7960 -r 0d574742208f M2XStreamClient.h --- a/M2XStreamClient.h Fri Sep 26 09:35:10 2014 +0000 +++ b/M2XStreamClient.h Tue Dec 09 14:36:16 2014 +0000 @@ -8,13 +8,13 @@ #ifdef ARDUINO_PLATFORM #include "Arduino.h" -#define USER_AGENT "User-Agent: M2X Arduino Client/0.1" +#define USER_AGENT "User-Agent: M2X Arduino Client/2.0.0" #endif #ifdef MBED_PLATFORM #include "mbed.h" -#define USER_AGENT "User-Agent: M2X Mbed Client/0.1" +#define USER_AGENT "User-Agent: M2X Mbed Client/2.0.0" #endif #include "Client.h" @@ -82,10 +82,10 @@ // Push data stream value using PUT request, returns the HTTP status code template <class T> - int put(const char* feedId, const char* streamName, T value); + int updateStreamValue(const char* deviceId, const char* streamName, T value); // Post multiple values to M2X all at once. - // +feedId+ - id of the feed to post values + // +deviceId+ - id of the device to post values // +streamNum+ - Number of streams to post // +names+ - Array of stream names, the length of the array should // be exactly +streamNum+ @@ -103,9 +103,9 @@ // for the second stream, etc. The length of this array should be // the sum of all values in +counts+ array. template <class T> - int postMultiple(const char* feedId, int streamNum, - const char* names[], const int counts[], - const char* ats[], T values[]); + int postDeviceUpdates(const char* deviceId, int streamNum, + const char* names[], const int counts[], + const char* ats[], T values[]); // Fetch values for a particular data stream. Since memory is // very limited on an Arduino, we cannot parse and get all the @@ -119,10 +119,9 @@ // For each data point, the callback will be called once. The HTTP // status code will be returned. And the content is only parsed when // the status code is 200. - int fetchValues(const char* feedId, const char* streamName, - stream_value_read_callback callback, void* context, - const char* startTime = NULL, const char* endTime = NULL, - const char* limit = NULL); + int listStreamValues(const char* deviceId, const char* streamName, + stream_value_read_callback callback, void* context, + const char* query = NULL); // Update datasource location // NOTE: On an Arduino Uno and other ATMEGA based boards, double has @@ -139,13 +138,13 @@ // without any precision problems. // Returned value is the http status code. template <class T> - int updateLocation(const char* feedId, const char* name, + int updateLocation(const char* deviceId, const char* name, T latitude, T longitude, T elevation); - // Read location information for a feed. Also used callback to process + // Read location information for a device. Also used callback to process // data points for memory reasons. The HTTP status code is returned, // response is only parsed when the HTTP status code is 200 - int readLocation(const char* feedId, location_read_callback callback, + int readLocation(const char* deviceId, location_read_callback callback, void* context); // Delete values from a data stream @@ -162,7 +161,7 @@ // The status code is 204 on success and 400 on a bad request (e.g. the // timestamp is not in ISO8601 format or the from timestamp is not less than // or equal to the end timestamp. - int deleteValues(const char* feedId, const char* streamName, + int deleteValues(const char* deviceId, const char* streamName, const char* from, const char* end); private: Client* _client; @@ -173,11 +172,11 @@ NullPrint _null_print; // Writes the HTTP header part for updating a stream value - void writePutHeader(const char* feedId, + void writePutHeader(const char* deviceId, const char* streamName, int contentLength); // Writes the HTTP header part for deleting stream values - void writeDeleteHeader(const char* feedId, + void writeDeleteHeader(const char* deviceId, const char* streamName, int contentLength); // Writes HTTP header lines including M2X API Key, host, content