Added native-border-router and slip-radio
This commit is contained in:
parent
65edc32de2
commit
8b83ffec67
37 changed files with 3176 additions and 104 deletions
|
@ -2,6 +2,10 @@ ifndef CONTIKI
|
|||
$(error CONTIKI not defined! You must specify where CONTIKI resides!)
|
||||
endif
|
||||
|
||||
ifdef UIP_CONF_IPV6
|
||||
CFLAGS += -DWITH_UIP6=1
|
||||
endif
|
||||
|
||||
CONTIKI_TARGET_DIRS = . dev
|
||||
CONTIKI_TARGET_MAIN = ${addprefix $(OBJECTDIR)/,contiki-main.o}
|
||||
|
||||
|
|
|
@ -35,6 +35,12 @@
|
|||
#define __CONTIKI_CONF_H__
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <sys/select.h>
|
||||
|
||||
struct select_callback {
|
||||
int (* set_fd)(int maxfd, fd_set *fdr, fd_set *fdw);
|
||||
void (* handle_fd)(fd_set *fdr, fd_set *fdw);
|
||||
};
|
||||
|
||||
#define CC_CONF_REGISTER_ARGS 1
|
||||
#define CC_CONF_FUNCTION_POINTER_ARGS 1
|
||||
|
@ -57,11 +63,51 @@ typedef unsigned short uip_stats_t;
|
|||
#define UIP_CONF_BUFFER_SIZE 420
|
||||
#define UIP_CONF_BYTE_ORDER UIP_LITTLE_ENDIAN
|
||||
#define UIP_CONF_TCP 1
|
||||
#define UIP_CONF_TCP_SPLIT 1
|
||||
#define UIP_CONF_TCP_SPLIT 0
|
||||
#define UIP_CONF_LOGGING 0
|
||||
#define UIP_CONF_UDP_CHECKSUMS 1
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
|
||||
#define RIMEADDR_CONF_SIZE 8
|
||||
|
||||
#ifndef NETSTACK_CONF_MAC
|
||||
#define NETSTACK_CONF_MAC nullmac_driver
|
||||
#endif /* NETSTACK_CONF_MAC */
|
||||
|
||||
#ifndef NETSTACK_CONF_RDC
|
||||
#define NETSTACK_CONF_RDC nullrdc_driver
|
||||
#endif /* NETSTACK_CONF_RDC */
|
||||
|
||||
#ifndef NETSTACK_CONF_RADIO
|
||||
#define NETSTACK_CONF_RADIO nullradio_driver
|
||||
#endif /* NETSTACK_CONF_RADIO */
|
||||
|
||||
#ifndef NETSTACK_CONF_FRAMER
|
||||
#define NETSTACK_CONF_FRAMER framer_802154
|
||||
#endif /* NETSTACK_CONF_FRAMER */
|
||||
|
||||
#define NETSTACK_CONF_NETWORK sicslowpan_driver
|
||||
|
||||
#define UIP_CONF_ROUTER 1
|
||||
#ifndef UIP_CONF_IPV6_RPL
|
||||
#define UIP_CONF_IPV6_RPL 1
|
||||
#endif /* UIP_CONF_IPV6_RPL */
|
||||
|
||||
#define SICSLOWPAN_CONF_COMPRESSION_IPV6 0
|
||||
#define SICSLOWPAN_CONF_COMPRESSION_HC1 1
|
||||
#define SICSLOWPAN_CONF_COMPRESSION_HC01 2
|
||||
#define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_COMPRESSION_HC06
|
||||
#ifndef SICSLOWPAN_CONF_FRAG
|
||||
#define SICSLOWPAN_CONF_FRAG 1
|
||||
#define SICSLOWPAN_CONF_MAXAGE 8
|
||||
#endif /* SICSLOWPAN_CONF_FRAG */
|
||||
#define SICSLOWPAN_CONF_CONVENTIONAL_MAC 1
|
||||
#define SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS 2
|
||||
#ifndef SICSLOWPAN_CONF_MAX_MAC_TRANSMISSIONS
|
||||
#define SICSLOWPAN_CONF_MAX_MAC_TRANSMISSIONS 5
|
||||
#endif /* SICSLOWPAN_CONF_MAX_MAC_TRANSMISSIONS */
|
||||
|
||||
#define UIP_CONF_IPV6_CHECKS 1
|
||||
#define UIP_CONF_IPV6_QUEUE_PKT 1
|
||||
#define UIP_CONF_IPV6_REASSEMBLY 0
|
||||
|
@ -70,7 +116,45 @@ typedef unsigned short uip_stats_t;
|
|||
#define UIP_CONF_ND6_MAX_NEIGHBORS 4
|
||||
#define UIP_CONF_ND6_MAX_DEFROUTERS 2
|
||||
#define UIP_CONF_ICMP6 1
|
||||
#endif /* UIP_CONF_ICMP6 */
|
||||
|
||||
/* configure number of neighbors and routes */
|
||||
#ifndef UIP_CONF_DS6_NBR_NBU
|
||||
#define UIP_CONF_DS6_NBR_NBU 30
|
||||
#endif /* UIP_CONF_DS6_NBR_NBU */
|
||||
#ifndef UIP_CONF_DS6_ROUTE_NBU
|
||||
#define UIP_CONF_DS6_ROUTE_NBU 30
|
||||
#endif /* UIP_CONF_DS6_ROUTE_NBU */
|
||||
|
||||
#define UIP_CONF_ND6_SEND_RA 0
|
||||
#define UIP_CONF_ND6_REACHABLE_TIME 600000
|
||||
#define UIP_CONF_ND6_RETRANS_TIMER 10000
|
||||
|
||||
#define UIP_CONF_IP_FORWARD 0
|
||||
#ifndef UIP_CONF_BUFFER_SIZE
|
||||
#define UIP_CONF_BUFFER_SIZE 240
|
||||
#endif
|
||||
|
||||
|
||||
#define UIP_CONF_LLH_LEN 0
|
||||
#define UIP_CONF_LL_802154 1
|
||||
|
||||
#define UIP_CONF_ICMP_DEST_UNREACH 1
|
||||
|
||||
#define UIP_CONF_DHCP_LIGHT
|
||||
#define UIP_CONF_RECEIVE_WINDOW 48
|
||||
#define UIP_CONF_TCP_MSS 48
|
||||
#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 1
|
||||
#define UIP_CONF_UDP_CHECKSUMS 1
|
||||
#define UIP_CONF_PINGADDRCONF 0
|
||||
#define UIP_CONF_LOGGING 0
|
||||
|
||||
|
||||
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
|
||||
typedef unsigned long clock_time_t;
|
||||
|
||||
|
@ -81,4 +165,11 @@ typedef unsigned long clock_time_t;
|
|||
/* Not part of C99 but actually present */
|
||||
int strcasecmp(const char*, const char*);
|
||||
|
||||
/* include the project config */
|
||||
/* PROJECT_CONF_H might be defined in the project Makefile */
|
||||
#ifdef PROJECT_CONF_H
|
||||
#include PROJECT_CONF_H
|
||||
#endif /* PROJECT_CONF_H */
|
||||
|
||||
|
||||
#endif /* __CONTIKI_CONF_H__ */
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/select.h>
|
||||
|
||||
|
@ -48,18 +49,90 @@
|
|||
#include "dev/pir-sensor.h"
|
||||
#include "dev/vib-sensor.h"
|
||||
|
||||
#if WITH_UIP6
|
||||
#include "net/uip-ds6.h"
|
||||
#endif /* WITH_UIP6 */
|
||||
|
||||
#include "net/rime.h"
|
||||
|
||||
|
||||
PROCINIT(&etimer_process, &tcpip_process);
|
||||
|
||||
SENSORS(&pir_sensor, &vib_sensor, &button_sensor);
|
||||
|
||||
static uint8_t serial_id[] = {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08};
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
main(void)
|
||||
static void
|
||||
set_rime_addr(void)
|
||||
{
|
||||
printf("Starting Contiki\n");
|
||||
rimeaddr_t addr;
|
||||
int i;
|
||||
|
||||
memset(&addr, 0, sizeof(rimeaddr_t));
|
||||
#if UIP_CONF_IPV6
|
||||
memcpy(addr.u8, serial_id, sizeof(addr.u8));
|
||||
#else
|
||||
if(node_id == 0) {
|
||||
for(i = 0; i < sizeof(rimeaddr_t); ++i) {
|
||||
addr.u8[i] = serial_id[7 - i];
|
||||
}
|
||||
} else {
|
||||
addr.u8[0] = node_id & 0xff;
|
||||
addr.u8[1] = node_id >> 8;
|
||||
}
|
||||
#endif
|
||||
rimeaddr_set_node_addr(&addr);
|
||||
printf("Rime started with address ");
|
||||
for(i = 0; i < sizeof(addr.u8) - 1; i++) {
|
||||
printf("%d.", addr.u8[i]);
|
||||
}
|
||||
printf("%d\n", addr.u8[i]);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int contiki_argc = 0;
|
||||
char **contiki_argv;
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
printf("Starting Contiki: IPV6:%d \n", UIP_CONF_IPV6);
|
||||
|
||||
/* crappy way of remembering and accessing argc/v */
|
||||
contiki_argc = argc;
|
||||
contiki_argv = argv;
|
||||
|
||||
process_init();
|
||||
ctimer_init();
|
||||
|
||||
set_rime_addr();
|
||||
|
||||
#if WITH_UIP6
|
||||
memcpy(&uip_lladdr.addr, serial_id, sizeof(uip_lladdr.addr));
|
||||
|
||||
process_start(&tcpip_process, NULL);
|
||||
|
||||
printf("Tentative link-local IPv6 address ");
|
||||
{
|
||||
uip_ds6_addr_t *lladdr;
|
||||
int i;
|
||||
lladdr = uip_ds6_get_link_local(-1);
|
||||
for(i = 0; i < 7; ++i) {
|
||||
printf("%02x%02x:", lladdr->ipaddr.u8[i * 2],
|
||||
lladdr->ipaddr.u8[i * 2 + 1]);
|
||||
}
|
||||
/* make it hardcoded... */
|
||||
lladdr->state = ADDR_AUTOCONF;
|
||||
|
||||
printf("%02x%02x\n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
queuebuf_init();
|
||||
|
||||
netstack_init();
|
||||
|
||||
procinit_init();
|
||||
|
@ -67,14 +140,15 @@ main(void)
|
|||
serial_line_init();
|
||||
|
||||
autostart_start(autostart_processes);
|
||||
|
||||
|
||||
/* Make standard output unbuffered. */
|
||||
setvbuf(stdout, (char *)NULL, _IONBF, 0);
|
||||
|
||||
while(1) {
|
||||
fd_set fds;
|
||||
fd_set fdr;
|
||||
fd_set fdw;
|
||||
int n;
|
||||
int maxfd;
|
||||
struct timeval tv;
|
||||
|
||||
n = process_run();
|
||||
|
@ -82,17 +156,28 @@ main(void)
|
|||
tv.tv_sec = 0;
|
||||
tv.tv_usec = 1;
|
||||
|
||||
FD_ZERO(&fds);
|
||||
FD_SET(STDIN_FILENO, &fds);
|
||||
if(select(1, &fds, NULL, NULL, &tv) < 0) {
|
||||
FD_ZERO(&fdr);
|
||||
FD_ZERO(&fdw);
|
||||
FD_SET(STDIN_FILENO, &fdr);
|
||||
maxfd = STDIN_FILENO;
|
||||
|
||||
#ifdef SELECT_CALLBACK
|
||||
maxfd = SELECT_CALLBACK->set_fd(maxfd, &fdr, &fdw);
|
||||
#endif
|
||||
if(select(maxfd + 1, &fdr, &fdw, NULL, &tv) < 0) {
|
||||
perror("select");
|
||||
} else if(FD_ISSET(STDIN_FILENO, &fds)) {
|
||||
char c;
|
||||
if(read(STDIN_FILENO, &c, 1) > 0) {
|
||||
serial_line_input_byte(c);
|
||||
} else {
|
||||
if(FD_ISSET(STDIN_FILENO, &fdr)) {
|
||||
char c;
|
||||
if(read(STDIN_FILENO, &c, 1) > 0) {
|
||||
serial_line_input_byte(c);
|
||||
}
|
||||
}
|
||||
#ifdef SELECT_CALLBACK
|
||||
SELECT_CALLBACK->handle_fd(&fdr, &fdw);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
etimer_request_poll();
|
||||
}
|
||||
|
||||
|
|
|
@ -10,22 +10,22 @@ button_press(void)
|
|||
sensors_changed(&button_sensor);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static unsigned int
|
||||
static int
|
||||
value(int type)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
configure(int type, void *c)
|
||||
configure(int type, int value)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void *
|
||||
static int
|
||||
status(int type)
|
||||
{
|
||||
return NULL;
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
SENSORS_SENSOR(button_sensor, BUTTON_SENSOR,
|
||||
|
|
|
@ -42,22 +42,22 @@
|
|||
#include "dev/temperature-sensor.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static unsigned int
|
||||
static int
|
||||
value(int type)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
configure(int type, void *c)
|
||||
configure(int type, int c)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void *
|
||||
static int
|
||||
status(int type)
|
||||
{
|
||||
return NULL;
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
SENSORS_SENSOR(temperature_sensor, TEMPERATURE_SENSOR,
|
||||
|
|
|
@ -13,22 +13,22 @@ pir_sensor_changed(int strength)
|
|||
sensors_changed(&pir_sensor);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static unsigned int
|
||||
static int
|
||||
value(int type)
|
||||
{
|
||||
return pir_value;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
configure(int type, void *c)
|
||||
configure(int type, int c)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void *
|
||||
static int
|
||||
status(int type)
|
||||
{
|
||||
return NULL;
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
SENSORS_SENSOR(pir_sensor, PIR_SENSOR,
|
||||
|
|
|
@ -48,26 +48,27 @@ static unsigned int vib;
|
|||
void
|
||||
vib_sensor_changed(void)
|
||||
{
|
||||
vib++;
|
||||
sensors_changed(&vib_sensor);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static unsigned int
|
||||
static int
|
||||
value(int type)
|
||||
{
|
||||
return vib;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
configure(int type, int c)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
configure(int type, void *c)
|
||||
status(int type)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void *
|
||||
status(int type)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
SENSORS_SENSOR(vib_sensor, VIB_SENSOR,
|
||||
value, configure, status);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue