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

Plugtest hotfixes #4

Closed
Closed
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
28 changes: 23 additions & 5 deletions Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,26 @@ ifneq (,$(filter destiny,$(USEMODULE)))
endif
endif

ifneq (,$(filter sixlowborder,$(USEMODULE)))
ifeq (,$(filter sixlowpan,$(USEMODULE)))
USEMODULE += sixlowpan
endif
endif

ifneq (,$(filter sixlowpan,$(USEMODULE)))
ifeq (,$(filter ieee802154,$(USEMODULE)))
USEMODULE += ieee802154
endif
ifeq (,$(filter net_help,$(USEMODULE)))
USEMODULE += net_help
endif
ifeq (,$(filter semaphore,$(USEMODULE)))
USEMODULE += semaphore
ifeq (,$(filter net_if,$(USEMODULE)))
USEMODULE += net_if
endif
ifeq (,$(filter transceiver,$(USEMODULE)))
USEMODULE += transceiver
ifeq (,$(filter semaphore, $(USEMODULE)))
USEMODULE += semaphore
endif
ifeq (,$(filter vtimer,$(USEMODULE)))
ifeq (,$(filter vtimer, $(USEMODULE)))
USEMODULE += vtimer
endif
endif
Expand All @@ -102,3 +108,15 @@ ifneq (,$(filter vtimer,$(USEMODULE)))
USEMODULE += timex
endif
endif

ifneq (,$(findstring net_if,$(USEMODULE)))
ifeq (,$(findstring transceiver,$(USEMODULE)))
USEMODULE += transceiver
endif
endif

ifneq (,$(findstring shell_commands,$(USEMODULE)))
ifneq (,$(findstring net_if,$(USEMODULE)))
USEMODULE += net_help
endif
endif
2 changes: 2 additions & 0 deletions drivers/at86rf231/at86rf231.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
*/

#include "at86rf231.h"
#include "at86rf231_arch.h"
#include "at86rf231_spi.h"

#define ENABLE_DEBUG (0)
#include "debug.h"
Expand Down
1 change: 1 addition & 0 deletions drivers/at86rf231/at86rf231_rx.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

#include "at86rf231.h"
#include "at86rf231_arch.h"
#include "at86rf231_spi.h"

#include "transceiver.h"
#include "msg.h"
Expand Down
1 change: 1 addition & 0 deletions drivers/at86rf231/at86rf231_tx.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "at86rf231.h"
#include "at86rf231_arch.h"
#include "at86rf231_spi.h"

static void at86rf231_xmit(uint8_t *data, uint8_t length);
static void at86rf231_gen_pkt(uint8_t *buf, at86rf231_packet_t *packet);
Expand Down
1 change: 1 addition & 0 deletions drivers/at86rf231/include/at86rf231_arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ void at86rf231_switch_to_rx(void);
void at86rf231_spi_select(void);
void at86rf231_spi_unselect(void);

void at86rf231_spi_transfer(const uint8_t *data_out, uint8_t *data_in, uint16_t length);
uint8_t at86rf231_spi_transfer_byte(uint8_t byte);

void at86rf231_init_interrupts(void);
Expand Down
1 change: 0 additions & 1 deletion drivers/at86rf231/include/at86rf231_spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ void at86rf231_reg_write(uint8_t addr, uint8_t value);

void at86rf231_read_fifo(uint8_t *data, uint8_t length);
void at86rf231_write_fifo(const uint8_t *data, uint8_t length);

#endif
10 changes: 2 additions & 8 deletions examples/rpl_udp/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@ extern uint8_t ipv6_ext_hdr_len;

msg_t msg_q[RCV_BUFFER_SIZE];

/* prints current IPv6 adresses */
void rpl_udp_ip(char *unused)
{
(void) unused;
ipv6_iface_print_addrs();
}

void rpl_udp_set_id(char *id_str)
{
int res = sscanf(id_str, "set %hu", &id);
Expand Down Expand Up @@ -93,7 +86,8 @@ void rpl_udp_monitor(void)
else if (m.type == IPV6_PACKET_RECEIVED) {
ipv6_buf = (ipv6_hdr_t *) m.content.ptr;
printf("IPv6 datagram received (next header: %02X)", ipv6_buf->nextheader);
printf(" from %s ", ipv6_addr_to_str(addr_str, &ipv6_buf->srcaddr));
printf(" from %s ", ipv6_addr_to_str(addr_str, IPV6_MAX_ADDR_STR_LEN,
&ipv6_buf->srcaddr));

if (ipv6_buf->nextheader == IPV6_PROTO_NUM_ICMPV6) {
icmpv6_buf = (icmpv6_hdr_t *) &ipv6_buf[(LL_HDR_LEN + IPV6_HDR_LEN) + ipv6_ext_hdr_len];
Expand Down
1 change: 0 additions & 1 deletion examples/rpl_udp/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ const shell_command_t shell_commands[] = {
{"loop", "", rpl_udp_loop},
{"server", "Starts a UDP server", udp_server},
{"send", "Send a UDP datagram", udp_send},
{"ip", "Print all assigned IP addresses", rpl_udp_ip},
{"ign", "ignore node", rpl_udp_ignore},
{NULL, NULL, NULL}
};
Expand Down
33 changes: 22 additions & 11 deletions examples/rpl_udp/rpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <string.h>
#include "vtimer.h"
#include "thread.h"
#include "net_if.h"
#include "sixlowpan.h"
#include "destiny.h"
#include "rpl.h"
Expand Down Expand Up @@ -68,7 +69,9 @@ void rpl_udp_init(char *str)
return;
}

state = rpl_init(TRANSCEIVER, id);
net_if_set_hardware_address(0, id);

state = rpl_init(0);

if (state != SIXLOWERROR_SUCCESS) {
printf("Error initializing RPL\n");
Expand Down Expand Up @@ -99,11 +102,13 @@ void rpl_udp_init(char *str)
ipv6_addr_t prefix, tmp;
ipv6_addr_init(&std_addr, 0xABCD, 0xEF12, 0, 0, 0x1034, 0x00FF, 0xFE00, id);
ipv6_addr_init_prefix(&prefix, &std_addr, 64);
plist_add(&prefix, 64, NDP_OPT_PI_VLIFETIME_INFINITE, 0, 1, ICMPV6_NDP_OPT_PI_FLAG_AUTONOM);
ipv6_init_iface_as_router();
ndp_add_prefix_info(0, &prefix, 64, NDP_OPT_PI_VLIFETIME_INFINITE,
NDP_OPT_PI_PLIFETIME_INFINITE, 1,
ICMPV6_NDP_OPT_PI_FLAG_AUTONOM);
ipv6_init_as_router();
/* add global address */
ipv6_addr_set_by_eui64(&tmp, &std_addr);
ipv6_iface_add_addr(&tmp, IPV6_ADDR_TYPE_GLOBAL, NDP_ADDR_STATE_PREFERRED, 0, 0);
ipv6_addr_set_by_eui64(&tmp, 0, &std_addr);
ipv6_net_if_add_addr(0, &tmp, NDP_ADDR_STATE_PREFERRED, 0, 0, 0);

/* set channel to 10 */
tcmd.transceivers = TRANSCEIVER;
Expand Down Expand Up @@ -137,17 +142,20 @@ void rpl_udp_loop(char *unused)

if (!is_root) {
printf("my preferred parent:\n");
printf("%s\n", ipv6_addr_to_str(addr_str, (&mydodag->my_preferred_parent->addr)));
printf("%s\n", ipv6_addr_to_str(addr_str, IPV6_MAX_ADDR_STR_LEN,
(&mydodag->my_preferred_parent->addr)));
printf("parent lifetime: %d\n", mydodag->my_preferred_parent->lifetime);
}

printf("---------------------------$\n");

for (int i = 0; i < RPL_MAX_ROUTING_ENTRIES; i++) {
if (rtable[i].used) {
printf("%s\n", ipv6_addr_to_str(addr_str, (&rtable[i].address)));
printf("%s\n", ipv6_addr_to_str(addr_str, IPV6_MAX_ADDR_STR_LEN,
(&rtable[i].address)));
puts("next hop");
printf("%s\n", ipv6_addr_to_str(addr_str, (&rtable[i].next_hop)));
printf("%s\n", ipv6_addr_to_str(addr_str, IPV6_MAX_ADDR_STR_LEN,
(&rtable[i].next_hop)));
printf("entry %d lifetime %d\n", i, rtable[i].lifetime);

if (!rpl_equal_id(&rtable[i].address, &rtable[i].next_hop)) {
Expand All @@ -173,7 +181,8 @@ void rpl_udp_table(char *unused)

for (int i = 0; i < RPL_MAX_ROUTING_ENTRIES; i++) {
if (rtable[i].used) {
printf("%s\n", ipv6_addr_to_str(addr_str, (&rtable[i].address)));
printf("%s\n", ipv6_addr_to_str(addr_str, IPV6_MAX_ADDR_STR_LEN,
(&rtable[i].address)));
printf("entry %d lifetime %d\n", i, rtable[i].lifetime);

if (!rpl_equal_id(&rtable[i].address, &rtable[i].next_hop)) {
Expand Down Expand Up @@ -201,12 +210,14 @@ void rpl_udp_dodag(char *unused)
}

printf("Part of Dodag:\n");
printf("%s\n", ipv6_addr_to_str(addr_str, (&mydodag->dodag_id)));
printf("%s\n", ipv6_addr_to_str(addr_str, IPV6_MAX_ADDR_STR_LEN,
(&mydodag->dodag_id)));
printf("my rank: %d\n", mydodag->my_rank);

if (!is_root) {
printf("my preferred parent:\n");
printf("%s\n", ipv6_addr_to_str(addr_str, (&mydodag->my_preferred_parent->addr)));
printf("%s\n", ipv6_addr_to_str(addr_str, IPV6_MAX_ADDR_STR_LEN,
(&mydodag->my_preferred_parent->addr)));
}

printf("---------------------------\n");
Expand Down
4 changes: 3 additions & 1 deletion examples/rpl_udp/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ void udp_send(char *str)
printf("Error sending packet!\n");
}
else {
printf("Successful deliverd %i bytes over UDP to %s to 6LoWPAN\n", bytes_sent, ipv6_addr_to_str(addr_str, &ipaddr));
printf("Successful deliverd %i bytes over UDP to %s to 6LoWPAN\n",
bytes_sent, ipv6_addr_to_str(addr_str, IPV6_MAX_ADDR_STR_LEN,
&ipaddr));
}

destiny_socket_close(sock);
Expand Down
6 changes: 6 additions & 0 deletions sys/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ endif
ifneq (,$(filter vtimer,$(USEMODULE)))
DIRS += vtimer
endif
ifneq (,$(filter net_if,$(USEMODULE)))
DIRS += net/link_layer/net_if
endif
ifneq (,$(filter destiny,$(USEMODULE)))
DIRS += net/transport_layer/destiny
endif
Expand All @@ -51,6 +54,9 @@ endif
ifneq (,$(filter sixlowpan,$(USEMODULE)))
DIRS += net/network_layer/sixlowpan
endif
ifneq (,$(filter sixlowborder,$(USEMODULE)))
DIRS += net/network_layer/sixlowpan/border
endif
ifneq (,$(filter rpl,$(USEMODULE)))
DIRS += net/routing/rpl
endif
Expand Down
4 changes: 4 additions & 0 deletions sys/auto_init/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
MODULE = auto_init

ifneq (,$(findstring net_if,$(USEMODULE)))
INCLUDES += -I$(RIOTBASE)/sys/net/include/
endif

include $(RIOTBASE)/Makefile.base
73 changes: 72 additions & 1 deletion sys/auto_init/auto_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,30 @@
#include "rtc.h"
#endif

#ifdef MODULE_SIXLOWPAN
#include "sixlowpan.h"
#endif

#ifdef MODULE_DESTINY
#include "destiny.h"
#endif

#define ENABLE_DEBUG (0)
#ifdef MODULE_NET_IF
#include "net_if.h"
#include "transceiver.h"
#endif

#define ENABLE_DEBUG (1)
#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)
Expand Down Expand Up @@ -105,6 +122,60 @@ void auto_init(void)
DEBUG("Auto init mci module.\n");
MCI_initialize();
#endif
#ifdef MODULE_NET_IF
int iface;
DEBUG("Auto init net_if module.\n");
transceiver_type_t transceivers = 0;
#ifdef MODULE_AT86RF231
transceivers |= TRANSCEIVER_AT86RF231;
#endif
#ifdef MODULE_CC1020
transceivers |= TRANSCEIVER_CC1020;
#endif
#if MODULE_CC110X || MODULE_CC110X_NG
transceivers |= TRANSCEIVER_CC1100;
#endif
#ifdef MODULE_CC2420
transceivers |= TRANSCEIVER_CC2420;
#endif
#ifdef MODULE_MC1322X
transceivers |= TRANSCEIVER_MC1322X;
#endif
#ifdef MODULE_NATIVENET
transceivers |= TRANSCEIVER_NATIVE;
#endif
net_if_init();

if (transceivers != 0) {
transceiver_init(transceivers);
transceiver_start();
iface = net_if_init_interface(0, transceivers);

if (!net_if_get_hardware_address(iface)) {
DEBUG("Set radio address on interface %d to %d\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("Set PAN ID on interface %d to 0x%x\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);
}
}
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);
profiling_init();
Expand Down
7 changes: 7 additions & 0 deletions sys/include/transceiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@
*/
typedef uint16_t transceiver_type_t;

/**
* @brief Data type to represent the transceiver's EUI-64.
*/
typedef uint64_t transceiver_eui64_t;

/**
* @brief Message types for transceiver interface
*/
Expand All @@ -129,6 +134,8 @@ enum transceiver_msg_type_t {
SET_CHANNEL, ///< Set a new channel
GET_ADDRESS, ///< Get the radio address
SET_ADDRESS, ///< Set the radio address
GET_LONG_ADDR, ///< Get the long radio address, if existing
SET_LONG_ADDR, ///< Set the long radio address, if supported by hardware
SET_MONITOR, ///< Set transceiver to monitor mode (disable address checking)
GET_PAN, ///< Get current pan
SET_PAN, ///< Set a new pan
Expand Down
Loading