trash over HTTP
Dependencies: C027_Support HTTPClient TrashSensors mbed Crypto
Fork of SLOTrashHTTP by
Collects sensor readings and sends them to https://trash.coreyford.name/
Server code: https://github.com/coyotebush/trash-map
Diff: main.cpp
- Revision:
- 2:ecc029c53752
- Parent:
- 1:929b55ff96b0
- Child:
- 3:1e5d19eb7c9a
--- a/main.cpp Mon May 25 03:19:34 2015 +0000 +++ b/main.cpp Wed May 27 06:03:25 2015 +0000 @@ -1,43 +1,43 @@ #include "mbed.h" #include "HTTPClient.h" -//------------------------------------------------------------------------------------ -// You need to configure these cellular modem / SIM parameters. -// These parameters are ignored for LISA-C200 variants and can be left NULL. -//------------------------------------------------------------------------------------ -#include "MDM.h" -//! Set your secret SIM pin here (e.g. "1234"). Check your SIM manual. -#define SIMPIN NULL -/*! The APN of your network operator SIM, sometimes it is "internet" check your - contract with the network operator. You can also try to look-up your settings in - google: https://www.google.de/search?q=APN+list */ -#define APN "Broadband" -//! 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 -//------------------------------------------------------------------------------------ - #include "hcsr04.h" #define TRIG_PIN D6 #define ECHO_PIN D5 #define SENSOR_NAME "Throop" -char str[512]; +#define CELLULAR_NETWORK 1 + +#ifdef CELLULAR_NETWORK +#include "MDM.h" +#define SIMPIN NULL +#define APN "Broadband" +#define USERNAME NULL +#define PASSWORD NULL +#else +#include "EthernetInterface.h" +#endif int main() -{ +{ +#ifdef CELLULAR_NETWORK + MDMSerial mdm; + //mdm.setDebug(4); + if (!mdm.connect(SIMPIN, APN,USERNAME,PASSWORD)) + return -1; +#else + EthernetInterface ethernet; + ethernet.init(); // DHCP + if (ethernet.connect() != 0) + return -1; +#endif + HTTPClient http; + HCSR04 distS(TRIG_PIN, ECHO_PIN); double distV; char distString[10]; - - // turn on the supplies of the Modem - MDMSerial mdm; - //mdm.setDebug(4); // enable this for debugging issues - if (!mdm.connect(SIMPIN, APN,USERNAME,PASSWORD)) - return -1; - HTTPClient http; + char str[512]; while (true) { distS.start();