
An m2x sample code that uses accelerometers. Not working yet.
Dependencies: MMA8451Q SocketModem jsonlite mbed
Fork of MTS_M2x_Example by
Revision 3:d24e8bec5610, committed 2014-01-04
- Comitter:
- sam_grove
- Date:
- Sat Jan 04 20:43:00 2014 +0000
- Parent:
- 2:76e0d5968991
- Child:
- 4:51ae5b9e1e9e
- Commit message:
- User needs to supply m2x settings
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sat Jan 04 06:37:50 2014 +0000 +++ b/main.cpp Sat Jan 04 20:43:00 2014 +0000 @@ -4,23 +4,26 @@ using namespace mts; -const char key[] = "b26a78445f81fcc56e42ffa42350fb09"; -const char feed[] = "9ed5d71fe2b0b2ea6ddd7d8d65206250"; -const char stream[] = "amb-temp"; +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 // set to 1 for cellular shield board // set to 0 for wifi shield board -#define CELL_SHIELD 0 +#define CELL_SHIELD 1 +// ssid and phrase for wifi std::string ssid = "belkin54g"; +std::string phrase = "hackathon"; -int main() { +int main() +{ #if CELL_SHIELD for (int i = 30; i >= 0; i = i - 2) { wait(2); printf("Waiting %d seconds...\n\r", i); } - + MTSSerialFlowControl* serial = new MTSSerialFlowControl(PTD3, PTD2, PTA12, PTC8); serial->baud(115200); Transport::setTransport(Transport::CELLULAR); @@ -30,7 +33,7 @@ int max_tries = 5; int i; std::string apn = "wap.cingular"; - + i = 0; while (i++ < max_tries) { if (cell->getRegistration() == Cellular::REGISTERED) { @@ -42,7 +45,7 @@ wait(3); } } - + printf("signal strength: %d\n\r", cell->getSignalStrength()); i = 0; @@ -57,7 +60,7 @@ wait(1); } } - + i = 0; printf("bringing up PPP link\n\r"); while (i++ < max_tries) { @@ -80,14 +83,14 @@ Transport::setTransport(Transport::WIFI); Wifi* wifi = Wifi::getInstance(); printf("Init: %s\n\r", wifi->init(serial) ? "SUCCESS" : "FAILURE"); - printf("Set Network: %s\n\r", getCodeNames(wifi->setNetwork(ssid, Wifi::NONE, "")).c_str()); + printf("Set Network: %s\n\r", getCodeNames(wifi->setNetwork(ssid, Wifi::WPA, phrase)).c_str()); printf("Set DHCP: %s\n\r", getCodeNames(wifi->setDeviceIP("DHCP")).c_str()); printf("Signal Strnegth (dBm): %d\n\r", wifi->getSignalStrength()); printf("Is Connected: %s\n\r", wifi->isConnected() ? "True" : "False"); printf("Connect: %s\n\r", wifi->connect() ? "Success" : "Failure"); printf("Is Connected: %s\n\r", wifi->isConnected() ? "True" : "False"); #endif - + /* send some data */ Client client; M2XStreamClient m2xClient(&client, key);