From 3808863e0db1238f4304763466598214a6e791fa Mon Sep 17 00:00:00 2001 From: Martin Lenders Date: Fri, 7 Feb 2014 01:08:57 +0100 Subject: [PATCH] Make applications work with #644 --- sixlowpan/Makefile | 4 ++- sixlowpan/main.c | 60 +++++++++++++++------------------------- tlayer/Makefile | 4 ++- tlayer/main.c | 2 +- tlayer/tlayer_shell.c | 64 ++++++++++++++++++------------------------- 5 files changed, 55 insertions(+), 79 deletions(-) diff --git a/sixlowpan/Makefile b/sixlowpan/Makefile index c719c48..72cbf01 100644 --- a/sixlowpan/Makefile +++ b/sixlowpan/Makefile @@ -10,6 +10,8 @@ # name of your project export PROJECT = sixlowpan +QUIET?=1 + # for easy switching of boards ifeq ($(strip $(BOARD)),) export BOARD = native @@ -44,7 +46,7 @@ else ifeq ($(BOARD),native) USEMODULE += nativenet endif -export INCLUDES = -I$(RIOTBOARD)/$(BOARD)/include -I$(RIOTBASE)/core/include -I$(RIOTCPU)/$(CPU)/include -I$(RIOTBASE)/sys/lib -I$(RIOTBASE)/sys/include/ -I$(RIOTBASE)/drivers/include/ -I$(RIOTBASE)/drivers/cc110x_ng/include/ -I$(RIOTBASE)/sys/net/include/ +export INCLUDES = -I$(RIOTBASE)/sys/net/include/ include $(RIOTBASE)/Makefile.include endif diff --git a/sixlowpan/main.c b/sixlowpan/main.c index be2a9ea..d1e4412 100644 --- a/sixlowpan/main.c +++ b/sixlowpan/main.c @@ -13,12 +13,19 @@ #include "vtimer.h" #include "ltc4150.h" #include "thread.h" +#ifdef MODULE_NATIVENET +#include "nativenet.h" +#elif MODULE_CC110X_NG #include "cc110x_ng.h" +#endif #include "transceiver.h" #include "time.h" #include "rtc.h" +#include "net_if.h" #include "ipv6.h" #include "sixlowpan.h" +#include "inet_ntop.h" +#include "destiny/socket.h" #ifdef MODULE_NATIVENET #define TRANSCEIVER_TYPE TRANSCEIVER_NATIVE @@ -26,10 +33,10 @@ #define TRANSCEIVER_TYPE TRANSCEIVER_CC1100 #endif -void print_ipv6_addr(const ipv6_addr_t *ipv6_addr) +void print_ipv6_addr(ipv6_addr_t *addr) { char addr_str[IPV6_MAX_ADDR_STR_LEN]; - printf("%s\n", ipv6_addr_to_str(addr_str, ipv6_addr)); + printf("%s\n", ipv6_addr_to_str(addr_str, IPV6_MAX_ADDR_STR_LEN, addr)); } void printUsage() @@ -46,7 +53,6 @@ void init(char *str) { uint16_t r_addr; ipv6_addr_t std_addr; - size_t str_len = strlen(str); char *command = strtok(str, " "); if ((command = strtok(NULL, " ")) == NULL) { @@ -63,50 +69,30 @@ void init(char *str) ipv6_addr_init(&std_addr, 0xABCD, 0, 0, 0, 0x1034, 0x00FF, 0xFE00, r_addr); + if (!net_if_set_hardware_address(0, r_addr)) { + printf("Error on setting hardware address %hu\n.", r_addr); + return; + } + switch (command[0]) { case 'h': printf("INFO: Initialize as host on radio address %hu\n", r_addr); - - if (r_addr > 255) { - printf("ERROR: radio_address not an 8 bit integer\n"); - return; - } - - sixlowpan_lowpan_init(TRANSCEIVER_TYPE, r_addr, 0); break; case 'r': printf("INFO: Initialize as router on radio address %hu\n", r_addr); - - if (r_addr > 255) { - printf("ERROR: radio_address not an 8 bit integer\n"); - return; - } - - sixlowpan_lowpan_init(TRANSCEIVER_TYPE, r_addr, 0); - ipv6_init_iface_as_router(); + ipv6_init_as_router(); break; case 'a': printf("INFO: Initialize as adhoc router on radio address %hu\n", r_addr); - - if (r_addr > 255) { - printf("ERROR: radio_address not an 8 bit integer\n"); - return; - } - - sixlowpan_lowpan_adhoc_init(TRANSCEIVER_TYPE, &std_addr, r_addr); + sixlowpan_lowpan_init_adhoc_interface(0, &std_addr); break; +#ifdef MODULE_SIXLOWBORDER case 'b': printf("INFO: Initialize as border router on radio address %hu\n", r_addr); - - if (r_addr > 255) { - printf("ERROR: radio_address not an 8 bit integer\n"); - return; - } - - int res = sixlowpan_lowpan_border_init(TRANSCEIVER_TYPE, &std_addr); + int res = sixlowpan_lowpan_border_init(0); switch (res) { case (SIXLOWERROR_SUCCESS): @@ -122,6 +108,7 @@ void init(char *str) printf("ERROR: Unknown error (%d).\n", res); break; } +#endif break; @@ -134,12 +121,14 @@ void init(char *str) void bootstrapping(char *str) { + (void)str; sixlowpan_lowpan_bootstrapping(); } void send_packet(char *str) { uint8_t test[2]; + (void)str; test[0] = 30; test[1] = 98; @@ -158,13 +147,9 @@ void send_packet(char *str) } } -void ip(char *str) -{ - ipv6_iface_print_addrs(); -} - void context(char *str) { + (void)str; uint8_t i; lowpan_context_t *context; @@ -182,7 +167,6 @@ const shell_command_t shell_commands[] = { {"send", "", send_packet}, {"init", "", init}, {"boot", "", bootstrapping}, - {"ip", "", ip}, {"context", "", context}, {NULL, NULL, NULL} }; diff --git a/tlayer/Makefile b/tlayer/Makefile index e2d6ea0..838ab9c 100644 --- a/tlayer/Makefile +++ b/tlayer/Makefile @@ -10,6 +10,8 @@ # name of your project export PROJECT = tlayer +QUIET?=1 + # for easy switching of boards ifeq ($(strip $(BOARD)),) export BOARD = native @@ -45,7 +47,7 @@ USEMODULE += uart0 USEMODULE += posix USEMODULE += ltc4150 -export INCLUDES += -I$(RIOTBASE)/sys/include -I$(RIOTBASE)/drivers/include -I$(RIOTBASE)/drivers/cc110x_ng/include -I$(RIOTBASE)/sys/net/include -I$(RIOTBASE)/sys/net/transport_layer/destiny +export INCLUDES += -I$(RIOTBASE)/sys/net/include -I$(RIOTBASE)/sys/net/transport_layer/destiny include $(RIOTBASE)/Makefile.include endif diff --git a/tlayer/main.c b/tlayer/main.c index 8b26a85..6fd9c84 100644 --- a/tlayer/main.c +++ b/tlayer/main.c @@ -15,6 +15,7 @@ static transceiver_command_t tcmd; void init_tl(char *str) { + (void)str; destiny_init_transport_layer(); } @@ -40,7 +41,6 @@ void ignore(char *addr) const shell_command_t shell_commands[] = { {"init", "initializes node", init}, {"boot", "performs 6lowpan bootstrapping", bootstrapping}, - {"ip", "shows current IPv6 addresses", ip}, {"shows", "Show Sockets", shows}, {"context", "shows 6lowpan context information", context}, {"init_udp_server_thread", "initializes UDP server", init_udp_server_thread}, diff --git a/tlayer/tlayer_shell.c b/tlayer/tlayer_shell.c index d59943e..76d4b53 100644 --- a/tlayer/tlayer_shell.c +++ b/tlayer/tlayer_shell.c @@ -9,6 +9,7 @@ #include "sixlowpan.h" #include "ipv6.h" +#include "net_if.h" #include "sixlowpan/ndp.h" #include "destiny/socket.h" @@ -36,7 +37,8 @@ char udp_server_stack_buffer[UDP_APP_STACK_SIZE]; void print_ipv6_addr(const ipv6_addr_t *ipv6_addr) { char addr_str[IPV6_MAX_ADDR_STR_LEN]; - printf("%s\n", ipv6_addr_to_str(addr_str, ipv6_addr)); + printf("%s\n", ipv6_addr_to_str(addr_str, IPV6_MAX_ADDR_STR_LEN, + ipv6_addr)); } /* initializes node */ @@ -60,50 +62,29 @@ void init(char *str) ipv6_addr_init(&std_addr, 0xABCD, 0xEF12, 0, 0, 0x1034, 0x00FF, 0xFE00, r_addr); + if (!net_if_set_hardware_address(0, r_addr)) { + printf("Error on setting hardware address %hu\n.", r_addr); + return; + } + switch(command) { case 'h': printf("INFO: Initialize as host on radio address %hu\n", r_addr); - - if(r_addr > 255) { - printf("ERROR: radio_address not an 8 bit integer\n"); - return; - } - - sixlowpan_lowpan_init(TRANSCEIVER, r_addr, 0); break; case 'r': printf("INFO: Initialize as router on radio address %hu\n", r_addr); - - if(r_addr > 255) { - printf("ERROR: radio_address not an 8 bit integer\n"); - return; - } - - sixlowpan_lowpan_init(TRANSCEIVER, r_addr, 0); - ipv6_init_iface_as_router(); + ipv6_init_as_router(); break; case 'a': printf("INFO: Initialize as adhoc router on radio address %hu\n", r_addr); - - if(r_addr > 255) { - printf("ERROR: radio_address not an 8 bit integer\n"); - return; - } - - sixlowpan_lowpan_adhoc_init(TRANSCEIVER, &std_addr, r_addr); + sixlowpan_lowpan_init_adhoc_interface(0, &std_addr); break; case 'b': printf("INFO: Initialize as border router on radio address %hu\n", r_addr); - - if(r_addr > 255) { - printf("ERROR: radio_address not an 8 bit integer\n"); - return; - } - - res = sixlowpan_lowpan_border_init(TRANSCEIVER, &std_addr); + res = sixlowpan_lowpan_border_init(0); switch(res) { case(SIXLOWERROR_SUCCESS): @@ -138,11 +119,13 @@ void init(char *str) /* performs 6lowpan bootstrapping */ void bootstrapping(char *str) { + (void) str; sixlowpan_lowpan_bootstrapping(); } void boot_server(char *str) { + (void) str; bootstrapping(NULL); vtimer_usleep(1000 * 1000 * 2); init_tcp_server_thread(NULL); @@ -150,22 +133,18 @@ void boot_server(char *str) void boot_client(char *str) { + (void) str; init_tcp_cht(NULL); vtimer_usleep(1000 * 1000 * 2); connect_tcp("connect_tcp 2"); } -/* prints current IPv6 adresses */ -void ip(char *str) -{ - ipv6_iface_print_addrs(); -} - /* shows 6lowpan context information */ void context(char *str) { uint8_t i; lowpan_context_t *context; + (void) str; for(i = 0; i < NDP_6LOWPAN_CONTEXT_MAX; i++) { context = lowpan_context_num_lookup(i); @@ -180,6 +159,7 @@ void context(char *str) /* shows info about open sockets */ void shows(char *str) { + (void) str; destiny_socket_print_sockets(); } @@ -187,11 +167,13 @@ void shows(char *str) #if ENABLE_DEBUG void showReas(char *str) { + (void) str; sixlowpan_lowpan_print_reassembly_buffers(); } void pfifo_buf(char *str) { + (void) str; sixlowpan_lowpan_print_fifo_buffers(); } #endif @@ -210,6 +192,7 @@ void kill_process(char *str) /* Init TCP server thread */ void init_tcp_server_thread(char *str) { + (void) str; tcp_server_thread_pid = thread_create(tcp_server_stack_buffer, TCP_APP_STACK_SIZE, PRIORITY_MAIN, CREATE_STACKTEST, init_tcp_server, "init_tcp_server"); printf("TCP SERVER THREAD PID: %i\n", tcp_server_thread_pid); } @@ -217,6 +200,7 @@ void init_tcp_server_thread(char *str) /* Init TCP connection handler thread */ void init_tcp_cht(char *str) { + (void) str; tcp_cht_pid = thread_create(tcp_cht_stack_buffer, TCP_APP_STACK_SIZE, PRIORITY_MAIN, @@ -280,7 +264,7 @@ void send_tcp_bandwidth_test(char *str) total = timex_sub(end, start); secs = total.microseconds / 1000000.0f; printf("Used power: %f\n", ltc4150_get_total_Joule()); - printf("Start: %lu, End: %lu, Total: %lu\n", start.microseconds, end.microseconds, total.microseconds); + printf("Start: %" PRIu32 ", End: %" PRIu32 ", Total: %" PRIu32 "\n", start.microseconds, end.microseconds, total.microseconds); printf("Time: %f seconds, Bandwidth: %f byte/second\n", secs, (count * 48) / secs); } @@ -297,6 +281,7 @@ void connect_tcp(char *str) void disconnect_tcp(char *str) { msg_t send_msg; + (void) str; send_msg.content.value = 0; msg_send(&send_msg, tcp_cht_pid, 0); @@ -305,6 +290,7 @@ void disconnect_tcp(char *str) /* UDP server thread */ void init_udp_server_thread(char *str) { + (void)str; udp_server_thread_pid = thread_create(udp_server_stack_buffer, UDP_APP_STACK_SIZE, PRIORITY_MAIN, CREATE_STACKTEST, init_udp_server, "init_udp_server"); printf("UDP SERVER THREAD PID: %i\n", udp_server_thread_pid); } @@ -357,7 +343,8 @@ void send_udp(char *str) total = timex_sub(end, start); secs = total.microseconds / 1000000; printf("Used power: %f\n", ltc4150_get_total_Joule()); - printf("Start: %lu, End: %lu, Total: %lu\n", start.microseconds, end.microseconds, total.microseconds); + printf("Start: %" PRIu32 ", End: %" PRIu32 ", Total: %" PRIu32 "\n", + start.microseconds, end.microseconds, total.microseconds); secs = total.microseconds / 1000000; if (!secs) { puts("Transmission in no time!"); @@ -370,6 +357,7 @@ void send_udp(char *str) void close_tcp(char *str) { + (void)str; thread_create(tcp_close_thread_stack, TCP_CLOSE_THREAD_STACK_SIZE, PRIORITY_MAIN, CREATE_STACKTEST, close_tcp_thread, "tcp_close_thread"); }