Removed obsolete platforms
This commit is contained in:
parent
0a428c9489
commit
66c280039b
71 changed files with 0 additions and 7020 deletions
|
@ -1,121 +0,0 @@
|
|||
# $Id: Makefile,v 1.7 2007/05/21 14:30:52 bg- Exp $
|
||||
#
|
||||
# This makefile requires GNU make!
|
||||
|
||||
LIB = libcontiki.a
|
||||
KERNELS = gateway.ihex
|
||||
PROGS = #loadable_prg.ko udpsend.ko udprecv.ko
|
||||
TOOLS = tunslip scat codeprop
|
||||
|
||||
all: $(LIB) $(KERNELS) $(PROGS) $(TOOLS)
|
||||
|
||||
loadable_prg.ko: loadable_prg.o
|
||||
udpsend.ko: udpsend.o
|
||||
udprecv.ko: udprecv.o
|
||||
test.ko: test.o
|
||||
|
||||
gateway.out: gateway.o $(LIB)
|
||||
client.out: client.o $(LIB)
|
||||
dhclient.out: dhclient.o $(LIB)
|
||||
|
||||
TOP=../..
|
||||
INCDIRS = -I. -I$(TOP)/cpu/avr -I$(TOP)/core -I$(TOP)/apps
|
||||
SRCDIRS = dev $(TOP)/cpu/avr $(TOP)/cpu/avr/dev ${addprefix $(TOP)/core/,sys dev net lib loader} $(TOP)/apps/codeprop
|
||||
|
||||
MCU=atmega128
|
||||
|
||||
ARCH=avr.o spi.o qleds.o rom.o xmem.o cle_avr.o
|
||||
SYSTEM=process.o procinit.o service.o clock.o etimer.o timer.o \
|
||||
sym.o cle.o elfloader_compat.o
|
||||
UIP=uip.o uiplib.o tcpip.o uip-fw.o uip-fw-drv.o uipbuf.o \
|
||||
tcpdump.o psock.o dhcpc.o uaodv.o uaodv-rt.o uip-udp-packet.o
|
||||
UIPDRIVERS=slip.o slip_uart1.o \
|
||||
cc2420.o cc2420_spi.o cc2420_send_ip.o cc2420_send_uaodv.o
|
||||
LIBS=memb.o list.o rand.o assert.o crtk.o
|
||||
SYSAPPS=tcp_loader.o
|
||||
LIBFILES=$(SYSTEM) $(ARCH) $(UIP) $(UIPDRIVERS) $(LIBS) $(SYSAPPS)
|
||||
|
||||
MKNMLIST=awk -f $(TOP)/tools/mknmlist-ansi
|
||||
CP=cp
|
||||
LIBC=-lgcc -lc -lgcc
|
||||
CC=avr-gcc
|
||||
LD=avr-ld
|
||||
AS=avr-as
|
||||
NM=avr-nm
|
||||
OBJCOPY=avr-objcopy
|
||||
STRIP=avr-strip
|
||||
AR=avr-ar
|
||||
RANLIB=avr-ranlib
|
||||
BSL=avrdude
|
||||
CFLAGS=-mmcu=$(MCU) $(INCDIRS) -Wall -Os
|
||||
LDFLAGS=-mmcu=$(MCU) -Wl,--section-start=.bootloader=$(BOOTLOADER_START)
|
||||
|
||||
# Check fuse high byte, bits BOOTSZ0 and BOOTSZ1.
|
||||
BOOTLOADER_START=0x1fc00
|
||||
|
||||
# Setup directory search path for source files
|
||||
vpath %.c $(SRCDIRS) ${filter-out CVS,${wildcard labs/*}}
|
||||
|
||||
# Set COM port if not already set.
|
||||
# DOS: 1 => COM2, 2 => COM3, etc.
|
||||
# Linux: /dev/ttyUSB0, /dev/ttyUSB1, etc.
|
||||
# FreeBSD 6.2: /dev/cuaU0, /dev/cuaU1, etc.
|
||||
ifndef COMPORT
|
||||
COMPORT := /dev/ttyUSB0
|
||||
endif
|
||||
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) -c $< -o $(notdir $(<:.c=.o))
|
||||
|
||||
# Combine several .o:s to one .ko and put COMMONs into the BSS segment
|
||||
%.ko:
|
||||
$(LD) -r -dc --strip-all --unresolved-symbols=ignore-in-object-files $^ -o $@
|
||||
|
||||
%.ihex: %.out
|
||||
$(OBJCOPY) $^ -O ihex $@
|
||||
|
||||
#%.out:
|
||||
# $(if $^,$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^,$(error "NO TARGET $@"))
|
||||
|
||||
# Add a namelist to the kernel
|
||||
%.out: $^
|
||||
: | $(MKNMLIST) > $@_tmp.c && mv $@_tmp.c $@_nm.c
|
||||
$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^ $(LIBC) $@_nm.c
|
||||
$(NM) $@ | $(MKNMLIST) > $@_tmp.c && mv $@_tmp.c $@_nm.c
|
||||
$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^ $(LIBC) $@_nm.c
|
||||
|
||||
%.u: %.ihex
|
||||
$(BSL) -p $(MCU) -P $(COMPORT) -c stk500 -U flash:w:$<
|
||||
|
||||
$(LIB): $(LIBFILES)
|
||||
$(AR) rcf $@ $^
|
||||
$(RANLIB) $@
|
||||
|
||||
codeprop: $(TOP)/tools/codeprop.c
|
||||
cc -g -Wall $< -o $@
|
||||
|
||||
tunslip: $(TOP)/tools/tunslip.c
|
||||
cc -g -Wall -DBAUDRATE="B38400" $< -o $@
|
||||
|
||||
scat: $(TOP)/tools/scat.c
|
||||
cc -g -Wall -DBAUDRATE="B38400" $< -o $@
|
||||
|
||||
### TEST ###
|
||||
|
||||
test.out: test.o $(LIB)
|
||||
$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^
|
||||
|
||||
depend: $(LIBFILES:.o=.c)
|
||||
-$(CC) $(CCDEPFLAGS) -MM $(CFLAGS) $(INCDIRS) $^ *.c >Makefile.depend
|
||||
|
||||
tags: $(LIBFILES:.o=.c)
|
||||
etags $^
|
||||
|
||||
clean:
|
||||
rm -f *.o *.ko *~ *.core *.out *.ihex *_nm.c
|
||||
rm -f $(LIB) $(KERNELS) $(TOOLS)
|
||||
|
||||
.PHONY: all
|
||||
|
||||
-include Makefile.depend
|
|
@ -1,162 +0,0 @@
|
|||
/* -*- C -*- */
|
||||
/* @(#)$Id: contiki-conf.h,v 1.5 2010/06/22 06:39:44 joxe Exp $ */
|
||||
|
||||
#ifndef CONTIKI_CONF_H
|
||||
#define CONTIKI_CONF_H
|
||||
|
||||
#include <avr/interrupt.h>
|
||||
|
||||
#define HAVE_STDINT_H
|
||||
#include "avrdef.h"
|
||||
|
||||
/* #define CB_GATEWAY */
|
||||
|
||||
#define CCIF
|
||||
#define CLIF
|
||||
|
||||
#define AODV_COMPLIANCE
|
||||
#define AODV_NUM_RT_ENTRIES 32
|
||||
|
||||
void clock_delay(unsigned int us2);
|
||||
void clock_wait(int ms10);
|
||||
void clock_set_seconds(unsigned long s);
|
||||
unsigned long clock_seconds(void);
|
||||
|
||||
#define WITH_UIP 1
|
||||
#define WITH_ASCII 1
|
||||
|
||||
#define PROCESS_CONF_FASTPOLL 4
|
||||
|
||||
/* Our clock resolution, this is the same as Unix HZ. */
|
||||
/* Fix clock.c XXX/bg */
|
||||
#define CLOCK_CONF_SECOND 62
|
||||
|
||||
/* CPU target speed in Hz */
|
||||
#define F_CPU 8000000L
|
||||
|
||||
/* The +1 and divide by 2 is to achieve rounding. */
|
||||
#define BAUD2UBR(baud) ((u16_t)((F_CPU/baud/8uL + 1)/2 - 1))
|
||||
|
||||
/* UART configs */
|
||||
//#define MCU_MHZ 8
|
||||
//#define MCU atmega128
|
||||
//#define SLIP_PORT RS232_PORT_1
|
||||
|
||||
|
||||
#define UIP_CONF_DHCP_LIGHT
|
||||
#define UIP_CONF_LLH_LEN 0
|
||||
#define UIP_CONF_BUFFER_SIZE 116
|
||||
#define UIP_CONF_RECEIVE_WINDOW (UIP_CONF_BUFFER_SIZE - 40)
|
||||
#define UIP_CONF_MAX_CONNECTIONS 4
|
||||
#define UIP_CONF_MAX_LISTENPORTS 8
|
||||
#define UIP_CONF_UDP_CONNS 12
|
||||
#define UIP_CONF_FWCACHE_SIZE 30
|
||||
#define UIP_CONF_BROADCAST 1
|
||||
//#define UIP_ARCH_IPCHKSUM 1
|
||||
#define UIP_CONF_UDP_CHECKSUMS 1
|
||||
#define UIP_CONF_PINGADDRCONF 0
|
||||
#define UIP_CONF_LOGGING 0
|
||||
|
||||
/*
|
||||
* Definitions below are dictated by the hardware and not really
|
||||
* changeable!
|
||||
*/
|
||||
|
||||
#ifdef CB_GATEWAY
|
||||
/* LED port E */
|
||||
#define LEDS_CONF_GREEN _BV(2) /* PE.2 - Output */
|
||||
#define LEDS_CONF_YELLOW _BV(3) /* PE.3 - Output */
|
||||
#else
|
||||
#define LEDS_ORANGE 8
|
||||
/* LED port B */
|
||||
#define LEDS_CONF_ORANGE _BV(4) /* PB.4 - Output */
|
||||
#define LEDS_CONF_GREEN _BV(7) /* PB.7 - Output */
|
||||
/* LED port E */
|
||||
#define LEDS_CONF_RED _BV(3) /* PE.3 - Output */
|
||||
#define LEDS_CONF_YELLOW _BV(4) /* PE.4 - Output */
|
||||
#endif
|
||||
|
||||
typedef u16_t uip_stats_t;
|
||||
typedef u16_t clock_time_t;
|
||||
|
||||
typedef u32_t off_t;
|
||||
#define ROM_ERASE_UNIT_SIZE SPM_PAGESIZE
|
||||
#define XMEM_ERASE_UNIT_SIZE 8
|
||||
|
||||
/* Use the first 64k of external flash for codeprop. */
|
||||
#define EEPROMFS_ADDR_CODEPROP (128 * XMEM_ERASE_UNIT_SIZE)
|
||||
|
||||
#define CC2420_RADIO
|
||||
/* LOOP count for waiting 20 symbols in the CC2420 code */
|
||||
#define CC2420_CONF_SYMBOL_LOOP_COUNT 500
|
||||
/*
|
||||
* SPI bus configuration for the CC2420DBK.
|
||||
*/
|
||||
|
||||
/* SPI input/output registers. */
|
||||
#define SPI_TXBUF SPDR
|
||||
#define SPI_RXBUF SPDR
|
||||
|
||||
#define BV(bitno) _BV(bitno)
|
||||
|
||||
#define SPI_WAITFOREOTx() do { while (!(SPSR & BV(SPIF))); } while (0)
|
||||
#define SPI_WAITFOREORx() do { while (!(SPSR & BV(SPIF))); } while (0)
|
||||
|
||||
#define SCK 1 /* - Output: SPI Serial Clock (SCLK) */
|
||||
#define MOSI 2 /* - Output: SPI Master out - slave in (MOSI) */
|
||||
#define MISO 3 /* - Input: SPI Master in - slave out (MISO) */
|
||||
|
||||
/*
|
||||
* SPI bus - CC2420 pin configuration.
|
||||
*/
|
||||
|
||||
#define FIFO_P 0 /* - Input: FIFOP from CC2420 */
|
||||
#define FIFO 1 /* - Input: FIFO from CC2420 */
|
||||
#define CCA 6 /* - Input: CCA from CC2420 */
|
||||
|
||||
#define SFD 4 /* - Input: SFD from CC2420 */
|
||||
#define CSN 0 /* - Output: SPI Chip Select (CS_N) */
|
||||
#define VREG_EN 5 /* - Output: VREG_EN to CC2420 */
|
||||
#define RESET_N 6 /* - Output: RESET_N to CC2420 */
|
||||
|
||||
/* Pin status. */
|
||||
|
||||
#define FIFO_IS_1 (!!(PIND & BV(FIFO)))
|
||||
#define CCA_IS_1 (!!(PIND & BV(CCA) ))
|
||||
#define RESET_IS_1 (!!(PINB & BV(RESET_N)))
|
||||
#define VREG_IS_1 (!!(PINB & BV(VREG_EN)))
|
||||
#define FIFOP_IS_1 (!!(PIND & BV(FIFO_P)))
|
||||
#define SFD_IS_1 (!!(PIND & BV(SFD)))
|
||||
|
||||
/* The CC2420 reset pin. */
|
||||
#define SET_RESET_INACTIVE() ( PORTB |= BV(RESET_N) )
|
||||
#define SET_RESET_ACTIVE() ( PORTB &= ~BV(RESET_N) )
|
||||
|
||||
/* CC2420 voltage regulator enable pin. */
|
||||
#define SET_VREG_ACTIVE() ( PORTB |= BV(VREG_EN) )
|
||||
#define SET_VREG_INACTIVE() ( PORTB &= ~BV(VREG_EN) )
|
||||
|
||||
/* CC2420 rising edge trigger for external interrupt 0 (FIFOP). */
|
||||
#define FIFOP_INT_INIT() do {\
|
||||
EICRA |= 0x03; \
|
||||
CLEAR_FIFOP_INT(); \
|
||||
} while (0)
|
||||
|
||||
/* FIFOP on external interrupt 0. */
|
||||
#define ENABLE_FIFOP_INT() do { EIMSK |= 0x01; } while (0)
|
||||
#define DISABLE_FIFOP_INT() do { EIMSK &= ~0x01; } while (0)
|
||||
#define CLEAR_FIFOP_INT() do { EIFR = 0x01; } while (0)
|
||||
|
||||
/* Enables/disables CC2420 access to the SPI bus (not the bus).
|
||||
*
|
||||
* These guys should really be renamed but are compatible with the
|
||||
* original Chipcon naming.
|
||||
*
|
||||
* SPI_CC2420_ENABLE/SPI_CC2420_DISABLE???
|
||||
* CC2420_ENABLE_SPI/CC2420_DISABLE_SPI???
|
||||
*/
|
||||
|
||||
#define SPI_ENABLE() ( PORTB &= ~BV(CSN) ) /* ENABLE CSn (active low) */
|
||||
#define SPI_DISABLE() ( PORTB |= BV(CSN) ) /* DISABLE CSn (active low) */
|
||||
|
||||
#endif /* CONTIKI_CONF_H */
|
|
@ -1,90 +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.
|
||||
*
|
||||
* @(#)$Id: cb_uart01.c,v 1.1 2007/02/02 14:09:06 bg- Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <avr/interrupt.h>
|
||||
|
||||
#include "contiki.h"
|
||||
|
||||
#include "dev/slip.h"
|
||||
|
||||
static int
|
||||
uart0_putchar(char c, FILE *stream)
|
||||
{
|
||||
while (!(UCSR0A & BV(UDRE0)))
|
||||
;
|
||||
UDR0 = c;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
static FILE uart0_stdout =
|
||||
FDEV_SETUP_STREAM(uart0_putchar, NULL, _FDEV_SETUP_WRITE);
|
||||
|
||||
void
|
||||
slip_arch_init(unsigned long ubr)
|
||||
{
|
||||
u8_t dummy;
|
||||
spl_t s = splhigh();
|
||||
|
||||
UBRR1L = ubr;
|
||||
UBRR1H = ubr >> 8;
|
||||
|
||||
UCSR1C = BV(UCSZ1) | BV(UCSZ0); /* 1 start bit, no parity, 1 stop bit */
|
||||
UCSR1B = BV(RXEN) | BV(TXEN) | BV(RXCIE);
|
||||
dummy = UDR1; /* Flush RX buffer. */
|
||||
|
||||
/* And now UART0. */
|
||||
UBRR0L = BAUD2UBR(38400);
|
||||
UBRR0H = BAUD2UBR(38400) >> 8;
|
||||
|
||||
UCSR0C = BV(UCSZ1) | BV(UCSZ0); /* 1 start bit, no parity, 1 stop bit */
|
||||
UCSR0B = BV(TXEN); /* TX ONLY!!! */
|
||||
|
||||
splx(s);
|
||||
|
||||
stdout = &uart0_stdout;
|
||||
}
|
||||
|
||||
void
|
||||
slip_arch_writeb(unsigned char c)
|
||||
{
|
||||
while (!(UCSR1A & BV(UDRE1)))
|
||||
;
|
||||
UDR1 = c;
|
||||
}
|
||||
|
||||
ISR(SIG_UART1_RECV)
|
||||
{
|
||||
/* Should deal with receive errors. */
|
||||
slip_input_byte(UDR1);
|
||||
}
|
|
@ -1,119 +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.
|
||||
*
|
||||
* @(#)$Id: qleds.c,v 1.1 2007/02/02 14:07:34 bg- Exp $
|
||||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
|
||||
#include "dev/leds.h"
|
||||
|
||||
#include <avr/io.h>
|
||||
|
||||
void
|
||||
leds_init(void)
|
||||
{
|
||||
#ifdef CB_GATEWAY
|
||||
DDRE |= LEDS_CONF_GREEN | LEDS_CONF_YELLOW;
|
||||
PORTE |= LEDS_CONF_GREEN | LEDS_CONF_YELLOW; /* LEDS off */
|
||||
#else
|
||||
DDRB |= LEDS_CONF_ORANGE | LEDS_CONF_GREEN;
|
||||
DDRE |= LEDS_CONF_RED | LEDS_CONF_YELLOW;
|
||||
|
||||
PORTB &= ~(LEDS_CONF_ORANGE | LEDS_CONF_GREEN);
|
||||
PORTE &= ~(LEDS_CONF_RED | LEDS_CONF_YELLOW);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
leds_on(unsigned char leds)
|
||||
{
|
||||
#ifdef CB_GATEWAY
|
||||
if (leds & LEDS_GREEN)
|
||||
PORTE &= ~LEDS_CONF_GREEN;
|
||||
if (leds & LEDS_YELLOW)
|
||||
PORTE &= ~LEDS_CONF_YELLOW;
|
||||
#else
|
||||
if (leds & LEDS_ORANGE)
|
||||
PORTB |= LEDS_CONF_ORANGE;
|
||||
if (leds & LEDS_GREEN)
|
||||
PORTB |= LEDS_CONF_GREEN;
|
||||
|
||||
if (leds & LEDS_RED)
|
||||
PORTE |= LEDS_CONF_RED;
|
||||
if (leds & LEDS_YELLOW)
|
||||
PORTE |= LEDS_CONF_YELLOW;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
leds_off(unsigned char leds)
|
||||
{
|
||||
#ifdef CB_GATEWAY
|
||||
if (leds & LEDS_GREEN)
|
||||
PORTE |= LEDS_CONF_GREEN;
|
||||
if (leds & LEDS_YELLOW)
|
||||
PORTE |= LEDS_CONF_YELLOW;
|
||||
#else
|
||||
if (leds & LEDS_ORANGE)
|
||||
PORTB &= ~LEDS_CONF_ORANGE;
|
||||
if (leds & LEDS_GREEN)
|
||||
PORTB &= ~LEDS_CONF_GREEN;
|
||||
|
||||
if (leds & LEDS_RED)
|
||||
PORTE &= ~LEDS_CONF_RED;
|
||||
if (leds & LEDS_YELLOW)
|
||||
PORTE &= ~LEDS_CONF_YELLOW;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
leds_toggle(unsigned char leds)
|
||||
{
|
||||
/*
|
||||
* Synonym: void leds_invert(unsigned char leds);
|
||||
*/
|
||||
asm(".global leds_invert\nleds_invert:\n");
|
||||
|
||||
#ifdef CB_GATEWAY
|
||||
if (leds & LEDS_GREEN)
|
||||
PORTE ^= ~LEDS_CONF_GREEN;
|
||||
if (leds & LEDS_YELLOW)
|
||||
PORTE ^= ~LEDS_CONF_YELLOW;
|
||||
#else
|
||||
if (leds & LEDS_ORANGE)
|
||||
PORTB ^= LEDS_CONF_ORANGE;
|
||||
if (leds & LEDS_GREEN)
|
||||
PORTB ^= LEDS_CONF_GREEN;
|
||||
|
||||
if (leds & LEDS_RED)
|
||||
PORTE ^= LEDS_CONF_RED;
|
||||
if (leds & LEDS_YELLOW)
|
||||
PORTE ^= LEDS_CONF_YELLOW;
|
||||
#endif
|
||||
}
|
|
@ -1,127 +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.
|
||||
*
|
||||
* @(#)$Id: rom.c,v 1.1 2007/02/02 14:08:22 bg- Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <avr/boot.h>
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
#include "contiki.h"
|
||||
|
||||
#include "lib/assert.h"
|
||||
|
||||
#include "dev/rom.h"
|
||||
|
||||
#if 0
|
||||
#define PRINTF(...) printf(__VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...) do {} while (0)
|
||||
#endif
|
||||
|
||||
BOOTLOADER_SECTION
|
||||
int
|
||||
rom_erase(long nbytes, off_t offset)
|
||||
{
|
||||
long nb = nbytes;
|
||||
|
||||
if(nbytes % ROM_ERASE_UNIT_SIZE != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(offset % ROM_ERASE_UNIT_SIZE != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
PRINTF("rom_erase(%ld, %06lx)\n", nbytes, offset);
|
||||
|
||||
while (nbytes > 0) {
|
||||
spl_t s = splhigh();
|
||||
|
||||
eeprom_busy_wait();
|
||||
|
||||
boot_page_erase(offset);
|
||||
boot_spm_busy_wait();
|
||||
|
||||
boot_rww_enable(); /* Before return or intr. */
|
||||
|
||||
splx(s);
|
||||
|
||||
nbytes -= ROM_ERASE_UNIT_SIZE;
|
||||
offset += ROM_ERASE_UNIT_SIZE;
|
||||
}
|
||||
|
||||
return nb;
|
||||
}
|
||||
|
||||
int
|
||||
rom_pread(void *buf, int nbytes, off_t offset)
|
||||
{
|
||||
PRINTF("rom_pread(%p, %d, %06lx)\n", buf, nbytes, offset);
|
||||
|
||||
assert(offset == (uintptr_t)offset);
|
||||
assert((offset + nbytes) == (uintptr_t)(offset + nbytes));
|
||||
memcpy_P(buf, (PGM_P)(uintptr_t)offset, nbytes);
|
||||
return nbytes;
|
||||
}
|
||||
|
||||
BOOTLOADER_SECTION
|
||||
int
|
||||
rom_pwrite(const void *buf, int nbytes, off_t offset)
|
||||
{
|
||||
long nb = nbytes;
|
||||
const unsigned char *from = buf;
|
||||
|
||||
PRINTF("rom_pwrite(%p, %d, %06lx)\n", buf, nbytes, offset);
|
||||
|
||||
while(nbytes > 0) {
|
||||
int i, n = (nbytes > ROM_ERASE_UNIT_SIZE) ? ROM_ERASE_UNIT_SIZE : nbytes;
|
||||
spl_t s = splhigh();
|
||||
|
||||
eeprom_busy_wait();
|
||||
|
||||
for (i = 0; i < n; i += 2) {
|
||||
uint16_t w = *from++;
|
||||
w |= (*from++) << 8;
|
||||
boot_page_fill(offset + i, w);
|
||||
}
|
||||
boot_page_write(offset);
|
||||
boot_spm_busy_wait();
|
||||
|
||||
boot_rww_enable(); /* Before return or intr. */
|
||||
|
||||
splx(s);
|
||||
|
||||
nbytes -= ROM_ERASE_UNIT_SIZE;
|
||||
offset += ROM_ERASE_UNIT_SIZE;
|
||||
}
|
||||
|
||||
return nb;
|
||||
}
|
|
@ -1,92 +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.
|
||||
*
|
||||
* @(#)$Id: xmem.c,v 1.1 2007/02/02 14:08:22 bg- Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
* External memory built from the AVR eeprom. It is incredibly slow!
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <avr/eeprom.h>
|
||||
|
||||
#include "contiki.h"
|
||||
|
||||
#include "dev/xmem.h"
|
||||
|
||||
#if 0
|
||||
#define PRINTF(...) printf(__VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...) do {} while (0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
*/
|
||||
void
|
||||
xmem_init(void)
|
||||
{
|
||||
PRINTF("xmem_init\n");
|
||||
}
|
||||
|
||||
int
|
||||
xmem_pread(void *_p, int size, off_t offset)
|
||||
{
|
||||
PRINTF("xmem_pread(%p, %d, %06lx)\n", _p, size, offset);
|
||||
|
||||
spl_t s = splhigh();
|
||||
eeprom_busy_wait();
|
||||
eeprom_read_block(_p, (void *)(uintptr_t)offset, size);
|
||||
splx(s);
|
||||
return size;
|
||||
}
|
||||
|
||||
int
|
||||
xmem_pwrite(const void *_p, int size, off_t offset)
|
||||
{
|
||||
PRINTF("xmem_pwrite(%p, %d, %06lx)\n", _p, size, offset);
|
||||
|
||||
spl_t s = splhigh();
|
||||
eeprom_busy_wait();
|
||||
eeprom_write_block(_p, (void *)(uintptr_t)offset, size);
|
||||
splx(s);
|
||||
return size;
|
||||
}
|
||||
|
||||
int
|
||||
xmem_erase(long size, off_t offset)
|
||||
{
|
||||
/*
|
||||
* AVR internal eeprom has a kind of auto erase, thus nothing is
|
||||
* done here.
|
||||
*/
|
||||
PRINTF("xmem_erase(%ld, %06lx)\n", size, offset);
|
||||
|
||||
return size;
|
||||
}
|
|
@ -1,169 +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.
|
||||
*
|
||||
* @(#)$Id: gateway.c,v 1.4 2010/10/19 18:29:05 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
* Example gateway configuration with two IP interfaces, one SLIP over
|
||||
* USB and one over 802.11.4 radio.
|
||||
*
|
||||
* The IP address is hardcoded to 172.16.0.1 and the 172.16/16 network
|
||||
* is on the radio interface.
|
||||
*
|
||||
* The default route is over the SLIP interface.
|
||||
*
|
||||
* On the SLIP host run a standard SLIP implementation or the tunslip
|
||||
* program that can also view debug printfs, example:
|
||||
*
|
||||
* sliphost# ./tunslip 172.16.0.1 255.255.0.0
|
||||
*
|
||||
*
|
||||
* This kernel has no application code but new modules can be uploaded
|
||||
* using the codeprop program, example:
|
||||
*
|
||||
* datan$ ./codeprop 172.16.0.1 loadable_prg.ko
|
||||
* File successfully sent (1116 bytes)
|
||||
* Reply: ok
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <avr/eeprom.h>
|
||||
|
||||
#include "contiki.h"
|
||||
|
||||
/* Also IP output. */
|
||||
#include "net/uip-fw-drv.h"
|
||||
#include "net/uaodv.h"
|
||||
#include "dev/slip.h"
|
||||
#include "dev/cc2420.h"
|
||||
|
||||
#include "dev/leds.h"
|
||||
#include "dev/xmem.h"
|
||||
|
||||
#include "codeprop/codeprop.h"
|
||||
|
||||
/* We have two IP interfaces. */
|
||||
struct uip_fw_netif cc2420if =
|
||||
{UIP_FW_NETIF(172,16,0,1, 255,255,0,0, cc2420_send_uaodv)};
|
||||
|
||||
static struct uip_fw_netif slipif =
|
||||
{UIP_FW_NETIF(0,0,0,0, 255,255,255,255, slip_send)};
|
||||
|
||||
/* Radio stuff in network byte order. */
|
||||
static u16_t panId = UIP_HTONS(0x2024);
|
||||
|
||||
#ifndef RF_CHANNEL
|
||||
#define RF_CHANNEL 15
|
||||
#endif
|
||||
|
||||
unsigned char ds2411_id[8] = { 0x00, 0x12, 0x4b, 0x00, 0x00, 0x00, 0x09, 0x04};
|
||||
|
||||
static void
|
||||
ds2411_init(void)
|
||||
{
|
||||
u8_t i, t;
|
||||
eeprom_read_block(ds2411_id, 0, 8);
|
||||
for (i = 0; i < 4; i++) {
|
||||
t = ds2411_id[i];
|
||||
ds2411_id[i] = ds2411_id[7 - i];
|
||||
ds2411_id[7 - i] = t;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
/*
|
||||
* Initalize hardware.
|
||||
*/
|
||||
cpu_init();
|
||||
clock_init();
|
||||
leds_init();
|
||||
leds_toggle(LEDS_ALL);
|
||||
slip_arch_init(BAUD2UBR(38400)); /* Must come before first printf */
|
||||
printf("Starting %s "
|
||||
"($Id: gateway.c,v 1.4 2010/10/19 18:29:05 adamdunkels Exp $)\n", __FILE__);
|
||||
ds2411_init();
|
||||
cc2420_init();
|
||||
xmem_init();
|
||||
clock_wait(CLOCK_SECOND/10);
|
||||
leds_toggle(LEDS_ALL);
|
||||
/*
|
||||
* Hardware initialization done!
|
||||
*/
|
||||
|
||||
printf("MAC %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x CHANNEL %d\n",
|
||||
ds2411_id[0], ds2411_id[1], ds2411_id[2], ds2411_id[3],
|
||||
ds2411_id[4], ds2411_id[5], ds2411_id[6], ds2411_id[7],
|
||||
RF_CHANNEL);
|
||||
|
||||
uip_ipaddr_copy(&uip_hostaddr, &cc2420if.ipaddr);
|
||||
uip_ipaddr_copy(&uip_netmask, &cc2420if.netmask);
|
||||
printf("IP %d.%d.%d.%d netmask %d.%d.%d.%d\n",
|
||||
uip_ipaddr_to_quad(&uip_hostaddr),
|
||||
uip_ipaddr_to_quad(&uip_netmask));
|
||||
cc2420_set_chan_pan_addr(RF_CHANNEL, panId, uip_hostaddr.u16[1], ds2411_id);
|
||||
|
||||
/*
|
||||
* Initialize Contiki and our processes.
|
||||
*/
|
||||
process_init();
|
||||
process_start(&etimer_process, NULL);
|
||||
|
||||
/* Configure IP stack. */
|
||||
uip_init();
|
||||
uip_fw_default(&slipif); /* Point2point, no default router. */
|
||||
uip_fw_register(&cc2420if);
|
||||
tcpip_set_forwarding(1);
|
||||
|
||||
/* Start IP stack. */
|
||||
process_start(&tcpip_process, NULL);
|
||||
process_start(&uip_fw_process, NULL); /* Start IP output */
|
||||
process_start(&slip_process, NULL);
|
||||
process_start(&cc2420_process, NULL);
|
||||
cc2420_on();
|
||||
process_start(&uaodv_process, NULL);
|
||||
|
||||
//process_start(&tcp_loader_process, NULL);
|
||||
|
||||
/*
|
||||
* This is the scheduler loop.
|
||||
*/
|
||||
printf("process_run()...\n");
|
||||
while (1) {
|
||||
do {
|
||||
/* Reset watchdog. */
|
||||
} while(process_run() > 0);
|
||||
/* Idle! */
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
CONTIKI_TARGET_DIRS = . dev apps net loader
|
||||
CONTIKI_TARGET_MAIN = ethernut-main.o
|
||||
|
||||
CONTIKI_TARGET_SOURCEFILES += slip.c rs232.c ethernut-main.c \
|
||||
rtl8019-drv.c rtl8019.c rtl8019dev.c debug.c delay.c
|
||||
|
||||
CONTIKIAVR=$(CONTIKI)/cpu/avr
|
||||
CONTIKIBOARD=.
|
||||
|
||||
APPS+=webserver telnetd #program-handler shell
|
||||
MCU=atmega128
|
||||
CONTIKI_PLAT_DEFS = -DF_CPU=14745600UL -DAUTO_CRC_PADDING=2
|
||||
include $(CONTIKIAVR)/Makefile.avr
|
||||
|
||||
%.u: %.$(TARGET)
|
||||
avrdude -P /dev/cuaa0 -c stk500 -p atmega128 -v -e
|
||||
avrdude -P /dev/cuaa0 -c stk500 -p atmega128 -v -U flash:w:$<
|
|
@ -1,165 +0,0 @@
|
|||
#ifndef __CONTIKI_CONF_H__
|
||||
#define __CONTIKI_CONF_H__
|
||||
|
||||
#define CC_CONF_REGISTER_ARGS 1
|
||||
#define CC_CONF_FUNCTION_POINTER_ARGS 1
|
||||
|
||||
#define CCIF
|
||||
#define CLIF
|
||||
|
||||
typedef unsigned short clock_time_t;
|
||||
#define CLOCK_CONF_SECOND 1000
|
||||
|
||||
void clock_delay(unsigned int us2);
|
||||
|
||||
void clock_wait(int ms10);
|
||||
|
||||
void clock_set_seconds(unsigned long s);
|
||||
unsigned long clock_seconds(void);
|
||||
|
||||
|
||||
/*
|
||||
* This file is used for setting various compile time settings for the
|
||||
* CTK GUI toolkit.
|
||||
*/
|
||||
|
||||
#include "ctk/ctk-vncarch.h"
|
||||
|
||||
/* Defines which key that is to be used for activating the menus */
|
||||
#define CTK_CONF_MENU_KEY CH_F1
|
||||
|
||||
/* Defines which key that is to be used for switching the frontmost
|
||||
window. */
|
||||
#define CTK_CONF_WINDOWSWITCH_KEY CH_ESC
|
||||
|
||||
/* Defines which key that is to be used for switching to the next
|
||||
widget. */
|
||||
#define CTK_CONF_WIDGETDOWN_KEY CH_TAB
|
||||
|
||||
/* Defines which key that is to be used for switching to the prevoius
|
||||
widget. */
|
||||
#define CTK_CONF_WIDGETUP_KEY 1
|
||||
|
||||
/* Toggles support for icons. */
|
||||
#define CTK_CONF_ICONS 1 /* 107 bytes */
|
||||
|
||||
/* Toggles support for icon bitmaps. */
|
||||
#define CTK_CONF_ICON_BITMAPS 1
|
||||
|
||||
/* Toggles support for icon textmaps. */
|
||||
#define CTK_CONF_ICON_TEXTMAPS 1
|
||||
|
||||
/* Toggles support for windows. */
|
||||
#define CTK_CONF_WINDOWS 1
|
||||
|
||||
/* Toggles support for movable windows. */
|
||||
#define CTK_CONF_WINDOWMOVE 1 /* 333 bytes */
|
||||
|
||||
/* Toggles support for closable windows. */
|
||||
#define CTK_CONF_WINDOWCLOSE 1 /* 14 bytes */
|
||||
|
||||
/* Toggles support for menus. */
|
||||
#define CTK_CONF_MENUS 1 /* 1384 bytes */
|
||||
|
||||
/* Toggles mouse support (must have support functions in the
|
||||
architecture specific files to work). */
|
||||
#define CTK_CONF_MOUSE_SUPPORT 1
|
||||
|
||||
/* Defines the default width of a menu. */
|
||||
#define CTK_CONF_MENUWIDTH 16
|
||||
/* The maximum number of menu items in each menu. */
|
||||
#define CTK_CONF_MAXMENUITEMS 10
|
||||
|
||||
|
||||
/* Maximum number of clients to the telnet server */
|
||||
#define CTK_TERM_CONF_MAX_TELNET_CLIENTS 3
|
||||
|
||||
/* Telnet server port */
|
||||
#define CTK_TERM_CONF_TELNET_PORT 23
|
||||
|
||||
/* Serial server output buffer size */
|
||||
#define CTK_TERM_CONF_SERIAL_BUFFER_SIZE 300
|
||||
|
||||
/* Maximum number of clients to the terminal module.
|
||||
Should be set to CTK_TERM_CONF_MAX_TELNET_CLIENTS or
|
||||
CTK_TERM_CONF_MAX_TELNET_CLIENTS+1 if the serial server is used too
|
||||
*/
|
||||
#define CTK_TERM_CONF_MAX_CLIENTS (CTK_TERM_CONF_MAX_TELNET_CLIENTS+1)
|
||||
|
||||
#define CTK_VNCSERVER_CONF_NUMCONNS 8
|
||||
|
||||
#define CTK_VNCSERVER_CONF_MAX_ICONS 8
|
||||
|
||||
#define EMAIL_CONF_WIDTH 48
|
||||
#define EMAIL_CONF_HEIGHT 16
|
||||
|
||||
#define IRC_CONF_WIDTH 78
|
||||
#define IRC_CONF_HEIGHT 20
|
||||
|
||||
#define IRC_CONF_SYSTEM_STRING "ethernut"
|
||||
|
||||
|
||||
#define LIBCONIO_CONF_SCREEN_WIDTH 70
|
||||
#define LIBCONIO_CONF_SCREEN_HEIGHT 40
|
||||
|
||||
|
||||
|
||||
#define LOG_CONF_ENABLED 0
|
||||
|
||||
#define PROGRAM_HANDLER_CONF_MAX_NUMDSCS 10
|
||||
|
||||
/* COM port to be used for SLIP connection */
|
||||
#define SLIP_PORT RS232_PORT_0
|
||||
|
||||
#define TELNETD_CONF_LINELEN 64
|
||||
#define TELNETD_CONF_NUMLINES 16
|
||||
|
||||
|
||||
#define UIP_CONF_MAX_CONNECTIONS 10
|
||||
#define UIP_CONF_MAX_LISTENPORTS 10
|
||||
#define UIP_CONF_BUFFER_SIZE 100
|
||||
|
||||
#define UIP_CONF_TCP_SPLIT 1
|
||||
|
||||
#define UIP_CONF_UDP_CONNS 6
|
||||
|
||||
#define UIP_CONF_FWCACHE_SIZE 1
|
||||
|
||||
#define UIP_CONF_BROADCAST 1
|
||||
|
||||
|
||||
/* The size of the HTML viewing area. */
|
||||
#define WWW_CONF_WEBPAGE_WIDTH 46
|
||||
#define WWW_CONF_WEBPAGE_HEIGHT 25
|
||||
|
||||
/* The size of the "Back" history. */
|
||||
#define WWW_CONF_HISTORY_SIZE 8
|
||||
|
||||
/* Defines the maximum length of an URL */
|
||||
#define WWW_CONF_MAX_URLLEN 160
|
||||
|
||||
/* The maxiumum number of widgets (i.e., hyperlinks, form elements) on
|
||||
a page. */
|
||||
#define WWW_CONF_MAX_NUMPAGEWIDGETS 30
|
||||
|
||||
/* Turns <center> support on or off; must be on for forms to work. */
|
||||
#define WWW_CONF_RENDERSTATE 1
|
||||
|
||||
/* Toggles support for HTML forms. */
|
||||
#define WWW_CONF_FORMS 1
|
||||
|
||||
/* Maximum lengths for various HTML form parameters. */
|
||||
#define WWW_CONF_MAX_FORMACTIONLEN 80
|
||||
#define WWW_CONF_MAX_FORMNAMELEN 40
|
||||
#define WWW_CONF_MAX_INPUTNAMELEN 40
|
||||
#define WWW_CONF_MAX_INPUTVALUELEN 40
|
||||
|
||||
#define WWW_CONF_PAGEVIEW 1
|
||||
|
||||
#define HAVE_STDINT_H
|
||||
#include "avrdef.h"
|
||||
|
||||
typedef unsigned short uip_stats_t;
|
||||
|
||||
|
||||
#endif /* __CONTIKI_CONF_H__ */
|
|
@ -1,102 +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. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 OS
|
||||
*
|
||||
* $Id: ethernut-main.c,v 1.5 2010/12/03 21:39:33 dak664 Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
#include "contiki-net.h"
|
||||
|
||||
#include "dev/rs232.h"
|
||||
#include "dev/rtl8019-drv.h"
|
||||
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/io.h>
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
PROCINIT(&etimer_process, &tcpip_process, &rtl8019_process);
|
||||
|
||||
static const struct uip_eth_addr ethaddr = {{0x00,0x06,0x98,0x01,0x02,0x29}};
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
uip_ipaddr_t addr;
|
||||
|
||||
/*
|
||||
* GCC depends on register r1 set to 0.
|
||||
*/
|
||||
asm volatile ("clr r1");
|
||||
|
||||
/*
|
||||
* No interrupts used.
|
||||
*/
|
||||
cli();
|
||||
|
||||
/*
|
||||
* Enable external data and address
|
||||
* bus.
|
||||
*/
|
||||
MCUCR = _BV(SRE) | _BV(SRW);
|
||||
|
||||
clock_init();
|
||||
rs232_init(RS232_PORT_0, USART_BAUD_57600,USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8);
|
||||
|
||||
sei();
|
||||
|
||||
|
||||
process_init();
|
||||
|
||||
uip_ipaddr(&addr, 193,10,67,152);
|
||||
uip_sethostaddr(&addr);
|
||||
|
||||
uip_setethaddr(ethaddr);
|
||||
|
||||
procinit_init();
|
||||
|
||||
autostart_start(autostart_processes);
|
||||
|
||||
rs232_print(RS232_PORT_0, "Initialized\n");
|
||||
|
||||
while(1) {
|
||||
process_run();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
putchar(int c)
|
||||
{
|
||||
rs232_send(RS232_PORT_0, c);
|
||||
return c;
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
CONTIKI_TARGET_DIRS = . dev apps net loader
|
||||
CONTIKI_TARGET_MAIN = ethernut-main.o
|
||||
|
||||
CONTIKI_SOURCEFILES += slip.c rs232.c ethernut-main.c
|
||||
|
||||
|
||||
CONTIKIAVR=$(CONTIKI)/cpu/avr
|
||||
CONTIKIBOARD=.
|
||||
MCU=atmega128
|
||||
CONTIKI_PLAT_DEFS = -DF_CPU=14745600UL -DAUTO_CRC_PADDING=2
|
||||
include $(CONTIKIAVR)/Makefile.avr
|
|
@ -1,168 +0,0 @@
|
|||
#ifndef __CONTIKI_CONF_H__
|
||||
#define __CONTIKI_CONF_H__
|
||||
|
||||
#define CC_CONF_REGISTER_ARGS 1
|
||||
#define CC_CONF_FUNCTION_POINTER_ARGS 1
|
||||
|
||||
#define CCIF
|
||||
#define CLIF
|
||||
|
||||
typedef unsigned short clock_time_t;
|
||||
#define CLOCK_CONF_SECOND 1000
|
||||
|
||||
#define NUT_CPU_FREQ 14745600UL
|
||||
#define AVR_CLK_COUNT (NUT_CPU_FREQ / (128L * CLOCK_CONF_SECOND) + 0.5)
|
||||
|
||||
void clock_delay(unsigned int us2);
|
||||
|
||||
void clock_wait(int ms10);
|
||||
|
||||
void clock_set_seconds(unsigned long s);
|
||||
unsigned long clock_seconds(void);
|
||||
|
||||
|
||||
/*
|
||||
* This file is used for setting various compile time settings for the
|
||||
* CTK GUI toolkit.
|
||||
*/
|
||||
|
||||
#include "ctk/ctk-vncarch.h"
|
||||
|
||||
/* Defines which key that is to be used for activating the menus */
|
||||
#define CTK_CONF_MENU_KEY CH_F1
|
||||
|
||||
/* Defines which key that is to be used for switching the frontmost
|
||||
window. */
|
||||
#define CTK_CONF_WINDOWSWITCH_KEY CH_ESC
|
||||
|
||||
/* Defines which key that is to be used for switching to the next
|
||||
widget. */
|
||||
#define CTK_CONF_WIDGETDOWN_KEY CH_TAB
|
||||
|
||||
/* Defines which key that is to be used for switching to the prevoius
|
||||
widget. */
|
||||
#define CTK_CONF_WIDGETUP_KEY 1
|
||||
|
||||
/* Toggles support for icons. */
|
||||
#define CTK_CONF_ICONS 1 /* 107 bytes */
|
||||
|
||||
/* Toggles support for icon bitmaps. */
|
||||
#define CTK_CONF_ICON_BITMAPS 1
|
||||
|
||||
/* Toggles support for icon textmaps. */
|
||||
#define CTK_CONF_ICON_TEXTMAPS 1
|
||||
|
||||
/* Toggles support for windows. */
|
||||
#define CTK_CONF_WINDOWS 1
|
||||
|
||||
/* Toggles support for movable windows. */
|
||||
#define CTK_CONF_WINDOWMOVE 1 /* 333 bytes */
|
||||
|
||||
/* Toggles support for closable windows. */
|
||||
#define CTK_CONF_WINDOWCLOSE 1 /* 14 bytes */
|
||||
|
||||
/* Toggles support for menus. */
|
||||
#define CTK_CONF_MENUS 1 /* 1384 bytes */
|
||||
|
||||
/* Toggles mouse support (must have support functions in the
|
||||
architecture specific files to work). */
|
||||
#define CTK_CONF_MOUSE_SUPPORT 1
|
||||
|
||||
/* Defines the default width of a menu. */
|
||||
#define CTK_CONF_MENUWIDTH 16
|
||||
/* The maximum number of menu items in each menu. */
|
||||
#define CTK_CONF_MAXMENUITEMS 10
|
||||
|
||||
|
||||
/* Maximum number of clients to the telnet server */
|
||||
#define CTK_TERM_CONF_MAX_TELNET_CLIENTS 3
|
||||
|
||||
/* Telnet server port */
|
||||
#define CTK_TERM_CONF_TELNET_PORT 23
|
||||
|
||||
/* Serial server output buffer size */
|
||||
#define CTK_TERM_CONF_SERIAL_BUFFER_SIZE 300
|
||||
|
||||
/* Maximum number of clients to the terminal module.
|
||||
Should be set to CTK_TERM_CONF_MAX_TELNET_CLIENTS or
|
||||
CTK_TERM_CONF_MAX_TELNET_CLIENTS+1 if the serial server is used too
|
||||
*/
|
||||
#define CTK_TERM_CONF_MAX_CLIENTS (CTK_TERM_CONF_MAX_TELNET_CLIENTS+1)
|
||||
|
||||
#define CTK_VNCSERVER_CONF_NUMCONNS 8
|
||||
|
||||
#define CTK_VNCSERVER_CONF_MAX_ICONS 8
|
||||
|
||||
#define EMAIL_CONF_WIDTH 48
|
||||
#define EMAIL_CONF_HEIGHT 16
|
||||
|
||||
#define IRC_CONF_WIDTH 78
|
||||
#define IRC_CONF_HEIGHT 20
|
||||
|
||||
#define IRC_CONF_SYSTEM_STRING "ethernut"
|
||||
|
||||
|
||||
#define LIBCONIO_CONF_SCREEN_WIDTH 70
|
||||
#define LIBCONIO_CONF_SCREEN_HEIGHT 40
|
||||
|
||||
|
||||
|
||||
#define LOG_CONF_ENABLED 0
|
||||
|
||||
#define PROGRAM_HANDLER_CONF_MAX_NUMDSCS 10
|
||||
|
||||
/* COM port to be used for SLIP connection */
|
||||
#define SLIP_PORT RS232_PORT_0
|
||||
|
||||
#define TELNETD_CONF_LINELEN 32
|
||||
#define TELNETD_CONF_NUMLINES 16
|
||||
|
||||
|
||||
#define UIP_CONF_MAX_CONNECTIONS 10
|
||||
#define UIP_CONF_MAX_LISTENPORTS 10
|
||||
#define UIP_CONF_BUFFER_SIZE 100
|
||||
|
||||
#define UIP_CONF_TCP_SPLIT 1
|
||||
|
||||
#define UIP_CONF_UDP_CONNS 6
|
||||
|
||||
#define UIP_CONF_FWCACHE_SIZE 1
|
||||
|
||||
#define UIP_CONF_BROADCAST 1
|
||||
|
||||
|
||||
/* The size of the HTML viewing area. */
|
||||
#define WWW_CONF_WEBPAGE_WIDTH 46
|
||||
#define WWW_CONF_WEBPAGE_HEIGHT 25
|
||||
|
||||
/* The size of the "Back" history. */
|
||||
#define WWW_CONF_HISTORY_SIZE 8
|
||||
|
||||
/* Defines the maximum length of an URL */
|
||||
#define WWW_CONF_MAX_URLLEN 160
|
||||
|
||||
/* The maxiumum number of widgets (i.e., hyperlinks, form elements) on
|
||||
a page. */
|
||||
#define WWW_CONF_MAX_NUMPAGEWIDGETS 30
|
||||
|
||||
/* Turns <center> support on or off; must be on for forms to work. */
|
||||
#define WWW_CONF_RENDERSTATE 1
|
||||
|
||||
/* Toggles support for HTML forms. */
|
||||
#define WWW_CONF_FORMS 1
|
||||
|
||||
/* Maximum lengths for various HTML form parameters. */
|
||||
#define WWW_CONF_MAX_FORMACTIONLEN 80
|
||||
#define WWW_CONF_MAX_FORMNAMELEN 40
|
||||
#define WWW_CONF_MAX_INPUTNAMELEN 40
|
||||
#define WWW_CONF_MAX_INPUTVALUELEN 40
|
||||
|
||||
#define WWW_CONF_PAGEVIEW 1
|
||||
|
||||
#define HAVE_STDINT_H
|
||||
#include "avrdef.h"
|
||||
|
||||
typedef unsigned short uip_stats_t;
|
||||
|
||||
|
||||
#endif /* __CONTIKI_CONF_H__ */
|
|
@ -1,99 +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. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 OS
|
||||
*
|
||||
* $Id: ethernut-main.c,v 1.4 2010/12/03 21:39:33 dak664 Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
#include "contiki-net.h"
|
||||
#include "dev/serial-line.h"
|
||||
#include "dev/slip.h"
|
||||
#include "dev/rs232.h"
|
||||
|
||||
#include <avr/interrupt.h>
|
||||
/*static void setup_xram(void) __attribute__ ((naked)) \
|
||||
__attribute__ ((section (".init1")));
|
||||
|
||||
static void
|
||||
setup_xram(void)
|
||||
{
|
||||
outp(BV(SRE) | BV(SRW), MCUCR);
|
||||
}*/
|
||||
|
||||
static struct uip_fw_netif slipif =
|
||||
{UIP_FW_NETIF(0,0,0,0, 0,0,0,0, slip_send)};
|
||||
|
||||
PROCESS(serial_test, "Serial test");
|
||||
|
||||
PROCESS_THREAD(serial_test, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
|
||||
while(1) {
|
||||
PROCESS_WAIT_EVENT_UNTIL(ev == serial_line_event_message);
|
||||
rs232_print(RS232_PORT_0, data);
|
||||
}
|
||||
PROCESS_END();
|
||||
}
|
||||
|
||||
PROCINIT(&etimer_process, &serial_line_process, &slip_process,
|
||||
&uip_fw_process);
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
uip_ipaddr_t addr;
|
||||
|
||||
clock_init();
|
||||
rs232_init(RS232_PORT_0, USART_BAUD_57600,USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8);
|
||||
rs232_set_input(RS232_PORT_0, slip_input_byte);
|
||||
|
||||
sei();
|
||||
|
||||
/* Initialize drivers and event kernal */
|
||||
process_init();
|
||||
|
||||
uip_ipaddr(&addr, 172,16,0,2);
|
||||
uip_sethostaddr(&addr);
|
||||
|
||||
procinit_init();
|
||||
autostart_start(autostart_processes);
|
||||
uip_fw_default(&slipif);
|
||||
|
||||
rs232_print_p(RS232_PORT_0, PSTR("Initialized\n"));
|
||||
|
||||
while(1) {
|
||||
process_run();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
ifndef CONTIKI
|
||||
$(error CONTIKI not defined! You must specify where CONTIKI resides!)
|
||||
endif
|
||||
|
||||
CONTIKI_TARGET_DIRS = . dev apps net
|
||||
|
||||
SENSORS = sensors.c beep.c button-sensor.c pir-sensor.c vib-sensor.c \
|
||||
radio-sensor.c irq.c eeprom.c \
|
||||
dummy-sensors.c leds.c leds-arch.c esb-sensors.c
|
||||
NETSIM = ether.c ethernode.c ethernode-uip.c lpm.c rs232.c flash.c \
|
||||
node.c nodes.c sensor.c display.c random.c radio.c \
|
||||
dlloader.c main.c netsim-init.c contiki-main.c symtab.c symbols.c tr1001.c tr1001-drv.c cfs-posix.c cfs-posix-dir.c
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
CONTIKI_TARGET_SOURCEFILES = $(NETSIM) $(SENSORS) wpcap-drv.c wpcap.c
|
||||
else
|
||||
CONTIKI_TARGET_SOURCEFILES = $(NETSIM) $(SENSORS) tapdev-drv.c tapdev.c
|
||||
endif
|
||||
|
||||
CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)
|
||||
|
||||
.SUFFIXES:
|
||||
|
||||
### Define the CPU directory
|
||||
CONTIKI_CPU=$(CONTIKI)/cpu/native
|
||||
include $(CONTIKI)/cpu/native/Makefile.native
|
||||
|
||||
### Compiler definitions
|
||||
CFLAGS += $(shell gtk-config --cflags) -DNETSIM=1
|
||||
TARGET_LIBFILES = $(shell gtk-config --libs)
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
TARGET_LIBFILES += /lib/w32api/libws2_32.a /lib/w32api/libiphlpapi.a
|
||||
endif
|
|
@ -1,139 +0,0 @@
|
|||
#ifndef __CONTIKI_CONF_H__
|
||||
#define __CONTIKI_CONF_H__
|
||||
|
||||
#define NETSTACK_CONF_RADIO ethernode_driver
|
||||
|
||||
#define XMAC_CONF_ON_TIME RTIMER_SECOND
|
||||
#define XMAC_CONF_OFF_TIME RTIMER_SECOND * 2
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003, Adam Dunkels.
|
||||
* 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. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 desktop OS
|
||||
*
|
||||
* $Id: contiki-conf.h,v 1.13 2010/02/18 23:10:06 adamdunkels Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#define CC_CONF_REGISTER_ARGS 1
|
||||
#define CC_CONF_FUNCTION_POINTER_ARGS 1
|
||||
#define CC_CONF_FASTCALL
|
||||
|
||||
#define CC_CONF_VA_ARGS 1
|
||||
|
||||
#define CCIF
|
||||
#define CLIF
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \defgroup uipopttypedef uIP type definitions
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
/**
|
||||
* The 8-bit unsigned data type.
|
||||
*
|
||||
* This may have to be tweaked for your particular compiler. "unsigned
|
||||
* char" works for most compilers.
|
||||
*/
|
||||
typedef uint8_t u8_t;
|
||||
|
||||
/**
|
||||
* The 16-bit unsigned data type.
|
||||
*
|
||||
* This may have to be tweaked for your particular compiler. "unsigned
|
||||
* short" works for most compilers.
|
||||
*/
|
||||
typedef uint16_t u16_t;
|
||||
|
||||
/**
|
||||
* The 32-bit unsigned data type.
|
||||
*
|
||||
* This may have to be tweaked for your particular compiler. "unsigned
|
||||
* short" works for most compilers.
|
||||
*/
|
||||
typedef uint32_t u32_t;
|
||||
|
||||
/**
|
||||
* The 32-bit signed data type.
|
||||
*
|
||||
* This may have to be tweaked for your particular compiler. "signed
|
||||
* short" works for most compilers.
|
||||
*/
|
||||
typedef int32_t s32_t;
|
||||
|
||||
/**
|
||||
* The statistics data type.
|
||||
*
|
||||
* This datatype determines how high the statistics counters are able
|
||||
* to count.
|
||||
*/
|
||||
typedef unsigned short uip_stats_t;
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
|
||||
typedef unsigned long clock_time_t;
|
||||
#define CLOCK_CONF_SECOND 1000
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
|
||||
#define PACKETBUF_CONF_SIZE 128
|
||||
#define PACKETBUF_CONF_HDR_SIZE 32
|
||||
#define QUEUEBUF_CONF_STATS 1
|
||||
|
||||
#define UIP_CONF_UIP_IP4ADDR_T_WITH_U32 1
|
||||
|
||||
#define UIP_CONF_ICMP_DEST_UNREACH 1
|
||||
|
||||
#define UIP_CONF_MAX_CONNECTIONS 40
|
||||
#define UIP_CONF_MAX_LISTENPORTS 40
|
||||
#define UIP_CONF_BUFFER_SIZE 120
|
||||
|
||||
#define UIP_CONF_BYTE_ORDER UIP_LITTLE_ENDIAN
|
||||
|
||||
#define UIP_CONF_BROADCAST 1
|
||||
|
||||
#define UIP_CONF_IP_FORWARD 1
|
||||
|
||||
/* TCP splitting does not work well with multi hop routing. */
|
||||
#define UIP_CONF_TCP_SPLIT 0
|
||||
|
||||
#define UIP_CONF_LOGGING 1
|
||||
|
||||
#define UIP_CONF_UDP_CHECKSUMS 0
|
||||
|
||||
#define LOADER_CONF_ARCH "loader/dlloader.h"
|
||||
|
||||
#endif /* __CONTIKI_CONF_H__ */
|
|
@ -1,65 +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.
|
||||
*
|
||||
* $Id: contiki-esb.h,v 1.2 2006/10/10 15:58:31 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* A brief description of what this file is.
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*/
|
||||
|
||||
#ifndef __CONTIKI_ESB_H__
|
||||
#define __CONTIKI_ESB_H__
|
||||
|
||||
#include "contiki.h"
|
||||
#include "contiki-net.h"
|
||||
#include "contiki-lib.h"
|
||||
#include "dev/leds.h"
|
||||
|
||||
#include "dev/vib-sensor.h"
|
||||
#include "dev/radio-sensor.h"
|
||||
#include "dev/pir-sensor.h"
|
||||
#include "dev/temperature-sensor.h"
|
||||
#include "dev/button-sensor.h"
|
||||
|
||||
#include "dev/lpm.h"
|
||||
#include "dev/radio.h"
|
||||
|
||||
#include "dev/tr1001.h"
|
||||
#include "dev/tr1001-drv.h"
|
||||
|
||||
#include "dev/beep.h"
|
||||
|
||||
#include "node-id.h"
|
||||
|
||||
#endif /* __CONTIKI_ESB_H__ */
|
|
@ -1,183 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2004, 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.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: contiki-main.c,v 1.37 2010/04/21 20:27:28 oliverschmidt Exp $
|
||||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
#include "contiki-net.h"
|
||||
#include "contiki-lib.h"
|
||||
|
||||
#include "dev/serial-line.h"
|
||||
#include "net/rime.h"
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
#include "net/wpcap-drv.h"
|
||||
#else /* __CYGWIN__ */
|
||||
#include "net/tapdev-drv.h"
|
||||
#endif /* __CYGWIN__ */
|
||||
#include "net/ethernode-uip.h"
|
||||
#include "net/ethernode-rime.h"
|
||||
#include "net/ethernode.h"
|
||||
#include "net/uip-over-mesh.h"
|
||||
|
||||
#include "net/mac/nullmac.h"
|
||||
#include "net/mac/lpp.h"
|
||||
|
||||
#include "ether.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#ifndef HAVE_SNPRINTF
|
||||
int snprintf(char *str, size_t size, const char *format, ...);
|
||||
#endif /* HAVE_SNPRINTF */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sys/select.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "dev/button-sensor.h"
|
||||
#include "dev/pir-sensor.h"
|
||||
#include "dev/vib-sensor.h"
|
||||
#include "dev/radio-sensor.h"
|
||||
#include "dev/leds.h"
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
static struct uip_fw_netif extif =
|
||||
{UIP_FW_NETIF(0,0,0,0, 0,0,0,0, wpcap_output)};
|
||||
#else /* __CYGWIN__ */
|
||||
static struct uip_fw_netif extif =
|
||||
{UIP_FW_NETIF(0,0,0,0, 0,0,0,0, tapdev_output)};
|
||||
#endif /* __CYGWIN__ */
|
||||
static struct uip_fw_netif meshif =
|
||||
{UIP_FW_NETIF(172,16,0,0, 255,255,0,0, uip_over_mesh_send)};
|
||||
/*static struct uip_fw_netif ethernodeif =
|
||||
{UIP_FW_NETIF(172,16,0,0, 255,255,0,0, ethernode_drv_send)};*/
|
||||
|
||||
static const struct uip_eth_addr ethaddr = {{0x00,0x06,0x98,0x01,0x02,0x12}};
|
||||
|
||||
SENSORS(&button_sensor, &pir_sensor, &vib_sensor, &radio_sensor);
|
||||
|
||||
PROCINIT(&sensors_process, &etimer_process, &tcpip_process);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifdef __CYGWIN__
|
||||
static void
|
||||
remove_route(int s)
|
||||
{
|
||||
char buf[1024];
|
||||
|
||||
snprintf(buf, sizeof(buf), "route delete %d.%d.%d.%d",
|
||||
uip_ipaddr_to_quad(&meshif.ipaddr));
|
||||
printf("%s\n", buf);
|
||||
system(buf);
|
||||
_exit(0);
|
||||
}
|
||||
#endif /* __CYGWIN__ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
contiki_main(int flag)
|
||||
{
|
||||
random_init(getpid());
|
||||
srand(getpid());
|
||||
|
||||
leds_init();
|
||||
|
||||
process_init();
|
||||
|
||||
procinit_init();
|
||||
|
||||
serial_line_init();
|
||||
|
||||
uip_init();
|
||||
|
||||
ctimer_init();
|
||||
|
||||
NETSTACK_MAC.init();
|
||||
NETSTACK_RDC.init();
|
||||
|
||||
uip_over_mesh_init(2);
|
||||
uip_over_mesh_set_net(&meshif.ipaddr, &meshif.netmask);
|
||||
|
||||
if(flag == 1) {
|
||||
#ifdef __CYGWIN__
|
||||
process_start(&wpcap_process, NULL);
|
||||
{
|
||||
char buf[1024];
|
||||
uip_ipaddr_t ifaddr;
|
||||
extern uip_ipaddr_t winifaddr;
|
||||
|
||||
uip_ipaddr_copy(&ifaddr, &winifaddr);
|
||||
|
||||
snprintf(buf, sizeof(buf), "route add %d.%d.%d.%d mask %d.%d.%d.%d %d.%d.%d.%d",
|
||||
uip_ipaddr_to_quad(&meshif.ipaddr),
|
||||
uip_ipaddr_to_quad(&meshif.netmask),
|
||||
uip_ipaddr_to_quad(&ifaddr));
|
||||
printf("%s\n", buf);
|
||||
system(buf);
|
||||
signal(SIGTERM, remove_route);
|
||||
}
|
||||
#else /* __CYGWIN__ */
|
||||
process_start(&tapdev_process, NULL);
|
||||
#endif /* __CYGWIN__ */
|
||||
process_start(&uip_fw_process, NULL);
|
||||
|
||||
uip_fw_register(&meshif);
|
||||
uip_fw_default(&extif);
|
||||
printf("uip_hostaddr %d.%d.%d.%d\n", uip_ipaddr_to_quad(&uip_hostaddr));
|
||||
uip_over_mesh_make_announced_gateway();
|
||||
} else {
|
||||
process_start(&uip_fw_process, NULL);
|
||||
uip_fw_default(&meshif);
|
||||
}
|
||||
|
||||
leds_on(LEDS_GREEN);
|
||||
|
||||
rtimer_init();
|
||||
|
||||
autostart_start(autostart_processes);
|
||||
|
||||
while(1) {
|
||||
int n;
|
||||
struct timeval tv;
|
||||
|
||||
n = process_run();
|
||||
/* if(n > 0) {
|
||||
printf("%d processes in queue\n", n);
|
||||
}*/
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = 1;
|
||||
select(0, NULL, NULL, NULL, &tv);
|
||||
etimer_request_poll();
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
process_event_t codeprop_event_quit;
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2004, 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.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: contiki-main.h,v 1.1 2006/06/17 22:41:35 adamdunkels Exp $
|
||||
*/
|
||||
#ifndef __CONTIKI_MAIN_H__
|
||||
#define __CONTIKI_MAIN_H__
|
||||
|
||||
void contiki_main(int b);
|
||||
|
||||
#endif /* __CONTIKI_MAIN_H__ */
|
|
@ -1,88 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2004, 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.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: beep.c,v 1.1 2006/06/17 22:41:35 adamdunkels Exp $
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "dev/beep.h"
|
||||
|
||||
void
|
||||
beep_down(int n)
|
||||
{
|
||||
printf("beep_down(%d)\n", n);
|
||||
}
|
||||
|
||||
void
|
||||
beep_beep(int n)
|
||||
{
|
||||
printf("beep_beep(%d)\n", n);
|
||||
}
|
||||
|
||||
void
|
||||
beep_alarm(int alarmmode, int len)
|
||||
{
|
||||
printf("beep_alarm(%d,%d)\n", alarmmode, len);
|
||||
}
|
||||
|
||||
void
|
||||
beep_spinup(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void beep(void)
|
||||
{
|
||||
printf("%cbeep\n", 7); /*fflush(NULL);*/
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
beep_off(void)
|
||||
{
|
||||
|
||||
}
|
||||
void
|
||||
beep_on(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
beep_long(clock_time_t len)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
beep_quick(int n)
|
||||
{
|
||||
|
||||
}
|
|
@ -1,163 +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.
|
||||
*
|
||||
* @(#)$Id: beep.h,v 1.2 2006/07/07 06:40:05 nifi Exp $
|
||||
*/
|
||||
/**
|
||||
* \addtogroup esb
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \defgroup beeper Beeper interface
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Interface to the beeper.
|
||||
* \author Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __BEEP_H__
|
||||
#define __BEEP_H__
|
||||
|
||||
#define BEEP_ALARM1 1
|
||||
#define BEEP_ALARM2 2
|
||||
|
||||
#include "sys/clock.h"
|
||||
|
||||
/**
|
||||
* Beep for a specified time.
|
||||
*
|
||||
* This function causes the beeper to beep for the specified time. The
|
||||
* time is measured in the same units as for the clock_delay()
|
||||
* function.
|
||||
*
|
||||
* \note This function will hang the CPU during the beep.
|
||||
*
|
||||
* \note This function will stop any beep that was on previously when this
|
||||
* function ends.
|
||||
*
|
||||
* \note If the beeper is turned off with beep_off() this call will still
|
||||
* take the same time, though it will be silent.
|
||||
*
|
||||
* \param len The length of the beep.
|
||||
*
|
||||
*/
|
||||
void beep_beep(int len);
|
||||
|
||||
/**
|
||||
* Beep an alarm for a specified time.
|
||||
*
|
||||
* This function causes the beeper to beep for the specified time. The
|
||||
* time is measured in the same units as for the clock_delay()
|
||||
* function.
|
||||
*
|
||||
* \note This function will hang the CPU during the beep.
|
||||
*
|
||||
* \note This function will stop any beep that was on previously when this
|
||||
* function ends.
|
||||
*
|
||||
* \note If the beeper is turned off with beep_off() this call will still
|
||||
* take the same time, though it will be silent.
|
||||
*
|
||||
* \param alarmmode The alarm mode (BEEP_ALARM1,BEEP_ALARM2)
|
||||
* \param len The length of the beep.
|
||||
*
|
||||
*/
|
||||
void beep_alarm(int alarmmode, int len);
|
||||
|
||||
/**
|
||||
* Produces a quick click-like beep.
|
||||
*
|
||||
* This function produces a short beep that sounds like a click.
|
||||
*
|
||||
*/
|
||||
void beep(void);
|
||||
|
||||
/**
|
||||
* A beep with a pitch-bend down.
|
||||
*
|
||||
* This function produces a pitch-bend sound with deecreasing
|
||||
* frequency.
|
||||
*
|
||||
* \param len The length of the pitch-bend.
|
||||
*
|
||||
*/
|
||||
void beep_down(int len);
|
||||
|
||||
/**
|
||||
* Turn the beeper on.
|
||||
*
|
||||
* This function turns on the beeper. The beeper is turned off with
|
||||
* the beep_off() function.
|
||||
*/
|
||||
void beep_on(void);
|
||||
|
||||
/**
|
||||
* Turn the beeper off.
|
||||
*
|
||||
* This function turns the beeper off after it has been turned on with
|
||||
* beep_on().
|
||||
*/
|
||||
void beep_off(void);
|
||||
|
||||
/**
|
||||
* Produce a sound similar to a hard-drive spinup.
|
||||
*
|
||||
* This function produces a sound that is intended to be similar to
|
||||
* the sound a hard-drive makes when it starts.
|
||||
*
|
||||
*/
|
||||
void beep_spinup(void);
|
||||
|
||||
/**
|
||||
* Beep for a long time (seconds)
|
||||
*
|
||||
* This function produces a beep with the specified length and will
|
||||
* not return until the beep is complete. The length of the beep is
|
||||
* specified using CLOCK_SECOND: a two second beep is CLOCK_SECOND *
|
||||
* 2, and a quarter second beep is CLOCK_SECOND / 4.
|
||||
*
|
||||
* \note If the beeper is turned off with beep_off() this call will still
|
||||
* take the same time, though it will be silent.
|
||||
*
|
||||
* \param len The length of the beep, measured in units of CLOCK_SECOND
|
||||
*/
|
||||
void beep_long(clock_time_t len);
|
||||
|
||||
void beep_quick(int num);
|
||||
|
||||
/** @} */
|
||||
/** @} */
|
||||
|
||||
#endif /* __BEEP_H__ */
|
|
@ -1,32 +0,0 @@
|
|||
|
||||
#include "dev/button-sensor.h"
|
||||
|
||||
const struct sensors_sensor button_sensor;
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
button_press(void)
|
||||
{
|
||||
sensors_changed(&button_sensor);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
value(int type)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
configure(int type, int value)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
status(int type)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
SENSORS_SENSOR(button_sensor, BUTTON_SENSOR,
|
||||
value, configure, status);
|
|
@ -1,12 +0,0 @@
|
|||
#ifndef __BUTTON_SENSOR_H__
|
||||
#define __BUTTON_SENSOR_H__
|
||||
|
||||
#include "lib/sensors.h"
|
||||
|
||||
extern const struct sensors_sensor button_sensor;
|
||||
|
||||
#define BUTTON_SENSOR "Button"
|
||||
|
||||
void button_press(void);
|
||||
|
||||
#endif /* __BUTTON_SENSOR_H__ */
|
|
@ -1,64 +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 Configurable Sensor Network Application
|
||||
* Architecture for sensor nodes running the Contiki operating system.
|
||||
*
|
||||
* $Id: dummy-sensors.c,v 1.4 2010/01/15 10:34:36 nifi Exp $
|
||||
*
|
||||
* -----------------------------------------------------------------
|
||||
*
|
||||
* Author : Adam Dunkels, Joakim Eriksson, Niclas Finne
|
||||
* Created : 2005-11-01
|
||||
* Updated : $Date: 2010/01/15 10:34:36 $
|
||||
* $Revision: 1.4 $
|
||||
*/
|
||||
|
||||
#include "dev/temperature-sensor.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
value(int type)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
configure(int type, int c)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
status(int type)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
SENSORS_SENSOR(temperature_sensor, TEMPERATURE_SENSOR,
|
||||
value, configure, status);
|
|
@ -1,67 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2004, 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.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: eeprom.c,v 1.2 2007/11/17 18:09:18 adamdunkels Exp $
|
||||
*/
|
||||
#include "dev/eeprom.h"
|
||||
#include "node.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static unsigned char eeprom[65536];
|
||||
|
||||
void
|
||||
eeprom_write(eeprom_addr_t addr, unsigned char *buf, int size)
|
||||
{
|
||||
int f;
|
||||
char name[400];
|
||||
|
||||
sprintf(name, "eeprom.%d.%d", node_x(), node_y());
|
||||
f = open(name, O_WRONLY | O_APPEND | O_CREAT, 0644);
|
||||
lseek(f, addr, SEEK_SET);
|
||||
write(f, buf, size);
|
||||
close(f);
|
||||
|
||||
printf("eeprom_write(addr 0x%02x, buf %p, size %d);\n", addr, buf, size);
|
||||
|
||||
memcpy(&eeprom[addr], buf, size);
|
||||
}
|
||||
void
|
||||
eeprom_read(eeprom_addr_t addr, unsigned char *buf, int size)
|
||||
{
|
||||
/* printf("eeprom_read(addr 0x%02x, buf %p, size %d);\n", addr, buf, size);*/
|
||||
memcpy(buf, &eeprom[addr], size);
|
||||
}
|
|
@ -1,55 +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.
|
||||
*
|
||||
* $Id: esb-sensors.c,v 1.1 2006/06/17 22:41:36 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* A brief description of what this file is.
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*/
|
||||
|
||||
#include "esb-sensors.h"
|
||||
#include <stdio.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
esb_sensors_on(void)
|
||||
{
|
||||
printf("esb_sensors_on()\n");
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
esb_sensors_off(void)
|
||||
{
|
||||
printf("esb_sensors_off()\n");
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -1,47 +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.
|
||||
*
|
||||
* $Id: esb-sensors.h,v 1.1 2006/06/17 22:41:36 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* A brief description of what this file is.
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*/
|
||||
|
||||
#ifndef __ESB_SENSORS_H__
|
||||
#define __ESB_SENSORS_H__
|
||||
|
||||
void esb_sensors_on(void);
|
||||
void esb_sensors_off(void);
|
||||
|
||||
#endif /* __ESB_SENSORS_H__ */
|
|
@ -1,61 +0,0 @@
|
|||
/**
|
||||
* \file
|
||||
* Functions for reading and writing flash ROM.
|
||||
* \author Adam Dunkels <adam@sics.se>
|
||||
*/
|
||||
|
||||
/* Copyright (c) 2004 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. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*
|
||||
* $Id: flash.c,v 1.1 2006/06/17 22:41:36 adamdunkels Exp $
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
flash_setup(void)
|
||||
{
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
flash_done(void)
|
||||
{
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
flash_clear(unsigned short *ptr)
|
||||
{
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
flash_write(unsigned short *ptr, unsigned short word)
|
||||
{
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -1,78 +0,0 @@
|
|||
/**
|
||||
* \file
|
||||
* Functions for reading and writing MSP430 flash ROM.
|
||||
* \author Adam Dunkels <adam@sics.se>
|
||||
*/
|
||||
|
||||
/* Copyright (c) 2004 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. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*
|
||||
* $Id: flash.h,v 1.1 2006/06/17 22:41:36 adamdunkels Exp $
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __FLASH_H__
|
||||
#define __FLASH_H__
|
||||
|
||||
/**
|
||||
* Setup function to be called before any of the flash programming functions.
|
||||
*
|
||||
*/
|
||||
void flash_setup(void);
|
||||
|
||||
/**
|
||||
* Function that is to be called after flashing is done.
|
||||
*/
|
||||
void flash_done(void);
|
||||
|
||||
/**
|
||||
* Write a 16-bit word to flash ROM.
|
||||
*
|
||||
* This function writes a 16-bit word to flash ROM. The function
|
||||
* flash_setup() must have been called first.
|
||||
*
|
||||
* \param addr A pointer to the address in flash ROM which is to be
|
||||
* written.
|
||||
*
|
||||
* \param word The 16-bit word that is to be written.
|
||||
*/
|
||||
void flash_write(unsigned short *addr, unsigned short word);
|
||||
|
||||
/**
|
||||
* Clear a 16-bit word in flash ROM.
|
||||
*
|
||||
* This function clears a 16-bit word in flash ROM. The function
|
||||
* flash_setup() must have been called first.
|
||||
*
|
||||
* \param addr A pointer to the address in flash ROM which is to be
|
||||
* cleared.
|
||||
*/
|
||||
void flash_clear(unsigned short *addr);
|
||||
|
||||
#endif /* __FLASH_H__ */
|
|
@ -1,5 +0,0 @@
|
|||
void
|
||||
irq_init(void)
|
||||
{
|
||||
}
|
||||
|
|
@ -1,60 +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 Configurable Sensor Network Application
|
||||
* Architecture for sensor nodes running the Contiki operating system.
|
||||
*
|
||||
* $Id: leds-arch.c,v 1.1 2006/06/17 22:41:36 adamdunkels Exp $
|
||||
*
|
||||
* -----------------------------------------------------------------
|
||||
*
|
||||
* Author : Adam Dunkels, Joakim Eriksson, Niclas Finne
|
||||
* Created : 2005-11-03
|
||||
* Updated : $Date: 2006/06/17 22:41:36 $
|
||||
* $Revision: 1.1 $
|
||||
*/
|
||||
|
||||
#include "dev/leds.h"
|
||||
#include "ether.h"
|
||||
|
||||
static int cleds;
|
||||
|
||||
void leds_arch_init() {
|
||||
cleds = 0;
|
||||
}
|
||||
|
||||
unsigned char leds_arch_get() {
|
||||
return cleds;
|
||||
}
|
||||
|
||||
void leds_arch_set(unsigned char leds) {
|
||||
if(leds != cleds) {
|
||||
cleds = leds;
|
||||
ether_set_leds(cleds);
|
||||
}
|
||||
}
|
|
@ -1,55 +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.
|
||||
*
|
||||
* $Id: lpm.c,v 1.1 2006/06/17 22:41:36 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* A brief description of what this file is.
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*/
|
||||
|
||||
#include "lpm.h"
|
||||
#include <stdio.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
lpm_on(void)
|
||||
{
|
||||
printf("lpm_on()\n");
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
lpm_off(void)
|
||||
{
|
||||
printf("lpm_off()\n");
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -1,40 +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.
|
||||
*
|
||||
* @(#)$Id: lpm.h,v 1.1 2006/06/17 22:41:36 adamdunkels Exp $
|
||||
*/
|
||||
#ifndef __LPM_H__
|
||||
#define __LPM_H__
|
||||
|
||||
void lpm_on(void);
|
||||
void lpm_off(void);
|
||||
|
||||
|
||||
#endif /* __LPM_H__ */
|
|
@ -1,35 +0,0 @@
|
|||
|
||||
#include "dev/pir-sensor.h"
|
||||
|
||||
const struct sensors_sensor pir_sensor;
|
||||
|
||||
static int pir_value;
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
pir_sensor_changed(int strength)
|
||||
{
|
||||
pir_value += strength;
|
||||
sensors_changed(&pir_sensor);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
value(int type)
|
||||
{
|
||||
return pir_value;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
configure(int type, int c)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
status(int type)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
SENSORS_SENSOR(pir_sensor, PIR_SENSOR,
|
||||
value, configure, status);
|
|
@ -1,14 +0,0 @@
|
|||
#ifndef __PIR_SENSOR_H__
|
||||
#define __PIR_SENSOR_H__
|
||||
|
||||
#include "lib/sensors.h"
|
||||
|
||||
extern const struct sensors_sensor pir_sensor;
|
||||
|
||||
#define PIR_SENSOR "PIR"
|
||||
|
||||
void pir_sensor_changed(int strength);
|
||||
|
||||
#define PIR_ENABLE_EVENT 1
|
||||
|
||||
#endif /* __PIR_SENSOR_H__ */
|
|
@ -1,61 +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.
|
||||
*
|
||||
* @(#)$Id: radio-sensor.c,v 1.3 2010/02/23 18:43:43 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
#include "lib/sensors.h"
|
||||
#include "dev/radio-sensor.h"
|
||||
|
||||
const struct sensors_sensor radio_sensor;
|
||||
|
||||
unsigned int radio_sensor_signal = 0;
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
value(int type)
|
||||
{
|
||||
return radio_sensor_signal;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
configure(int type, int c)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
status(int type)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
SENSORS_SENSOR(radio_sensor, RADIO_SENSOR,
|
||||
value, configure, status);
|
|
@ -1,44 +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.
|
||||
*
|
||||
* @(#)$Id: radio-sensor.h,v 1.1 2006/06/17 22:41:36 adamdunkels Exp $
|
||||
*/
|
||||
#ifndef __RADIO_SENSOR_H__
|
||||
#define __RADIO_SENSOR_H__
|
||||
|
||||
#include "contiki-esb.h"
|
||||
|
||||
extern const struct sensors_sensor radio_sensor;
|
||||
|
||||
#define RADIO_SENSOR "Radio"
|
||||
|
||||
extern unsigned int radio_sensor_signal;
|
||||
|
||||
#endif /* __RADIO_SENSOR_H__ */
|
|
@ -1,52 +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.
|
||||
*
|
||||
* $Id: radio.c,v 1.1 2006/06/17 22:41:36 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* A brief description of what this file is.
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*/
|
||||
|
||||
#include "radio.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
radio_on(void)
|
||||
{
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
radio_off(void)
|
||||
{
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -1,55 +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.
|
||||
*
|
||||
* $Id: rs232.c,v 1.2 2006/10/10 15:58:31 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* A brief description of what this file is.
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*/
|
||||
|
||||
#include "rs232.h"
|
||||
#include <stdio.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
rs232_set_input(int (* f)(unsigned char))
|
||||
{
|
||||
/* printf("rs232_set_input(%p)\n", f);*/
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
slip_arch_writeb(unsigned char c)
|
||||
{
|
||||
printf("%c", c);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -1,46 +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.
|
||||
*
|
||||
* $Id: rs232.h,v 1.1 2006/06/17 22:41:36 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* A brief description of what this file is.
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*/
|
||||
|
||||
#ifndef __RS232_H__
|
||||
#define __RS232_H__
|
||||
|
||||
void rs232_set_input(int (* f)(unsigned char));
|
||||
|
||||
#endif /* __RS232_H__ */
|
|
@ -1,51 +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 Configurable Sensor Network Application
|
||||
* Architecture for sensor nodes running the Contiki operating system.
|
||||
*
|
||||
* $Id: temperature-sensor.h,v 1.1 2006/06/17 22:41:36 adamdunkels Exp $
|
||||
*
|
||||
* -----------------------------------------------------------------
|
||||
*
|
||||
* Author : Adam Dunkels, Joakim Eriksson, Niclas Finne
|
||||
* Created : 2005-11-01
|
||||
* Updated : $Date: 2006/06/17 22:41:36 $
|
||||
* $Revision: 1.1 $
|
||||
*/
|
||||
|
||||
#ifndef __TEMPERATURE_SENSOR_H__
|
||||
#define __TEMPERATURE_SENSOR_H__
|
||||
|
||||
#include "lib/sensors.h"
|
||||
|
||||
extern const struct sensors_sensor temperature_sensor;
|
||||
|
||||
#define TEMPERATURE_SENSOR "Temperature"
|
||||
|
||||
#endif /* __TEMPERATURE_SENSOR_H__ */
|
|
@ -1,84 +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.
|
||||
*
|
||||
* @(#)$Id: tr1001-drv.c,v 1.2 2006/10/10 15:58:31 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
#include "contiki-esb.h"
|
||||
#include "net/hc.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
PROCESS(tr1001_drv_process, "TR1001 driver");
|
||||
|
||||
static unsigned char slip_dump;
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(tr1001_drv_process, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
|
||||
tr1001_init();
|
||||
|
||||
while(1) {
|
||||
|
||||
PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_POLL);
|
||||
|
||||
uip_len = tr1001_poll();
|
||||
|
||||
if(uip_len > 0) {
|
||||
uip_len = hc_inflate(&uip_buf[UIP_LLH_LEN], uip_len);
|
||||
tcpip_input();
|
||||
}
|
||||
}
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
tr1001_drv_request_poll(void)
|
||||
{
|
||||
process_poll(&tr1001_drv_process);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
u8_t
|
||||
tr1001_drv_send(void)
|
||||
{
|
||||
uip_len = hc_compress(&uip_buf[UIP_LLH_LEN], uip_len);
|
||||
return tr1001_send(&uip_buf[UIP_LLH_LEN], uip_len);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
tr1001_drv_set_slip_dump(int dump)
|
||||
{
|
||||
slip_dump = dump;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -1,44 +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.
|
||||
*
|
||||
* @(#)$Id: tr1001-drv.h,v 1.1 2006/06/17 22:41:36 adamdunkels Exp $
|
||||
*/
|
||||
#ifndef __TR1001_DRV_H__
|
||||
#define __TR1001_DRV_H__
|
||||
|
||||
PROCESS_NAME(tr1001_drv_process);
|
||||
|
||||
void tr1001_drv_set_slip_dump(int dump);
|
||||
|
||||
u8_t tr1001_drv_send(void);
|
||||
|
||||
void tr1001_drv_request_poll(void);
|
||||
|
||||
#endif /* __TR1001_DRV_H__ */
|
|
@ -1,112 +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.
|
||||
*
|
||||
* $Id: tr1001.c,v 1.2 2006/10/10 15:58:31 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* A brief description of what this file is.
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "tr1001.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
tr1001_init(void)
|
||||
{
|
||||
printf("tr1001_init()\n");
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
unsigned short
|
||||
tr1001_poll(void)
|
||||
{
|
||||
printf("tr1001_poll()\n");
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
u8_t
|
||||
tr1001_send(u8_t *packet, u16_t len)
|
||||
{
|
||||
printf("tr1001_send(%p, %d)\n", packet, len);
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
tr1001_set_txpower(unsigned char p)
|
||||
{
|
||||
printf("tr1001_set_txpower(%d)\n", p);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
unsigned short
|
||||
tr1001_sstrength(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static unsigned short packets_ok, packets_err;
|
||||
unsigned short
|
||||
tr1001_packets_ok(void)
|
||||
{
|
||||
return packets_ok;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
unsigned short
|
||||
tr1001_packets_dropped(void)
|
||||
{
|
||||
return packets_err;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
tr1001_clear_packets(void)
|
||||
{
|
||||
packets_ok = packets_err = 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
tr1001_clear_active(void)
|
||||
{
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
tr1001_active(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
unsigned short
|
||||
tr1001_sstrength_value(unsigned int type)
|
||||
{
|
||||
printf("tr1001_sstrength_value(%d)\n", type);
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -1,65 +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.
|
||||
*
|
||||
* $Id: tr1001.h,v 1.1 2006/06/17 22:41:36 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* A brief description of what this file is.
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*/
|
||||
|
||||
#ifndef __TR1001_H__
|
||||
#define __TR1001_H__
|
||||
|
||||
#include "contiki-net.h"
|
||||
|
||||
|
||||
void tr1001_init(void);
|
||||
u8_t tr1001_send(u8_t *packet, u16_t len);
|
||||
unsigned short tr1001_poll(void);
|
||||
|
||||
void tr1001_set_txpower(unsigned char p);
|
||||
#define TR1001_TXPOWER_HIGHEST 100
|
||||
#define TR1001_TXPOWER_LOWEST 1
|
||||
|
||||
unsigned short tr1001_sstrength(void);
|
||||
|
||||
#define TR1001_SSTRENGTH_DROPPED 1
|
||||
#define TR1001_SSTRENGTH_MAX 2
|
||||
#define TR1001_SSTRENGTH_MIN 3
|
||||
unsigned short tr1001_packets_ok(void);
|
||||
unsigned short tr1001_packets_dropped(void);
|
||||
void tr1001_clear_packets(void);
|
||||
unsigned short tr1001_sstrength_value(unsigned int type);
|
||||
|
||||
#endif /* __TR1001_H__ */
|
|
@ -1,72 +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 Configurable Sensor Network Application
|
||||
* Architecture for sensor nodes running the Contiki operating system.
|
||||
*
|
||||
* $Id: vib-sensor.c,v 1.3 2010/02/23 18:43:43 adamdunkels Exp $
|
||||
*
|
||||
* -----------------------------------------------------------------
|
||||
*
|
||||
* Author : Adam Dunkels, Joakim Eriksson, Niclas Finne
|
||||
* Created : 2005-11-01
|
||||
* Updated : $Date: 2010/02/23 18:43:43 $
|
||||
* $Revision: 1.3 $
|
||||
*/
|
||||
|
||||
#include "dev/vib-sensor.h"
|
||||
|
||||
const struct sensors_sensor vib_sensor;
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
vib_sensor_changed(void)
|
||||
{
|
||||
sensors_changed(&vib_sensor);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
value(int type)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
configure(int type, int c)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
status(int type)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
SENSORS_SENSOR(vib_sensor, VIB_SENSOR,
|
||||
value, configure, status);
|
|
@ -1,55 +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 Configurable Sensor Network Application
|
||||
* Architecture for sensor nodes running the Contiki operating system.
|
||||
*
|
||||
* $Id: vib-sensor.h,v 1.2 2006/10/10 15:58:31 adamdunkels Exp $
|
||||
*
|
||||
* -----------------------------------------------------------------
|
||||
*
|
||||
* Author : Adam Dunkels, Joakim Eriksson, Niclas Finne
|
||||
* Created : 2005-11-01
|
||||
* Updated : $Date: 2006/10/10 15:58:31 $
|
||||
* $Revision: 1.2 $
|
||||
*/
|
||||
|
||||
#ifndef __VIB_SENSOR_H__
|
||||
#define __VIB_SENSOR_H__
|
||||
|
||||
#include "lib/sensors.h"
|
||||
|
||||
extern const struct sensors_sensor vib_sensor;
|
||||
|
||||
#define VIB_SENSOR "Vibration"
|
||||
|
||||
void vib_sensor_changed(void);
|
||||
|
||||
#define VIB_ENABLE_EVENT 1
|
||||
|
||||
#endif /* __VIB_SENSOR_H__ */
|
|
@ -1,738 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2004 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. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*
|
||||
* $Id: display.c,v 1.10 2010/02/23 18:44:08 adamdunkels Exp $
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "dev/leds.h"
|
||||
#include "display.h"
|
||||
#include "nodes.h"
|
||||
#include "node.h"
|
||||
#include "ether.h"
|
||||
#include "lib/list.h"
|
||||
#include "lib/memb.h"
|
||||
#include "sensor.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static GdkPixmap *pixmap = NULL;
|
||||
static GtkWidget *drawing_area;
|
||||
static GdkFont *font;
|
||||
|
||||
#define DISPLAY_WIDTH 400
|
||||
#define DISPLAY_HEIGHT 400
|
||||
|
||||
#define BASESTATION_SIZE 4
|
||||
|
||||
#define MAPSCALE 20
|
||||
#define SCALE 2
|
||||
|
||||
#define MARK_SIZE 8
|
||||
|
||||
#define RADIO_SIZE 20
|
||||
|
||||
#define DOT_SIZE ether_strength()
|
||||
#define DOT_INTENSITY 3
|
||||
|
||||
struct dot {
|
||||
struct dot *next;
|
||||
int x, y;
|
||||
int destx, desty;
|
||||
int size;
|
||||
int intensity;
|
||||
};
|
||||
|
||||
MEMB(dotsmem, struct dot, 20000);
|
||||
LIST(dots);
|
||||
LIST(tempdots);
|
||||
|
||||
static int window_is_open;
|
||||
|
||||
static GdkGC *intensity_gcs[DOT_INTENSITY];
|
||||
|
||||
static GdkGC *intensity_clusterhead;
|
||||
static GdkGC *intensity_clusterhead_lightgray;
|
||||
static GdkGC *intensity_clusterhead_red;
|
||||
|
||||
static GdkGC *green, *red, *yellow, *black, *white;
|
||||
|
||||
static struct nodes_node *marked_node;
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
display_redraw(void)
|
||||
{
|
||||
int i;
|
||||
struct nodes_node *n;
|
||||
int x, y;
|
||||
struct dot *d;
|
||||
|
||||
if(!window_is_open) {
|
||||
return;
|
||||
}
|
||||
|
||||
gdk_draw_rectangle(pixmap,
|
||||
white,
|
||||
TRUE,
|
||||
0, 0,
|
||||
drawing_area->allocation.width,
|
||||
drawing_area->allocation.height);
|
||||
|
||||
|
||||
for(i = 0; i < nodes_num(); ++i) {
|
||||
n = nodes_node(i);
|
||||
x = n->x;
|
||||
y = n->y;
|
||||
|
||||
/* if(n->type == NODE_TYPE_CLUSTERHEAD) {
|
||||
gdk_draw_arc(pixmap,
|
||||
intensity_clusterhead_lightgray,
|
||||
TRUE,
|
||||
x * SCALE - DOT_SIZE * SCALE,
|
||||
y * SCALE - DOT_SIZE * SCALE,
|
||||
DOT_SIZE * 2 * SCALE, DOT_SIZE * 2 * SCALE,
|
||||
0, 360 * 64);
|
||||
}*/
|
||||
|
||||
if(n == marked_node) {
|
||||
gdk_draw_arc(pixmap,
|
||||
red,
|
||||
FALSE,
|
||||
x * SCALE - MARK_SIZE * SCALE,
|
||||
y * SCALE - MARK_SIZE * SCALE,
|
||||
MARK_SIZE * 2 * SCALE, MARK_SIZE * 2 * SCALE,
|
||||
0, 360 * 64);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for(i = 0; i < nodes_num(); ++i) {
|
||||
n = nodes_node(i);
|
||||
x = n->x;
|
||||
y = n->y;
|
||||
|
||||
/* if(n->type == NODE_TYPE_CLUSTERHEAD) {
|
||||
gdk_draw_rectangle(pixmap,
|
||||
intensity_clusterhead_red,
|
||||
TRUE,
|
||||
x * SCALE,
|
||||
y * SCALE,
|
||||
3, 3);
|
||||
for(j = 0; j < nodes_num(); ++j) {
|
||||
m = nodes_node(j);
|
||||
if(m->type == NODE_TYPE_CLUSTERHEAD &&
|
||||
((x - m->x) * (x - m->x) +
|
||||
(y - m->y) * (y - m->y) < ether_strength() * ether_strength())) {
|
||||
gdk_draw_line(pixmap,
|
||||
intensity_clusterhead,
|
||||
x * SCALE,
|
||||
y * SCALE,
|
||||
m->x * SCALE,
|
||||
m->y * SCALE);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
} else */ {
|
||||
|
||||
if(strlen(n->text) > 0) {
|
||||
gdk_draw_string(pixmap,
|
||||
font,
|
||||
black,
|
||||
x * SCALE + 10,
|
||||
y * SCALE + 7,
|
||||
n->text);
|
||||
|
||||
}
|
||||
gdk_draw_rectangle(pixmap,
|
||||
black,
|
||||
TRUE,
|
||||
x * SCALE,
|
||||
y * SCALE,
|
||||
2, 2);
|
||||
/* gdk_draw_rectangle(pixmap,
|
||||
drawing_area->style->white_gc,
|
||||
TRUE,
|
||||
x * SCALE,
|
||||
y * SCALE,
|
||||
2, 2);*/
|
||||
if(n->leds & LEDS_GREEN) {
|
||||
gdk_draw_rectangle(pixmap,
|
||||
green,
|
||||
TRUE,
|
||||
x * SCALE + 2,
|
||||
y * SCALE,
|
||||
4, 4);
|
||||
}
|
||||
if(n->leds & LEDS_YELLOW) {
|
||||
gdk_draw_rectangle(pixmap,
|
||||
yellow,
|
||||
TRUE,
|
||||
x * SCALE,
|
||||
y * SCALE + 2,
|
||||
4, 4);
|
||||
}
|
||||
if(n->leds & LEDS_RED) {
|
||||
gdk_draw_rectangle(pixmap,
|
||||
red,
|
||||
TRUE,
|
||||
x * SCALE + 2,
|
||||
y * SCALE + 2,
|
||||
4, 4);
|
||||
}
|
||||
if(n->linex != 0 && n->liney != 0) {
|
||||
gdk_draw_line(pixmap,
|
||||
green,
|
||||
x * SCALE,
|
||||
y * SCALE,
|
||||
n->linex * SCALE,
|
||||
n->liney * SCALE);
|
||||
gdk_draw_rectangle(pixmap,
|
||||
green,
|
||||
TRUE,
|
||||
n->linex * SCALE - 2,
|
||||
n->liney * SCALE - 2,
|
||||
4, 4);
|
||||
}
|
||||
|
||||
if(n->radio_status) {
|
||||
gdk_draw_arc(pixmap,
|
||||
green,
|
||||
FALSE,
|
||||
x * SCALE - RADIO_SIZE * SCALE,
|
||||
y * SCALE - RADIO_SIZE * SCALE,
|
||||
RADIO_SIZE * 2 * SCALE, RADIO_SIZE * 2 * SCALE,
|
||||
0, 360 * 64);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for(d = list_head(dots); d != NULL; d = d->next) {
|
||||
gdk_draw_arc(pixmap,
|
||||
intensity_gcs[d->intensity - 1],
|
||||
FALSE,
|
||||
d->x * SCALE - d->size * SCALE,
|
||||
d->y * SCALE - d->size * SCALE,
|
||||
d->size * 2 * SCALE, d->size * 2 * SCALE,
|
||||
0, 360 * 64);
|
||||
}
|
||||
|
||||
|
||||
gtk_widget_draw(drawing_area, NULL);
|
||||
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
display_tick(void)
|
||||
{
|
||||
struct dot *d, *e;
|
||||
struct ether_packet *p;
|
||||
|
||||
if(!window_is_open) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Fade out active dots. The intensity value of each dot is counted
|
||||
downwards, and those dots that still have an intensity are placed
|
||||
in a temporary list. The temporary list is then copied into the
|
||||
list of all dots. */
|
||||
|
||||
list_init(tempdots);
|
||||
|
||||
for(d = list_head(dots);
|
||||
d != NULL;
|
||||
d = e) {
|
||||
if(d != NULL) {
|
||||
e = d->next;
|
||||
} else {
|
||||
e = NULL;
|
||||
}
|
||||
if(d->size > 20) {
|
||||
d->size /= 2;
|
||||
} else {
|
||||
d->size -= 4;
|
||||
}
|
||||
/* --(d->intensity);*/
|
||||
if(d->size > 0) {
|
||||
list_push(tempdots, d);
|
||||
} else {
|
||||
memb_free(&dotsmem, (void *)d);
|
||||
}
|
||||
}
|
||||
list_copy(dots, tempdots);
|
||||
|
||||
/* Check if there are any new dots that should be placed in the list. */
|
||||
for(p = ether_packets(); p != NULL; p = p->next) {
|
||||
d = (struct dot *)memb_alloc(&dotsmem);
|
||||
|
||||
if(d != NULL) {
|
||||
d->x = p->x;
|
||||
d->y = p->y;
|
||||
d->size = DOT_SIZE;
|
||||
d->intensity = DOT_INTENSITY;
|
||||
list_push(dots, d);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static gint
|
||||
configure_event(GtkWidget *widget, GdkEventConfigure *event)
|
||||
{
|
||||
if(pixmap != NULL) {
|
||||
gdk_pixmap_unref(pixmap);
|
||||
}
|
||||
|
||||
pixmap = gdk_pixmap_new(widget->window,
|
||||
widget->allocation.width,
|
||||
widget->allocation.height,
|
||||
-1);
|
||||
|
||||
if(pixmap == NULL) {
|
||||
printf("gdk_pixmap_new == NULL\n");
|
||||
exit(1);
|
||||
}
|
||||
gdk_draw_rectangle(pixmap,
|
||||
widget->style->black_gc,
|
||||
TRUE,
|
||||
0, 0,
|
||||
widget->allocation.width,
|
||||
widget->allocation.height);
|
||||
/* draw_screen();*/
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Redraw the screen from the backing pixmap */
|
||||
static gint
|
||||
expose_event (GtkWidget * widget, GdkEventExpose * event)
|
||||
{
|
||||
/* draw_screen();*/
|
||||
gdk_draw_pixmap(widget->window,
|
||||
widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
|
||||
pixmap,
|
||||
event->area.x, event->area.y,
|
||||
event->area.x, event->area.y,
|
||||
event->area.width, event->area.height);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gint
|
||||
key_press_event (GtkWidget * widget, GdkEventKey * event)
|
||||
{
|
||||
/* if(event->keyval == GDK_Shift_L ||
|
||||
event->keyval == GDK_Shift_R) {
|
||||
return TRUE;
|
||||
}
|
||||
keys[lastkey] = event->keyval;
|
||||
++lastkey;
|
||||
if(lastkey >= NUMKEYS) {
|
||||
lastkey = 0;
|
||||
}*/
|
||||
|
||||
if(event->keyval == 'q') {
|
||||
gtk_exit(0);
|
||||
/* exit(0);*/
|
||||
}
|
||||
if(event->keyval == 'p') {
|
||||
display_output_fig();
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gint
|
||||
key_release_event (GtkWidget * widget, GdkEventKey * event)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gint
|
||||
button_press_event (GtkWidget * widget, GdkEventKey * event)
|
||||
{
|
||||
struct dot *d;
|
||||
struct sensor_data s;
|
||||
GdkModifierType state;
|
||||
int x, y;
|
||||
|
||||
gdk_window_get_pointer (event->window, &x, &y, &state);
|
||||
|
||||
x = ((GdkEventButton*)event)->x / SCALE;
|
||||
y = ((GdkEventButton*)event)->y / SCALE;
|
||||
|
||||
if(state & GDK_BUTTON1_MASK) {
|
||||
d = (struct dot *)memb_alloc(&dotsmem);
|
||||
|
||||
if(d != NULL) {
|
||||
d->x = x;
|
||||
d->y = y;
|
||||
d->size = sensor_strength();
|
||||
d->intensity = DOT_INTENSITY - 2;
|
||||
list_push(dots, d);
|
||||
}
|
||||
sensor_data_init(&s);
|
||||
s.pir = 1;
|
||||
s.button = 0;
|
||||
s.vib = 0;
|
||||
ether_send_sensor_data(&s, x, y, sensor_strength());
|
||||
} else if(state & GDK_BUTTON2_MASK) {
|
||||
sensor_data_init(&s);
|
||||
s.pir = 0;
|
||||
s.button = 1;
|
||||
s.vib = 0;
|
||||
if(marked_node != NULL) {
|
||||
ether_send_sensor_data(&s, marked_node->x, marked_node->y, 1);
|
||||
}
|
||||
} else if(state & GDK_BUTTON3_MASK) {
|
||||
sensor_data_init(&s);
|
||||
s.pir = 0;
|
||||
s.button = 0;
|
||||
s.vib = 1;
|
||||
if(marked_node != NULL) {
|
||||
ether_send_sensor_data(&s, marked_node->x, marked_node->y, 1);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gint
|
||||
pointer_motion_event (GtkWidget * widget, GdkEventMotion * event)
|
||||
{
|
||||
struct dot *d;
|
||||
struct sensor_data s;
|
||||
GdkModifierType state;
|
||||
|
||||
int x, y;
|
||||
struct nodes_node *node, *closest;
|
||||
int nodex, nodey;
|
||||
unsigned long dist;
|
||||
int i;
|
||||
|
||||
if(event->is_hint) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gdk_window_get_pointer (event->window, &x, &y, &state);
|
||||
x /= SCALE;
|
||||
y /= SCALE;
|
||||
|
||||
|
||||
if(state & GDK_BUTTON1_MASK) {
|
||||
d = (struct dot *)memb_alloc(&dotsmem);
|
||||
|
||||
if(d != NULL) {
|
||||
d->x = x;
|
||||
d->y = y;
|
||||
d->size = sensor_strength();
|
||||
d->intensity = DOT_INTENSITY - 2;
|
||||
list_push(dots, d);
|
||||
}
|
||||
sensor_data_init(&s);
|
||||
s.pir = 1;
|
||||
ether_send_sensor_data(&s, x, y, sensor_strength());
|
||||
} else {
|
||||
|
||||
|
||||
/* Find the closest node and mark it. */
|
||||
closest = NULL;
|
||||
dist = 0;
|
||||
for(i = 0; i < nodes_num(); ++i) {
|
||||
node = nodes_node(i);
|
||||
nodex = node->x;
|
||||
nodey = node->y;
|
||||
|
||||
if(closest == NULL ||
|
||||
(x - nodex) * (x - nodex) + (y - nodey) * (y - nodey) < dist) {
|
||||
dist = (x - nodex) * (x - nodex) + (y - nodey) * (y - nodey);
|
||||
closest = node;
|
||||
}
|
||||
}
|
||||
marked_node = closest;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
quit(void)
|
||||
{
|
||||
gtk_exit(0);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void (* idle)(void);
|
||||
static gint
|
||||
idle_callback(gpointer data)
|
||||
{
|
||||
idle();
|
||||
return TRUE;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static GdkGC *
|
||||
get_color(unsigned short r, unsigned short g, unsigned short b)
|
||||
{
|
||||
GdkGCValues values;
|
||||
GdkColor color;
|
||||
|
||||
color.pixel = 0;
|
||||
color.red = r;
|
||||
color.green = g;
|
||||
color.blue = b;
|
||||
|
||||
if(gdk_colormap_alloc_color(gdk_colormap_get_system(),
|
||||
&color, FALSE, TRUE)) {
|
||||
}
|
||||
|
||||
values.foreground = color;
|
||||
|
||||
return gdk_gc_new_with_values(drawing_area->window,
|
||||
&values,
|
||||
GDK_GC_FOREGROUND);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
stdin_callback(gpointer data, gint source, GdkInputCondition condition)
|
||||
{
|
||||
char buf[1000];
|
||||
int len;
|
||||
|
||||
len = read(STDIN_FILENO, &buf, sizeof(buf));
|
||||
printf("read len %d\n", len);
|
||||
buf[len] = 0;
|
||||
ether_send_serial(buf);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
display_init(void (* idlefunc)(void), int time, int with_gui)
|
||||
{
|
||||
int i;
|
||||
GtkWidget *window;
|
||||
GtkWidget *vbox;
|
||||
GdkGCValues values;
|
||||
GdkColor color;
|
||||
|
||||
memb_init(&dotsmem);
|
||||
list_init(dots);
|
||||
list_init(tempdots);
|
||||
|
||||
gtk_init(NULL, NULL);
|
||||
|
||||
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_title(GTK_WINDOW(window), "Contiki simulation display");
|
||||
|
||||
vbox = gtk_vbox_new(FALSE, 0);
|
||||
gtk_container_add(GTK_CONTAINER (window), vbox);
|
||||
gtk_widget_show(vbox);
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT (window), "destroy",
|
||||
GTK_SIGNAL_FUNC (quit), NULL);
|
||||
|
||||
font = gdk_font_load("-*-courier-medium-r-*-*-12-*-*-*-*-*-iso8859-1");
|
||||
|
||||
/* Create the drawing area */
|
||||
|
||||
drawing_area = gtk_drawing_area_new();
|
||||
gtk_drawing_area_size(GTK_DRAWING_AREA (drawing_area),
|
||||
DISPLAY_WIDTH,
|
||||
DISPLAY_HEIGHT);
|
||||
gtk_box_pack_start(GTK_BOX(vbox), drawing_area, TRUE, TRUE, 0);
|
||||
|
||||
gtk_widget_show(drawing_area);
|
||||
|
||||
/* Signals used to handle backing pixmap */
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT (drawing_area), "expose_event",
|
||||
(GtkSignalFunc) expose_event, NULL);
|
||||
gtk_signal_connect(GTK_OBJECT (drawing_area), "configure_event",
|
||||
(GtkSignalFunc) configure_event, NULL);
|
||||
|
||||
/* Event signals */
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT (window), "key_press_event",
|
||||
(GtkSignalFunc) key_press_event, NULL);
|
||||
gtk_signal_connect(GTK_OBJECT (window), "key_release_event",
|
||||
(GtkSignalFunc) key_release_event, NULL);
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT (window), "button_press_event",
|
||||
(GtkSignalFunc) button_press_event, NULL);
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT (window), "motion_notify_event",
|
||||
(GtkSignalFunc) pointer_motion_event, NULL);
|
||||
|
||||
gtk_widget_set_events(drawing_area,GDK_KEY_PRESS_MASK
|
||||
| GDK_KEY_RELEASE_MASK | GDK_BUTTON_PRESS_MASK
|
||||
| GDK_POINTER_MOTION_MASK);
|
||||
|
||||
/* gtk_window_iconify(window);*/
|
||||
if(with_gui) {
|
||||
gtk_widget_show(window);
|
||||
window_is_open = with_gui;
|
||||
}
|
||||
|
||||
|
||||
idle = idlefunc;
|
||||
gtk_timeout_add(time, idle_callback, NULL);
|
||||
|
||||
if(with_gui) {
|
||||
|
||||
for(i = 0; i < DOT_INTENSITY; ++i) {
|
||||
color.pixel = 0;
|
||||
color.red = 0;
|
||||
color.green = ((DOT_INTENSITY + 1) * 0xffff) / (i + 1);
|
||||
color.blue = ((DOT_INTENSITY + 1) * 0xffff) / (i + 1);
|
||||
|
||||
if(gdk_colormap_alloc_color(gdk_colormap_get_system(),
|
||||
&color, FALSE, TRUE)) {
|
||||
}
|
||||
|
||||
values.foreground = color;
|
||||
|
||||
intensity_gcs[i] = gdk_gc_new_with_values(drawing_area->window, &values,
|
||||
GDK_GC_FOREGROUND);
|
||||
}
|
||||
|
||||
color.pixel = 0;
|
||||
color.red = 0xbfff;
|
||||
color.green = 0xbfff;
|
||||
color.blue = 0xbfff;
|
||||
|
||||
if(gdk_colormap_alloc_color(gdk_colormap_get_system(),
|
||||
&color, FALSE, TRUE)) {
|
||||
}
|
||||
|
||||
values.foreground = color;
|
||||
|
||||
intensity_clusterhead = gdk_gc_new_with_values(drawing_area->window, &values,
|
||||
GDK_GC_FOREGROUND);
|
||||
|
||||
color.pixel = 0;
|
||||
color.red = 0xefff;
|
||||
color.green = 0xefff;
|
||||
color.blue = 0xefff;
|
||||
|
||||
if(gdk_colormap_alloc_color(gdk_colormap_get_system(),
|
||||
&color, FALSE, TRUE)) {
|
||||
}
|
||||
|
||||
values.foreground = color;
|
||||
|
||||
intensity_clusterhead_lightgray = gdk_gc_new_with_values(drawing_area->window, &values,
|
||||
GDK_GC_FOREGROUND);
|
||||
|
||||
color.pixel = 0;
|
||||
color.red = 0xffff;
|
||||
color.green = 0;
|
||||
color.blue = 0;
|
||||
|
||||
if(gdk_colormap_alloc_color(gdk_colormap_get_system(),
|
||||
&color, FALSE, TRUE)) {
|
||||
}
|
||||
|
||||
values.foreground = color;
|
||||
|
||||
intensity_clusterhead_red = gdk_gc_new_with_values(drawing_area->window, &values,
|
||||
GDK_GC_FOREGROUND);
|
||||
|
||||
|
||||
red = get_color(0xffff, 0, 0);
|
||||
green = get_color(0, 0xffff, 0);
|
||||
yellow = get_color(0xffff, 0xffff, 0);
|
||||
black = get_color(0, 0, 0);
|
||||
white = get_color(0xffff, 0xffff, 0xffff);
|
||||
}
|
||||
|
||||
gdk_input_add(STDIN_FILENO, GDK_INPUT_READ, stdin_callback, NULL);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
display_run(void)
|
||||
{
|
||||
gtk_main();
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
display_output_fig(void)
|
||||
{
|
||||
int i;
|
||||
struct nodes_node *n;
|
||||
int x, y;
|
||||
int dot_radius = 75;
|
||||
int scale = 50;
|
||||
FILE *fp;
|
||||
char name[40];
|
||||
struct timeval tv;
|
||||
|
||||
gettimeofday(&tv, NULL);
|
||||
snprintf(name, sizeof(name), "network-%lu.fig", tv.tv_sec);
|
||||
|
||||
fp = fopen(name, "w");
|
||||
fprintf(fp, "#FIG 3.2\n"
|
||||
"Landscape\n"
|
||||
"Center\n"
|
||||
"Inches\n"
|
||||
"Letter\n"
|
||||
"100.00\n"
|
||||
"Single\n"
|
||||
"-2\n"
|
||||
"1200 2\n"
|
||||
);
|
||||
|
||||
for(i = 0; i < nodes_num(); ++i) {
|
||||
n = nodes_node(i);
|
||||
x = n->x * scale;
|
||||
y = n->y * scale;
|
||||
|
||||
fprintf(fp, "1 3 1 1 0 7 50 -1 0 4.000 1 0.0000 %d %d %d %d %d %d %d %d\n",
|
||||
x, y,
|
||||
dot_radius, dot_radius,
|
||||
x, y,
|
||||
x + dot_radius, y + dot_radius);
|
||||
|
||||
if(strlen(n->text) > 0) {
|
||||
fprintf(fp, "4 0 0 50 -1 16 18 0.0000 4 135 720 %d %d %s\\001\n",
|
||||
x + 2 * scale, y, n->text);
|
||||
}
|
||||
|
||||
if(n->linex != 0 && n->liney != 0) {
|
||||
fprintf(fp, "2 1 1 1 0 7 50 -1 -1 0.000 0 0 -1 0 1 2\n"
|
||||
"1 1 4.00 60.00 120.00\n"
|
||||
"%d %d %d %d\n",
|
||||
x, y,
|
||||
n->linex * scale, n->liney * scale);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2004 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. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*
|
||||
* $Id: display.h,v 1.2 2008/05/14 19:22:57 adamdunkels Exp $
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __DISPLAY_H__
|
||||
#define __DISPLAY_H__
|
||||
|
||||
|
||||
void display_redraw(void);
|
||||
void display_init(void (* idle)(void), int time, int with_gui);
|
||||
void display_run(void);
|
||||
|
||||
void display_tick(void);
|
||||
|
||||
void display_output_fig(void);
|
||||
|
||||
#endif /* __DISPLAY_H__ */
|
|
@ -1,698 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2004, 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.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: ether.c,v 1.17 2010/10/19 18:29:05 adamdunkels Exp $
|
||||
*/
|
||||
/**
|
||||
* \file
|
||||
* This module implements a simple "ether", into which datapackets can
|
||||
* be injected. The packets are delivered to all nodes that are in
|
||||
* transmission range.
|
||||
*
|
||||
* \author Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include "ether.h"
|
||||
#include "lib/memb.h"
|
||||
#include "lib/list.h"
|
||||
#include "nodes.h"
|
||||
|
||||
#include "dev/radio-sensor.h"
|
||||
|
||||
#include "dev/serial-line.h"
|
||||
|
||||
#include "sensor.h"
|
||||
|
||||
#include "node.h"
|
||||
#include "net/uip.h"
|
||||
#include "net/uip-fw.h"
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif /* NULL */
|
||||
|
||||
MEMB(packets, struct ether_packet, 20000);
|
||||
LIST(active_packets);
|
||||
|
||||
static u8_t rxbuffer[2048];
|
||||
static clock_time_t timer;
|
||||
|
||||
#define BUF ((struct uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN])
|
||||
|
||||
#define PRINTF(...)
|
||||
/*#define PRINTF(x) printf x*/
|
||||
|
||||
static int s, sc;
|
||||
|
||||
#define PTYPE_NONE 0
|
||||
#define PTYPE_CLOCK 1
|
||||
#define PTYPE_DATA 2
|
||||
#define PTYPE_SENSOR 3
|
||||
#define PTYPE_LEDS 4
|
||||
#define PTYPE_TEXT 5
|
||||
#define PTYPE_DONE 6
|
||||
#define PTYPE_SERIAL 7
|
||||
#define PTYPE_RADIO_STATUS 8
|
||||
|
||||
#define SERIAL_LEN 80
|
||||
|
||||
struct ether_hdr {
|
||||
int type;
|
||||
struct sensor_data sensor_data;
|
||||
clock_time_t clock;
|
||||
int linex, liney;
|
||||
int signal;
|
||||
int srcx, srcy;
|
||||
int srcpid;
|
||||
int srcid;
|
||||
int srcnodetype;
|
||||
int leds;
|
||||
int radio_status;
|
||||
char text[NODES_TEXTLEN + SERIAL_LEN];
|
||||
};
|
||||
|
||||
static int strength;
|
||||
|
||||
static int collisions = 1;
|
||||
static int num_collisions = 0;
|
||||
static int num_sent = 0;
|
||||
static int num_received = 0;
|
||||
static int drop_probability = 0;
|
||||
static int num_drops = 0;
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
static struct timeval t1;
|
||||
|
||||
static int linex, liney;
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
ether_print_stats(void)
|
||||
{
|
||||
unsigned long time;
|
||||
struct timeval t2;
|
||||
gettimeofday(&t2, NULL);
|
||||
|
||||
time = (t2.tv_sec * 1000 + t2.tv_usec / 1000) -
|
||||
(t1.tv_sec * 1000 + t1.tv_usec / 1000);
|
||||
/* printf("%d, %d, %f\n", num_packets, num_collisions, time/1000.0);*/
|
||||
printf("Time: %f\n", time/1000.0);
|
||||
printf("Total packets sent: %d\n", num_sent);
|
||||
printf("Total collisions: %d\n", num_collisions);
|
||||
printf("Total packets receptions: %d\n", num_received);
|
||||
printf("Total randomly dropped packets: %d\n", num_drops);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
ether_set_drop_probability(double p)
|
||||
{
|
||||
drop_probability = p * 65536;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
ether_set_collisions(int c)
|
||||
{
|
||||
collisions = c;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
ether_set_strength(int s)
|
||||
{
|
||||
strength = s;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
int
|
||||
ether_strength(void)
|
||||
{
|
||||
return strength;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
ether_server_init(void)
|
||||
{
|
||||
struct sockaddr_in sa;
|
||||
|
||||
gettimeofday(&t1, NULL);
|
||||
|
||||
memb_init(&packets);
|
||||
list_init(active_packets);
|
||||
|
||||
timer = 0;
|
||||
|
||||
s = socket(AF_INET,SOCK_DGRAM,0);
|
||||
|
||||
if(s < 0) {
|
||||
perror("ether_server_init: socket");
|
||||
}
|
||||
|
||||
memset((char *)&sa, 0, sizeof(sa));
|
||||
|
||||
sa.sin_family = AF_INET;
|
||||
sa.sin_addr.s_addr = inet_addr("127.0.0.1");/*uip_htonl(INADDR_ANY);*/
|
||||
|
||||
sa.sin_port = uip_htons(ETHER_PORT);
|
||||
|
||||
/* printf("Binding to port %d\n", ETHER_PORT);*/
|
||||
|
||||
if(bind(s, (struct sockaddr *)&sa, sizeof(sa)) < 0) {
|
||||
printf("Bind to port %d\n", ETHER_PORT);
|
||||
perror("bind");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
ether_client_init(int port)
|
||||
{
|
||||
struct sockaddr_in sa;
|
||||
|
||||
sc = socket(AF_INET,SOCK_DGRAM,0);
|
||||
|
||||
if(sc < 0) {
|
||||
perror("socket");
|
||||
}
|
||||
|
||||
memset((char *)&sa, 0, sizeof(sa));
|
||||
|
||||
sa.sin_family = AF_INET;
|
||||
sa.sin_addr.s_addr = inet_addr("127.0.0.1");/*uip_htonl(INADDR_ANY);*/
|
||||
|
||||
sa.sin_port = uip_htons(port);
|
||||
|
||||
/* printf("ether_client_init: binding to port %d\n", port);*/
|
||||
if(bind(sc, (struct sockaddr *)&sa, sizeof(sa)) < 0) {
|
||||
printf("Bind to port %d\n", port);
|
||||
perror("bind");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
int
|
||||
ether_client_poll(void)
|
||||
{
|
||||
fd_set fdset;
|
||||
struct timeval tv;
|
||||
int ret;
|
||||
|
||||
FD_ZERO(&fdset);
|
||||
FD_SET(sc, &fdset);
|
||||
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = 1000;
|
||||
|
||||
ret = select(sc + 1, &fdset, NULL, NULL, &tv);
|
||||
|
||||
if(ret < 0) {
|
||||
perror("ether_client_poll: select");
|
||||
}
|
||||
return ret == 1;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
u16_t
|
||||
ether_client_read(u8_t *buf, int bufsize)
|
||||
{
|
||||
int ret, len;
|
||||
fd_set fdset;
|
||||
struct timeval tv;
|
||||
struct ether_hdr *hdr = (struct ether_hdr *)rxbuffer;
|
||||
|
||||
FD_ZERO(&fdset);
|
||||
FD_SET(sc, &fdset);
|
||||
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = 10000;
|
||||
|
||||
ret = select(sc + 1, &fdset, NULL, NULL, &tv);
|
||||
|
||||
if(ret == 0) {
|
||||
/* printf("ret 0\n");*/
|
||||
return 0;
|
||||
}
|
||||
if(FD_ISSET(sc, &fdset)) {
|
||||
ret = recv(sc, &rxbuffer[0], sizeof(rxbuffer), 0);
|
||||
if(ret == -1) {
|
||||
perror("ether_client_poll: recv");
|
||||
return 0;
|
||||
}
|
||||
len = ret;
|
||||
|
||||
if(len > bufsize) {
|
||||
PRINTF("ether_client_read: packet truncated from %d to %d\n",
|
||||
len, bufsize);
|
||||
len = bufsize;
|
||||
}
|
||||
|
||||
/* printf("Incoming len %d\n", len);*/
|
||||
memcpy(buf, &rxbuffer[sizeof(struct ether_hdr)], len);
|
||||
radio_sensor_signal = hdr->signal;
|
||||
|
||||
if(hdr->type == PTYPE_DATA && hdr->srcid != node.id) {
|
||||
return len - sizeof(struct ether_hdr);
|
||||
} else if(hdr->type == PTYPE_CLOCK) {
|
||||
node_set_time(hdr->clock);
|
||||
} else if(hdr->type == PTYPE_SENSOR) {
|
||||
int strength = sensor_strength() -
|
||||
((hdr->srcx - node_x()) * (hdr->srcx - node_x()) +
|
||||
(hdr->srcy - node_y()) * (hdr->srcy - node_y())) / sensor_strength();
|
||||
/* printf("Dist %d \n", strength);*/
|
||||
if(strength > 0) {
|
||||
sensor_input(&hdr->sensor_data, strength);
|
||||
}
|
||||
} else if(hdr->type == PTYPE_SERIAL) {
|
||||
char *ptr = hdr->text;
|
||||
printf("serial input %s\n", ptr);
|
||||
for(ptr = hdr->text; *ptr != 0; ++ptr) {
|
||||
serial_line_input_byte(*ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
ether_server_poll(void)
|
||||
{
|
||||
int ret;
|
||||
fd_set fdset;
|
||||
struct timeval tv;
|
||||
struct ether_hdr *hdr = (struct ether_hdr *)rxbuffer;
|
||||
/* struct timeval rtime1, rtime2;
|
||||
struct timespec ts;
|
||||
struct timezone tz;*/
|
||||
|
||||
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = 100;
|
||||
|
||||
|
||||
do {
|
||||
FD_ZERO(&fdset);
|
||||
FD_SET(s, &fdset);
|
||||
|
||||
ret = select(s + 1, &fdset, NULL, NULL, &tv);
|
||||
if(ret == 0) {
|
||||
return;
|
||||
}
|
||||
if(FD_ISSET(s, &fdset)) {
|
||||
ret = recv(s, &rxbuffer[0], sizeof(rxbuffer), 0);
|
||||
if(ret == -1) {
|
||||
perror("ether_poll: read");
|
||||
return;
|
||||
}
|
||||
nodes_set_line(hdr->srcx, hdr->srcy, hdr->linex, hdr->liney);
|
||||
switch(hdr->type) {
|
||||
case PTYPE_DATA:
|
||||
PRINTF("ether_poll: read %d bytes from (%d, %d)\n",
|
||||
ret, hdr->srcx, hdr->srcy);
|
||||
ether_put((char *)rxbuffer, ret, hdr->srcx, hdr->srcy);
|
||||
break;
|
||||
case PTYPE_LEDS:
|
||||
nodes_set_leds(hdr->srcx, hdr->srcy, hdr->leds);
|
||||
break;
|
||||
case PTYPE_TEXT:
|
||||
nodes_set_text(hdr->srcx, hdr->srcy, hdr->text);
|
||||
break;
|
||||
case PTYPE_DONE:
|
||||
nodes_done(hdr->srcid);
|
||||
break;
|
||||
case PTYPE_SERIAL:
|
||||
break;
|
||||
case PTYPE_RADIO_STATUS:
|
||||
nodes_set_radio_status(hdr->srcx, hdr->srcy, hdr->radio_status);
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* tv.tv_sec = 0;
|
||||
tv.tv_usec = 1;*/
|
||||
|
||||
} while(1/*ret > 0*/);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
ether_put(char *data, int len, int x, int y)
|
||||
{
|
||||
struct ether_packet *p;
|
||||
|
||||
/* printf("ether_put: packet len %d at (%d, %d)\n", len, x, y);*/
|
||||
|
||||
p = (struct ether_packet *)memb_alloc(&packets);
|
||||
|
||||
if(p != NULL) {
|
||||
if(len > 1500) {
|
||||
len = 1500;
|
||||
}
|
||||
memcpy(p->data, data, len);
|
||||
p->len = len;
|
||||
p->x = x;
|
||||
p->y = y;
|
||||
list_push(active_packets, p);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
send_packet(char *data, int len, int port)
|
||||
{
|
||||
struct sockaddr_in sa;
|
||||
|
||||
memset((char *)&sa, 0, sizeof(sa));
|
||||
sa.sin_family = AF_INET;
|
||||
sa.sin_addr.s_addr = inet_addr("127.0.0.1");
|
||||
sa.sin_port = uip_htons(port);
|
||||
|
||||
if(sendto(s, data, len, 0, (struct sockaddr *)&sa, sizeof(sa)) == -1) {
|
||||
perror("ether: send_packet: sendto");
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
ether_tick(void)
|
||||
{
|
||||
struct ether_packet *p, *q;
|
||||
struct ether_hdr *hdr;
|
||||
int port;
|
||||
int x, y;
|
||||
int i;
|
||||
int interference;
|
||||
|
||||
/* Go through every node and see if there are any packets destined
|
||||
to them. If two or more packets are sent in the vicinity of the
|
||||
node, they interfere with each otehr and none reaches the
|
||||
node. */
|
||||
for(i = 0; i < nodes_num(); ++i) {
|
||||
|
||||
x = nodes_node(i)->x;
|
||||
y = nodes_node(i)->y;
|
||||
port = nodes_node(i)->port;
|
||||
|
||||
/* Go through all active packets to see if anyone is sent within
|
||||
range of this node. */
|
||||
for(p = list_head(active_packets); p != NULL; p = p->next) {
|
||||
|
||||
num_sent++;
|
||||
|
||||
/* Update the node type. */
|
||||
hdr = (struct ether_hdr *)p->data;
|
||||
/* nodes_node(hdr->srcid)->type = hdr->srcnodetype;*/
|
||||
|
||||
if(!(p->x == x && p->y == y) && /* Don't send packets back to
|
||||
the sender. */
|
||||
(p->x - x) * (p->x - x) +
|
||||
(p->y - y) * (p->y - y) <=
|
||||
ether_strength() * ether_strength()) {
|
||||
|
||||
hdr->signal = ether_strength() * ether_strength() -
|
||||
(p->x - x) * (p->x - x) -
|
||||
(p->y - y) * (p->y - y);
|
||||
/* This packet was sent in the reception range of this node,
|
||||
so we check against all other packets to see if there is
|
||||
more than one packet sent towards this node. If so, we have
|
||||
interference and the node will not be able to receive any
|
||||
data. */
|
||||
interference = 0;
|
||||
if(collisions) {
|
||||
for(q = list_head(active_packets); q != NULL; q = q->next) {
|
||||
|
||||
/* Compute the distance^2 and check against signal strength. */
|
||||
if(p != q &&
|
||||
((q->x - x) * (q->x - x) +
|
||||
(q->y - y) * (q->y - y) <=
|
||||
ether_strength() * ether_strength())) {
|
||||
|
||||
/* If the potentially interfering packets were sent from
|
||||
the same node, then they don't interfere with each
|
||||
other. Otherwise they interfere and we sent the
|
||||
interference flag to 1. */
|
||||
if(p->x != q->x ||
|
||||
p->y != q->y) {
|
||||
interference = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(interference) {
|
||||
num_collisions++;
|
||||
/* printf("Collisions %d\n", num_collisions);*/
|
||||
}
|
||||
|
||||
if(!interference) {
|
||||
/* printf("ether: delivering packet from %d to %d\n",
|
||||
hdr->srcid, port);*/
|
||||
if((unsigned int)((rand() * 17) % 65536) >= drop_probability) {
|
||||
send_packet(p->data, p->len, port);
|
||||
num_received++;
|
||||
} else {
|
||||
num_drops++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* Remove all packets from the active packets list. */
|
||||
while((p = list_pop(active_packets)) != NULL) {
|
||||
memb_free(&packets, (void *) p);
|
||||
}
|
||||
|
||||
++timer;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
struct ether_packet *
|
||||
ether_packets(void)
|
||||
{
|
||||
return list_head(active_packets);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
clock_time_t
|
||||
ether_time(void)
|
||||
{
|
||||
return timer;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
node_send_packet(char *data, int len)
|
||||
{
|
||||
struct sockaddr_in sa;
|
||||
|
||||
memset((char *)&sa, 0, sizeof(sa));
|
||||
sa.sin_family = AF_INET;
|
||||
sa.sin_addr.s_addr = inet_addr("127.0.0.1");
|
||||
sa.sin_port = uip_htons(ETHER_PORT);
|
||||
|
||||
if(sendto(sc, data, len, 0,
|
||||
(struct sockaddr *)&sa, sizeof(sa)) == -1) {
|
||||
perror("ether.c node_send_packet: sendto");
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
u8_t
|
||||
ether_send(char *data, int len)
|
||||
{
|
||||
char tmpbuf[2048];
|
||||
struct ether_hdr *hdr = (struct ether_hdr *)tmpbuf;
|
||||
|
||||
|
||||
memcpy(&tmpbuf[sizeof(struct ether_hdr)], data, len);
|
||||
|
||||
hdr->srcx = node.x;
|
||||
hdr->srcy = node.y;
|
||||
hdr->type = PTYPE_DATA;
|
||||
/* hdr->srcnodetype = node.type;*/
|
||||
hdr->srcid = node.id;
|
||||
|
||||
hdr->linex = linex;
|
||||
hdr->liney = liney;
|
||||
node_send_packet(tmpbuf, len + sizeof(struct ether_hdr));
|
||||
|
||||
return UIP_FW_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
ether_set_leds(int leds)
|
||||
{
|
||||
struct ether_hdr hdr;
|
||||
|
||||
memset(&hdr, 0, sizeof (hdr));
|
||||
hdr.srcx = node.x;
|
||||
hdr.srcy = node.y;
|
||||
hdr.type = PTYPE_LEDS;
|
||||
hdr.leds = leds;
|
||||
/* hdr.srcnodetype = node.type;*/
|
||||
hdr.srcid = node.id;
|
||||
hdr.linex = linex;
|
||||
hdr.liney = liney;
|
||||
|
||||
node_send_packet((char *)&hdr, sizeof(struct ether_hdr));
|
||||
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
ether_set_text(char *text)
|
||||
{
|
||||
struct ether_hdr hdr;
|
||||
|
||||
hdr.srcx = node.x;
|
||||
hdr.srcy = node.y;
|
||||
hdr.type = PTYPE_TEXT;
|
||||
strncpy(hdr.text, text, NODES_TEXTLEN);
|
||||
/* hdr.srcnodetype = node.type;*/
|
||||
hdr.srcid = node.id;
|
||||
hdr.linex = linex;
|
||||
hdr.liney = liney;
|
||||
|
||||
node_send_packet((char *)&hdr, sizeof(struct ether_hdr));
|
||||
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
ether_set_radio_status(int onoroff)
|
||||
{
|
||||
struct ether_hdr hdr;
|
||||
|
||||
hdr.srcx = node.x;
|
||||
hdr.srcy = node.y;
|
||||
hdr.type = PTYPE_RADIO_STATUS;
|
||||
hdr.radio_status = onoroff;
|
||||
hdr.srcid = node.id;
|
||||
hdr.linex = linex;
|
||||
hdr.liney = liney;
|
||||
|
||||
node_send_packet((char *)&hdr, sizeof(struct ether_hdr));
|
||||
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
ether_send_sensor_data(struct sensor_data *d, int srcx, int srcy, int strength)
|
||||
{
|
||||
int port;
|
||||
int x, y;
|
||||
int i;
|
||||
struct ether_hdr hdr;
|
||||
|
||||
/* printf("Sensor data at (%d, %d)\n", srcx, srcy);*/
|
||||
|
||||
for(i = 0; i < nodes_num(); ++i) {
|
||||
|
||||
x = nodes_node(i)->x;
|
||||
y = nodes_node(i)->y;
|
||||
port = nodes_node(i)->port;
|
||||
|
||||
if((srcx - x) * (srcx - x) +
|
||||
(srcy - y) * (srcy - y) <=
|
||||
strength * strength) {
|
||||
|
||||
hdr.srcx = srcx;
|
||||
hdr.srcy = srcy;
|
||||
hdr.type = PTYPE_SENSOR;
|
||||
hdr.sensor_data = *d;
|
||||
send_packet((char *)&hdr, sizeof(hdr), port);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
ether_send_done(void)
|
||||
{
|
||||
struct ether_hdr hdr;
|
||||
|
||||
hdr.srcx = node.x;
|
||||
hdr.srcy = node.y;
|
||||
hdr.type = PTYPE_DONE;
|
||||
hdr.srcid = node.id;
|
||||
|
||||
node_send_packet((char *)&hdr, sizeof(struct ether_hdr));
|
||||
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
ether_send_serial(char *str)
|
||||
{
|
||||
struct ether_hdr hdr;
|
||||
int len;
|
||||
|
||||
|
||||
hdr.srcx = node.x;
|
||||
hdr.srcy = node.y;
|
||||
hdr.type = PTYPE_SERIAL;
|
||||
hdr.srcid = node.id;
|
||||
len = strlen(str) + 1;
|
||||
if(len > sizeof(hdr.text)) {
|
||||
len = sizeof(hdr.text);
|
||||
}
|
||||
memcpy(&hdr.text, str, len);
|
||||
hdr.text[len] = 0;
|
||||
|
||||
/* printf("ether_send_serial '%s' to %d len %d\n", str, nodes_base_node_port, sizeof(struct ether_hdr));*/
|
||||
|
||||
send_packet((char *)&hdr, sizeof(struct ether_hdr), nodes_base_node_port);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
ether_set_line(int x, int y)
|
||||
{
|
||||
struct ether_hdr hdr;
|
||||
|
||||
linex = x;
|
||||
liney = y;
|
||||
|
||||
|
||||
hdr.srcx = node.x;
|
||||
hdr.srcy = node.y;
|
||||
hdr.type = PTYPE_NONE;
|
||||
hdr.srcid = node.id;
|
||||
hdr.linex = linex;
|
||||
hdr.liney = liney;
|
||||
|
||||
node_send_packet((char *)&hdr, sizeof(struct ether_hdr));
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
|
@ -1,92 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2004, 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.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: ether.h,v 1.9 2008/05/14 19:22:58 adamdunkels Exp $
|
||||
*/
|
||||
#ifndef __ETHER_H__
|
||||
#define __ETHER_H__
|
||||
|
||||
#include "contiki.h"
|
||||
#include "sensor.h"
|
||||
|
||||
struct ether_packet {
|
||||
struct ether_packet *next;
|
||||
char data[1500];
|
||||
int len;
|
||||
int x, y;
|
||||
int destx, desty;
|
||||
};
|
||||
|
||||
|
||||
void ether_send_done(void);
|
||||
|
||||
u8_t ether_send(char *data, int len);
|
||||
void ether_set_leds(int leds);
|
||||
void ether_set_text(char *text);
|
||||
|
||||
void ether_set_radio_status(int onoroff);
|
||||
void ether_send_serial(char *text);
|
||||
|
||||
|
||||
void ether_poll(void);
|
||||
void ether_server_init(void);
|
||||
void ether_client_init(int port);
|
||||
void ether_tick(void);
|
||||
|
||||
|
||||
u16_t ether_client_read(u8_t *buf, int len);
|
||||
void ether_server_poll(void);
|
||||
|
||||
void ether_put(char *packet, int len, int src_x, int src_y);
|
||||
|
||||
void ether_send_sensor_data(struct sensor_data *d, int srcx, int srcy, int strength);
|
||||
|
||||
|
||||
int ether_client_poll(void);
|
||||
|
||||
struct ether_packet * ether_packets(void);
|
||||
|
||||
clock_time_t ether_time(void);
|
||||
|
||||
#define ETHER_PORT 4999
|
||||
/*#define ETHER_STRENGTH 24*/
|
||||
int ether_strength(void);
|
||||
void ether_set_strength(int s);
|
||||
void ether_set_collisions(int c);
|
||||
void ether_set_drop_probability(double p);
|
||||
|
||||
void ether_print_stats(void);
|
||||
|
||||
void ether_set_line(int x, int y);
|
||||
|
||||
|
||||
#endif /* __ETHER_H__ */
|
|
@ -1,70 +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.
|
||||
*
|
||||
* @(#)$Id: init.c,v 1.1 2006/06/17 22:41:35 adamdunkels Exp $
|
||||
*/
|
||||
#include "init.h"
|
||||
#include "random.h"
|
||||
|
||||
void
|
||||
init(void)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
ether_set_strength(21);
|
||||
|
||||
main_add_node(1, 1);
|
||||
main_add_node(1, 20);
|
||||
main_add_node(20, 1);
|
||||
|
||||
/*for(x = 1; x < 201; x += 20) {
|
||||
for(y = 1; y < 201; y += 20) {
|
||||
main_add_node(x, y);
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
/* main_add_node(10, 10);
|
||||
main_add_node(11, 11);
|
||||
main_add_node(12, 12);
|
||||
main_add_node(13, 13);
|
||||
main_add_node(14, 14);
|
||||
main_add_node(15, 15);
|
||||
main_add_node(16, 16); */
|
||||
|
||||
/* for(x = 10; x < 370; x += 20) {
|
||||
for(y = 10; y < 370; y += 20) {
|
||||
main_add_node(x + (random_rand() % 20) - 10,
|
||||
y + (random_rand() % 20) - 10);
|
||||
}
|
||||
}*/
|
||||
|
||||
/* main_add_base(1, 1);*/
|
||||
}
|
|
@ -1,43 +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.
|
||||
*
|
||||
* @(#)$Id: init.h,v 1.3 2007/11/17 18:09:18 adamdunkels Exp $
|
||||
*/
|
||||
#ifndef __INIT_H__
|
||||
#define __INIT_H__
|
||||
|
||||
#include "ether.h"
|
||||
|
||||
void init(void);
|
||||
|
||||
int main_add_node(int x, int y);
|
||||
void main_add_base(int x, int y);
|
||||
|
||||
#endif /* __INIT_H__ */
|
|
@ -1,48 +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.
|
||||
*
|
||||
* $Id: loader-arch.h,v 1.1 2006/06/17 22:41:35 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Loader definitions for the netsim target
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*/
|
||||
|
||||
#ifndef __LOADER_ARCH_H__
|
||||
#define __LOADER_ARCH_H__
|
||||
|
||||
#include "loader/dlloader.h"
|
||||
|
||||
#define LOADER_LOAD(name, arg) dlloader_load(name, arg);
|
||||
|
||||
#endif /* __LOADER_ARCH_H__ */
|
|
@ -1,296 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2004, 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.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: main.c,v 1.13 2008/11/09 12:30:32 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* This file implements the main function of the Contiki distributed
|
||||
* sensor network simulation environment.
|
||||
* \author Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* When starting, each sensor node is created as its own process. The
|
||||
* sensor node processes communicates with the starting process using
|
||||
* named pipes. These pipes carry messages such as data packets and
|
||||
* configuration and statistics information requests.
|
||||
*/
|
||||
#include "contiki-net.h"
|
||||
#include "display.h"
|
||||
#include "contiki-main.h"
|
||||
#include "nodes.h"
|
||||
#include "ether.h"
|
||||
#include "node.h"
|
||||
|
||||
#include "net/ethernode.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/wait.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
in_addr_t gwaddr, winifaddr;
|
||||
|
||||
void netsim_init(void);
|
||||
|
||||
static int main_process = 0;
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
sigchld_handler(int sig)
|
||||
{
|
||||
int status;
|
||||
pid_t pid;
|
||||
struct nodes_node *node;
|
||||
if(!main_process) {
|
||||
return;
|
||||
}
|
||||
|
||||
pid = waitpid(-1, &status, WNOHANG);
|
||||
|
||||
if(WIFSIGNALED(status) &&
|
||||
WTERMSIG(status) == SIGSEGV) {
|
||||
node = nodes_find_pid(pid);
|
||||
if(node == NULL) {
|
||||
printf("A Contiki node crashed, but it wasn't even started by the system. Something weird is going on!\n");
|
||||
} else {
|
||||
printf("Contiki node at (%d, %d) crashed - Segmentation fault\n",
|
||||
node->x, node->y);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
idle(void)
|
||||
{
|
||||
int events;
|
||||
|
||||
do {
|
||||
ether_server_poll();
|
||||
display_tick();
|
||||
display_redraw();
|
||||
ether_tick();
|
||||
events = process_run();
|
||||
if(events > 0) {
|
||||
printf("events %d\n", events);
|
||||
}
|
||||
} while(events > 0);
|
||||
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
start_node(int x, int y, int b)
|
||||
{
|
||||
pid_t pid;
|
||||
struct timeval tv;
|
||||
static unsigned short port = NODES_PORTBASE;
|
||||
|
||||
pid = fork();
|
||||
|
||||
if(pid == 0) {
|
||||
|
||||
/* This is the sensor process. */
|
||||
main_process = 0;
|
||||
|
||||
/* Make standard output unbuffered. */
|
||||
setvbuf(stdout, (char *)NULL, _IONBF, 0);
|
||||
|
||||
|
||||
srand(getpid());
|
||||
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = 1000 * (rand() % 1000);
|
||||
select(0, NULL, NULL, NULL, &tv);
|
||||
|
||||
node_init(port - NODES_PORTBASE + 2, x, y, b);
|
||||
ethernode_init(port);
|
||||
|
||||
contiki_main(b);
|
||||
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
if(b) {
|
||||
nodes_base_node_port = port;
|
||||
}
|
||||
|
||||
/* printf("Adding sensor %d at (%d,%d)\n", pid, x, y);*/
|
||||
main_process = 1;
|
||||
nodes_add(pid, x, y, port, port - NODES_PORTBASE + 2);
|
||||
|
||||
|
||||
++port;
|
||||
return port - NODES_PORTBASE + 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
main_add_node(int x, int y)
|
||||
{
|
||||
return start_node(x, y, 0);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
main_add_base(int x, int y)
|
||||
{
|
||||
start_node(x, y, 1);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
#ifdef __CYGWIN__
|
||||
if(argc == 3 &&
|
||||
inet_addr(argv[1]) == INADDR_NONE &&
|
||||
inet_addr(argv[2]) == INADDR_NONE) {
|
||||
printf("usage: %s <ip addr of ethernet card to share> "
|
||||
"<ip addr of netsim gateway>\n", argv[0]);
|
||||
exit(1);
|
||||
} else if(argc >= 2) {
|
||||
gwaddr = inet_addr(argv[2]);
|
||||
winifaddr = inet_addr(argv[1]);
|
||||
}
|
||||
#endif /* __CYGWIN__ */
|
||||
|
||||
/* system("ifconfig tap0 inet 192.168.250.1");*/
|
||||
/* system("route delete 172.16.0.0/16");
|
||||
system("route add 172.16.0.0/16 192.168.250.2");*/
|
||||
|
||||
nodes_init();
|
||||
|
||||
atexit(nodes_kill);
|
||||
atexit(ether_print_stats);
|
||||
|
||||
netsim_init();
|
||||
|
||||
ether_server_init();
|
||||
|
||||
#if 0
|
||||
while(1) {
|
||||
ether_server_poll();
|
||||
ether_tick();
|
||||
process_run();
|
||||
usleep(100);
|
||||
}
|
||||
#endif /* 0 */
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
if(argc > 1 && (strcmp(argv[1], "-q") ||
|
||||
strcmp(argv[2], "-q") ||
|
||||
strcmp(argv[3], "-q")) == 0) {
|
||||
#else /* __CYGWIN__ */
|
||||
if(argc > 1 && strcmp(argv[1], "-q") == 0) {
|
||||
#endif /* __CYGWIN__ */
|
||||
display_init(idle, 50, 0);
|
||||
} else {
|
||||
display_init(idle, 50, 1);
|
||||
}
|
||||
display_redraw();
|
||||
|
||||
signal(SIGCHLD, sigchld_handler);
|
||||
|
||||
display_run();
|
||||
|
||||
return 0;
|
||||
|
||||
argv = argv;
|
||||
argc = argc;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
char *arg_alloc(char size) {return NULL;}
|
||||
void arg_init(void) {}
|
||||
void arg_free(char *arg) {}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
char *shell_prompt_text = "sensor-router> ";
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
#include <sys/time.h>
|
||||
|
||||
static signed long drift = 0;
|
||||
|
||||
void
|
||||
clock_delay(unsigned int num)
|
||||
{
|
||||
struct timeval tv;
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = 100 * num;
|
||||
select(0, NULL, NULL, NULL, &tv);
|
||||
}
|
||||
|
||||
void
|
||||
clock_set_time(clock_time_t time, clock_time_t ftime)
|
||||
{
|
||||
drift = time - node_time();
|
||||
}
|
||||
|
||||
clock_time_t
|
||||
clock_time(void)
|
||||
{
|
||||
return drift + node_time();
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
unsigned long
|
||||
clock_seconds(void)
|
||||
{
|
||||
return node_seconds();
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
uip_log(char *m)
|
||||
{
|
||||
uip_ipaddr_t addr;
|
||||
|
||||
uip_gethostaddr(&addr);
|
||||
|
||||
printf("uIP log at %d.%d.%d.%d: %s\n", uip_ipaddr_to_quad(&addr), m);
|
||||
fflush(NULL);
|
||||
}
|
||||
void
|
||||
configurator_send_config(uip_ipaddr_t *addr, unsigned long seconds)
|
||||
{
|
||||
printf("Configurator: address %d.%d.%d.%d, seconds %lu\n",
|
||||
uip_ipaddr_to_quad(addr), seconds);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
system_log(char *m)
|
||||
{
|
||||
printf("%s", m);
|
||||
}
|
||||
/*void tr1001_drv_set_slip_dump(int c)
|
||||
{
|
||||
|
||||
}*/
|
|
@ -1,78 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2004, 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.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: ethernode-rime.c,v 1.7 2009/03/12 21:58:21 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
|
||||
#include "ethernode.h"
|
||||
|
||||
#include "net/rime.h"
|
||||
|
||||
#define DEBUG 0
|
||||
#if DEBUG
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) printf(__VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#endif
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
receiver(void)
|
||||
{
|
||||
u8_t len;
|
||||
|
||||
packetbuf_clear();
|
||||
|
||||
len = ethernode_read(packetbuf_dataptr(), PACKETBUF_SIZE);
|
||||
|
||||
if(len > 0) {
|
||||
packetbuf_set_datalen(len);
|
||||
rime_input();
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
ethernode_rime_send(void)
|
||||
{
|
||||
ethernode_send_buf(packetbuf_hdrptr(), packetbuf_totlen());
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
ethernode_rime_init(void)
|
||||
{
|
||||
ethernode_set_receiver(receiver);
|
||||
rime_set_output(ethernode_rime_send);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -1,48 +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.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: ethernode-rime.h,v 1.1 2007/03/13 13:07:48 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* A brief description of what this file is.
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*/
|
||||
|
||||
#ifndef __ETHERNODE_RIME_H__
|
||||
#define __ETHERNODE_RIME_H__
|
||||
|
||||
#include "contiki.h"
|
||||
|
||||
PROCESS_NAME(ethernode_rime_process);
|
||||
|
||||
#endif /* __ETHERNODE_RIME_H__ */
|
|
@ -1,99 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2004, 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.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: ethernode-uip.c,v 1.6 2008/01/04 21:59:13 oliverschmidt Exp $
|
||||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
|
||||
#include "ethernode.h"
|
||||
|
||||
#include "net/uip-fw.h"
|
||||
#include "net/hc.h"
|
||||
#ifdef __CYGWIN__
|
||||
#include "net/wpcap.h"
|
||||
#else /* __CYGWIN__ */
|
||||
#include "net/tapdev.h"
|
||||
#endif /* __CYGWIN__ */
|
||||
|
||||
#include "node-id.h"
|
||||
|
||||
PROCESS(ethernode_uip_process, "Ethernode driver");
|
||||
|
||||
enum { NULLEVENT };
|
||||
/*---------------------------------------------------------------------------*/
|
||||
u8_t
|
||||
ethernode_uip_send(void)
|
||||
{
|
||||
/* printf("%d: ethernode_uip_send\n", node_id);*/
|
||||
uip_len = hc_compress(&uip_buf[UIP_LLH_LEN], uip_len);
|
||||
|
||||
return ethernode_send();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(ethernode_uip_process, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
|
||||
while(1) {
|
||||
process_poll(ðernode_uip_process);
|
||||
PROCESS_WAIT_EVENT();
|
||||
|
||||
/* Poll Ethernet device to see if there is a frame avaliable. */
|
||||
uip_len = ethernode_read(uip_buf, UIP_BUFSIZE);
|
||||
|
||||
if(uip_len > 0) {
|
||||
/* printf("%d: new packet len %d\n", node_id, uip_len);*/
|
||||
|
||||
/* if((random_rand() % drop) <= drop / 2) {
|
||||
printf("Bropp\n");
|
||||
} else*/ {
|
||||
|
||||
uip_len = hc_inflate(&uip_buf[UIP_LLH_LEN], uip_len);
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
wpcap_send();
|
||||
#else /* __CYGWIN__ */
|
||||
tapdev_send();
|
||||
#endif /* __CYGWIN__ */
|
||||
/* if(uip_fw_forward() == UIP_FW_LOCAL)*/ {
|
||||
/* A frame was avaliable (and is now read into the uip_buf), so
|
||||
we process it. */
|
||||
tcpip_input();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
PROCESS_END();
|
||||
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -1,43 +0,0 @@
|
|||
/* Copyright (c) 2004, 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.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: ethernode-uip.h,v 1.2 2007/03/22 18:59:34 adamdunkels Exp $
|
||||
*/
|
||||
#ifndef __ETHERNODE_UIP_H__
|
||||
#define __ETHERNODE_UIP_H__
|
||||
|
||||
#include "contiki.h"
|
||||
|
||||
PROCESS_NAME(ethernode_uip_process);
|
||||
|
||||
u8_t ethernode_uip_send(void);
|
||||
|
||||
#endif /* __ETHERNODE_UIP_H__ */
|
|
@ -1,323 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2004, 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.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: ethernode.c,v 1.18 2010/06/14 19:19:17 adamdunkels Exp $
|
||||
*/
|
||||
/**
|
||||
* \file
|
||||
* uIP virtual network interface using UDP tunnels.
|
||||
* \author Adam Dunkels
|
||||
*
|
||||
*/
|
||||
|
||||
#include "net/ethernode.h"
|
||||
#include "net/uip_arch.h"
|
||||
#include "net/uip-fw.h"
|
||||
#include "ether.h"
|
||||
|
||||
#include "dev/radio.h"
|
||||
#include "net/netstack.h"
|
||||
#include "net/packetbuf.h"
|
||||
|
||||
#include "node.h"
|
||||
|
||||
#include "lib/random.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/select.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "net/ethernode.h"
|
||||
|
||||
#define BUF ((uip_tcpip_hdr *)&uip_buf[HDR_LEN])
|
||||
|
||||
#define PRINTF(...)
|
||||
/*#define PRINTF(x) printf x; fflush(NULL)*/
|
||||
|
||||
struct {
|
||||
u8_t id;
|
||||
int timer;
|
||||
u8_t seqno;
|
||||
} state;
|
||||
|
||||
#define TYPE_DATA 1
|
||||
#define TYPE_ACK 2
|
||||
|
||||
struct hdr {
|
||||
u8_t type;
|
||||
u8_t src;
|
||||
u8_t dest;
|
||||
u8_t seqno;
|
||||
};
|
||||
|
||||
static int radio_is_on = 1;
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
ethernode_on(void)
|
||||
{
|
||||
radio_is_on = 1;
|
||||
ether_set_radio_status(radio_is_on);
|
||||
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
ethernode_safe_off(void)
|
||||
{
|
||||
radio_is_on = 0;
|
||||
ether_set_radio_status(radio_is_on);
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
channel_clear(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
receiving(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
pending(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#define HDR_LEN UIP_LLH_LEN
|
||||
|
||||
#define ID_BROADCAST 0x80
|
||||
|
||||
PROCESS(ethernode_process, "Ethernode");
|
||||
/*-------------------------------------------------------------------------------*/
|
||||
static u8_t
|
||||
do_send(u8_t type, u8_t dest, struct hdr *hdr, int len)
|
||||
{
|
||||
|
||||
hdr->type = type;
|
||||
hdr->src = state.id;
|
||||
|
||||
hdr->dest = dest;
|
||||
|
||||
hdr->seqno = state.seqno;
|
||||
|
||||
++state.seqno;
|
||||
|
||||
PRINTF("ether_send len %d\n", len);
|
||||
return ether_send((char *)hdr, len);
|
||||
|
||||
}
|
||||
/*-------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Initialize the virtual UDP tunnel network interface.
|
||||
*
|
||||
* \param sid The ID number of this node.
|
||||
*
|
||||
*/
|
||||
/*-------------------------------------------------------------------------------*/
|
||||
void
|
||||
ethernode_init(int port)
|
||||
{
|
||||
ether_client_init(port);
|
||||
|
||||
do {
|
||||
state.id = random_rand() & 0x7f;
|
||||
} while(state.id == ID_BROADCAST);
|
||||
|
||||
state.seqno = 0;
|
||||
}
|
||||
/*-------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Poll the network device to see if a packet has arrived.
|
||||
*
|
||||
* \return The length of the incoming packet, or zero if no packet was
|
||||
* found.
|
||||
*/
|
||||
/*-------------------------------------------------------------------------------*/
|
||||
int
|
||||
ethernode_poll(void)
|
||||
{
|
||||
return ether_client_poll();
|
||||
}
|
||||
/*-------------------------------------------------------------------------------*/
|
||||
int
|
||||
ethernode_read(void *buf, unsigned short bufsize)
|
||||
{
|
||||
int len;
|
||||
u8_t tmpbuf[2048];
|
||||
struct hdr *hdr = (struct hdr *)tmpbuf;
|
||||
|
||||
len = ether_client_read(tmpbuf, sizeof(tmpbuf));
|
||||
if(len == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(radio_is_on == 0) {
|
||||
/* Drop the incoming packet if the simulated radio is switched off. */
|
||||
return 0;
|
||||
}
|
||||
/* printf("ethernode_poll: received data packet with len %d type %d\n", len, hdr->type);*/
|
||||
|
||||
switch(hdr->type) {
|
||||
case TYPE_DATA:
|
||||
if(hdr->dest == state.id ||
|
||||
hdr->dest == ID_BROADCAST) {
|
||||
memcpy(buf, tmpbuf + HDR_LEN, bufsize);
|
||||
return len - HDR_LEN;
|
||||
}
|
||||
break;
|
||||
case TYPE_ACK:
|
||||
printf("<%d>: Received ack packet from %d\n", state.id, hdr->src);
|
||||
break;
|
||||
default:
|
||||
printf("<%d>: Received unknown packet type %d from %d\n", state.id, hdr->type, hdr->src);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
/*-------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Send a packet from the uip_buf buffer over the UDP tunnel.
|
||||
*
|
||||
*
|
||||
* \retval UIP_FW_TOOLARGE A transmission of packet that was too large was attempted.
|
||||
*
|
||||
* \retval UIP_FW_DROPPED The packet is known to be dropped.
|
||||
*
|
||||
* \retval UIP_FW_OK The packet was transmitted.
|
||||
*/
|
||||
/*-------------------------------------------------------------------------------*/
|
||||
u8_t
|
||||
ethernode_send(void)
|
||||
{
|
||||
int len;
|
||||
static char tmpbuf[2048];
|
||||
struct hdr *hdr = (struct hdr *)tmpbuf;
|
||||
u8_t dest;
|
||||
struct timeval tv;
|
||||
|
||||
if(uip_len > sizeof(tmpbuf)) {
|
||||
PRINTF(("Ethernode_send: too large uip_len %d\n", uip_len));
|
||||
return UIP_FW_TOOLARGE;
|
||||
}
|
||||
|
||||
memcpy(&tmpbuf[HDR_LEN], &uip_buf[HDR_LEN], uip_len);
|
||||
len = uip_len + HDR_LEN;
|
||||
|
||||
dest = ID_BROADCAST;
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = (random_rand() % 1000);
|
||||
select(0, NULL, NULL, NULL, &tv);
|
||||
|
||||
do_send(TYPE_DATA, dest, hdr, len);
|
||||
|
||||
return UIP_FW_OK;
|
||||
}
|
||||
/*-------------------------------------------------------------------------------*/
|
||||
static char tmpbuf[2048];
|
||||
static struct hdr *hdr = (struct hdr *)tmpbuf;
|
||||
static u8_t dest;
|
||||
|
||||
static int
|
||||
prepare(const void *buf, unsigned short len)
|
||||
{
|
||||
memcpy(&tmpbuf[HDR_LEN], buf, len);
|
||||
len = len + HDR_LEN;
|
||||
|
||||
dest = ID_BROADCAST;
|
||||
return len;
|
||||
}
|
||||
/*-------------------------------------------------------------------------------*/
|
||||
static int
|
||||
transmit(unsigned short len)
|
||||
{
|
||||
do_send(TYPE_DATA, dest, hdr, len + HDR_LEN);
|
||||
return RADIO_TX_OK;
|
||||
}
|
||||
/*-------------------------------------------------------------------------------*/
|
||||
static int
|
||||
send(const void *payload, unsigned short payload_len)
|
||||
{
|
||||
prepare(payload, payload_len);
|
||||
return transmit(payload_len);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(ethernode_process, ev, data)
|
||||
{
|
||||
int len;
|
||||
PROCESS_BEGIN();
|
||||
|
||||
while(1) {
|
||||
process_post(PROCESS_CURRENT(), PROCESS_EVENT_CONTINUE, NULL);
|
||||
PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_CONTINUE);
|
||||
|
||||
len = ethernode_poll();
|
||||
if(len > 0) {
|
||||
|
||||
packetbuf_clear();
|
||||
len = ethernode_read(packetbuf_dataptr(), PACKETBUF_SIZE);
|
||||
if(len > 0) {
|
||||
packetbuf_set_datalen(len);
|
||||
NETSTACK_RDC.input();
|
||||
}
|
||||
|
||||
/* if(receiver_callback) {
|
||||
receiver_callback(ðernode_driver);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
PROCESS_END();
|
||||
}
|
||||
/*-------------------------------------------------------------------------------*/
|
||||
const struct radio_driver ethernode_driver =
|
||||
{
|
||||
(int (*)(void))ethernode_init,
|
||||
prepare,
|
||||
transmit,
|
||||
send,
|
||||
ethernode_read,
|
||||
channel_clear,
|
||||
receiving,
|
||||
pending,
|
||||
ethernode_on,
|
||||
ethernode_safe_off,
|
||||
};
|
||||
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2004, 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.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: ethernode.h,v 1.4 2007/11/17 18:09:19 adamdunkels Exp $
|
||||
*/
|
||||
#ifndef __ETHERNODE_H__
|
||||
#define __ETHERNODE_H__
|
||||
|
||||
#include "contiki.h"
|
||||
|
||||
#include "dev/radio.h"
|
||||
|
||||
void ethernode_init(int port);
|
||||
int ethernode_read(void *buf, unsigned short bufsize);
|
||||
u8_t ethernode_send(void);
|
||||
int ethernode_send_buf(const void *buf, unsigned short len);
|
||||
void ethernode_periodic(void);
|
||||
void ethernode_set_receiver(void (* recv)(const struct radio_driver *));
|
||||
|
||||
extern const struct radio_driver ethernode_driver;
|
||||
|
||||
#endif /* __ETHERNODE_H__ */
|
|
@ -1,52 +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.
|
||||
*
|
||||
* @(#)$Id: netsim-init.c,v 1.2 2007/03/22 18:59:34 adamdunkels Exp $
|
||||
*/
|
||||
#include "init.h"
|
||||
#include "random.h"
|
||||
|
||||
void
|
||||
netsim_init(void)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
ether_set_strength(41);
|
||||
|
||||
main_add_base(1, 1);
|
||||
|
||||
for(x = 1; x < 201; x += 40) {
|
||||
for(y = 1; y < 201; y += 40) {
|
||||
if(!(x == 1 && y == 1)) {
|
||||
main_add_node(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,43 +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.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: node-id.h,v 1.1 2006/06/17 22:41:35 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
#ifndef __NODE_ID_H__
|
||||
#define __NODE_ID_H__
|
||||
|
||||
#include "node.h"
|
||||
|
||||
#define node_id (node.id)
|
||||
|
||||
#endif /* __NODE_ID_H__ */
|
|
@ -1,152 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2004, 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.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: node.c,v 1.10 2008/01/04 23:23:29 oliverschmidt Exp $
|
||||
*/
|
||||
#include "node.h"
|
||||
#include "contiki.h"
|
||||
#include "net/uip.h"
|
||||
#include "net/rime.h"
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
extern in_addr_t gwaddr;
|
||||
|
||||
static clock_time_t drift, timer;
|
||||
|
||||
struct node node;
|
||||
|
||||
static int fd;
|
||||
|
||||
static void init_node_log(void);
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
void
|
||||
node_init(int id, int posx, int posy, int b)
|
||||
{
|
||||
uip_ipaddr_t addr;
|
||||
|
||||
node.id = id;
|
||||
node.x = posx;
|
||||
node.y = posy;
|
||||
/* node.type = NODE_TYPE_NORMAL;*/
|
||||
|
||||
if(b) {
|
||||
#ifdef __CYGWIN__
|
||||
addr = *(uip_ipaddr_t *)&gwaddr;
|
||||
#else /* __CYGWIN__ */
|
||||
uip_ipaddr(&addr, 192,168,1,2);
|
||||
#endif /* __CYGWIN__ */
|
||||
} else {
|
||||
uip_ipaddr(&addr, 172,16,posx,posy);
|
||||
}
|
||||
uip_sethostaddr(&addr);
|
||||
|
||||
{
|
||||
rimeaddr_t nodeaddr;
|
||||
|
||||
nodeaddr.u8[0] = posx;
|
||||
nodeaddr.u8[1] = posy;
|
||||
rimeaddr_set_node_addr(&nodeaddr);
|
||||
}
|
||||
|
||||
drift = rand() % 95726272;
|
||||
|
||||
init_node_log();
|
||||
}
|
||||
/*------------------------------------------------------------------------------*/
|
||||
#include <sys/time.h>
|
||||
|
||||
clock_time_t
|
||||
node_time(void)
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
gettimeofday(&tv, NULL);
|
||||
|
||||
return tv.tv_sec * 1000 + tv.tv_usec / 1000/* + drift*/;
|
||||
}
|
||||
/*------------------------------------------------------------------------------*/
|
||||
unsigned long
|
||||
node_seconds(void)
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
gettimeofday(&tv, NULL);
|
||||
|
||||
return tv.tv_sec;
|
||||
}
|
||||
/*------------------------------------------------------------------------------*/
|
||||
void
|
||||
node_set_time(clock_time_t time)
|
||||
{
|
||||
timer = time;
|
||||
}
|
||||
/*------------------------------------------------------------------------------*/
|
||||
int
|
||||
node_x(void)
|
||||
{
|
||||
return node.x;
|
||||
}
|
||||
/*------------------------------------------------------------------------------*/
|
||||
int
|
||||
node_y(void)
|
||||
{
|
||||
return node.y;
|
||||
}
|
||||
/*------------------------------------------------------------------------------*/
|
||||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static void
|
||||
init_node_log(void)
|
||||
{
|
||||
fd = open("log", O_CREAT | O_WRONLY | O_APPEND, 0666);
|
||||
}
|
||||
|
||||
void
|
||||
node_log(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char buf[4096];
|
||||
int len;
|
||||
|
||||
len = sprintf(buf, "Node %d (%d, %d): ", node.id, node.x, node.y);
|
||||
va_start(ap, fmt);
|
||||
vsprintf(&buf[len], fmt, ap);
|
||||
write(fd, buf, strlen(buf));
|
||||
va_end(ap);
|
||||
}
|
||||
/*------------------------------------------------------------------------------*/
|
|
@ -1,58 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2004, 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.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: node.h,v 1.3 2006/10/23 09:01:06 adamdunkels Exp $
|
||||
*/
|
||||
#ifndef __NODE_H__
|
||||
#define __NODE_H__
|
||||
|
||||
#include "sys/clock.h"
|
||||
|
||||
struct node {
|
||||
int x, y;
|
||||
int id;
|
||||
};
|
||||
|
||||
extern struct node node;
|
||||
|
||||
void node_init(int id, int x, int y, int b);
|
||||
void node_set_time(clock_time_t time);
|
||||
clock_time_t node_time(void);
|
||||
unsigned long node_seconds(void);
|
||||
|
||||
int node_x(void);
|
||||
int node_y(void);
|
||||
|
||||
void node_log(const char *fmt, ...);
|
||||
|
||||
|
||||
#endif /* __NODE_H__ */
|
|
@ -1,167 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2004, 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.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: nodes.c,v 1.8 2008/05/14 19:22:58 adamdunkels Exp $
|
||||
*/
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "nodes.h"
|
||||
|
||||
|
||||
static int numnodes;
|
||||
|
||||
static struct nodes_node nodes[2000];
|
||||
|
||||
int nodes_base_node_port = 0;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
nodes_init(void)
|
||||
{
|
||||
numnodes = 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
nodes_add(int pid, int x, int y, int port, int id)
|
||||
{
|
||||
nodes[numnodes].pid = pid;
|
||||
nodes[numnodes].x = x;
|
||||
nodes[numnodes].y = y;
|
||||
nodes[numnodes].port = port;
|
||||
nodes[numnodes].leds = 0;
|
||||
nodes[numnodes].done = 0;
|
||||
nodes[numnodes].id = id;
|
||||
++numnodes;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
nodes_kill(void)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < numnodes; ++i) {
|
||||
kill(nodes[i].pid, SIGTERM);
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
nodes_num(void)
|
||||
{
|
||||
return numnodes;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
struct nodes_node *
|
||||
nodes_node(int num)
|
||||
{
|
||||
if(num > numnodes) {
|
||||
fprintf(stderr, "nodes_node: request for %d > %d\n", num, numnodes);
|
||||
abort();
|
||||
}
|
||||
return &nodes[num];
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static struct nodes_node *
|
||||
find_node(int x, int y)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = numnodes; i >= 0; --i) {
|
||||
if(nodes[i].x == x && nodes[i].y == y) {
|
||||
return &nodes[i];
|
||||
}
|
||||
}
|
||||
return &nodes[0];
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
nodes_set_leds(int x, int y, int leds)
|
||||
{
|
||||
find_node(x, y)->leds = leds;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
nodes_set_text(int x, int y, char *text)
|
||||
{
|
||||
strncpy(find_node(x, y)->text, text, NODES_TEXTLEN);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
nodes_set_radio_status(int x, int y, int radio_status)
|
||||
{
|
||||
find_node(x, y)->radio_status = radio_status;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
nodes_set_line(int x, int y, int linex, int liney)
|
||||
{
|
||||
struct nodes_node *n;
|
||||
|
||||
n = find_node(x, y);
|
||||
n->linex = linex;
|
||||
n->liney = liney;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
struct nodes_node *
|
||||
nodes_find_pid(pid_t pid)
|
||||
{
|
||||
int i;
|
||||
printf("Nofodes %d\n", numnodes);
|
||||
for(i = 0; i < numnodes; ++i) {
|
||||
printf("%d == %d\n", pid, nodes[i].pid); fflush(NULL);
|
||||
if(nodes[i].pid == pid) {
|
||||
return &nodes[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
nodes_done(int id)
|
||||
{
|
||||
int i;
|
||||
int num_done = 0;
|
||||
|
||||
for(i = numnodes; i >= 0; --i) {
|
||||
if(nodes[i].id == id) {
|
||||
nodes[i].done = 1;
|
||||
}
|
||||
if(nodes[i].done != 0) {
|
||||
num_done++;
|
||||
}
|
||||
}
|
||||
|
||||
if(num_done == numnodes) {
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -1,72 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2004, 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.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: nodes.h,v 1.6 2008/05/14 19:22:58 adamdunkels Exp $
|
||||
*/
|
||||
#ifndef __NODES_H__
|
||||
#define __NODES_H__
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#define NODES_TEXTLEN 10
|
||||
|
||||
void nodes_init(void);
|
||||
void nodes_add(int pid, int x, int y, int port, int id);
|
||||
void nodes_kill(void);
|
||||
void nodes_set_leds(int x, int y, int leds);
|
||||
void nodes_set_text(int x, int y, char *text);
|
||||
void nodes_set_line(int x, int y, int linex, int liney);
|
||||
void nodes_set_radio_status(int x, int y, int radio_status);
|
||||
|
||||
void nodes_done(int id);
|
||||
|
||||
int nodes_num(void);
|
||||
struct nodes_node *nodes_node(int num);
|
||||
struct nodes_node *nodes_find_pid(pid_t pid);
|
||||
|
||||
struct nodes_node {
|
||||
int pid;
|
||||
int id;
|
||||
int x, y;
|
||||
int port;
|
||||
int leds;
|
||||
int done;
|
||||
int linex, liney;
|
||||
int radio_status;
|
||||
char text[NODES_TEXTLEN];
|
||||
};
|
||||
|
||||
#define NODES_PORTBASE 5000
|
||||
|
||||
extern int nodes_base_node_port;
|
||||
|
||||
#endif /* __NODES_H__ */
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2004, 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.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: random.c,v 1.2 2007/11/17 18:09:18 adamdunkels Exp $
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/*
|
||||
* \file
|
||||
* Stubs for pseudo-random generator.
|
||||
* \author Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void
|
||||
random_init(void)
|
||||
{
|
||||
srand(getpid());
|
||||
}
|
||||
/*----------------------------------------------------------------------------*/
|
||||
unsigned short
|
||||
random_rand(void)
|
||||
{
|
||||
return (rand() >> 4) & 0xffff;
|
||||
}
|
||||
/*----------------------------------------------------------------------------*/
|
|
@ -1,53 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2004, 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.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: random.h,v 1.1 2006/06/17 22:41:35 adamdunkels Exp $
|
||||
*/
|
||||
#ifndef __RANDOM_H__
|
||||
#define __RANDOM_H__
|
||||
|
||||
/*
|
||||
* Initialize the pseudo-random generator.
|
||||
*
|
||||
*/
|
||||
void random_init(void);
|
||||
|
||||
/*
|
||||
* Calculate a pseudo random number between 0 and 65535.
|
||||
*
|
||||
* \return A pseudo-random number between 0 and 65535.
|
||||
*/
|
||||
unsigned short random_rand(void);
|
||||
|
||||
|
||||
|
||||
#endif /* __RANDOM_H__ */
|
|
@ -1,82 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2004, 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.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: sensor.c,v 1.1 2006/06/17 22:41:35 adamdunkels Exp $
|
||||
*/
|
||||
#include "sensor.h"
|
||||
#include "dev/pir-sensor.h"
|
||||
#include "dev/button-sensor.h"
|
||||
#include "dev/vib-sensor.h"
|
||||
|
||||
static int strength = 20;
|
||||
|
||||
static int pir, button, vib;
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
sensor_init(void)
|
||||
{
|
||||
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
sensor_strength(void)
|
||||
{
|
||||
return strength;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
sensor_set_strength(int s)
|
||||
{
|
||||
strength = s;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
sensor_input(struct sensor_data *d, int strength)
|
||||
{
|
||||
pir += d->pir;
|
||||
if(d->pir) {
|
||||
pir_sensor_changed(strength);
|
||||
}
|
||||
if(d->button) {
|
||||
button_press();
|
||||
}
|
||||
button += d->button;
|
||||
/* if(button) {
|
||||
printf("Button %d %d\n", button, d->button);
|
||||
}*/
|
||||
if(d->vib) {
|
||||
vib_sensor_changed();
|
||||
}
|
||||
vib += d->vib;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -1,55 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2004, 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.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: sensor.h,v 1.1 2006/06/17 22:41:35 adamdunkels Exp $
|
||||
*/
|
||||
#ifndef __SENSOR_H__
|
||||
#define __SENSOR_H__
|
||||
|
||||
#include <string.h>
|
||||
|
||||
struct sensor_data {
|
||||
int pir;
|
||||
int button;
|
||||
int vib;
|
||||
};
|
||||
|
||||
void sensor_input(struct sensor_data *d, int strength);
|
||||
void sensor_init(void);
|
||||
int sensor_poll(void);
|
||||
|
||||
int sensor_strength(void);
|
||||
void sensor_set_strength(int s);
|
||||
|
||||
#define sensor_data_init(s) memset(s, 0, sizeof(struct sensor_data))
|
||||
|
||||
#endif /* __SENSOR_H__ */
|
|
@ -1,35 +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.
|
||||
*
|
||||
* @(#)$Id: symbols.c,v 1.1 2006/06/17 22:41:35 adamdunkels Exp $
|
||||
*/
|
||||
#include "loader/symbols.h"
|
||||
const struct symbols symbols[] = {
|
||||
{(void *)0, 0} };
|
Loading…
Reference in a new issue