Minor fixes to platform initialization

This commit is contained in:
Simon Duquennoy 2017-10-18 18:21:26 +02:00 committed by George Oikonomou
parent ff4ad7998a
commit 56d1f795ff
5 changed files with 20 additions and 80 deletions

View File

@ -165,11 +165,10 @@ set_lladdr(void)
addr.u8[1] = node_id >> 8;
#endif /* NETSTACK_CONF_WITH_IPV6 */
linkaddr_set_node_addr(&addr);
printf("Contiki started with address ");
for(i = 0; i < sizeof(addr.u8) - 1; i++) {
printf("%d.", addr.u8[i]);
}
printf("%d\n", addr.u8[i]);
printf("Link-layer address ");
log_lladdr(&addr);
printf("\n");
}
/*---------------------------------------------------------------------------*/
void
@ -215,6 +214,7 @@ contiki_init()
/* IPv6 CONFIGURATION */
{
int i;
uip_ds6_addr_t *lladdr;
uint8_t addr[sizeof(uip_lladdr.addr)];
for(i = 0; i < sizeof(uip_lladdr.addr); i += 2) {
addr[i + 1] = node_id & 0xff;
@ -225,33 +225,10 @@ contiki_init()
process_start(&tcpip_process, NULL);
lladdr = uip_ds6_get_link_local(-1);
printf("Tentative link-local IPv6 address ");
{
uip_ds6_addr_t *lladdr;
int i;
lladdr = uip_ds6_get_link_local(-1);
for(i = 0; i < 7; ++i) {
printf("%02x%02x:", lladdr->ipaddr.u8[i * 2],
lladdr->ipaddr.u8[i * 2 + 1]);
}
printf("%02x%02x\n", lladdr->ipaddr.u8[14],
lladdr->ipaddr.u8[15]);
}
if(1) {
uip_ipaddr_t ipaddr;
int i;
uip_ip6addr(&ipaddr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0);
uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
uip_ds6_addr_add(&ipaddr, 0, ADDR_TENTATIVE);
printf("Tentative global IPv6 address ");
for(i = 0; i < 7; ++i) {
printf("%02x%02x:",
ipaddr.u8[i * 2], ipaddr.u8[i * 2 + 1]);
}
printf("%02x%02x\n",
ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]);
}
log_6addr(lladdr != NULL ? &lladdr->ipaddr : NULL);
printf("\n");
}
#endif /* NETSTACK_CONF_WITH_IPV6 */

View File

@ -129,22 +129,6 @@ init_node_mac(void)
node_mac[0] = psExtAddress.sExt.u32H >> (uint32_t)24;
}
/*---------------------------------------------------------------------------*/
#if NETSTACK_CONF_WITH_IPV6
static void
start_uip6(void)
{
if(!UIP_CONF_IPV6_RPL) {
uip_ipaddr_t ipaddr;
uip_ip6addr(&ipaddr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0);
uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
uip_ds6_addr_add(&ipaddr, 0, ADDR_TENTATIVE);
LOG_INFO("Tentative global IPv6 address ");
LOG_INFO_6ADDR(&ipaddr);
LOG_INFO_("\n");
}
}
#endif /* NETSTACK_CONF_WITH_IPV6 */
/*---------------------------------------------------------------------------*/
static void
set_linkaddr(void)
{
@ -256,10 +240,6 @@ platform_init_stage_three(void)
timesynch_set_authority_level((linkaddr_node_addr.u8[0] << 4) + 16);
#endif /* TIMESYNCH_CONF_ENABLED */
#if NETSTACK_CONF_WITH_IPV6
start_uip6();
#endif /* NETSTACK_CONF_WITH_IPV6 */
/* need this to reliably generate the first rtimer callback and callbacks in other
auto-start processes */
(void)u32AHI_Init();

View File

@ -209,16 +209,6 @@ platform_init_stage_three(void)
NETSTACK_MAC.name,
CC2420_CONF_CHANNEL,
CC2420_CONF_CCA_THRESH);
if(!UIP_CONF_IPV6_RPL) {
uip_ipaddr_t ipaddr;
uip_ip6addr(&ipaddr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0);
uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
uip_ds6_addr_add(&ipaddr, 0, ADDR_TENTATIVE);
LOG_INFO("Tentative global IPv6 address ");
LOG_INFO_6ADDR(&ipaddr);
LOG_INFO_("\n");
}
#else /* NETSTACK_CONF_WITH_IPV6 */
LOG_INFO("%s, radio channel %u\n",
NETSTACK_MAC.name, CC2420_CONF_CHANNEL);

View File

@ -169,17 +169,6 @@ set_rf_params(void)
/* Populate linkaddr_node_addr. Maintain endianness */
memcpy(&linkaddr_node_addr, &ext_addr[8 - LINKADDR_SIZE], LINKADDR_SIZE);
#if PLATFORM_STARTUP_VERBOSE
{
int i;
printf("Contiki configured with address ");
for(i = 0; i < LINKADDR_SIZE - 1; i++) {
printf("%02x:", linkaddr_node_addr.u8[i]);
}
printf("%02x\n", linkaddr_node_addr.u8[i]);
}
#endif
NETSTACK_RADIO.set_value(RADIO_PARAM_PAN_ID, IEEE802154_PANID);
NETSTACK_RADIO.set_value(RADIO_PARAM_16BIT_ADDR, short_addr);
NETSTACK_RADIO.set_value(RADIO_PARAM_CHANNEL, CC2538_RF_CHANNEL);

View File

@ -92,17 +92,21 @@ main(void)
netstack_init();
#if NETSTACK_CONF_WITH_IPV6
memcpy(&uip_lladdr.addr, &linkaddr_node_addr, sizeof(uip_lladdr.addr));
process_start(&tcpip_process, NULL);
LOG_INFO("Contiki configured with address ");
LOG_INFO("Link-layer address ");
LOG_INFO_LLADDR(&linkaddr_node_addr);
LOG_INFO_("\n");
LOG_INFO("Tentative link-local IPv6 address ");
LOG_INFO_6ADDR(&uip_ds6_get_link_local(-1)->ipaddr);
LOG_INFO_("\n");
#if NETSTACK_CONF_WITH_IPV6
{
uip_ds6_addr_t *lladdr;
memcpy(&uip_lladdr.addr, &linkaddr_node_addr, sizeof(uip_lladdr.addr));
process_start(&tcpip_process, NULL);
lladdr = uip_ds6_get_link_local(-1);
LOG_INFO("Tentative link-local IPv6 address ");
LOG_INFO_6ADDR(lladdr != NULL ? &lladdr->ipaddr : NULL);
LOG_INFO_("\n");
}
#endif /* NETSTACK_CONF_WITH_IPV6 */