Example of using the ATT M2X back end. Connect over Ethernet with the WIZnet 5500 chip. This code sends random data to M2X.
Dependencies: M2XStreamClient WIZnet_Library jsonlite mbed
Fork of M2X_Nucleo411_ESP8266-wifi by
Revision 1:c7b9e522cc8e, committed 2015-08-29
- Comitter:
- jb8414
- Date:
- Sat Aug 29 17:11:28 2015 +0000
- Parent:
- 0:ece599ab76bb
- Child:
- 2:68b759c89fd9
- Commit message:
- Update with new M2XStreamClient
Changed in this revision
M2XStreamClient.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/M2XStreamClient.lib Tue Aug 05 14:46:55 2014 +0000 +++ b/M2XStreamClient.lib Sat Aug 29 17:11:28 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/teams/ATT-M2X-team/code/M2XStreamClient/#f479e4f4db0e +http://mbed.org/teams/ATT-M2X-team/code/M2XStreamClient/#2610823f7f2e
--- a/main.cpp Tue Aug 05 14:46:55 2014 +0000 +++ b/main.cpp Sat Aug 29 17:11:28 2015 +0000 @@ -12,9 +12,9 @@ #define min(a,b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; }) #endif -const char key[] = "<key>"; // Replace with your M2X user account master key -const char feed[] = "<feed>"; // Replace with your blueprint feed ID -const char stream[] = "<stream>"; // Replace with your stream name +char deviceId[] = "<device id>"; // Device you want to push to +char streamName[] = "<stream name>"; // Stream you want to push to +char m2xKey[] = "<m2x api key>"; // Your M2X API Key or Master API Key int main() { @@ -30,7 +30,7 @@ // Initialize the M2X client Client client; - M2XStreamClient m2xClient(&client, key); + M2XStreamClient m2xClient(&client, m2xKey); int ret; // Create an accelerometer instance @@ -58,9 +58,9 @@ // If the maximum title is over 20 degrees, then send // data to stream if (maxTilt > 20) { - ret = m2xClient.post(feed, stream, maxTilt); + ret = m2xClient.updateStreamValue(deviceId, streamName, maxTilt); printf("send() returned %d\r\n", ret); - // wait(0.5); + wait(0.5); } } } \ No newline at end of file