Avoid tsch crash when loosing timesource

This commit is contained in:
Michael Karlsson 2017-11-07 01:43:54 +01:00
parent 0adc6bfbad
commit c33c10540a
1 changed files with 11 additions and 7 deletions

View File

@ -304,13 +304,17 @@ keepalive_send(void *ptr)
{
if(tsch_is_associated) {
struct tsch_neighbor *n = tsch_queue_get_time_source();
/* Simply send an empty packet */
packetbuf_clear();
packetbuf_set_addr(PACKETBUF_ADDR_RECEIVER, &n->addr);
NETSTACK_MAC.send(keepalive_packet_sent, NULL);
LOG_INFO("sending KA to ");
LOG_INFO_LLADDR(&n->addr);
LOG_INFO_("\n");
if(n != NULL) {
/* Simply send an empty packet */
packetbuf_clear();
packetbuf_set_addr(PACKETBUF_ADDR_RECEIVER, &n->addr);
NETSTACK_MAC.send(keepalive_packet_sent, NULL);
LOG_INFO("sending KA to ");
LOG_INFO_LLADDR(&n->addr);
LOG_INFO_("\n");
} else {
LOG_INFO("no timesource - KA not sent\n");
}
}
}
/*---------------------------------------------------------------------------*/