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
|
@ -86,13 +86,17 @@
|
||||||
|
|
||||||
|
|
||||||
#if UIP_CONF_IPV6
|
#if UIP_CONF_IPV6
|
||||||
PROCINIT(&tcpip_process, &sensors_process);
|
PROCINIT(&tcpip_process, &sensors_process);
|
||||||
#else
|
#else
|
||||||
PROCINIT(&sensors_process);
|
PROCINIT(&sensors_process);
|
||||||
#warning "No TCP/IP process!"
|
#warning "No TCP/IP process!"
|
||||||
#endif
|
#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
|
static void
|
||||||
|
@ -101,24 +105,26 @@ set_rime_addr(void)
|
||||||
int i;
|
int i;
|
||||||
union {
|
union {
|
||||||
uint8_t u8[8];
|
uint8_t u8[8];
|
||||||
}eui64;
|
} eui64;
|
||||||
|
|
||||||
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
|
||||||
eui64.u8[c] = stm32w_eui64[7 - c];
|
Big-Endian. */
|
||||||
}
|
for(c = 0; c < 8; c++) {
|
||||||
|
eui64.u8[c] = stm32w_eui64[7 - c];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if UIP_CONF_IPV6
|
#if UIP_CONF_IPV6
|
||||||
memcpy(&uip_lladdr.addr, &eui64, sizeof(uip_lladdr.addr));
|
memcpy(&uip_lladdr.addr, &eui64, sizeof(uip_lladdr.addr));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if UIP_CONF_IPV6
|
#if UIP_CONF_IPV6
|
||||||
rimeaddr_set_node_addr((rimeaddr_t *)&eui64);
|
rimeaddr_set_node_addr((rimeaddr_t *)&eui64);
|
||||||
#else
|
#else
|
||||||
rimeaddr_set_node_addr((rimeaddr_t *)&eui64.u8[8-RIMEADDR_SIZE]);
|
rimeaddr_set_node_addr((rimeaddr_t *)&eui64.u8[8 - RIMEADDR_SIZE]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
printf("Rime started with address ");
|
printf("Rime started with address ");
|
||||||
|
@ -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
|
||||||
rtimer_init();
|
layers */
|
||||||
/* etimer_process should be initialized before ctimer */
|
rtimer_init();
|
||||||
process_start(&etimer_process, NULL);
|
/* etimer_process should be initialized before ctimer */
|
||||||
ctimer_init();
|
process_start(&etimer_process, NULL);
|
||||||
|
ctimer_init();
|
||||||
|
|
||||||
netstack_init();
|
netstack_init();
|
||||||
|
|
||||||
set_rime_addr();
|
set_rime_addr();
|
||||||
|
@ -179,14 +184,23 @@ main(void)
|
||||||
IEEE802154_CONF_PANID, UIP_CONF_LL_802154?64:16);
|
IEEE802154_CONF_PANID, UIP_CONF_LL_802154?64:16);
|
||||||
uip_debug_lladdr_print(&rimeaddr_node_addr);
|
uip_debug_lladdr_print(&rimeaddr_node_addr);
|
||||||
printf(", radio channel %u\n", RF_CHANNEL);
|
printf(", radio channel %u\n", RF_CHANNEL);
|
||||||
|
|
||||||
procinit_init();
|
procinit_init();
|
||||||
|
|
||||||
energest_init();
|
energest_init();
|
||||||
ENERGEST_ON(ENERGEST_TYPE_CPU);
|
ENERGEST_ON(ENERGEST_TYPE_CPU);
|
||||||
|
|
||||||
|
/* 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);
|
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,10 +228,11 @@ 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();
|
||||||
|
|
||||||
while(1){
|
while(1) {
|
||||||
|
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue