![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
M2X demo using the Freescale FRDM-KL46Z and Multitech Socketmodem MTSMS-H5
Dependencies: M2XStreamClient MMA8451Q SocketModem jsonlite mbed
Fork of MTS_M2x_Example by
Revision 8:54f32950dab2, committed 2014-04-29
- Comitter:
- jb8414
- Date:
- Tue Apr 29 21:15:00 2014 +0000
- Parent:
- 7:b90e8119f3cd
- Commit message:
- initial commit
Changed in this revision
diff -r b90e8119f3cd -r 54f32950dab2 M2XStreamClient.lib --- a/M2XStreamClient.lib Wed Jan 22 23:26:47 2014 +0000 +++ b/M2XStreamClient.lib Tue Apr 29 21:15:00 2014 +0000 @@ -1,1 +1,1 @@ -https://mbed.org/users/jb8414/code/M2XStreamClient/#95482e2b09ef +https://mbed.org/teams/ATT-M2X-team/code/M2XStreamClient/#f479e4f4db0e
diff -r b90e8119f3cd -r 54f32950dab2 MMA8451Q.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MMA8451Q.lib Tue Apr 29 21:15:00 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/JoKer/code/MMA8451Q/#2d14600116fc
diff -r b90e8119f3cd -r 54f32950dab2 jsonlite.lib --- a/jsonlite.lib Wed Jan 22 23:26:47 2014 +0000 +++ b/jsonlite.lib Tue Apr 29 21:15:00 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/citrusbyte/code/jsonlite/#01a2f8de46c8 +http://mbed.org/users/citrusbyte/code/jsonlite/#807034181e02
diff -r b90e8119f3cd -r 54f32950dab2 main.cpp --- a/main.cpp Wed Jan 22 23:26:47 2014 +0000 +++ b/main.cpp Tue Apr 29 21:15:00 2014 +0000 @@ -1,12 +1,29 @@ #include "mbed.h" +#include "MMA8451Q.h" #include "M2XStreamClient.h" #include "include_me.h" + +#if defined (TARGET_KL25Z) || defined (TARGET_KL46Z) + PinName const SDA = PTE25; + PinName const SCL = PTE24; +#elif defined (TARGET_KL05Z) + PinName const SDA = PTB4; + PinName const SCL = PTB3; +#else + #error TARGET NOT DEFINED +#endif + +#define MMA8451_I2C_ADDRESS (0x1d<<1) + using namespace mts; const char key[] = ""; // enter your m2x user account master key const char feed[] = ""; // enter your blueprint feed id -const char stream[] = "amb-temp"; // Create a stream name +const char* names[] = { "x", "y", "z" }; // user will need to create these Streams manually in the Dev Portal +int counts[] = { 1, 1, 1 }; + + // set to 1 for cellular shield board // set to 0 for wifi shield board @@ -28,7 +45,7 @@ int max_tries = 5; int i; - std::string apn = "wap.cingular"; + std::string apn = "m2m.com.attz"; i = 0; while (i++ < max_tries) { @@ -91,12 +108,26 @@ Client client; M2XStreamClient m2xClient(&client, key); int ret; - int num; + int streamNum = 3; + + MMA8451Q acc(SDA, SCL, MMA8451_I2C_ADDRESS); + PwmOut rled(LED1); + PwmOut gled(LED2); + PwmOut bled(LED3); + + printf("MMA8451 ID: %d\n", acc.getWhoAmI()); + while (true) { - num = rand(); - printf("sending %d\r\n", num); - ret = m2xClient.send(feed, stream, num); + float x, y, z; + x = rled = 1.0 - abs(acc.getAccX()); + y = gled = 1.0 - abs(acc.getAccY()); + z = bled = 1.0 - abs(acc.getAccZ()); + printf("Sending X: %1.2f, Y: %1.2f, Z: %1.2f\n\r", x, y, z); + double values[] = { x, y, z }; + ret = m2xClient.postMultiple(feed, streamNum, names, counts, NULL, values); printf("send() returned %d\r\n", ret); wait(5); } + + } \ No newline at end of file
diff -r b90e8119f3cd -r 54f32950dab2 mbed.bld --- a/mbed.bld Wed Jan 22 23:26:47 2014 +0000 +++ b/mbed.bld Tue Apr 29 21:15:00 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/a842253909c9 \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/8a40adfe8776 \ No newline at end of file