Skip to content

Commit 5a37354

Browse files
author
Juha Heiskanen
committed
Primary Parent Update Hook to Wi-sun for synch broadcast schedule.
Change-Id: I804200fda6cf47beb0180cd37f2b97ffe8917d58
1 parent 98b0e23 commit 5a37354

File tree

5 files changed

+30
-5
lines changed

5 files changed

+30
-5
lines changed

source/6LoWPAN/Bootstraps/Generic/protocol_6lowpan.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
#include "6LoWPAN/Fragmentation/cipv6_fragmenter.h"
7575
#include "Service_Libs/etx/etx.h"
7676
#include "Service_Libs/mac_neighbor_table/mac_neighbor_table.h"
77+
#include "6LoWPAN/ws/ws_bootstrap.h"
7778

7879

7980
#define TRACE_GROUP_LOWPAN "6lo"
@@ -473,7 +474,6 @@ void protocol_6lowpan_neighbor_priority_update(protocol_interface_info_entry_t *
473474
}
474475

475476
#ifdef HAVE_RPL
476-
#ifndef NO_MLE
477477

478478
uint16_t protocol_6lowpan_neighbor_priority_set(int8_t interface_id, addrtype_t addr_type, const uint8_t *addr_ptr)
479479
{
@@ -486,9 +486,12 @@ uint16_t protocol_6lowpan_neighbor_priority_set(int8_t interface_id, addrtype_t
486486
mac_neighbor_table_entry_t * entry = mac_neighbor_table_address_discover(mac_neighbor_info(cur), addr_ptr + PAN_ID_LEN, addr_type);
487487

488488
if (entry) {
489+
490+
bool new_primary = false;
489491
etx_storage_t *etx_entry = etx_storage_entry_get(interface_id, entry->index);
490492
// If primary parent has changed clears priority from previous parent
491493
if (entry->link_role != PRIORITY_PARENT_NEIGHBOUR) {
494+
new_primary = true;
492495
protocol_6lowpan_neighbor_priority_clear_all(interface_id, PRIORITY_1ST);
493496
}
494497
entry->link_role = PRIORITY_PARENT_NEIGHBOUR;
@@ -501,6 +504,10 @@ uint16_t protocol_6lowpan_neighbor_priority_set(int8_t interface_id, addrtype_t
501504
if (etx_entry) {
502505
protocol_stats_update(STATS_ETX_1ST_PARENT, etx_entry->etx >> 4);
503506
}
507+
508+
if (new_primary) {
509+
ws_primary_parent_update(cur, entry);
510+
}
504511
return 1;
505512
} else {
506513
return 0;
@@ -557,7 +564,6 @@ void protocol_6lowpan_neighbor_priority_clear_all(int8_t interface_id, neighbor_
557564
}
558565
}
559566

560-
#endif
561567
#endif
562568

563569
#endif

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,6 @@ static void ws_bootstrap_primary_parent_set(struct protocol_interface_info_entry
342342
// Update LLC to follow updated fhss settings
343343
ws_bootstrap_llc_hopping_update(cur,&fhss_configuration);
344344

345-
// set neighbor as priority parent clear if there is others
346-
protocol_6lowpan_neighbor_priority_clear_all(cur->id, PRIORITY_1ST);
347-
neighbor_info->neighbor->link_role = PRIORITY_PARENT_NEIGHBOUR;
348345

349346
}
350347
/* \return 0x0100 to 0xFFFF ETX value (8 bit fraction)
@@ -765,6 +762,9 @@ static void ws_bootstrap_pan_config_analyse(struct protocol_interface_info_entry
765762
cur->bootsrap_state_machine_cnt = randLIB_get_random_in_range(10 ,20);
766763
// enable frequency hopping for unicast channel and start listening first neighbour
767764
ws_bootstrap_primary_parent_set(cur, &neighbor_info);
765+
// set neighbor as priority parent clear if there is others
766+
protocol_6lowpan_neighbor_priority_clear_all(cur->id, PRIORITY_1ST);
767+
neighbor_info.neighbor->link_role = PRIORITY_PARENT_NEIGHBOUR;
768768
} else if (neighbor_info.neighbor->link_role == PRIORITY_PARENT_NEIGHBOUR) {
769769
// RPL priority parent configuration we must update FHSS data
770770
ws_bootstrap_primary_parent_set(cur, &neighbor_info);
@@ -1858,4 +1858,14 @@ void ws_bootstrap_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t s
18581858
}
18591859
}
18601860

1861+
void ws_primary_parent_update(protocol_interface_info_entry_t *interface, mac_neighbor_table_entry_t *neighbor)
1862+
{
1863+
if (interface->ws_info) {
1864+
llc_neighbour_req_t neighbor_info;
1865+
neighbor_info.neighbor = neighbor;
1866+
neighbor_info.ws_neighbor = ws_neighbor_class_entry_get(&interface->ws_info->neighbor_storage, neighbor->index);
1867+
ws_bootstrap_primary_parent_set(interface, &neighbor_info);
1868+
}
1869+
}
1870+
18611871
#endif //HAVE_WS

source/6LoWPAN/ws/ws_bootstrap.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,14 @@ void ws_bootstrap_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t s
5454

5555
void ws_bootstrap_trickle_timer(protocol_interface_info_entry_t *cur, uint16_t ticks);
5656

57+
void ws_primary_parent_update(protocol_interface_info_entry_t *interface, mac_neighbor_table_entry_t *neighbor);
58+
5759
#else
5860

5961
#define ws_bootstrap_init(interface_id, bootstrap_mode) (-1)
6062
#define ws_bootstrap_state_machine(cur)
6163
#define ws_bootstrap_restart(cur)
64+
#define ws_primary_parent_update(interface, neighbor)
6265

6366
#endif //HAVE_WS
6467

test/nanostack/unittest/Bootstraps/protocol_6lowpan/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ TEST_SRC_FILES = \
4141
../../stub/adaptation_interface_stub.c \
4242
../../stub/security_lib_stub.c \
4343
../../stub/net_load_balance_stub.c \
44+
../../stub/ws_bootstrap_stub.c \
4445
../../stub/etx_stub.c \
4546

4647
include ../../MakefileWorker.mk

test/nanostack/unittest/stub/ws_bootstrap_stub.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,8 @@ void ws_bootstrap_configuration_trickle_reset(protocol_interface_info_entry_t *c
5151
{
5252

5353
}
54+
55+
void ws_primary_parent_update(protocol_interface_info_entry_t *interface, mac_neighbor_table_entry_t *neighbor)
56+
{
57+
58+
}

0 commit comments

Comments
 (0)