bugfix switch netstack mode
This commit is contained in:
parent
fd12dcccf0
commit
5de29079ae
|
@ -56,6 +56,7 @@
|
||||||
#include "adc.h"
|
#include "adc.h"
|
||||||
#include "hw-arduino.h"
|
#include "hw-arduino.h"
|
||||||
#include "contiki.h"
|
#include "contiki.h"
|
||||||
|
#include "net/netstack.h"
|
||||||
|
|
||||||
#define DEBUG 0
|
#define DEBUG 0
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
@ -110,20 +111,26 @@ PROCESS(arduino_sketch, "Arduino Sketch Wrapper");
|
||||||
#define LOOP_INTERVAL (1 * CLOCK_SECOND)
|
#define LOOP_INTERVAL (1 * CLOCK_SECOND)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef SLEEP_NETWORK_INTERVAL
|
||||||
|
#define SLEEP_NETWORK_INTERVAL (60 * CLOCK_SECOND)
|
||||||
|
#endif
|
||||||
|
|
||||||
PROCESS_THREAD(arduino_sketch, ev, data)
|
PROCESS_THREAD(arduino_sketch, ev, data)
|
||||||
{
|
{
|
||||||
static struct etimer loop_periodic_timer;
|
static struct etimer loop_periodic_timer;
|
||||||
|
static struct etimer network_off_periodic_timer;
|
||||||
PROCESS_BEGIN();
|
PROCESS_BEGIN();
|
||||||
adc_init ();
|
adc_init ();
|
||||||
mcu_sleep_init ();
|
mcu_sleep_init ();
|
||||||
setup ();
|
setup ();
|
||||||
/* Define application-specific events here. */
|
/* Define application-specific events here. */
|
||||||
etimer_set(&loop_periodic_timer, LOOP_INTERVAL);
|
etimer_set(&loop_periodic_timer, LOOP_INTERVAL);
|
||||||
|
etimer_set(&network_off_periodic_timer, SLEEP_NETWORK_INTERVAL);
|
||||||
while (1) {
|
while (1) {
|
||||||
PROCESS_WAIT_EVENT();
|
PROCESS_WAIT_EVENT();
|
||||||
#if PLATFORM_HAS_BUTTON
|
#if PLATFORM_HAS_BUTTON
|
||||||
if(ev == sensors_event && data == &button_sensor) {
|
if(ev == sensors_event && data == &button_sensor) {
|
||||||
|
NETSTACK_MAC.off(1);
|
||||||
mcu_sleep_off();
|
mcu_sleep_off();
|
||||||
PRINTF("*******BUTTON*******\n");
|
PRINTF("*******BUTTON*******\n");
|
||||||
|
|
||||||
|
@ -136,11 +143,16 @@ PROCESS_THREAD(arduino_sketch, ev, data)
|
||||||
}
|
}
|
||||||
#endif /* PLATFORM_HAS_BUTTON */
|
#endif /* PLATFORM_HAS_BUTTON */
|
||||||
|
|
||||||
if(etimer_expired(&loop_periodic_timer)) {
|
if(etimer_expired(&network_off_periodic_timer)) {
|
||||||
mcu_sleep_off();
|
// NETSTACK_MAC.off(0);
|
||||||
loop ();
|
NETSTACK_MAC.on();
|
||||||
mcu_sleep_on();
|
etimer_reset(&network_off_periodic_timer);
|
||||||
etimer_reset(&loop_periodic_timer);
|
}
|
||||||
|
if(etimer_expired(&loop_periodic_timer)) {
|
||||||
|
mcu_sleep_off();
|
||||||
|
loop ();
|
||||||
|
mcu_sleep_on();
|
||||||
|
etimer_reset(&loop_periodic_timer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PROCESS_END();
|
PROCESS_END();
|
||||||
|
|
Loading…
Reference in a new issue