2016-08-03 21:58:02 +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" {
|
|
|
|
#include "arduino-process.h"
|
|
|
|
#include "rest-engine.h"
|
|
|
|
#include "net/netstack.h"
|
|
|
|
#include "dev/button-sensor.h"
|
|
|
|
|
|
|
|
extern resource_t
|
2016-08-20 14:09:44 +02:00
|
|
|
res_led,
|
|
|
|
res_bled,
|
2016-08-03 21:58:02 +02:00
|
|
|
res_battery,
|
|
|
|
res_cputemp,
|
|
|
|
res_event,
|
|
|
|
res_separate,
|
|
|
|
res_server;
|
|
|
|
|
|
|
|
uint8_t led_pin=4;
|
|
|
|
uint8_t led_status;
|
2016-08-20 14:09:44 +02:00
|
|
|
uint8_t bled_pin=7;
|
|
|
|
uint8_t bled_status;
|
2016-08-03 21:58:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void setup (void)
|
|
|
|
{
|
|
|
|
// switch off the led
|
|
|
|
pinMode(led_pin, OUTPUT);
|
|
|
|
digitalWrite(led_pin, HIGH);
|
|
|
|
led_status=0;
|
2016-08-20 14:09:44 +02:00
|
|
|
// switch off the bled
|
|
|
|
pinMode(bled_pin, OUTPUT);
|
|
|
|
digitalWrite(bled_pin, LOW);
|
|
|
|
bled_status=0;
|
2016-08-03 21:58:02 +02:00
|
|
|
// sensors
|
|
|
|
SENSORS_ACTIVATE(button_sensor);
|
|
|
|
// init coap resourcen
|
|
|
|
rest_init_engine ();
|
2016-08-24 00:59:47 +02:00
|
|
|
#pragma GCC diagnostic ignored "-Wwrite-strings"
|
2016-08-03 21:58:02 +02:00
|
|
|
rest_activate_resource (&res_led, "s/led");
|
2016-08-20 14:09:44 +02:00
|
|
|
rest_activate_resource (&res_bled, "s/bled");
|
2016-08-03 21:58:02 +02:00
|
|
|
rest_activate_resource (&res_battery, "s/battery");
|
|
|
|
rest_activate_resource (&res_cputemp, "s/cputemp");
|
2016-08-20 14:09:44 +02:00
|
|
|
rest_activate_resource(&res_event, "s/button");
|
2016-08-24 00:59:47 +02:00
|
|
|
#pragma GCC diagnostic pop
|
2016-08-03 21:58:02 +02:00
|
|
|
|
2016-08-11 23:49:45 +02:00
|
|
|
// NETSTACK_MAC.off(1);
|
2016-08-03 21:58:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void loop (void)
|
|
|
|
{
|
2016-08-11 23:49:45 +02:00
|
|
|
|
2016-08-03 21:58:02 +02:00
|
|
|
}
|