1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

Merge pull request #1903 from authmillenon/rpl_udp_non_routing

rpl_udp: add non-routing hosts to example
This commit is contained in:
Oleg Hahm 2014-10-30 23:38:59 +01:00
commit 8c44eaa6f8

View File

@ -47,15 +47,18 @@ void rpl_udp_init(int argc, char **argv)
uint8_t chan = RADIO_CHANNEL;
if (argc != 2) {
printf("Usage: %s (r|n)\n", argv[0]);
printf("Usage: %s (r|n|h)\n", argv[0]);
printf("\tr\tinitialize as root\n");
printf("\tn\tinitialize as node router\n");
printf("\th\tinitialize as non-routing node (host-mode)\n");
return;
}
char command = argv[1][0];
if ((command == 'n') || (command == 'r')) {
printf("INFO: Initialize as %s on address %d\n", ((command == 'n') ? "node" : "root"), id);
if ((command == 'n') || (command == 'r') || (command == 'h')) {
printf("INFO: Initialize as %srouting %s on address %d\n",
((command == 'h') ? "non-" : ""),
(((command == 'n') || (command == 'h')) ? "node" : "root"), id);
if (!id || (id > 255)) {
printf("ERROR: address not a valid 8 bit integer\n");
@ -65,6 +68,7 @@ void rpl_udp_init(int argc, char **argv)
DEBUGF("Setting HW address to %u\n", id);
net_if_set_hardware_address(0, id);
if (command != 'h') {
DEBUGF("Initializing RPL for interface 0\n");
uint8_t state = rpl_init(0);
@ -77,11 +81,16 @@ void rpl_udp_init(int argc, char **argv)
if (command == 'r') {
rpl_init_root();
ipv6_iface_set_routing_provider(rpl_get_next_hop);
is_root = 1;
}
else {
ipv6_iface_set_routing_provider(rpl_get_next_hop);
}
}
else {
puts("6LoWPAN initialized.");
}
DEBUGF("Start monitor\n");
kernel_pid_t monitor_pid = thread_create(monitor_stack_buffer,
@ -109,7 +118,9 @@ void rpl_udp_init(int argc, char **argv)
ipv6_addr_set_by_eui64(&tmp, 0, &tmp);
ipv6_net_if_add_addr(0, &tmp, NDP_ADDR_STATE_PREFERRED, 0, 0, 0);
if (command != 'h') {
ipv6_init_as_router();
}
/* set channel to 10 */
tcmd.transceivers = TRANSCEIVER;