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:
parent
cf9de6be25
commit
b4e7468b12
1 changed files with 42 additions and 26 deletions
|
@ -92,7 +92,11 @@ PROCINIT(&sensors_process);
|
|||
#warning "No TCP/IP process!"
|
||||
#endif
|
||||
|
||||
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
|
||||
|
@ -101,12 +105,14 @@ set_rime_addr(void)
|
|||
int i;
|
||||
union {
|
||||
uint8_t u8[8];
|
||||
}eui64;
|
||||
} eui64;
|
||||
|
||||
int8u *stm32w_eui64 = ST_RadioGetEui64();
|
||||
{
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
@ -118,7 +124,7 @@ set_rime_addr(void)
|
|||
#if UIP_CONF_IPV6
|
||||
rimeaddr_set_node_addr((rimeaddr_t *)&eui64);
|
||||
#else
|
||||
rimeaddr_set_node_addr((rimeaddr_t *)&eui64.u8[8-RIMEADDR_SIZE]);
|
||||
rimeaddr_set_node_addr((rimeaddr_t *)&eui64.u8[8 - RIMEADDR_SIZE]);
|
||||
#endif
|
||||
|
||||
printf("Rime started with address ");
|
||||
|
@ -126,7 +132,6 @@ set_rime_addr(void)
|
|||
printf("%d.", rimeaddr_node_addr.u8[i]);
|
||||
}
|
||||
printf("%d\n", rimeaddr_node_addr.u8[i]);
|
||||
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
|
@ -141,7 +146,7 @@ main(void)
|
|||
|
||||
uart1_init(115200);
|
||||
|
||||
// Led initialization
|
||||
/* Led initialization */
|
||||
leds_init();
|
||||
|
||||
INTERRUPTS_ON();
|
||||
|
@ -160,13 +165,13 @@ main(void)
|
|||
uart1_set_input(serial_line_input_byte);
|
||||
serial_line_init();
|
||||
#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();
|
||||
/* etimer_process should be initialized before ctimer */
|
||||
process_start(&etimer_process, NULL);
|
||||
ctimer_init();
|
||||
|
||||
|
||||
netstack_init();
|
||||
|
||||
set_rime_addr();
|
||||
|
@ -185,8 +190,17 @@ main(void)
|
|||
energest_init();
|
||||
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 ");
|
||||
{
|
||||
uip_ds6_addr_t *lladdr;
|
||||
|
@ -199,6 +213,7 @@ main(void)
|
|||
printf("%02x%02x\n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]);
|
||||
}
|
||||
|
||||
|
||||
if(!UIP_CONF_IPV6_RPL) {
|
||||
uip_ipaddr_t ipaddr;
|
||||
int i;
|
||||
|
@ -213,10 +228,11 @@ main(void)
|
|||
printf("%02x%02x\n",
|
||||
ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]);
|
||||
}
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
|
||||
watchdog_start();
|
||||
|
||||
while(1){
|
||||
while(1) {
|
||||
|
||||
int r;
|
||||
|
||||
|
@ -229,12 +245,12 @@ main(void)
|
|||
|
||||
|
||||
ENERGEST_OFF(ENERGEST_TYPE_CPU);
|
||||
//watchdog_stop();
|
||||
/* watchdog_stop(); */
|
||||
ENERGEST_ON(ENERGEST_TYPE_LPM);
|
||||
/* Go to idle mode. */
|
||||
halSleepWithOptions(SLEEPMODE_IDLE,0);
|
||||
/* We are awake. */
|
||||
//watchdog_start();
|
||||
/* watchdog_start(); */
|
||||
ENERGEST_OFF(ENERGEST_TYPE_LPM);
|
||||
ENERGEST_ON(ENERGEST_TYPE_CPU);
|
||||
|
||||
|
|
Loading…
Reference in a new issue