Merge pull request #1672 from simonduq/pr/orchestra-fixes

Various Orchestra fixes
This commit is contained in:
Simon Duquennoy 2016-05-22 14:37:34 +02:00
commit a7ce256309
2 changed files with 40 additions and 13 deletions

View file

@ -74,8 +74,8 @@ select_packet(uint16_t *slotframe, uint16_t *timeslot)
static void
new_time_source(const struct tsch_neighbor *old, const struct tsch_neighbor *new)
{
uint16_t old_ts = get_node_timeslot(&old->addr);
uint16_t new_ts = get_node_timeslot(&new->addr);
uint16_t old_ts = old != NULL ? get_node_timeslot(&old->addr) : 0xffff;
uint16_t new_ts = new != NULL ? get_node_timeslot(&new->addr) : 0xffff;
if(new_ts == old_ts) {
return;
@ -83,14 +83,24 @@ new_time_source(const struct tsch_neighbor *old, const struct tsch_neighbor *new
if(old_ts != 0xffff) {
/* Stop listening to the old time source's EBs */
if(old_ts == get_node_timeslot(&linkaddr_node_addr)) {
/* This was the same timeslot as slot. Reset original link options */
tsch_schedule_add_link(sf_eb, LINK_OPTION_TX, LINK_TYPE_ADVERTISING_ONLY,
&tsch_broadcast_address, old_ts, 0);
} else {
/* Remove slot */
tsch_schedule_remove_link_by_timeslot(sf_eb, old_ts);
}
}
if(new_ts != 0xffff) {
uint8_t link_options = LINK_OPTION_RX;
if(new_ts == get_node_timeslot(&linkaddr_node_addr)) {
/* This is also our timeslot, add necessary flags */
link_options |= LINK_OPTION_TX;
}
/* Listen to the time source's EBs */
tsch_schedule_add_link(sf_eb,
LINK_OPTION_RX,
LINK_TYPE_ADVERTISING_ONLY, NULL,
new_ts, 0);
tsch_schedule_add_link(sf_eb, link_options, LINK_TYPE_ADVERTISING_ONLY,
&tsch_broadcast_address, new_ts, 0);
}
}
/*---------------------------------------------------------------------------*/

View file

@ -85,9 +85,15 @@ 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,
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,8 +129,18 @@ remove_uc_link(const linkaddr_t *linkaddr)
}
item = nbr_table_next(nbr_routes, item);
}
/* 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
child_added(const linkaddr_t *linkaddr)
@ -160,13 +176,14 @@ static void
new_time_source(const struct tsch_neighbor *old, const struct tsch_neighbor *new)
{
if(new != old) {
const linkaddr_t *old_addr = old != NULL ? &old->addr : NULL;
const linkaddr_t *new_addr = new != NULL ? &new->addr : NULL;
if(new_addr != NULL) {
linkaddr_copy(&orchestra_parent_linkaddr, new_addr);
} else {
linkaddr_copy(&orchestra_parent_linkaddr, &linkaddr_null);
}
remove_uc_link(new_addr);
remove_uc_link(old_addr);
add_uc_link(new_addr);
}
}