Timeouts configurable at run-time

This commit is contained in:
adamdunkels 2007-03-25 12:06:28 +00:00
parent e12086c980
commit f69268b4ab
7 changed files with 37 additions and 19 deletions

View file

@ -1,3 +1,8 @@
/**
* \addtogroup rime-mesh
* @{
*/
/*
* Copyright (c) 2007, Swedish Institute of Computer Science.
* All rights reserved.
@ -28,7 +33,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: mesh.c,v 1.5 2007/03/22 17:34:16 adamdunkels Exp $
* $Id: mesh.c,v 1.6 2007/03/25 12:06:57 adamdunkels Exp $
*/
/**
@ -111,7 +116,9 @@ mesh_open(struct mesh_conn *c, u16_t channels,
const struct mesh_callbacks *callbacks)
{
mh_open(&c->mh, channels, &data_callbacks);
route_discovery_open(&c->route_discovery_conn, channels + 1,
route_discovery_open(&c->route_discovery_conn,
CLOCK_SECOND / 2,
channels + 1,
&route_discovery_callbacks);
c->cb = callbacks;
}
@ -146,3 +153,4 @@ mesh_send(struct mesh_conn *c, rimeaddr_t *to)
return 1;
}
/*---------------------------------------------------------------------------*/
/** @} */

View file

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: neighbor.c,v 1.6 2007/03/24 13:57:04 oliverschmidt Exp $
* $Id: neighbor.c,v 1.7 2007/03/25 12:06:28 adamdunkels Exp $
*/
/**
@ -215,3 +215,9 @@ neighbor_best(void)
return NULL;
}
/*---------------------------------------------------------------------------*/
void
neighbor_set_lifetime(int seconds)
{
max_time = seconds;
}
/*---------------------------------------------------------------------------*/

View file

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: neighbor.h,v 1.3 2007/03/22 17:34:43 adamdunkels Exp $
* $Id: neighbor.h,v 1.4 2007/03/25 12:06:28 adamdunkels Exp $
*/
/**
@ -60,6 +60,7 @@ void neighbor_remove(rimeaddr_t *addr);
struct neighbor *neighbor_find(rimeaddr_t *addr);
struct neighbor *neighbor_best(void);
void neighbor_set_lifetime(int seconds);
#endif /* __NEIGHBOR_H__ */

View file

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: nf.c,v 1.9 2007/03/23 10:46:35 adamdunkels Exp $
* $Id: nf.c,v 1.10 2007/03/25 12:06:28 adamdunkels Exp $
*/
/**
@ -43,8 +43,6 @@
#include "lib/rand.h"
#include <string.h>
#define QUEUE_TIME CLOCK_SECOND / 4
#define HOPS_MAX 16
struct nf_hdr {
@ -70,7 +68,7 @@ static void send(void *ptr);
static void
set_timer(struct nf_conn *c)
{
ctimer_set(&c->t, QUEUE_TIME, send, c);
ctimer_set(&c->t, c->queue_time, send, c);
}
/*---------------------------------------------------------------------------*/
static void
@ -88,7 +86,7 @@ send(void *ptr)
c->buf = NULL;
PRINTF("%d.%d: nf send to uibc\n",
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1]);
uibc_send(&c->c, QUEUE_TIME);
uibc_send(&c->c, c->queue_time);
if(c->u->sent != NULL) {
c->u->sent(c);
}
@ -164,11 +162,12 @@ recv_from_uibc(struct uibc_conn *uibc, rimeaddr_t *from)
static const struct uibc_callbacks nf = {recv_from_uibc, NULL, NULL};
/*---------------------------------------------------------------------------*/
void
nf_open(struct nf_conn *c, u16_t channel,
const struct nf_callbacks *u)
nf_open(struct nf_conn *c, clock_time_t queue_time,
u16_t channel, const struct nf_callbacks *u)
{
uibc_open(&c->c, channel, &nf);
c->u = u;
c->queue_time = queue_time;
}
/*---------------------------------------------------------------------------*/
void

View file

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: nf.h,v 1.7 2007/03/21 23:21:54 adamdunkels Exp $
* $Id: nf.h,v 1.8 2007/03/25 12:06:28 adamdunkels Exp $
*/
/**
@ -58,14 +58,15 @@ struct nf_conn {
struct uibc_conn c;
struct ctimer t;
struct queuebuf *buf;
clock_time_t queue_time;
u8_t packets_received;
u8_t last_originator_seqno;
rimeaddr_t last_originator;
const struct nf_callbacks *u;
};
void nf_open(struct nf_conn *c, u16_t channel,
const struct nf_callbacks *u);
void nf_open(struct nf_conn *c, clock_time_t queue_time,
u16_t channel, const struct nf_callbacks *u);
void nf_close(struct nf_conn *c);
int nf_send(struct nf_conn *c);

View file

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: route-discovery.c,v 1.1 2007/03/22 17:34:16 adamdunkels Exp $
* $Id: route-discovery.c,v 1.2 2007/03/25 12:06:28 adamdunkels Exp $
*/
/**
@ -207,10 +207,12 @@ static const struct uc_callbacks rrep_callbacks = {rrep_packet_received};
static const struct nf_callbacks rreq_callbacks = {rreq_packet_received, NULL};
/*---------------------------------------------------------------------------*/
void
route_discovery_open(struct route_discovery_conn *c, u16_t channels,
route_discovery_open(struct route_discovery_conn *c,
clock_time time,
u16_t channels,
const struct route_discovery_callbacks *callbacks)
{
nf_open(&c->rreqconn, channels + 0, &rreq_callbacks);
nf_open(&c->rreqconn, time, channels + 0, &rreq_callbacks);
uc_open(&c->rrepconn, channels + 1, &rrep_callbacks);
c->cb = callbacks;
}

View file

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: route-discovery.h,v 1.1 2007/03/22 17:34:16 adamdunkels Exp $
* $Id: route-discovery.h,v 1.2 2007/03/25 12:06:28 adamdunkels Exp $
*/
/**
@ -63,7 +63,8 @@ struct route_discovery_conn {
const struct route_discovery_callbacks *cb;
};
void route_discovery_open(struct route_discovery_conn *c, u16_t channels,
void route_discovery_open(struct route_discovery_conn *c, clock_time_t time,
u16_t channels,
const struct route_discovery_callbacks *callbacks);
void route_discovery_discover(struct route_discovery_conn *c, rimeaddr_t *dest,
clock_time_t timeout);