Merge branch 'master' of ssh://contiki.git.sourceforge.net/gitroot/contiki/contiki

This commit is contained in:
Nicolas Tsiftes 2011-03-21 09:20:59 +01:00
commit 59dde4f509
7 changed files with 41 additions and 35 deletions

View file

@ -48,38 +48,38 @@
#define ETX_ALPHA 90
#define ETX_NOACK_PENALTY ETX_LIMIT
/*---------------------------------------------------------------------------*/
NEIGHBOR_ATTRIBUTE(uint8_t, etx, NULL);
NEIGHBOR_ATTRIBUTE(link_metric_t, etx, NULL);
static neighbor_info_subscriber_t subscriber_callback;
/*---------------------------------------------------------------------------*/
static void
update_etx(const rimeaddr_t *dest, int packet_etx)
update_metric(const rimeaddr_t *dest, int packet_metric)
{
uint8_t *etxp;
uint8_t recorded_etx, new_etx;
link_metric_t *metricp;
link_metric_t recorded_metric, new_metric;
etxp = (uint8_t *)neighbor_attr_get_data(&etx, dest);
packet_etx = NEIGHBOR_INFO_ETX2FIX(packet_etx);
if(etxp == NULL || *etxp == 0) {
recorded_etx = NEIGHBOR_INFO_ETX2FIX(ETX_LIMIT);
new_etx = packet_etx;
metricp = (link_metric_t *)neighbor_attr_get_data(&etx, dest);
packet_metric = NEIGHBOR_INFO_ETX2FIX(packet_metric);
if(metricp == NULL || *metricp == 0) {
recorded_metric = NEIGHBOR_INFO_ETX2FIX(ETX_LIMIT);
new_metric = packet_metric;
} else {
recorded_etx = *etxp;
recorded_metric = *metricp;
/* Update the EWMA of the ETX for the neighbor. */
new_etx = ((uint16_t)recorded_etx * ETX_ALPHA +
(uint16_t)packet_etx * (ETX_SCALE - ETX_ALPHA)) / ETX_SCALE;
new_metric = ((uint16_t)recorded_metric * ETX_ALPHA +
(uint16_t)packet_metric * (ETX_SCALE - ETX_ALPHA)) / ETX_SCALE;
}
PRINTF("neighbor-info: ETX changed from %d to %d (packet ETX = %d) %d\n",
NEIGHBOR_INFO_FIX2ETX(recorded_etx),
NEIGHBOR_INFO_FIX2ETX(new_etx),
NEIGHBOR_INFO_FIX2ETX(packet_etx),
NEIGHBOR_INFO_FIX2ETX(recorded_metric),
NEIGHBOR_INFO_FIX2ETX(new_metric),
NEIGHBOR_INFO_FIX2ETX(packet_metric),
dest->u8[7]);
if(neighbor_attr_has_neighbor(dest)) {
neighbor_attr_set_data(&etx, dest, &new_etx);
if(new_etx != recorded_etx && subscriber_callback != NULL) {
subscriber_callback(dest, 1, new_etx);
neighbor_attr_set_data(&etx, dest, &new_metric);
if(new_metric != recorded_metric && subscriber_callback != NULL) {
subscriber_callback(dest, 1, new_metric);
}
}
}
@ -103,7 +103,7 @@ void
neighbor_info_packet_sent(int status, int numtx)
{
const rimeaddr_t *dest;
uint8_t packet_etx;
link_metric_t packet_metric;
dest = packetbuf_addr(PACKETBUF_ADDR_RECEIVER);
if(rimeaddr_cmp(dest, &rimeaddr_null)) {
@ -116,14 +116,14 @@ neighbor_info_packet_sent(int status, int numtx)
switch(status) {
case MAC_TX_OK:
packet_etx = numtx;
packet_metric = numtx;
add_neighbor(dest);
break;
case MAC_TX_COLLISION:
packet_etx = numtx;
packet_metric = numtx;
break;
case MAC_TX_NOACK:
packet_etx = ETX_NOACK_PENALTY;
packet_metric = ETX_NOACK_PENALTY;
break;
default:
/* Do not penalize the ETX when collisions or transmission
@ -131,7 +131,7 @@ neighbor_info_packet_sent(int status, int numtx)
return;
}
update_etx(dest, packet_etx);
update_metric(dest, packet_metric);
}
/*---------------------------------------------------------------------------*/
void
@ -162,12 +162,12 @@ neighbor_info_subscribe(neighbor_info_subscriber_t s)
return 0;
}
/*---------------------------------------------------------------------------*/
uint8_t
neighbor_info_get_etx(const rimeaddr_t *addr)
link_metric_t
neighbor_info_get_metric(const rimeaddr_t *addr)
{
uint8_t *etxp;
link_metric_t *metricp;
etxp = (uint8_t *)neighbor_attr_get_data(&etx, addr);
return etxp == NULL ? ETX_LIMIT : *etxp;
metricp = (link_metric_t *)neighbor_attr_get_data(&etx, addr);
return metricp == NULL ? ETX_LIMIT : *metricp;
}
/*---------------------------------------------------------------------------*/

View file

@ -52,6 +52,7 @@
#define NEIGHBOR_INFO_FIX2ETX(fix) ((fix) / NEIGHBOR_INFO_ETX_DIVISOR)
typedef void (*neighbor_info_subscriber_t)(const rimeaddr_t *, int known, int etx);
typedef uint8_t link_metric_t;
/**
* Notify the neighbor information module about the status of
@ -85,6 +86,6 @@ int neighbor_info_subscribe(neighbor_info_subscriber_t);
*
* \return Returns ETX if the neighbor exists, and 0 if not.
*/
uint8_t neighbor_info_get_etx(const rimeaddr_t *addr);
link_metric_t neighbor_info_get_etx(const rimeaddr_t *addr);
#endif /* NEIGHBOR_INFO_H */

View file

@ -112,7 +112,7 @@ new_dio_interval(rpl_dag_t *dag)
dag->version,
dag->dio_totint, dag->dio_totsend,
dag->dio_totrecv,dag->dio_intcurrent,
dag->rank == ROOT_RANK ? "BLUE" : "ORANGE");
dag->rank == ROOT_RANK(dag) ? "BLUE" : "ORANGE");
#endif /* RPL_CONF_STATS */
/* reset the redundancy counter */

View file

@ -7,7 +7,7 @@ ARCH=msp430.c leds.c watchdog.c xmem.c \
spix.c cc2420.c cc2420-aes.c cc2420-arch.c cc2420-arch-sfd.c\
node-id.c sensors.c button-sensor.c cfs-coffee.c \
radio-sensor.c uart0x.c uart0-putchar.c uip-ipchksum.c \
checkpoint-arch.c slip.c slip_uart0.c z1-phidgets.c
checkpoint-arch.c slip.c slip_uart0.c z1-phidgets.c adxl345.c i2cmaster.c
CONTIKI_TARGET_DIRS = . dev apps net
ifndef CONTIKI_TARGET_MAIN

View file

@ -69,6 +69,7 @@
SENSORS(&button_sensor);
#if DCOSYNCH_CONF_ENABLED
static struct timer mgt_timer;
#endif
@ -258,6 +259,8 @@ main(int argc, char **argv)
set_rime_addr();
cc2420_init();
accm_init();
{
uint8_t longaddr[8];
uint16_t shortaddr;

View file

@ -43,7 +43,7 @@
#include <signal.h>
#include "contiki.h"
#include "adxl345.h"
#include "cc2420-arch.c"
#include "cc2420.h"
#include "i2cmaster.h"
/* Callback pointers when interrupt occurs */
@ -400,6 +400,7 @@ interrupt(PORT1_VECTOR) port1_isr (void) {
}
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
}
/*---------------------------------------------------------------------------*/

View file

@ -116,6 +116,8 @@ static bool clean_route = false;
static bool clean_neighb = false;
static struct uip_eth_addr adapter_eth_addr;
static char * if_name;
static char * if_mac;
OSVERSIONINFO osVersionInfo;
/* Fictitious Ethernet address of the attached device (used in tun mode). */
@ -357,7 +359,7 @@ read_more:
}
addLoWPANRoute(if_name, br_prefix, rem_ipaddr);
addNeighbor(if_name, rem_ipaddr, DEV_MAC_ADDR);
addNeighbor(if_name, rem_ipaddr, if_mac);//DEV_MAC_ADDR);
}
}
@ -1058,13 +1060,12 @@ main(int argc, char **argv)
(int *)&adapter_eth_addr.addr[2],(int *)&adapter_eth_addr.addr[3],
(int *)&adapter_eth_addr.addr[4],(int *)&adapter_eth_addr.addr[5]);
if_name = wpcap_start(&adapter_eth_addr, verbose);
if_mac = argv[1];
if(local_ipaddr!=NULL){
addAddress(if_name, local_ipaddr);
}
switch(baudrate) {
case -2:
break; /* Use default. */