Proof of concept for distance and temperature monitoring

Dependencies:   mbed mbedConnectorInterface mbedEndpointNetwork

Committer:
coyotebush
Date:
Thu May 07 04:14:57 2015 +0000
Revision:
9:16b63cd4aba8
Parent:
8:c69fe28366d8
Child:
10:338191178cbf
Add static location resource

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
coyotebush 3:b51fcb5fd114 21 HCSR04 distS(TRIG_PIN, ECHO_PIN);
coyotebush 3:b51fcb5fd114 22 GroveTempSensor tempS;
Luminoscity 0:cb422b231ea5 23
coyotebush 3:b51fcb5fd114 24 /* Resources */
coyotebush 3:b51fcb5fd114 25 StaticResource mfg(&logger, "3/0/0", "Freescale");
coyotebush 3:b51fcb5fd114 26 StaticResource model(&logger, "3/0/1", "K64F mbed Ethernet demo");
coyotebush 3:b51fcb5fd114 27
coyotebush 9:16b63cd4aba8 28 StaticResource latitude(&logger, "6/0/0", "35.296");
coyotebush 9:16b63cd4aba8 29 StaticResource longitude(&logger, "6/0/1", "-120.677");
coyotebush 9:16b63cd4aba8 30
coyotebush 7:939fdc8df95b 31 DistanceResource distR(&logger, "3302/0/5600", &distS, true);
coyotebush 6:bbea44df21e8 32 TemperatureResource tempR(&logger, "3303/0/5700", &tempS, true);
coyotebush 3:b51fcb5fd114 33 LEDResource led(&logger, "3311/1/5706");
Luminoscity 0:cb422b231ea5 34
coyotebush 3:b51fcb5fd114 35 /* invoked through linker magic via Endpoint::start() */
coyotebush 3:b51fcb5fd114 36 Connector::Options *configure_endpoint(Connector::OptionsBuilder &config)
coyotebush 3:b51fcb5fd114 37 {
coyotebush 4:1ca75e77ae33 38 /* NSP configuration is in nsp_configuration.h */
coyotebush 3:b51fcb5fd114 39 logger.log("configure_endpoint: building endpoint configuration...");
coyotebush 7:939fdc8df95b 40 tempR.setMaxAge(5);
coyotebush 7:939fdc8df95b 41 distR.setMaxAge(15);
coyotebush 3:b51fcb5fd114 42 return config.addResource(&mfg)
coyotebush 3:b51fcb5fd114 43 .addResource(&model)
coyotebush 9:16b63cd4aba8 44 .addResource(&latitude)
coyotebush 9:16b63cd4aba8 45 .addResource(&longitude)
coyotebush 7:939fdc8df95b 46 .addResource(&distR)
coyotebush 6:bbea44df21e8 47 .addResource(&tempR)
coyotebush 3:b51fcb5fd114 48 .addResource(&led)
coyotebush 3:b51fcb5fd114 49 .build();
coyotebush 3:b51fcb5fd114 50 }
coyotebush 3:b51fcb5fd114 51
Luminoscity 0:cb422b231ea5 52 int main() {
coyotebush 3:b51fcb5fd114 53 logger.log("\r\n\r\nSmart Trash Can booting\r\n");
coyotebush 3:b51fcb5fd114 54 Connector::Endpoint::plumbNetwork();
coyotebush 3:b51fcb5fd114 55 Connector::Endpoint::start();
coyotebush 3:b51fcb5fd114 56 }