added init function in MAC driver for easier configuration
This commit is contained in:
parent
728c482cc3
commit
912aba7280
13 changed files with 70 additions and 38 deletions
|
@ -28,7 +28,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* $Id: ctdma_mac.c,v 1.3 2009/03/12 21:58:20 adamdunkels Exp $
|
* $Id: ctdma_mac.c,v 1.4 2009/06/22 11:14:11 nifi Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "contiki.h"
|
#include "contiki.h"
|
||||||
|
@ -215,12 +215,16 @@ on(void)
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int
|
static int
|
||||||
off(void)
|
off(int keep_radio_on)
|
||||||
{
|
{
|
||||||
return radio->off();
|
if(keep_radio_on) {
|
||||||
|
return radio->on();
|
||||||
|
} else {
|
||||||
|
return radio->off();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
void
|
const struct mac_driver *
|
||||||
ctdma_mac_init(const struct radio_driver *d)
|
ctdma_mac_init(const struct radio_driver *d)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -232,9 +236,12 @@ ctdma_mac_init(const struct radio_driver *d)
|
||||||
radio = d;
|
radio = d;
|
||||||
radio->set_receive_function(input);
|
radio->set_receive_function(input);
|
||||||
radio->on();
|
radio->on();
|
||||||
|
return &ctdma_mac_driver;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
const struct mac_driver ctdma_mac_driver = {
|
const struct mac_driver ctdma_mac_driver = {
|
||||||
|
"CTDMA",
|
||||||
|
ctdma_mac_init,
|
||||||
send,
|
send,
|
||||||
read,
|
read,
|
||||||
set_receive_function,
|
set_receive_function,
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* $Id: ctdma_mac.h,v 1.1 2007/09/18 10:36:36 fros4943 Exp $
|
* $Id: ctdma_mac.h,v 1.2 2009/06/22 11:14:11 nifi Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __CTDMA_MAC_H__
|
#ifndef __CTDMA_MAC_H__
|
||||||
|
@ -39,6 +39,6 @@
|
||||||
|
|
||||||
extern const struct mac_driver ctdma_mac_driver;
|
extern const struct mac_driver ctdma_mac_driver;
|
||||||
|
|
||||||
void ctdma_mac_init(const struct radio_driver *r);
|
const struct mac_driver *ctdma_mac_init(const struct radio_driver *r);
|
||||||
|
|
||||||
#endif /* __CTDMA_MAC_H__ */
|
#endif /* __CTDMA_MAC_H__ */
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* $Id: cxmac.c,v 1.3 2009/03/12 21:58:20 adamdunkels Exp $
|
* $Id: cxmac.c,v 1.4 2009/06/22 11:14:11 nifi Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -481,7 +481,7 @@ read(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
void
|
const struct mac_driver *
|
||||||
cxmac_init(const struct radio_driver *d)
|
cxmac_init(const struct radio_driver *d)
|
||||||
{
|
{
|
||||||
radio_is_on = 0;
|
radio_is_on = 0;
|
||||||
|
@ -494,6 +494,7 @@ cxmac_init(const struct radio_driver *d)
|
||||||
|
|
||||||
radio = d;
|
radio = d;
|
||||||
radio->set_receive_function(input);
|
radio->set_receive_function(input);
|
||||||
|
return &cxmac_driver;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int
|
static int
|
||||||
|
@ -511,22 +512,20 @@ on(void)
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int
|
static int
|
||||||
off(int radio_status)
|
off(int keep_radio_on)
|
||||||
{
|
{
|
||||||
should_stop = 1;
|
should_stop = 1;
|
||||||
return radio->off();
|
if(keep_radio_on) {
|
||||||
|
|
||||||
/* switch(radio_status) {
|
|
||||||
case MAC_RADIO_ON:
|
|
||||||
return radio->on();
|
return radio->on();
|
||||||
case MAC_RADIO_OFF:
|
} else {
|
||||||
return radio->off();
|
return radio->off();
|
||||||
}
|
}
|
||||||
return 0; */
|
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
const struct mac_driver cxmac_driver =
|
const struct mac_driver cxmac_driver =
|
||||||
{
|
{
|
||||||
|
"CXMAC",
|
||||||
|
cxmac_init,
|
||||||
qsend,
|
qsend,
|
||||||
read,
|
read,
|
||||||
set_receive_function,
|
set_receive_function,
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* $Id: cxmac.h,v 1.1 2007/09/18 10:35:39 fros4943 Exp $
|
* $Id: cxmac.h,v 1.2 2009/06/22 11:14:11 nifi Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,6 +46,6 @@
|
||||||
|
|
||||||
extern const struct mac_driver cxmac_driver;
|
extern const struct mac_driver cxmac_driver;
|
||||||
|
|
||||||
void cxmac_init(const struct radio_driver *d);
|
const struct mac_driver *cxmac_init(const struct radio_driver *d);
|
||||||
|
|
||||||
#endif /* __CXMAC_H__ */
|
#endif /* __CXMAC_H__ */
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* $Id: lpp.c,v 1.22 2009/05/10 21:09:05 adamdunkels Exp $
|
* $Id: lpp.c,v 1.23 2009/06/22 11:14:11 nifi Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -818,8 +818,9 @@ off(int keep_radio_on)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static const struct mac_driver lpp_driver = {
|
const struct mac_driver lpp_driver = {
|
||||||
"LPP",
|
"LPP",
|
||||||
|
lpp_init,
|
||||||
send_packet,
|
send_packet,
|
||||||
read_packet,
|
read_packet,
|
||||||
set_receive_function,
|
set_receive_function,
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* $Id: lpp.h,v 1.1 2008/05/15 08:56:29 adamdunkels Exp $
|
* $Id: lpp.h,v 1.2 2009/06/22 11:14:11 nifi Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,6 +47,8 @@
|
||||||
#include "net/mac/mac.h"
|
#include "net/mac/mac.h"
|
||||||
#include "dev/radio.h"
|
#include "dev/radio.h"
|
||||||
|
|
||||||
|
extern const struct mac_driver lpp_driver;
|
||||||
|
|
||||||
const struct mac_driver *lpp_init(const struct radio_driver *d);
|
const struct mac_driver *lpp_init(const struct radio_driver *d);
|
||||||
|
|
||||||
#endif /* __LPP_H__ */
|
#endif /* __LPP_H__ */
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* $Id: mac.h,v 1.4 2008/07/02 14:10:28 adamdunkels Exp $
|
* $Id: mac.h,v 1.5 2009/06/22 11:14:11 nifi Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,12 +41,17 @@
|
||||||
#ifndef __MAC_H__
|
#ifndef __MAC_H__
|
||||||
#define __MAC_H__
|
#define __MAC_H__
|
||||||
|
|
||||||
|
#include "dev/radio.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The structure of a MAC protocol driver in Contiki.
|
* The structure of a MAC protocol driver in Contiki.
|
||||||
*/
|
*/
|
||||||
struct mac_driver {
|
struct mac_driver {
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
|
/** Initialize the MAC driver */
|
||||||
|
const struct mac_driver *(* init)(const struct radio_driver *r);
|
||||||
|
|
||||||
/** Send a packet from the Rime buffer */
|
/** Send a packet from the Rime buffer */
|
||||||
int (* send)(void);
|
int (* send)(void);
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* $Id: nullmac.c,v 1.9 2009/03/12 21:58:20 adamdunkels Exp $
|
* $Id: nullmac.c,v 1.10 2009/06/22 11:14:11 nifi Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -92,6 +92,7 @@ off(int keep_radio_on)
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
const struct mac_driver nullmac_driver = {
|
const struct mac_driver nullmac_driver = {
|
||||||
"nullmac",
|
"nullmac",
|
||||||
|
nullmac_init,
|
||||||
send_packet,
|
send_packet,
|
||||||
read_packet,
|
read_packet,
|
||||||
set_receive_function,
|
set_receive_function,
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* $Id: sicslowmac.c,v 1.2 2009/05/26 12:08:29 nifi Exp $
|
* $Id: sicslowmac.c,v 1.3 2009/06/22 11:14:11 nifi Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -234,6 +234,7 @@ off(int keep_radio_on)
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
const struct mac_driver sicslowmac_driver = {
|
const struct mac_driver sicslowmac_driver = {
|
||||||
"sicslowmac",
|
"sicslowmac",
|
||||||
|
sicslowmac_init,
|
||||||
send_packet,
|
send_packet,
|
||||||
read_packet,
|
read_packet,
|
||||||
set_receive_function,
|
set_receive_function,
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* $Id: tdma_mac.c,v 1.6 2009/03/12 21:58:20 adamdunkels Exp $
|
* $Id: tdma_mac.c,v 1.7 2009/06/22 11:14:11 nifi Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "contiki.h"
|
#include "contiki.h"
|
||||||
|
@ -221,9 +221,13 @@ on(void)
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int
|
static int
|
||||||
off(void)
|
off(int keep_radio_on)
|
||||||
{
|
{
|
||||||
return radio->off();
|
if(keep_radio_on) {
|
||||||
|
return radio->on();
|
||||||
|
} else {
|
||||||
|
return radio->off();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
const struct mac_driver *
|
const struct mac_driver *
|
||||||
|
@ -243,6 +247,7 @@ tdma_mac_init(const struct radio_driver *d)
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
const struct mac_driver tdma_mac_driver = {
|
const struct mac_driver tdma_mac_driver = {
|
||||||
"TDMA MAC",
|
"TDMA MAC",
|
||||||
|
tdma_mac_init,
|
||||||
send,
|
send,
|
||||||
read,
|
read,
|
||||||
set_receive_function,
|
set_receive_function,
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* $Id: xmac.c,v 1.33 2009/05/06 15:05:28 adamdunkels Exp $
|
* $Id: xmac.c,v 1.34 2009/06/22 11:14:11 nifi Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -745,6 +745,7 @@ turn_off(int keep_radio_on)
|
||||||
const struct mac_driver xmac_driver =
|
const struct mac_driver xmac_driver =
|
||||||
{
|
{
|
||||||
"X-MAC",
|
"X-MAC",
|
||||||
|
xmac_init,
|
||||||
qsend_packet,
|
qsend_packet,
|
||||||
read_packet,
|
read_packet,
|
||||||
set_receive_function,
|
set_receive_function,
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
/* -*- C -*- */
|
/* -*- C -*- */
|
||||||
/* @(#)$Id: contiki-conf.h,v 1.53 2009/05/18 10:32:56 fros4943 Exp $ */
|
/* @(#)$Id: contiki-conf.h,v 1.54 2009/06/22 11:14:11 nifi Exp $ */
|
||||||
|
|
||||||
#ifndef CONTIKI_CONF_H
|
#ifndef CONTIKI_CONF_H
|
||||||
#define CONTIKI_CONF_H
|
#define CONTIKI_CONF_H
|
||||||
|
|
||||||
|
/* Specifies the default MAC driver */
|
||||||
|
#define MAC_CONF_DRIVER xmac_driver
|
||||||
|
|
||||||
#define XMAC_CONF_COMPOWER 1
|
#define XMAC_CONF_COMPOWER 1
|
||||||
#define XMAC_CONF_ANNOUNCEMENTS 1
|
#define XMAC_CONF_ANNOUNCEMENTS 1
|
||||||
#define RIME_CONF_NO_POLITE_ANNOUCEMENTS 1
|
#define RIME_CONF_NO_POLITE_ANNOUCEMENTS 1
|
||||||
|
|
|
@ -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.55 2009/05/12 17:32:49 adamdunkels Exp $
|
* @(#)$Id: contiki-sky-main.c,v 1.56 2009/06/22 11:14:11 nifi Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
@ -53,9 +53,6 @@
|
||||||
#include "lib/random.h"
|
#include "lib/random.h"
|
||||||
|
|
||||||
#include "net/mac/frame802154.h"
|
#include "net/mac/frame802154.h"
|
||||||
#include "net/mac/nullmac.h"
|
|
||||||
#include "net/mac/xmac.h"
|
|
||||||
#include "net/mac/lpp.h"
|
|
||||||
|
|
||||||
#if WITH_UIP6
|
#if WITH_UIP6
|
||||||
#include "net/sicslowpan.h"
|
#include "net/sicslowpan.h"
|
||||||
|
@ -106,6 +103,20 @@ static uint8_t is_gateway;
|
||||||
#include "experiment-setup.h"
|
#include "experiment-setup.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if WITH_NULLMAC
|
||||||
|
#define MAC_DRIVER nullmac_driver
|
||||||
|
#endif /* WITH_NULLMAC */
|
||||||
|
|
||||||
|
#ifndef MAC_DRIVER
|
||||||
|
#ifdef MAC_CONF_DRIVER
|
||||||
|
#define MAC_DRIVER MAC_CONF_DRIVER
|
||||||
|
#else
|
||||||
|
#define MAC_DRIVER xmac_driver
|
||||||
|
#endif /* MAC_CONF_DRIVER */
|
||||||
|
#endif /* MAC_DRIVER */
|
||||||
|
|
||||||
|
extern const struct mac_driver MAC_DRIVER;
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#if 0
|
#if 0
|
||||||
int
|
int
|
||||||
|
@ -271,11 +282,7 @@ 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 WITH_NULLMAC
|
rime_init(MAC_DRIVER.init(&cc2420_driver));
|
||||||
rime_init(nullmac_init(&cc2420_driver));
|
|
||||||
#else /* WITH_NULLMAC */
|
|
||||||
rime_init(xmac_init(&cc2420_driver));
|
|
||||||
#endif /* WITH_NULLMAC */
|
|
||||||
printf(" %s channel %u\n", rime_mac->name, RF_CHANNEL);
|
printf(" %s channel %u\n", rime_mac->name, RF_CHANNEL);
|
||||||
#endif /* WITH_UIP6 */
|
#endif /* WITH_UIP6 */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue