diff --git a/examples/zolertia/zoul/Makefile b/examples/zolertia/zoul/Makefile index aa371757b..beef98880 100644 --- a/examples/zolertia/zoul/Makefile +++ b/examples/zolertia/zoul/Makefile @@ -1,5 +1,5 @@ DEFINES+=PROJECT_CONF_H=\"project-conf.h\" -CONTIKI_PROJECT = zoul-demo test-tsl2563 test-sht25 test-pwm +CONTIKI_PROJECT = zoul-demo test-tsl2563 test-sht25 test-pwm test-power-mgmt CONTIKI_TARGET_SOURCEFILES += tsl2563.c sht25.c all: $(CONTIKI_PROJECT) diff --git a/examples/zolertia/zoul/power-mgmt/Makefile b/examples/zolertia/zoul/power-mgmt/Makefile deleted file mode 100644 index c574add4f..000000000 --- a/examples/zolertia/zoul/power-mgmt/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -CONTIKI_PROJECT = test-power-mgmt - -TARGET = zoul - -all: $(CONTIKI_PROJECT) - -CONTIKI = ../../../.. -include $(CONTIKI)/Makefile.include diff --git a/examples/zolertia/zoul/project-conf.h b/examples/zolertia/zoul/project-conf.h index 9ff57c953..420d9a8e0 100644 --- a/examples/zolertia/zoul/project-conf.h +++ b/examples/zolertia/zoul/project-conf.h @@ -38,7 +38,7 @@ #ifndef PROJECT_CONF_H_ #define PROJECT_CONF_H_ -#define NETSTACK_CONF_RDC nullrdc_driver +#define BROADCAST_CHANNEL 129 #endif /* PROJECT_CONF_H_ */ diff --git a/examples/zolertia/zoul/power-mgmt/test-power-mgmt.c b/examples/zolertia/zoul/test-power-mgmt.c similarity index 85% rename from examples/zolertia/zoul/power-mgmt/test-power-mgmt.c rename to examples/zolertia/zoul/test-power-mgmt.c index aefc718bd..1b0690bdb 100644 --- a/examples/zolertia/zoul/power-mgmt/test-power-mgmt.c +++ b/examples/zolertia/zoul/test-power-mgmt.c @@ -29,11 +29,9 @@ */ /*---------------------------------------------------------------------------*/ /** - * \addtogroup remote-examples + * \addtogroup remote-power-management-test * @{ * - * \defgroup remote-power-management-test RE-Mote power management example - * * Test the RE-Mote's power management features, shutdown mode and battery * management * @@ -53,6 +51,8 @@ #include "dev/gpio.h" #include "lib/list.h" #include "power-mgmt.h" +#include "net/rime/broadcast.h" + #include #include /*---------------------------------------------------------------------------*/ @@ -65,6 +65,17 @@ AUTOSTART_PROCESSES(&test_remote_pm); /*---------------------------------------------------------------------------*/ static struct etimer et; /*---------------------------------------------------------------------------*/ +static void +broadcast_recv(struct broadcast_conn *c, const linkaddr_t *from) +{ + leds_toggle(LEDS_BLUE); + printf("*** Received %u bytes from %u:%u: '0x%04x'\n", packetbuf_datalen(), + from->u8[0], from->u8[1], *(uint16_t *)packetbuf_dataptr()); +} +/*---------------------------------------------------------------------------*/ +static const struct broadcast_callbacks bc_rx = { broadcast_recv }; +static struct broadcast_conn bc; +/*---------------------------------------------------------------------------*/ static char * print_pm(uint8_t state) { @@ -173,23 +184,37 @@ PROCESS_THREAD(test_remote_pm, ev, data) * disconnect the USB cable and power only with the external battery. If * something fails, then you should not see the red LED blinking */ - aux = 0; + aux = ENTER_SHUTDOWN_COUNT; + /* Open the broadcast channel */ + broadcast_open(&bc, BROADCAST_CHANNEL, &bc_rx); + + /* Send a message */ + packetbuf_copyfrom(&aux, sizeof(aux)); + broadcast_send(&bc); + + /* And wait a few seconds before going to sleep */ while(1){ etimer_set(&et, CLOCK_SECOND); PROCESS_WAIT_EVENT(); - aux++; - /* Enter shutdown mode before the shutdown period (1 min) expires */ - if((aux % ENTER_SHUTDOWN_COUNT) == 0) { + /* Enter shutdown mode before the shutdown period (1 min default) expires */ + if(!aux) { /* Say goodnight */ PM_SHUTDOWN_NOW; printf("Goodnight!\n"); + PROCESS_EXIT(); } + aux--; leds_toggle(LEDS_RED); } PROCESS_END(); } +/*---------------------------------------------------------------------------*/ +/** + * @} + * @} + */ diff --git a/examples/zolertia/zoul/zoul-demo.c b/examples/zolertia/zoul/zoul-demo.c index a42ef2507..ff31d5ef9 100644 --- a/examples/zolertia/zoul/zoul-demo.c +++ b/examples/zolertia/zoul/zoul-demo.c @@ -73,6 +73,7 @@ #include "dev/watchdog.h" #include "dev/serial-line.h" #include "dev/sys-ctrl.h" +#include "net/netstack.h" #include "net/rime/broadcast.h" #include @@ -86,8 +87,6 @@ #define LEDS_SERIAL_IN LEDS_GREEN #define LEDS_REBOOT LEDS_ALL #define LEDS_RF_RX (LEDS_YELLOW | LEDS_RED) -#define BROADCAST_CHANNEL 129 - #define BUTTON_PRESS_EVENT_INTERVAL (CLOCK_SECOND) /*---------------------------------------------------------------------------*/ static struct etimer et; @@ -121,6 +120,10 @@ PROCESS_THREAD(zoul_demo_process, ev, data) PROCESS_BEGIN(); counter = 0; + + /* Disable the radio duty cycle and keep the radio on */ + NETSTACK_MAC.off(1); + broadcast_open(&bc, BROADCAST_CHANNEL, &bc_rx); /* Configure the user button */