Proof of concept for distance and temperature monitoring

Dependencies:   mbed mbedConnectorInterface mbedEndpointNetwork

Committer:
coyotebush
Date:
Wed May 06 02:53:36 2015 +0000
Revision:
7:939fdc8df95b
Parent:
6:bbea44df21e8
Child:
8:c69fe28366d8
Add DistanceResource

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Luminoscity 0:cb422b231ea5 1 #include "mbed.h"
coyotebush 3:b51fcb5fd114 2 #include "EthernetInterface.h"
coyotebush 3:b51fcb5fd114 3 #include "ConnectorEndpoint.h"
coyotebush 3:b51fcb5fd114 4 #include "OptionsBuilder.h"
coyotebush 3:b51fcb5fd114 5
Luminoscity 0:cb422b231ea5 6 #include "hcsr04.h"
Luminoscity 0:cb422b231ea5 7 #include "GroveTemp.h"
coyotebush 6:bbea44df21e8 8
coyotebush 7:939fdc8df95b 9 #include "StaticResource.h"
coyotebush 3:b51fcb5fd114 10 #include "OnBoardLED.h"
coyotebush 6:bbea44df21e8 11 #include "TemperatureResource.h"
coyotebush 7:939fdc8df95b 12 #include "DistanceResource.h"
coyotebush 3:b51fcb5fd114 13
coyotebush 3:b51fcb5fd114 14 /* Terminal connection */
coyotebush 3:b51fcb5fd114 15 RawSerial term(USBTX, USBRX);
coyotebush 3:b51fcb5fd114 16 Logger logger(&term);
coyotebush 3:b51fcb5fd114 17
coyotebush 3:b51fcb5fd114 18 /* Sensors */
Luminoscity 0:cb422b231ea5 19 #define TRIG_PIN D6
coyotebush 7:939fdc8df95b 20 #define ECHO_PIN D5
Luminoscity 0:cb422b231ea5 21 #define FIRE_THRESH 32.0
coyotebush 3:b51fcb5fd114 22 HCSR04 distS(TRIG_PIN, ECHO_PIN);
coyotebush 3:b51fcb5fd114 23 GroveTempSensor tempS;
Luminoscity 0:cb422b231ea5 24
coyotebush 3:b51fcb5fd114 25 /* Resources */
coyotebush 3:b51fcb5fd114 26 StaticResource mfg(&logger, "3/0/0", "Freescale");
coyotebush 3:b51fcb5fd114 27 StaticResource model(&logger, "3/0/1", "K64F mbed Ethernet demo");
coyotebush 3:b51fcb5fd114 28
coyotebush 7:939fdc8df95b 29 DistanceResource distR(&logger, "3302/0/5600", &distS, true);
coyotebush 6:bbea44df21e8 30 TemperatureResource tempR(&logger, "3303/0/5700", &tempS, true);
coyotebush 3:b51fcb5fd114 31 LEDResource led(&logger, "3311/1/5706");
Luminoscity 0:cb422b231ea5 32
coyotebush 3:b51fcb5fd114 33 /* invoked through linker magic via Endpoint::start() */
coyotebush 3:b51fcb5fd114 34 Connector::Options *configure_endpoint(Connector::OptionsBuilder &config)
coyotebush 3:b51fcb5fd114 35 {
coyotebush 4:1ca75e77ae33 36 /* NSP configuration is in nsp_configuration.h */
coyotebush 3:b51fcb5fd114 37 logger.log("configure_endpoint: building endpoint configuration...");
coyotebush 7:939fdc8df95b 38 tempR.setMaxAge(5);
coyotebush 7:939fdc8df95b 39 distR.setMaxAge(15);
coyotebush 3:b51fcb5fd114 40 return config.addResource(&mfg)
coyotebush 3:b51fcb5fd114 41 .addResource(&model)
coyotebush 7:939fdc8df95b 42 .addResource(&distR)
coyotebush 6:bbea44df21e8 43 .addResource(&tempR)
coyotebush 3:b51fcb5fd114 44 .addResource(&led)
coyotebush 3:b51fcb5fd114 45 .build();
coyotebush 3:b51fcb5fd114 46 }
coyotebush 3:b51fcb5fd114 47
Luminoscity 0:cb422b231ea5 48 int main() {
coyotebush 3:b51fcb5fd114 49 double temperature;
Luminoscity 0:cb422b231ea5 50 unsigned int distance;
coyotebush 3:b51fcb5fd114 51
coyotebush 3:b51fcb5fd114 52 logger.log("\r\n\r\nSmart Trash Can booting\r\n");
coyotebush 3:b51fcb5fd114 53 Connector::Endpoint::plumbNetwork();
coyotebush 3:b51fcb5fd114 54 Connector::Endpoint::start();
coyotebush 3:b51fcb5fd114 55 }