Added a field to the struct mac interface:

channel_check_interval(). This function returns the interval by which
the duty cycling mechanism checks the radio channel for activity. It
is used by higher layer mechanisms to determine suitable timeouts for
retransmissions.
This commit is contained in:
adamdunkels 2010-01-25 11:43:32 +00:00
parent 15dd2bd88a
commit 7ad93e5d18
4 changed files with 29 additions and 5 deletions

View File

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: lpp.c,v 1.28 2009/12/06 13:18:32 adamdunkels Exp $
* $Id: lpp.c,v 1.29 2010/01/25 11:43:32 adamdunkels Exp $
*/
/**
@ -882,6 +882,12 @@ off(int keep_radio_on)
return 1;
}
/*---------------------------------------------------------------------------*/
static unsigned short
channel_check_interval(void)
{
return OFF_TIME + LISTEN_TIME;
}
/*---------------------------------------------------------------------------*/
const struct mac_driver lpp_driver = {
"LPP",
lpp_init,
@ -890,6 +896,7 @@ const struct mac_driver lpp_driver = {
set_receive_function,
on,
off,
channel_check_interval,
};
/*---------------------------------------------------------------------------*/
static void

View File

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: mac.h,v 1.7 2009/12/05 21:49:51 adamdunkels Exp $
* $Id: mac.h,v 1.8 2010/01/25 11:43:32 adamdunkels Exp $
*/
/**
@ -66,6 +66,9 @@ struct mac_driver {
/** Turn the MAC layer off. */
int (* off)(int keep_radio_on);
/** Returns the channel check interval, expressed in clock_time_t ticks. */
unsigned short (* channel_check_interval)(void);
};
/* Generic MAC return values. */

View File

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: nullmac.c,v 1.12 2009/12/05 13:29:41 adamdunkels Exp $
* $Id: nullmac.c,v 1.13 2010/01/25 11:43:32 adamdunkels Exp $
*/
/**
@ -93,6 +93,12 @@ off(int keep_radio_on)
}
}
/*---------------------------------------------------------------------------*/
static unsigned short
channel_check_interval(void)
{
return 0;
}
/*---------------------------------------------------------------------------*/
const struct mac_driver nullmac_driver = {
"nullmac",
nullmac_init,
@ -101,6 +107,7 @@ const struct mac_driver nullmac_driver = {
set_receive_function,
on,
off,
channel_check_interval,
};
/*---------------------------------------------------------------------------*/
const struct mac_driver *

View File

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: xmac.c,v 1.48 2010/01/14 20:14:03 adamdunkels Exp $
* $Id: xmac.c,v 1.49 2010/01/25 11:43:32 adamdunkels Exp $
*/
/**
@ -920,6 +920,12 @@ turn_off(int keep_radio_on)
}
}
/*---------------------------------------------------------------------------*/
static unsigned short
channel_check_interval(void)
{
return (1ul * CLOCK_SECOND * DEFAULT_PERIOD) / RTIMER_ARCH_SECOND;
}
/*---------------------------------------------------------------------------*/
const struct mac_driver xmac_driver =
{
"X-MAC",
@ -928,5 +934,6 @@ const struct mac_driver xmac_driver =
read_packet,
set_receive_function,
turn_on,
turn_off
turn_off,
channel_check_interval,
};