endpoint including temperature and distance sensors

Dependencies:   mbed mbedConnectorInterface mbedEndpointNetwork TrashSensors

Fork of TempAndDistTest by Tim Ambrose

Committer:
coyotebush
Date:
Mon May 18 00:44:59 2015 +0000
Revision:
10:338191178cbf
Parent:
9:16b63cd4aba8
max distance

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 10:338191178cbf 10 //#include "OnBoardLED.h"
coyotebush 6:bbea44df21e8 11 #include "TemperatureResource.h"
coyotebush 7:939fdc8df95b 12 #include "DistanceResource.h"
coyotebush 10:338191178cbf 13 #include "MaxDistanceResource.h"
coyotebush 2:b51fcb5fd114 14
coyotebush 2:b51fcb5fd114 15 /* Terminal connection */
coyotebush 2:b51fcb5fd114 16 RawSerial term(USBTX, USBRX);
coyotebush 2:b51fcb5fd114 17 Logger logger(&term);
coyotebush 2:b51fcb5fd114 18
coyotebush 2:b51fcb5fd114 19 /* Sensors */
Luminoscity 0:cb422b231ea5 20 #define TRIG_PIN D6
coyotebush 7:939fdc8df95b 21 #define ECHO_PIN D5
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 9:16b63cd4aba8 29 StaticResource latitude(&logger, "6/0/0", "35.296");
coyotebush 9:16b63cd4aba8 30 StaticResource longitude(&logger, "6/0/1", "-120.677");
coyotebush 9:16b63cd4aba8 31
coyotebush 10:338191178cbf 32 DistanceResource distR(&logger, "3302/0/5700", &distS, true);
coyotebush 10:338191178cbf 33 MaxDistanceResource maxDistR(&logger, "3302/0/5602", &distS, true);
coyotebush 10:338191178cbf 34 StaticResource unitsDistR(&logger, "3302/0/5701", "cm");
coyotebush 10:338191178cbf 35
coyotebush 6:bbea44df21e8 36 TemperatureResource tempR(&logger, "3303/0/5700", &tempS, true);
coyotebush 10:338191178cbf 37 StaticResource unitsTempR(&logger, "3302/0/5701", "Cel");
coyotebush 10:338191178cbf 38
coyotebush 10:338191178cbf 39 //LEDResource led(&logger, "3311/1/5706");
Luminoscity 0:cb422b231ea5 40
coyotebush 2:b51fcb5fd114 41 /* invoked through linker magic via Endpoint::start() */
coyotebush 2:b51fcb5fd114 42 Connector::Options *configure_endpoint(Connector::OptionsBuilder &config)
coyotebush 2:b51fcb5fd114 43 {
coyotebush 4:1ca75e77ae33 44 /* NSP configuration is in nsp_configuration.h */
coyotebush 2:b51fcb5fd114 45 logger.log("configure_endpoint: building endpoint configuration...");
coyotebush 7:939fdc8df95b 46 tempR.setMaxAge(5);
coyotebush 7:939fdc8df95b 47 distR.setMaxAge(15);
coyotebush 2:b51fcb5fd114 48 return config.addResource(&mfg)
coyotebush 2:b51fcb5fd114 49 .addResource(&model)
coyotebush 9:16b63cd4aba8 50 .addResource(&latitude)
coyotebush 9:16b63cd4aba8 51 .addResource(&longitude)
coyotebush 7:939fdc8df95b 52 .addResource(&distR)
coyotebush 10:338191178cbf 53 .addResource(&maxDistR)
coyotebush 10:338191178cbf 54 .addResource(&unitsDistR)
coyotebush 6:bbea44df21e8 55 .addResource(&tempR)
coyotebush 10:338191178cbf 56 .addResource(&unitsTempR)
coyotebush 10:338191178cbf 57 //.addResource(&led)
coyotebush 2:b51fcb5fd114 58 .build();
coyotebush 2:b51fcb5fd114 59 }
coyotebush 2:b51fcb5fd114 60
Luminoscity 0:cb422b231ea5 61 int main() {
coyotebush 2:b51fcb5fd114 62 logger.log("\r\n\r\nSmart Trash Can booting\r\n");
coyotebush 2:b51fcb5fd114 63 Connector::Endpoint::plumbNetwork();
coyotebush 2:b51fcb5fd114 64 Connector::Endpoint::start();
coyotebush 2:b51fcb5fd114 65 }