port to cellular
Dependencies: C027_Support LM75B M2XStreamClient jsonlite mbed mbed-rtos
Fork of m2x-demo-all by
Diff: main.cpp
- Revision:
- 1:c73a98da0e7a
- Parent:
- 0:38a7a8cae773
- Child:
- 2:83dd0b8109ca
--- a/main.cpp Fri Feb 21 21:12:15 2014 +0000 +++ b/main.cpp Tue May 13 07:18:59 2014 +0000 @@ -2,9 +2,33 @@ #include "M2XStreamClient.h" #include "mbed.h" -#include "EthernetInterface.h" #include "LM75B.h" //I2C Temperature Sensor +#include "C027.h" +#include "MDM.h" + +//---------------------------------------------------------------------- +// You may need to configure these parameters + +/** Set your secret SIM pin here "1234" +*/ +#define SIMPIN NULL + +/** The APN of your network operator, sometimes it is "internet" + check your contract with the network operator +*/ +#define APN "gprs.swisscom.ch" + +/** Set the user name for your APN, or NULL if not needed +*/ +#define USERNAME NULL + +/** Set the password for your APN, or NULL if not needed +*/ +#define PASSWORD NULL + +C027 c027; + char feedId[] = "<feed id>"; // Feed you want to post to char m2xKey[] = "<m2x api key>"; // Your M2X access key char streamName[] = "<stream name>"; // Stream you want to post to @@ -17,8 +41,7 @@ Client client; M2XStreamClient m2xClient(&client, m2xKey); -EthernetInterface eth; -LM75B tmp(p28,p27); // I2C Temperature Sensor +LM75B tmp(SDA,SCL); // I2C Temperature Sensor void on_data_point_found(const char* at, const char* value, int index, void* context) { printf("Found a data point, index: %d\r\n", index); @@ -38,9 +61,12 @@ } int main() { - eth.init(); - eth.connect(); - printf("IP Address: %s\r\n", eth.getIPAddress()); + // turn on the supplies of the Modem and the GPS + c027.mdmPower(true); + printf("Modem Initialize\r\n"); + MDMSerial mdm; + if (!mdm.connect(SIMPIN, APN,USERNAME,PASSWORD, true)) + return -1; char amb_temp[6]; @@ -72,4 +98,9 @@ // wait 60 secs and then loop delay(60000); } + + mdm.disconnect(); + mdm.powerOff(); + c027.mdmPower(false); + printf("Done\n"); } \ No newline at end of file