Merge pull request #436 from adamdunkels/push/cleanup-examples

A first cleanup of the examples/ directory
This commit is contained in:
Nicolas Tsiftes 2013-11-19 09:41:19 -08:00
commit 5c7b61e939
18 changed files with 0 additions and 1118 deletions

View File

@ -1,5 +0,0 @@
CONTIKI_PROJECT = blinker
all: $(CONTIKI_PROJECT)
CONTIKI = ../..
include $(CONTIKI)/Makefile.include

View File

@ -1 +0,0 @@
TARGET = esb

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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 <stdio.h>
#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();
}

View File

@ -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 <string.h>
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();
}
/*---------------------------------------------------------------------*/

View File

@ -1,9 +0,0 @@
all:
make -f Makefile.ipso TARGET=avr-raven ipso.elf
avr-objcopy -O ihex -R .eeprom ipso.elf ipso.hex
avr-size -C ipso.elf
clean:
make -f Makefile.ipso TARGET=avr-raven clean
rm symbols.c symbols.h ipso.elf ipso.hex
rm -rf obj_avr-raven

View File

@ -1,10 +0,0 @@
all: ipso
APPS=raven-ipso
TARGET=avr-raven
UIP_CONF_IPV6=1
CONTIKI = ../..
include $(CONTIKI)/Makefile.include

View File

@ -1,44 +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.
*
* This file is part of the Contiki operating system.
*
*/
#include "contiki.h"
/*---------------------------------------------------------------------------*/
PROCESS(init_stack_process, "Init stack process");
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(init_stack_process, ev, data)
{
PROCESS_BEGIN();
PROCESS_END();
}
/*---------------------------------------------------------------------------*/
AUTOSTART_PROCESSES(&init_stack_process);
/*---------------------------------------------------------------------------*/

View File

@ -1,24 +0,0 @@
CONTIKI_PROJECT = jcreate-shell
all: $(CONTIKI_PROJECT)
APPS = serial-shell
CONTIKI = ../..
jcreate-blink:
(echo; sleep 4; echo "~K"; sleep 4; \
echo "repeat 0 0 { acc | leds 1 } &"; sleep 4) | make login
%.shell-upload: %.ce
(echo; sleep 4; echo "~K"; sleep 4; \
echo "dec64 | write $*.ce | null"; sleep 4; \
../../tools/base64-encode < $<; sleep 4; \
echo "~K"; sleep 4; \
echo "read $*.ce | size"; sleep 4) | make login
%.netsend: %.shell-upload
(echo; sleep 4; echo "~K"; sleep 4; \
echo "netcmd { recvnetfile | write $*.ce | size | send } "; sleep 4; \
echo "netfile $*.ce"; sleep 4;\
echo "collect | binprint"; sleep 40) | make login
include $(CONTIKI)/Makefile.include

View File

@ -1 +0,0 @@
TARGET = jcreate

View File

@ -1,176 +0,0 @@
/*
* Copyright (c) 2009, 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.
*
*/
/**
* \file
* Example program that displays the number of neighbors on the JCreate LEDs
* \author
* Adam Dunkels <adam@sics.se>
*/
#include "contiki.h"
#include "contiki-net.h"
#include "shell.h"
#include "dev/acc-sensor.h"
#include "net/mac/xmac.h"
#include "dev/leds.h"
#include <stdio.h>
#define MAX_NEIGHBORS_SEEN 8
#define NEIGHBOR_TIMEOUT 4 * CLOCK_SECOND
static struct announcement announcement;
struct neighbor_entry {
struct neighbor_entry *next;
rimeaddr_t addr;
struct ctimer ctimer;
};
LIST(neighbor_table);
MEMB(neighbor_mem, struct neighbor_entry, MAX_NEIGHBORS_SEEN);
/*---------------------------------------------------------------------------*/
PROCESS(announce_blink_process, "Annouce blink");
AUTOSTART_PROCESSES(&announce_blink_process);
/*---------------------------------------------------------------------------*/
/*
* This function takes the length of the neighbor table list and
* displays it on the on-board LEDs.
*/
static void
show_leds(void)
{
int val, i;
int num;
num = list_length(neighbor_table);
val = 1;
for(i = 0; i < num; ++i) {
val |= (val << 1);
}
val >>= 1;
leds_on(val & 0xff);
leds_off(~(val & 0xff));
}
/*---------------------------------------------------------------------------*/
static void
remove_neighbor(void *dummy)
{
struct neighbor_entry *e = dummy;
list_remove(neighbor_table, e);
memb_free(&neighbor_mem, e);
show_leds();
printf("%d.%d: removed %d.%d\n",
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
e->addr.u8[0], e->addr.u8[1]);
}
/*---------------------------------------------------------------------------*/
static void
received_announcement(struct announcement *a, const rimeaddr_t *from,
uint16_t id, uint16_t value)
{
struct neighbor_entry *e;
printf("%d.%d: announcement from neighbor %d.%d, id %d, value %d\n",
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
from->u8[0], from->u8[1],
id, value);
for(e = list_head(neighbor_table); e != NULL; e = e->next) {
if(rimeaddr_cmp(from, &e->addr)) {
ctimer_set(&e->ctimer, NEIGHBOR_TIMEOUT, remove_neighbor, e);
show_leds();
return;
}
}
e = memb_alloc(&neighbor_mem);
if(e != NULL) {
rimeaddr_copy(&e->addr, from);
list_add(neighbor_table, e);
ctimer_set(&e->ctimer, NEIGHBOR_TIMEOUT, remove_neighbor, e);
} else {
}
show_leds();
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(announce_blink_process, ev, data)
{
PROCESS_BEGIN();
announcement_register(&announcement, 80, received_announcement);
list_init(neighbor_table);
memb_init(&neighbor_mem);
{
int i;
for(i = 0; i < 10; ++i) {
rimeaddr_t r;
r.u8[0] = r.u8[1] = i;
received_announcement(NULL, &r, 0, 0);
received_announcement(NULL, &r, 0, 0);
}
}
SENSORS_ACTIVATE(acc_sensor);
/* Lower the transmission power for the announcements so that only
close-range neighbors are noticed. (Makes for a nicer visual
effect.) */
xmac_set_announcement_radio_txpower(1);
while(1) {
static struct etimer e;
static uint16_t last_value;
etimer_set(&e, CLOCK_SECOND / 8);
PROCESS_WAIT_EVENT();
if(acc_sensor.value(1) / 256 != last_value) {
last_value = acc_sensor.value(1) / 256;
announcement_listen(1);
}
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View File

@ -1,87 +0,0 @@
/*
* Copyright (c) 2010, 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.
*
*/
/**
* \file
* A very simple Contiki application showing how to use ext-sensor
* In this case a i-Snail current sensor for 10A is used to measure
* current.
* \author
* Joakim Eriksson <joakime@sics.se>
*/
#include "contiki.h"
#include "dev/leds.h"
#include "dev/ext-sensor.h"
#include <stdio.h>
/*---------------------------------------------------------------------------*/
PROCESS(ext_sensor_process, "ext-sensor process");
AUTOSTART_PROCESSES(&ext_sensor_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(ext_sensor_process, ev, data)
{
static struct etimer et;
static long maValue;
static long maSum;
static int time;
PROCESS_BEGIN();
SENSORS_ACTIVATE(ext_sensor);
leds_invert(LEDS_ALL);
etimer_set(&et, CLOCK_SECOND);
while(1) {
leds_invert(LEDS_ALL);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
etimer_reset(&et);
leds_invert(LEDS_ALL);
/* the max value of the i-Snail sensor is 10 Ampere (=> ~5V) */
/* and we are using the 2.5 V reference voltage which */
/* means that 5 Ampere will make the sensor max-out. */
/* => 5 Ampere will be 4095 in the sensor ADC register */
maValue = (ext_sensor.value(ADC0) * 5000L) / 4095;
maSum += maValue;
time++;
printf("Measured ext1 %d %ld mA %ld W %ld Wh %d (s)\n",
ext_sensor.value(ADC0), maValue, (maValue * 230L) / 1000,
(maSum * 230L) / (1000L * 60 * 60), time);
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View File

@ -1,227 +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.
*
* This file is part of the Contiki operating system.
*
*/
/**
* \file
* Jcreate-specific Contiki shell
* \author
* Adam Dunkels <adam@sics.se>
*/
#include "contiki.h"
#include "shell.h"
#include "serial-shell.h"
#include "dev/leds.h"
#include "dev/acc-sensor.h"
#include <stdio.h>
#include <string.h>
#include <io.h>
#include <signal.h>
/*---------------------------------------------------------------------------*/
PROCESS(shell_poke_process, "poke");
SHELL_COMMAND(poke_command,
"poke",
"poke <address> <byte>: write byte <byte> to address <address>",
&shell_poke_process);
PROCESS(shell_peek_process, "peek");
SHELL_COMMAND(peek_command,
"peek",
"peek <address>: read a byte from address <address>",
&shell_peek_process);
PROCESS(shell_acc_process, "acc");
SHELL_COMMAND(acc_command,
"acc",
"acc: print out accelerometer data",
&shell_acc_process);
PROCESS(shell_leds_process, "leds");
SHELL_COMMAND(leds_command,
"leds",
"leds: set LEDs",
&shell_leds_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_poke_process, ev, data)
{
uint8_t *address;
uint8_t byte;
const char *args, *next;
PROCESS_BEGIN();
args = data;
if(args == NULL) {
shell_output_str(&poke_command, "usage 0", "");
PROCESS_EXIT();
}
address = (uint8_t *)(int)shell_strtolong(args, &next);
if(next == args) {
shell_output_str(&poke_command, "usage 1", "");
PROCESS_EXIT();
}
args = next;
byte = shell_strtolong(args, &next);
if(next == args) {
shell_output_str(&poke_command, "usage 2", "");
PROCESS_EXIT();
}
printf("address %p byte 0x%02x\n", address, byte);
*address = byte;
PROCESS_END();
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_peek_process, ev, data)
{
uint8_t *address;
const char *args, *next;
char buf[32];
PROCESS_BEGIN();
args = data;
if(args == NULL) {
shell_output_str(&peek_command, "usage 0", "");
PROCESS_EXIT();
}
address = (uint8_t *)(int)shell_strtolong(args, &next);
if(next == args) {
shell_output_str(&peek_command, "usage 1", "");
PROCESS_EXIT();
}
snprintf(buf, sizeof(buf), "0x%02x", *address);
shell_output_str(&peek_command, buf, "");
PROCESS_END();
}
/*---------------------------------------------------------------------------*/
struct acc_msg {
uint16_t len;
uint16_t acc[4];
};
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_acc_process, ev, data)
{
struct acc_msg msg;
int i;
PROCESS_BEGIN();
msg.len = 1;
for(i = 0; i < 4; ++i) {
msg.acc[i] = acc_sensor.value(i);
}
shell_output(&acc_command, &msg, sizeof(msg), "", 0);
PROCESS_END();
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_leds_process, ev, data)
{
struct acc_msg *msg;
struct shell_input *input;
int val, i;
static int num;
const char *args, *next;
PROCESS_BEGIN();
args = data;
if(args == NULL) {
shell_output_str(&acc_command, "usage 0", "");
PROCESS_EXIT();
}
num = shell_strtolong(args, &next);
if(next == args) {
shell_output_str(&acc_command, "usage 1", "");
PROCESS_EXIT();
}
PROCESS_WAIT_EVENT_UNTIL(ev == shell_event_input);
input = data;
msg = (struct acc_msg *)input->data1;
val = 0;
for(i = 0; i < msg->acc[num] >> 9; ++i) {
val = (val << 1) | 1;
}
leds_on(val & 0xff);
leds_off(~(val & 0xff));
PROCESS_END();
}
/*---------------------------------------------------------------------------*/
PROCESS(sky_shell_process, "Sky Contiki shell");
AUTOSTART_PROCESSES(&sky_shell_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(sky_shell_process, ev, data)
{
PROCESS_BEGIN();
serial_shell_init();
shell_blink_init();
shell_file_init();
shell_coffee_init();
shell_ps_init();
shell_reboot_init();
shell_rime_init();
/* shell_rime_debug_init();*/
shell_rime_netcmd_init();
/* shell_rime_ping_init(); */
shell_rime_neighbors_init();
shell_rime_sendcmd_init();
/* shell_rime_sniff_init();*/
shell_rime_unicast_init();
/*shell_sky_init();*/
shell_text_init();
shell_time_init();
SENSORS_ACTIVATE(acc_sensor);
shell_register_command(&acc_command);
shell_register_command(&poke_command);
shell_register_command(&peek_command);
shell_register_command(&leds_command);
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View File

@ -1,6 +0,0 @@
all: empty
UIP_CONF_IPV6=1
CONTIKI = ../..
include $(CONTIKI)/Makefile.include

View File

@ -1 +0,0 @@
TARGET = minimal-net

View File

@ -1,8 +0,0 @@
New IPv6
========
This example just runs the IPv6 stack without any application on the top.
To test the stack you can, for example, run a ping6 command:
ping6 -I tap0 ff02:0000:0000:0000:0000:0001:ff00:0232

View File

@ -1,44 +0,0 @@
/*
* 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.
*
* No application for this example, this file is a place holder
*/
#include "contiki.h"
//#include <stdio.h>
/*---------------------------------------------------------------------------*/
PROCESS(init_stack_process, "Init stack process");
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(init_stack_process, ev, data)
{
PROCESS_BEGIN();
//printf("WARNING: Running Contiki without application\n");
PROCESS_END();
}
/*---------------------------------------------------------------------------*/
AUTOSTART_PROCESSES(&init_stack_process);
/*---------------------------------------------------------------------------*/