diff --git a/examples/esb/Makefile b/examples/esb/Makefile deleted file mode 100644 index c33cf63e2..000000000 --- a/examples/esb/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -CONTIKI_PROJECT = blinker -all: $(CONTIKI_PROJECT) - -CONTIKI = ../.. -include $(CONTIKI)/Makefile.include diff --git a/examples/esb/Makefile.target b/examples/esb/Makefile.target deleted file mode 100644 index 5718cd682..000000000 --- a/examples/esb/Makefile.target +++ /dev/null @@ -1 +0,0 @@ -TARGET = esb diff --git a/examples/esb/beeper.c b/examples/esb/beeper.c deleted file mode 100644 index d5aa55754..000000000 --- a/examples/esb/beeper.c +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ -#include "contiki-esb.h" - -PROCESS(beeper_process, "Beeper"); - -AUTOSTART_PROCESSES(&beeper_process); - -static struct etimer etimer; - -static struct pt beeper_pt; - -static -PT_THREAD(beeper_thread(struct pt *pt)) -{ - PT_BEGIN(pt); - - while(1) { - PT_WAIT_UNTIL(pt, etimer_expired(&etimer)); - etimer_reset(&etimer); - leds_invert(LEDS_RED); - beep(); - - PT_WAIT_UNTIL(pt, etimer_expired(&etimer)); - etimer_reset(&etimer); - leds_invert(LEDS_RED); - } - - PT_END(pt); -} - -PROCESS_THREAD(beeper_process, ev, data) -{ - PROCESS_EXITHANDLER(goto exit); - PROCESS_BEGIN(); - - etimer_set(&etimer, CLOCK_SECOND / 2); - PT_INIT(&beeper_pt); - - button_sensor.configure(SENSORS_ACTIVE, 1); - - while(1) { - - beeper_thread(&beeper_pt); - - PROCESS_WAIT_EVENT(); - - if(ev == sensors_event && data == &button_sensor) { - leds_invert(LEDS_YELLOW); - } - - } - exit: - ; - PROCESS_END(); -} diff --git a/examples/esb/blinker.c b/examples/esb/blinker.c deleted file mode 100644 index 5288e5f16..000000000 --- a/examples/esb/blinker.c +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2006, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * - * ----------------------------------------------------------------- - * - * Author : Adam Dunkels, Joakim Eriksson, Niclas Finne - * Created : 2006-08-28 - * Updated : $Date: 2010/01/14 18:18:51 $ - * $Revision: 1.3 $ - */ - -#include "contiki-esb.h" - -PROCESS(blinker_process, "Blinker"); - -AUTOSTART_PROCESSES(&blinker_process); - -PROCESS_THREAD(blinker_process, ev, data) -{ - static struct etimer etimer, pir_timer, vib_timer; - static int on = 0; - PROCESS_EXITHANDLER(goto exit); - PROCESS_BEGIN(); - - etimer_stop(&pir_timer); - etimer_stop(&vib_timer); - etimer_set(&etimer, CLOCK_SECOND * 4); - button_sensor.configure(SENSORS_ACTIVE, 1); - vib_sensor.configure(SENSORS_ACTIVE, 1); - pir_sensor.configure(SENSORS_ACTIVE, 1); - - while(1) { - - PROCESS_WAIT_EVENT(); - - if(ev == sensors_event) { - if(data == &vib_sensor) { - if(etimer_expired(&vib_timer)) { - leds_on(LEDS_RED); - etimer_set(&vib_timer, CLOCK_SECOND); - } else { - leds_off(LEDS_RED); - etimer_stop(&vib_timer); - } - beep(); - - } else if(data == &pir_sensor) { - leds_on(LEDS_YELLOW); - etimer_set(&pir_timer, CLOCK_SECOND); - - } else if(data == &button_sensor) { - beep_beep(100); - } - - } else if(ev == PROCESS_EVENT_TIMER) { - if(data == &etimer) { - if(on) { - etimer_set(&etimer, CLOCK_SECOND * 4); - leds_off(LEDS_GREEN); - } else { - etimer_set(&etimer, CLOCK_SECOND / 2); - leds_on(LEDS_GREEN); - } - on = !on; - } else if(data == &pir_timer) { - leds_off(LEDS_YELLOW); - } else if(data == &vib_timer) { - leds_off(LEDS_RED); - } - } - } - - exit: - leds_off(LEDS_ALL); - PROCESS_END(); -} diff --git a/examples/esb/fft-test.c b/examples/esb/fft-test.c deleted file mode 100644 index 10fd99ab4..000000000 --- a/examples/esb/fft-test.c +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (c) 2008, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * - * ----------------------------------------------------------------- - * fft-test - a test program that use the sound sensor for sampling - * some data and then performs an FFT on that. Then flashes leds based - * on energy-level and position of highest frequency band. - * - * Author : Joakim Eriksson - * Created : 2008-04-04 - * Updated : $Date: 2010/01/14 18:18:51 $ - * $Revision: 1.3 $ - */ - -#include "contiki-esb.h" -#include "dev/sound-sensor.h" -#include -#include "lib/ifft.h" - -#define FFT_TEST_SIZE 128 - -PROCESS(fft_process, "Fft"); - -AUTOSTART_PROCESSES(&fft_process); - -PROCESS_THREAD(fft_process, ev, data) -{ - static struct etimer etimer; - static int on = 0; - static int i = 0; - static int mode = 0; - static int16_t fftBuf[FFT_TEST_SIZE]; - static int16_t tmpBuf[FFT_TEST_SIZE]; - static int max_value = 0; - static int max_pos = 0; - - PROCESS_EXITHANDLER(goto exit); - PROCESS_BEGIN(); - - etimer_set(&etimer, CLOCK_SECOND * 4); - button_sensor.configure(SENSORS_ACTIVE, 1); - /* start and configure the sound sensor for sampling */ - sound_sensor.configure(SENSORS_ACTIVE, 1); - sound_sensor_set_buffer(fftBuf, FFT_TEST_SIZE, 1); - while(1) { - - PROCESS_WAIT_EVENT(); - - if(ev == sensors_event) { - if(data == &button_sensor) { - beep_beep(100); - mode = !mode; - } else if(data == &sound_sensor) { - for(i = 0; i < FFT_TEST_SIZE; i++) { - fftBuf[i] = -128 + (fftBuf[i] >> 4); - if(!mode) { - /* just print the samples if mode = 0 */ - if(i > 0) { - printf(" "); - } - printf("%d", fftBuf[i]); - } - } - if (mode) { - /* Calculate fft, print result, and find index of - highest energy level */ - ifft(fftBuf, tmpBuf, FFT_TEST_SIZE); - max_value = 0; - max_pos = 0; - for (i = 0; i < FFT_TEST_SIZE/2; i++) { - if(i > 0) { - printf(" "); - } - printf("%d", fftBuf[i]); - - if(max_value < fftBuf[i]) { - max_value = fftBuf[i]; - max_pos = i; - } - } - /* flash leds based on energy level and position of max */ - if(max_value < 400 || max_pos < 2) { - leds_off(LEDS_ALL); - } else if (max_pos > 1 && max_pos < 15) { - leds_on(LEDS_GREEN); - } else if(max_pos < 25) { - leds_on(LEDS_YELLOW); - } else { - leds_on(LEDS_RED); - } - } - printf("\n"); - printf("#Maxval: %d, maxpos: %d\n", max_value, max_pos); - } - } else if(ev == PROCESS_EVENT_TIMER) { - if(data == &etimer) { - if(on) { - sound_sensor_start_sample(); - leds_off(LEDS_ALL); - } - etimer_set(&etimer, CLOCK_SECOND / 2); - on = !on; - } - } - } - - exit: - leds_off(LEDS_ALL); - PROCESS_END(); -} diff --git a/examples/esb/radio-test.c b/examples/esb/radio-test.c deleted file mode 100644 index a0b0a599b..000000000 --- a/examples/esb/radio-test.c +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (c) 2007, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * - * ----------------------------------------------------------------- - * - * Author : Adam Dunkels, Joakim Eriksson, Niclas Finne - * Created : 2006-03-07 - * Updated : $Date: 2009/03/12 21:58:21 $ - * $Revision: 1.2 $ - * - * Simple application to indicate connectivity between two nodes: - * - * - Red led indicates a packet sent via radio (one packet sent each second) - * - Yellow led indicates that this node can hear the other node but not - * necessary vice versa (unidirectional communication). - * - Green led indicates that both nodes can communicate with each - * other (bidirectional communication) - */ - -#include "contiki.h" -#include "net/rime.h" -#include "dev/leds.h" -#include - -PROCESS(radio_test_process, "Radio test"); -AUTOSTART_PROCESSES(&radio_test_process); - -#define ON 1 -#define OFF 0 - -#define HEADER "RTST" -#define PACKET_SIZE 20 -#define PORT 9345 - -struct indicator { - int onoff; - int led; - clock_time_t interval; - struct etimer timer; -}; -static struct etimer send_timer; -static struct indicator recv, other, flash; - -/*---------------------------------------------------------------------*/ -static void -set(struct indicator *indicator, int onoff) { - if(indicator->onoff ^ onoff) { - indicator->onoff = onoff; - if(onoff) { - leds_on(indicator->led); - } else { - leds_off(indicator->led); - } - } - if(onoff) { - etimer_set(&indicator->timer, indicator->interval); - } -} -/*---------------------------------------------------------------------------*/ -static void -abc_recv(struct abc_conn *c) -{ - /* packet received */ - if(packetbuf_datalen() < PACKET_SIZE - || strncmp((char *)packetbuf_dataptr(), HEADER, sizeof(HEADER))) { - /* invalid message */ - leds_blink(); - - } else { - PROCESS_CONTEXT_BEGIN(&radio_test_process); - set(&recv, ON); - set(&other, ((char *)packetbuf_dataptr())[sizeof(HEADER)] ? ON : OFF); - - /* synchronize the sending to keep the nodes from sending - simultaneously */ - - etimer_set(&send_timer, CLOCK_SECOND); - etimer_adjust(&send_timer, - (int) (CLOCK_SECOND >> 1)); - PROCESS_CONTEXT_END(&radio_test_process); - } -} -static const struct abc_callbacks abc_call = {abc_recv}; -static struct abc_conn abc; -/*---------------------------------------------------------------------*/ -PROCESS_THREAD(radio_test_process, ev, data) -{ - PROCESS_BEGIN(); - - /* Initialize the indicators */ - recv.onoff = other.onoff = flash.onoff = OFF; - recv.interval = other.interval = CLOCK_SECOND; - flash.interval = 1; - flash.led = LEDS_RED; - recv.led = LEDS_YELLOW; - other.led = LEDS_GREEN; - - abc_open(&abc, PORT, &abc_call); - etimer_set(&send_timer, CLOCK_SECOND); - - while(1) { - PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_TIMER); - - if(data == &send_timer) { - etimer_reset(&send_timer); - - /* send packet */ - packetbuf_copyfrom(HEADER, sizeof(HEADER)); - ((char *)packetbuf_dataptr())[sizeof(HEADER)] = recv.onoff; - /* send arbitrary data to fill the packet size */ - packetbuf_set_datalen(PACKET_SIZE); - set(&flash, ON); - abc_send(&abc); - - } else if(data == &other.timer) { - set(&other, OFF); - - } else if(data == &recv.timer) { - set(&recv, OFF); - - } else if(data == &flash.timer) { - set(&flash, OFF); - } - } - PROCESS_END(); -} -/*---------------------------------------------------------------------*/