Added the CSMA MAC mechanism on top of the default duty cycling

mechanism X-MAC. The CSMA is configurable with a MAC_CSMA define, just
like the MAC protocol is configurable with the MAC_DRIVER define.
This commit is contained in:
adamdunkels 2010-01-25 11:48:16 +00:00
parent 4f3e8d565c
commit 5922402b3e
2 changed files with 21 additions and 3 deletions

View file

@ -1,10 +1,11 @@
/* -*- C -*- */ /* -*- C -*- */
/* @(#)$Id: contiki-conf.h,v 1.65 2010/01/14 22:26:38 nifi Exp $ */ /* @(#)$Id: contiki-conf.h,v 1.66 2010/01/25 11:48:16 adamdunkels Exp $ */
#ifndef CONTIKI_CONF_H #ifndef CONTIKI_CONF_H
#define CONTIKI_CONF_H #define CONTIKI_CONF_H
/* Specifies the default MAC driver */ /* Specifies the default MAC driver */
#define MAC_CONF_CSMA 1
#define MAC_CONF_DRIVER xmac_driver #define MAC_CONF_DRIVER xmac_driver
#define XMAC_CONF_COMPOWER 1 #define XMAC_CONF_COMPOWER 1

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* @(#)$Id: contiki-sky-main.c,v 1.63 2010/01/21 11:17:08 adamdunkels Exp $ * @(#)$Id: contiki-sky-main.c,v 1.64 2010/01/25 11:48:16 adamdunkels Exp $
*/ */
#include <signal.h> #include <signal.h>
@ -119,6 +119,15 @@ static uint8_t is_gateway;
#endif /* MAC_CONF_DRIVER */ #endif /* MAC_CONF_DRIVER */
#endif /* MAC_DRIVER */ #endif /* MAC_DRIVER */
#ifndef MAC_CSMA
#ifdef MAC_CONF_CSMA
#define MAC_CSMA MAC_CONF_CSMA
#else
#define MAC_CSMA 1
#endif /* MAC_CONF_CSMA */
#endif /* MAC_CSMA */
extern const struct mac_driver MAC_DRIVER; extern const struct mac_driver MAC_DRIVER;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
@ -325,8 +334,16 @@ main(int argc, char **argv)
uip_router_register(&rimeroute); uip_router_register(&rimeroute);
#endif /* UIP_CONF_ROUTER */ #endif /* UIP_CONF_ROUTER */
#else /* WITH_UIP6 */ #else /* WITH_UIP6 */
#if MAC_CSMA
rime_init(csma_init(MAC_DRIVER.init(&cc2420_driver)));
#else /* MAC_CSMA */
rime_init(MAC_DRIVER.init(&cc2420_driver)); rime_init(MAC_DRIVER.init(&cc2420_driver));
printf(" %s channel %u\n", rime_mac->name, RF_CHANNEL); #endif /* MAC_CSMA */
printf(" %s, channel check rate %d Hz, radio channel %u\n",
rime_mac->name,
CLOCK_SECOND / (rime_mac->channel_check_interval() == 0? 1:
rime_mac->channel_check_interval()),
RF_CHANNEL);
#endif /* WITH_UIP6 */ #endif /* WITH_UIP6 */
#if !WITH_UIP && !WITH_UIP6 #if !WITH_UIP && !WITH_UIP6