endpoint including temperature and distance sensors

Dependencies:   mbed mbedConnectorInterface mbedEndpointNetwork TrashSensors

Fork of TempAndDistTest by Tim Ambrose

Committer:
coyotebush
Date:
Wed May 06 04:02:08 2015 +0000
Revision:
8:c69fe28366d8
Parent:
7:939fdc8df95b
Child:
9:16b63cd4aba8
Distance sensing improvements

Who changed what in which revision?

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