osd-contiki/examples/osd/arduino-merkurboard/sketch.pde

45 lines
1.1 KiB
Plaintext
Raw Normal View History

2015-01-22 14:03:29 +01: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" {
2016-04-12 10:34:40 +02:00
#include "arduino-process.h"
2015-01-22 14:03:29 +01:00
#include "rest-engine.h"
2016-01-22 21:46:35 +01:00
#include "net/netstack.h"
2016-04-24 17:45:35 +02:00
extern resource_t res_led, res_battery, res_cputemp;
2015-01-22 14:03:29 +01:00
2016-04-24 17:45:35 +02:00
uint8_t led_pin=4;
uint8_t led_status;
2015-01-22 14:03:29 +01:00
}
void setup (void)
{
// switch off the led
2016-04-24 17:45:35 +02:00
pinMode(led_pin, OUTPUT);
digitalWrite(led_pin, HIGH);
led_status=0;
2015-01-22 14:03:29 +01:00
// init coap resourcen
rest_init_engine ();
2016-04-24 17:45:35 +02:00
rest_activate_resource (&res_led, "s/led");
2015-01-22 14:03:29 +01:00
rest_activate_resource (&res_battery, "s/battery");
rest_activate_resource (&res_cputemp, "s/cputemp");
2016-01-22 21:46:35 +01:00
// NETSTACK_MAC.off(1);
2015-01-22 14:03:29 +01:00
}
void loop (void)
{
2016-04-12 10:34:40 +02:00
mcu_sleep_off();
mcu_sleep_on();
2015-01-22 14:03:29 +01:00
}