![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Proof of concept for distance and temperature monitoring
Dependencies: mbed mbedConnectorInterface mbedEndpointNetwork
main.cpp
- Committer:
- coyotebush
- Date:
- 2015-05-06
- Revision:
- 7:939fdc8df95b
- Parent:
- 6:bbea44df21e8
- Child:
- 8:c69fe28366d8
File content as of revision 7:939fdc8df95b:
#include "mbed.h" #include "EthernetInterface.h" #include "ConnectorEndpoint.h" #include "OptionsBuilder.h" #include "hcsr04.h" #include "GroveTemp.h" #include "StaticResource.h" #include "OnBoardLED.h" #include "TemperatureResource.h" #include "DistanceResource.h" /* Terminal connection */ RawSerial term(USBTX, USBRX); Logger logger(&term); /* Sensors */ #define TRIG_PIN D6 #define ECHO_PIN D5 #define FIRE_THRESH 32.0 HCSR04 distS(TRIG_PIN, ECHO_PIN); GroveTempSensor tempS; /* Resources */ StaticResource mfg(&logger, "3/0/0", "Freescale"); StaticResource model(&logger, "3/0/1", "K64F mbed Ethernet demo"); DistanceResource distR(&logger, "3302/0/5600", &distS, true); TemperatureResource tempR(&logger, "3303/0/5700", &tempS, true); LEDResource led(&logger, "3311/1/5706"); /* invoked through linker magic via Endpoint::start() */ Connector::Options *configure_endpoint(Connector::OptionsBuilder &config) { /* NSP configuration is in nsp_configuration.h */ logger.log("configure_endpoint: building endpoint configuration..."); tempR.setMaxAge(5); distR.setMaxAge(15); return config.addResource(&mfg) .addResource(&model) .addResource(&distR) .addResource(&tempR) .addResource(&led) .build(); } int main() { double temperature; unsigned int distance; logger.log("\r\n\r\nSmart Trash Can booting\r\n"); Connector::Endpoint::plumbNetwork(); Connector::Endpoint::start(); }