diff --git a/examples/mesh4all_rpl_dag/Kconfig b/examples/mesh4all_rpl_dag/Kconfig deleted file mode 100644 index ee7d58367..000000000 --- a/examples/mesh4all_rpl_dag/Kconfig +++ /dev/null @@ -1,7 +0,0 @@ -menu "RPL settings" -#comment "RPL settings" - config IS_DODAG - bool "dodag node" - default n - -endmenu #RPL diff --git a/examples/mesh4all_rpl_dag/Makefile b/examples/rpl_dag/Makefile similarity index 54% rename from examples/mesh4all_rpl_dag/Makefile rename to examples/rpl_dag/Makefile index 1743cba95..74e137cf2 100644 --- a/examples/mesh4all_rpl_dag/Makefile +++ b/examples/rpl_dag/Makefile @@ -18,5 +18,21 @@ USEMODULE += rpl_protocol USEMODULE += gnrc_icmpv6_echo # Use UART_DEV(1) for slipdev as a default, baudrate by default is 115200 +# Instead of simulating an Ethernet connection, we can also simulate +# an IEEE 802.15.4 radio using ZEP +# set the ZEP port for native +ZEP_PORT_BASE ?= 17754 + +ifneq (,$(filter native,$(BOARD))) + USE_ZEP ?= 1 + ifeq (1,$(USE_ZEP)) + TERMFLAGS += -z [::1]:$(ZEP_PORT_BASE) + USEMODULE += socket_zep + + ifneq (,$(ZEP_MAC)) + TERMFLAGS += --eui64=$(ZEP_MAC) + endif + endif +endif include $(RIOTBASE)/Makefile.include diff --git a/examples/mesh4all_rpl_dag/README.md b/examples/rpl_dag/README.md similarity index 100% rename from examples/mesh4all_rpl_dag/README.md rename to examples/rpl_dag/README.md diff --git a/examples/mesh4all_rpl_dag/doc.txt b/examples/rpl_dag/doc.txt similarity index 100% rename from examples/mesh4all_rpl_dag/doc.txt rename to examples/rpl_dag/doc.txt diff --git a/examples/mesh4all_rpl_dag/main.c b/examples/rpl_dag/main.c similarity index 88% rename from examples/mesh4all_rpl_dag/main.c rename to examples/rpl_dag/main.c index 66590aec0..5ebe8a388 100644 --- a/examples/mesh4all_rpl_dag/main.c +++ b/examples/rpl_dag/main.c @@ -24,6 +24,7 @@ #include #include +#include "msg.h" #include "shell.h" #include "log.h" @@ -32,7 +33,6 @@ #define MAIN_QUEUE_SIZE (8) msg_t _main_msg_queue[MAIN_QUEUE_SIZE]; -shell_command_t shell_extended_commands[] = {{NULL, NULL, NULL}}; int main(void) { LOG_INFO("~~ Welcome to rpl exam ~~\n"); @@ -42,7 +42,7 @@ int main(void) { rpl_setup(DAG); - shell_run(shell_extended_commands, line_buf, SHELL_DEFAULT_BUFSIZE); + shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE); return 0; } diff --git a/examples/mesh4all_rpl_dodag/Kconfig b/examples/rpl_dodag/Kconfig similarity index 66% rename from examples/mesh4all_rpl_dodag/Kconfig rename to examples/rpl_dodag/Kconfig index 2eb41b752..ae32c8b3e 100644 --- a/examples/mesh4all_rpl_dodag/Kconfig +++ b/examples/rpl_dodag/Kconfig @@ -8,4 +8,8 @@ menu "RPL settings" int "Default DODAG instance" default 1 + config DODAG_IPV6_ADDRESS + string "Wireless Address of DODAG" + default "2001:db8::1" + endmenu #RPL diff --git a/examples/mesh4all_rpl_dodag/Makefile b/examples/rpl_dodag/Makefile similarity index 50% rename from examples/mesh4all_rpl_dodag/Makefile rename to examples/rpl_dodag/Makefile index afa116519..3c86288ed 100644 --- a/examples/mesh4all_rpl_dodag/Makefile +++ b/examples/rpl_dodag/Makefile @@ -3,10 +3,10 @@ APPLICATION = mesh4all-rpl-dodag # If We need custom actions, routines, etc **SHOULD BE** included in the "core" folder # and "MUST BE" code hardware independent # EXTERNAL_MODULE_DIRS += $(CURDIR)/../core - DEVHELP ?= 1 include ../Makefile.common + # Modules USEMODULE += saul_default USEMODULE += shell @@ -16,7 +16,24 @@ USEMODULE += ps USEMODULE += rpl_protocol USEMODULE += radio USEMODULE += gnrc_icmpv6_echo -USEMODULE += at_client +# Instead of simulating an Ethernet connection, we can also simulate +# an IEEE 802.15.4 radio using ZEP +# set the ZEP port for native +ZEP_PORT_BASE ?= 17754 +ifneq (,$(filter native,$(BOARD))) + USE_ZEP ?= 1 + ifeq (1,$(USE_ZEP)) + TERMFLAGS += -z [::1]:$(ZEP_PORT_BASE) + USEMODULE += socket_zep + + ifneq (,$(ZEP_MAC)) + TERMFLAGS += --eui64=$(ZEP_MAC) + endif + endif +endif include $(RIOTBASE)/Makefile.include + +# Set a custom channel if needed +include $(RIOTMAKE)/default-radio-settings.inc.mk diff --git a/examples/mesh4all_rpl_dodag/README.md b/examples/rpl_dodag/README.md similarity index 100% rename from examples/mesh4all_rpl_dodag/README.md rename to examples/rpl_dodag/README.md diff --git a/examples/mesh4all_rpl_dodag/main.c b/examples/rpl_dodag/main.c similarity index 69% rename from examples/mesh4all_rpl_dodag/main.c rename to examples/rpl_dodag/main.c index 0a1e6ffe0..842b86bcc 100644 --- a/examples/mesh4all_rpl_dodag/main.c +++ b/examples/rpl_dodag/main.c @@ -26,23 +26,32 @@ #include "shell.h" #include "log.h" - #include "rpl_protocol.h" +#include "net_tools.h" #define MAIN_QUEUE_SIZE (8) +#ifndef CONFIG_DODAG_IPV6_ADDRESS +#define CONFIG_DODAG_IPV6_ADDRESS "2001:db8::1" +#endif msg_t _main_msg_queue[MAIN_QUEUE_SIZE]; -shell_command_t shell_extended_commands[] = {{NULL, NULL, NULL}}; int main(void) { LOG_INFO("~~ Welcome to rpl exam ~~\n"); /* Start shell */ char line_buf[SHELL_DEFAULT_BUFSIZE]; msg_init_queue(_main_msg_queue, MAIN_QUEUE_SIZE); - + ipv6_addr_t addr; + ipv6_addr_from_str(&addr, CONFIG_DODAG_IPV6_ADDRESS); +#ifdef BOARD_NATIVE + gnrc_netif_t *iface = gnrc_netif_get_by_type(NETDEV_SOCKET_ZEP, NETDEV_INDEX_ANY); + int8_t iface_idx = iface->pid; +#else + int8_t iface_idx = get_ieee802154_iface(); +#endif + set_ipv6_global(iface_idx, addr, 64); rpl_setup(DODAG); - - shell_run(shell_extended_commands, line_buf, SHELL_DEFAULT_BUFSIZE); + shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE); return 0; } diff --git a/firmware/network/rpl_protocol/Makefile.dep b/firmware/network/rpl_protocol/Makefile.dep index 3e3ea8d06..eab79cde1 100644 --- a/firmware/network/rpl_protocol/Makefile.dep +++ b/firmware/network/rpl_protocol/Makefile.dep @@ -5,10 +5,6 @@ USEMODULE += uniqueid USEMODULE += gnrc_ipv6_router_default USEMODULE += net_tools -ifeq (,$(filter auto_init_gnrc_rpl,$(USEMODULE))) - USEMODULE += auto_init_gnrc_rpl -endif - ifneq (,$(filter 6lpan_node,$(USEMODULE))) USEMODULE += gnrc_sixlowpan_router_default endif diff --git a/firmware/network/rpl_protocol/include/rpl_protocol.h b/firmware/network/rpl_protocol/include/rpl_protocol.h index bf04379cb..06c3500cb 100644 --- a/firmware/network/rpl_protocol/include/rpl_protocol.h +++ b/firmware/network/rpl_protocol/include/rpl_protocol.h @@ -27,6 +27,7 @@ #define RPL_PROTOCOL_H #include "net/ipv6/addr.h" +#include "sched.h" #ifdef __cplusplus extern "C" { diff --git a/firmware/network/rpl_protocol/rpl_protocol.c b/firmware/network/rpl_protocol/rpl_protocol.c index 26cda5482..844229caf 100644 --- a/firmware/network/rpl_protocol/rpl_protocol.c +++ b/firmware/network/rpl_protocol/rpl_protocol.c @@ -71,6 +71,7 @@ int8_t rpl_setup(uint8_t mode) { if (mode > 1) { printf("Error: Rpl mode not accepted\n"); } +#ifndef BOARD_NATIVE err = initial_radio_setup(); if (err != 0) { printf("Error: couldn't init the radio module .\n"); @@ -81,6 +82,9 @@ int8_t rpl_setup(uint8_t mode) { printf("Error: could not get the iface.\n"); return -1; } +#else + kernel_pid_t iface_index = get_wired_iface(); +#endif err = rpl_init(iface_index); if (err != 0) { printf("Error: couldn't init the RPL .\n");