![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
asdf
Dependencies: Servo mbed mbedConnectorInterface mbedEndpointNetwork
Fork of TempAndDistTest by
Diff: main.cpp
- Revision:
- 3:c17adf68862b
- Parent:
- 1:2d8c4995c5bc
--- a/main.cpp Fri May 01 23:30:11 2015 +0000 +++ b/main.cpp Sat May 09 18:40:08 2015 +0000 @@ -1,30 +1,46 @@ #include "mbed.h" -#include "hcsr04.h" -#include "GroveTemp.h" +#include "EthernetInterface.h" +#include "ConnectorEndpoint.h" +#include "OptionsBuilder.h" + +#include "Servo.h" + +#include "StaticResource.h" +#include "ServoResource.h" + + /* Terminal connection */ +RawSerial term(USBTX, USBRX); +Logger logger(&term); + +/* Sensors */ +#define SERVO_PIN D4 +Servo servoA(SERVO_PIN); -#define TRIG_PIN D6 -#define ECHO_PIN D7 -#define FIRE_THRESH 32.0 +/* Resources */ +StaticResource mfg(&logger, "3/0/0", "Freescale"); +StaticResource model(&logger, "3/0/1", "K64F mbed Ethernet demo"); + +StaticResource latitude(&logger, "6/0/0", "35.296"); +StaticResource longitude(&logger, "6/0/1", "-120.677"); + +ServoResource servoR(&logger, "3302/0/5600", &servoA, true); -Serial term(USBTX, USBRX); -HCSR04 distS(TRIG_PIN, ECHO_PIN); +/* 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..."); + servoR.setMaxAge(15); + return config.addResource(&mfg) + .addResource(&model) + .addResource(&latitude) + .addResource(&longitude) + .addResource(&servoR) + .build(); +} -// Corey was here int main() { - GroveTempSensor tempS; - float temperature; - unsigned int distance; - - while (1) { - temperature = tempS.getTemp() * 3.0 / 5.0; - term.printf("Temp: %0.1f\n\r", temperature); - if (temperature > FIRE_THRESH) { - term.printf(" OMG! THE TRASH CAN CAN IS TOTALLY ON FIRE!!\n\r"); - } - - distS.start(); - wait_ms(500); - distance = distS.get_dist_cm(); - term.printf("Distance: %d\n\r", distance); - } -} \ No newline at end of file + logger.log("\r\n\r\nServoTest booting\r\n"); + Connector::Endpoint::plumbNetwork(); + Connector::Endpoint::start(); +}