Set CCA threshold before starting, to make ContikiMAC more efficient. Fix compilation problem with non-IPv6 compiles. Various style fixes.

This commit is contained in:
Adam Dunkels 2012-04-22 20:54:02 +02:00
parent cf9de6be25
commit b4e7468b12

View file

@ -94,6 +94,10 @@ PROCINIT(&sensors_process);
SENSORS(&button_sensor, &temperature_sensor, &acc_sensor); SENSORS(&button_sensor, &temperature_sensor, &acc_sensor);
/* The default CCA threshold is set to -77, which is the same as the
default setting on the TI CC2420. */
#define DEFAULT_RADIO_CCA_THRESHOLD -77
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
set_rime_addr(void) set_rime_addr(void)
@ -106,7 +110,9 @@ set_rime_addr(void)
int8u *stm32w_eui64 = ST_RadioGetEui64(); int8u *stm32w_eui64 = ST_RadioGetEui64();
{ {
int8u c; int8u c;
for(c = 0; c < 8; c++) { // Copy the EUI-64 to lladdr converting from Little-Endian to Big-Endian. /* Copy the EUI-64 to lladdr converting from Little-Endian to
Big-Endian. */
for(c = 0; c < 8; c++) {
eui64.u8[c] = stm32w_eui64[7 - c]; eui64.u8[c] = stm32w_eui64[7 - c];
} }
} }
@ -126,7 +132,6 @@ set_rime_addr(void)
printf("%d.", rimeaddr_node_addr.u8[i]); printf("%d.", rimeaddr_node_addr.u8[i]);
} }
printf("%d\n", rimeaddr_node_addr.u8[i]); printf("%d\n", rimeaddr_node_addr.u8[i]);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int int
@ -141,7 +146,7 @@ main(void)
uart1_init(115200); uart1_init(115200);
// Led initialization /* Led initialization */
leds_init(); leds_init();
INTERRUPTS_ON(); INTERRUPTS_ON();
@ -160,13 +165,13 @@ main(void)
uart1_set_input(serial_line_input_byte); uart1_set_input(serial_line_input_byte);
serial_line_init(); serial_line_init();
#endif #endif
/* rtimer and ctimer should be initialized before radio duty cycling layers*/ /* rtimer and ctimer should be initialized before radio duty cycling
layers */
rtimer_init(); rtimer_init();
/* etimer_process should be initialized before ctimer */ /* etimer_process should be initialized before ctimer */
process_start(&etimer_process, NULL); process_start(&etimer_process, NULL);
ctimer_init(); ctimer_init();
netstack_init(); netstack_init();
set_rime_addr(); set_rime_addr();
@ -185,8 +190,17 @@ main(void)
energest_init(); energest_init();
ENERGEST_ON(ENERGEST_TYPE_CPU); ENERGEST_ON(ENERGEST_TYPE_CPU);
autostart_start(autostart_processes); /* Set the Clear Channel Assessment (CCA) threshold of the
radio. The CCA threshold is used both for sending packets and for
waking up ContikiMAC nodes. If the CCA threshold is too high,
ContikiMAC will not wake up from neighbor transmissions. If the
CCA threshold is too low, transmissions will be too restrictive
and no packets will be sent. DEFAULT_RADIO_CCA_THRESHOLD is
defined in this file. */
ST_RadioSetEdCcaThreshold(DEFAULT_RADIO_CCA_THRESHOLD);
autostart_start(autostart_processes);
#if UIP_CONF_IPV6
printf("Tentative link-local IPv6 address "); printf("Tentative link-local IPv6 address ");
{ {
uip_ds6_addr_t *lladdr; uip_ds6_addr_t *lladdr;
@ -199,6 +213,7 @@ main(void)
printf("%02x%02x\n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]); printf("%02x%02x\n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]);
} }
if(!UIP_CONF_IPV6_RPL) { if(!UIP_CONF_IPV6_RPL) {
uip_ipaddr_t ipaddr; uip_ipaddr_t ipaddr;
int i; int i;
@ -213,6 +228,7 @@ main(void)
printf("%02x%02x\n", printf("%02x%02x\n",
ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]); ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]);
} }
#endif /* UIP_CONF_IPV6 */
watchdog_start(); watchdog_start();
@ -229,12 +245,12 @@ main(void)
ENERGEST_OFF(ENERGEST_TYPE_CPU); ENERGEST_OFF(ENERGEST_TYPE_CPU);
//watchdog_stop(); /* watchdog_stop(); */
ENERGEST_ON(ENERGEST_TYPE_LPM); ENERGEST_ON(ENERGEST_TYPE_LPM);
/* Go to idle mode. */ /* Go to idle mode. */
halSleepWithOptions(SLEEPMODE_IDLE,0); halSleepWithOptions(SLEEPMODE_IDLE,0);
/* We are awake. */ /* We are awake. */
//watchdog_start(); /* watchdog_start(); */
ENERGEST_OFF(ENERGEST_TYPE_LPM); ENERGEST_OFF(ENERGEST_TYPE_LPM);
ENERGEST_ON(ENERGEST_TYPE_CPU); ENERGEST_ON(ENERGEST_TYPE_CPU);