Nanostack Border Router is a generic mbed border router implementation that provides the 6LoWPAN ND or Thread border router initialization logic.

Revision:
37:465118eec099
Parent:
13:993808eb2e9c
Child:
61:b80d169da384
--- a/source/borderrouter_tasklet.c	Fri Oct 06 03:00:48 2017 +0100
+++ b/source/borderrouter_tasklet.c	Mon Oct 09 10:45:42 2017 +0100
@@ -117,11 +117,12 @@
 
 void border_router_tasklet_start(void)
 {
-    load_config();
     net_init_core();
     /* initialize Radio module*/
     net_6lowpan_id = rf_interface_init();
 
+    load_config();
+
     protocol_stats_start(&nwk_stats);
 
     eventOS_event_handler_create(
@@ -211,9 +212,14 @@
 
     /* generate DODAG ID */
     memcpy(rpl_setup_info.DODAG_ID, nd_prefix, 8);
-    memcpy(&rpl_setup_info.DODAG_ID[8], gp16_address_suffix, 6);
-    rpl_setup_info.DODAG_ID[14] = (br.mac_short_adr >> 8);
-    rpl_setup_info.DODAG_ID[15] = br.mac_short_adr;
+    if (br.mac_short_adr < 0xfffe) {
+        memcpy(&rpl_setup_info.DODAG_ID[8], gp16_address_suffix, 6);
+        rpl_setup_info.DODAG_ID[14] = (br.mac_short_adr >> 8);
+        rpl_setup_info.DODAG_ID[15] = br.mac_short_adr;
+    } else {
+        rf_read_mac_address(&rpl_setup_info.DODAG_ID[8]);
+        rpl_setup_info.DODAG_ID[8] ^= 2;
+    }
 
     /* DODAG configuration */
     dodag_config.DAG_DIO_INT_DOUB = cfg_int(global_config, "RPL_IDOUBLINGS", 12);