diff --git a/sys/auto_init/auto_init.c b/sys/auto_init/auto_init.c index 5652f3ce7a..5b3b17b374 100644 --- a/sys/auto_init/auto_init.c +++ b/sys/auto_init/auto_init.c @@ -51,6 +51,10 @@ #include "rtc.h" #endif +#ifdef MODULE_SIXLOWPAN +#include "sixlowpan.h" +#endif + #ifdef MODULE_DESTINY #include "destiny.h" #endif @@ -63,6 +67,14 @@ #define ENABLE_DEBUG (0) #include "debug.h" +#ifndef CONF_RADIO_ADDR +#define CONF_RADIO_ADDR (1) +#endif + +#ifndef CONF_PAN_ID +#define CONF_PAN_ID (0xabcd) +#endif + extern int main(void); void auto_init(void) @@ -103,6 +115,7 @@ void auto_init(void) MCI_initialize(); #endif #ifdef MODULE_NET_IF + int iface; DEBUG("Auto init net_if module.\n"); transceiver_type_t transceivers = 0; #ifdef MODULE_AT86RF231 @@ -128,13 +141,32 @@ void auto_init(void) if (transceivers != 0) { transceiver_init(transceivers); transceiver_start(); - int iface = net_if_init_interface(0, transceivers); + iface = net_if_init_interface(0, transceivers); + + if (!net_if_get_hardware_address(iface)) { + DEBUG("Auto init radio address on interface %d to 0x%04x\n", iface, CONF_RADIO_ADDR); + DEBUG("Change this value at compile time with macro CONF_RADIO_ADDR\n"); + net_if_set_hardware_address(iface, CONF_RADIO_ADDR); + } + + if (net_if_get_pan_id(iface) <= 0) { + DEBUG("Auto init PAN ID on interface %d to 0x%04x\n", iface, CONF_PAN_ID); + DEBUG("Change this value at compile time with macro CONF_PAN_ID\n"); + net_if_set_pan_id(iface, CONF_PAN_ID); + } if (iface >= 0) { - DEBUG("Interface %d initialized\n", iface); + DEBUG("Auto init interface %d\n", iface); } } + else { + iface = -1; + } +#ifdef MODULE_SIXLOWPAN + DEBUG("Auto init 6LoWPAN module.\n"); + sixlowpan_lowpan_init(); +#endif #endif #ifdef MODULE_PROFILING extern void profiling_init(void); diff --git a/sys/net/network_layer/sixlowpan/border/border.c b/sys/net/network_layer/sixlowpan/border/border.c index f478a7505f..2433cf61b0 100644 --- a/sys/net/network_layer/sixlowpan/border/border.c +++ b/sys/net/network_layer/sixlowpan/border/border.c @@ -142,10 +142,6 @@ int sixlowpan_lowpan_border_init(int if_id) return 0; } - if (!sixlowpan_lowpan_init()) { - return 0; - } - if (!sixlowpan_lowpan_init_interface(if_id)) { return 0; } diff --git a/sys/net/routing/rpl/rpl.c b/sys/net/routing/rpl/rpl.c index eb1535ec8f..2d9b2701d0 100644 --- a/sys/net/routing/rpl/rpl.c +++ b/sys/net/routing/rpl/rpl.c @@ -209,10 +209,6 @@ uint8_t rpl_init(int if_id) objective_functions[0] = rpl_get_of0(); /* objective_functions[1] = rpl_get_of_ETX() */ - if (!sixlowpan_lowpan_init()) { - return 0; - } - sixlowpan_lowpan_init_interface(if_id); /* need link local prefix to query _our_ corresponding address */ ipv6_addr_t ll_address;