Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make applications work with #644 #95

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion sixlowpan/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
# name of your project
export PROJECT = sixlowpan

QUIET?=1

# for easy switching of boards
ifeq ($(strip $(BOARD)),)
export BOARD = native
Expand Down Expand Up @@ -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
60 changes: 22 additions & 38 deletions sixlowpan/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,30 @@
#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
#else
#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()
Expand All @@ -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) {
Expand All @@ -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):
Expand All @@ -122,6 +108,7 @@ void init(char *str)
printf("ERROR: Unknown error (%d).\n", res);
break;
}
#endif

break;

Expand All @@ -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;

Expand All @@ -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;

Expand All @@ -182,7 +167,6 @@ const shell_command_t shell_commands[] = {
{"send", "", send_packet},
{"init", "", init},
{"boot", "", bootstrapping},
{"ip", "", ip},
{"context", "", context},
{NULL, NULL, NULL}
};
Expand Down
4 changes: 3 additions & 1 deletion tlayer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
# name of your project
export PROJECT = tlayer

QUIET?=1

# for easy switching of boards
ifeq ($(strip $(BOARD)),)
export BOARD = native
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion tlayer/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ static transceiver_command_t tcmd;

void init_tl(char *str)
{
(void)str;
destiny_init_transport_layer();
}

Expand All @@ -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},
Expand Down
64 changes: 26 additions & 38 deletions tlayer/tlayer_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include "sixlowpan.h"
#include "ipv6.h"
#include "net_if.h"
#include "sixlowpan/ndp.h"

#include "destiny/socket.h"
Expand Down Expand Up @@ -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 */
Expand All @@ -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):
Expand Down Expand Up @@ -138,34 +119,32 @@ 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);
}

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);
Expand All @@ -180,18 +159,21 @@ void context(char *str)
/* shows info about open sockets */
void shows(char *str)
{
(void) str;
destiny_socket_print_sockets();
}

/* shows reassembling buffer */
#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
Expand All @@ -210,13 +192,15 @@ 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);
}

/* 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,
Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
Expand All @@ -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);
}
Expand Down Expand Up @@ -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!");
Expand All @@ -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");
}