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) { if(tsch_is_associated) {
struct tsch_neighbor *n = tsch_queue_get_time_source(); struct tsch_neighbor *n = tsch_queue_get_time_source();
/* Simply send an empty packet */ if(n != NULL) {
packetbuf_clear(); /* Simply send an empty packet */
packetbuf_set_addr(PACKETBUF_ADDR_RECEIVER, &n->addr); packetbuf_clear();
NETSTACK_MAC.send(keepalive_packet_sent, NULL); packetbuf_set_addr(PACKETBUF_ADDR_RECEIVER, &n->addr);
LOG_INFO("sending KA to "); NETSTACK_MAC.send(keepalive_packet_sent, NULL);
LOG_INFO_LLADDR(&n->addr); LOG_INFO("sending KA to ");
LOG_INFO_("\n"); LOG_INFO_LLADDR(&n->addr);
LOG_INFO_("\n");
} else {
LOG_INFO("no timesource - KA not sent\n");
}
} }
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/