2014-09-18 15:08:55 +02:00
|
|
|
/*
|
|
|
|
* Sample arduino sketch using contiki features.
|
|
|
|
* We turn the LED off
|
|
|
|
* We allow read the moisture sensor
|
|
|
|
* Unfortunately sleeping for long times in loop() isn't currently
|
|
|
|
* possible, something turns off the CPU (including PWM outputs) if a
|
|
|
|
* Proto-Thread is taking too long. We need to find out how to sleep in
|
|
|
|
* a Contiki-compatible way.
|
|
|
|
* Note that for a normal arduino sketch you won't have to include any
|
|
|
|
* of the contiki-specific files here, the sketch should just work.
|
|
|
|
*/
|
|
|
|
|
|
|
|
extern "C" {
|
2014-11-27 14:07:14 +01:00
|
|
|
#include "rest-engine.h"
|
2014-09-18 15:08:55 +02:00
|
|
|
|
2014-11-27 15:01:07 +01:00
|
|
|
extern resource_t res_moisture, res_battery;
|
2014-09-18 15:08:55 +02:00
|
|
|
uint8_t moisture_pin = A5;
|
2014-12-12 08:47:01 +01:00
|
|
|
uint8_t moisture_vcc = 19;
|
2014-09-18 15:08:55 +02:00
|
|
|
uint16_t moisture_voltage = 0;
|
2014-11-27 14:07:14 +01:00
|
|
|
|
|
|
|
#define LED_PIN 4
|
2014-09-18 15:08:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void setup (void)
|
|
|
|
{
|
2014-11-27 14:07:14 +01:00
|
|
|
// switch off the led
|
2014-09-18 15:08:55 +02:00
|
|
|
pinMode(LED_PIN, OUTPUT);
|
|
|
|
digitalWrite(LED_PIN, HIGH);
|
2014-12-12 08:47:01 +01:00
|
|
|
// init moisture sensor
|
|
|
|
pinMode(moisture_vcc, OUTPUT);
|
|
|
|
digitalWrite(moisture_vcc, LOW);
|
2014-11-27 14:07:14 +01:00
|
|
|
// init coap resourcen
|
2014-09-18 15:08:55 +02:00
|
|
|
rest_init_engine ();
|
2014-11-27 14:07:14 +01:00
|
|
|
rest_activate_resource (&res_moisture, "s/moisture");
|
2014-11-27 15:01:07 +01:00
|
|
|
rest_activate_resource (&res_battery, "s/battery");
|
2014-09-18 15:08:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void loop (void)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|