Merge pull request #1672 from simonduq/pr/orchestra-fixes
Various Orchestra fixes
This commit is contained in:
commit
a7ce256309
|
@ -74,8 +74,8 @@ select_packet(uint16_t *slotframe, uint16_t *timeslot)
|
||||||
static void
|
static void
|
||||||
new_time_source(const struct tsch_neighbor *old, const struct tsch_neighbor *new)
|
new_time_source(const struct tsch_neighbor *old, const struct tsch_neighbor *new)
|
||||||
{
|
{
|
||||||
uint16_t old_ts = get_node_timeslot(&old->addr);
|
uint16_t old_ts = old != NULL ? get_node_timeslot(&old->addr) : 0xffff;
|
||||||
uint16_t new_ts = get_node_timeslot(&new->addr);
|
uint16_t new_ts = new != NULL ? get_node_timeslot(&new->addr) : 0xffff;
|
||||||
|
|
||||||
if(new_ts == old_ts) {
|
if(new_ts == old_ts) {
|
||||||
return;
|
return;
|
||||||
|
@ -83,14 +83,24 @@ new_time_source(const struct tsch_neighbor *old, const struct tsch_neighbor *new
|
||||||
|
|
||||||
if(old_ts != 0xffff) {
|
if(old_ts != 0xffff) {
|
||||||
/* Stop listening to the old time source's EBs */
|
/* Stop listening to the old time source's EBs */
|
||||||
tsch_schedule_remove_link_by_timeslot(sf_eb, old_ts);
|
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) {
|
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 */
|
/* Listen to the time source's EBs */
|
||||||
tsch_schedule_add_link(sf_eb,
|
tsch_schedule_add_link(sf_eb, link_options, LINK_TYPE_ADVERTISING_ONLY,
|
||||||
LINK_OPTION_RX,
|
&tsch_broadcast_address, new_ts, 0);
|
||||||
LINK_TYPE_ADVERTISING_ONLY, NULL,
|
|
||||||
new_ts, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -85,10 +85,16 @@ add_uc_link(const linkaddr_t *linkaddr)
|
||||||
{
|
{
|
||||||
if(linkaddr != NULL) {
|
if(linkaddr != NULL) {
|
||||||
uint16_t timeslot = get_node_timeslot(linkaddr);
|
uint16_t timeslot = get_node_timeslot(linkaddr);
|
||||||
tsch_schedule_add_link(sf_unicast,
|
uint8_t link_options = ORCHESTRA_UNICAST_SENDER_BASED ? LINK_OPTION_RX : LINK_OPTION_TX | UNICAST_SLOT_SHARED_FLAG;
|
||||||
ORCHESTRA_UNICAST_SENDER_BASED ? LINK_OPTION_RX : LINK_OPTION_TX | UNICAST_SLOT_SHARED_FLAG,
|
|
||||||
LINK_TYPE_NORMAL, &tsch_broadcast_address,
|
if(timeslot == get_node_timeslot(&linkaddr_node_addr)) {
|
||||||
timeslot, channel_offset);
|
/* 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);
|
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
|
static void
|
||||||
|
@ -160,13 +176,14 @@ static void
|
||||||
new_time_source(const struct tsch_neighbor *old, const struct tsch_neighbor *new)
|
new_time_source(const struct tsch_neighbor *old, const struct tsch_neighbor *new)
|
||||||
{
|
{
|
||||||
if(new != old) {
|
if(new != old) {
|
||||||
|
const linkaddr_t *old_addr = old != NULL ? &old->addr : NULL;
|
||||||
const linkaddr_t *new_addr = new != NULL ? &new->addr : NULL;
|
const linkaddr_t *new_addr = new != NULL ? &new->addr : NULL;
|
||||||
if(new_addr != NULL) {
|
if(new_addr != NULL) {
|
||||||
linkaddr_copy(&orchestra_parent_linkaddr, new_addr);
|
linkaddr_copy(&orchestra_parent_linkaddr, new_addr);
|
||||||
} else {
|
} else {
|
||||||
linkaddr_copy(&orchestra_parent_linkaddr, &linkaddr_null);
|
linkaddr_copy(&orchestra_parent_linkaddr, &linkaddr_null);
|
||||||
}
|
}
|
||||||
remove_uc_link(new_addr);
|
remove_uc_link(old_addr);
|
||||||
add_uc_link(new_addr);
|
add_uc_link(new_addr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue