Added a function (quick hack) that sets the radio transmission power of outgoing announcement packets in xmac

This commit is contained in:
adamdunkels 2009-03-23 21:06:26 +00:00
parent 1cbc0f4ea9
commit ec1677ca6c
2 changed files with 16 additions and 2 deletions

View file

@ -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.29 2009/03/23 21:00:25 adamdunkels Exp $ * $Id: xmac.c,v 1.30 2009/03/23 21:06:26 adamdunkels Exp $
*/ */
/** /**
@ -162,6 +162,8 @@ static const struct radio_driver *radio;
#if XMAC_CONF_ANNOUNCEMENTS #if XMAC_CONF_ANNOUNCEMENTS
/* Timers for keeping track of when to send announcements. */ /* Timers for keeping track of when to send announcements. */
static struct ctimer announcement_cycle_ctimer, announcement_ctimer; static struct ctimer announcement_cycle_ctimer, announcement_ctimer;
static int announcement_radio_txpower;
#endif /* XMAC_CONF_ANNOUNCEMENTS */ #endif /* XMAC_CONF_ANNOUNCEMENTS */
/* Flag that is used to keep track of whether or not we are listening /* Flag that is used to keep track of whether or not we are listening
@ -704,6 +706,8 @@ send_announcement(void *ptr)
if(announcement_len > 0) { if(announcement_len > 0) {
packetbuf_set_datalen(sizeof(struct xmac_hdr) + announcement_len); packetbuf_set_datalen(sizeof(struct xmac_hdr) + announcement_len);
packetbuf_set_attr(PACKETBUF_ATTR_RADIO_TXPOWER, announcement_radio_txpower);
radio->send(packetbuf_hdrptr(), packetbuf_totlen()); radio->send(packetbuf_hdrptr(), packetbuf_totlen());
} }
} }
@ -727,6 +731,14 @@ listen_callback(int periods)
} }
#endif /* XMAC_CONF_ANNOUNCEMENTS */ #endif /* XMAC_CONF_ANNOUNCEMENTS */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void
xmac_set_announcement_radio_txpower(int txpower)
{
#if XMAC_CONF_ANNOUNCEMENTS
announcement_radio_txpower = txpower;
#endif /* XMAC_CONF_ANNOUNCEMENTS */
}
/*---------------------------------------------------------------------------*/
const struct mac_driver * const struct mac_driver *
xmac_init(const struct radio_driver *d) xmac_init(const struct radio_driver *d)
{ {

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: xmac.h,v 1.6 2007/11/12 22:29:37 adamdunkels Exp $ * $Id: xmac.h,v 1.7 2009/03/23 21:06:26 adamdunkels Exp $
*/ */
/** /**
@ -64,4 +64,6 @@ const struct mac_driver *xmac_init(const struct radio_driver *d);
extern struct xmac_config xmac_config; extern struct xmac_config xmac_config;
void xmac_set_announcement_radio_txpower(int txpower);
#endif /* __XMAC_H__ */ #endif /* __XMAC_H__ */