From 287b4767e39b6aff45eb0c8f93a73059e7f5de43 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Fri, 20 May 2016 13:40:20 +0200 Subject: [PATCH] Orchestra: handle case where ORCHESTRA_UNICAST_PERIOD is smaller than the network size --- .../orchestra-rule-unicast-per-neighbor.c | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/apps/orchestra/orchestra-rule-unicast-per-neighbor.c b/apps/orchestra/orchestra-rule-unicast-per-neighbor.c index b70a907d0..acba8e7be 100644 --- a/apps/orchestra/orchestra-rule-unicast-per-neighbor.c +++ b/apps/orchestra/orchestra-rule-unicast-per-neighbor.c @@ -85,10 +85,16 @@ add_uc_link(const linkaddr_t *linkaddr) { if(linkaddr != NULL) { uint16_t timeslot = get_node_timeslot(linkaddr); - tsch_schedule_add_link(sf_unicast, - ORCHESTRA_UNICAST_SENDER_BASED ? LINK_OPTION_RX : LINK_OPTION_TX | UNICAST_SLOT_SHARED_FLAG, - LINK_TYPE_NORMAL, &tsch_broadcast_address, - timeslot, channel_offset); + uint8_t link_options = ORCHESTRA_UNICAST_SENDER_BASED ? LINK_OPTION_RX : LINK_OPTION_TX | UNICAST_SLOT_SHARED_FLAG; + + if(timeslot == get_node_timeslot(&linkaddr_node_addr)) { + /* This is also our timeslot, add necessary flags */ + link_options |= ORCHESTRA_UNICAST_SENDER_BASED ? LINK_OPTION_TX | UNICAST_SLOT_SHARED_FLAG: LINK_OPTION_RX; + } + + /* Add/update link */ + tsch_schedule_add_link(sf_unicast, link_options, LINK_TYPE_NORMAL, &tsch_broadcast_address, + timeslot, channel_offset); } } /*---------------------------------------------------------------------------*/ @@ -123,7 +129,17 @@ remove_uc_link(const linkaddr_t *linkaddr) } item = nbr_table_next(nbr_routes, item); } - tsch_schedule_remove_link(sf_unicast, l); + + /* Do we need this timeslot? */ + if(timeslot == get_node_timeslot(&linkaddr_node_addr)) { + /* This is our link, keep it but update the link options */ + uint8_t link_options = ORCHESTRA_UNICAST_SENDER_BASED ? LINK_OPTION_TX | UNICAST_SLOT_SHARED_FLAG: LINK_OPTION_RX; + tsch_schedule_add_link(sf_unicast, link_options, LINK_TYPE_NORMAL, &tsch_broadcast_address, + timeslot, channel_offset); + } else { + /* Remove link */ + tsch_schedule_remove_link(sf_unicast, l); + } } /*---------------------------------------------------------------------------*/ static void