diff --git a/.travis.yml b/.travis.yml index 00dba89ab..0467424de 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,3 +33,4 @@ env: - TEST_NAME='doxygen' - TEST_NAME='compile-tools' - TEST_NAME='native-runs' + - TEST_NAME='ipv6' diff --git a/Makefile.include b/Makefile.include index dd24fcacb..4de7e7dbb 100644 --- a/Makefile.include +++ b/Makefile.include @@ -49,6 +49,8 @@ CFLAGS += -DCONTIKI_BOARD_$(TARGET_BOARD_UPPERCASE)=1 CFLAGS += -DCONTIKI_BOARD_STRING=\"$(BOARD)\" endif +LDFLAGS = -Wl,--fatal-warnings + MODULES += os os/sys os/dev os/lib os/services # Automatically include project-conf.h if found @@ -165,14 +167,12 @@ MAKE_NET ?= MAKE_NET_IPV6 ifeq ($(MAKE_NET),MAKE_NET_NULLNET) CFLAGS += -DNETSTACK_CONF_WITH_NULLNET=1 + MODULES += os/net/nullnet endif ifeq ($(MAKE_NET),MAKE_NET_IPV6) CFLAGS += -DNETSTACK_CONF_WITH_IPV6=1 MODULES += os/net/ipv6 -else - CFLAGS += -DNETSTACK_CONF_WITH_NULLNET=1 - MODULES += os/net/nullnet endif ifeq ($(MAKE_NET),MAKE_NET_OTHER) @@ -298,14 +298,15 @@ CONTIKI_NG_PROJECT_MAP = $(addsuffix -$(TARGET).map, $(basename $@)) .PHONY: clean distclean usage help targets boards savetarget savedefines viewconf clean: - -rm -f *.d *.e *.o $(CONTIKI_NG_TARGET_LIB) $(CLEAN) - -rm -rf $(OBJECTDIR) - -rm -f $(addsuffix -$(TARGET).map, $(CONTIKI_PROJECT)) - -rm -f $(addsuffix .$(TARGET), $(CONTIKI_PROJECT)) + -$(Q)rm -f *.d *.e *.o $(CONTIKI_NG_TARGET_LIB) $(CLEAN) + -$(Q)rm -rf $(OBJECTDIR) + -$(Q)rm -f $(addsuffix -$(TARGET).map, $(CONTIKI_PROJECT)) + -$(Q)rm -f $(addsuffix .$(TARGET), $(CONTIKI_PROJECT)) + @echo Target $(TARGET) cleaned distclean: @for TARG in `ls $(CONTIKI)/arch/platform $(TARGETDIRS)`; do \ - echo make $$TARG clean; \ + echo Running: make TARGET=$$TARG clean; \ make TARGET=$$TARG clean; \ done @@ -397,11 +398,16 @@ usage: @echo "Miscellaneous targets:" @echo " targets Prints list of supported platforms" @echo " boards Prints a list of supported boards for TARGET" - @echo " savegtarget Saves TARGET and BOARD for future invocations of make" + @echo " savetarget Saves TARGET and BOARD for future invocations of make" @echo " savedefines Saves DEFINES for future invocations of make" @echo " clean Removes all compiled files for TARGET" @echo " distclean Removes all compiled files for all TARGETs" @echo " viewconf Prints Contiki-NG build configuration for TARGET" + @echo " %.flashprof Shows a Flash/ROM profile of a given firmware (e.g. hello-world.flashprof)" + @echo " %.ramprof Shows a RAM profile of a given firmware (e.g. hello-world.ramprof)" + @echo " %.o Produces an object file from a given source file (e.g. hello-world.o)" + @echo " %.e Produces the pre-processed version of a given source file (e.g. hello-world.e)" + @echo " %.s Produces an assembly file from a given source file (e.g. hello-world.s)" help: usage diff --git a/README.md b/README.md index f29f369c1..df7d7ff58 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Contiki-NG: The OS for Next Generation IoT Devices [![Build Status](https://travis-ci.org/contiki-ng/contiki-ng.svg?branch=master)](https://travis-ci.org/contiki-ng/contiki-ng/branches) -[![License](https://img.shields.io/badge/License-3--Clause%20BSD-brightgreen.svg)](https://github.com/contiki-ng/contiki-ng/blob/master/LICENSE.md) +[![license](https://img.shields.io/badge/license-3--clause%20bsd-brightgreen.svg)](https://github.com/contiki-ng/contiki-ng/blob/master/LICENSE.md) [![Latest release](https://img.shields.io/github/release/contiki-ng/contiki-ng.svg)](https://github.com/contiki-ng/contiki-ng/releases/latest) [![GitHub Release Date](https://img.shields.io/github/release-date/contiki-ng/contiki-ng.svg)](https://github.com/contiki-ng/contiki-ng/releases/latest) [![Last commit](https://img.shields.io/github/last-commit/contiki-ng/contiki-ng.svg)](https://github.com/contiki-ng/contiki-ng/commit/HEAD) @@ -9,7 +9,7 @@ Contiki-NG is an open-source, cross-platform operating system for Next-Generation IoT devices. It focuses on dependable (secure and reliable) low-power communication and standard protocols, such as IPv6/6LoWPAN, 6TiSCH, RPL, and CoAP. Contiki-NG comes with extensive documentation, tutorials, a roadmap, release cycle, and well-defined development flow for smooth integration of community contributions. Unless excplicitly stated otherwise, Contiki-NG sources are distributed under -the terms of the [3-clause BSD license](LICENSE.md). +the terms of the [3-clause BSD license](LICENSE.md). Contiki-NG started as a fork of the Contiki OS and retains some of its original features. diff --git a/arch/cpu/arm/arm-def.h b/arch/cpu/arm/arm-def.h index 92b19048d..c83cfd3fc 100644 --- a/arch/cpu/arm/arm-def.h +++ b/arch/cpu/arm/arm-def.h @@ -57,8 +57,6 @@ typedef uint32_t clock_time_t; typedef uint32_t uip_stats_t; -typedef uint32_t rtimer_clock_t; -#define RTIMER_CLOCK_DIFF(a, b) ((int32_t)((a) - (b))) /** @} */ /* diff --git a/arch/cpu/cc2538/cc2538-conf.h b/arch/cpu/cc2538/cc2538-conf.h index 725f95439..d34c3dee5 100644 --- a/arch/cpu/cc2538/cc2538-conf.h +++ b/arch/cpu/cc2538/cc2538-conf.h @@ -219,14 +219,6 @@ */ /* RF Config */ -#ifdef RF_CHANNEL -#define CC2538_RF_CONF_CHANNEL RF_CHANNEL -#endif - -#ifndef CC2538_RF_CONF_CHANNEL -#define CC2538_RF_CONF_CHANNEL 26 -#endif /* CC2538_RF_CONF_CHANNEL */ - #ifndef CC2538_RF_CONF_AUTOACK #define CC2538_RF_CONF_AUTOACK 1 /**< RF H/W generates ACKs */ #endif /* CC2538_CONF_AUTOACK */ diff --git a/arch/cpu/cc2538/dev/cc2538-rf.c b/arch/cpu/cc2538/dev/cc2538-rf.c index 5e6661b3e..f33e87131 100644 --- a/arch/cpu/cc2538/dev/cc2538-rf.c +++ b/arch/cpu/cc2538/dev/cc2538-rf.c @@ -113,7 +113,7 @@ static int8_t rssi; static uint8_t crc_corr; /*---------------------------------------------------------------------------*/ static uint8_t rf_flags; -static uint8_t rf_channel = CC2538_RF_CHANNEL; +static uint8_t rf_channel = IEEE802154_DEFAULT_CHANNEL; static int on(void); static int off(void); diff --git a/arch/cpu/cc2538/dev/cc2538-rf.h b/arch/cpu/cc2538/dev/cc2538-rf.h index 87fef3a59..b89738436 100644 --- a/arch/cpu/cc2538/dev/cc2538-rf.h +++ b/arch/cpu/cc2538/dev/cc2538-rf.h @@ -74,12 +74,6 @@ #define CC2538_RF_CCA_THRES CC2538_RF_CCA_THRES_USER_GUIDE #endif /* CC2538_RF_CONF_CCA_THRES */ -#ifdef CC2538_RF_CONF_CHANNEL -#define CC2538_RF_CHANNEL CC2538_RF_CONF_CHANNEL -#else -#define CC2538_RF_CHANNEL 18 -#endif /* CC2538_RF_CONF_CHANNEL */ - #ifdef CC2538_RF_CONF_AUTOACK #define CC2538_RF_AUTOACK CC2538_RF_CONF_AUTOACK #else diff --git a/arch/cpu/cc2538/dev/spi-arch-legacy.h b/arch/cpu/cc2538/dev/spi-arch-legacy.h index de7a765bb..9608110ed 100644 --- a/arch/cpu/cc2538/dev/spi-arch-legacy.h +++ b/arch/cpu/cc2538/dev/spi-arch-legacy.h @@ -55,7 +55,7 @@ * - SPIX_FLUSH(x) * * Some of the old functions and macros are still supported. - * When using these deprecated functions, the SSI module to use + * When using these deprecated functions, the SSI module to use * has to be be selected by means of the macro SPI_CONF_DEFAULT_INSTANCE. * * This SPI driver depends on the following defines: @@ -95,14 +95,14 @@ #endif /*---------------------------------------------------------------------------*/ /* Default values for the clock rate divider */ -#ifdef SPI0_CONF_CPRS_CPSDVSR -#define SPI0_CPRS_CPSDVSR SPI0_CONF_CPRS_CPSDVSR +#ifdef SPI0_CONF_CPRS_CPSDVSR +#define SPI0_CPRS_CPSDVSR SPI0_CONF_CPRS_CPSDVSR #else #define SPI0_CPRS_CPSDVSR 2 #endif -#ifdef SPI1_CONF_CPRS_CPSDVSR -#define SPI1_CPRS_CPSDVSR SPI1_CONF_CPRS_CPSDVSR +#ifdef SPI1_CONF_CPRS_CPSDVSR +#define SPI1_CPRS_CPSDVSR SPI1_CONF_CPRS_CPSDVSR #else #define SPI1_CPRS_CPSDVSR 2 #endif @@ -120,7 +120,7 @@ } while(0) #define SPIX_FLUSH(spi) do { \ while(REG(SSI_BASE(spi) + SSI_SR) & SSI_SR_RNE) { \ - SPIX_BUF(spi); \ + SPIX_BUF(spi); \ } \ } while(0) #define SPIX_CS_CLR(port, pin) do { \ @@ -144,7 +144,7 @@ #endif #define SPI_CS_CLR(port, pin) SPIX_CS_CLR(port, pin) #define SPI_CS_SET(port, pin) SPIX_CS_SET(port, pin) -#endif /* #ifdef SPI_DEFAULT_INSTANCE */ +#endif /* #ifdef SPI_DEFAULT_INSTANCE */ /*---------------------------------------------------------------------------*/ /** \name Arch-specific SPI functions * @{ @@ -183,7 +183,7 @@ void spix_disable(uint8_t spi); * * See section 19.4.4 in the CC2538 user guide for more information. * - * \param spi The SSI instance to use. + * \param spi The SSI instance to use. * \param frame_format Set the SSI frame format. Use SSI_CR0_FRF_MOTOROLA, * SSI_CR0_FRF_TI, or SSI_CR0_FRF_MICROWIRE. * \param clock_polarity In Motorola mode, set whether the clock is high or low diff --git a/arch/cpu/cc2538/ieee-addr.c b/arch/cpu/cc2538/ieee-addr.c index c914b511d..6a676f4eb 100644 --- a/arch/cpu/cc2538/ieee-addr.c +++ b/arch/cpu/cc2538/ieee-addr.c @@ -70,11 +70,8 @@ ieee_addr_cpy_to(uint8_t *dst, uint8_t len) if(((uint8_t *)IEEE_ADDR_LOCATION)[3] == oui_ti[0] && ((uint8_t *)IEEE_ADDR_LOCATION)[2] == oui_ti[1] && ((uint8_t *)IEEE_ADDR_LOCATION)[1] == oui_ti[2]) { - for(i = 0; i < len / 2; i++) { - dst[i] = ((uint8_t *)IEEE_ADDR_LOCATION)[len / 2 - 1 - i]; - } - for(i = 0; i < len / 2; i++) { - dst[i + len / 2] = ((uint8_t *)IEEE_ADDR_LOCATION)[len - 1 - i]; + for(i = 0; i < len; i++) { + dst[len - i - 1] = ((uint8_t *)IEEE_ADDR_LOCATION)[i < 4 ? i + 4 : i - 4]; } } else { for(i = 0; i < len; i++) { diff --git a/arch/cpu/cc26xx-cc13xx/Makefile.cc26xx-cc13xx b/arch/cpu/cc26xx-cc13xx/Makefile.cc26xx-cc13xx index e72954c17..ef7c47443 100644 --- a/arch/cpu/cc26xx-cc13xx/Makefile.cc26xx-cc13xx +++ b/arch/cpu/cc26xx-cc13xx/Makefile.cc26xx-cc13xx @@ -93,10 +93,10 @@ ifeq ($(HOST_OS),Windows) SERIALDUMP ?= $(CONTIKI)/tools/sky/serialdump-windows else ifeq ($(HOST_OS),Darwin) - SERIALDUMP ?= $(CONTIKI)/tools/sky/serialdump-macos + SERIALDUMP ?= rlwrap $(CONTIKI)/tools/sky/serialdump-macos else # Else assume Linux - SERIALDUMP ?= $(CONTIKI)/tools/sky/serialdump-linux + SERIALDUMP ?= rlwrap $(CONTIKI)/tools/sky/serialdump-linux endif endif diff --git a/arch/cpu/cc26xx-cc13xx/cc13xx-cc26xx-conf.h b/arch/cpu/cc26xx-cc13xx/cc13xx-cc26xx-conf.h index 83519f795..df1ca0440 100644 --- a/arch/cpu/cc26xx-cc13xx/cc13xx-cc26xx-conf.h +++ b/arch/cpu/cc26xx-cc13xx/cc13xx-cc26xx-conf.h @@ -54,14 +54,6 @@ #define CC2650_FAST_RADIO_STARTUP (MAC_CONF_WITH_TSCH) #endif -#ifdef RF_CHANNEL -#define RF_CORE_CONF_CHANNEL RF_CHANNEL -#endif - -#ifndef RF_CORE_CONF_CHANNEL -#define RF_CORE_CONF_CHANNEL 25 -#endif - /* Number of Prop Mode RX buffers */ #ifndef PROP_MODE_CONF_RX_BUF_CNT #define PROP_MODE_CONF_RX_BUF_CNT 4 @@ -81,13 +73,22 @@ #if CC13XX_CONF_PROP_MODE #define NETSTACK_CONF_RADIO prop_mode_driver -#ifndef RF_CORE_CONF_CHANNEL -#define RF_CORE_CONF_CHANNEL 0 -#endif +/* Channels count from 0 upwards in IEEE 802.15.4g */ +#ifndef IEEE802154_CONF_DEFAULT_CHANNEL +#define IEEE802154_CONF_DEFAULT_CHANNEL 0 +#endif /* IEEE802154_CONF_DEFAULT_CHANNEL */ +#ifndef CSMA_CONF_ACK_WAIT_TIME #define CSMA_CONF_ACK_WAIT_TIME (RTIMER_SECOND / 400) +#endif /* CSMA_CONF_ACK_WAIT_TIME */ + +#ifndef CSMA_CONF_AFTER_ACK_DETECTED_WAIT_TIME #define CSMA_CONF_AFTER_ACK_DETECTED_WAIT_TIME (RTIMER_SECOND / 1000) +#endif /* CSMA_CONF_AFTER_ACK_DETECTED_WAIT_TIME */ + +#ifndef CSMA_CONF_SEND_SOFT_ACK #define CSMA_CONF_SEND_SOFT_ACK 1 +#endif /* CSMA_CONF_SEND_SOFT_ACK */ #else /* CC13XX_CONF_PROP_MODE */ #ifndef NETSTACK_CONF_RADIO @@ -197,7 +198,7 @@ * @{ */ #ifndef ROM_BOOTLOADER_ENABLE -#define ROM_BOOTLOADER_ENABLE 0 +#define ROM_BOOTLOADER_ENABLE 1 #endif /** @} */ /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/cc26xx-cc13xx/rf-core/dot-15-4g.h b/arch/cpu/cc26xx-cc13xx/rf-core/dot-15-4g.h index 7282ac9ba..37c5d3e34 100644 --- a/arch/cpu/cc26xx-cc13xx/rf-core/dot-15-4g.h +++ b/arch/cpu/cc26xx-cc13xx/rf-core/dot-15-4g.h @@ -49,20 +49,21 @@ #include "driverlib/rf_mailbox.h" /*---------------------------------------------------------------------------*/ /* IEEE 802.15.4g frequency band identifiers (Table 68f) */ -#define DOT_15_4G_FREQUENCY_BAND_169 0 /* 169.400–169.475 (Europe) - 169 MHz band */ -#define DOT_15_4G_FREQUENCY_BAND_450 1 /* 450–470 (US FCC Part 22/90) - 450 MHz band */ -#define DOT_15_4G_FREQUENCY_BAND_470 2 /* 470–510 (China) - 470 MHz band */ -#define DOT_15_4G_FREQUENCY_BAND_780 3 /* 779–787 (China) - 780 MHz band */ -#define DOT_15_4G_FREQUENCY_BAND_863 4 /* 863–870 (Europe) - 863 MHz band */ -#define DOT_15_4G_FREQUENCY_BAND_896 5 /* 896–901 (US FCC Part 90) - 896 MHz band */ -#define DOT_15_4G_FREQUENCY_BAND_901 6 /* 901–902 (US FCC Part 24) - 901 MHz band */ -#define DOT_15_4G_FREQUENCY_BAND_915 7 /* 902–928 (US) - 915 MHz band */ -#define DOT_15_4G_FREQUENCY_BAND_917 8 /* 917–923.5 (Korea) - 917 MHz band */ -#define DOT_15_4G_FREQUENCY_BAND_920 9 /* 920–928 (Japan) - 920 MHz band */ -#define DOT_15_4G_FREQUENCY_BAND_928 10 /* 928–960 (US, non-contiguous) - 928 MHz band */ -#define DOT_15_4G_FREQUENCY_BAND_950 11 /* 950–958 (Japan) - 950 MHz band */ -#define DOT_15_4G_FREQUENCY_BAND_1427 12 /* 1427–1518 (US and Canada, non-contiguous) - 1427 MHz band */ -#define DOT_15_4G_FREQUENCY_BAND_2450 13 /* 2400–2483.5 2450 MHz band */ +#define DOT_15_4G_FREQUENCY_BAND_169 0 /* 169.400–169.475 (Europe) - 169 MHz band */ +#define DOT_15_4G_FREQUENCY_BAND_450 1 /* 450–470 (US FCC Part 22/90) - 450 MHz band */ +#define DOT_15_4G_FREQUENCY_BAND_470 2 /* 470–510 (China) - 470 MHz band */ +#define DOT_15_4G_FREQUENCY_BAND_780 3 /* 779–787 (China) - 780 MHz band */ +#define DOT_15_4G_FREQUENCY_BAND_863 4 /* 863–870 (Europe) - 863 MHz band */ +#define DOT_15_4G_FREQUENCY_BAND_896 5 /* 896–901 (US FCC Part 90) - 896 MHz band */ +#define DOT_15_4G_FREQUENCY_BAND_901 6 /* 901–902 (US FCC Part 24) - 901 MHz band */ +#define DOT_15_4G_FREQUENCY_BAND_915 7 /* 902–928 (US) - 915 MHz band */ +#define DOT_15_4G_FREQUENCY_BAND_917 8 /* 917–923.5 (Korea) - 917 MHz band */ +#define DOT_15_4G_FREQUENCY_BAND_920 9 /* 920–928 (Japan) - 920 MHz band */ +#define DOT_15_4G_FREQUENCY_BAND_928 10 /* 928–960 (US, non-contiguous) - 928 MHz band */ +#define DOT_15_4G_FREQUENCY_BAND_950 11 /* 950–958 (Japan) - 950 MHz band */ +#define DOT_15_4G_FREQUENCY_BAND_1427 12 /* 1427–1518 (US and Canada, non-contiguous) - 1427 MHz band */ +#define DOT_15_4G_FREQUENCY_BAND_2450 13 /* 2400–2483.5 2450 MHz band */ +#define DOT_15_4G_FREQUENCY_BAND_CUSTOM 14 /* For use with custom frequency band settings */ /*---------------------------------------------------------------------------*/ /* Default band selection to band 4 - 863MHz */ #ifdef DOT_15_4G_CONF_FREQUENCY_BAND_ID @@ -77,6 +78,18 @@ * bands we only support operating mode #1 (Table 134). * * DOT_15_4G_CHAN0_FREQUENCY is specified here in KHz + * + * Custom bands and configuration can be used with DOT_15_4G_FREQUENCY_BAND_CUSTOM. + * + * Example of custom setup for the 868Mhz sub-band in Europe with 11 channels, + * center frequency at 868.050MHz and channel spacing at 100KHz. + * These should be put in project-config.h or similar. + * + * #define DOT_15_4G_FREQUENCY_BAND_ID DOT_15_4G_FREQUENCY_BAND_CUSTOM + * #define DOT_15_4G_CHAN0_FREQUENCY 868050 + * #define DOT_15_4G_CHANNEL_SPACING 100 + * #define DOT_15_4G_CHANNEL_MAX 11 + * #define PROP_MODE_CONF_LO_DIVIDER 0x05 */ #if DOT_15_4G_FREQUENCY_BAND_ID==DOT_15_4G_FREQUENCY_BAND_470 #define DOT_15_4G_CHANNEL_MAX 198 @@ -116,6 +129,22 @@ #define DOT_15_4G_CHAN0_FREQUENCY 951000 #define PROP_MODE_CONF_LO_DIVIDER 0x05 +#elif DOT_15_4G_FREQUENCY_BAND_ID==DOT_15_4G_FREQUENCY_BAND_CUSTOM +#ifndef DOT_15_4G_CHANNEL_MAX +#error DOT_15_4G_CHANNEL_MAX must be manually set when using custom frequency band +#endif + +#ifndef DOT_15_4G_CHANNEL_SPACING +#error DOT_15_4G_CHANNEL_SPACING must be manually set when using custom frequency band +#endif + +#ifndef DOT_15_4G_CHAN0_FREQUENCY +#error DOT_15_4G_CHAN0_FREQUENCY must be manually set when using custom frequency band +#endif + +#ifndef PROP_MODE_CONF_LO_DIVIDER +#error PROP_MODE_CONF_LO_DIVIDER must be manually set when using custom frequency band +#endif #else #error The selected frequency band is not supported #endif diff --git a/arch/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c b/arch/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c index a5479a4ee..3516147b5 100644 --- a/arch/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c +++ b/arch/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c @@ -610,7 +610,7 @@ init_rf_params(void) cmd->startTime = 0x00000000; cmd->startTrigger.triggerType = TRIG_NOW; cmd->condition.rule = COND_NEVER; - cmd->channel = RF_CORE_CHANNEL; + cmd->channel = IEEE802154_DEFAULT_CHANNEL; cmd->rxConfig.bAutoFlushCrc = 1; cmd->rxConfig.bAutoFlushIgn = 0; diff --git a/arch/cpu/cc26xx-cc13xx/rf-core/prop-mode.c b/arch/cpu/cc26xx-cc13xx/rf-core/prop-mode.c index f9f49e9a0..f4e7f66e7 100644 --- a/arch/cpu/cc26xx-cc13xx/rf-core/prop-mode.c +++ b/arch/cpu/cc26xx-cc13xx/rf-core/prop-mode.c @@ -629,7 +629,7 @@ init(void) smartrf_settings_cmd_prop_rx_adv.pQueue = &rx_data_queue; smartrf_settings_cmd_prop_rx_adv.pOutput = (uint8_t *)&rx_stats; - set_channel(RF_CORE_CHANNEL); + set_channel(IEEE802154_DEFAULT_CHANNEL); if(on() != RF_CORE_CMD_OK) { PRINTF("init: on() failed\n"); diff --git a/arch/cpu/cc26xx-cc13xx/rf-core/rf-core.h b/arch/cpu/cc26xx-cc13xx/rf-core/rf-core.h index 3264cfc01..ac48bc52a 100644 --- a/arch/cpu/cc26xx-cc13xx/rf-core/rf-core.h +++ b/arch/cpu/cc26xx-cc13xx/rf-core/rf-core.h @@ -57,13 +57,6 @@ #include #include /*---------------------------------------------------------------------------*/ -/* The channel to use in IEEE or prop mode. */ -#ifdef RF_CORE_CONF_CHANNEL -#define RF_CORE_CHANNEL RF_CORE_CONF_CHANNEL -#else -#define RF_CORE_CHANNEL 25 -#endif /* RF_CORE_CONF_IEEE_MODE_CHANNEL */ -/*---------------------------------------------------------------------------*/ #define RF_CORE_FRONT_END_MODE_DIFFERENTIAL 0 #define RF_CORE_FRONT_END_MODE_SINGLE_RFP 1 #define RF_CORE_FRONT_END_MODE_SINGLE_RFN 2 diff --git a/arch/cpu/msp430/f1xxx/spi-legacy.c b/arch/cpu/msp430/f1xxx/spi-legacy.c index c9e98508f..38adfaa31 100644 --- a/arch/cpu/msp430/f1xxx/spi-legacy.c +++ b/arch/cpu/msp430/f1xxx/spi-legacy.c @@ -1,30 +1,30 @@ /* * Copyright (c) 2006, Swedish Institute of Computer Science - * All rights reserved. + * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. * */ @@ -35,7 +35,7 @@ * exclusive. Set spi_busy so that interrupt handlers can check if * they are allowed to use the bus or not. Only the CC2420 radio needs * this in practice. - * + * */ unsigned char spi_busy = 0; diff --git a/arch/cpu/msp430/msp430-def.h b/arch/cpu/msp430/msp430-def.h index 93e575702..28b482e9a 100644 --- a/arch/cpu/msp430/msp430-def.h +++ b/arch/cpu/msp430/msp430-def.h @@ -1,30 +1,30 @@ /* * Copyright (c) 2007, Swedish Institute of Computer Science - * All rights reserved. + * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. */ #ifndef MSP430_DEF_H_ @@ -79,6 +79,9 @@ typedef long off_t; /* Our clock resolution, this is the same as Unix HZ. */ #define CLOCK_CONF_SECOND 128UL +/* Use 16-bit rtimer (default in Contiki-NG is 32) */ +#define RTIMER_CONF_CLOCK_SIZE 2 + typedef int spl_t; spl_t splhigh_(void); diff --git a/arch/cpu/msp430/rtimer-arch.h b/arch/cpu/msp430/rtimer-arch.h index 6063292b1..9fd5b46ba 100644 --- a/arch/cpu/msp430/rtimer-arch.h +++ b/arch/cpu/msp430/rtimer-arch.h @@ -42,11 +42,7 @@ #include "sys/rtimer.h" -#ifdef RTIMER_CONF_SECOND -#define RTIMER_ARCH_SECOND RTIMER_CONF_SECOND -#else #define RTIMER_ARCH_SECOND (4096U*8) -#endif /* Do the math in 32bits to save precision. * Round to nearest integer rather than truncate. */ diff --git a/arch/cpu/native/Makefile.native b/arch/cpu/native/Makefile.native index cda288e65..af7328b31 100644 --- a/arch/cpu/native/Makefile.native +++ b/arch/cpu/native/Makefile.native @@ -1,6 +1,7 @@ CONTIKI_CPU_DIRS = . net dev -CONTIKI_SOURCEFILES += rtimer-arch.c watchdog.c eeprom.c +CONTIKI_SOURCEFILES += rtimer-arch.c watchdog.c eeprom.c int-master.c +CONTIKI_SOURCEFILES += gpio-hal-arch.c ### Compiler definitions CC ?= gcc @@ -20,7 +21,7 @@ CFLAGSNO = -Wall -g -I/usr/local/include $(CFLAGSWERROR) CFLAGS += $(CFLAGSNO) ifeq ($(HOST_OS),Darwin) -AROPTS = -r +AROPTS = -rc LDFLAGS += -Wl,-flat_namespace,-map,$(CONTIKI_NG_PROJECT_MAP) CFLAGS += -DHAVE_SNPRINTF=1 -U__ASSERT_USE_STDERR else diff --git a/arch/cpu/native/dev/gpio-hal-arch.c b/arch/cpu/native/dev/gpio-hal-arch.c new file mode 100644 index 000000000..553a23444 --- /dev/null +++ b/arch/cpu/native/dev/gpio-hal-arch.c @@ -0,0 +1,216 @@ +/* + * Copyright (c) 2018, George Oikonomou - http://www.spd.gr + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/*---------------------------------------------------------------------------*/ +#include "contiki.h" +#include "dev/gpio-hal.h" +#include "sys/log.h" + +#include +/*---------------------------------------------------------------------------*/ +/* Log configuration */ +#define LOG_MODULE "GPIO arch" +#define LOG_LEVEL LOG_LEVEL_NONE +/*---------------------------------------------------------------------------*/ +static gpio_hal_pin_cfg_t pin_cfg[GPIO_HAL_PIN_COUNT]; +static uint8_t pin_state[GPIO_HAL_PIN_COUNT]; +/*---------------------------------------------------------------------------*/ +void +gpio_hal_arch_interrupt_enable(gpio_hal_pin_t pin) +{ + if(pin >= GPIO_HAL_PIN_COUNT) { + LOG_ERR("Pin %u out of bounds\n", pin); + return; + } + + LOG_DBG("Pin %u: Enabled interrupt\n", pin); +} +/*---------------------------------------------------------------------------*/ +void +gpio_hal_arch_interrupt_disable(gpio_hal_pin_t pin) +{ + if(pin >= GPIO_HAL_PIN_COUNT) { + LOG_ERR("Pin %u out of bounds\n", pin); + return; + } + + LOG_DBG("Pin %u: Disabled interrupt\n", pin); +} +/*---------------------------------------------------------------------------*/ +void +gpio_hal_arch_pin_cfg_set(gpio_hal_pin_t pin, gpio_hal_pin_cfg_t cfg) +{ + if(pin >= GPIO_HAL_PIN_COUNT) { + LOG_ERR("Pin %u out of bounds\n", pin); + return; + } + + pin_cfg[pin] = cfg; + LOG_DBG("Pin %u: Set config=0x%02x\n", pin, pin_cfg[pin]); +} +/*---------------------------------------------------------------------------*/ +gpio_hal_pin_cfg_t +gpio_hal_arch_pin_cfg_get(gpio_hal_pin_t pin) +{ + if(pin >= GPIO_HAL_PIN_COUNT) { + LOG_ERR("Pin %u out of bounds\n", pin); + return 0; + } + + LOG_DBG("Pin %u: Config=0x%02x\n", pin, pin_cfg[pin]); + return pin_cfg[pin]; +} +/*---------------------------------------------------------------------------*/ +void +gpio_hal_arch_pin_set_input(gpio_hal_pin_t pin) +{ + if(pin >= GPIO_HAL_PIN_COUNT) { + LOG_ERR("Pin %u out of bounds\n", pin); + return; + } + + LOG_DBG("Pin %u: Set input\n", pin); +} +/*---------------------------------------------------------------------------*/ +void +gpio_hal_arch_pin_set_output(gpio_hal_pin_t pin) +{ + if(pin >= GPIO_HAL_PIN_COUNT) { + LOG_ERR("Pin %u out of bounds\n", pin); + return; + } + + LOG_DBG("Pin %u: Set output\n", pin); +} +/*---------------------------------------------------------------------------*/ +void +gpio_hal_arch_set_pin(gpio_hal_pin_t pin) +{ + if(pin >= GPIO_HAL_PIN_COUNT) { + LOG_ERR("Pin %u out of bounds\n", pin); + return; + } + + pin_state[pin] = 1; + LOG_DBG("Pin %u: Set\n", pin); +} +/*---------------------------------------------------------------------------*/ +void +gpio_hal_arch_clear_pin(gpio_hal_pin_t pin) +{ + if(pin >= GPIO_HAL_PIN_COUNT) { + LOG_ERR("Pin %u out of bounds\n", pin); + return; + } + + pin_state[pin] = 0; + LOG_DBG("Pin %u: Clear\n", pin); +} +/*---------------------------------------------------------------------------*/ +uint8_t +gpio_hal_arch_read_pin(gpio_hal_pin_t pin) +{ + if(pin >= GPIO_HAL_PIN_COUNT) { + LOG_ERR("Pin %u out of bounds\n", pin); + return 0; + } + + LOG_DBG("Pin %u: Read=%u\n", pin, pin_state[pin]); + return pin_state[pin]; +} +/*---------------------------------------------------------------------------*/ +void +gpio_hal_arch_write_pin(gpio_hal_pin_t pin, uint8_t value) +{ + if(pin >= GPIO_HAL_PIN_COUNT) { + LOG_ERR("Pin %u out of bounds\n", pin); + return; + } + + pin_state[pin] = value; + LOG_DBG("Pin %u: Write=%u\n", pin, pin_state[pin]); +} +/*---------------------------------------------------------------------------*/ +void +gpio_hal_arch_set_pins(gpio_hal_pin_mask_t pins) +{ + gpio_hal_pin_t pin; + + for(pin = 0; pin < GPIO_HAL_PIN_COUNT; pin++) { + if(pins & (1 << pin)) { + pin_state[pin] = 1; + } + } + + LOG_DBG("Set pins 0x%08" PRIx32 "\n", pins); +} +/*---------------------------------------------------------------------------*/ +void +gpio_hal_arch_clear_pins(gpio_hal_pin_mask_t pins) +{ + gpio_hal_pin_t pin; + + for(pin = 0; pin < GPIO_HAL_PIN_COUNT; pin++) { + if(pins & (1 << pin)) { + pin_state[pin] = 0; + } + } + + LOG_DBG("Clear pins 0x%08" PRIx32 "\n", pins); +} +/*---------------------------------------------------------------------------*/ +gpio_hal_pin_mask_t +gpio_hal_arch_read_pins(gpio_hal_pin_mask_t pins) +{ + gpio_hal_pin_t pin; + gpio_hal_pin_mask_t state = 0; + + for(pin = 0; pin < GPIO_HAL_PIN_COUNT; pin++) { + state |= (pin_state[pin] << pin); + } + + LOG_DBG("Read pins 0x%08" PRIx32 "\n", state); + return state; +} +/*---------------------------------------------------------------------------*/ +void +gpio_hal_arch_write_pins(gpio_hal_pin_mask_t pins, gpio_hal_pin_mask_t value) +{ + gpio_hal_pin_t pin; + + for(pin = 0; pin < GPIO_HAL_PIN_COUNT; pin++) { + if(pins & (1 << pin)) { + pin_state[pin] = (value & (1 << pin)) == 0 ? 0 : 1; + } + } + + LOG_DBG("Write pins 0x%08" PRIx32 "->0x%08" PRIx32 "\n", pins, value); +} +/*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/native/int-master.c b/arch/cpu/native/int-master.c new file mode 100644 index 000000000..177dbd442 --- /dev/null +++ b/arch/cpu/native/int-master.c @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2018, George Oikonomou - http://www.spd.gr + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/*---------------------------------------------------------------------------*/ +#include "contiki.h" +#include "sys/int-master.h" + +#include +/*---------------------------------------------------------------------------*/ +#define DISABLED 0 +#define ENABLED 1 +/*---------------------------------------------------------------------------*/ +static int_master_status_t stat = DISABLED; +/*---------------------------------------------------------------------------*/ +void +int_master_enable(void) +{ + stat = ENABLED; +} +/*---------------------------------------------------------------------------*/ +int_master_status_t +int_master_read_and_disable(void) +{ + int_master_status_t rv = stat; + stat = DISABLED; + return rv; +} +/*---------------------------------------------------------------------------*/ +void +int_master_status_set(int_master_status_t status) +{ + stat = status; +} +/*---------------------------------------------------------------------------*/ +bool +int_master_is_enabled(void) +{ + return stat == DISABLED ? false : true; +} +/*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/native/native-def.h b/arch/cpu/native/native-def.h new file mode 100644 index 000000000..d85ae7100 --- /dev/null +++ b/arch/cpu/native/native-def.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, George Oikonomou - http://www.spd.gr + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/*---------------------------------------------------------------------------*/ +#ifndef NATIVE_DEF_H_ +#define NATIVE_DEF_H_ +/*---------------------------------------------------------------------------*/ +#define GPIO_HAL_CONF_ARCH_SW_TOGGLE 1 +/*---------------------------------------------------------------------------*/ +#endif /* NATIVE_DEF_H_ */ +/*---------------------------------------------------------------------------*/ diff --git a/arch/dev/cc2420/cc2420.c b/arch/dev/cc2420/cc2420.c index 9310ec9e4..5cfa00e4a 100644 --- a/arch/dev/cc2420/cc2420.c +++ b/arch/dev/cc2420/cc2420.c @@ -641,7 +641,7 @@ cc2420_init(void) init_security(); cc2420_set_pan_addr(0xffff, 0x0000, NULL); - cc2420_set_channel(CC2420_CONF_CHANNEL); + cc2420_set_channel(IEEE802154_DEFAULT_CHANNEL); cc2420_set_cca_threshold(CC2420_CONF_CCA_THRESH); flushrx(); diff --git a/arch/dev/cc2420/cc2420.h b/arch/dev/cc2420/cc2420.h index a030632a6..07b578aa4 100644 --- a/arch/dev/cc2420/cc2420.h +++ b/arch/dev/cc2420/cc2420.h @@ -50,10 +50,6 @@ #define WITH_SEND_CCA 1 -#ifndef CC2420_CONF_CHANNEL -#define CC2420_CONF_CHANNEL 26 -#endif /* CC2420_CONF_CHANNEL */ - #ifndef CC2420_CONF_CCA_THRESH #define CC2420_CONF_CCA_THRESH -45 #endif /* CC2420_CONF_CCA_THRESH */ diff --git a/arch/dev/ext-flash/ext-flash.c b/arch/dev/ext-flash/ext-flash.c index 547ec062c..10e953ffa 100644 --- a/arch/dev/ext-flash/ext-flash.c +++ b/arch/dev/ext-flash/ext-flash.c @@ -113,13 +113,15 @@ static spi_device_t flash_spi_configuration_default = { /** * Get spi configuration, return default configuration if NULL */ -static spi_device_t* -get_spi_conf(spi_device_t *conf) { +static spi_device_t * +get_spi_conf(spi_device_t *conf) +{ if(conf == NULL) { return &flash_spi_configuration_default; } return conf; -}/*---------------------------------------------------------------------------*/ +} +/*---------------------------------------------------------------------------*/ /** * Clear external flash CSN line */ @@ -334,7 +336,7 @@ ext_flash_open(spi_device_t *conf) /* Put the part is standby mode */ power_standby(flash_spi_configuration); - if (verify_part(flash_spi_configuration) == VERIFY_PART_OK) { + if(verify_part(flash_spi_configuration) == VERIFY_PART_OK) { return true; } @@ -353,7 +355,7 @@ ext_flash_close(spi_device_t *conf) /* Put the part in low power mode */ ret = power_down(flash_spi_configuration); - + /* SPI is released no matter if power_down() succeeds or fails */ if(spi_release(flash_spi_configuration) != SPI_DEV_STATUS_OK) { return false; @@ -474,7 +476,7 @@ ext_flash_erase(spi_device_t *conf, uint32_t offset, uint32_t length) uint8_t wbuf[4]; uint32_t i, numsectors; uint32_t endoffset = offset + length - 1; - + spi_device_t *flash_spi_configuration; flash_spi_configuration = get_spi_conf(conf); diff --git a/arch/platform/cc2538dk/Makefile.cc2538dk b/arch/platform/cc2538dk/Makefile.cc2538dk index c452ccfaf..d80fd8d5f 100644 --- a/arch/platform/cc2538dk/Makefile.cc2538dk +++ b/arch/platform/cc2538dk/Makefile.cc2538dk @@ -37,3 +37,17 @@ else sort -g | head -1)) $(PYTHON) $(BSL) $(BSL_FLAGS) $(BSL_ADDRESS_ARG) $< endif + +ifeq ($(HOST_OS),Darwin) + RENODE = mono /Applications/Renode.app/Contents/MacOS/bin/Renode.exe +else + RENODE = renode +endif + +SCRIPT ?= $(notdir $(CURDIR)).resc + +.PHONY: renode + +renode: all + $(RENODE) $(SCRIPT) + diff --git a/arch/platform/cc2538dk/dev/leds-arch.c b/arch/platform/cc2538dk/dev/leds-arch.c index c849355b4..78441defc 100644 --- a/arch/platform/cc2538dk/dev/leds-arch.c +++ b/arch/platform/cc2538dk/dev/leds-arch.c @@ -57,5 +57,3 @@ const leds_t leds_arch_leds[] = { #endif }; /*---------------------------------------------------------------------------*/ - - diff --git a/arch/platform/cc2538dk/platform.c b/arch/platform/cc2538dk/platform.c index bf945bfdd..2a3ca21ed 100644 --- a/arch/platform/cc2538dk/platform.c +++ b/arch/platform/cc2538dk/platform.c @@ -106,7 +106,7 @@ set_rf_params(void) NETSTACK_RADIO.set_value(RADIO_PARAM_PAN_ID, IEEE802154_PANID); NETSTACK_RADIO.set_value(RADIO_PARAM_16BIT_ADDR, short_addr); - NETSTACK_RADIO.set_value(RADIO_PARAM_CHANNEL, CC2538_RF_CHANNEL); + NETSTACK_RADIO.set_value(RADIO_PARAM_CHANNEL, IEEE802154_DEFAULT_CHANNEL); NETSTACK_RADIO.set_object(RADIO_PARAM_64BIT_ADDR, ext_addr, 8); } /*---------------------------------------------------------------------------*/ diff --git a/arch/platform/cooja/contiki-conf.h b/arch/platform/cooja/contiki-conf.h index cf7bdbbd3..4942b0ab6 100644 --- a/arch/platform/cooja/contiki-conf.h +++ b/arch/platform/cooja/contiki-conf.h @@ -118,8 +118,9 @@ typedef unsigned short uip_stats_t; #define CLOCK_CONF_SECOND 1000L typedef unsigned long clock_time_t; -typedef uint64_t rtimer_clock_t; -#define RTIMER_CLOCK_DIFF(a,b) ((int64_t)((a)-(b))) + +/* Use 64-bit rtimer (default in Contiki-NG is 32) */ +#define RTIMER_CONF_CLOCK_SIZE 8 #define RADIO_DELAY_BEFORE_TX 0 #define RADIO_DELAY_BEFORE_RX 0 @@ -138,7 +139,6 @@ typedef uint64_t rtimer_clock_t; #define CFS_CONF_OFFSET_TYPE long -#define RF_CHANNEL 26 #define NETSTACK_RADIO_MAX_PAYLOAD_LEN 125 #define PLATFORM_CONF_SUPPORTS_STACK_CHECK 0 diff --git a/arch/platform/jn516x/Makefile.jn516x b/arch/platform/jn516x/Makefile.jn516x index 9f7a31adf..bb40b5638 100644 --- a/arch/platform/jn516x/Makefile.jn516x +++ b/arch/platform/jn516x/Makefile.jn516x @@ -180,12 +180,12 @@ else ifeq ($(HOST_OS),Darwin) USBDEVPREFIX= USBDEVBASENAME=/dev/tty.usbserial- - SERIALDUMP ?= $(CONTIKI)/tools/jn516x/serialdump-macos + SERIALDUMP ?= rlwrap $(CONTIKI)/tools/jn516x/serialdump-macos else # Else we assume Linux USBDEVPREFIX= USBDEVBASENAME=/dev/ttyUSB - SERIALDUMP ?= $(CONTIKI)/tools/jn516x/serialdump-linux + SERIALDUMP ?= rlwrap $(CONTIKI)/tools/jn516x/serialdump-linux endif endif diff --git a/arch/platform/jn516x/contiki-conf.h b/arch/platform/jn516x/contiki-conf.h index f8dbdc3e5..e4d741400 100644 --- a/arch/platform/jn516x/contiki-conf.h +++ b/arch/platform/jn516x/contiki-conf.h @@ -40,14 +40,6 @@ #include "jn516x-def.h" -#ifdef RF_CHANNEL -#define MICROMAC_CONF_CHANNEL RF_CHANNEL -#endif - -#ifndef MICROMAC_CONF_CHANNEL -#define MICROMAC_CONF_CHANNEL 26 -#endif - /* Configure radio driver */ #ifndef NETSTACK_CONF_RADIO #define NETSTACK_CONF_RADIO micromac_radio_driver diff --git a/arch/platform/jn516x/dev/micromac-radio.c b/arch/platform/jn516x/dev/micromac-radio.c index 3ebc13578..6e2ddb908 100644 --- a/arch/platform/jn516x/dev/micromac-radio.c +++ b/arch/platform/jn516x/dev/micromac-radio.c @@ -100,11 +100,6 @@ #define MIRCOMAC_CONF_BUF_NUM 2 #endif /* MIRCOMAC_CONF_BUF_NUM */ -/* Init radio channel */ -#ifndef MICROMAC_CONF_CHANNEL -#define MICROMAC_CONF_CHANNEL 26 -#endif - /* Default energy level threshold for clear channel detection */ #ifndef MICROMAC_CONF_CCA_THR #define MICROMAC_CONF_CCA_THR 39 /* approximately -85 dBm */ @@ -159,7 +154,7 @@ static uint8_t autoack_enabled = MICROMAC_CONF_AUTOACK; static uint8_t send_on_cca = 0; /* Current radio channel */ -static int current_channel = MICROMAC_CONF_CHANNEL; +static int current_channel = IEEE802154_DEFAULT_CHANNEL; /* Current set point tx power Actual tx power may be different. Use get_txpower() for actual power */ diff --git a/arch/platform/jn516x/dev/rtimer-arch.h b/arch/platform/jn516x/dev/rtimer-arch.h index 3ffafeeac..63212566b 100644 --- a/arch/platform/jn516x/dev/rtimer-arch.h +++ b/arch/platform/jn516x/dev/rtimer-arch.h @@ -43,19 +43,15 @@ #include "sys/rtimer.h" -#ifdef RTIMER_CONF_SECOND -# define RTIMER_ARCH_SECOND RTIMER_CONF_SECOND -#else #if RTIMER_USE_32KHZ -# if JN516X_EXTERNAL_CRYSTAL_OSCILLATOR -# define RTIMER_ARCH_SECOND 32768 -# else -# define RTIMER_ARCH_SECOND 32000 +#if JN516X_EXTERNAL_CRYSTAL_OSCILLATOR +#define RTIMER_ARCH_SECOND 32768 +#else +#define RTIMER_ARCH_SECOND 32000 #endif #else /* 32MHz CPU clock => 16MHz timer */ -# define RTIMER_ARCH_SECOND (F_CPU / 2) -#endif +#define RTIMER_ARCH_SECOND (F_CPU / 2) #endif #if RTIMER_USE_32KHZ diff --git a/arch/platform/jn516x/jn516x-def.h b/arch/platform/jn516x/jn516x-def.h index 0c76a4332..a4ee45c75 100644 --- a/arch/platform/jn516x/jn516x-def.h +++ b/arch/platform/jn516x/jn516x-def.h @@ -79,10 +79,6 @@ #define JN516X_EXTERNAL_CRYSTAL_OSCILLATOR (RTIMER_USE_32KHZ || JN516X_SLEEP_ENABLED) #endif /* JN516X_EXTERNAL_CRYSTAL_OSCILLATOR */ -/* Core rtimer.h defaults to 16 bit timer unless RTIMER_CLOCK_DIFF is defined */ -typedef uint32_t rtimer_clock_t; -#define RTIMER_CLOCK_DIFF(a, b) ((int32_t)((a) - (b))) - /* 8ms timer tick */ #define CLOCK_CONF_SECOND 125 diff --git a/arch/platform/native/Makefile.native b/arch/platform/native/Makefile.native index 24f433796..afeddd22f 100644 --- a/arch/platform/native/Makefile.native +++ b/arch/platform/native/Makefile.native @@ -2,15 +2,12 @@ ifndef CONTIKI $(error CONTIKI not defined! You must specify where CONTIKI resides!) endif -ifeq ($(HOST_OS),Darwin) - AROPTS = rc -endif CONTIKI_TARGET_DIRS = . dev CONTIKI_TARGET_MAIN = ${addprefix $(OBJECTDIR)/,contiki-main.o} -CONTIKI_TARGET_SOURCEFILES += platform.c clock.c xmem.c leds-arch.c -CONTIKI_TARGET_SOURCEFILES += cfs-posix.c cfs-posix-dir.c +CONTIKI_TARGET_SOURCEFILES += platform.c clock.c xmem.c +CONTIKI_TARGET_SOURCEFILES += cfs-posix.c cfs-posix-dir.c buttons.c ifeq ($(HOST_OS),Windows) CONTIKI_TARGET_SOURCEFILES += wpcap-drv.c wpcap.c diff --git a/arch/platform/native/contiki-conf.h b/arch/platform/native/contiki-conf.h index ea1383660..8d2c13820 100644 --- a/arch/platform/native/contiki-conf.h +++ b/arch/platform/native/contiki-conf.h @@ -37,7 +37,9 @@ #ifdef PROJECT_CONF_PATH #include PROJECT_CONF_PATH #endif /* PROJECT_CONF_PATH */ - +/*---------------------------------------------------------------------------*/ +#include "native-def.h" +/*---------------------------------------------------------------------------*/ #include #ifndef WIN32_LEAN_AND_MEAN #include @@ -60,8 +62,6 @@ int select_set_callback(int fd, const struct select_callback *callback); typedef unsigned int uip_stats_t; -#define LEDS_CONF_LEGACY_API 1 - #ifndef UIP_CONF_BYTE_ORDER #define UIP_CONF_BYTE_ORDER UIP_LITTLE_ENDIAN #endif @@ -91,6 +91,8 @@ typedef unsigned long clock_time_t; #define LOG_CONF_ENABLED 1 +#define PLATFORM_SUPPORTS_BUTTON_HAL 1 + /* Not part of C99 but actually present */ int strcasecmp(const char*, const char*); diff --git a/arch/platform/native/dev/buttons.c b/arch/platform/native/dev/buttons.c new file mode 100644 index 000000000..359f7a409 --- /dev/null +++ b/arch/platform/native/dev/buttons.c @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2018, George Oikonomou - http://www.spd.gr + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/*---------------------------------------------------------------------------*/ +#include "contiki.h" +#include "dev/button-hal.h" + +#include +#include +/*---------------------------------------------------------------------------*/ +button_hal_button_t *button_hal_buttons[] = { NULL }; +const uint8_t button_hal_button_count = 0; +/*---------------------------------------------------------------------------*/ diff --git a/arch/platform/native/platform.c b/arch/platform/native/platform.c index fceab0207..c5c4f23e7 100644 --- a/arch/platform/native/platform.c +++ b/arch/platform/native/platform.c @@ -56,6 +56,9 @@ #include "net/netstack.h" #include "dev/serial-line.h" +#include "dev/button-hal.h" +#include "dev/gpio-hal.h" +#include "dev/leds.h" #include "net/ipv6/uip.h" #include "net/ipv6/uip-debug.h" @@ -251,6 +254,9 @@ platform_process_args(int argc, char**argv) void platform_init_stage_one() { + gpio_hal_init(); + button_hal_init(); + leds_init(); return; } /*---------------------------------------------------------------------------*/ diff --git a/arch/platform/openmote-cc2538/dev/leds-arch.c b/arch/platform/openmote-cc2538/dev/leds-arch.c index 2bc13bed8..3c1fe333f 100644 --- a/arch/platform/openmote-cc2538/dev/leds-arch.c +++ b/arch/platform/openmote-cc2538/dev/leds-arch.c @@ -54,5 +54,3 @@ const leds_t leds_arch_leds[] = { }, }; /*---------------------------------------------------------------------------*/ - - diff --git a/arch/platform/openmote-cc2538/platform.c b/arch/platform/openmote-cc2538/platform.c index c226785c6..4656d2332 100644 --- a/arch/platform/openmote-cc2538/platform.c +++ b/arch/platform/openmote-cc2538/platform.c @@ -115,7 +115,7 @@ set_rf_params(void) NETSTACK_RADIO.set_value(RADIO_PARAM_PAN_ID, IEEE802154_PANID); NETSTACK_RADIO.set_value(RADIO_PARAM_16BIT_ADDR, short_addr); - NETSTACK_RADIO.set_value(RADIO_PARAM_CHANNEL, CC2538_RF_CHANNEL); + NETSTACK_RADIO.set_value(RADIO_PARAM_CHANNEL, IEEE802154_DEFAULT_CHANNEL); NETSTACK_RADIO.set_object(RADIO_PARAM_64BIT_ADDR, ext_addr, 8); } /*---------------------------------------------------------------------------*/ diff --git a/arch/platform/sky/Makefile.common b/arch/platform/sky/Makefile.common index 081ffaa9f..3d688b573 100644 --- a/arch/platform/sky/Makefile.common +++ b/arch/platform/sky/Makefile.common @@ -54,7 +54,7 @@ else ifeq ($(HOST_OS),Darwin) ifndef MOTELIST USBDEVPREFIX= - SERIALDUMP = $(CONTIKI)/tools/sky/serialdump-macos + SERIALDUMP = rlwrap $(CONTIKI)/tools/sky/serialdump-macos MOTELIST = $(CONTIKI)/tools/sky/motelist-macos TMOTE_BSL_FILE = tmote-bsl-linux TMOTE_BSL=$(if $(wildcard $(CONTIKI)/tools/sky/$(TMOTE_BSL_FILE)),1,0) @@ -75,7 +75,7 @@ else # Else we assume Linux ifndef MOTELIST USBDEVPREFIX= - SERIALDUMP = $(CONTIKI)/tools/sky/serialdump-linux + SERIALDUMP = rlwrap $(CONTIKI)/tools/sky/serialdump-linux MOTELIST = $(CONTIKI)/tools/sky/motelist-linux TMOTE_BSL_FILE = tmote-bsl-linux TMOTE_BSL=$(if $(wildcard $(CONTIKI)/tools/sky/$(TMOTE_BSL_FILE)),1,0) diff --git a/arch/platform/sky/contiki-conf.h b/arch/platform/sky/contiki-conf.h index 500e00e08..8df4549ef 100644 --- a/arch/platform/sky/contiki-conf.h +++ b/arch/platform/sky/contiki-conf.h @@ -11,10 +11,6 @@ #include "sky-def.h" #include "msp430-def.h" /*---------------------------------------------------------------------------*/ -/* Map RF_CHANNEL to cc2420 default channel */ -#ifdef RF_CHANNEL -#define CC2420_CONF_CHANNEL RF_CHANNEL -#endif /* RF_CHANNEL */ /* Configure radio driver */ #ifndef NETSTACK_CONF_RADIO diff --git a/arch/platform/sky/platform.c b/arch/platform/sky/platform.c index d71471340..deaa53b5a 100644 --- a/arch/platform/sky/platform.c +++ b/arch/platform/sky/platform.c @@ -204,15 +204,7 @@ platform_init_stage_three(void) LOG_INFO("Node id: N/A\n"); } -#if NETSTACK_CONF_WITH_IPV6 - LOG_INFO("%s, rf channel %u, CCA threshold %i\n", - NETSTACK_MAC.name, - CC2420_CONF_CHANNEL, - CC2420_CONF_CCA_THRESH); -#else /* NETSTACK_CONF_WITH_IPV6 */ - LOG_INFO("%s, rf channel %u\n", - NETSTACK_MAC.name, CC2420_CONF_CHANNEL); -#endif /* NETSTACK_CONF_WITH_IPV6 */ + LOG_INFO("CC2420 CCA threshold %i\n", CC2420_CONF_CCA_THRESH); #if !NETSTACK_CONF_WITH_IPV6 uart1_set_input(serial_line_input_byte); diff --git a/arch/platform/srf06-cc26xx/cfs-coffee-arch.h b/arch/platform/srf06-cc26xx/cfs-coffee-arch.h index 33cc5123b..6816ca043 100644 --- a/arch/platform/srf06-cc26xx/cfs-coffee-arch.h +++ b/arch/platform/srf06-cc26xx/cfs-coffee-arch.h @@ -43,44 +43,41 @@ #include "contiki-conf.h" #include "dev/xmem.h" -/*** MX25R8035F Memory Organization -The memory is organized as: -8Mbit = 1048576 bytes (8 bits each) -256 sectors (32 Kbits, 4096 bytes each) -4096 pages (256 bytes each). -Each page can be individually programmed (bits are programmed from 1 to 0). The device is -sector or bulk erasable (bits are erased from 0 to 1) but not page erasable -*/ -#define COFFEE_XMEM_TOTAL_SIZE_KB 1024UL //Total size of the External Flash Memory in the Z1 +/* + * MX25R8035F Memory Organization + * The memory is organized as: + * 8Mbit = 1048576 bytes (8 bits each) + * 256 sectors (32 Kbits, 4096 bytes each) + * 4096 pages (256 bytes each). + * Each page can be individually programmed (bits are programmed from 1 to 0). + * The device is sector or bulk erasable (bits are erased from 0 to 1) but not + * page erasable + */ +#define COFFEE_XMEM_TOTAL_SIZE_KB 1024UL /* Total size of the External Flash Memory in the Z1 */ /* Coffee configuration parameters. */ -#define COFFEE_SECTOR_SIZE 4096UL +#define COFFEE_SECTOR_SIZE 4096UL #define COFFEE_PAGE_SIZE 256UL -#define COFFEE_START 0UL //COFFEE_SECTOR_SIZE +#define COFFEE_START 0UL /* COFFEE_SECTOR_SIZE */ #define COFFEE_SIZE (COFFEE_XMEM_TOTAL_SIZE_KB * 1024UL - COFFEE_START) #define COFFEE_NAME_LENGTH 16 #define COFFEE_MAX_OPEN_FILES 6 #define COFFEE_FD_SET_SIZE 8 #define COFFEE_LOG_TABLE_LIMIT 256 -#define COFFEE_DYN_SIZE 2*1024 +#define COFFEE_DYN_SIZE 2 * 1024 #define COFFEE_LOG_SIZE 1024 #define COFFEE_MICRO_LOGS 1 - - - - - /* Flash operations. */ -#define COFFEE_WRITE(buf, size, offset) \ - xmem_pwrite((char *)(buf), (size), COFFEE_START + (offset)) +#define COFFEE_WRITE(buf, size, offset) \ + xmem_pwrite((char *)(buf), (size), COFFEE_START + (offset)) -#define COFFEE_READ(buf, size, offset) \ - xmem_pread((char *)(buf), (size), COFFEE_START + (offset)) +#define COFFEE_READ(buf, size, offset) \ + xmem_pread((char *)(buf), (size), COFFEE_START + (offset)) -#define COFFEE_ERASE(sector) \ - xmem_erase(COFFEE_SECTOR_SIZE, COFFEE_START + (sector) * COFFEE_SECTOR_SIZE) +#define COFFEE_ERASE(sector) \ + xmem_erase(COFFEE_SECTOR_SIZE, COFFEE_START + (sector) * COFFEE_SECTOR_SIZE) /* Coffee types. */ typedef int16_t coffee_page_t; diff --git a/arch/platform/srf06-cc26xx/common/xmem.c b/arch/platform/srf06-cc26xx/common/xmem.c index 116991c66..9228e0fbb 100644 --- a/arch/platform/srf06-cc26xx/common/xmem.c +++ b/arch/platform/srf06-cc26xx/common/xmem.c @@ -49,21 +49,17 @@ #define XMEM_BUFF_LENGHT 128 - #if 0 #define PRINTF(...) printf(__VA_ARGS__) #else -#define PRINTF(...) do {} while (0) +#define PRINTF(...) do {} while(0) #endif - void xmem_init(void) { ext_flash_open(NULL); } - - int xmem_pread(void *_p, int size, unsigned long addr) { @@ -80,21 +76,20 @@ xmem_pread(void *_p, int size, unsigned long addr) } rv = ext_flash_read(NULL, addr, size, _p); - for (i = 0; i < size; i++){ + for(i = 0; i < size; i++) { x = ~*((uint8_t *)_p + i); - *((uint8_t *)_p+i) = x; + *((uint8_t *)_p + i) = x; } ext_flash_close(NULL); - if(rv) + if(rv) { return size; + } PRINTF("Could not read flash memory!\n"); return -1; -} - - +} int xmem_pwrite(const void *_buf, int size, unsigned long addr) { @@ -112,13 +107,13 @@ xmem_pwrite(const void *_buf, int size, unsigned long addr) return -1; } - for (remain = size, j = 0; remain > 0; remain -= XMEM_BUFF_LENGHT, j += XMEM_BUFF_LENGHT) { + for(remain = size, j = 0; remain > 0; remain -= XMEM_BUFF_LENGHT, j += XMEM_BUFF_LENGHT) { int to_write = MIN(XMEM_BUFF_LENGHT, remain); - for (i = 0; i < to_write; i++) { + for(i = 0; i < to_write; i++) { tmp_buf[i] = ~*((uint8_t *)_buf + j + i); } rv = ext_flash_write(NULL, addr + j, to_write, tmp_buf); - if (!rv) { + if(!rv) { PRINTF("Could not write flash memory!\n"); return size - remain; } @@ -128,8 +123,6 @@ xmem_pwrite(const void *_buf, int size, unsigned long addr) return size; } - - int xmem_erase(long size, unsigned long addr) { @@ -137,7 +130,6 @@ xmem_erase(long size, unsigned long addr) rv = ext_flash_open(NULL); - if(!rv) { PRINTF("Could not open flash to save config\n"); ext_flash_close(NULL); @@ -160,8 +152,9 @@ xmem_erase(long size, unsigned long addr) watchdog_periodic(); - if(rv) + if(rv) { return size; + } PRINTF("Could not erase flash memory\n"); return -1; diff --git a/arch/platform/srf06-cc26xx/launchpad/leds-arch.c b/arch/platform/srf06-cc26xx/launchpad/leds-arch.c index 5d70dea40..3c483d3bd 100644 --- a/arch/platform/srf06-cc26xx/launchpad/leds-arch.c +++ b/arch/platform/srf06-cc26xx/launchpad/leds-arch.c @@ -41,5 +41,3 @@ const leds_t leds_arch_leds[] = { { .pin = BOARD_IOID_LED_2, .negative_logic = false }, }; /*---------------------------------------------------------------------------*/ - - diff --git a/arch/platform/srf06-cc26xx/platform.c b/arch/platform/srf06-cc26xx/platform.c index bfda15dad..362b9614e 100644 --- a/arch/platform/srf06-cc26xx/platform.c +++ b/arch/platform/srf06-cc26xx/platform.c @@ -128,7 +128,7 @@ set_rf_params(void) NETSTACK_RADIO.set_value(RADIO_PARAM_PAN_ID, IEEE802154_PANID); NETSTACK_RADIO.set_value(RADIO_PARAM_16BIT_ADDR, short_addr); - NETSTACK_RADIO.set_value(RADIO_PARAM_CHANNEL, RF_CORE_CHANNEL); + NETSTACK_RADIO.set_value(RADIO_PARAM_CHANNEL, IEEE802154_DEFAULT_CHANNEL); NETSTACK_RADIO.set_object(RADIO_PARAM_64BIT_ADDR, ext_addr, 8); /* also set the global node id */ diff --git a/arch/platform/srf06-cc26xx/sensortag/cc1350/leds-arch.c b/arch/platform/srf06-cc26xx/sensortag/cc1350/leds-arch.c index 21b8cf968..8da95520f 100644 --- a/arch/platform/srf06-cc26xx/sensortag/cc1350/leds-arch.c +++ b/arch/platform/srf06-cc26xx/sensortag/cc1350/leds-arch.c @@ -39,5 +39,3 @@ const leds_t leds_arch_leds[] = { { .pin = BOARD_IOID_LED_1, .negative_logic = false }, }; /*---------------------------------------------------------------------------*/ - - diff --git a/arch/platform/srf06-cc26xx/sensortag/cc2650/leds-arch.c b/arch/platform/srf06-cc26xx/sensortag/cc2650/leds-arch.c index cab4888b7..ac4abb7d5 100644 --- a/arch/platform/srf06-cc26xx/sensortag/cc2650/leds-arch.c +++ b/arch/platform/srf06-cc26xx/sensortag/cc2650/leds-arch.c @@ -40,5 +40,3 @@ const leds_t leds_arch_leds[] = { { .pin = BOARD_IOID_LED_2, .negative_logic = false }, }; /*---------------------------------------------------------------------------*/ - - diff --git a/arch/platform/srf06-cc26xx/srf06/leds-arch.c b/arch/platform/srf06-cc26xx/srf06/leds-arch.c index fba996b39..f504f9cc2 100644 --- a/arch/platform/srf06-cc26xx/srf06/leds-arch.c +++ b/arch/platform/srf06-cc26xx/srf06/leds-arch.c @@ -42,5 +42,3 @@ const leds_t leds_arch_leds[] = { { .pin = BOARD_IOID_LED_4, .negative_logic = false }, }; /*---------------------------------------------------------------------------*/ - - diff --git a/arch/platform/zoul/Makefile.zoul b/arch/platform/zoul/Makefile.zoul index 586a74ae2..e7e4af709 100644 --- a/arch/platform/zoul/Makefile.zoul +++ b/arch/platform/zoul/Makefile.zoul @@ -56,11 +56,11 @@ ifeq ($(HOST_OS),Darwin) USBDEVPREFIX= MOTELIST := $(CONTIKI)/tools/zolertia/motelist-zolertia-macos MOTES := $(shell $(MOTELIST) -c 2>&- | cut -f 2 -d ,) - SERIALDUMP := $(CONTIKI)/tools/sky/serialdump-macos + SERIALDUMP := rlwrap $(CONTIKI)/tools/sky/serialdump-macos else ### If we are not running under Mac, we assume Linux USBDEVPREFIX= - SERIALDUMP := $(CONTIKI)/tools/sky/serialdump-linux + SERIALDUMP := rlwrap $(CONTIKI)/tools/sky/serialdump-linux MOTELIST := $(CONTIKI)/tools/zolertia/motelist-zolertia MOTES := $(shell $(MOTELIST) -b $(MOTELIST_ZOLERTIA) -c 2>&- | cut -f 2 -d , | \ perl -ne 'print $$1 . " " if(m-(/dev/\w+)-);') diff --git a/arch/platform/zoul/dev/dht22.c b/arch/platform/zoul/dev/dht22.c index f12859dff..e5d14d53b 100644 --- a/arch/platform/zoul/dev/dht22.c +++ b/arch/platform/zoul/dev/dht22.c @@ -72,7 +72,7 @@ dht22_read(void) { uint8_t i; uint8_t j = 0; - uint8_t last_state; + uint8_t last_state = 0xFF; uint8_t counter = 0; uint8_t checksum = 0; @@ -95,7 +95,6 @@ dht22_read(void) * if the line is high between 70-74us the bit sent will be "1" (one). */ GPIO_SET_INPUT(DHT22_PORT_BASE, DHT22_PIN_MASK); - last_state = GPIO_READ_PIN(DHT22_PORT_BASE, DHT22_PIN_MASK); for(i = 0; i < DHT22_MAX_TIMMING; i++) { counter = 0; @@ -208,8 +207,8 @@ value(int type) } } /*---------------------------------------------------------------------------*/ -int -dht22_read_all(int *temperature, int *humidity) +int16_t +dht22_read_all(int16_t *temperature, int16_t *humidity) { if((temperature == NULL) || (humidity == NULL)) { PRINTF("DHT22: Invalid arguments\n"); diff --git a/arch/platform/zoul/dev/dht22.h b/arch/platform/zoul/dev/dht22.h index f75a96494..ecd02a26e 100644 --- a/arch/platform/zoul/dev/dht22.h +++ b/arch/platform/zoul/dev/dht22.h @@ -90,7 +90,7 @@ #define DHT22_COUNT 8 /**< Minimum ticks to detect a "1" bit */ #define DHT22_MAX_TIMMING 85 /**< Maximum ticks in a single operation */ #define DHT22_READING_DELAY 1 /**< 1 us */ -#define DHT22_READY_TIME 20 /**< 40 us */ +#define DHT22_READY_TIME 40 /**< 40 us */ #define DHT22_START_TIME (RTIMER_SECOND / 50) /**< 20 ms */ #define DHT22_AWAKE_TIME (RTIMER_SECOND / 4) /**< 250 ms */ /** @} */ @@ -99,7 +99,7 @@ * \name DHT22 auxiliary functions * @{ */ -int dht22_read_all(int *temperature, int *humidity); +int16_t dht22_read_all(int16_t *temperature, int16_t *humidity); /** @} */ /* -------------------------------------------------------------------------- */ #define DHT22_SENSOR "DHT22 sensor" diff --git a/arch/platform/zoul/dev/leds-arch.c b/arch/platform/zoul/dev/leds-arch.c index eea4187c0..ecb02b2f6 100644 --- a/arch/platform/zoul/dev/leds-arch.c +++ b/arch/platform/zoul/dev/leds-arch.c @@ -50,5 +50,3 @@ const leds_t leds_arch_leds[] = { }, }; /*---------------------------------------------------------------------------*/ - - diff --git a/arch/platform/zoul/platform.c b/arch/platform/zoul/platform.c index 8cce149ee..703f0e521 100644 --- a/arch/platform/zoul/platform.c +++ b/arch/platform/zoul/platform.c @@ -171,7 +171,7 @@ set_rf_params(void) NETSTACK_RADIO.set_value(RADIO_PARAM_PAN_ID, IEEE802154_PANID); NETSTACK_RADIO.set_value(RADIO_PARAM_16BIT_ADDR, short_addr); - NETSTACK_RADIO.set_value(RADIO_PARAM_CHANNEL, CC2538_RF_CHANNEL); + NETSTACK_RADIO.set_value(RADIO_PARAM_CHANNEL, IEEE802154_DEFAULT_CHANNEL); NETSTACK_RADIO.set_object(RADIO_PARAM_64BIT_ADDR, ext_addr, 8); } /*---------------------------------------------------------------------------*/ diff --git a/examples/6tisch/6p-packet/project-conf.h b/examples/6tisch/6p-packet/project-conf.h index ece485a17..9771fe4b1 100644 --- a/examples/6tisch/6p-packet/project-conf.h +++ b/examples/6tisch/6p-packet/project-conf.h @@ -28,8 +28,8 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _PROJECT_CONF_H_ -#define _PROJECT_CONF_H_ +#ifndef PROJECT_CONF_H_ +#define PROJECT_CONF_H_ #define UIP_CONF_ND6_SEND_RA 0 @@ -39,4 +39,4 @@ #define LOG_CONF_LEVEL_6TOP LOG_LEVEL_DBG -#endif /* _PROJECT_CONF_H_ */ +#endif /* PROJECT_CONF_H_ */ diff --git a/examples/6tisch/etsi-plugtest-2017/project-conf.h b/examples/6tisch/etsi-plugtest-2017/project-conf.h index 971f9020d..93c5925b6 100644 --- a/examples/6tisch/etsi-plugtest-2017/project-conf.h +++ b/examples/6tisch/etsi-plugtest-2017/project-conf.h @@ -32,8 +32,8 @@ * \author Simon Duquennoy */ -#ifndef __PROJECT_CONF_H__ -#define __PROJECT_CONF_H__ +#ifndef PROJECT_CONF_H_ +#define PROJECT_CONF_H_ /* Set to enable TSCH security */ #ifndef WITH_SECURITY @@ -115,4 +115,4 @@ #define LOG_CONF_LEVEL_6TOP LOG_LEVEL_DBG #define TSCH_LOG_CONF_PER_SLOT 1 -#endif /* __PROJECT_CONF_H__ */ +#endif /* PROJECT_CONF_H_ */ diff --git a/examples/6tisch/simple-node/project-conf.h b/examples/6tisch/simple-node/project-conf.h index f77e63706..3771fb50f 100644 --- a/examples/6tisch/simple-node/project-conf.h +++ b/examples/6tisch/simple-node/project-conf.h @@ -32,8 +32,8 @@ * \author Simon Duquennoy */ -#ifndef __PROJECT_CONF_H__ -#define __PROJECT_CONF_H__ +#ifndef PROJECT_CONF_H_ +#define PROJECT_CONF_H_ /* Set to enable TSCH security */ #ifndef WITH_SECURITY @@ -78,4 +78,4 @@ #define LOG_CONF_LEVEL_FRAMER LOG_LEVEL_DBG #define TSCH_LOG_CONF_PER_SLOT 1 -#endif /* __PROJECT_CONF_H__ */ +#endif /* PROJECT_CONF_H_ */ diff --git a/examples/6tisch/sixtop/project-conf.h b/examples/6tisch/sixtop/project-conf.h index 7f416342e..5235353c2 100755 --- a/examples/6tisch/sixtop/project-conf.h +++ b/examples/6tisch/sixtop/project-conf.h @@ -28,8 +28,8 @@ * */ -#ifndef __PROJECT_CONF_H__ -#define __PROJECT_CONF_H__ +#ifndef PROJECT_CONF_H_ +#define PROJECT_CONF_H_ /* Set to enable TSCH security */ #ifndef WITH_SECURITY @@ -103,4 +103,4 @@ #endif /* CONTIKI_TARGET_CC2538DK || CONTIKI_TARGET_ZOUL \ || CONTIKI_TARGET_OPENMOTE_CC2538 */ -#endif /* __PROJECT_CONF_H__ */ +#endif /* PROJECT_CONF_H_ */ diff --git a/examples/coap/Makefile b/examples/coap/Makefile deleted file mode 100644 index 1195a37a3..000000000 --- a/examples/coap/Makefile +++ /dev/null @@ -1,38 +0,0 @@ -CONTIKI_PROJECT = coap-example-server coap-example-client -# use target "plugtest-server" explicitly when required - -all: $(CONTIKI_PROJECT) - -CONTIKI=../.. - -# Do not try to build on Sky because of code size limitation -PLATFORMS_EXCLUDE = sky - -# build RESTful resources -include $(CONTIKI)/Makefile.identify-target -ifeq ($(TARGET),native) - MODULES_REL += ./resources-plugtest -endif -MODULES_REL += ./resources -MODULES_REL += $(TARGET) - -# Include the CoAP implementation -MODULES += os/net/app-layer/coap - -include $(CONTIKI)/Makefile.include - -# border router rules -$(CONTIKI)/tools/tunslip6: $(CONTIKI)/tools/tunslip6.c - (cd $(CONTIKI)/tools && $(MAKE) tunslip6) - -connect-router: $(CONTIKI)/tools/tunslip6 - sudo $(CONTIKI)/tools/tunslip6 fd00::1/64 - -connect-router-cooja: $(CONTIKI)/tools/tunslip6 - sudo $(CONTIKI)/tools/tunslip6 -a 127.0.0.1 -p 60001 fd00::1/64 - -connect-router-native: $(CONTIKI)/examples/rpl-border-router/border-router.native - sudo $(CONTIKI)/examples/rpl-border-router/border-router.native -a 127.0.0.1 -p 60001 fd00::1/64 - -connect-native: - sudo ip address add fdfd::1/64 dev tun0 diff --git a/examples/coap/README.md b/examples/coap/README.md index 67ba38f26..7d0ac47d2 100644 --- a/examples/coap/README.md +++ b/examples/coap/README.md @@ -1,83 +1,9 @@ -A Quick Introduction to the Erbium (Er) CoAP Engine -=================================================== +# CoAP examples: client, server, and plugtest server -EXAMPLE FILES -------------- +* coap-example-server: A CoAP server example showing how to use the CoAP layer to develop server-side applications. +* coap-example-client: A CoAP client that polls the /actuators/toggle resource every 10 seconds and cycles through 4 resources on button press (target address is hard-coded). +* coap-plugtest-server: The server used for draft compliance testing at ETSI IoT CoAP Plugtests. Erbium (Er) participated in Paris, France, March 2012 and Sophia-Antipolis, France, November 2012 (configured for native). -- coap-example-server.c: A CoAP server example showing how to use the CoAP - layer to develop server-side applications. -- coap-example-client.c: A CoAP client that polls the /actuators/toggle resource - every 10 seconds and cycles through 4 resources on button press (target - address is hard-coded). -- plugtest-server.c: The server used for draft compliance testing at ETSI - IoT CoAP Plugtests. Erbium (Er) participated in Paris, France, March 2012 and - Sophia-Antipolis, France, November 2012 (configured for native). - -PRELIMINARIES -------------- - -- Get the Copper (Cu) CoAP user-agent from - [https://addons.mozilla.org/en-US/firefox/addon/copper-270430](https://addons.mozilla.org/en-US/firefox/addon/copper-270430) - -TMOTE SKY HOWTO ---------------- - -The CoAP example no longer fits in the limited ROM of the Tmote Sky. -Please use a platform with larger ROM instead. - -NATIVE HOWTO ------------- - -With the target native you can test your CoAP applications without -constraints, i.e., with large buffers, debug output, memory protection, etc. -The plugtest-server is thought for the native platform, as it requires -an 1280-byte IP buffer and 1024-byte blocks. - - make TARGET=native plugtest-server - sudo ./plugtest-server.native - -Open new terminal - - make connect-native - -- Start Copper and discover resources at coap://[fdfd::ff:fe00:10]:5683/ -- You can enable the ETSI Plugtest menu in Copper's preferences - -Under Windows/Cygwin, WPCAP might need a patch in -\usr\include\w32api\in6addr.h: - - 21,23c21 - < #ifdef __INSIDE_CYGWIN__ - < uint32_t __s6_addr32[4]; - < #endif - --- - > u_int __s6_addr32[4]; - 36d33 - < #ifdef __INSIDE_CYGWIN__ - 39d35 - < #endif - -DETAILS -------- - -Erbium implements the Proposed Standard of CoAP. Central features are commented -in coap-example-server.c. In general, coap supports: - -- All draft-18 header options -- CON Retransmissions (note COAP_MAX_OPEN_TRANSACTIONS) -- Blockwise Transfers (note COAP_MAX_CHUNK_SIZE, see plugtest-server.c for - Block1 uploads) -- Separate Responses (no rest_set_pre_handler() required anymore, note - coap_separate_accept(), _reject(), and _resume()) -- Resource Discovery -- Observing Resources (see EVENT_ and PERIODIC_RESOURCE, note - COAP_MAX_OBSERVERS) - -TODOs ------ - -- Dedicated Observe buffers -- Optimize message struct variable access (directly access struct without copying) -- Observe client -- Multiple If-Match ETags -- (Message deduplication) +The examples can run either on a real device or as native. +In the latter case, just start the executable with enough permissions (e.g. sudo), and you will then be able to reach the node via tun. +A tutorial for setting up the CoAP server example and querying it is provided on the wiki. diff --git a/examples/coap/coap-example-client/Makefile b/examples/coap/coap-example-client/Makefile new file mode 100644 index 000000000..1d3440990 --- /dev/null +++ b/examples/coap/coap-example-client/Makefile @@ -0,0 +1,12 @@ +CONTIKI_PROJECT = coap-example-client +# coap-example-observe-client is outdated but will be ported at a later point +all: $(CONTIKI_PROJECT) + +# Do not try to build on Sky because of code size limitation +PLATFORMS_EXCLUDE = sky + +# Include the CoAP implementation +MODULES += os/net/app-layer/coap + +CONTIKI=../../.. +include $(CONTIKI)/Makefile.include diff --git a/examples/coap/coap-example-client.c b/examples/coap/coap-example-client/coap-example-client.c similarity index 97% rename from examples/coap/coap-example-client.c rename to examples/coap/coap-example-client/coap-example-client.c index 27efbbf6e..645283093 100644 --- a/examples/coap/coap-example-client.c +++ b/examples/coap/coap-example-client/coap-example-client.c @@ -51,8 +51,8 @@ /* Log configuration */ #include "coap-log.h" -#define LOG_MODULE "client" -#define LOG_LEVEL LOG_LEVEL_COAP +#define LOG_MODULE "App" +#define LOG_LEVEL LOG_LEVEL_APP /* FIXME: This server address is hard-coded for Cooja and link-local for unconnected border router. */ #define SERVER_EP "coap://[fe80::212:7402:0002:0202]" @@ -92,9 +92,6 @@ PROCESS_THREAD(er_example_client, ev, data) coap_endpoint_parse(SERVER_EP, strlen(SERVER_EP), &server_ep); - /* receives all CoAP messages */ - coap_engine_init(); - etimer_set(&et, TOGGLE_INTERVAL * CLOCK_SECOND); #if PLATFORM_HAS_BUTTON diff --git a/examples/coap/coap-example-observe-client.c b/examples/coap/coap-example-client/coap-example-observe-client.c similarity index 94% rename from examples/coap/coap-example-observe-client.c rename to examples/coap/coap-example-client/coap-example-observe-client.c index 1dbed0bd4..3b6eb9871 100644 --- a/examples/coap/coap-example-observe-client.c +++ b/examples/coap/coap-example-client/coap-example-observe-client.c @@ -47,15 +47,11 @@ #else #include "dev/button-sensor.h" #endif -/*----------------------------------------------------------------------------*/ -#define DEBUG 0 -#if DEBUG -#define PRINTF(...) printf(__VA_ARGS__) -#define PRINTFLN(format, ...) printf(format "\n", ##__VA_ARGS__) -#else -#define PRINTF(...) -#define PRINTFLN(...) -#endif + +/* Log configuration */ +#include "sys/log.h" +#define LOG_MODULE "App" +#define LOG_LEVEL LOG_LEVEL_APP /*----------------------------------------------------------------------------*/ /* FIXME: This server address is hard-coded for Cooja */ @@ -145,8 +141,6 @@ PROCESS_THREAD(er_example_observe_client, ev, data) /* store server address in server_ipaddr */ SERVER_NODE(server_ipaddr); - /* receives all CoAP messages */ - coap_init_engine(); /* init timer and button (if available) */ etimer_set(&et, TOGGLE_INTERVAL * CLOCK_SECOND); #if PLATFORM_HAS_BUTTON diff --git a/arch/platform/native/dev/leds-arch.c b/examples/coap/coap-example-client/project-conf.h similarity index 70% rename from arch/platform/native/dev/leds-arch.c rename to examples/coap/coap-example-client/project-conf.h index 07addc84e..7247ea08c 100644 --- a/arch/platform/native/dev/leds-arch.c +++ b/examples/coap/coap-example-client/project-conf.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Swedish Institute of Computer Science. + * Copyright (c) 2013, Institute for Pervasive Computing, ETH Zurich * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -27,34 +27,21 @@ * SUCH DAMAGE. * * This file is part of the Contiki operating system. - * */ /** * \file - * A brief description of what this file is. + * Erbium (Er) example project configuration. * \author - * Adam Dunkels + * Matthias Kovatsch */ -#include "dev/leds.h" -static leds_mask_t leds; -/*---------------------------------------------------------------------------*/ -void -leds_arch_init(void) -{ - leds = 0; -} -/*---------------------------------------------------------------------------*/ -leds_mask_t -leds_arch_get(void) -{ - return leds; -} -/*---------------------------------------------------------------------------*/ -void -leds_arch_set(leds_mask_t l) -{ - leds = l; -} -/*---------------------------------------------------------------------------*/ +#ifndef PROJECT_CONF_H_ +#define PROJECT_CONF_H_ + +#define LOG_LEVEL_APP LOG_LEVEL_DBG + +/* Enable client-side support for COAP observe */ +#define COAP_OBSERVE_CLIENT 1 + +#endif /* PROJECT_CONF_H_ */ diff --git a/examples/coap/coap-example-server/Makefile b/examples/coap/coap-example-server/Makefile new file mode 100644 index 000000000..6d9e2db85 --- /dev/null +++ b/examples/coap/coap-example-server/Makefile @@ -0,0 +1,14 @@ +CONTIKI_PROJECT = coap-example-server +all: $(CONTIKI_PROJECT) + +# Do not try to build on Sky because of code size limitation +PLATFORMS_EXCLUDE = sky + +# Include the CoAP implementation +MODULES += os/net/app-layer/coap + +# Include CoAP resources +MODULES_REL += ./resources + +CONTIKI=../../.. +include $(CONTIKI)/Makefile.include diff --git a/examples/coap/coap-example-server.c b/examples/coap/coap-example-server/coap-example-server.c similarity index 75% rename from examples/coap/coap-example-server.c rename to examples/coap/coap-example-server/coap-example-server.c index 41ea53744..f32b743f7 100644 --- a/examples/coap/coap-example-server.c +++ b/examples/coap/coap-example-server/coap-example-server.c @@ -48,14 +48,10 @@ #include "dev/button-sensor.h" #endif -#define DEBUG 0 -#if DEBUG -#include -#define PRINTF(...) printf(__VA_ARGS__) -#else -#define PRINTF(...) -#endif - +/* Log configuration */ +#include "sys/log.h" +#define LOG_MODULE "App" +#define LOG_LEVEL LOG_LEVEL_APP /* * Resources to be activated need to be imported through the extern keyword. * The build system automatically compiles the resources in the corresponding sub-directory. @@ -84,17 +80,6 @@ extern coap_resource_t res_battery; #include "dev/temperature-sensor.h" extern coap_resource_t res_temperature; #endif -/* -extern coap_resource_t res_battery; -#endif -#if PLATFORM_HAS_RADIO -extern coap_resource_t res_radio; -#endif -#if PLATFORM_HAS_SHT11 -#include "dev/sht11/sht11-sensor.h" -extern coap_resource_t res_sht11; -#endif -*/ PROCESS(er_example_server, "Erbium Example Server"); AUTOSTART_PROCESSES(&er_example_server); @@ -105,22 +90,7 @@ PROCESS_THREAD(er_example_server, ev, data) PROCESS_PAUSE(); - PRINTF("Starting Erbium Example Server\n"); - -#ifdef RF_CHANNEL - PRINTF("RF channel: %u\n", RF_CHANNEL); -#endif -#ifdef IEEE802154_PANID - PRINTF("PAN ID: 0x%04X\n", IEEE802154_PANID); -#endif - - PRINTF("uIP buffer: %u\n", UIP_BUFSIZE); - PRINTF("LL header: %u\n", UIP_LLH_LEN); - PRINTF("IP+UDP header: %u\n", UIP_IPUDPH_LEN); - PRINTF("CoAP max chunk: %u\n", COAP_MAX_CHUNK_SIZE); - - /* Initialize the REST engine. */ - coap_engine_init(); + LOG_INFO("Starting Erbium Example Server\n"); /* * Bind the resources to their Uri-Path. @@ -128,15 +98,15 @@ PROCESS_THREAD(er_example_server, ev, data) * All static variables are the same for each URI path. */ coap_activate_resource(&res_hello, "test/hello"); - coap_activate_resource(&res_mirror, "debug/mirror"); - coap_activate_resource(&res_chunks, "test/chunks"); - coap_activate_resource(&res_separate, "test/separate"); - coap_activate_resource(&res_push, "test/push"); + coap_activate_resource(&res_mirror, "debug/mirror"); + coap_activate_resource(&res_chunks, "test/chunks"); + coap_activate_resource(&res_separate, "test/separate"); + coap_activate_resource(&res_push, "test/push"); #if PLATFORM_HAS_BUTTON - coap_activate_resource(&res_event, "sensors/button"); + coap_activate_resource(&res_event, "sensors/button"); #endif /* PLATFORM_HAS_BUTTON */ - coap_activate_resource(&res_sub, "test/sub"); - coap_activate_resource(&res_b1_sep_b2, "test/b1sepb2"); + coap_activate_resource(&res_sub, "test/sub"); + coap_activate_resource(&res_b1_sep_b2, "test/b1sepb2"); #if PLATFORM_HAS_LEDS /* coap_activate_resource(&res_leds, "actuators/leds"); */ coap_activate_resource(&res_toggle, "actuators/toggle"); @@ -153,15 +123,6 @@ PROCESS_THREAD(er_example_server, ev, data) coap_activate_resource(&res_temperature, "sensors/temperature"); SENSORS_ACTIVATE(temperature_sensor); #endif -/* -#if PLATFORM_HAS_RADIO - coap_activate_resource(&res_radio, "sensors/radio"); -#endif -#if PLATFORM_HAS_SHT11 - coap_activate_resource(&res_sht11, "sensors/sht11"); - SENSORS_ACTIVATE(sht11_sensor); -#endif -*/ /* Define application-specific events here. */ while(1) { @@ -172,7 +133,7 @@ PROCESS_THREAD(er_example_server, ev, data) #else if(ev == sensors_event && data == &button_sensor) { #endif - PRINTF("*******BUTTON*******\n"); + LOG_DBG("*******BUTTON*******\n"); /* Call the event_handler for this application-specific event. */ res_event.trigger(); diff --git a/examples/coap/project-conf.h b/examples/coap/coap-example-server/project-conf.h similarity index 59% rename from examples/coap/project-conf.h rename to examples/coap/coap-example-server/project-conf.h index 115d6fbb0..eeec89082 100644 --- a/examples/coap/project-conf.h +++ b/examples/coap/coap-example-server/project-conf.h @@ -36,37 +36,9 @@ * Matthias Kovatsch */ -#ifndef PROJECT_ERBIUM_CONF_H_ -#define PROJECT_ERBIUM_CONF_H_ +#ifndef PROJECT_CONF_H_ +#define PROJECT_CONF_H_ -/* Custom channel and PAN ID configuration for your project. */ -/* #define RF_CHANNEL 26 */ -/* #define IEEE802154_CONF_PANID 0xABCD */ +#define LOG_LEVEL_APP LOG_LEVEL_DBG -/* IP buffer size must match all other hops, in particular the border router. */ -/* #define UIP_CONF_BUFFER_SIZE 256 */ - -/* Increase rpl-border-router IP-buffer when using more than 64. */ -#define COAP_MAX_CHUNK_SIZE 48 - -/* Estimate your header size, especially when using Proxy-Uri. */ -/* #define COAP_MAX_HEADER_SIZE 70 */ - -/* Multiplies with chunk size, be aware of memory constraints. */ -#ifndef COAP_MAX_OPEN_TRANSACTIONS -#define COAP_MAX_OPEN_TRANSACTIONS 4 -#endif /* COAP_MAX_OPEN_TRANSACTIONS */ - -/* Must be <= open transactions, default is COAP_MAX_OPEN_TRANSACTIONS-1. */ -/* #define COAP_MAX_OBSERVERS 2 */ - -/* Filtering .well-known/core per query can be disabled to save space. */ -#define COAP_LINK_FORMAT_FILTERING 0 -#define COAP_PROXY_OPTION_PROCESSING 0 - -/* Enable client-side support for COAP observe */ -#ifndef COAP_OBSERVE_CLIENT -#define COAP_OBSERVE_CLIENT 1 -#endif /* COAP_OBSERVE_CLIENT */ - -#endif /* PROJECT_ERBIUM_CONF_H_ */ +#endif /* PROJECT_CONF_H_ */ diff --git a/examples/coap/resources/res-b1-sep-b2.c b/examples/coap/coap-example-server/resources/res-b1-sep-b2.c similarity index 100% rename from examples/coap/resources/res-b1-sep-b2.c rename to examples/coap/coap-example-server/resources/res-b1-sep-b2.c diff --git a/examples/coap/resources/res-battery.c b/examples/coap/coap-example-server/resources/res-battery.c similarity index 100% rename from examples/coap/resources/res-battery.c rename to examples/coap/coap-example-server/resources/res-battery.c diff --git a/examples/coap/resources/res-chunks.c b/examples/coap/coap-example-server/resources/res-chunks.c similarity index 100% rename from examples/coap/resources/res-chunks.c rename to examples/coap/coap-example-server/resources/res-chunks.c diff --git a/examples/coap/resources/res-event.c b/examples/coap/coap-example-server/resources/res-event.c similarity index 80% rename from examples/coap/resources/res-event.c rename to examples/coap/coap-example-server/resources/res-event.c index 5640353b3..f8f754afa 100644 --- a/examples/coap/resources/res-event.c +++ b/examples/coap/coap-example-server/resources/res-event.c @@ -41,17 +41,10 @@ #include "coap-engine.h" #include "coap.h" -#define DEBUG 0 -#if DEBUG -#include -#define PRINTF(...) printf(__VA_ARGS__) -#define PRINT6ADDR(addr) PRINTF("[%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x]", ((uint8_t *)addr)[0], ((uint8_t *)addr)[1], ((uint8_t *)addr)[2], ((uint8_t *)addr)[3], ((uint8_t *)addr)[4], ((uint8_t *)addr)[5], ((uint8_t *)addr)[6], ((uint8_t *)addr)[7], ((uint8_t *)addr)[8], ((uint8_t *)addr)[9], ((uint8_t *)addr)[10], ((uint8_t *)addr)[11], ((uint8_t *)addr)[12], ((uint8_t *)addr)[13], ((uint8_t *)addr)[14], ((uint8_t *)addr)[15]) -#define PRINTLLADDR(lladdr) PRINTF("[%02x:%02x:%02x:%02x:%02x:%02x]", (lladdr)->addr[0], (lladdr)->addr[1], (lladdr)->addr[2], (lladdr)->addr[3], (lladdr)->addr[4], (lladdr)->addr[5]) -#else -#define PRINTF(...) -#define PRINT6ADDR(addr) -#define PRINTLLADDR(addr) -#endif +/* Log configuration */ +#include "sys/log.h" +#define LOG_MODULE "App" +#define LOG_LEVEL LOG_LEVEL_APP static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_event_handler(void); @@ -94,7 +87,7 @@ res_event_handler(void) /* Usually a condition is defined under with subscribers are notified, e.g., event was above a threshold. */ if(1) { - PRINTF("TICK %u for /%s\n", event_counter, res_event.url); + LOG_DBG("TICK %u for /%s\n", (unsigned)event_counter, res_event.url); /* Notify the registered observers which will trigger the res_get_handler to create the response. */ coap_notify_observers(&res_event); diff --git a/examples/coap/resources/res-hello.c b/examples/coap/coap-example-server/resources/res-hello.c similarity index 96% rename from examples/coap/resources/res-hello.c rename to examples/coap/coap-example-server/resources/res-hello.c index 46b0139ef..914bc28d6 100644 --- a/examples/coap/resources/res-hello.c +++ b/examples/coap/coap-example-server/resources/res-hello.c @@ -75,7 +75,9 @@ res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff memcpy(buffer, message, length); } else { memcpy(buffer, message, length); - } coap_set_header_content_format(response, TEXT_PLAIN); /* text/plain is the default, hence this option could be omitted. */ + } + + coap_set_header_content_format(response, TEXT_PLAIN); /* text/plain is the default, hence this option could be omitted. */ coap_set_header_etag(response, (uint8_t *)&length, 1); coap_set_payload(response, buffer, length); } diff --git a/examples/coap/resources/res-leds.c b/examples/coap/coap-example-server/resources/res-leds.c similarity index 78% rename from examples/coap/resources/res-leds.c rename to examples/coap/coap-example-server/resources/res-leds.c index d601e49f5..72dbc8b41 100644 --- a/examples/coap/resources/res-leds.c +++ b/examples/coap/coap-example-server/resources/res-leds.c @@ -44,17 +44,10 @@ #if PLATFORM_HAS_LEDS || LEDS_COUNT -#define DEBUG 0 -#if DEBUG -#include -#define PRINTF(...) printf(__VA_ARGS__) -#define PRINT6ADDR(addr) PRINTF("[%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x]", ((uint8_t *)addr)[0], ((uint8_t *)addr)[1], ((uint8_t *)addr)[2], ((uint8_t *)addr)[3], ((uint8_t *)addr)[4], ((uint8_t *)addr)[5], ((uint8_t *)addr)[6], ((uint8_t *)addr)[7], ((uint8_t *)addr)[8], ((uint8_t *)addr)[9], ((uint8_t *)addr)[10], ((uint8_t *)addr)[11], ((uint8_t *)addr)[12], ((uint8_t *)addr)[13], ((uint8_t *)addr)[14], ((uint8_t *)addr)[15]) -#define PRINTLLADDR(lladdr) PRINTF("[%02x:%02x:%02x:%02x:%02x:%02x]", (lladdr)->addr[0], (lladdr)->addr[1], (lladdr)->addr[2], (lladdr)->addr[3], (lladdr)->addr[4], (lladdr)->addr[5]) -#else -#define PRINTF(...) -#define PRINT6ADDR(addr) -#define PRINTLLADDR(addr) -#endif +/* Log configuration */ +#include "sys/log.h" +#define LOG_MODULE "App" +#define LOG_LEVEL LOG_LEVEL_APP static void res_post_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); @@ -76,7 +69,7 @@ res_post_put_handler(coap_message_t *request, coap_message_t *response, uint8_t int success = 1; if((len = coap_get_query_variable(request, "color", &color))) { - PRINTF("color %.*s\n", len, color); + LOG_DBG("color %.*s\n", (int)len, color); if(strncmp(color, "r", len) == 0) { led = LEDS_RED; @@ -90,7 +83,7 @@ res_post_put_handler(coap_message_t *request, coap_message_t *response, uint8_t } else { success = 0; } if(success && (len = coap_get_post_variable(request, "mode", &mode))) { - PRINTF("mode %s\n", mode); + LOG_DBG("mode %s\n", mode); if(strncmp(mode, "on", len) == 0) { leds_on(led); diff --git a/examples/coap/resources/res-light.c b/examples/coap/coap-example-server/resources/res-light.c similarity index 100% rename from examples/coap/resources/res-light.c rename to examples/coap/coap-example-server/resources/res-light.c diff --git a/examples/coap/resources/res-mirror.c b/examples/coap/coap-example-server/resources/res-mirror.c similarity index 91% rename from examples/coap/resources/res-mirror.c rename to examples/coap/coap-example-server/resources/res-mirror.c index 1ba948b0d..619ed08a7 100644 --- a/examples/coap/resources/res-mirror.c +++ b/examples/coap/coap-example-server/resources/res-mirror.c @@ -41,17 +41,10 @@ #include "coap-engine.h" #include "coap.h" -#define DEBUG 0 -#if DEBUG -#include -#define PRINTF(...) printf(__VA_ARGS__) -#define PRINT6ADDR(addr) PRINTF("[%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x]", ((uint8_t *)addr)[0], ((uint8_t *)addr)[1], ((uint8_t *)addr)[2], ((uint8_t *)addr)[3], ((uint8_t *)addr)[4], ((uint8_t *)addr)[5], ((uint8_t *)addr)[6], ((uint8_t *)addr)[7], ((uint8_t *)addr)[8], ((uint8_t *)addr)[9], ((uint8_t *)addr)[10], ((uint8_t *)addr)[11], ((uint8_t *)addr)[12], ((uint8_t *)addr)[13], ((uint8_t *)addr)[14], ((uint8_t *)addr)[15]) -#define PRINTLLADDR(lladdr) PRINTF("[%02x:%02x:%02x:%02x:%02x:%02x]", (lladdr)->addr[0], (lladdr)->addr[1], (lladdr)->addr[2], (lladdr)->addr[3], (lladdr)->addr[4], (lladdr)->addr[5]) -#else -#define PRINTF(...) -#define PRINT6ADDR(addr) -#define PRINTLLADDR(addr) -#endif +/* Log configuration */ +#include "sys/log.h" +#define LOG_MODULE "App" +#define LOG_LEVEL LOG_LEVEL_APP static void res_any_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); @@ -158,7 +151,7 @@ res_any_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff } coap_set_payload(response, buffer, strpos); - PRINTF("/mirror options received: %s\n", buffer); + LOG_DBG("/mirror options received: %s\n", buffer); /* Set dummy header options for response. Like getters, some setters are not implemented for HTTP and have no effect. */ coap_set_header_content_format(response, TEXT_PLAIN); diff --git a/examples/coap/resources/res-push.c b/examples/coap/coap-example-server/resources/res-push.c similarity index 100% rename from examples/coap/resources/res-push.c rename to examples/coap/coap-example-server/resources/res-push.c diff --git a/examples/coap/resources/res-radio.c b/examples/coap/coap-example-server/resources/res-radio.c similarity index 100% rename from examples/coap/resources/res-radio.c rename to examples/coap/coap-example-server/resources/res-radio.c diff --git a/examples/coap/resources/res-separate.c b/examples/coap/coap-example-server/resources/res-separate.c similarity index 100% rename from examples/coap/resources/res-separate.c rename to examples/coap/coap-example-server/resources/res-separate.c diff --git a/examples/coap/resources/res-sht11.c b/examples/coap/coap-example-server/resources/res-sht11.c similarity index 100% rename from examples/coap/resources/res-sht11.c rename to examples/coap/coap-example-server/resources/res-sht11.c diff --git a/examples/coap/resources/res-sub.c b/examples/coap/coap-example-server/resources/res-sub.c similarity index 100% rename from examples/coap/resources/res-sub.c rename to examples/coap/coap-example-server/resources/res-sub.c diff --git a/examples/coap/resources/res-temperature.c b/examples/coap/coap-example-server/resources/res-temperature.c similarity index 100% rename from examples/coap/resources/res-temperature.c rename to examples/coap/coap-example-server/resources/res-temperature.c diff --git a/examples/coap/resources/res-toggle.c b/examples/coap/coap-example-server/resources/res-toggle.c similarity index 100% rename from examples/coap/resources/res-toggle.c rename to examples/coap/coap-example-server/resources/res-toggle.c diff --git a/examples/coap/coap-plugtest-server/Makefile b/examples/coap/coap-plugtest-server/Makefile new file mode 100644 index 000000000..ee3bc511b --- /dev/null +++ b/examples/coap/coap-plugtest-server/Makefile @@ -0,0 +1,14 @@ +CONTIKI_PROJECT = coap-plugtest-server +all: $(CONTIKI_PROJECT) + +# Only intended for native +PLATFORMS_ONLY = native + +# Include the CoAP implementation +MODULES += os/net/app-layer/coap + +# Include CoAP resources +MODULES_REL += ./resources + +CONTIKI=../../.. +include $(CONTIKI)/Makefile.include diff --git a/examples/coap/plugtest-server.c b/examples/coap/coap-plugtest-server/coap-plugtest-server.c similarity index 89% rename from examples/coap/plugtest-server.c rename to examples/coap/coap-plugtest-server/coap-plugtest-server.c index 7ca53bc2d..8783ae6dd 100644 --- a/examples/coap/plugtest-server.c +++ b/examples/coap/coap-plugtest-server/coap-plugtest-server.c @@ -45,7 +45,11 @@ #include "coap-transactions.h" #include "coap-separate.h" #include "coap-engine.h" -#include "plugtest.h" + +/* Log configuration */ +#include "sys/log.h" +#define LOG_MODULE "Plugtest" +#define LOG_LEVEL LOG_LEVEL_PLUGTEST /* * Resources to be activated need to be imported through the extern keyword. @@ -80,22 +84,7 @@ PROCESS_THREAD(plugtest_server, ev, data) { PROCESS_BEGIN(); - PRINTF("ETSI IoT CoAP Plugtests Server\n"); - -#ifdef RF_CHANNEL - PRINTF("RF channel: %u\n", RF_CHANNEL); -#endif -#ifdef IEEE802154_PANID - PRINTF("PAN ID: 0x%04X\n", IEEE802154_PANID); -#endif - - PRINTF("uIP buffer: %u\n", UIP_BUFSIZE); - PRINTF("LL header: %u\n", UIP_LLH_LEN); - PRINTF("IP+UDP header: %u\n", UIP_IPUDPH_LEN); - PRINTF("REST max chunk: %u\n", REST_MAX_CHUNK_SIZE); - - /* Initialize the REST engine. */ - coap_engine_init(); + LOG_INFO("ETSI IoT CoAP Plugtests Server\n"); /* Activate the application-specific resources. */ coap_activate_resource(&res_plugtest_test, "test"); diff --git a/examples/coap/plugtest.h b/examples/coap/coap-plugtest-server/project-conf.h similarity index 88% rename from examples/coap/plugtest.h rename to examples/coap/coap-plugtest-server/project-conf.h index dff97282f..5c86ae985 100644 --- a/examples/coap/plugtest.h +++ b/examples/coap/coap-plugtest-server/project-conf.h @@ -36,20 +36,10 @@ * Matthias Kovatsch */ -#ifndef PLUGTEST_H_ -#define PLUGTEST_H_ +#ifndef PROJECT_CONF_H_ +#define PROJECT_CONF_H_ -#if !defined(CONTIKI_TARGET_NATIVE) -#warning "Should only be compiled for native!" -#endif - -#define DEBUG 0 -#if DEBUG -#include -#define PRINTF(...) printf(__VA_ARGS__) -#else -#define PRINTF(...) -#endif +#define LOG_LEVEL_PLUGTEST LOG_LEVEL_DBG /* double expansion */ #define TO_STRING2(x) # x @@ -59,4 +49,4 @@ #define MAX_PLUGFEST_BODY 2048 #define CHUNKS_TOTAL 2012 -#endif /* PLUGTEST_H_ */ +#endif /* PROJECT_CONF_H_ */ diff --git a/examples/coap/coap-plugtest-server/resources/res-mirror.c b/examples/coap/coap-plugtest-server/resources/res-mirror.c new file mode 100644 index 000000000..ea9ddd3ad --- /dev/null +++ b/examples/coap/coap-plugtest-server/resources/res-mirror.c @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2013, Institute for Pervasive Computing, ETH Zurich + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of the Contiki operating system. + */ + +/** + * \file + * Example resource + * \author + * Matthias Kovatsch + */ + +#include +#include +#include "coap-engine.h" +#include "coap.h" + +/* Log configuration */ +#include "sys/log.h" +#define LOG_MODULE "Plugtest" +#define LOG_LEVEL LOG_LEVEL_PLUGTEST + +static void res_any_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); + +/* This resource mirrors the incoming request. It shows how to access the options and how to set them for the response. */ +RESOURCE(res_mirror, + "title=\"Returns your decoded message\";rt=\"Debug\"", + res_any_handler, + res_any_handler, + res_any_handler, + res_any_handler); + +static void +res_any_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) +{ + /* The ETag and Token is copied to the header. */ + uint8_t opaque[] = { 0x0A, 0xBC, 0xDE }; + + /* Strings are not copied, so use static string buffers or strings in .text memory (char *str = "string in .text";). */ + static char location[] = { '/', 'f', '/', 'a', '?', 'k', '&', 'e', 0 }; + + /* No default my be assumed for the Content-Format. (Unsigned -1 means all bits set.) */ + unsigned int content_format = -1; + + /* The other getters copy the value (or string/array pointer) to the given pointers and return 1 for success or the length of strings/arrays. */ + uint32_t longint = 0; + const char *str = NULL; + const uint8_t *bytes = NULL; + uint32_t block_num = 0; + uint8_t block_more = 0; + uint16_t block_size = 0; + int len = 0; + + /* Mirror the received header options in the response payload. Unsupported getters (e.g., rest_get_header_observe() with HTTP) will return 0. */ + + int strpos = 0; + /* snprintf() counts the terminating '\0' to the size parameter. + * The additional byte is taken care of by allocating REST_MAX_CHUNK_SIZE+1 bytes in the REST framework. + * Add +1 to fill the complete buffer, as the payload does not need a terminating '\0'. */ + if(coap_get_header_content_format(request, &content_format)) { + strpos += snprintf((char *)buffer, REST_MAX_CHUNK_SIZE + 1, "CF %u\n", content_format); + } + if(strpos <= REST_MAX_CHUNK_SIZE && (len = coap_get_header_accept(request, &content_format))) { + strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "Ac %u\n", content_format); + /* Some getters such as for ETag or Location are omitted, as these options should not appear in a request. + * Max-Age might appear in HTTP requests or used for special purposes in CoAP. */ + } + if(strpos <= REST_MAX_CHUNK_SIZE && coap_get_header_max_age(request, &longint)) { + strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "MA %lu\n", (unsigned long) longint); + /* For HTTP this is the Length option, for CoAP it is the Size option. */ + } + if(strpos <= REST_MAX_CHUNK_SIZE && coap_get_header_size1(request, &longint)) { + strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "SZ %lu\n", (unsigned long) longint); + } + if(strpos <= REST_MAX_CHUNK_SIZE && (len = coap_get_header_uri_host(request, &str))) { + strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "UH %.*s\n", len, str); + } + if(strpos <= REST_MAX_CHUNK_SIZE && (len = coap_get_header_uri_path(request, &str))) { + strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "UP %.*s\n", len, str); + } + if(strpos <= REST_MAX_CHUNK_SIZE && (len = coap_get_header_uri_query(request, &str))) { + strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "UQ %.*s\n", len, str); + /* Undefined request options for debugging: actions not required for normal RESTful Web service. */ + } + if(strpos <= REST_MAX_CHUNK_SIZE && (len = coap_get_header_location_path(request, &str))) { + strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "LP %.*s\n", len, str); + } + if(strpos <= REST_MAX_CHUNK_SIZE && (len = coap_get_header_location_query(request, &str))) { + strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "LQ %.*s\n", len, str); + /* CoAP-specific example: actions not required for normal RESTful Web service. */ + } + coap_message_t *const coap_pkt = (coap_message_t *)request; + + if(strpos <= REST_MAX_CHUNK_SIZE && coap_pkt->token_len > 0) { + strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "To 0x"); + int index = 0; + for(index = 0; index < coap_pkt->token_len; ++index) { + strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "%02X", coap_pkt->token[index]); + } + strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "\n"); + } + + if(strpos <= REST_MAX_CHUNK_SIZE && coap_is_option(coap_pkt, COAP_OPTION_OBSERVE)) { + strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "Ob %lu\n", (unsigned long) coap_pkt->observe); + } + if(strpos <= REST_MAX_CHUNK_SIZE && coap_is_option(coap_pkt, COAP_OPTION_ETAG)) { + strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "ET 0x"); + int index = 0; + for(index = 0; index < coap_pkt->etag_len; ++index) { + strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "%02X", coap_pkt->etag[index]); + } + strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "\n"); + } + if(strpos <= REST_MAX_CHUNK_SIZE && coap_get_header_block2(request, &block_num, &block_more, &block_size, NULL)) { /* This getter allows NULL pointers to get only a subset of the block parameters. */ + strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "B2 %lu%s (%u)\n", (unsigned long) block_num, block_more ? "+" : "", block_size); + } + if(strpos <= REST_MAX_CHUNK_SIZE && coap_get_header_block1(request, &block_num, &block_more, &block_size, NULL)) { + strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "B1 %lu%s (%u)\n", (unsigned long) block_num, block_more ? "+" : "", block_size); + } + if(strpos <= REST_MAX_CHUNK_SIZE && (len = coap_get_payload(request, &bytes))) { + strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "%.*s", len, bytes); + } + if(strpos >= REST_MAX_CHUNK_SIZE) { + buffer[REST_MAX_CHUNK_SIZE - 1] = 0xBB; /* '»' to indicate truncation */ + } + coap_set_payload(response, buffer, strpos); + + LOG_DBG("/mirror options received: %s\n", buffer); + + /* Set dummy header options for response. Like getters, some setters are not implemented for HTTP and have no effect. */ + coap_set_header_content_format(response, TEXT_PLAIN); + coap_set_header_max_age(response, 17); /* For HTTP, browsers will not re-request the page for 17 seconds. */ + coap_set_header_etag(response, opaque, 2); + coap_set_header_location_path(response, location); /* Initial slash is omitted by framework */ + coap_set_header_size1(response, strpos); /* For HTTP, browsers will not re-request the page for 10 s. CoAP action depends on the client. */ + +/* CoAP-specific example: actions not required for normal RESTful Web service. */ + coap_set_header_uri_host(response, "tiki"); + coap_set_header_observe(response, 10); + coap_set_header_proxy_uri(response, "ftp://x"); + coap_set_header_block2(response, 42, 0, 64); /* The block option might be overwritten by the framework when blockwise transfer is requested. */ + coap_set_header_block1(response, 23, 0, 16); + coap_set_header_accept(response, TEXT_PLAIN); + coap_set_header_if_none_match(response); +} diff --git a/examples/coap/resources-plugtest/res-plugtest-create1.c b/examples/coap/coap-plugtest-server/resources/res-plugtest-create1.c similarity index 94% rename from examples/coap/resources-plugtest/res-plugtest-create1.c rename to examples/coap/coap-plugtest-server/resources/res-plugtest-create1.c index 50f48a09e..fe57e4961 100644 --- a/examples/coap/resources-plugtest/res-plugtest-create1.c +++ b/examples/coap/coap-plugtest-server/resources/res-plugtest-create1.c @@ -39,7 +39,11 @@ #include #include "coap-engine.h" #include "coap.h" -#include "plugtest.h" + +/* Log configuration */ +#include "sys/log.h" +#define LOG_MODULE "Plugtest" +#define LOG_LEVEL LOG_LEVEL_PLUGTEST static void res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_delete_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); @@ -56,7 +60,7 @@ static uint8_t create1_exists = 0; static void res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) { - PRINTF("/create1 PUT"); + LOG_DBG("/create1 PUT"); if(coap_get_header_if_none_match(request)) { if(!create1_exists) { @@ -73,7 +77,7 @@ res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff static void res_delete_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) { - PRINTF("/create1 DELETE "); + LOG_DBG("/create1 DELETE "); coap_set_status_code(response, DELETED_2_02); create1_exists = 0; diff --git a/examples/coap/resources-plugtest/res-plugtest-create2.c b/examples/coap/coap-plugtest-server/resources/res-plugtest-create2.c similarity index 94% rename from examples/coap/resources-plugtest/res-plugtest-create2.c rename to examples/coap/coap-plugtest-server/resources/res-plugtest-create2.c index 169f47812..b4520d672 100644 --- a/examples/coap/resources-plugtest/res-plugtest-create2.c +++ b/examples/coap/coap-plugtest-server/resources/res-plugtest-create2.c @@ -39,7 +39,11 @@ #include #include "coap-engine.h" #include "coap.h" -#include "plugtest.h" + +/* Log configuration */ +#include "sys/log.h" +#define LOG_MODULE "Plugtest" +#define LOG_LEVEL LOG_LEVEL_PLUGTEST static void res_post_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); @@ -53,7 +57,7 @@ RESOURCE(res_plugtest_create2, static void res_post_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) { - PRINTF("/create2 "); + LOG_DBG("/create2 "); coap_set_status_code(response, CREATED_2_01); coap_set_header_location_path(response, "/location1/location2/location3"); diff --git a/examples/coap/resources-plugtest/res-plugtest-create3.c b/examples/coap/coap-plugtest-server/resources/res-plugtest-create3.c similarity index 94% rename from examples/coap/resources-plugtest/res-plugtest-create3.c rename to examples/coap/coap-plugtest-server/resources/res-plugtest-create3.c index 178a0089e..b78fca67e 100644 --- a/examples/coap/resources-plugtest/res-plugtest-create3.c +++ b/examples/coap/coap-plugtest-server/resources/res-plugtest-create3.c @@ -39,7 +39,11 @@ #include #include "coap-engine.h" #include "coap.h" -#include "plugtest.h" + +/* Log configuration */ +#include "sys/log.h" +#define LOG_MODULE "Plugtest" +#define LOG_LEVEL LOG_LEVEL_PLUGTEST static void res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_delete_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); @@ -56,7 +60,7 @@ static uint8_t create3_exists = 0; static void res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) { - PRINTF("/create3 PUT "); + LOG_DBG("/create3 PUT "); if(coap_get_header_if_none_match(request)) { if(!create3_exists) { @@ -73,7 +77,7 @@ res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff static void res_delete_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) { - PRINTF("/create3 DELETE "); + LOG_DBG("/create3 DELETE "); coap_set_status_code(response, DELETED_2_02); create3_exists = 0; diff --git a/examples/coap/resources-plugtest/res-plugtest-large-create.c b/examples/coap/coap-plugtest-server/resources/res-plugtest-large-create.c similarity index 96% rename from examples/coap/resources-plugtest/res-plugtest-large-create.c rename to examples/coap/coap-plugtest-server/resources/res-plugtest-large-create.c index 78d21b69b..923702f51 100644 --- a/examples/coap/resources-plugtest/res-plugtest-large-create.c +++ b/examples/coap/coap-plugtest-server/resources/res-plugtest-large-create.c @@ -39,7 +39,11 @@ #include #include "coap-engine.h" #include "coap.h" -#include "plugtest.h" + +/* Log configuration */ +#include "sys/log.h" +#define LOG_MODULE "Plugtest" +#define LOG_LEVEL LOG_LEVEL_PLUGTEST static void res_post_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); diff --git a/examples/coap/resources-plugtest/res-plugtest-large-update.c b/examples/coap/coap-plugtest-server/resources/res-plugtest-large-update.c similarity index 97% rename from examples/coap/resources-plugtest/res-plugtest-large-update.c rename to examples/coap/coap-plugtest-server/resources/res-plugtest-large-update.c index a79978be1..289fbdfdf 100644 --- a/examples/coap/resources-plugtest/res-plugtest-large-update.c +++ b/examples/coap/coap-plugtest-server/resources/res-plugtest-large-update.c @@ -41,7 +41,11 @@ #include "sys/cc.h" #include "coap-engine.h" #include "coap.h" -#include "plugtest.h" + +/* Log configuration */ +#include "sys/log.h" +#define LOG_MODULE "Plugtest" +#define LOG_LEVEL LOG_LEVEL_PLUGTEST static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); diff --git a/examples/coap/resources-plugtest/res-plugtest-large.c b/examples/coap/coap-plugtest-server/resources/res-plugtest-large.c similarity index 96% rename from examples/coap/resources-plugtest/res-plugtest-large.c rename to examples/coap/coap-plugtest-server/resources/res-plugtest-large.c index f828e4dbe..850f88461 100644 --- a/examples/coap/resources-plugtest/res-plugtest-large.c +++ b/examples/coap/coap-plugtest-server/resources/res-plugtest-large.c @@ -40,7 +40,11 @@ #include #include "coap-engine.h" #include "coap.h" -#include "plugtest.h" + +/* Log configuration */ +#include "sys/log.h" +#define LOG_MODULE "Plugtest" +#define LOG_LEVEL LOG_LEVEL_PLUGTEST static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); diff --git a/examples/coap/resources-plugtest/res-plugtest-links.c b/examples/coap/coap-plugtest-server/resources/res-plugtest-links.c similarity index 95% rename from examples/coap/resources-plugtest/res-plugtest-links.c rename to examples/coap/coap-plugtest-server/resources/res-plugtest-links.c index 99315a17f..3bbd2a062 100644 --- a/examples/coap/resources-plugtest/res-plugtest-links.c +++ b/examples/coap/coap-plugtest-server/resources/res-plugtest-links.c @@ -39,7 +39,11 @@ #include #include "coap-engine.h" #include "coap.h" -#include "plugtest.h" + +/* Log configuration */ +#include "sys/log.h" +#define LOG_MODULE "Plugtest" +#define LOG_LEVEL LOG_LEVEL_PLUGTEST static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); diff --git a/examples/coap/resources-plugtest/res-plugtest-locquery.c b/examples/coap/coap-plugtest-server/resources/res-plugtest-locquery.c similarity index 95% rename from examples/coap/resources-plugtest/res-plugtest-locquery.c rename to examples/coap/coap-plugtest-server/resources/res-plugtest-locquery.c index e93ef8b65..e7163e8b1 100644 --- a/examples/coap/resources-plugtest/res-plugtest-locquery.c +++ b/examples/coap/coap-plugtest-server/resources/res-plugtest-locquery.c @@ -39,7 +39,11 @@ #include #include "coap-engine.h" #include "coap.h" -#include "plugtest.h" + +/* Log configuration */ +#include "sys/log.h" +#define LOG_MODULE "Plugtest" +#define LOG_LEVEL LOG_LEVEL_PLUGTEST static void res_post_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); @@ -53,11 +57,9 @@ RESOURCE(res_plugtest_locquery, static void res_post_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) { -#if DEBUG coap_message_t *const coap_req = (coap_message_t *)request; -#endif - PRINTF( + LOG_DBG( "/location-query POST (%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid); coap_set_status_code(response, CREATED_2_01); diff --git a/examples/coap/resources-plugtest/res-plugtest-longpath.c b/examples/coap/coap-plugtest-server/resources/res-plugtest-longpath.c similarity index 91% rename from examples/coap/resources-plugtest/res-plugtest-longpath.c rename to examples/coap/coap-plugtest-server/resources/res-plugtest-longpath.c index 7a1271321..990ad2677 100644 --- a/examples/coap/resources-plugtest/res-plugtest-longpath.c +++ b/examples/coap/coap-plugtest-server/resources/res-plugtest-longpath.c @@ -41,7 +41,11 @@ #include #include "coap-engine.h" #include "coap.h" -#include "plugtest.h" + +/* Log configuration */ +#include "sys/log.h" +#define LOG_MODULE "Plugtest" +#define LOG_LEVEL LOG_LEVEL_PLUGTEST static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); @@ -57,7 +61,7 @@ res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff { coap_message_t *const coap_req = (coap_message_t *)request; - PRINTF("/seg1/seg2/seg3 GET "); + LOG_DBG("/seg1/seg2/seg3 GET "); /* Code 2.05 CONTENT is default. */ coap_set_header_content_format(response, TEXT_PLAIN); coap_set_payload( @@ -66,5 +70,5 @@ res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff snprintf((char *)buffer, MAX_PLUGFEST_PAYLOAD, "Type: %u\nCode: %u\nMID: %u", coap_req->type, coap_req->code, coap_req->mid)); - PRINTF("(%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid); + LOG_DBG_("(%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid); } diff --git a/examples/coap/resources-plugtest/res-plugtest-multi.c b/examples/coap/coap-plugtest-server/resources/res-plugtest-multi.c similarity index 91% rename from examples/coap/resources-plugtest/res-plugtest-multi.c rename to examples/coap/coap-plugtest-server/resources/res-plugtest-multi.c index f0a388430..9606d91a6 100644 --- a/examples/coap/resources-plugtest/res-plugtest-multi.c +++ b/examples/coap/coap-plugtest-server/resources/res-plugtest-multi.c @@ -40,7 +40,11 @@ #include #include "coap-engine.h" #include "coap.h" -#include "plugtest.h" + +/* Log configuration */ +#include "sys/log.h" +#define LOG_MODULE "Plugtest" +#define LOG_LEVEL LOG_LEVEL_PLUGTEST static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); @@ -59,7 +63,7 @@ res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff unsigned int accept = -1; coap_get_header_accept(request, &accept); - PRINTF("/multi-format GET (%s %u) ", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid); + LOG_DBG("/multi-format GET (%s %u) ", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid); if(accept == -1 || accept == TEXT_PLAIN) { coap_set_header_content_format(response, TEXT_PLAIN); @@ -69,7 +73,7 @@ res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff snprintf((char *)buffer, MAX_PLUGFEST_PAYLOAD, "Type: %u\nCode: %u\nMID: %u%s", coap_req->type, coap_req->code, coap_req->mid, accept != -1 ? "\nAccept: 0" : "")); - PRINTF("PLAIN\n"); + LOG_DBG_("PLAIN\n"); } else if(accept == APPLICATION_XML) { coap_set_header_content_format(response, APPLICATION_XML); coap_set_payload( @@ -78,11 +82,11 @@ res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff snprintf((char *)buffer, MAX_PLUGFEST_PAYLOAD, "", coap_req->type, coap_req->code, coap_req->mid, accept)); - PRINTF("XML\n"); + LOG_DBG_("XML\n"); } else { coap_set_status_code(response, NOT_ACCEPTABLE_4_06); const char *msg = "Supporting content-types text/plain and application/xml"; coap_set_payload(response, msg, strlen(msg)); - PRINTF("ERROR\n"); + LOG_DBG_("ERROR\n"); } } diff --git a/examples/coap/resources-plugtest/res-plugtest-obs.c b/examples/coap/coap-plugtest-server/resources/res-plugtest-obs.c similarity index 94% rename from examples/coap/resources-plugtest/res-plugtest-obs.c rename to examples/coap/coap-plugtest-server/resources/res-plugtest-obs.c index d60aaec04..7d191e751 100644 --- a/examples/coap/resources-plugtest/res-plugtest-obs.c +++ b/examples/coap/coap-plugtest-server/resources/res-plugtest-obs.c @@ -41,7 +41,11 @@ #include "coap-engine.h" #include "coap.h" #include "coap-observe.h" -#include "plugtest.h" + +/* Log configuration */ +#include "sys/log.h" +#define LOG_MODULE "Plugtest" +#define LOG_LEVEL LOG_LEVEL_PLUGTEST static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); @@ -67,7 +71,7 @@ static char obs_status = 0; static void obs_purge_list() { - PRINTF("### SERVER ACTION ### Purging obs list"); + LOG_DBG("### SERVER ACTION ### Purging obs list\n"); coap_remove_observer_by_uri(NULL, res_plugtest_obs.url); } static void @@ -75,7 +79,7 @@ res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff { /* Keep server log clean from ticking events */ if(request != NULL) { - PRINTF("/obs GET\n"); + LOG_DBG("/obs GET\n"); } coap_set_header_content_format(response, obs_format); coap_set_header_max_age(response, 5); @@ -98,7 +102,7 @@ res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff coap_get_header_content_format(request, &ct); - PRINTF("/obs PUT\n"); + LOG_DBG("/obs PUT\n"); if(ct != obs_format) { obs_status = 1; @@ -115,7 +119,7 @@ res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff static void res_delete_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) { - PRINTF("/obs DELETE\n"); + LOG_DBG("/obs DELETE\n"); obs_status = 2; @@ -130,14 +134,12 @@ res_periodic_handler() { ++obs_counter; - /* PRINTF("TICK %u for /%s\n", obs_counter, r->url); */ - if(obs_status == 1) { /* Notify the registered observers with the given message type, observe option, and payload. */ coap_notify_observers(&res_plugtest_obs); - PRINTF("######### sending 5.00\n"); + LOG_DBG("######### sending 5.00\n"); obs_purge_list(); } else if(obs_status == 2) { diff --git a/examples/coap/resources-plugtest/res-plugtest-path.c b/examples/coap/coap-plugtest-server/resources/res-plugtest-path.c similarity index 96% rename from examples/coap/resources-plugtest/res-plugtest-path.c rename to examples/coap/coap-plugtest-server/resources/res-plugtest-path.c index fac05ccb0..767609f09 100644 --- a/examples/coap/resources-plugtest/res-plugtest-path.c +++ b/examples/coap/coap-plugtest-server/resources/res-plugtest-path.c @@ -40,7 +40,11 @@ #include #include "coap-engine.h" #include "coap.h" -#include "plugtest.h" + +/* Log configuration */ +#include "sys/log.h" +#define LOG_MODULE "Plugtest" +#define LOG_LEVEL LOG_LEVEL_PLUGTEST static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); diff --git a/examples/coap/resources-plugtest/res-plugtest-query.c b/examples/coap/coap-plugtest-server/resources/res-plugtest-query.c similarity index 94% rename from examples/coap/resources-plugtest/res-plugtest-query.c rename to examples/coap/coap-plugtest-server/resources/res-plugtest-query.c index 10df145b3..1080d3162 100644 --- a/examples/coap/resources-plugtest/res-plugtest-query.c +++ b/examples/coap/coap-plugtest-server/resources/res-plugtest-query.c @@ -40,7 +40,11 @@ #include #include "coap-engine.h" #include "coap.h" -#include "plugtest.h" + +/* Log configuration */ +#include "sys/log.h" +#define LOG_MODULE "Plugtest" +#define LOG_LEVEL LOG_LEVEL_PLUGTEST static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); @@ -58,11 +62,11 @@ res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff int len = 0; const char *query = NULL; - PRINTF( + LOG_DBG( "/query GET (%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid); if((len = coap_get_header_uri_query(request, &query))) { - PRINTF("Query: %.*s\n", len, query); + LOG_DBG("Query: %.*s\n", len, query); /* Code 2.05 CONTENT is default. */ } coap_set_header_content_format(response, diff --git a/examples/coap/resources-plugtest/res-plugtest-separate.c b/examples/coap/coap-plugtest-server/resources/res-plugtest-separate.c similarity index 93% rename from examples/coap/resources-plugtest/res-plugtest-separate.c rename to examples/coap/coap-plugtest-server/resources/res-plugtest-separate.c index 16aa267ce..c0ae81d11 100644 --- a/examples/coap/resources-plugtest/res-plugtest-separate.c +++ b/examples/coap/coap-plugtest-server/resources/res-plugtest-separate.c @@ -42,7 +42,11 @@ #include "coap.h" #include "coap-transactions.h" #include "coap-separate.h" -#include "plugtest.h" + +/* Log configuration */ +#include "sys/log.h" +#define LOG_MODULE "Plugtest" +#define LOG_LEVEL LOG_LEVEL_PLUGTEST static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_resume_handler(void); @@ -72,12 +76,12 @@ res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff { coap_message_t *const coap_req = (coap_message_t *)request; - PRINTF("/separate "); + LOG_DBG("/separate "); if(separate_active) { - PRINTF("REJECTED "); + LOG_DBG_("REJECTED "); coap_separate_reject(); } else { - PRINTF("STORED "); + LOG_DBG_("STORED "); separate_active = 1; /* Take over and skip response by engine. */ @@ -89,17 +93,17 @@ res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff coap_req->mid); } - PRINTF("(%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid); + LOG_DBG_("(%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid); } static void res_resume_handler() { if(separate_active) { - PRINTF("/separate "); + LOG_DBG("/separate "); coap_transaction_t *transaction = NULL; if((transaction = coap_new_transaction(separate_store->request_metadata.mid, &separate_store->request_metadata.endpoint))) { - PRINTF( + LOG_DBG_( "RESPONSE (%s %u)\n", separate_store->request_metadata.type == COAP_TYPE_CON ? "CON" : "NON", separate_store->request_metadata.mid); coap_message_t response[1]; /* This way the message can be treated as pointer as usual. */ @@ -127,7 +131,7 @@ res_resume_handler() separate_active = 0; } else { - PRINTF("ERROR (transaction)\n"); + LOG_DBG_("ERROR (transaction)\n"); } } /* if (separate_active) */ } diff --git a/examples/coap/resources-plugtest/res-plugtest-test.c b/examples/coap/coap-plugtest-server/resources/res-plugtest-test.c similarity index 81% rename from examples/coap/resources-plugtest/res-plugtest-test.c rename to examples/coap/coap-plugtest-server/resources/res-plugtest-test.c index f7ac97c83..d02b3026d 100644 --- a/examples/coap/resources-plugtest/res-plugtest-test.c +++ b/examples/coap/coap-plugtest-server/resources/res-plugtest-test.c @@ -40,9 +40,13 @@ #include #include "coap-engine.h" #include "coap.h" -#include "plugtest.h" #include "random.h" +/* Log configuration */ +#include "sys/log.h" +#define LOG_MODULE "Plugtest" +#define LOG_LEVEL LOG_LEVEL_PLUGTEST + static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_post_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); @@ -68,7 +72,7 @@ test_update_etag() } test_change = 0; - PRINTF("### SERVER ACTION ### Changed ETag %u [0x%02X%02X%02X%02X%02X%02X%02X%02X]\n", test_etag_len, test_etag[0], test_etag[1], test_etag[2], test_etag[3], test_etag[4], test_etag[5], test_etag[6], test_etag[7]); + LOG_DBG("### SERVER ACTION ### Changed ETag %u [0x%02X%02X%02X%02X%02X%02X%02X%02X]\n", test_etag_len, test_etag[0], test_etag[1], test_etag[2], test_etag[3], test_etag[4], test_etag[5], test_etag[6], test_etag[7]); } static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) @@ -78,17 +82,17 @@ res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff if(test_change) { test_update_etag(); } - PRINTF("/test GET (%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid); + LOG_DBG("/test GET (%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid); if((len = coap_get_header_etag(request, &bytes)) > 0 && len == test_etag_len && memcmp(test_etag, bytes, len) == 0) { - PRINTF("validate "); + LOG_DBG("validate\n"); coap_set_status_code(response, VALID_2_03); coap_set_header_etag(response, test_etag, test_etag_len); test_change = 1; - PRINTF("### SERVER ACTION ### Resource will change\n"); + LOG_DBG("### SERVER ACTION ### Resource will change\n"); } else { /* Code 2.05 CONTENT is default. */ coap_set_header_content_format(response, TEXT_PLAIN); @@ -103,32 +107,28 @@ res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff static void res_post_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) { -#if DEBUG - coap_message_t *const coap_req = (coap_message_t *)request; - PRINTF("/test POST (%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid); -#endif + coap_message_t *const coap_req = (coap_message_t *)request; + LOG_DBG("/test POST (%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid); coap_set_status_code(response, CREATED_2_01); coap_set_header_location_path(response, "/location1/location2/location3"); } static void res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) { -#if DEBUG coap_message_t *const coap_req = (coap_message_t *)request; - PRINTF("/test PUT (%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid); -#endif + LOG_DBG("/test PUT (%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid); if(coap_get_header_if_none_match(request)) { if(test_none_match_okay) { coap_set_status_code(response, CREATED_2_01); test_none_match_okay = 0; - PRINTF("### SERVER ACTION ### If-None-Match will FAIL\n"); + LOG_DBG("### SERVER ACTION ### If-None-Match will FAIL\n"); } else { coap_set_status_code(response, PRECONDITION_FAILED_4_12); test_none_match_okay = 1; - PRINTF("### SERVER ACTION ### If-None-Match will SUCCEED\n"); + LOG_DBG("### SERVER ACTION ### If-None-Match will SUCCEED\n"); } } else if(((len = coap_get_header_if_match(request, &bytes)) > 0 && (len == test_etag_len @@ -141,12 +141,12 @@ res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff if(len > 0) { test_change = 1; - PRINTF("### SERVER ACTION ### Resource will change\n"); + LOG_DBG("### SERVER ACTION ### Resource will change\n"); } } else { - PRINTF("Check %u/%u\n [0x%02X%02X%02X%02X%02X%02X%02X%02X]\n [0x%02X%02X%02X%02X%02X%02X%02X%02X]\n", - len, - test_etag_len, + LOG_DBG("Check %u/%u\n [0x%02X%02X%02X%02X%02X%02X%02X%02X]\n [0x%02X%02X%02X%02X%02X%02X%02X%02X]\n", + (unsigned)len, + (unsigned)test_etag_len, bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7], test_etag[0], test_etag[1], test_etag[2], test_etag[3], test_etag[4], test_etag[5], test_etag[6], test_etag[7]); @@ -156,9 +156,7 @@ res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff static void res_delete_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) { -#if DEBUG coap_message_t *const coap_req = (coap_message_t *)request; - PRINTF("/test DELETE (%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid); -#endif + LOG_DBG("/test DELETE (%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid); coap_set_status_code(response, DELETED_2_02); } diff --git a/examples/coap/resources-plugtest/res-plugtest-validate.c b/examples/coap/coap-plugtest-server/resources/res-plugtest-validate.c similarity index 87% rename from examples/coap/resources-plugtest/res-plugtest-validate.c rename to examples/coap/coap-plugtest-server/resources/res-plugtest-validate.c index 30d97e727..7a5920c2b 100644 --- a/examples/coap/resources-plugtest/res-plugtest-validate.c +++ b/examples/coap/coap-plugtest-server/resources/res-plugtest-validate.c @@ -40,9 +40,13 @@ #include #include "coap-engine.h" #include "coap.h" -#include "plugtest.h" #include "random.h" +/* Log configuration */ +#include "sys/log.h" +#define LOG_MODULE "Plugtest" +#define LOG_LEVEL LOG_LEVEL_PLUGTEST + static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); @@ -70,7 +74,7 @@ validate_update_etag() } validate_change = 0; - PRINTF("### SERVER ACTION ### Changed ETag %u [0x%02X%02X%02X%02X%02X%02X%02X%02X]\n", + LOG_DBG("### SERVER ACTION ### Changed ETag %u [0x%02X%02X%02X%02X%02X%02X%02X%02X]\n", validate_etag_len, validate_etag[0], validate_etag[1], validate_etag[2], validate_etag[3], validate_etag[4], validate_etag[5], validate_etag[6], validate_etag[7]); } static void @@ -81,17 +85,17 @@ res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff if(validate_change) { validate_update_etag(); } - PRINTF("/validate GET"); - PRINTF("(%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid); + LOG_DBG("/validate GET"); + LOG_DBG_("(%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid); if((len = coap_get_header_etag(request, &bytes)) > 0 && len == validate_etag_len && memcmp(validate_etag, bytes, len) == 0) { - PRINTF("validate "); + LOG_DBG("validate\n"); coap_set_status_code(response, VALID_2_03); coap_set_header_etag(response, validate_etag, validate_etag_len); validate_change = 1; - PRINTF("### SERVER ACTION ### Resouce will change\n"); + LOG_DBG("### SERVER ACTION ### Resouce will change\n"); } else { /* Code 2.05 CONTENT is default. */ coap_set_header_content_format(response, TEXT_PLAIN); @@ -108,12 +112,10 @@ res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff static void res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) { -#if DEBUG coap_message_t *const coap_req = (coap_message_t *)request; -#endif - PRINTF("/validate PUT "); - PRINTF("(%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid); + LOG_DBG("/validate PUT "); + LOG_DBG_("(%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid); if(((len = coap_get_header_if_match(request, &bytes)) > 0 && (len == validate_etag_len @@ -126,13 +128,13 @@ res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff if(len > 0) { validate_change = 1; - PRINTF("### SERVER ACTION ### Resouce will change\n"); + LOG_DBG("### SERVER ACTION ### Resouce will change\n"); } } else { - PRINTF( - "Check %u/%u\n [0x%02X%02X%02X%02X%02X%02X%02X%02X]\n [0x%02X%02X%02X%02X%02X%02X%02X%02X] ", - len, - validate_etag_len, + LOG_DBG( + "Check %u/%u\n [0x%02X%02X%02X%02X%02X%02X%02X%02X]\n [0x%02X%02X%02X%02X%02X%02X%02X%02X]\n", + (unsigned)len, + (unsigned)validate_etag_len, bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7], validate_etag[0], validate_etag[1], validate_etag[2], validate_etag[3], validate_etag[4], validate_etag[5], validate_etag[6], validate_etag[7]); diff --git a/examples/dev/button-hal/Makefile b/examples/dev/button-hal/Makefile index 071ec02ec..0c209918c 100644 --- a/examples/dev/button-hal/Makefile +++ b/examples/dev/button-hal/Makefile @@ -3,6 +3,6 @@ CONTIKI = ../../.. all: $(CONTIKI_PROJECT) -PLATFORMS_ONLY = srf06-cc26xx cc2538dk openmote-cc2538 zoul +PLATFORMS_ONLY = srf06-cc26xx cc2538dk openmote-cc2538 zoul native include $(CONTIKI)/Makefile.include diff --git a/examples/dev/button-hal/button-hal-example.c b/examples/dev/button-hal/button-hal-example.c index b4d584e3e..db34b86af 100644 --- a/examples/dev/button-hal/button-hal-example.c +++ b/examples/dev/button-hal/button-hal-example.c @@ -47,10 +47,13 @@ PROCESS_THREAD(button_hal_example, ev, data) printf("Button HAL example.\n"); printf("Device button count: %u.\n", button_hal_button_count); - printf("%s on pin %u with ID=0, Logic=%s, Pull=%s\n", - BUTTON_HAL_GET_DESCRIPTION(btn), btn->pin, - btn->negative_logic ? "Negative" : "Positive", - btn->pull == GPIO_HAL_PIN_CFG_PULL_UP ? "Pull Up" : "Pull Down"); + + if(btn) { + printf("%s on pin %u with ID=0, Logic=%s, Pull=%s\n", + BUTTON_HAL_GET_DESCRIPTION(btn), btn->pin, + btn->negative_logic ? "Negative" : "Positive", + btn->pull == GPIO_HAL_PIN_CFG_PULL_UP ? "Pull Up" : "Pull Down"); + } while(1) { diff --git a/examples/dev/gpio-hal/Makefile b/examples/dev/gpio-hal/Makefile index efbdf6e05..016f53377 100644 --- a/examples/dev/gpio-hal/Makefile +++ b/examples/dev/gpio-hal/Makefile @@ -1,7 +1,7 @@ CONTIKI_PROJECT = gpio-hal-example CONTIKI = ../../.. -PLATFORMS_ONLY = srf06-cc26xx cc2538dk openmote-cc2538 zoul +PLATFORMS_ONLY = srf06-cc26xx cc2538dk openmote-cc2538 zoul native include $(CONTIKI)/Makefile.identify-target diff --git a/examples/dev/gpio-hal/gpio-hal-example.c b/examples/dev/gpio-hal/gpio-hal-example.c index 040df3b38..380c06388 100644 --- a/examples/dev/gpio-hal/gpio-hal-example.c +++ b/examples/dev/gpio-hal/gpio-hal-example.c @@ -36,6 +36,7 @@ #include "dev/button-hal.h" #include +#include /*---------------------------------------------------------------------------*/ extern gpio_hal_pin_t out_pin1, out_pin2, out_pin3; extern gpio_hal_pin_t btn_pin; @@ -43,6 +44,13 @@ extern gpio_hal_pin_t btn_pin; static struct etimer et; static uint8_t counter; /*---------------------------------------------------------------------------*/ +/* Print gpio_hal_pin_mask_t using the correct format */ +#if GPIO_HAL_PIN_COUNT > 32 +#define PIN_MASK_FMT PRIx64 +#else +#define PIN_MASK_FMT PRIx32 +#endif +/*---------------------------------------------------------------------------*/ PROCESS(gpio_hal_example, "GPIO HAL Example"); AUTOSTART_PROCESSES(&gpio_hal_example); /*---------------------------------------------------------------------------*/ @@ -119,7 +127,8 @@ PROCESS_THREAD(gpio_hal_example, ev, data) } /* Test read */ - printf("%u: Pins are 1-%u, 2=%u, 3=%u, mask=0x%08lx\n", counter & 7, + printf("%u: Pins are 1-%u, 2=%u, 3=%u, mask=0x%08" PIN_MASK_FMT "\n", + counter & 7, gpio_hal_arch_read_pin(out_pin1), gpio_hal_arch_read_pin(out_pin2), gpio_hal_arch_read_pin(out_pin3), diff --git a/examples/dev/gpio-hal/native/pins.c b/examples/dev/gpio-hal/native/pins.c new file mode 100644 index 000000000..10472b78a --- /dev/null +++ b/examples/dev/gpio-hal/native/pins.c @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2018, George Oikonomou - http://www.spd.gr + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/*---------------------------------------------------------------------------*/ +#include "contiki.h" +#include "dev/gpio-hal.h" +/*---------------------------------------------------------------------------*/ +gpio_hal_pin_t out_pin1 = 0; +gpio_hal_pin_t out_pin2 = 1; +gpio_hal_pin_t out_pin3 = 2; +/*---------------------------------------------------------------------------*/ +gpio_hal_pin_t btn_pin = 4; +/*---------------------------------------------------------------------------*/ diff --git a/examples/hello-world/hello-world.c b/examples/hello-world/hello-world.c index 30724140e..e6d452d9e 100644 --- a/examples/hello-world/hello-world.c +++ b/examples/hello-world/hello-world.c @@ -46,10 +46,21 @@ AUTOSTART_PROCESSES(&hello_world_process); /*---------------------------------------------------------------------------*/ PROCESS_THREAD(hello_world_process, ev, data) { + static struct etimer timer; + PROCESS_BEGIN(); - printf("Hello, world\n"); - + /* Setup a periodic timer that expires after 10 seconds. */ + etimer_set(&timer, CLOCK_SECOND * 10); + + while(1) { + printf("Hello, world\n"); + + /* Wait for the periodic timer to expire and then restart the timer. */ + PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&timer)); + etimer_reset(&timer); + } + PROCESS_END(); } /*---------------------------------------------------------------------------*/ diff --git a/examples/ipso-objects/Makefile b/examples/ipso-objects/Makefile deleted file mode 100644 index d77f4200a..000000000 --- a/examples/ipso-objects/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -CONTIKI_PROJECT = example-ipso-objects - -CONTIKI_SOURCEFILES += serial-protocol.c example-ipso-temperature.c - -PLATFORMS_EXCLUDE = sky - -all: $(CONTIKI_PROJECT) - -MODULES += os/net/app-layer/coap -MODULES += os/services/lwm2m -MODULES += os/services/ipso-objects - -CONTIKI=../.. -include $(CONTIKI)/Makefile.include - -# border router rules -$(CONTIKI)/tools/tunslip6: $(CONTIKI)/tools/tunslip6.c - (cd $(CONTIKI)/tools && $(MAKE) tunslip6) - -connect-router: $(CONTIKI)/tools/tunslip6 - sudo $(CONTIKI)/tools/tunslip6 aaaa::1/64 - -connect-router-cooja: $(CONTIKI)/tools/tunslip6 - sudo $(CONTIKI)/tools/tunslip6 -a 127.0.0.1 -p 60001 aaaa::1/64 - -connect-router-native: $(CONTIKI)/examples/native-border-router/border-router.native - sudo $(CONTIKI)/examples/native-border-router/border-router.native -a 127.0.0.1 -p 60001 aaaa::1/64 diff --git a/examples/ipso-objects/README.md b/examples/ipso-objects/README.md deleted file mode 100644 index e9be82dcb..000000000 --- a/examples/ipso-objects/README.md +++ /dev/null @@ -1,48 +0,0 @@ -IPSO Objects Example -============================================ - -This is an example of how to make use of the IPSO Object and LWM2M -implementation in Contiki. - -The LWM2M implementation is based on the Erbium CoAP implementation -and consists of two apps: lwm2m-engine and ipso-objects. The -lwm2m-engine handle the specifics of LWM2M including bootstrapping and -how read/writes of objects and resources are handled. The ipso-objects -contains implementations of some of the IPSO Smart Objects. - -The implementation was used during the IPSO Interop in May 2015, -Kista, Sweden, and was successfully tested with other -implementations. - -The examples use some of the basic IPSO object for controlling LEDs on -Contiki devices and for reading out temperature. - -##Testing IPSO-objects with Leshan - -First program a device with the examples/ipso-objects/example-ipso-objects.c - -```bash ->make example-ipso-objects.upload TARGET=zoul ->... -``` - -After that start up a native-border router or other border router on fd00::1/64 -or another prefix - NOTE: if you use another prefix you will need to change LWM2M_SERVER_ADDRESS for which the device will register - in project-conf.h: -``` -#define LWM2M_SERVER_ADDRESS "fd00::1" -``` - -Then when everything is setup you can download a Leshan and use that to -test controlling LEDs of the device. - -###Starting Leshan -```bash -wget https://hudson.eclipse.org/leshan/job/leshan/lastSuccessfulBuild/artifact/leshan-standalone.jar -java -jar ./leshan-standalone.jar -``` -Browse to leshans device page with http://127.0.0.1:8080 . - -When you have started the border-router and also Leshan you should now -start (or reboot) your IPSO Object enabled device. Within 30 seconds -you should be able to see it on the Leshan device page. - diff --git a/examples/ipv6-hooks/Makefile b/examples/libs/ipv6-hooks/Makefile similarity index 84% rename from examples/ipv6-hooks/Makefile rename to examples/libs/ipv6-hooks/Makefile index be8cc953e..63085face 100644 --- a/examples/ipv6-hooks/Makefile +++ b/examples/libs/ipv6-hooks/Makefile @@ -1,5 +1,5 @@ CONTIKI_PROJECT = ipv6-hooks all: $(CONTIKI_PROJECT) -CONTIKI=../.. +CONTIKI=../../.. include $(CONTIKI)/Makefile.include diff --git a/examples/ipv6-hooks/README.md b/examples/libs/ipv6-hooks/README.md similarity index 100% rename from examples/ipv6-hooks/README.md rename to examples/libs/ipv6-hooks/README.md diff --git a/examples/ipv6-hooks/ipv6-hooks.c b/examples/libs/ipv6-hooks/ipv6-hooks.c similarity index 100% rename from examples/ipv6-hooks/ipv6-hooks.c rename to examples/libs/ipv6-hooks/ipv6-hooks.c diff --git a/examples/libs/stack-check/project-conf.h b/examples/libs/stack-check/project-conf.h index 2509dd080..a9cbe2265 100644 --- a/examples/libs/stack-check/project-conf.h +++ b/examples/libs/stack-check/project-conf.h @@ -36,9 +36,9 @@ * */ -#ifndef __PROJECT_CONF_H__ -#define __PROJECT_CONF_H__ +#ifndef PROJECT_CONF_H_ +#define PROJECT_CONF_H_ #define STACK_CHECK_CONF_ENABLED 1 -#endif /* __PROJECT_CONF_H__ */ +#endif /* PROJECT_CONF_H_ */ diff --git a/examples/lwm2m-ipso-objects/Makefile b/examples/lwm2m-ipso-objects/Makefile new file mode 100644 index 000000000..7fa79d1ee --- /dev/null +++ b/examples/lwm2m-ipso-objects/Makefile @@ -0,0 +1,14 @@ +CONTIKI_PROJECT = example-ipso-objects + +CONTIKI_SOURCEFILES += serial-protocol.c example-ipso-temperature.c + +PLATFORMS_EXCLUDE = sky + +all: $(CONTIKI_PROJECT) + +MODULES += os/net/app-layer/coap +MODULES += os/services/lwm2m +MODULES += os/services/ipso-objects + +CONTIKI=../.. +include $(CONTIKI)/Makefile.include diff --git a/examples/lwm2m-ipso-objects/README.md b/examples/lwm2m-ipso-objects/README.md new file mode 100644 index 000000000..d31b3a844 --- /dev/null +++ b/examples/lwm2m-ipso-objects/README.md @@ -0,0 +1,10 @@ +LWM2M with IPSO Objects Example +============================================ + +This is an OMA LWM2M example implementing IPSO Objects. +It can connect to a Leshan server out-of-the-box. +Important configuration parameters: +* `LWM2M_SERVER_ADDRESS`: the address of the server to register to (or bootstrap from) +* `REGISTER_WITH_LWM2M_BOOTSTRAP_SERVER`: set to bootstrap via `LWM2M_SERVER_ADDRESS` and then obtain the registration server address + +A tutorial for setting up this example is provided on the wiki. diff --git a/examples/ipso-objects/example-ipso-objects.c b/examples/lwm2m-ipso-objects/example-ipso-objects.c similarity index 100% rename from examples/ipso-objects/example-ipso-objects.c rename to examples/lwm2m-ipso-objects/example-ipso-objects.c diff --git a/examples/ipso-objects/example-ipso-temperature.c b/examples/lwm2m-ipso-objects/example-ipso-temperature.c similarity index 100% rename from examples/ipso-objects/example-ipso-temperature.c rename to examples/lwm2m-ipso-objects/example-ipso-temperature.c diff --git a/examples/ipso-objects/example-server.c b/examples/lwm2m-ipso-objects/example-server.c similarity index 70% rename from examples/ipso-objects/example-server.c rename to examples/lwm2m-ipso-objects/example-server.c index 4eac38f69..98e1fef9a 100644 --- a/examples/ipso-objects/example-server.c +++ b/examples/lwm2m-ipso-objects/example-server.c @@ -38,19 +38,23 @@ #include "contiki.h" #include "net/ipv6/uip.h" +#include "net/ipv6/uip-ds6.h" #include "net/netstack.h" #include "net/routing/routing.h" -#include "coap-constants.h" -#include "coap-engine.h" +#include "coap-transport.h" +#include "coap-blocking-api.h" #include "lwm2m-engine.h" #include "lwm2m-tlv.h" #include "dev/serial-line.h" #include "serial-protocol.h" +#include #define DEBUG DEBUG_PRINT #include "net/ipv6/uip-debug.h" -#define REMOTE_PORT UIP_HTONS(COAP_DEFAULT_PORT) +#define REMOTE_PORT UIP_HTONS(COAP_DEFAULT_PORT) + +#define EVENT_RUN_NOW 0 #define URL_WELL_KNOWN ".well-known/core" #define URL_DEVICE_MODEL "/3/0/1" @@ -63,8 +67,8 @@ #define NODE_HAS_TYPE (1 << 0) struct node { - uip_ipaddr_t ipaddr; - char type[32]; + coap_endpoint_t endpoint; + char type[64]; uint8_t flags; uint8_t retries; }; @@ -86,13 +90,15 @@ add_node(const uip_ipaddr_t *addr) { int i; for(i = 0; i < node_count; i++) { - if(uip_ipaddr_cmp(&nodes[i].ipaddr, addr)) { + if(uip_ipaddr_cmp(&nodes[i].endpoint.ipaddr, addr)) { /* Node already added */ return &nodes[i]; } } if(node_count < MAX_NODES) { - uip_ipaddr_copy(&nodes[node_count].ipaddr, addr); + memset(&nodes[node_count].endpoint, 0, sizeof(coap_endpoint_t)); + uip_ipaddr_copy(&nodes[node_count].endpoint.ipaddr, addr); + nodes[node_count].endpoint.port = REMOTE_PORT; return &nodes[node_count++]; } return NULL; @@ -107,13 +113,13 @@ set_value(const uip_ipaddr_t *addr, char *uri, char *value) printf(" URI: %s Value: %s\n", uri, value); for(i = 0; i < node_count; i++) { - if(uip_ipaddr_cmp(&nodes[i].ipaddr, addr)) { + if(uip_ipaddr_cmp(&nodes[i].endpoint.ipaddr, addr)) { /* setup command */ current_target = &nodes[i]; current_request = COAP_PUT; strncpy(current_uri, uri, sizeof(current_uri) - 1); strncpy(current_value, value, sizeof(current_value) - 1); - process_poll(&router_process); + process_post(&router_process, EVENT_RUN_NOW, NULL); break; } } @@ -128,13 +134,13 @@ get_value(const uip_ipaddr_t *addr, char *uri) printf(" URI: %s\n", uri); for(i = 0; i < node_count; i++) { - if(uip_ipaddr_cmp(&nodes[i].ipaddr, addr)) { + if(uip_ipaddr_cmp(&nodes[i].endpoint.ipaddr, addr)) { /* setup command */ current_target = &nodes[i]; current_request = COAP_GET; strncpy(current_uri, uri, sizeof(current_uri) - 1); current_value[0] = 0; - process_poll(&router_process); + process_post(&router_process, EVENT_RUN_NOW, NULL); break; } } @@ -151,7 +157,7 @@ print_node_list(void) printf(";"); } printf("%s,", nodes[i].type); - uip_debug_ipaddr_print(&nodes[i].ipaddr); + uip_debug_ipaddr_print(&nodes[i].endpoint.ipaddr); } } printf("\n"); @@ -162,7 +168,7 @@ print_node_list(void) * handle responses. */ static void -client_chunk_handler(void *response) +client_chunk_handler(coap_message_t *response) { const uint8_t *chunk; unsigned int format; @@ -172,7 +178,9 @@ client_chunk_handler(void *response) /* if(len > 0) { */ /* printf("|%.*s (%d,%d)", len, (char *)chunk, len, format); */ /* } */ - if(current_target != NULL && fetching_type) { + if(response->code >= BAD_REQUEST_4_00) { + PRINTF("\nReceived error %u: %.*s\n", response->code, len, (char *)chunk); + } else if(current_target != NULL && fetching_type) { if(len > sizeof(current_target->type) - 1) { len = sizeof(current_target->type) - 1; } @@ -181,7 +189,7 @@ client_chunk_handler(void *response) current_target->flags |= NODE_HAS_TYPE; PRINTF("\nNODE "); - PRINT6ADDR(¤t_target->ipaddr); + PRINT6ADDR(¤t_target->endpoint.ipaddr); PRINTF(" HAS TYPE %s\n", current_target->type); } else { /* otherwise update the current value */ @@ -193,7 +201,9 @@ client_chunk_handler(void *response) /* tlv.type, tlv.length, tlv.id, tlv.value[0]); */ int value = lwm2m_tlv_get_int32(&tlv); - snprintf(current_value, sizeof(current_value), "%d", value); + snprintf(current_value, sizeof(current_value) - 1, "%d", value); + } else { + PRINTF("Failed to parse LWM2M TLV\n"); } } else { if(len > sizeof(current_value) - 1) { @@ -205,72 +215,81 @@ client_chunk_handler(void *response) } } /*---------------------------------------------------------------------------*/ -static void -setup_network(void) +#if UIP_CONF_IPV6_RPL +static bool +check_rpl_routes(void) { - uip_ipaddr_t ipaddr; - struct uip_ds6_addr *root_if; - rpl_dag_t *dag; - int i; - uint8_t state; + uip_sr_node_t *link; + uip_ipaddr_t child_ipaddr; + uip_ipaddr_t parent_ipaddr; -#if UIP_CONF_ROUTER -/** - * The choice of server address determines its 6LoWPAN header compression. - * Obviously the choice made here must also be selected in udp-client.c. - * - * For correct Wireshark decoding using a sniffer, add the /64 prefix to the 6LowPAN protocol preferences, - * e.g. set Context 0 to fd00::. At present Wireshark copies Context/128 and then overwrites it. - * (Setting Context 0 to fd00::1111:2222:3333:4444 will report a 16 bit compressed address of fd00::1111:22ff:fe33:xxxx) - * Note Wireshark's IPCMV6 checksum verification depends on the correct uncompressed addresses. - */ -#if 0 -/* Mode 1 - 64 bits inline */ - uip_ip6addr(&ipaddr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 1); -#elif 1 -/* Mode 2 - 16 bits inline */ - uip_ip6addr(&ipaddr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0x00ff, 0xfe00, 1); -#else -/* Mode 3 - derived from link local (MAC) address */ - uip_ip6addr(&ipaddr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0); - uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr); -#endif + /* Our routing links */ + for(link = uip_sr_node_head(); link != NULL; link = uip_sr_node_next(link)) { + NETSTACK_ROUTING.get_sr_node_ipaddr(&child_ipaddr, link); - NETSTACK_ROUTING.root_set_prefix(&ipaddr, &ipaddr); - NETSTACK_ROUTING.root_start(); -#endif /* UIP_CONF_ROUTER */ - - PRINTF("IPv6 addresses: "); - for(i = 0; i < UIP_DS6_ADDR_NB; i++) { - state = uip_ds6_if.addr_list[i].state; - if(state == ADDR_TENTATIVE || state == ADDR_PREFERRED) { - PRINT6ADDR(&uip_ds6_if.addr_list[i].ipaddr); - PRINTF("\n"); - /* hack to make address "final" */ - if (state == ADDR_TENTATIVE) { - uip_ds6_if.addr_list[i].state = ADDR_PREFERRED; - } + if(link->parent == NULL) { + /* Igore the DAG root */ + continue; } + + current_target = add_node(&child_ipaddr); + if(current_target == NULL || + (current_target->flags & NODE_HAS_TYPE) != 0 || + current_target->retries > 5) { + continue; + } + + NETSTACK_ROUTING.get_sr_node_ipaddr(&parent_ipaddr, link->parent); + PRINTF(" "); + PRINT6ADDR(&child_ipaddr); + PRINTF(" -> "); + PRINT6ADDR(&parent_ipaddr); + PRINTF("\n"); + return true; } + return false; } +#endif /* UIP_CONF_IPV6_RPL */ +/*---------------------------------------------------------------------------*/ +#if (UIP_MAX_ROUTES != 0) +static bool +check_routes(void) +{ + uip_ds6_route_t *r; + + for(r = uip_ds6_route_head(); r != NULL; r = uip_ds6_route_next(r)) { + current_target = add_node(&r->ipaddr); + if(current_target == NULL || + (current_target->flags & NODE_HAS_TYPE) != 0 || + current_target->retries > 5) { + continue; + } + PRINTF(" "); + PRINT6ADDR(&r->ipaddr); + PRINTF(" -> "); + nexthop = uip_ds6_route_nexthop(r); + if(nexthop != NULL) { + PRINT6ADDR(nexthop); + } else { + PRINTF("-"); + } + PRINTF("\n"); + return true; + } + return false; +} +#endif /* (UIP_MAX_ROUTES != 0) */ /*---------------------------------------------------------------------------*/ PROCESS_THREAD(router_process, ev, data) { /* This way the message can be treated as pointer as usual. */ static coap_message_t request[1]; static struct etimer timer; - uip_ds6_route_t *r; - uip_ipaddr_t *nexthop; - int n; PROCESS_BEGIN(); - PROCESS_PAUSE(); - - /* receives all CoAP messages */ - coap_engine_init(); - - setup_network(); + /* Initialize DAG root */ + NETSTACK_ROUTING.root_start(); while(1) { etimer_set(&timer, CLOCK_SECOND * 5); @@ -283,28 +302,15 @@ PROCESS_THREAD(router_process, ev, data) if(etimer_expired(&timer)) { current_target = NULL; - n = 0; - for(r = uip_ds6_route_head(); r != NULL; r = uip_ds6_route_next(r)) { - current_target = add_node(&r->ipaddr); - if(current_target == NULL || - (current_target->flags & NODE_HAS_TYPE) != 0 || - current_target->retries > 5) { - continue; - } - PRINTF(" "); - PRINT6ADDR(&r->ipaddr); - PRINTF(" -> "); - nexthop = uip_ds6_route_nexthop(r); - if(nexthop != NULL) { - PRINT6ADDR(nexthop); - PRINTF("\n"); - } else { - PRINTF("-"); - } - PRINTF("\n"); - n++; - break; +#if UIP_CONF_IPV6_RPL + check_rpl_routes(); +#endif /* UIP_CONF_IPV6_RPL */ + +#if (UIP_MAX_ROUTES != 0) + if(current_target == NULL) { + check_routes(); } +#endif /* (UIP_MAX_ROUTES != 0) */ } /* This is a node type discovery */ @@ -319,15 +325,15 @@ PROCESS_THREAD(router_process, ev, data) current_target->retries++; PRINTF("CoAP request to ["); - PRINT6ADDR(¤t_target->ipaddr); - PRINTF("]:%u (%u tx)\n", UIP_HTONS(REMOTE_PORT), + PRINT6ADDR(¤t_target->endpoint.ipaddr); + PRINTF("]:%u (%u tx)\n", UIP_HTONS(current_target->endpoint.port), current_target->retries); fetching_type = 1; - COAP_BLOCKING_REQUEST(¤t_target->ipaddr, REMOTE_PORT, request, + COAP_BLOCKING_REQUEST(¤t_target->endpoint, request, client_chunk_handler); fetching_type = 0; - strncpy(current_uri, URL_LIGHT_CONTROL, sizeof(current_uri)); + strncpy(current_uri, URL_LIGHT_CONTROL, sizeof(current_uri) - 1); printf("\n--Done--\n"); } @@ -344,10 +350,11 @@ PROCESS_THREAD(router_process, ev, data) } PRINTF("CoAP request to ["); - PRINT6ADDR(¤t_target->ipaddr); - PRINTF("]:%u %s\n", UIP_HTONS(REMOTE_PORT), current_uri); + PRINT6ADDR(¤t_target->endpoint.ipaddr); + PRINTF("]:%u %s\n", UIP_HTONS(current_target->endpoint.port), + current_uri); - COAP_BLOCKING_REQUEST(¤t_target->ipaddr, REMOTE_PORT, request, + COAP_BLOCKING_REQUEST(¤t_target->endpoint, request, client_chunk_handler); /* print out result of command */ @@ -356,13 +363,12 @@ PROCESS_THREAD(router_process, ev, data) } else { printf("g "); } - uip_debug_ipaddr_print(¤t_target->ipaddr); + uip_debug_ipaddr_print(¤t_target->endpoint.ipaddr); printf(" %s %s\n", current_uri, current_value); current_target = NULL; current_uri[0] = 0; current_value[0] = 0; - } } diff --git a/examples/ipso-objects/project-conf.h b/examples/lwm2m-ipso-objects/project-conf.h similarity index 100% rename from examples/ipso-objects/project-conf.h rename to examples/lwm2m-ipso-objects/project-conf.h diff --git a/examples/ipso-objects/serial-protocol.c b/examples/lwm2m-ipso-objects/serial-protocol.c similarity index 97% rename from examples/ipso-objects/serial-protocol.c rename to examples/lwm2m-ipso-objects/serial-protocol.c index bc59294f6..00c7e0139 100644 --- a/examples/ipso-objects/serial-protocol.c +++ b/examples/lwm2m-ipso-objects/serial-protocol.c @@ -60,7 +60,7 @@ find_next_sep(const char *str, char sep, int pos) /* * l - list all discovered devices * s - set - * d - get + * g - get */ void serial_protocol_input(char *data) @@ -119,8 +119,12 @@ serial_protocol_input(char *data) } break; } + case '\0': + /* Ignore empty lines */ + break; default: printf("Unknown command\n"); } + printf("> "); } /*---------------------------------------------------------------------------*/ diff --git a/examples/ipso-objects/serial-protocol.h b/examples/lwm2m-ipso-objects/serial-protocol.h similarity index 100% rename from examples/ipso-objects/serial-protocol.h rename to examples/lwm2m-ipso-objects/serial-protocol.h diff --git a/examples/mqtt-client/Makefile b/examples/mqtt-client/Makefile index c4741bec9..d315cfea3 100644 --- a/examples/mqtt-client/Makefile +++ b/examples/mqtt-client/Makefile @@ -8,6 +8,6 @@ CONTIKI = ../.. MODULES_REL += arch/platform/$(TARGET) -PLATFORMS_ONLY = srf06-cc26xx cc2538dk openmote-cc2538 zoul +PLATFORMS_ONLY = srf06-cc26xx cc2538dk openmote-cc2538 zoul native include $(CONTIKI)/Makefile.include diff --git a/examples/mqtt-client/README.md b/examples/mqtt-client/README.md index 44bba8877..8312ec024 100644 --- a/examples/mqtt-client/README.md +++ b/examples/mqtt-client/README.md @@ -13,25 +13,34 @@ The demo will give some visual feedback with a LED (configurable): This example is known to work with all platforms that support the new button API. +This example can operate in two modes: A default mode to be used with the +mosquitto MQTT broker and a second mode to be used with the IBM Watson IoT +platform. + +To enable Watson mode, define `MQTT_CLIENT_CONF_WITH_IBM_WATSON` as 1 in the +example's `project-conf.h`. + Publishing ---------- By default the example will attempt to publish readings to an MQTT broker -running on the IPv6 address specified as `MQTT_DEMO_BROKER_IP_ADDR` in +running on the IPv6 address specified as `MQTT_CLIENT_CONF_BROKER_IP_ADDR` in `project-conf.h`. This functionality was tested successfully with -[mosquitto](http://mosquitto.org/). +[mosquitto](http://mosquitto.org/). This define will be ignored in IBM Watson +mode. The publish messages include sensor readings but also some other information, such as device uptime in seconds and a message sequence number. The demo will publish to topic `iot-2/evt/status/fmt/json`. The device will connect using -client-id `d:contiki-ng:mqtt-client:`, where `` gets -constructed from the device's IEEE address. +client-id `d::mqtt-client:`, where `` gets +constructed from the device's IEEE address. `` can be controlled +through the `MQTT_CLIENT_CONF_ORG_ID` define. Subscribing ----------- You can also subscribe to topics and receive commands, but this will only work if you use "Org ID" != 'quickstart'. To achieve this, you will need to -change 'Org ID' (`DEFAULT_ORG_ID`). In this scenario, the device will subscribe -to: +change `MQTT_CLIENT_CONF_ORG_ID` in `project-conf.h`. In this scenario, the +device will subscribe to: `iot-2/cmd/+/fmt/json` @@ -53,13 +62,18 @@ messages, outgoing publish messages use proper json payload. IBM Quickstart Service ---------------------- It is also possible to publish to IBM's quickstart service. To do so, you need -to undefine `MQTT_DEMO_BROKER_IP_ADDR`. +to enable this mode by setting `MQTT_CLIENT_CONF_WITH_IBM_WATSON` to 1 in +`project-conf.h`. The device will then try to connect to IBM's quickstart over NAT64, so you will need a NAT64 gateway in your network to make this work. A guide on how to -setup NAT64 is out of scope here. +setup NAT64 is out of scope here, but you can find one in the +[Contiki-NG wiki](https://github.com/contiki-ng/contiki-ng/wiki/NAT64-for-Contiki%E2%80%90NG). -If you want to use IBM's cloud service with a registered device, change -'Org ID' (`DEFAULT_ORG_ID`) and provide the 'Auth Token' (`DEFAULT_AUTH_TOKEN`), -which acts as a 'password', but bear in mind that it gets transported in clear -text. +If you want to use IBM's cloud service with a registered device, you will need +to set `MQTT_CLIENT_CONF_ORG_ID` and then also to provide the 'Auth Token' +(`MQTT_CLIENT_CONF_AUTH_TOKEN`), which acts as a 'password'. You will also +need to configure your Organisation / Registered device on Watson such that +TLS is optional. + +Note: The token will be transported in cleartext. diff --git a/examples/mqtt-client/mqtt-client.c b/examples/mqtt-client/mqtt-client.c index 258660459..4e128ae37 100644 --- a/examples/mqtt-client/mqtt-client.c +++ b/examples/mqtt-client/mqtt-client.c @@ -49,22 +49,61 @@ #define LOG_MODULE "mqtt-client" #define LOG_LEVEL LOG_LEVEL_NONE /*---------------------------------------------------------------------------*/ -/* - * IBM server: messaging.quickstart.internetofthings.ibmcloud.com - * (184.172.124.189) mapped in an NAT64 (prefix 64:ff9b::/96) IPv6 address - * Note: If not able to connect; lookup the IP address again as it may change. - * - * Alternatively, publish to a local MQTT broker (e.g. mosquitto) running on - * the node that hosts your border router - */ -#ifdef MQTT_CLIENT_CONF_BROKER_IP_ADDR -static const char *broker_ip = MQTT_CLIENT_CONF_BROKER_IP_ADDR; -#define DEFAULT_ORG_ID "contiki-ng" +/* Controls whether the example will work in IBM Watson IoT platform mode */ +#ifdef MQTT_CLIENT_CONF_WITH_IBM_WATSON +#define MQTT_CLIENT_WITH_IBM_WATSON MQTT_CLIENT_CONF_WITH_IBM_WATSON #else -static const char *broker_ip = "0064:ff9b:0000:0000:0000:0000:b8ac:7cbd"; -#define DEFAULT_ORG_ID "quickstart" +#define MQTT_CLIENT_WITH_IBM_WATSON 0 #endif /*---------------------------------------------------------------------------*/ +/* MQTT broker address. Ignored in Watson mode */ +#ifdef MQTT_CLIENT_CONF_BROKER_IP_ADDR +#define MQTT_CLIENT_BROKER_IP_ADDR MQTT_CLIENT_CONF_BROKER_IP_ADDR +#else +#define MQTT_CLIENT_BROKER_IP_ADDR "fd00::1" +#endif +/*---------------------------------------------------------------------------*/ +/* + * MQTT Org ID. + * + * If it equals "quickstart", the client will connect without authentication. + * In all other cases, the client will connect with authentication mode. + * + * In Watson mode, the username will be "use-token-auth". In non-Watson mode + * the username will be MQTT_CLIENT_USERNAME. + * + * In all cases, the password will be MQTT_CLIENT_AUTH_TOKEN. + */ +#ifdef MQTT_CLIENT_CONF_ORG_ID +#define MQTT_CLIENT_ORG_ID MQTT_CLIENT_CONF_ORG_ID +#else +#define MQTT_CLIENT_ORG_ID "quickstart" +#endif +/*---------------------------------------------------------------------------*/ +/* MQTT token */ +#ifdef MQTT_CLIENT_CONF_AUTH_TOKEN +#define MQTT_CLIENT_AUTH_TOKEN MQTT_CLIENT_CONF_AUTH_TOKEN +#else +#define MQTT_CLIENT_AUTH_TOKEN "AUTHTOKEN" +#endif +/*---------------------------------------------------------------------------*/ +#if MQTT_CLIENT_WITH_IBM_WATSON +/* With IBM Watson support */ +static const char *broker_ip = "0064:ff9b:0000:0000:0000:0000:b8ac:7cbd"; +#define MQTT_CLIENT_USERNAME "use-token-auth" + +#else /* MQTT_CLIENT_WITH_IBM_WATSON */ +/* Without IBM Watson support. To be used with other brokers, e.g. Mosquitto */ +static const char *broker_ip = MQTT_CLIENT_BROKER_IP_ADDR; + +#ifdef MQTT_CLIENT_CONF_USERNAME +#define MQTT_CLIENT_USERNAME MQTT_CLIENT_CONF_USERNAME +#else +#define MQTT_CLIENT_USERNAME "use-token-auth" +#endif + +#endif /* MQTT_CLIENT_WITH_IBM_WATSON */ +/*---------------------------------------------------------------------------*/ #ifdef MQTT_CLIENT_CONF_STATUS_LED #define MQTT_CLIENT_STATUS_LED MQTT_CLIENT_CONF_STATUS_LED #else @@ -122,18 +161,12 @@ static uint8_t state; #define CONFIG_CMD_TYPE_LEN 8 #define CONFIG_IP_ADDR_STR_LEN 64 /*---------------------------------------------------------------------------*/ -#define RSSI_MEASURE_INTERVAL_MAX 86400 /* secs: 1 day */ -#define RSSI_MEASURE_INTERVAL_MIN 5 /* secs */ -#define PUBLISH_INTERVAL_MAX 86400 /* secs: 1 day */ -#define PUBLISH_INTERVAL_MIN 5 /* secs */ -/*---------------------------------------------------------------------------*/ /* A timeout used when waiting to connect to a network */ #define NET_CONNECT_PERIODIC (CLOCK_SECOND >> 2) #define NO_NET_LED_DURATION (NET_CONNECT_PERIODIC >> 1) /*---------------------------------------------------------------------------*/ /* Default configuration values */ #define DEFAULT_TYPE_ID "mqtt-client" -#define DEFAULT_AUTH_TOKEN "AUTHZ" #define DEFAULT_EVENT_TYPE_ID "status" #define DEFAULT_SUBSCRIBE_CMD_TYPE "+" #define DEFAULT_BROKER_PORT 1883 @@ -423,9 +456,10 @@ init_config() /* Populate configuration with default values */ memset(&conf, 0, sizeof(mqtt_client_config_t)); - memcpy(conf.org_id, DEFAULT_ORG_ID, strlen(DEFAULT_ORG_ID)); + memcpy(conf.org_id, MQTT_CLIENT_ORG_ID, strlen(MQTT_CLIENT_ORG_ID)); memcpy(conf.type_id, DEFAULT_TYPE_ID, strlen(DEFAULT_TYPE_ID)); - memcpy(conf.auth_token, DEFAULT_AUTH_TOKEN, strlen(DEFAULT_AUTH_TOKEN)); + memcpy(conf.auth_token, MQTT_CLIENT_AUTH_TOKEN, + strlen(MQTT_CLIENT_AUTH_TOKEN)); memcpy(conf.event_type_id, DEFAULT_EVENT_TYPE_ID, strlen(DEFAULT_EVENT_TYPE_ID)); memcpy(conf.broker_ip, broker_ip, strlen(broker_ip)); @@ -568,7 +602,7 @@ state_machine(void) state = STATE_ERROR; break; } else { - mqtt_set_username_password(&conn, "use-token-auth", + mqtt_set_username_password(&conn, MQTT_CLIENT_USERNAME, conf.auth_token); } } diff --git a/examples/mqtt-client/project-conf.h b/examples/mqtt-client/project-conf.h index 7b041ae38..66ba909ce 100644 --- a/examples/mqtt-client/project-conf.h +++ b/examples/mqtt-client/project-conf.h @@ -35,8 +35,40 @@ /* Enable TCP */ #define UIP_CONF_TCP 1 -/* If undefined, the demo will attempt to connect to IBM's quickstart */ +/* Change to 1 to use with the IBM Watson IoT platform */ +#define MQTT_CLIENT_CONF_WITH_IBM_WATSON 0 + +/* + * The IPv6 address of the MQTT broker to connect to. + * Ignored if MQTT_CLIENT_CONF_WITH_IBM_WATSON is 1 + */ #define MQTT_CLIENT_CONF_BROKER_IP_ADDR "fd00::1" + +/* + * The Organisation ID. + * + * When in Watson mode, the example will default to Org ID "quickstart" and + * will connect using non-authenticated mode. If you want to use registered + * devices, set your Org ID here and then make sure you set the correct token + * through MQTT_CLIENT_CONF_AUTH_TOKEN. + */ +#define MQTT_CLIENT_CONF_ORG_ID "quickstart" + +/* + * The MQTT username. + * + * Ignored in Watson mode: In this mode the username is always "use-token-auth" + */ +#define MQTT_CLIENT_CONF_USERNAME "mqtt-client-username" + +/* + * The MQTT auth token (password) used when connecting to the MQTT broker. + * + * Used with as well as without Watson. + * + * Transported in cleartext! + */ +#define MQTT_CLIENT_CONF_AUTH_TOKEN "AUTHTOKEN" /*---------------------------------------------------------------------------*/ #endif /* PROJECT_CONF_H_ */ /*---------------------------------------------------------------------------*/ diff --git a/examples/multicast/Makefile b/examples/multicast/Makefile index 6037c8172..86c16e481 100644 --- a/examples/multicast/Makefile +++ b/examples/multicast/Makefile @@ -3,6 +3,8 @@ all: $(CONTIKI_PROJECT) # nrf52dk only supports slave mode, i.e., with no routing PLATFORMS_EXCLUDE = nrf52dk +# does not fit sky motes +PLATFORMS_EXCLUDE += sky CONTIKI = ../.. diff --git a/examples/multicast/project-conf.h b/examples/multicast/project-conf.h index 45fe1309e..c1bb6910e 100644 --- a/examples/multicast/project-conf.h +++ b/examples/multicast/project-conf.h @@ -54,7 +54,12 @@ #define UIP_MCAST6_ROUTE_CONF_ROUTES 1 /* Code/RAM footprint savings so that things will fit on our device */ +#ifndef NETSTACK_MAX_ROUTE_ENTRIES #define NETSTACK_MAX_ROUTE_ENTRIES 10 +#endif + +#ifndef NBR_TABLE_CONF_MAX_NEIGHBORS #define NBR_TABLE_CONF_MAX_NEIGHBORS 10 +#endif #endif /* PROJECT_CONF_H_ */ diff --git a/examples/coap/sky/module-macros.h b/examples/multicast/srf06-cc26xx/module-macros.h similarity index 73% rename from examples/coap/sky/module-macros.h rename to examples/multicast/srf06-cc26xx/module-macros.h index 3fcb04015..460688ebd 100644 --- a/examples/coap/sky/module-macros.h +++ b/examples/multicast/srf06-cc26xx/module-macros.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, RISE SICS AB. + * Copyright (c) 2018, University of Bristol - http://www.bristol.ac.uk/ * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -27,21 +27,8 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#error The CoAP example no longer fits the limited ROM in the Tmote Sky. \ - Please select another platform with more ROM to compile the CoAP example. - -/*---------------------------------------------------------------------------*/ -#define COAP_OBSERVE_CLIENT 0 - -#define COAP_MAX_CHUNK_SIZE 48 - -/* Turn off DAO-ACK and probing to make code smaller */ -#define RPL_CONF_WITH_DAO_ACK 0 - -#define LOG_CONF_LEVEL_MAIN 0 - -#define DCOSYNCH_CONF_ENABLED 0 - -#define PROCESS_CONF_NUMEVENTS 8 /*---------------------------------------------------------------------------*/ +/* Code/RAM footprint savings so that things will fit on sensortags */ +#define NETSTACK_MAX_ROUTE_ENTRIES 4 +#define NBR_TABLE_CONF_MAX_NEIGHBORS 4 +#define QUEUEBUF_CONF_NUM 4 diff --git a/examples/platform-specific/cc26xx/ble-ipv6/README.md b/examples/platform-specific/cc26xx/ble-ipv6/README.md index d72ab752d..d33c7329f 100644 --- a/examples/platform-specific/cc26xx/ble-ipv6/README.md +++ b/examples/platform-specific/cc26xx/ble-ipv6/README.md @@ -6,7 +6,7 @@ can be exchanged using BLE connections (IPv6 over BLE). This Contiki extenstion implements [BLEach][bleachWeb], a fully open-source IPv6-over-BLE stack for Contiki. BLEach in Contiki-NG can be used for node (BLE slave) devices. -It was developed by +It was developed by * [Michael Spoerk](http://www.michaelspoerk.com), Graz University of Technology, michael.spoerk@tugraz.at, github user: [spoerk](https://github.com/spoerk) This IPv6-over-BLE stack is presented and evaluated in the paper: @@ -21,7 +21,7 @@ This implementation includes: * BLE link layer support for version [4.1][bleSpec]: * BLE advertisement * BLE connection slave - + It has been tested on the TI CC2650 SensorTag and the TI CC2650 LaunchPad hardware. ## Modules @@ -78,4 +78,3 @@ specifies the used advertisement interval in milliseconds. [rfc7668]: https://tools.ietf.org/html/rfc7668 [bleSpec]: https://www.bluetooth.com/specifications/bluetooth-core-specification/legacy-specifications [bleachWeb]: http://www.iti.tugraz.at/BLEach - diff --git a/examples/platform-specific/cc26xx/cc26xx-web-demo/Makefile b/examples/platform-specific/cc26xx/cc26xx-web-demo/Makefile index 3ddf9671b..05dbface1 100644 --- a/examples/platform-specific/cc26xx/cc26xx-web-demo/Makefile +++ b/examples/platform-specific/cc26xx/cc26xx-web-demo/Makefile @@ -5,9 +5,14 @@ PLATFORMS_ONLY = srf06-cc26xx MODULES_REL += ./resources -PROJECT_SOURCEFILES += cetic-6lbr-client.c coap-server.c net-uart.c mqtt-client.c +PROJECT_SOURCEFILES += coap-server.c net-uart.c mqtt-client.c PROJECT_SOURCEFILES += httpd-simple.c +ifeq ($(MAKE_ROUTING),MAKE_ROUTING_RPL_CLASSIC) +# 6lbr only supports RPL Classic +PROJECT_SOURCEFILES += cetic-6lbr-client.c +endif + # REST Engine shall use Erbium CoAP implementation MODULES += os/net/app-layer/mqtt MODULES += os/net/app-layer/coap diff --git a/examples/platform-specific/cc26xx/cc26xx-web-demo/README.md b/examples/platform-specific/cc26xx/cc26xx-web-demo/README.md index 67b28ba93..9a4617b3c 100644 --- a/examples/platform-specific/cc26xx/cc26xx-web-demo/README.md +++ b/examples/platform-specific/cc26xx/cc26xx-web-demo/README.md @@ -54,33 +54,38 @@ tab, as per the image below. CoAP Server ----------- -For this functionality to work, you will need to install the -[Copper (Cu)](https://addons.mozilla.org/en-US/firefox/addon/copper-270430/) -addon to your browser. +For this functionality to work, you will need to install a CoAP client. +You can achieve this by following the guides on how to set up your system +[in the wiki](https://github.com/contiki-ng/contiki-ng/wiki#setting-up-contiki-ng). -From the sensors tab in the 6lbr web page, click the 'coap' link in the line -corresponding to your CC26xx device. Once the addon fires up, select -".well-known/core" in the left pane and then hit the 'Get' button at the top. +You should start by sending a CoAP GET request for the `.well-known/core` +resource. If you are using libcoap's CoAP client, this can be achieved by: -![CoAP Resources](img/coap-resources.png) +``` +coap-client -m get coap://[]/.well-known/core +``` + +Adjust the above command to match the command line arguments of your CoAP +client. The Device will respond with a list of all available CoAP resources. This list -will be different between the Srf and the SensorTag. The screenshot below shows -a (partial) list of resources exported by the SensorTag CoAP server. Select -a resource on the left pane and hit 'Get' to retrieve its value. Select -`lt/g` and hit 'Post' to toggle the green LED, `lt/r` for the red one. +will be different between the various CC13x0/CC26x0 boards. -You can also use CoAP to enable/disable BLE advertisements! Select -`dev/ble_advd` and then hit the "Outgoing" button in the payload panel. Type in -the desired payload, which can be: +Send a CoAP GET request for any of those resrouces to retrieve its value. + +Send a CoAP POST to the `lt/g` or `lt/r` to toggle the green/red LED +respectively. + +You can also use CoAP to enable/disable BLE advertisements! This can be done +by sending a PUT or POST request to the `dev/ble_advd` resource. Your request +should contain the desired payload, which can be: * `mode=on|off` * `name=` * `interval=` -or a combination of both delimited with an amp. For example, you can set as -payload `mode=on&name=My CC26xx Device 4&interval=5`. Once you have set the -payload, hit either the POST or PUT button. +or a combination of the above delimited with an amp. For example, you can set +as payload `mode=on&name=My CC26xx Device 4&interval=5`. Bear in mind that you must set `name` at least once before enabling BLE advertisements. If you fail to do so, the RF will refuse to enter BLE mode and @@ -166,3 +171,9 @@ the state of the LED. Bear in mind that, even though the topic suggests that messages are of json format, they are in fact not. This was done in order to avoid linking a json parser into the firmware. + +IBM Watson IoT Platform +---------------------------- +To use IBM Watson IoT Platform, you have to go to SECURITY tab of Device page to select "TLS Optional". This step is critical. If you don't do this, you need to use TLS for connection and default cc26xx-web-demo won't work. + +![IBM Watson IoT Platform TLS Optional Configuration](img/ibm-watson-iot-platform-tls-optional.png) diff --git a/examples/platform-specific/cc26xx/cc26xx-web-demo/cetic-6lbr-client.c b/examples/platform-specific/cc26xx/cc26xx-web-demo/cetic-6lbr-client.c index d3042bf81..569a36a89 100644 --- a/examples/platform-specific/cc26xx/cc26xx-web-demo/cetic-6lbr-client.c +++ b/examples/platform-specific/cc26xx/cc26xx-web-demo/cetic-6lbr-client.c @@ -37,10 +37,11 @@ #include "contiki-net.h" #include "net/routing/routing.h" #include "net/ipv6/uip.h" -#if ROUTING_CONF_RPL_LITE -#include "net/routing/rpl-lite/rpl.h" -#elif ROUTING_CONF_RPL_CLASSIC +#if ROUTING_CONF_RPL_CLASSIC #include "net/routing/rpl-classic/rpl.h" +#include "net/routing/rpl-classic/rpl-private.h" +#else +#error The 6LBR client is only meant for RPL Classic. Set MAKE_ROUTING accordingly. #endif #include @@ -160,8 +161,8 @@ timeout_handler(void) PRINT6ADDR(&client_conn->ripaddr); i = sprintf(buf, "%d | ", ++seq_id); instance = rpl_get_default_instance(); - if(instance && instance->dag.preferred_parent) { - add_ipaddr(buf + i, rpl_parent_get_ipaddr(instance->dag.preferred_parent)); + if(instance && instance->current_dag->preferred_parent) { + add_ipaddr(buf + i, rpl_parent_get_ipaddr(instance->current_dag->preferred_parent)); } else { sprintf(buf + i, "(null)"); } diff --git a/examples/platform-specific/cc26xx/cc26xx-web-demo/coap-server.c b/examples/platform-specific/cc26xx/cc26xx-web-demo/coap-server.c index 54289f102..37b9a295d 100644 --- a/examples/platform-specific/cc26xx/cc26xx-web-demo/coap-server.c +++ b/examples/platform-specific/cc26xx/cc26xx-web-demo/coap-server.c @@ -133,9 +133,6 @@ PROCESS_THREAD(coap_server_process, ev, data) printf("CC26XX CoAP Server\n"); - /* Initialize the REST engine. */ - coap_engine_init(); - coap_activate_resource(&res_batmon_temp, "sen/batmon/temp"); coap_activate_resource(&res_batmon_volt, "sen/batmon/voltage"); diff --git a/examples/platform-specific/cc26xx/cc26xx-web-demo/img/coap-resources.png b/examples/platform-specific/cc26xx/cc26xx-web-demo/img/coap-resources.png deleted file mode 100644 index c71c934fe..000000000 Binary files a/examples/platform-specific/cc26xx/cc26xx-web-demo/img/coap-resources.png and /dev/null differ diff --git a/examples/platform-specific/cc26xx/cc26xx-web-demo/img/ibm-watson-iot-platform-tls-optional.png b/examples/platform-specific/cc26xx/cc26xx-web-demo/img/ibm-watson-iot-platform-tls-optional.png new file mode 100644 index 000000000..93c98624f Binary files /dev/null and b/examples/platform-specific/cc26xx/cc26xx-web-demo/img/ibm-watson-iot-platform-tls-optional.png differ diff --git a/examples/platform-specific/cc26xx/cc26xx-web-demo/project-conf.h b/examples/platform-specific/cc26xx/cc26xx-web-demo/project-conf.h index f007eb403..ccd0bf8fb 100644 --- a/examples/platform-specific/cc26xx/cc26xx-web-demo/project-conf.h +++ b/examples/platform-specific/cc26xx/cc26xx-web-demo/project-conf.h @@ -33,7 +33,7 @@ /*---------------------------------------------------------------------------*/ /* Change to match your configuration */ #define IEEE802154_CONF_PANID 0xABCD -#define RF_CORE_CONF_CHANNEL 25 +#define IEEE802154_CONF_DEFAULT_CHANNEL 26 #define RF_BLE_CONF_ENABLED 1 /*---------------------------------------------------------------------------*/ @@ -42,7 +42,7 @@ /* Enable/Disable Components of this Demo */ #define CC26XX_WEB_DEMO_CONF_MQTT_CLIENT 1 -#define CC26XX_WEB_DEMO_CONF_6LBR_CLIENT 1 +#define CC26XX_WEB_DEMO_CONF_6LBR_CLIENT ROUTING_CONF_RPL_CLASSIC #define CC26XX_WEB_DEMO_CONF_COAP_SERVER 1 #define CC26XX_WEB_DEMO_CONF_NET_UART 1 diff --git a/examples/platform-specific/cc26xx/project-conf.h b/examples/platform-specific/cc26xx/project-conf.h index 8231dd4ea..17bd2ce29 100644 --- a/examples/platform-specific/cc26xx/project-conf.h +++ b/examples/platform-specific/cc26xx/project-conf.h @@ -36,7 +36,7 @@ /*---------------------------------------------------------------------------*/ /* Change to match your configuration */ #define IEEE802154_CONF_PANID 0xABCD -#define RF_CORE_CONF_CHANNEL 25 +#define IEEE802154_CONF_DEFAULT_CHANNEL 25 #define RF_BLE_CONF_ENABLED 1 /*---------------------------------------------------------------------------*/ #endif /* PROJECT_CONF_H_ */ diff --git a/examples/platform-specific/cc26xx/very-sleepy-demo/project-conf.h b/examples/platform-specific/cc26xx/very-sleepy-demo/project-conf.h index b60df036d..f22fb2685 100644 --- a/examples/platform-specific/cc26xx/very-sleepy-demo/project-conf.h +++ b/examples/platform-specific/cc26xx/very-sleepy-demo/project-conf.h @@ -33,7 +33,7 @@ /*---------------------------------------------------------------------------*/ /* Change to match your configuration */ #define IEEE802154_CONF_PANID 0xABCD -#define RF_CORE_CONF_CHANNEL 25 +#define IEEE802154_CONF_DEFAULT_CHANNEL 25 /*---------------------------------------------------------------------------*/ /* Enable the ROM bootloader */ diff --git a/examples/platform-specific/cc26xx/very-sleepy-demo/very-sleepy-demo.c b/examples/platform-specific/cc26xx/very-sleepy-demo/very-sleepy-demo.c index cac8033b7..ebd55712b 100644 --- a/examples/platform-specific/cc26xx/very-sleepy-demo/very-sleepy-demo.c +++ b/examples/platform-specific/cc26xx/very-sleepy-demo/very-sleepy-demo.c @@ -344,8 +344,6 @@ PROCESS_THREAD(very_sleepy_demo_process, ev, data) event_new_config = process_alloc_event(); - coap_engine_init(); - readings_resource.flags += IS_OBSERVABLE; coap_activate_resource(&readings_resource, "sen/readings"); coap_activate_resource(&very_sleepy_conf, "very_sleepy_config"); diff --git a/examples/platform-specific/jn516x/rpl/coap-dongle-node/dongle-node.c b/examples/platform-specific/jn516x/rpl/coap-dongle-node/dongle-node.c index 2fb2d7761..9c7cbb7aa 100644 --- a/examples/platform-specific/jn516x/rpl/coap-dongle-node/dongle-node.c +++ b/examples/platform-specific/jn516x/rpl/coap-dongle-node/dongle-node.c @@ -135,7 +135,6 @@ PROCESS_THREAD(start_app, ev, data) NETSTACK_MAC.on(); printf("Starting RPL node\n"); - coap_engine_init(); coap_activate_resource(&resource_led_toggle, "Dongle/LED-toggle"); PROCESS_END(); diff --git a/examples/platform-specific/jn516x/rpl/coap-dongle-node/project-conf.h b/examples/platform-specific/jn516x/rpl/coap-dongle-node/project-conf.h index a46f32f1c..bb7d4d785 100644 --- a/examples/platform-specific/jn516x/rpl/coap-dongle-node/project-conf.h +++ b/examples/platform-specific/jn516x/rpl/coap-dongle-node/project-conf.h @@ -31,11 +31,11 @@ * \author Simon Duquennoy */ -#ifndef __PROJECT_CONF_H__ -#define __PROJECT_CONF_H__ +#ifndef PROJECT_CONF_H_ +#define PROJECT_CONF_H_ #define UIP_CONF_TCP 0 #include "../common-conf.h" -#endif /* __PROJECT_CONF_H__ */ +#endif /* PROJECT_CONF_H_ */ diff --git a/examples/platform-specific/jn516x/rpl/coap-dr1175-node/dr1175-node.c b/examples/platform-specific/jn516x/rpl/coap-dr1175-node/dr1175-node.c index 443cf4fbe..4a8432099 100644 --- a/examples/platform-specific/jn516x/rpl/coap-dr1175-node/dr1175-node.c +++ b/examples/platform-specific/jn516x/rpl/coap-dr1175-node/dr1175-node.c @@ -355,7 +355,6 @@ PROCESS_THREAD(start_app, ev, data) NETSTACK_MAC.on(); printf("Starting RPL node\n"); - coap_engine_init(); coap_activate_resource(&resource_light_sensor_value, "DR1175/LightSensor/Value"); coap_activate_resource(&resource_light_sensor_unit, "DR1175/LightSensor/Unit"); coap_activate_resource(&resource_temperature_unit, "DR1175/Temperature/Unit"); diff --git a/examples/platform-specific/jn516x/rpl/coap-dr1175-node/project-conf.h b/examples/platform-specific/jn516x/rpl/coap-dr1175-node/project-conf.h index a46f32f1c..bb7d4d785 100644 --- a/examples/platform-specific/jn516x/rpl/coap-dr1175-node/project-conf.h +++ b/examples/platform-specific/jn516x/rpl/coap-dr1175-node/project-conf.h @@ -31,11 +31,11 @@ * \author Simon Duquennoy */ -#ifndef __PROJECT_CONF_H__ -#define __PROJECT_CONF_H__ +#ifndef PROJECT_CONF_H_ +#define PROJECT_CONF_H_ #define UIP_CONF_TCP 0 #include "../common-conf.h" -#endif /* __PROJECT_CONF_H__ */ +#endif /* PROJECT_CONF_H_ */ diff --git a/examples/platform-specific/jn516x/rpl/coap-dr1199-node/dr1199-node.c b/examples/platform-specific/jn516x/rpl/coap-dr1199-node/dr1199-node.c index d341170ad..d493636b5 100644 --- a/examples/platform-specific/jn516x/rpl/coap-dr1199-node/dr1199-node.c +++ b/examples/platform-specific/jn516x/rpl/coap-dr1199-node/dr1199-node.c @@ -356,7 +356,6 @@ PROCESS_THREAD(start_app, ev, data) NETSTACK_MAC.on(); printf("Starting RPL node\n"); - coap_engine_init(); coap_activate_resource(&resource_switch_sw1, "DR1199/Switch/SW1"); coap_activate_resource(&resource_switch_sw2, "DR1199/Switch/SW2"); coap_activate_resource(&resource_switch_sw3, "DR1199/Switch/SW3"); diff --git a/examples/platform-specific/jn516x/rpl/coap-dr1199-node/project-conf.h b/examples/platform-specific/jn516x/rpl/coap-dr1199-node/project-conf.h index a46f32f1c..bb7d4d785 100644 --- a/examples/platform-specific/jn516x/rpl/coap-dr1199-node/project-conf.h +++ b/examples/platform-specific/jn516x/rpl/coap-dr1199-node/project-conf.h @@ -31,11 +31,11 @@ * \author Simon Duquennoy */ -#ifndef __PROJECT_CONF_H__ -#define __PROJECT_CONF_H__ +#ifndef PROJECT_CONF_H_ +#define PROJECT_CONF_H_ #define UIP_CONF_TCP 0 #include "../common-conf.h" -#endif /* __PROJECT_CONF_H__ */ +#endif /* PROJECT_CONF_H_ */ diff --git a/examples/platform-specific/jn516x/rpl/common-conf.h b/examples/platform-specific/jn516x/rpl/common-conf.h index daa66ae29..8ffb3b4f5 100644 --- a/examples/platform-specific/jn516x/rpl/common-conf.h +++ b/examples/platform-specific/jn516x/rpl/common-conf.h @@ -72,8 +72,6 @@ #define IEEE802154_CONF_PANID 0xabcd -#define MICROMAC_CONF_CHANNEL 26 - /* UART Configuration */ #define UART_HW_FLOW_CTRL 0 diff --git a/examples/platform-specific/jn516x/rpl/node/project-conf.h b/examples/platform-specific/jn516x/rpl/node/project-conf.h index 9db6f0229..52adee3b9 100644 --- a/examples/platform-specific/jn516x/rpl/node/project-conf.h +++ b/examples/platform-specific/jn516x/rpl/node/project-conf.h @@ -32,9 +32,9 @@ * \author Simon Duquennoy */ -#ifndef __PROJECT_CONF_H__ -#define __PROJECT_CONF_H__ +#ifndef PROJECT_CONF_H_ +#define PROJECT_CONF_H_ #include "../common-conf.h" -#endif /* __PROJECT_CONF_H__ */ +#endif /* PROJECT_CONF_H_ */ diff --git a/examples/platform-specific/jn516x/tsch/common-conf.h b/examples/platform-specific/jn516x/tsch/common-conf.h index 39d012d52..5911f34ee 100644 --- a/examples/platform-specific/jn516x/tsch/common-conf.h +++ b/examples/platform-specific/jn516x/tsch/common-conf.h @@ -104,8 +104,6 @@ #if MAC_CONF_WITH_CSMA /* Configure Csma with ACK (default MAC) */ -#define MICROMAC_CONF_CHANNEL 26 - #define MICROMAC_CONF_AUTOACK 1 /* increase internal radio buffering */ diff --git a/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/project-conf.h b/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/project-conf.h index 360fdef25..65ddcef46 100644 --- a/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/project-conf.h +++ b/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/project-conf.h @@ -32,12 +32,12 @@ * */ -#ifndef __PROJECT_CONF_H__ -#define __PROJECT_CONF_H__ +#ifndef PROJECT_CONF_H_ +#define PROJECT_CONF_H_ #define UIP_CONF_TCP 0 #define UART_BAUD_RATE UART_RATE_115200 #include "../../common-conf.h" -#endif /* __PROJECT_CONF_H__ */ +#endif /* PROJECT_CONF_H_ */ diff --git a/examples/platform-specific/jn516x/tsch/tx-power-verification/node/node.c b/examples/platform-specific/jn516x/tsch/tx-power-verification/node/node.c index 995dc3304..2230f4831 100644 --- a/examples/platform-specific/jn516x/tsch/tx-power-verification/node/node.c +++ b/examples/platform-specific/jn516x/tsch/tx-power-verification/node/node.c @@ -110,7 +110,6 @@ PROCESS_THREAD(start_app, ev, data) NETSTACK_MAC.on(); printf("Starting RPL node\n"); - coap_engine_init(); coap_activate_resource(&resource_set_tx_power, "Set-TX-Power"); coap_activate_resource(&resource_get_tx_power, "Get-TX-Power"); diff --git a/examples/platform-specific/jn516x/tsch/tx-power-verification/node/project-conf.h b/examples/platform-specific/jn516x/tsch/tx-power-verification/node/project-conf.h index 0394b0ad5..94e17dc1c 100644 --- a/examples/platform-specific/jn516x/tsch/tx-power-verification/node/project-conf.h +++ b/examples/platform-specific/jn516x/tsch/tx-power-verification/node/project-conf.h @@ -31,12 +31,12 @@ * \author Simon Duquennoy */ -#ifndef __PROJECT_CONF_H__ -#define __PROJECT_CONF_H__ +#ifndef PROJECT_CONF_H_ +#define PROJECT_CONF_H_ #define UIP_CONF_TCP 0 #define UART_BAUD_RATE UART_RATE_115200 #include "../../common-conf.h" -#endif /* __PROJECT_CONF_H__ */ +#endif /* PROJECT_CONF_H_ */ diff --git a/examples/platform-specific/jn516x/tsch/uart1-test-node/project-conf.h b/examples/platform-specific/jn516x/tsch/uart1-test-node/project-conf.h index 373ea0f27..d833869bb 100644 --- a/examples/platform-specific/jn516x/tsch/uart1-test-node/project-conf.h +++ b/examples/platform-specific/jn516x/tsch/uart1-test-node/project-conf.h @@ -31,8 +31,8 @@ * \author Simon Duquennoy */ -#ifndef __PROJECT_CONF_H__ -#define __PROJECT_CONF_H__ +#ifndef PROJECT_CONF_H_ +#define PROJECT_CONF_H_ #define UIP_CONF_TCP 0 @@ -46,4 +46,4 @@ #include "../common-conf.h" -#endif /* __PROJECT_CONF_H__ */ +#endif /* PROJECT_CONF_H_ */ diff --git a/examples/platform-specific/jn516x/tsch/uart1-test-node/uart1-test-node.c b/examples/platform-specific/jn516x/tsch/uart1-test-node/uart1-test-node.c index dd647fa21..8759e8307 100644 --- a/examples/platform-specific/jn516x/tsch/uart1-test-node/uart1-test-node.c +++ b/examples/platform-specific/jn516x/tsch/uart1-test-node/uart1-test-node.c @@ -151,7 +151,6 @@ PROCESS_THREAD(start_app, ev, data) NETSTACK_MAC.on(); printf("Starting RPL node\n"); - coap_engine_init(); coap_activate_resource(&resource_coap_rx_uart1, "UART1-RX"); coap_activate_resource(&resource_coap_tx_uart1, "UART1-TX"); diff --git a/examples/platform-specific/nrf52dk/coap-demo/coap-client/coap-client.c b/examples/platform-specific/nrf52dk/coap-demo/coap-client/coap-client.c index 4effcc876..916c06603 100644 --- a/examples/platform-specific/nrf52dk/coap-demo/coap-client/coap-client.c +++ b/examples/platform-specific/nrf52dk/coap-demo/coap-client/coap-client.c @@ -148,9 +148,6 @@ PROCESS_THREAD(er_example_observe_client, ev, data) static coap_endpoint_t server_endpoint; coap_endpoint_parse(SERVER_IPV6_EP, strlen(SERVER_IPV6_EP), &server_endpoint); - /* receives all CoAP messages */ - coap_engine_init(); - #if PLATFORM_HAS_BUTTON SENSORS_ACTIVATE(button_1); SENSORS_ACTIVATE(button_2); diff --git a/examples/platform-specific/nrf52dk/coap-demo/coap-server/coap-server.c b/examples/platform-specific/nrf52dk/coap-demo/coap-server/coap-server.c index 6b4025cd3..584f54318 100644 --- a/examples/platform-specific/nrf52dk/coap-demo/coap-server/coap-server.c +++ b/examples/platform-specific/nrf52dk/coap-demo/coap-server/coap-server.c @@ -103,8 +103,6 @@ PROCESS_THREAD(er_example_server, ev, data) print_local_addresses(); - /* Initialize the REST engine. */ - coap_engine_init(); coap_activate_resource(&res_led3, "lights/led3"); SENSORS_ACTIVATE(button_1); diff --git a/examples/platform-specific/zoul/Makefile b/examples/platform-specific/zoul/Makefile index 88dcb3ce2..3b57eb035 100644 --- a/examples/platform-specific/zoul/Makefile +++ b/examples/platform-specific/zoul/Makefile @@ -1,9 +1,9 @@ -CONTIKI_PROJECT = test-tsl256x test-sht25 test-servo.c +CONTIKI_PROJECT = test-tsl256x test-sht25 test-servo CONTIKI_PROJECT += test-bmp085-bmp180 test-motion test-rotation-sensor CONTIKI_PROJECT += test-grove-light-sensor test-grove-loudness-sensor CONTIKI_PROJECT += test-weather-meter test-grove-gyro test-lcd test-iaq CONTIKI_PROJECT += test-pm10-sensor test-vac-sensor test-aac-sensor -CONTIKI_PROJECT += test-zonik test-dht22.c test-ac-dimmer.c +CONTIKI_PROJECT += test-zonik test-dht22 test-ac-dimmer CONTIKI_PROJECT += test-bme280 CONTIKI_TARGET_SOURCEFILES += tsl256x.c sht25.c bmpx8x.c motion-sensor.c diff --git a/examples/rpl-udp/Makefile b/examples/rpl-udp/Makefile index 26190e839..78e6d1653 100644 --- a/examples/rpl-udp/Makefile +++ b/examples/rpl-udp/Makefile @@ -1,20 +1,5 @@ CONTIKI_PROJECT = udp-client udp-server all: $(CONTIKI_PROJECT) -.PHONY: renode -renode: all -ifneq ($(TARGET),cc2538dk) - $(error Only the cc2538dk TARGET is supported for Renode demo scripts) -endif -ifndef SCRIPT - $(warning SCRIPT not defined! Using "rpl-udp.resc" as default) - renode rpl-udp.resc -else -ifeq ($(wildcard $(SCRIPT)),) - $(error SCRIPT "$(SCRIPT)" does not exist!) -endif - renode $(SCRIPT) -endif - CONTIKI=../.. include $(CONTIKI)/Makefile.include diff --git a/examples/rpl-udp/rpl-udp-sky.csc b/examples/rpl-udp/rpl-udp-sky.csc index 7975acf05..4b9ce6099 100644 --- a/examples/rpl-udp/rpl-udp-sky.csc +++ b/examples/rpl-udp/rpl-udp-sky.csc @@ -24,7 +24,7 @@ sky1 Sky Mote Type #sky1 [CONTIKI_DIR]/examples/rpl-udp/udp-server.c - make clean udp-server.sky TARGET=sky + make udp-server.sky TARGET=sky [CONTIKI_DIR]/examples/rpl-udp/udp-server.sky org.contikios.cooja.interfaces.Position org.contikios.cooja.interfaces.RimeAddress @@ -47,7 +47,7 @@ sky2 Sky Mote Type #sky2 [CONTIKI_DIR]/examples/rpl-udp/udp-client.c - make clean udp-client.sky TARGET=sky + make udp-client.sky TARGET=sky [CONTIKI_DIR]/examples/rpl-udp/udp-client.sky org.contikios.cooja.interfaces.Position org.contikios.cooja.interfaces.RimeAddress diff --git a/examples/slip-radio/slip-radio.c b/examples/slip-radio/slip-radio.c index 21779a3dc..d4e9db1cf 100644 --- a/examples/slip-radio/slip-radio.c +++ b/examples/slip-radio/slip-radio.c @@ -187,13 +187,13 @@ slip_radio_cmd_handler(const uint8_t *data, int len) } return 1; } - } else if(uip_buf[0] == '?') { - LOG_DBG("Got request message of type %c\n", uip_buf[1]); + } else if(data[0] == '?') { + LOG_DBG("Got request message of type %c\n", data[1]); if(data[1] == 'M') { /* this is just a test so far... just to see if it works */ uip_buf[0] = '!'; uip_buf[1] = 'M'; - for(i = 0; i < 8; i++) { + for(i = 0; i < UIP_LLADDR_LEN; i++) { uip_buf[2 + i] = uip_lladdr.addr[i]; } uip_len = 10; @@ -226,8 +226,9 @@ slip_radio_cmd_handler(const uint8_t *data, int len) static void slip_input_callback(void) { - LOG_DBG("SR-SIN: %u '%c%c'\n", uip_len, uip_buf[0], uip_buf[1]); - if(!cmd_input(uip_buf, uip_len)) { + LOG_DBG("SR-SIN: %u '%c%c'\n", uip_len, + uip_buf[UIP_LLH_LEN], uip_buf[UIP_LLH_LEN + 1]); + if(!cmd_input(&uip_buf[UIP_LLH_LEN], uip_len)) { cmd_send((uint8_t *)"EUnknown command", 16); } uip_clear_buf(); diff --git a/examples/storage/antelope-shell/Makefile b/examples/storage/antelope-shell/Makefile index 3b3f7fd23..5eff3dcd3 100644 --- a/examples/storage/antelope-shell/Makefile +++ b/examples/storage/antelope-shell/Makefile @@ -3,7 +3,7 @@ CONTIKI = ../../.. MODULES += os/storage/antelope os/services/unit-test # does not fit on Sky -PLATFORMS_ONLY= cc2538 +PLATFORMS_ONLY= cc2538dk zoul CONTIKI_PROJECT = shell-db all: $(CONTIKI_PROJECT) diff --git a/examples/storage/cfs-coffee/Makefile b/examples/storage/cfs-coffee/Makefile index 10d6256fa..b6d22f5ac 100644 --- a/examples/storage/cfs-coffee/Makefile +++ b/examples/storage/cfs-coffee/Makefile @@ -1,6 +1,6 @@ CONTIKI = ../../.. -PLATFORMS_ONLY= cc2538 sky +PLATFORMS_ONLY= cc2538dk zoul sky MODULES += os/services/unit-test MODULES += os/storage/cfs diff --git a/examples/http-socket/Makefile b/examples/websocket/Makefile similarity index 100% rename from examples/http-socket/Makefile rename to examples/websocket/Makefile diff --git a/examples/http-socket/http-example.c b/examples/websocket/http-example.c similarity index 100% rename from examples/http-socket/http-example.c rename to examples/websocket/http-example.c diff --git a/examples/http-socket/project-conf.h b/examples/websocket/project-conf.h similarity index 100% rename from examples/http-socket/project-conf.h rename to examples/websocket/project-conf.h diff --git a/examples/http-socket/websocket-example.c b/examples/websocket/websocket-example.c similarity index 100% rename from examples/http-socket/websocket-example.c rename to examples/websocket/websocket-example.c diff --git a/examples/http-socket/websocket-node/Makefile b/examples/websocket/websocket-node/Makefile similarity index 100% rename from examples/http-socket/websocket-node/Makefile rename to examples/websocket/websocket-node/Makefile diff --git a/examples/http-socket/websocket-node/example-server.js b/examples/websocket/websocket-node/example-server.js similarity index 100% rename from examples/http-socket/websocket-node/example-server.js rename to examples/websocket/websocket-node/example-server.js diff --git a/os/contiki-default-conf.h b/os/contiki-default-conf.h index 8ec1a41f7..f8fbc9933 100644 --- a/os/contiki-default-conf.h +++ b/os/contiki-default-conf.h @@ -41,6 +41,16 @@ #define IEEE802154_CONF_PANID 0xabcd #endif /* IEEE802154_CONF_PANID */ +/* IEEE802154_CONF_DEFAULT_CHANNEL defines the default channel for IEEE 802.15.4 + * networks, for MAC layers without a channel selection or channel hopping + * mechanism. Current 802.15.4 MAC layers: + * - CSMA: uses IEEE802154_CONF_DEFAULT_CHANNEL + * - TSCH: uses its own TSCH_DEFAULT_HOPPING_SEQUENCE instead + */ +#ifndef IEEE802154_CONF_DEFAULT_CHANNEL +#define IEEE802154_CONF_DEFAULT_CHANNEL 26 +#endif /* IEEE802154_CONF_DEF_CHANNEL */ + /* QUEUEBUF_CONF_NUM specifies the number of queue buffers. Queue buffers are used throughout the Contiki netstack but the configuration option can be tweaked to save memory. Performance can diff --git a/os/contiki-main.c b/os/contiki-main.c index 234b759ee..b9aea5cd6 100644 --- a/os/contiki-main.c +++ b/os/contiki-main.c @@ -47,6 +47,7 @@ #include "sys/stack-check.h" #include "dev/watchdog.h" +#include "net/app-layer/coap/coap-engine.h" #include "services/rpl-border-router/rpl-border-router.h" #include "services/orchestra/orchestra.h" #include "services/shell/serial-shell.h" @@ -86,9 +87,15 @@ main(void) platform_init_stage_two(); LOG_INFO("Starting " CONTIKI_VERSION_STRING "\n"); - - LOG_INFO(" Net: %s\n", NETSTACK_NETWORK.name); - LOG_INFO(" MAC: %s\n", NETSTACK_MAC.name); + LOG_INFO("- Routing: %s\n", NETSTACK_ROUTING.name); + LOG_INFO("- Net: %s\n", NETSTACK_NETWORK.name); + LOG_INFO("- MAC: %s\n", NETSTACK_MAC.name); + LOG_INFO("- 802.15.4 PANID: 0x%04x\n", IEEE802154_PANID); +#if MAC_CONF_WITH_TSCH + LOG_INFO("- 802.15.4 TSCH default hopping sequence length: %u\n", (unsigned)sizeof(TSCH_DEFAULT_HOPPING_SEQUENCE)); +#else /* MAC_CONF_WITH_TSCH */ + LOG_INFO("- 802.15.4 Default channel: %u\n", IEEE802154_DEFAULT_CHANNEL); +#endif /* MAC_CONF_WITH_TSCH */ netstack_init(); @@ -126,6 +133,11 @@ main(void) LOG_DBG("With Shell\n"); #endif /* BUILD_WITH_SHELL */ +#if BUILD_WITH_COAP + coap_engine_init(); + LOG_DBG("With CoAP\n"); +#endif /* BUILD_WITH_SHELL */ + autostart_start(autostart_processes); watchdog_start(); diff --git a/os/lib/aes-128.c b/os/lib/aes-128.c index 98e115c3f..3b0082e7c 100644 --- a/os/lib/aes-128.c +++ b/os/lib/aes-128.c @@ -166,16 +166,6 @@ encrypt(uint8_t *state) } } /*---------------------------------------------------------------------------*/ -void -aes_128_set_padded_key(uint8_t *key, uint8_t key_len) -{ - uint8_t block[AES_128_BLOCK_SIZE]; - - memset(block, 0, AES_128_BLOCK_SIZE); - memcpy(block, key, key_len); - AES_128.set_key(block); -} -/*---------------------------------------------------------------------------*/ const struct aes_128_driver aes_128_driver = { set_key, encrypt diff --git a/os/lib/aes-128.h b/os/lib/aes-128.h index 458b93915..e003c2b25 100644 --- a/os/lib/aes-128.h +++ b/os/lib/aes-128.h @@ -67,11 +67,6 @@ struct aes_128_driver { void (* encrypt)(uint8_t *plaintext_and_result); }; -/** - * \brief Pads the key with zeroes before calling AES_128.set_key - */ -void aes_128_set_padded_key(uint8_t *key, uint8_t key_len); - extern const struct aes_128_driver AES_128; #endif /* AES_128_H_ */ diff --git a/os/lib/dbg-io/strformat.h b/os/lib/dbg-io/strformat.h index 62d99b303..478fb7af7 100644 --- a/os/lib/dbg-io/strformat.h +++ b/os/lib/dbg-io/strformat.h @@ -53,7 +53,7 @@ typedef struct strformat_context_s { /*---------------------------------------------------------------------------*/ int format_str(const strformat_context_t *ctxt, const char *format, ...) __attribute__ ((__format__ (__printf__, 2,3))); - + int format_str_v(const strformat_context_t *ctxt, const char *format, va_list ap); /*---------------------------------------------------------------------------*/ diff --git a/os/net/app-layer/coap/coap-block1.c b/os/net/app-layer/coap/coap-block1.c index e08a321d1..600c09b27 100644 --- a/os/net/app-layer/coap/coap-block1.c +++ b/os/net/app-layer/coap/coap-block1.c @@ -49,7 +49,7 @@ /* Log configuration */ #include "coap-log.h" -#define LOG_MODULE "coap-block1" +#define LOG_MODULE "coap" #define LOG_LEVEL LOG_LEVEL_COAP /*---------------------------------------------------------------------------*/ diff --git a/os/net/app-layer/coap/coap-blocking-api.c b/os/net/app-layer/coap/coap-blocking-api.c index 0d2c5dc58..1be7cbe7c 100644 --- a/os/net/app-layer/coap/coap-blocking-api.c +++ b/os/net/app-layer/coap/coap-blocking-api.c @@ -51,7 +51,7 @@ /* Log configuration */ #include "coap-log.h" -#define LOG_MODULE "coap-blocking-api" +#define LOG_MODULE "coap" #define LOG_LEVEL LOG_LEVEL_COAP /*---------------------------------------------------------------------------*/ diff --git a/os/net/app-layer/coap/coap-callback-api.c b/os/net/app-layer/coap/coap-callback-api.c index 652856233..b1b05597e 100644 --- a/os/net/app-layer/coap/coap-callback-api.c +++ b/os/net/app-layer/coap/coap-callback-api.c @@ -51,7 +51,7 @@ /* Log configuration */ #include "coap-log.h" -#define LOG_MODULE "coap-callback-api" +#define LOG_MODULE "coap" #define LOG_LEVEL LOG_LEVEL_COAP /* These should go into the state struct so that we can have multiple diff --git a/os/net/app-layer/coap/coap-engine.c b/os/net/app-layer/coap/coap-engine.c index fb85b5b15..474826c1c 100644 --- a/os/net/app-layer/coap/coap-engine.c +++ b/os/net/app-layer/coap/coap-engine.c @@ -199,10 +199,18 @@ coap_receive(const coap_endpoint_t *src, new_offset = block_offset; } - /* call CoAP framework and check if found and allowed */ - status = call_service(message, response, - transaction->message + COAP_MAX_HEADER_SIZE, - block_size, &new_offset); + if(new_offset < 0) { + LOG_DBG("Blockwise: block request offset overflow\n"); + coap_status_code = BAD_OPTION_4_02; + coap_error_message = "BlockOutOfScope"; + status = COAP_HANDLER_STATUS_CONTINUE; + } else { + /* call CoAP framework and check if found and allowed */ + status = call_service(message, response, + transaction->message + COAP_MAX_HEADER_SIZE, + block_size, &new_offset); + } + if(status != COAP_HANDLER_STATUS_CONTINUE) { if(coap_status_code == NO_ERROR) { @@ -363,7 +371,6 @@ coap_engine_init(void) { /* avoid initializing twice */ if(is_initialized) { - LOG_DBG("already running - double initialization?\n"); return; } is_initialized = 1; diff --git a/os/net/app-layer/coap/coap-observe-client.c b/os/net/app-layer/coap/coap-observe-client.c index af1e89f14..a27308494 100644 --- a/os/net/app-layer/coap/coap-observe-client.c +++ b/os/net/app-layer/coap/coap-observe-client.c @@ -55,7 +55,7 @@ /* Log configuration */ #include "coap-log.h" -#define LOG_MODULE "coap-observe-client" +#define LOG_MODULE "coap" #define LOG_LEVEL LOG_LEVEL_COAP MEMB(obs_subjects_memb, coap_observee_t, COAP_MAX_OBSERVEES); diff --git a/os/net/app-layer/coap/coap-observe.c b/os/net/app-layer/coap/coap-observe.c index 676c4d1b3..83f5edf4a 100644 --- a/os/net/app-layer/coap/coap-observe.c +++ b/os/net/app-layer/coap/coap-observe.c @@ -50,7 +50,7 @@ /* Log configuration */ #include "coap-log.h" -#define LOG_MODULE "coap-observe" +#define LOG_MODULE "coap" #define LOG_LEVEL LOG_LEVEL_COAP /*---------------------------------------------------------------------------*/ diff --git a/os/net/app-layer/coap/coap-res-well-known-core.c b/os/net/app-layer/coap/coap-res-well-known-core.c index 2893925c9..ebaae8fd4 100644 --- a/os/net/app-layer/coap/coap-res-well-known-core.c +++ b/os/net/app-layer/coap/coap-res-well-known-core.c @@ -47,7 +47,7 @@ /* Log configuration */ #include "coap-log.h" -#define LOG_MODULE "coap-res-well-known-core" +#define LOG_MODULE "coap" #define LOG_LEVEL LOG_LEVEL_COAP #define ADD_CHAR_IF_POSSIBLE(char) \ diff --git a/os/net/app-layer/coap/coap-separate.c b/os/net/app-layer/coap/coap-separate.c index 318a4e53d..7eb5e5675 100644 --- a/os/net/app-layer/coap/coap-separate.c +++ b/os/net/app-layer/coap/coap-separate.c @@ -49,7 +49,7 @@ /* Log configuration */ #include "coap-log.h" -#define LOG_MODULE "coap-separate" +#define LOG_MODULE "coap" #define LOG_LEVEL LOG_LEVEL_COAP /*---------------------------------------------------------------------------*/ diff --git a/os/net/app-layer/coap/coap-timer-default.c b/os/net/app-layer/coap/coap-timer-default.c index ad1b30d28..7da3dfb05 100644 --- a/os/net/app-layer/coap/coap-timer-default.c +++ b/os/net/app-layer/coap/coap-timer-default.c @@ -52,7 +52,7 @@ /* Log configuration */ #include "coap-log.h" -#define LOG_MODULE "coap-timer-default" +#define LOG_MODULE "coap-timer" #define LOG_LEVEL LOG_LEVEL_NONE PROCESS(coap_timer_process, "coap timer process"); diff --git a/os/net/app-layer/coap/coap-transactions.c b/os/net/app-layer/coap/coap-transactions.c index 652737b94..7e34d22e4 100644 --- a/os/net/app-layer/coap/coap-transactions.c +++ b/os/net/app-layer/coap/coap-transactions.c @@ -50,7 +50,7 @@ /* Log configuration */ #include "coap-log.h" -#define LOG_MODULE "coap-transactions" +#define LOG_MODULE "coap" #define LOG_LEVEL LOG_LEVEL_COAP /*---------------------------------------------------------------------------*/ diff --git a/os/net/app-layer/coap/coap.c b/os/net/app-layer/coap/coap.c index 42a2d5cef..c28e2d8b5 100644 --- a/os/net/app-layer/coap/coap.c +++ b/os/net/app-layer/coap/coap.c @@ -1115,13 +1115,10 @@ coap_set_header_size1(coap_message_t *coap_pkt, uint32_t size) int coap_get_payload(coap_message_t *coap_pkt, const uint8_t **payload) { - if(coap_pkt->payload) { + if(payload != NULL) { *payload = coap_pkt->payload; - return coap_pkt->payload_len; - } else { - *payload = NULL; - return 0; } + return coap_pkt->payload != NULL ? coap_pkt->payload_len : 0; } int coap_set_payload(coap_message_t *coap_pkt, const void *payload, size_t length) diff --git a/os/net/app-layer/coap/module-macros.h b/os/net/app-layer/coap/module-macros.h new file mode 100644 index 000000000..053040e50 --- /dev/null +++ b/os/net/app-layer/coap/module-macros.h @@ -0,0 +1 @@ +#define BUILD_WITH_COAP 1 diff --git a/os/net/app-layer/coap/tinydtls-support/dtls-support.c b/os/net/app-layer/coap/tinydtls-support/dtls-support.c index ad960b718..4675c76d0 100644 --- a/os/net/app-layer/coap/tinydtls-support/dtls-support.c +++ b/os/net/app-layer/coap/tinydtls-support/dtls-support.c @@ -42,7 +42,7 @@ #include /* Log configuration */ -#define LOG_MODULE "dtls-support" +#define LOG_MODULE "dtls" #define LOG_LEVEL LOG_LEVEL_DTLS #include "dtls-log.h" #include "coap-log.h" diff --git a/os/net/ipv6/sicslowpan.c b/os/net/ipv6/sicslowpan.c index 0fa7e26ce..200068b03 100644 --- a/os/net/ipv6/sicslowpan.c +++ b/os/net/ipv6/sicslowpan.c @@ -97,6 +97,7 @@ /* define the buffer as a byte array */ #define PACKETBUF_IPHC_BUF ((uint8_t *)(packetbuf_ptr + packetbuf_hdr_len)) +#define PACKETBUF_PAYLOAD_END ((uint8_t *)(packetbuf_ptr + mac_max_payload)) #define PACKETBUF_6LO_PTR (packetbuf_ptr + packetbuf_hdr_len) #define PACKETBUF_6LO_DISPATCH 0 /* 8 bit */ @@ -197,6 +198,11 @@ static int packetbuf_payload_len; */ static uint8_t uncomp_hdr_len; +/** + * mac_max_payload is the maimum payload space on the MAC frame. + */ +static int mac_max_payload; + /** * The current page (RFC 4944) */ @@ -661,8 +667,9 @@ uncompress_addr(uip_ipaddr_t *ipaddr, uint8_t const prefix[], * compress the IID. * \param link_destaddr L2 destination address, needed to compress IP * dest + * \return 1 if success, else 0 */ -static void +static int compress_hdr_iphc(linkaddr_t *link_destaddr) { uint8_t tmp, iphc0, iphc1, *next_hdr, *next_nhc; @@ -679,7 +686,23 @@ compress_hdr_iphc(linkaddr_t *link_destaddr) LOG_DBG_("\n"); } +/* Macro used only internally, during header compression. Checks if there + * is sufficient space in packetbuf before writing any further. */ +#define CHECK_BUFFER_SPACE(writelen) do { \ + if(hc06_ptr + (writelen) >= PACKETBUF_PAYLOAD_END) { \ + LOG_WARN("Not enough packetbuf space to compress header (%u bytes, %u left). Aborting.\n", \ + (unsigned)(writelen), (unsigned)(PACKETBUF_PAYLOAD_END - hc06_ptr)); \ + return 0; \ + } \ +} while(0); + hc06_ptr = PACKETBUF_IPHC_BUF + 2; + + /* Check if there is enough space for the compressed IPv6 header, in the + * worst case (least compressed case). Extension headers and transport + * layer will be checked when they are compressed. */ + CHECK_BUFFER_SPACE(38); + /* * As we copy some bit-length fields, in the IPHC encoding bytes, * we sometimes use |= @@ -908,11 +931,13 @@ compress_hdr_iphc(linkaddr_t *link_destaddr) NHC byte extra - before the next header here. This is due to next not being elided in that case. */ if(!IS_COMPRESSABLE_PROTO(*next_hdr)) { + CHECK_BUFFER_SPACE(1); hc06_ptr++; LOG_DBG("compression: keeping the next header in this ext hdr: %d\n", ext_hdr->next); } /* copy the ext-hdr into the hc06 buffer */ + CHECK_BUFFER_SPACE(len); memcpy(hc06_ptr, ext_hdr, len); /* modify the len to octets */ ext_hdr = (struct uip_ext_hdr *) hc06_ptr; @@ -941,7 +966,8 @@ compress_hdr_iphc(linkaddr_t *link_destaddr) ((UIP_HTONS(udp_buf->destport) & 0xfff0) == SICSLOWPAN_UDP_4_BIT_PORT_MIN)) { /* we can compress 12 bits of both source and dest */ *next_nhc = SICSLOWPAN_NHC_UDP_CS_P_11; - LOG_DBG("compression: remove 12 bits of both source & dest with prefix 0xFOB\n"); + LOG_DBG("IPHC: remove 12 b of both source & dest with prefix 0xFOB\n"); + CHECK_BUFFER_SPACE(1); *hc06_ptr = (uint8_t)((UIP_HTONS(udp_buf->srcport) - SICSLOWPAN_UDP_4_BIT_PORT_MIN) << 4) + @@ -951,7 +977,8 @@ compress_hdr_iphc(linkaddr_t *link_destaddr) } else if((UIP_HTONS(udp_buf->destport) & 0xff00) == SICSLOWPAN_UDP_8_BIT_PORT_MIN) { /* we can compress 8 bits of dest, leave source. */ *next_nhc = SICSLOWPAN_NHC_UDP_CS_P_01; - LOG_DBG("compression: leave source, remove 8 bits of dest with prefix 0xF0\n"); + LOG_DBG("IPHC: leave source, remove 8 bits of dest with prefix 0xF0\n"); + CHECK_BUFFER_SPACE(3); memcpy(hc06_ptr, &udp_buf->srcport, 2); *(hc06_ptr + 2) = (uint8_t)((UIP_HTONS(udp_buf->destport) - @@ -960,7 +987,8 @@ compress_hdr_iphc(linkaddr_t *link_destaddr) } else if((UIP_HTONS(udp_buf->srcport) & 0xff00) == SICSLOWPAN_UDP_8_BIT_PORT_MIN) { /* we can compress 8 bits of src, leave dest. Copy compressed port */ *next_nhc = SICSLOWPAN_NHC_UDP_CS_P_10; - LOG_DBG("compression: remove 8 bits of source with prefix 0xF0, leave dest. hch: %i\n", *next_nhc); + LOG_DBG("IPHC: remove 8 bits of source with prefix 0xF0, leave dest. hch: %i\n", *next_nhc); + CHECK_BUFFER_SPACE(3); *hc06_ptr = (uint8_t)((UIP_HTONS(udp_buf->srcport) - SICSLOWPAN_UDP_8_BIT_PORT_MIN)); @@ -969,11 +997,13 @@ compress_hdr_iphc(linkaddr_t *link_destaddr) } else { /* we cannot compress. Copy uncompressed ports, full checksum */ *next_nhc = SICSLOWPAN_NHC_UDP_CS_P_00; - LOG_DBG("compression: cannot compress UDP headers\n"); + LOG_DBG("IPHC: cannot compress UDP headers\n"); + CHECK_BUFFER_SPACE(4); memcpy(hc06_ptr, &udp_buf->srcport, 4); hc06_ptr += 4; } /* always inline the checksum */ + CHECK_BUFFER_SPACE(2); memcpy(hc06_ptr, &udp_buf->udpchksum, 2); hc06_ptr += 2; uncomp_hdr_len += UIP_UDPH_LEN; @@ -1004,6 +1034,8 @@ compress_hdr_iphc(linkaddr_t *link_destaddr) } packetbuf_hdr_len = hc06_ptr - packetbuf_ptr; + + return 1; } /*--------------------------------------------------------------------*/ @@ -1554,6 +1586,16 @@ output(const linkaddr_t *localdest) packetbuf_set_attr(PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS, uipbuf_get_attr(UIPBUF_ATTR_MAX_MAC_TRANSMISSIONS)); +/* Calculate NETSTACK_FRAMER's header length, that will be added in the NETSTACK_MAC */ + packetbuf_set_addr(PACKETBUF_ADDR_RECEIVER, &dest); + framer_hdrlen = NETSTACK_FRAMER.length(); + if(framer_hdrlen < 0) { + /* Framing failed, we assume the maximum header length */ + framer_hdrlen = MAC_MAX_HEADER; + } + + mac_max_payload = MAC_MAX_PAYLOAD - framer_hdrlen; + /* Try to compress the headers */ #if SICSLOWPAN_COMPRESSION == SICSLOWPAN_COMPRESSION_IPV6 compress_hdr_ipv6(&dest); @@ -1567,7 +1609,10 @@ output(const linkaddr_t *localdest) } #endif /* SICSLOWPAN_COMPRESSION == SICSLOWPAN_COMPRESSION_6LORH */ #if SICSLOWPAN_COMPRESSION >= SICSLOWPAN_COMPRESSION_IPHC - compress_hdr_iphc(&dest); + if(compress_hdr_iphc(&dest) == 0) { + /* Warning should already be issued by function above */ + return 0; + } #endif /* SICSLOWPAN_COMPRESSION >= SICSLOWPAN_COMPRESSION_IPHC */ /* Calculate NETSTACK_FRAMER's header length, that will be added in the NETSTACK_MAC. @@ -1610,21 +1655,31 @@ output(const linkaddr_t *localdest) int fragn_max_payload = (max_payload - SICSLOWPAN_FRAGN_HDR_LEN) & 0xfffffff8; /* max IPv6 payload in the last fragment. Needs not be multiple of 8 bytes */ int last_fragn_max_payload = max_payload - SICSLOWPAN_FRAGN_HDR_LEN; - /* IPv6 payload that goes to non-first and non-last fragments */ + /* sum of all IPv6 payload that goes to non-first and non-last fragments */ int middle_fragn_total_payload = MAX(total_payload - frag1_payload - last_fragn_max_payload, 0); /* Ceiling of: 2 + middle_fragn_total_payload / fragn_max_payload */ - int fragment_count = 2 + - 1 + (middle_fragn_total_payload - 1) / fragn_max_payload; + int fragment_count = 2; + if(middle_fragn_total_payload > 0) { + fragment_count += 1 + (middle_fragn_total_payload - 1) / fragn_max_payload; + } int freebuf = queuebuf_numfree() - 1; LOG_INFO("output: fragmentation needed, fragments: %d, free queuebufs: %d\n", - fragment_count, freebuf); + fragment_count, freebuf); if(freebuf < fragment_count) { LOG_WARN("output: dropping packet, not enough free bufs\n"); return 0; } + if(frag1_payload < 0) { + /* The current implementation requires that all headers fit in the first + * fragment. Here is a corner case where the header did fit packetbuf + * but do no longer fit after truncating for a length multiple of 8. */ + LOG_WARN("output: compressed header does not fit first fragment\n"); + return 0; + } + /* Reset last tx status -- MAC layers most often call packet_sent asynchrously */ last_tx_status = MAC_TX_OK; /* Update fragment tag */ @@ -1641,6 +1696,7 @@ output(const linkaddr_t *localdest) /* Set frag1 payload len. Was already caulcated earlier as frag1_payload */ packetbuf_payload_len = frag1_payload; + /* Copy payload from uIP and send fragment */ /* Send fragment */ LOG_INFO("output: fragment %d/%d (tag %d, payload %d)\n", @@ -1850,7 +1906,7 @@ input(void) uncomp_hdr_len += UIP_IPH_LEN; } else { LOG_ERR("uncompression: unknown dispatch: 0x%02x\n", - PACKETBUF_6LO_PTR[PACKETBUF_6LO_DISPATCH]); + PACKETBUF_6LO_PTR[PACKETBUF_6LO_DISPATCH] & SICSLOWPAN_DISPATCH_IPHC_MASK); return; } @@ -1872,8 +1928,8 @@ input(void) #if SICSLOWPAN_CONF_FRAG if(is_fragment) { - LOG_INFO("input: fragment (tag %d, payload %d, offset %d)\n", - frag_tag, packetbuf_payload_len, frag_offset << 3); + LOG_INFO("input: fragment (tag %d, payload %d, offset %d) -- %u %u\n", + frag_tag, packetbuf_payload_len, frag_offset << 3, packetbuf_datalen(), packetbuf_hdr_len); } #endif /*SICSLOWPAN_CONF_FRAG*/ diff --git a/os/net/ipv6/uip-ds6-nbr.c b/os/net/ipv6/uip-ds6-nbr.c index e49125548..f937986b5 100644 --- a/os/net/ipv6/uip-ds6-nbr.c +++ b/os/net/ipv6/uip-ds6-nbr.c @@ -127,6 +127,41 @@ uip_ds6_nbr_rm(uip_ds6_nbr_t *nbr) return 0; } +/*---------------------------------------------------------------------------*/ +int +uip_ds6_nbr_update_ll(uip_ds6_nbr_t **nbr_pp, const uip_lladdr_t *new_ll_addr) +{ + uip_ds6_nbr_t nbr_backup; + + if(nbr_pp == NULL || new_ll_addr == NULL) { + LOG_ERR("%s: invalid argument\n", __func__); + return -1; + } + + /* make sure new_ll_addr is not used in some other nbr */ + if(uip_ds6_nbr_ll_lookup(new_ll_addr) != NULL) { + LOG_ERR("%s: new_ll_addr, ", __func__); + LOG_ERR_LLADDR((const linkaddr_t *)new_ll_addr); + LOG_ERR_(", is already used in another nbr\n"); + return -1; + } + + memcpy(&nbr_backup, *nbr_pp, sizeof(uip_ds6_nbr_t)); + if(uip_ds6_nbr_rm(*nbr_pp) == 0) { + LOG_ERR("%s: input nbr cannot be removed\n", __func__); + return -1; + } + + if((*nbr_pp = uip_ds6_nbr_add(&nbr_backup.ipaddr, new_ll_addr, + nbr_backup.isrouter, nbr_backup.state, + NBR_TABLE_REASON_IPV6_ND, NULL)) == NULL) { + LOG_ERR("%s: cannot allocate a new nbr for new_ll_addr\n", __func__); + return -1; + } + memcpy(*nbr_pp, &nbr_backup, sizeof(uip_ds6_nbr_t)); + + return 0; +} /*---------------------------------------------------------------------------*/ const uip_ipaddr_t * uip_ds6_nbr_get_ipaddr(const uip_ds6_nbr_t *nbr) diff --git a/os/net/ipv6/uip-ds6-nbr.h b/os/net/ipv6/uip-ds6-nbr.h index 9aec47b4a..d645ac627 100644 --- a/os/net/ipv6/uip-ds6-nbr.h +++ b/os/net/ipv6/uip-ds6-nbr.h @@ -90,6 +90,7 @@ uip_ds6_nbr_t *uip_ds6_nbr_add(const uip_ipaddr_t *ipaddr, nbr_table_reason_t reason, void *data); int uip_ds6_nbr_rm(uip_ds6_nbr_t *nbr); const uip_lladdr_t *uip_ds6_nbr_get_ll(const uip_ds6_nbr_t *nbr); +int uip_ds6_nbr_update_ll(uip_ds6_nbr_t **nbr, const uip_lladdr_t *new_ll_addr); const uip_ipaddr_t *uip_ds6_nbr_get_ipaddr(const uip_ds6_nbr_t *nbr); uip_ds6_nbr_t *uip_ds6_nbr_lookup(const uip_ipaddr_t *ipaddr); uip_ds6_nbr_t *uip_ds6_nbr_ll_lookup(const uip_lladdr_t *lladdr); diff --git a/os/net/ipv6/uip-ds6.c b/os/net/ipv6/uip-ds6.c index 6dd178dc8..879f47881 100644 --- a/os/net/ipv6/uip-ds6.c +++ b/os/net/ipv6/uip-ds6.c @@ -91,6 +91,7 @@ static uip_ds6_maddr_t *locmaddr; static uip_ds6_aaddr_t *locaaddr; #endif /* UIP_DS6_AADDR_NB */ static uip_ds6_prefix_t *locprefix; +static const uint8_t iid_prefix[] = { 0x00, 0x00 , 0x00 , 0xff , 0xfe , 0x00 }; /*---------------------------------------------------------------------------*/ void @@ -553,8 +554,6 @@ uip_ds6_select_src(uip_ipaddr_t *src, uip_ipaddr_t *dst) void uip_ds6_set_addr_iid(uip_ipaddr_t *ipaddr, uip_lladdr_t *lladdr) { - /* We consider only links with IEEE EUI-64 identifier or - * IEEE 48-bit MAC addresses */ #if (UIP_LLADDR_LEN == 8) memcpy(ipaddr->u8 + 8, lladdr, UIP_LLADDR_LEN); ipaddr->u8[8] ^= 0x02; @@ -564,11 +563,14 @@ uip_ds6_set_addr_iid(uip_ipaddr_t *ipaddr, uip_lladdr_t *lladdr) ipaddr->u8[12] = 0xfe; memcpy(ipaddr->u8 + 13, (uint8_t *)lladdr + 3, 3); ipaddr->u8[8] ^= 0x02; +#elif (UIP_LLADDR_LEN == 2) + /* derive IID as per RFC 6282 */ + memcpy(ipaddr->u8 + 8, iid_prefix, 6); + memcpy(ipaddr->u8 + 8 + 6, lladdr, UIP_LLADDR_LEN); #else -#error uip-ds6.c cannot build interface address when UIP_LLADDR_LEN is not 6 or 8 +#error uip-ds6.c cannot build interface address when UIP_LLADDR_LEN is not 6, 8, or 2 #endif } - /*---------------------------------------------------------------------------*/ void uip_ds6_set_lladdr_from_iid(uip_lladdr_t *lladdr, const uip_ipaddr_t *ipaddr) @@ -576,8 +578,10 @@ uip_ds6_set_lladdr_from_iid(uip_lladdr_t *lladdr, const uip_ipaddr_t *ipaddr) #if (UIP_LLADDR_LEN == 8) memcpy(lladdr, ipaddr->u8 + 8, UIP_LLADDR_LEN); lladdr->addr[0] ^= 0x02; +#elif (UIP_LLADDR_LEN == 2) + memcpy(lladdr, ipaddr->u8 + 6, UIP_LLADDR_LEN); #else -#error uip-ds6.c cannot build lladdr address when UIP_LLADDR_LEN is not 8 +#error uip-ds6.c cannot build lladdr address when UIP_LLADDR_LEN is not 8 or 2 #endif } diff --git a/os/net/ipv6/uip-nd6.c b/os/net/ipv6/uip-nd6.c index ce555ed53..7a5724308 100644 --- a/os/net/ipv6/uip-nd6.c +++ b/os/net/ipv6/uip-nd6.c @@ -230,7 +230,9 @@ ns_input(void) } if(memcmp(&nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET], lladdr, UIP_LLADDR_LEN) != 0) { - if(nbr_table_update_lladdr((const linkaddr_t *)lladdr, (const linkaddr_t *)&lladdr_aligned, 1) == 0) { + if(uip_ds6_nbr_update_ll(&nbr, + (const uip_lladdr_t *)&lladdr_aligned) + < 0) { /* failed to update the lladdr */ goto discard; } @@ -534,7 +536,8 @@ na_input(void) if(nd6_opt_llao == NULL || !extract_lladdr_from_llao_aligned(&lladdr_aligned)) { goto discard; } - if(nbr_table_update_lladdr((const linkaddr_t *)lladdr, (const linkaddr_t *)&lladdr_aligned, 1) == 0) { + if(uip_ds6_nbr_update_ll(&nbr, + (const uip_lladdr_t *)&lladdr_aligned) < 0) { /* failed to update the lladdr */ goto discard; } @@ -561,7 +564,9 @@ na_input(void) if(is_override || !is_llchange || nd6_opt_llao == NULL) { if(nd6_opt_llao != NULL && is_llchange) { if(!extract_lladdr_from_llao_aligned(&lladdr_aligned) || - nbr_table_update_lladdr((const linkaddr_t *) lladdr, (const linkaddr_t *) &lladdr_aligned, 1) == 0) { + uip_ds6_nbr_update_ll(&nbr, + (const uip_lladdr_t *)&lladdr_aligned) + < 0) { /* failed to update the lladdr */ goto discard; } @@ -925,7 +930,8 @@ ra_input(void) if(memcmp(&nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET], lladdr, UIP_LLADDR_LEN) != 0) { /* change of link layer address */ - if(nbr_table_update_lladdr((const linkaddr_t *)lladdr, (const linkaddr_t *)&lladdr_aligned, 1) == 0) { + if(uip_ds6_nbr_update_ll(&nbr, + (const uip_lladdr_t *)&lladdr_aligned) < 0) { /* failed to update the lladdr */ goto discard; } diff --git a/os/net/ipv6/uip.h b/os/net/ipv6/uip.h index 7751b8fc3..9f5eb159d 100755 --- a/os/net/ipv6/uip.h +++ b/os/net/ipv6/uip.h @@ -81,6 +81,7 @@ #include "net/ipv6/uipopt.h" #include "net/ipv6/uipbuf.h" +#include "net/linkaddr.h" /* For memcmp */ #include @@ -107,14 +108,16 @@ typedef uip_ip4addr_t uip_ipaddr_t; /*---------------------------------------------------------------------------*/ +#define UIP_802154_SHORTADDR_LEN 2 +#define UIP_802154_LONGADDR_LEN 8 /** \brief 16 bit 802.15.4 address */ typedef struct uip_802154_shortaddr { - uint8_t addr[2]; + uint8_t addr[UIP_802154_SHORTADDR_LEN]; } uip_802154_shortaddr; /** \brief 64 bit 802.15.4 address */ typedef struct uip_802154_longaddr { - uint8_t addr[8]; + uint8_t addr[UIP_802154_LONGADDR_LEN]; } uip_802154_longaddr; /** \brief 802.11 address */ @@ -134,11 +137,15 @@ typedef struct uip_eth_addr { #if UIP_CONF_LL_802154 /** \brief 802.15.4 address */ +#if LINKADDR_SIZE == UIP_802154_LONGADDR_LEN typedef uip_802154_longaddr uip_lladdr_t; -#define UIP_802154_SHORTADDR_LEN 2 -#define UIP_802154_LONGADDR_LEN 8 +#elif LINKADDR_SIZE == UIP_802154_SHORTADDR_LEN +typedef uip_802154_shortaddr uip_lladdr_t; +#else /* LINKADDR_SIZE == 8 */ +#error unsupported configuration of LINKADDR_SIZE +#endif /* LINKADDR_SIZE == 8 */ /** \brief Link layer address length */ -#define UIP_LLADDR_LEN UIP_802154_LONGADDR_LEN +#define UIP_LLADDR_LEN LINKADDR_SIZE #else /*UIP_CONF_LL_802154*/ #if UIP_CONF_LL_80211 /** \brief 802.11 address */ diff --git a/os/net/ipv6/uiplib.c b/os/net/ipv6/uiplib.c index 693626c87..afe6de42b 100644 --- a/os/net/ipv6/uiplib.c +++ b/os/net/ipv6/uiplib.c @@ -250,9 +250,11 @@ uiplib_ipaddr_snprint(char *buf, size_t size, const uip_ipaddr_t *addr) } } - if(n >= size - 1) { - buf[size - 1] = '\0'; - } + /* + * Make sure the output string is always null-terminated. + */ + buf[MIN(n, size - 1)] = '\0'; + return n; } /*---------------------------------------------------------------------------*/ diff --git a/os/net/link-stats.c b/os/net/link-stats.c index 60b107aec..fbb7677da 100644 --- a/os/net/link-stats.c +++ b/os/net/link-stats.c @@ -64,7 +64,7 @@ /* ETX fixed point divisor. 128 is the value used by RPL (RFC 6551 and RFC 6719) */ #define ETX_DIVISOR LINK_STATS_ETX_DIVISOR /* Number of Tx used to update the ETX EWMA in case of no-ACK */ -#define ETX_NOACK_PENALTY 16 +#define ETX_NOACK_PENALTY 20 /* Initial ETX value */ #define ETX_DEFAULT 2 diff --git a/os/net/linkaddr.h b/os/net/linkaddr.h index 6f7380218..7926550b1 100644 --- a/os/net/linkaddr.h +++ b/os/net/linkaddr.h @@ -70,11 +70,6 @@ typedef union { #endif /* LINKADDR_SIZE == 2 */ } linkaddr_t; -typedef union { - uint8_t u8[8]; - uint16_t u16[4]; -} linkaddr_extended_t; - /** * \brief Copy a link-layer address * \param dest The destination diff --git a/os/net/mac/csma/csma-output.c b/os/net/mac/csma/csma-output.c index 59949c040..9c88d569d 100644 --- a/os/net/mac/csma/csma-output.c +++ b/os/net/mac/csma/csma-output.c @@ -50,10 +50,10 @@ #include "lib/list.h" #include "lib/memb.h" -#if CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64 +#if CONTIKI_TARGET_COOJA #include "lib/simEnvChange.h" #include "sys/cooja_mt.h" -#endif /* CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64 */ +#endif /* CONTIKI_TARGET_COOJA */ /* Log configuration */ #include "sys/log.h" @@ -207,10 +207,10 @@ send_one_packet(void *ptr) wt = RTIMER_NOW(); watchdog_periodic(); while(RTIMER_CLOCK_LT(RTIMER_NOW(), wt + CSMA_ACK_WAIT_TIME)) { -#if CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64 +#if CONTIKI_TARGET_COOJA simProcessRunValue = 1; cooja_mt_yield(); -#endif /* CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64 */ +#endif /* CONTIKI_TARGET_COOJA */ } ret = MAC_TX_NOACK; @@ -225,10 +225,10 @@ send_one_packet(void *ptr) watchdog_periodic(); while(RTIMER_CLOCK_LT(RTIMER_NOW(), wt + CSMA_AFTER_ACK_DETECTED_WAIT_TIME)) { -#if CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64 +#if CONTIKI_TARGET_COOJA simProcessRunValue = 1; cooja_mt_yield(); -#endif /* CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64 */ +#endif /* CONTIKI_TARGET_COOJA */ } } diff --git a/os/net/mac/framer/framer-802154.c b/os/net/mac/framer/framer-802154.c index 7122c5ccd..b4c24da19 100644 --- a/os/net/mac/framer/framer-802154.c +++ b/os/net/mac/framer/framer-802154.c @@ -171,7 +171,6 @@ framer_802154_setup_params(packetbuf_attr_t (*get_attr)(uint8_t type), #if LLSEC802154_USES_EXPLICIT_KEYS params->aux_hdr.security_control.key_id_mode = get_attr(PACKETBUF_ATTR_KEY_ID_MODE); params->aux_hdr.key_index = get_attr(PACKETBUF_ATTR_KEY_INDEX); - params->aux_hdr.key_source.u16[0] = get_attr(PACKETBUF_ATTR_KEY_SOURCE_BYTES_0_1); #endif /* LLSEC802154_USES_EXPLICIT_KEYS */ #else params->fcf.security_enabled = 0; @@ -273,7 +272,6 @@ parse(void) #if LLSEC802154_USES_EXPLICIT_KEYS packetbuf_set_attr(PACKETBUF_ATTR_KEY_ID_MODE, frame.aux_hdr.security_control.key_id_mode); packetbuf_set_attr(PACKETBUF_ATTR_KEY_INDEX, frame.aux_hdr.key_index); - packetbuf_set_attr(PACKETBUF_ATTR_KEY_SOURCE_BYTES_0_1, frame.aux_hdr.key_source.u16[0]); #endif /* LLSEC802154_USES_EXPLICIT_KEYS */ } #endif /* LLSEC802154_USES_AUX_HEADER */ diff --git a/os/net/mac/mac.h b/os/net/mac/mac.h index ce68d46c7..4f2a75b15 100644 --- a/os/net/mac/mac.h +++ b/os/net/mac/mac.h @@ -43,6 +43,14 @@ #include "contiki.h" #include "dev/radio.h" +/** + *\brief The default channel for IEEE 802.15.4 networks. + */ +#ifdef IEEE802154_CONF_DEFAULT_CHANNEL +#define IEEE802154_DEFAULT_CHANNEL IEEE802154_CONF_DEFAULT_CHANNEL +#else /* IEEE802154_CONF_DEFAULT_CHANNEL */ +#define IEEE802154_DEFAULT_CHANNEL 26 +#endif /* IEEE802154_CONF_DEFAULT_CHANNEL */ typedef void (* mac_callback_t)(void *ptr, int status, int transmissions); diff --git a/os/net/mac/tsch/tsch-adaptive-timesync.h b/os/net/mac/tsch/tsch-adaptive-timesync.h index be61b9514..c4ca20b7b 100644 --- a/os/net/mac/tsch/tsch-adaptive-timesync.h +++ b/os/net/mac/tsch/tsch-adaptive-timesync.h @@ -33,6 +33,8 @@ /** * \addtogroup tsch * @{ + * \file + * TSCH adaptive time synchronization */ #ifndef __TSCH_ADAPTIVE_TIMESYNC_H__ @@ -44,15 +46,30 @@ /***** External Variables *****/ -/* The neighbor last used as our time source */ +/** \brief The neighbor last used as our time source */ extern struct tsch_neighbor *last_timesource_neighbor; /********** Functions *********/ +/** + * \brief Updates timesync information for a given neighbor + * \param n The neighbor + * \param time_delta_asn ASN time delta since last synchronization, i.e. number of slots elapsed + * \param drift_correction The measured drift in ticks since last synchronization + */ void tsch_timesync_update(struct tsch_neighbor *n, uint16_t time_delta_asn, int32_t drift_correction); +/** + * \brief Computes time compensation for a given point in the future + * \param delta_ticks The number of ticks in the future we want to calculate compensation for + * \return The time compensation + */ int32_t tsch_timesync_adaptive_compensate(rtimer_clock_t delta_ticks); +/** + * \brief Gives the estimated clock drift w.r.t. the time source in PPM (parts per million) + * \return The time drift in PPM + */ long int tsch_adaptive_timesync_get_drift_ppm(void); #endif /* __TSCH_ADAPTIVE_TIMESYNC_H__ */ diff --git a/os/net/mac/tsch/tsch-asn.h b/os/net/mac/tsch/tsch-asn.h index 9895cdcf4..1db99b432 100644 --- a/os/net/mac/tsch/tsch-asn.h +++ b/os/net/mac/tsch/tsch-asn.h @@ -31,16 +31,12 @@ */ /** + * \addtogroup tsch + * @{ * \file * TSCH 5-Byte Absolute Slot Number (ASN) management * \author * Simon Duquennoy - * - */ - -/** - * \addtogroup tsch - * @{ */ #ifndef __TSCH_ASN_H__ @@ -48,13 +44,13 @@ /************ Types ***********/ -/* The ASN is an absolute slot number over 5 bytes. */ +/** \brief The ASN is an absolute slot number over 5 bytes. */ struct tsch_asn_t { uint32_t ls4b; /* least significant 4 bytes */ uint8_t ms1b; /* most significant 1 byte */ }; -/* For quick modulo operation on ASN */ +/** \brief For quick modulo operation on ASN */ struct tsch_asn_divisor_t { uint16_t val; /* Divisor value */ uint16_t asn_ms1b_remainder; /* Remainder of the operation 0x100000000 / val */ @@ -62,37 +58,37 @@ struct tsch_asn_divisor_t { /************ Macros **********/ -/* Initialize ASN */ +/** \brief Initialize ASN */ #define TSCH_ASN_INIT(asn, ms1b_, ls4b_) do { \ (asn).ms1b = (ms1b_); \ (asn).ls4b = (ls4b_); \ } while(0); -/* Increment an ASN by inc (32 bits) */ +/** \brief Increment an ASN by inc (32 bits) */ #define TSCH_ASN_INC(asn, inc) do { \ uint32_t new_ls4b = (asn).ls4b + (inc); \ if(new_ls4b < (asn).ls4b) { (asn).ms1b++; } \ (asn).ls4b = new_ls4b; \ } while(0); -/* Decrement an ASN by inc (32 bits) */ +/** \brief Decrement an ASN by inc (32 bits) */ #define TSCH_ASN_DEC(asn, dec) do { \ uint32_t new_ls4b = (asn).ls4b - (dec); \ if(new_ls4b > (asn).ls4b) { (asn).ms1b--; } \ (asn).ls4b = new_ls4b; \ } while(0); -/* Returns the 32-bit diff between asn1 and asn2 */ +/** \brief Returns the 32-bit diff between asn1 and asn2 */ #define TSCH_ASN_DIFF(asn1, asn2) \ ((asn1).ls4b - (asn2).ls4b) -/* Initialize a struct asn_divisor_t */ +/** \brief Initialize a struct asn_divisor_t */ #define TSCH_ASN_DIVISOR_INIT(div, val_) do { \ (div).val = (val_); \ (div).asn_ms1b_remainder = ((0xffffffff % (val_)) + 1) % (val_); \ } while(0); -/* Returns the result (16 bits) of a modulo operation on ASN, +/** \brief Returns the result (16 bits) of a modulo operation on ASN, * with divisor being a struct asn_divisor_t */ #define TSCH_ASN_MOD(asn, div) \ ((uint16_t)((asn).ls4b % (div).val) \ diff --git a/os/net/mac/tsch/tsch-conf.h b/os/net/mac/tsch/tsch-conf.h index 8c94fbc9d..3ee47b9cb 100644 --- a/os/net/mac/tsch/tsch-conf.h +++ b/os/net/mac/tsch/tsch-conf.h @@ -31,17 +31,14 @@ */ /** +* \addtogroup tsch +* @{ * \file * TSCH configuration * \author * Simon Duquennoy */ -/** - * \addtogroup tsch - * @{ -*/ - #ifndef __TSCH_CONF_H__ #define __TSCH_CONF_H__ diff --git a/os/net/mac/tsch/tsch-const.h b/os/net/mac/tsch/tsch-const.h index 607bb3506..81ca7ffa8 100644 --- a/os/net/mac/tsch/tsch-const.h +++ b/os/net/mac/tsch/tsch-const.h @@ -31,17 +31,14 @@ */ /** +* \addtogroup tsch +* @{ * \file - * TSCH configuration + * TSCH constants * \author * Simon Duquennoy */ -/** - * \addtogroup tsch - * @{ -*/ - #ifndef __TSCH_CONST_H__ #define __TSCH_CONST_H__ diff --git a/os/net/mac/tsch/tsch-log.h b/os/net/mac/tsch/tsch-log.h index 198304b43..468eff869 100644 --- a/os/net/mac/tsch/tsch-log.h +++ b/os/net/mac/tsch/tsch-log.h @@ -33,6 +33,8 @@ /** * \addtogroup tsch * @{ + * \file + * TSCH per-slot logging */ #ifndef __TSCH_LOG_H__ @@ -70,7 +72,7 @@ /************ Types ***********/ -/* Structure for a log. Union of different types of logs */ +/** \brief Structure for a log. Union of different types of logs */ struct tsch_log_t { enum { tsch_log_tx, tsch_log_rx, @@ -107,21 +109,31 @@ struct tsch_log_t { /********** Functions *********/ -/* Prepare addition of a new log. - * Returns pointer to log structure if success, NULL otherwise */ +/** + * \brief Prepare addition of a new log. + * \return A pointer to log structure if success, NULL otherwise + */ struct tsch_log_t *tsch_log_prepare_add(void); -/* Actually add the previously prepared log */ +/** + * \brief Actually add the previously prepared log + */ void tsch_log_commit(void); -/* Initialize log module */ +/** + * \brief Initialize log module + */ void tsch_log_init(void); -/* Process pending log messages */ +/** + * \brief Process pending log messages + */ void tsch_log_process_pending(void); -/* Stop logging module */ +/** + * \brief Stop logging module + */ void tsch_log_stop(void); /************ Macros **********/ -/* Use this macro to add a log to the queue (will be printed out +/** \brief Use this macro to add a log to the queue (will be printed out * later, after leaving interrupt context) */ #define TSCH_LOG_ADD(log_type, init_code) do { \ struct tsch_log_t *log = tsch_log_prepare_add(); \ diff --git a/os/net/mac/tsch/tsch-packet.c b/os/net/mac/tsch/tsch-packet.c index e0e253a3f..64f03b588 100644 --- a/os/net/mac/tsch/tsch-packet.c +++ b/os/net/mac/tsch/tsch-packet.c @@ -390,8 +390,7 @@ tsch_packet_update_eb(uint8_t *buf, int buf_size, uint8_t tsch_sync_ie_offset) struct ieee802154_ies ies; ies.ie_asn = tsch_current_asn; ies.ie_join_priority = tsch_join_priority; - frame80215e_create_ie_tsch_synchronization(buf+tsch_sync_ie_offset, buf_size-tsch_sync_ie_offset, &ies); - return 1; + return frame80215e_create_ie_tsch_synchronization(buf+tsch_sync_ie_offset, buf_size-tsch_sync_ie_offset, &ies) != -1; } /*---------------------------------------------------------------------------*/ /* Parse a IEEE 802.15.4e TSCH Enhanced Beacon (EB) */ diff --git a/os/net/mac/tsch/tsch-packet.h b/os/net/mac/tsch/tsch-packet.h index 4dfbcbe72..6b05d6653 100644 --- a/os/net/mac/tsch/tsch-packet.h +++ b/os/net/mac/tsch/tsch-packet.h @@ -33,6 +33,8 @@ /** * \addtogroup tsch * @{ + * \file + * TSCH packet parsing and creation. EBs and EACKs. */ #ifndef __TSCH_PACKET_H__ @@ -46,18 +48,56 @@ /********** Functions *********/ -/* Construct enhanced ACK packet and return ACK length */ +/** + * \brief Construct Enhanced ACK packet + * \param buf The buffer where to build the EACK + * \param buf_size The buffer size + * \param dest_addr The link-layer address of the neighbor we are ACKing + * \param seqno The sequence number we are ACKing + * \param drift The time offset in usec measured at Rx of the packer we are ACKing + * \param nack Value of the NACK bit + * \return The length of the packet that was created. -1 if failure. + */ int tsch_packet_create_eack(uint8_t *buf, uint16_t buf_size, const linkaddr_t *dest_addr, uint8_t seqno, int16_t drift, int nack); -/* Parse enhanced ACK packet, extract drift and nack */ +/** + * \brief Parse enhanced ACK packet + * \param buf The buffer where to parse the EACK from + * \param buf_size The buffer size + * \param seqno The sequence number we are expecting + * \param frame The frame structure where to store parsed fields + * \param ies The IE structure where to store parsed IEs + * \param hdr_len A pointer where to store the length of the parsed header + * \return 1 if the EACK is correct and acknowledges the specified frame, 0 otherwise + */ int tsch_packet_parse_eack(const uint8_t *buf, int buf_size, uint8_t seqno, frame802154_t *frame, struct ieee802154_ies *ies, uint8_t *hdr_len); -/* Create an EB packet */ +/** + * \brief Create an EB packet directly in packetbuf + * \param hdr_len A pointer where to store the length of the created header + * \param tsch_sync_ie_ptr A pointer where to store the address of the TSCH synchronization IE + * \return The total length of the EB + */ int tsch_packet_create_eb(uint8_t *hdr_len, uint8_t *tsch_sync_ie_ptr); -/* Update ASN in EB packet */ +/** + * \brief Update ASN in EB packet + * \param buf The buffer that contains the EB + * \param buf_size The buffer size + * \param tsch_sync_ie_offset The offset of the TSCH synchronization IE, in which the ASN is to be written + * \return 1 if success, 0 otherwise + */ int tsch_packet_update_eb(uint8_t *buf, int buf_size, uint8_t tsch_sync_ie_offset); -/* Parse EB and extract ASN and join priority */ +/** + * \brief Parse EB + * \param buf The buffer where to parse the EB from + * \param buf_size The buffer sizecting + * \param frame The frame structure where to store parsed fields + * \param ies The IE structure where to store parsed IEs + * \param hdrlen A pointer where to store the length of the parsed header + * \param frame_without_mic When set, the security MIC will not be parsed + * \return The length of the parsed EB + */ int tsch_packet_parse_eb(const uint8_t *buf, int buf_size, frame802154_t *frame, struct ieee802154_ies *ies, uint8_t *hdrlen, int frame_without_mic); diff --git a/os/net/mac/tsch/tsch-queue.h b/os/net/mac/tsch/tsch-queue.h index 8c7dceb37..b7edcf300 100644 --- a/os/net/mac/tsch/tsch-queue.h +++ b/os/net/mac/tsch/tsch-queue.h @@ -33,6 +33,8 @@ /** * \addtogroup tsch * @{ + * \file + * TSCH queues */ #ifndef __TSCH_QUEUE_H__ @@ -53,50 +55,128 @@ extern struct tsch_neighbor *n_eb; /********** Functions *********/ -/* Add a TSCH neighbor */ +/** + * \brief Add a TSCH neighbor queue + * \param addr The link-layer address of the neighbor to be added + */ struct tsch_neighbor *tsch_queue_add_nbr(const linkaddr_t *addr); -/* Get a TSCH neighbor */ +/** + * \brief Get a TSCH neighbor + * \param addr The link-layer address of the neighbor we are looking for + * \return A pointer to the neighbor queue, NULL if not found + */ struct tsch_neighbor *tsch_queue_get_nbr(const linkaddr_t *addr); -/* Get a TSCH time source (we currently assume there is only one) */ +/** + * \brief Get the TSCH time source (we currently assume there is only one) + * \return The neighbor queue associated to the time source + */ struct tsch_neighbor *tsch_queue_get_time_source(void); -/* Update TSCH time source */ +/** + * \brief Update TSCH time source + * \param new_addr The address of the new TSCH time source + */ int tsch_queue_update_time_source(const linkaddr_t *new_addr); -/* Add packet to neighbor queue. Use same lockfree implementation as ringbuf.c (put is atomic) */ +/** + * \brief Add packet to neighbor queue. Use same lockfree implementation as ringbuf.c (put is atomic) + * \param addr The address of the targetted neighbor, &tsch_broadcast_address for broadcast + * \param max_transmissions The number of MAC retries + * \param sent The MAC packet sent callback + * \param ptr The MAC packet send callback parameter + * \return The newly created packet if any, NULL otherwise + */ struct tsch_packet *tsch_queue_add_packet(const linkaddr_t *addr, uint8_t max_transmissions, mac_callback_t sent, void *ptr); -/* Returns the number of packets currently in any TSCH queue */ +/** + * \brief Returns the number of packets currently in all TSCH queues + * \return The number of packets currently in all TSCH queues + */ int tsch_queue_global_packet_count(void); -/* Returns the number of packets currently a given neighbor queue */ +/** + * \brief Returns the number of packets currently a given neighbor queue + * \param addr The link-layer address of the neighbor we are interested in + * \return The number of packets in the neighbor's queue + */ int tsch_queue_packet_count(const linkaddr_t *addr); -/* Remove first packet from a neighbor queue. The packet is stored in a separate - * dequeued packet list, for later processing. Return the packet. */ +/** + * \brief Remove first packet from a neighbor queue. The packet is stored in a separate + * dequeued packet list, for later processing. + * \param n The neighbor queue + * \return The packet that was removed if any, NULL otherwise + */ struct tsch_packet *tsch_queue_remove_packet_from_queue(struct tsch_neighbor *n); -/* Free a packet */ +/** + * \brief Free a packet + * \param p The packet to be freed + */ void tsch_queue_free_packet(struct tsch_packet *p); -/* Updates neighbor queue state after a transmission */ +/** + * \brief Updates neighbor queue state after a transmission + * \param n The neighbor queue we just sent from + * \param p The packet that was just sent + * \param link The TSCH link used for Tx + * \param mac_tx_status The MAC status (see mac.h) + * \return 1 if the packet remains in queue after the call, 0 if it was removed + */ int tsch_queue_packet_sent(struct tsch_neighbor *n, struct tsch_packet *p, struct tsch_link *link, uint8_t mac_tx_status); -/* Reset neighbor queues */ +/** + * \brief Reset neighbor queues module + */ void tsch_queue_reset(void); -/* Deallocate neighbors with empty queue */ +/** + * \brief Deallocate all neighbors with empty queue + */ void tsch_queue_free_unused_neighbors(void); -/* Is the neighbor queue empty? */ +/** + * \brief Is the neighbor queue empty? + * \param n The neighbor queue + * \return 1 if empty, 0 otherwise + */ int tsch_queue_is_empty(const struct tsch_neighbor *n); -/* Returns the first packet from a neighbor queue */ +/** + * \brief Returns the first packet that can be sent from a queue on a given link + * \param n The neighbor queue + * \param link The link + * \return The next packet to be sent for the neighbor on the given link, if any, else NULL + */ struct tsch_packet *tsch_queue_get_packet_for_nbr(const struct tsch_neighbor *n, struct tsch_link *link); -/* Returns the head packet from a neighbor queue (from neighbor address) */ +/** + * \brief Returns the first packet that can be sent to a given address on a given link + * \param addr The target link-layer address + * \param link The link + * \return The next packet to be sent for to the given address on the given link, if any, else NULL + */ struct tsch_packet *tsch_queue_get_packet_for_dest_addr(const linkaddr_t *addr, struct tsch_link *link); -/* Returns the head packet of any neighbor queue with zero backoff counter. - * Writes pointer to the neighbor in *n */ +/** + * \brief Gets the head packet of any neighbor queue with zero backoff counter. + * \param n A pointer where to store the neighbor queue to be used for Tx + * \param link The link to be used for Tx + * \return The packet if any, else NULL + */ struct tsch_packet *tsch_queue_get_unicast_packet_for_any(struct tsch_neighbor **n, struct tsch_link *link); -/* May the neighbor transmit over a share link? */ +/** + * \brief Is the neighbor backoff timer expired? + * \param n The neighbor queue + * \return 1 if the backoff has expired (neighbor ready to transmit on a shared link), 0 otherwise + */ int tsch_queue_backoff_expired(const struct tsch_neighbor *n); -/* Reset neighbor backoff */ +/** + * \brief Reset neighbor backoff + * \param n The neighbor queue + */ void tsch_queue_backoff_reset(struct tsch_neighbor *n); -/* Increment backoff exponent, pick a new window */ +/** + * \brief Increment backoff exponent of a given neighbor queue, pick a new window + * \param n The neighbor queue + */ void tsch_queue_backoff_inc(struct tsch_neighbor *n); -/* Decrement backoff window for all queues directed at dest_addr */ +/** + * \brief Decrement backoff window for the queue(s) able to Tx to a given address + * \param dest_addr The target address, &tsch_broadcast_address for broadcast + */ void tsch_queue_update_all_backoff_windows(const linkaddr_t *dest_addr); -/* Initialize TSCH queue module */ +/** + * \brief Initialize TSCH queue module + */ void tsch_queue_init(void); #endif /* __TSCH_QUEUE_H__ */ diff --git a/os/net/mac/tsch/tsch-rpl.h b/os/net/mac/tsch/tsch-rpl.h index 64e31166c..23a148db8 100644 --- a/os/net/mac/tsch/tsch-rpl.h +++ b/os/net/mac/tsch/tsch-rpl.h @@ -31,6 +31,8 @@ /** * \addtogroup tsch * @{ + * \file + * TSCH-RPL interaction */ #ifndef __TSCH_RPL_H__ @@ -47,20 +49,35 @@ /********** Functions *********/ -/* Keep-alives packet sent callback. - * To use, set #define TSCH_CALLBACK_KA_SENT tsch_rpl_callback_ka_sent */ +/** +* \brief Report statiscs from KA packet sent in RPL. +* To use, set TSCH_CALLBACK_KA_SENT to tsch_rpl_callback_ka_sent +* \param status The packet sent status +* \param transmissions The total number of transmissions +*/ void tsch_rpl_callback_ka_sent(int status, int transmissions); -/* To use, set #define TSCH_CALLBACK_JOINING_NETWORK tsch_rpl_callback_joining_network */ +/** + * \brief Let RPL know that TSCH joined a new network. + * To use, set TSCH_CALLBACK_JOINING_NETWORK to tsch_rpl_callback_joining_network + */ void tsch_rpl_callback_joining_network(void); -/* Upon leaving a TSCH network, perform a local repair - * (cleanup neighbor state, reset Trickle timer etc) - * To use, set #define TSCH_CALLBACK_LEAVING_NETWORK tsch_rpl_callback_leaving_network */ +/** + * \brief Let RPL know that TSCH joined a new network. Triggers a local repair. + * To use, set TSCH_CALLBACK_LEAVING_NETWORK to tsch_rpl_callback_leaving_network + */ void tsch_rpl_callback_leaving_network(void); -/* Set TSCH EB period based on current RPL DIO period. - * To use, set #define RPL_CALLBACK_NEW_DIO_INTERVAL tsch_rpl_callback_new_dio_interval */ +/** + * \brief Set TSCH EB period based on current RPL DIO period. + * To use, set RPL_CALLBACK_NEW_DIO_INTERVAL to tsch_rpl_callback_new_dio_interval + * \param dio_interval The new DIO interval in clock ticks + */ void tsch_rpl_callback_new_dio_interval(clock_time_t dio_interval); -/* Set TSCH time source based on current RPL preferred parent. - * To use, set #define RPL_CALLBACK_PARENT_SWITCH tsch_rpl_callback_parent_switch */ +/** + * \brief Set TSCH time source based on current RPL preferred parent. + * To use, set RPL_CALLBACK_PARENT_SWITCH to tsch_rpl_callback_parent_switch + * \param old The old RPL parent + * \param new The new RPL parent + */ void tsch_rpl_callback_parent_switch(rpl_parent_t *old, rpl_parent_t *new); #endif /* __TSCH_RPL_H__ */ diff --git a/os/net/mac/tsch/tsch-schedule.h b/os/net/mac/tsch/tsch-schedule.h index 2a2cf5e25..d98a744f3 100644 --- a/os/net/mac/tsch/tsch-schedule.h +++ b/os/net/mac/tsch/tsch-schedule.h @@ -33,6 +33,8 @@ /** * \addtogroup tsch * @{ + * \file + * TSCH scheduling engine */ #ifndef __TSCH_SCHEDULE_H__ @@ -45,42 +47,115 @@ /********** Functions *********/ -/* Module initialization, call only once at startup. Returns 1 is success, 0 if failure. */ +/** + * \brief Module initialization, call only once at init + * \return 1 if success, 0 if failure + */ int tsch_schedule_init(void); -/* Create a 6TiSCH minimal schedule */ +/** + * \brief Create a 6tisch minimal schedule with length TSCH_SCHEDULE_DEFAULT_LENGTH + */ void tsch_schedule_create_minimal(void); -/* Prints out the current schedule (all slotframes and links) */ +/** + * \brief Prints out the current schedule (all slotframes and links) + */ void tsch_schedule_print(void); -/* Adds and returns a slotframe (NULL if failure) */ + +/** + * \brief Creates and adds a new slotframe + * \param handle the slotframe handle + * \param size the slotframe size + * \return the new slotframe, NULL if failure + */ struct tsch_slotframe *tsch_schedule_add_slotframe(uint16_t handle, uint16_t size); -/* Looks for a slotframe from a handle */ + +/** + * \brief Looks up a slotframe by handle + * \param handle the slotframe handle + * \return the slotframe with required handle, if any. NULL otherwise. + */ struct tsch_slotframe *tsch_schedule_get_slotframe_by_handle(uint16_t handle); -/* Removes a slotframe Return 1 if success, 0 if failure */ + +/** + * \brief Removes a slotframe + * \param slotframe The slotframe to be removed + * \return 1 if success, 0 if failure + */ int tsch_schedule_remove_slotframe(struct tsch_slotframe *slotframe); -/* Removes all slotframes, resulting in an empty schedule */ + +/** + * \brief Removes all slotframes, resulting in an empty schedule + * \return 1 if success, 0 if failure + */ int tsch_schedule_remove_all_slotframes(void); -/* Returns next slotframe */ -struct tsch_slotframe *tsch_schedule_slotframes_next(struct tsch_slotframe *sf); -/* Adds a link to a slotframe, return a pointer to it (NULL if failure) */ +/** + * \brief Adds a link to a slotframe + * \param slotframe The slotframe that will contain the new link + * \param link_options The link options, as a bitfield (LINK_OPTION_* flags) + * \param link_type The link type (advertising, normal) + * \param address The link address of the intended destination. Use &tsch_broadcast_address for a slot towards any neighbor + * \param timeslot The link timeslot within the slotframe + * \param channel_offset The link channel offset + * \return A pointer to the new link, NULL if failure + */ struct tsch_link *tsch_schedule_add_link(struct tsch_slotframe *slotframe, uint8_t link_options, enum link_type link_type, const linkaddr_t *address, uint16_t timeslot, uint16_t channel_offset); -/* Looks for a link from a handle */ +/** +* \brief Looks for a link from a handle +* \param handle The target handle +* \return The link with required handle, if any. Otherwise, NULL +*/ struct tsch_link *tsch_schedule_get_link_by_handle(uint16_t handle); -/* Looks within a slotframe for a link with a given timeslot */ + +/** + * \brief Looks within a slotframe for a link with a given timeslot + * \param slotframe The desired slotframe + * \param timeslot The desired timeslot + * \return The link if found, NULL otherwise + */ struct tsch_link *tsch_schedule_get_link_by_timeslot(struct tsch_slotframe *slotframe, uint16_t timeslot); -/* Removes a link. Return 1 if success, 0 if failure */ + +/** + * \brief Removes a link + * \param slotframe The slotframe the link belongs to + * \param l The link to be removed + * \return 1 if success, 0 if failure + */ int tsch_schedule_remove_link(struct tsch_slotframe *slotframe, struct tsch_link *l); -/* Removes a link from slotframe and timeslot. Return a 1 if success, 0 if failure */ + +/** + * \brief Removes a link from a slotframe and timeslot + * \param slotframe The slotframe where to look for the link + * \param timeslot The timeslot where to look for the link within the target slotframe + * \return 1 if success, 0 if failure + */ int tsch_schedule_remove_link_by_timeslot(struct tsch_slotframe *slotframe, uint16_t timeslot); -/* Returns the next active link after a given ASN, and a backup link (for the same ASN, with Rx flag) */ + +/** + * \brief Returns the next active link after a given ASN, and a backup link (for the same ASN, with Rx flag) + * \param asn The base ASN, from which we look for the next active link + * \param time_offset A pointer to uint16_t where to store the time offset between base ASN and link found + * \param backup_link A pointer where to write the address of a backup link, to be executed should the original be no longer active at wakeup + * \return The next active link if any, NULL otherwise + */ struct tsch_link * tsch_schedule_get_next_active_link(struct tsch_asn_t *asn, uint16_t *time_offset, struct tsch_link **backup_link); -/* Access to slotframe list */ + +/** + * \brief Access the first item in the list of slotframes + * \return The first slotframe in the schedule if any, NULL otherwise + */ struct tsch_slotframe *tsch_schedule_slotframe_head(void); + +/** + * \brief Access the next item in the list of slotframes + * \param sf The current slotframe (item in the list) + * \return The next slotframe if any, NULL otherwise + */ struct tsch_slotframe *tsch_schedule_slotframe_next(struct tsch_slotframe *sf); #endif /* __TSCH_SCHEDULE_H__ */ diff --git a/os/net/mac/tsch/tsch-security.h b/os/net/mac/tsch/tsch-security.h index 683bc6316..56c854414 100644 --- a/os/net/mac/tsch/tsch-security.h +++ b/os/net/mac/tsch/tsch-security.h @@ -33,6 +33,8 @@ /** * \addtogroup tsch * @{ + * \file + * TSCH security */ #ifndef __TSCH_SECURITY_H__ diff --git a/os/net/mac/tsch/tsch-slot-operation.h b/os/net/mac/tsch/tsch-slot-operation.h index 1702ce199..1c71c5587 100644 --- a/os/net/mac/tsch/tsch-slot-operation.h +++ b/os/net/mac/tsch/tsch-slot-operation.h @@ -33,6 +33,8 @@ /** * \addtogroup tsch * @{ + * \file + * TSCH runtime operation within timeslots */ #ifndef __TSCH_SLOT_OPERATION_H__ @@ -58,19 +60,45 @@ extern clock_time_t last_sync_time; /********** Functions *********/ -/* Returns a 802.15.4 channel from an ASN and channel offset */ +/** + * Returns a 802.15.4 channel from an ASN and channel offset. Basically adds + * The offset to the ASN and performs a hopping sequence lookup. + * + * \param asn A given ASN + * \param channel_offset A given channel offset + * \return The resulting channel + */ uint8_t tsch_calculate_channel(struct tsch_asn_t *asn, uint8_t channel_offset); -/* Is TSCH locked? */ +/** + * Checks if the TSCH lock is set. Accesses to global structures outside of + * interrupts must be done through the lock, unless the sturcutre has + * atomic read/write + * + * \return 1 if the lock is taken, 0 otherwise + */ int tsch_is_locked(void); -/* Lock TSCH (no link operation) */ +/** + * Takes the TSCH lock. When the lock is taken, slot operation will be skipped + * until release. + * + * \return 1 if the lock was successfully taken, 0 otherwise + */ int tsch_get_lock(void); -/* Release TSCH lock */ +/** + * Releases the TSCH lock. + */ void tsch_release_lock(void); -/* Set global time before starting slot operation, - * with a rtimer time and an ASN */ +/** + * Set global time before starting slot operation, with a rtimer time and an ASN + * + * \param next_slot_start the time to the start of the next slot, in rtimer ticks + * \param next_slot_asn the ASN of the next slot + */ void tsch_slot_operation_sync(rtimer_clock_t next_slot_start, struct tsch_asn_t *next_slot_asn); -/* Start actual slot operation */ +/** + * Start actual slot operation + */ void tsch_slot_operation_start(void); #endif /* __TSCH_SLOT_OPERATION_H__ */ diff --git a/os/net/mac/tsch/tsch-types.h b/os/net/mac/tsch/tsch-types.h index 6bc8895a2..20f9911f6 100644 --- a/os/net/mac/tsch/tsch-types.h +++ b/os/net/mac/tsch/tsch-types.h @@ -31,17 +31,14 @@ */ /** +* \addtogroup tsch +* @{ * \file * TSCH types * \author * Simon Duquennoy */ -/** - * \addtogroup tsch - * @{ -*/ - #ifndef __TSCH_TYPES_H__ #define __TSCH_TYPES_H__ @@ -53,10 +50,10 @@ /********** Data types **********/ -/* 802.15.4e link types. - * LINK_TYPE_ADVERTISING_ONLY is an extra one: for EB-only links. */ +/** \brief 802.15.4e link types. LINK_TYPE_ADVERTISING_ONLY is an extra one: for EB-only links. */ enum link_type { LINK_TYPE_NORMAL, LINK_TYPE_ADVERTISING, LINK_TYPE_ADVERTISING_ONLY }; +/** \brief An IEEE 802.15.4-2015 TSCH link (also called cell or slot) */ struct tsch_link { /* Links are stored as a list: "next" must be the first field */ struct tsch_link *next; @@ -83,7 +80,7 @@ struct tsch_link { void *data; }; -/* 802.15.4e slotframe (contains links) */ +/** \brief 802.15.4e slotframe (contains links) */ struct tsch_slotframe { /* Slotframes are stored as a list: "next" must be the first field */ struct tsch_slotframe *next; @@ -96,7 +93,7 @@ struct tsch_slotframe { LIST_STRUCT(links_list); }; -/* TSCH packet information */ +/** \brief TSCH packet information */ struct tsch_packet { struct queuebuf *qb; /* pointer to the queuebuf to be sent */ mac_callback_t sent; /* callback for this packet */ @@ -108,7 +105,7 @@ struct tsch_packet { uint8_t tsch_sync_ie_offset; /* Offset within the frame used for quick update of EB ASN and join priority */ }; -/* TSCH neighbor information */ +/** \brief TSCH neighbor information */ struct tsch_neighbor { /* Neighbors are stored as a list: "next" must be the first field */ struct tsch_neighbor *next; @@ -127,7 +124,7 @@ struct tsch_neighbor { struct ringbufindex tx_ringbuf; }; -/* TSCH timeslot timing elements. Used to index timeslot timing +/** \brief TSCH timeslot timing elements. Used to index timeslot timing * of different units, such as rtimer tick or micro-second */ enum tsch_timeslot_timing_elements { tsch_ts_cca_offset, @@ -145,7 +142,7 @@ enum tsch_timeslot_timing_elements { tsch_ts_elements_count, /* Not a timing element */ }; -/* Stores data about an incoming packet */ +/** \brief Stores data about an incoming packet */ struct input_packet { uint8_t payload[TSCH_PACKET_MAX_LEN]; /* Packet payload */ struct tsch_asn_t rx_asn; /* ASN when the packet was received */ diff --git a/os/net/mac/tsch/tsch.h b/os/net/mac/tsch/tsch.h index 5f2289c66..0f108bd93 100644 --- a/os/net/mac/tsch/tsch.h +++ b/os/net/mac/tsch/tsch.h @@ -37,6 +37,8 @@ The IEEE 802.15.4-2015 TimeSlotted Channel Hopping (TSCH) protocol. Provides scheduled communication on top of a globally-synchronized network. Performs frequency hopping for enhanced reliability. * @{ +* \file +* Main API declarations for TSCH. */ #ifndef __TSCH_H__ @@ -180,21 +182,57 @@ PROCESS_NAME(tsch_pending_events_process); /********** Functions *********/ -/* The the TSCH join priority */ +/** + * Set the TSCH join priority (JP) + * + * \param jp the new join priority + */ void tsch_set_join_priority(uint8_t jp); -/* The period at which EBs are sent */ +/** + * Set the period at wich TSCH enhanced beacons (EBs) are sent. The period can + * not be set to exceed TSCH_MAX_EB_PERIOD. Set to 0 to stop sending EBs. + * Actual transmissions are jittered, spaced by a random number within + * [period*0.75, period[ + * + * \param period The period in Clock ticks. + */ void tsch_set_eb_period(uint32_t period); -/* The keep-alive timeout */ +/** + * Set the desynchronization timeout after which a node sends a unicasst + * keep-alive (KA) to its time source. Set to 0 to stop sending KAs. The + * actual timeout is a random number within + * [timeout*0.9, timeout[ + * + * \param timeout The timeout in Clock ticks. + */ void tsch_set_ka_timeout(uint32_t timeout); -/* Set the node as PAN coordinator */ +/** + * Set the node as PAN coordinator + * + * \param enable 1 to be coordinator, 0 to be a node + */ void tsch_set_coordinator(int enable); -/* Set the pan as secured or not */ +/** + * Enable/disable security. If done at the coordinator, the Information + * will be included in EBs, and all nodes will adopt the same security level. + * Enabling requires compilation with LLSEC802154_ENABLED set. + * Note: when LLSEC802154_ENABLED is set, nodes boot with security enabled. + * + * \param enable 1 to enable security, 0 to disable it + */ void tsch_set_pan_secured(int enable); -/* Set TSCH to send a keepalive message after TSCH_KEEPALIVE_TIMEOUT */ +/** + * Schedule a keep-alive transmission within [timeout*0.9, timeout[ + * @see tsch_set_ka_timeout + */ void tsch_schedule_keepalive(void); -/* Set TSCH to send a keepalive message immediately */ +/** + * Schedule a keep-alive immediately + */ void tsch_schedule_keepalive_immediately(void); -/* Leave the TSCH network */ +/** + * Leave the TSCH network we are currently in + */ void tsch_disassociate(void); #endif /* __TSCH_H__ */ diff --git a/os/net/nbr-table.c b/os/net/nbr-table.c index 77d3cb07d..8a8eaeb78 100644 --- a/os/net/nbr-table.c +++ b/os/net/nbr-table.c @@ -439,39 +439,6 @@ nbr_table_get_lladdr(nbr_table_t *table, const void *item) return key != NULL ? &key->lladdr : NULL; } /*---------------------------------------------------------------------------*/ -/* Update link-layer address of an item */ -int -nbr_table_update_lladdr(const linkaddr_t *old_addr, const linkaddr_t *new_addr, - int remove_if_duplicate) -{ - int index; - int new_index; - nbr_table_key_t *key; - index = index_from_lladdr(old_addr); - if(index == -1) { - /* Failure to change since there is nothing to change. */ - return 0; - } - if((new_index = index_from_lladdr(new_addr)) != -1) { - /* check if it is a change or not - do not remove / fail if same */ - if(new_index == index) { - return 1; - } - /* This new entry already exists - failure! - remove if requested. */ - if(remove_if_duplicate) { - remove_key(key_from_index(index)); - } - return 0; - } - key = key_from_index(index); - /** - * Copy the new lladdr into the key - since we know that there is no - * conflicting entry. - */ - memcpy(&key->lladdr, new_addr, sizeof(linkaddr_t)); - return 1; -} -/*---------------------------------------------------------------------------*/ #if DEBUG static void print_table() diff --git a/os/net/nbr-table.h b/os/net/nbr-table.h index d7fad5267..0dccd1092 100644 --- a/os/net/nbr-table.h +++ b/os/net/nbr-table.h @@ -113,7 +113,6 @@ int nbr_table_unlock(nbr_table_t *table, nbr_table_item_t *item); /** \name Neighbor tables: address manipulation */ /** @{ */ linkaddr_t *nbr_table_get_lladdr(nbr_table_t *table, const nbr_table_item_t *item); -int nbr_table_update_lladdr(const linkaddr_t *old_addr, const linkaddr_t *new_addr, int remove_if_duplicate); /** @} */ #endif /* NBR_TABLE_H_ */ diff --git a/os/net/packetbuf.h b/os/net/packetbuf.h index 39ce4a467..20e071474 100644 --- a/os/net/packetbuf.h +++ b/os/net/packetbuf.h @@ -236,7 +236,6 @@ enum { #if LLSEC802154_USES_EXPLICIT_KEYS PACKETBUF_ATTR_KEY_ID_MODE, PACKETBUF_ATTR_KEY_INDEX, - PACKETBUF_ATTR_KEY_SOURCE_BYTES_0_1, #endif /* LLSEC802154_USES_EXPLICIT_KEYS */ /* Scope 2 attributes: used between end-to-end nodes. */ diff --git a/os/net/routing/nullrouting/nullrouting.c b/os/net/routing/nullrouting/nullrouting.c index 14c328b0c..bb1399fbb 100644 --- a/os/net/routing/nullrouting/nullrouting.c +++ b/os/net/routing/nullrouting/nullrouting.c @@ -106,7 +106,9 @@ local_repair(const char *str) static void ext_header_remove(void) { +#if NETSTACK_CONF_WITH_IPV6 uip_ext_len = 0; +#endif /* NETSTACK_CONF_WITH_IPV6 */ } /*---------------------------------------------------------------------------*/ static int @@ -149,7 +151,7 @@ drop_route(uip_ds6_route_t *route) } /*---------------------------------------------------------------------------*/ const struct routing_driver nullrouting_driver = { - "Null Routing", + "nullrouting", init, root_set_prefix, root_start, diff --git a/os/net/routing/rpl-classic/rpl-dag.c b/os/net/routing/rpl-classic/rpl-dag.c index 899322264..670a54f3f 100644 --- a/os/net/routing/rpl-classic/rpl-dag.c +++ b/os/net/routing/rpl-classic/rpl-dag.c @@ -829,7 +829,7 @@ rpl_select_dag(rpl_instance_t *instance, rpl_parent_t *p) if(best_dag->preferred_parent != last_parent) { rpl_set_default_route(instance, rpl_parent_get_ipaddr(best_dag->preferred_parent)); PRINTF("RPL: Changed preferred parent, rank changed from %u to %u\n", - (unsigned)old_rank, best_dag->rank); + (unsigned)old_rank, best_dag->rank); RPL_STAT(rpl_stats.parent_switch++); if(RPL_IS_STORING(instance)) { if(last_parent != NULL) { @@ -848,7 +848,7 @@ rpl_select_dag(rpl_instance_t *instance, rpl_parent_t *p) #endif } else if(best_dag->rank != old_rank) { PRINTF("RPL: Preferred parent update, rank changed from %u to %u\n", - (unsigned)old_rank, best_dag->rank); + (unsigned)old_rank, best_dag->rank); } return best_dag; } @@ -908,6 +908,8 @@ rpl_select_parent(rpl_dag_t *dag) #if RPL_WITH_PROBING if(rpl_parent_is_fresh(best)) { rpl_set_preferred_parent(dag, best); + /* Unschedule any already scheduled urgent probing */ + dag->instance->urgent_probing_target = NULL; } else { /* The best is not fresh. Look for the best fresh now. */ rpl_parent_t *best_fresh = best_parent(dag, 1); @@ -920,7 +922,7 @@ rpl_select_parent(rpl_dag_t *dag) } /* Probe the best parent shortly in order to get a fresh estimate */ dag->instance->urgent_probing_target = best; - rpl_schedule_probing(dag->instance); + rpl_schedule_probing_now(dag->instance); } #else /* RPL_WITH_PROBING */ rpl_set_preferred_parent(dag, best); diff --git a/os/net/routing/rpl-classic/rpl-mrhof.c b/os/net/routing/rpl-classic/rpl-mrhof.c index 4f5189384..f3c75985b 100644 --- a/os/net/routing/rpl-classic/rpl-mrhof.c +++ b/os/net/routing/rpl-classic/rpl-mrhof.c @@ -56,14 +56,19 @@ /* RFC6551 and RFC6719 do not mandate the use of a specific formula to * compute the ETX value. This MRHOF implementation relies on the value - * computed by the link-stats module. It has an optional feature, + * computed by the link-stats module.It has an optional feature, * RPL_MRHOF_CONF_SQUARED_ETX, that consists in squaring this value. - * This basically penalizes bad links while preserving the semantics of ETX + * + * Squaring basically penalizes bad links while preserving the semantics of ETX * (1 = perfect link, more = worse link). As a result, MRHOF will favor - * good links over short paths. Recommended when reliability is a priority. - * Without this feature, a hop with 50% PRR (ETX=2) is equivalent to two - * perfect hops with 100% PRR (ETX=1+1=2). With this feature, the former - * path obtains ETX=2*2=4 and the former ETX=1*1+1*1=2. */ + * good links over short paths. Without this feature, a hop with 50% PRR (ETX=2) + * is equivalent to two perfect hops with 100% PRR (ETX=1+1=2). With this + * feature, the former path obtains ETX=2*2=4 and the former ETX=1*1+1*1=2. + * + * While this feature helps achieve extra relaibility, it also results in + * added churn. In networks with high congestion or poor links, this can lead + * to poor connectivity due to more parent switches, loops, Trickle resets, etc. + */ #ifdef RPL_MRHOF_CONF_SQUARED_ETX #define RPL_MRHOF_SQUARED_ETX RPL_MRHOF_CONF_SQUARED_ETX #else /* RPL_MRHOF_CONF_SQUARED_ETX */ diff --git a/os/net/routing/rpl-classic/rpl-private.h b/os/net/routing/rpl-classic/rpl-private.h index 1259fffeb..5a01c538a 100644 --- a/os/net/routing/rpl-classic/rpl-private.h +++ b/os/net/routing/rpl-classic/rpl-private.h @@ -341,6 +341,7 @@ void rpl_schedule_dao_immediately(rpl_instance_t *); void rpl_schedule_unicast_dio_immediately(rpl_instance_t *instance); void rpl_cancel_dao(rpl_instance_t *instance); void rpl_schedule_probing(rpl_instance_t *instance); +void rpl_schedule_probing_now(rpl_instance_t *instance); void rpl_reset_dio_timer(rpl_instance_t *); void rpl_reset_periodic_timer(void); diff --git a/os/net/routing/rpl-classic/rpl-timers.c b/os/net/routing/rpl-classic/rpl-timers.c index c812a8897..97233f574 100644 --- a/os/net/routing/rpl-classic/rpl-timers.c +++ b/os/net/routing/rpl-classic/rpl-timers.c @@ -380,14 +380,7 @@ rpl_schedule_unicast_dio_immediately(rpl_instance_t *instance) clock_time_t get_probing_delay(rpl_dag_t *dag) { - if(dag != NULL && dag->instance != NULL - && dag->instance->urgent_probing_target != NULL) { - /* Urgent probing needed (to find out if a neighbor may become preferred parent) */ - return random_rand() % (CLOCK_SECOND * 10); - } else { - /* Else, use normal probing interval */ - return ((RPL_PROBING_INTERVAL) / 2) + random_rand() % (RPL_PROBING_INTERVAL); - } + return ((RPL_PROBING_INTERVAL) / 2) + random_rand() % (RPL_PROBING_INTERVAL); } /*---------------------------------------------------------------------------*/ rpl_parent_t * @@ -494,7 +487,6 @@ handle_probing_timer(void *ptr) ); /* Send probe, e.g. unicast DIO or DIS */ RPL_PROBING_SEND_FUNC(instance, target_ipaddr); - instance->urgent_probing_target = NULL; } /* Schedule next probing */ @@ -511,5 +503,12 @@ rpl_schedule_probing(rpl_instance_t *instance) ctimer_set(&instance->probing_timer, RPL_PROBING_DELAY_FUNC(instance->current_dag), handle_probing_timer, instance); } +/*---------------------------------------------------------------------------*/ +void +rpl_schedule_probing_now(rpl_instance_t *instance) +{ + ctimer_set(&instance->probing_timer, random_rand() % (CLOCK_SECOND * 4), + handle_probing_timer, instance); +} #endif /* RPL_WITH_PROBING */ /** @}*/ diff --git a/os/net/routing/rpl-classic/rpl.c b/os/net/routing/rpl-classic/rpl.c index b1905d611..ecbcdc158 100644 --- a/os/net/routing/rpl-classic/rpl.c +++ b/os/net/routing/rpl-classic/rpl.c @@ -266,6 +266,11 @@ rpl_link_callback(const linkaddr_t *addr, int status, int numtx) if(instance->used == 1 ) { parent = rpl_find_parent_any_dag(instance, &ipaddr); if(parent != NULL) { + /* If this is the neighbor we were probing urgently, mark urgent + probing as done */ + if(instance->urgent_probing_target == parent) { + instance->urgent_probing_target = NULL; + } /* Trigger DAG rank recalculation. */ PRINTF("RPL: rpl_link_callback triggering update\n"); parent->flags |= RPL_PARENT_FLAG_UPDATED; diff --git a/os/net/routing/rpl-lite/rpl-conf.h b/os/net/routing/rpl-lite/rpl-conf.h index a3693f8b9..8d2f4b7b9 100644 --- a/os/net/routing/rpl-lite/rpl-conf.h +++ b/os/net/routing/rpl-lite/rpl-conf.h @@ -185,10 +185,10 @@ * This value decides if this node must stay as a leaf or not * as allowed by draft-ietf-roll-rpl-19#section-8.5 */ -#ifdef RPL_CONF_LEAF_ONLY -#define RPL_LEAF_ONLY RPL_CONF_LEAF_ONLY +#ifdef RPL_CONF_DEFAULT_LEAF_ONLY +#define RPL_DEFAULT_LEAF_ONLY RPL_CONF_DEFAULT_LEAF_ONLY #else -#define RPL_LEAF_ONLY 0 +#define RPL_DEFAULT_LEAF_ONLY 0 #endif /******************************************************************************/ diff --git a/os/net/routing/rpl-lite/rpl-dag.c b/os/net/routing/rpl-lite/rpl-dag.c index 00ee1663e..68d9e7aaa 100644 --- a/os/net/routing/rpl-lite/rpl-dag.c +++ b/os/net/routing/rpl-lite/rpl-dag.c @@ -183,14 +183,14 @@ void rpl_refresh_routes(const char *str) { if(rpl_dag_root_is_root()) { - LOG_WARN("incrementing DTSN (%s), current %u)\n", + /* Increment DTSN */ + RPL_LOLLIPOP_INCREMENT(curr_instance.dtsn_out); + + LOG_WARN("incremented DTSN (%s), current %u\n", str, curr_instance.dtsn_out); if(LOG_INFO_ENABLED) { rpl_neighbor_print_list("Refresh routes (before)"); } - - /* Increment DTSN */ - RPL_LOLLIPOP_INCREMENT(curr_instance.dtsn_out); } } /*---------------------------------------------------------------------------*/ @@ -198,15 +198,16 @@ void rpl_global_repair(const char *str) { if(rpl_dag_root_is_root()) { - LOG_WARN("initiating global repair (%s), version %u, rank %u)\n", + RPL_LOLLIPOP_INCREMENT(curr_instance.dag.version); /* New DAG version */ + curr_instance.dtsn_out = RPL_LOLLIPOP_INIT; /* Re-initialize DTSN */ + + LOG_WARN("initiating global repair (%s), version %u, rank %u\n", str, curr_instance.dag.version, curr_instance.dag.rank); if(LOG_INFO_ENABLED) { rpl_neighbor_print_list("Global repair (before)"); } - /* Initiate global repair */ - RPL_LOLLIPOP_INCREMENT(curr_instance.dag.version); /* New DAG version */ - RPL_LOLLIPOP_INCREMENT(curr_instance.dtsn_out); /* Request new DAOs */ + /* Now do a local repair to disseminate the new version */ rpl_local_repair("Global repair"); } } @@ -215,12 +216,13 @@ static void global_repair_non_root(rpl_dio_t *dio) { if(!rpl_dag_root_is_root()) { - LOG_WARN("participating in global repair, version %u, rank %u)\n", - curr_instance.dag.version, curr_instance.dag.rank); + LOG_WARN("participating in global repair, version %u, rank %u\n", + dio->version, curr_instance.dag.rank); if(LOG_INFO_ENABLED) { rpl_neighbor_print_list("Global repair (before)"); } /* Re-initialize configuration from DIO */ + rpl_timers_stop_dag_timers(); init_dag_from_dio(dio); rpl_local_repair("Global repair"); } @@ -395,9 +397,15 @@ process_dio_from_current_dag(uip_ipaddr_t *from, rpl_dio_t *dio) return; } - /* If the DIO sender is on an older version of the DAG, ignore it. The node - will eventually hear the global repair and catch up. */ + /* If the DIO sender is on an older version of the DAG, do not process it + * further. The sender will eventually hear the global repair and catch up. */ if(rpl_lollipop_greater_than(curr_instance.dag.version, dio->version)) { + if(dio->rank == ROOT_RANK) { + /* Before returning, if the DIO was from the root, an old DAG versions + * likely incidates a root reboot. Reset our DIO timer to make sure the + * root hears our version ASAP, and in turn triggers a global repair. */ + rpl_timers_dio_reset("Heard old version from root"); + } return; } @@ -412,10 +420,12 @@ process_dio_from_current_dag(uip_ipaddr_t *from, rpl_dio_t *dio) * Must come first, as it might remove all neighbors, and we then need * to re-add this source of the DIO to the neighbor table */ if(rpl_lollipop_greater_than(dio->version, curr_instance.dag.version)) { - if(curr_instance.dag.rank == ROOT_RANK) { /* The root should not hear newer versions */ + if(curr_instance.dag.rank == ROOT_RANK) { + /* The root should not hear newer versions unless it just rebooted */ LOG_ERR("inconsistent DIO version (current: %u, received: %u), initiate global repair\n", curr_instance.dag.version, dio->version); - curr_instance.dag.version = dio->version; /* Update version and trigger global repair */ + /* Update version and trigger global repair */ + curr_instance.dag.version = dio->version; rpl_global_repair("Inconsistent DIO version"); } else { LOG_WARN("new DIO version (current: %u, received: %u), apply global repair\n", @@ -451,7 +461,7 @@ process_dio_from_current_dag(uip_ipaddr_t *from, rpl_dio_t *dio) if(curr_instance.mop != RPL_MOP_NO_DOWNWARD_ROUTES) { if(nbr != NULL && nbr == curr_instance.dag.preferred_parent && rpl_lollipop_greater_than(dio->dtsn, last_dtsn)) { RPL_LOLLIPOP_INCREMENT(curr_instance.dtsn_out); - LOG_INFO("DTSN increment %u->%u, schedule new DAO with DTSN %u", + LOG_WARN("DTSN increment %u->%u, schedule new DAO with DTSN %u\n", last_dtsn, dio->dtsn, curr_instance.dtsn_out); rpl_timers_schedule_dao(); } diff --git a/os/net/routing/rpl-lite/rpl-icmp6.c b/os/net/routing/rpl-lite/rpl-icmp6.c index 1e4a50423..be5ea2948 100644 --- a/os/net/routing/rpl-lite/rpl-icmp6.c +++ b/os/net/routing/rpl-lite/rpl-icmp6.c @@ -342,14 +342,14 @@ rpl_icmp6_dio_output(uip_ipaddr_t *uc_addr) /* Make sure we're up-to-date before sending data out */ rpl_dag_update_state(); -#if RPL_LEAF_ONLY - /* In leaf mode, we only send DIO messages as unicasts in response to - unicast DIS messages. */ - if(uc_addr == NULL) { - /* Do not send multicast DIO in leaf mode */ - return; + if(rpl_get_leaf_only()) { + /* In leaf mode, we only send DIO messages as unicasts in response to + unicast DIS messages. */ + if(uc_addr == NULL) { + /* Do not send multicast DIO in leaf mode */ + return; + } } -#endif /* RPL_LEAF_ONLY */ /* DAG Information Object */ pos = 0; @@ -358,11 +358,11 @@ rpl_icmp6_dio_output(uip_ipaddr_t *uc_addr) buffer[pos++] = curr_instance.instance_id; buffer[pos++] = curr_instance.dag.version; -#if RPL_LEAF_ONLY - set16(buffer, pos, RPL_INFINITE_RANK); -#else /* RPL_LEAF_ONLY */ - set16(buffer, pos, curr_instance.dag.rank); -#endif /* RPL_LEAF_ONLY */ + if(rpl_get_leaf_only()) { + set16(buffer, pos, RPL_INFINITE_RANK); + } else { + set16(buffer, pos, curr_instance.dag.rank); + } pos += 2; buffer[pos] = 0; @@ -383,29 +383,29 @@ rpl_icmp6_dio_output(uip_ipaddr_t *uc_addr) memcpy(buffer + pos, &curr_instance.dag.dag_id, sizeof(curr_instance.dag.dag_id)); pos += 16; -#if !RPL_LEAF_ONLY - if(curr_instance.mc.type != RPL_DAG_MC_NONE) { - buffer[pos++] = RPL_OPTION_DAG_METRIC_CONTAINER; - buffer[pos++] = 6; - buffer[pos++] = curr_instance.mc.type; - buffer[pos++] = curr_instance.mc.flags >> 1; - buffer[pos] = (curr_instance.mc.flags & 1) << 7; - buffer[pos++] |= (curr_instance.mc.aggr << 4) | curr_instance.mc.prec; - if(curr_instance.mc.type == RPL_DAG_MC_ETX) { - buffer[pos++] = 2; - set16(buffer, pos, curr_instance.mc.obj.etx); - pos += 2; - } else if(curr_instance.mc.type == RPL_DAG_MC_ENERGY) { - buffer[pos++] = 2; - buffer[pos++] = curr_instance.mc.obj.energy.flags; - buffer[pos++] = curr_instance.mc.obj.energy.energy_est; - } else { - LOG_ERR("unable to send DIO because of unsupported DAG MC type %u\n", - (unsigned)curr_instance.mc.type); - return; + if(!rpl_get_leaf_only()) { + if(curr_instance.mc.type != RPL_DAG_MC_NONE) { + buffer[pos++] = RPL_OPTION_DAG_METRIC_CONTAINER; + buffer[pos++] = 6; + buffer[pos++] = curr_instance.mc.type; + buffer[pos++] = curr_instance.mc.flags >> 1; + buffer[pos] = (curr_instance.mc.flags & 1) << 7; + buffer[pos++] |= (curr_instance.mc.aggr << 4) | curr_instance.mc.prec; + if(curr_instance.mc.type == RPL_DAG_MC_ETX) { + buffer[pos++] = 2; + set16(buffer, pos, curr_instance.mc.obj.etx); + pos += 2; + } else if(curr_instance.mc.type == RPL_DAG_MC_ENERGY) { + buffer[pos++] = 2; + buffer[pos++] = curr_instance.mc.obj.energy.flags; + buffer[pos++] = curr_instance.mc.obj.energy.energy_est; + } else { + LOG_ERR("unable to send DIO because of unsupported DAG MC type %u\n", + (unsigned)curr_instance.mc.type); + return; + } } } -#endif /* !RPL_LEAF_ONLY */ /* Always add a DAG configuration option. */ buffer[pos++] = RPL_OPTION_DAG_CONF; @@ -442,9 +442,9 @@ rpl_icmp6_dio_output(uip_ipaddr_t *uc_addr) pos += 16; } -#if !RPL_LEAF_ONLY - addr = addr != NULL ? addr : &rpl_multicast_addr; -#endif /* RPL_LEAF_ONLY */ + if(!rpl_get_leaf_only()) { + addr = addr != NULL ? addr : &rpl_multicast_addr; + } LOG_INFO("sending a %s-DIO with rank %u to ", uc_addr != NULL ? "unicast" : "multicast", diff --git a/os/net/routing/rpl-lite/rpl-mrhof.c b/os/net/routing/rpl-lite/rpl-mrhof.c index a0b2546eb..79c06d496 100644 --- a/os/net/routing/rpl-lite/rpl-mrhof.c +++ b/os/net/routing/rpl-lite/rpl-mrhof.c @@ -56,26 +56,39 @@ /* RFC6551 and RFC6719 do not mandate the use of a specific formula to * compute the ETX value. This MRHOF implementation relies on the value - * computed by the link-stats module. It has an optional feature, + * computed by the link-stats module.It has an optional feature, * RPL_MRHOF_CONF_SQUARED_ETX, that consists in squaring this value. - * This basically penalizes bad links while preserving the semantics of ETX + * + * Squaring basically penalizes bad links while preserving the semantics of ETX * (1 = perfect link, more = worse link). As a result, MRHOF will favor - * good links over short paths. Recommended when reliability is a priority. - * Without this feature, a hop with 50% PRR (ETX=2) is equivalent to two - * perfect hops with 100% PRR (ETX=1+1=2). With this feature, the former - * path obtains ETX=2*2=4 and the former ETX=1*1+1*1=2. */ + * good links over short paths. Without this feature, a hop with 50% PRR (ETX=2) + * is equivalent to two perfect hops with 100% PRR (ETX=1+1=2). With this + * feature, the former path obtains ETX=2*2=4 and the former ETX=1*1+1*1=2. + * + * While this feature helps achieve extra relaibility, it also results in + * added churn. In networks with high congestion or poor links, this can lead + * to poor connectivity due to more parent switches, loops, Trickle resets, etc. + */ #ifdef RPL_MRHOF_CONF_SQUARED_ETX #define RPL_MRHOF_SQUARED_ETX RPL_MRHOF_CONF_SQUARED_ETX #else /* RPL_MRHOF_CONF_SQUARED_ETX */ -#define RPL_MRHOF_SQUARED_ETX 1 +#define RPL_MRHOF_SQUARED_ETX 0 #endif /* RPL_MRHOF_CONF_SQUARED_ETX */ /* Configuration parameters of RFC6719. Reject parents that have a higher * link metric than the following. The default value is 512. */ +#ifdef RPL_MRHOF_CONF_MAX_LINK_METRIC +#define MAX_LINK_METRIC RPL_MRHOF_CONF_MAX_LINK_METRIC +#else /* RPL_MRHOF_CONF_MAX_LINK_METRIC */ #define MAX_LINK_METRIC 512 /* Eq ETX of 4 */ +#endif /* RPL_MRHOF_CONF_MAX_LINK_METRIC */ /* Reject parents that have a higher path cost than the following. */ +#ifdef RPL_MRHOF_CONF_MAX_PATH_COST +#define MAX_PATH_COST RPL_MRHOF_CONF_MAX_PATH_COST +#else /* RPL_MRHOF_CONF_MAX_PATH_COST */ #define MAX_PATH_COST 32768 /* Eq path ETX of 256 */ +#endif /* RPL_MRHOF_CONF_MAX_PATH_COST */ #if !RPL_MRHOF_SQUARED_ETX /* Hysteresis of MRHOF: the rank must differ more than PARENT_SWITCH_THRESHOLD_DIV diff --git a/os/net/routing/rpl-lite/rpl-neighbor.c b/os/net/routing/rpl-lite/rpl-neighbor.c index d6a545e13..bd0632778 100644 --- a/os/net/routing/rpl-lite/rpl-neighbor.c +++ b/os/net/routing/rpl-lite/rpl-neighbor.c @@ -63,6 +63,18 @@ static rpl_nbr_t * best_parent(int fresh_only); /* Per-neighbor RPL information */ NBR_TABLE_GLOBAL(rpl_nbr_t, rpl_neighbors); +/*---------------------------------------------------------------------------*/ +static int +max_acceptable_rank(void) +{ + if(curr_instance.max_rankinc == 0) { + /* There is no max rank increment */ + return RPL_INFINITE_RANK; + } else { + /* Make sure not to exceed RPL_INFINITE_RANK */ + return MIN((uint32_t)curr_instance.dag.lowest_rank + curr_instance.max_rankinc, RPL_INFINITE_RANK); + } +} /*---------------------------------------------------------------------------*/ /* As per RFC 6550, section 8.2.2.4 */ static int @@ -70,8 +82,7 @@ acceptable_rank(rpl_rank_t rank) { return rank != RPL_INFINITE_RANK && rank >= ROOT_RANK - && ((curr_instance.max_rankinc == 0) || - rank <= curr_instance.dag.lowest_rank + curr_instance.max_rankinc); + && rank <= max_acceptable_rank(); } /*---------------------------------------------------------------------------*/ void @@ -89,7 +100,7 @@ rpl_neighbor_print_list(const char *str) LOG_INFO_(", DAG state: %s, MOP %u OCP %u rank %u max-rank %u, dioint %u, nbr count %u (%s)\n", rpl_dag_state_to_str(curr_instance.dag.state), curr_instance.mop, curr_instance.of->ocp, curr_rank, - curr_instance.max_rankinc != 0 ? curr_instance.dag.lowest_rank + curr_instance.max_rankinc : 0xffff, + max_acceptable_rank(), curr_dio_interval, rpl_neighbor_count(), str); while(nbr != NULL) { const struct link_stats *stats = rpl_neighbor_get_link_stats(nbr); @@ -357,6 +368,8 @@ rpl_neighbor_select_best(void) #if RPL_WITH_PROBING if(best != NULL) { if(rpl_neighbor_is_fresh(best)) { + /* Unschedule any already scheduled urgent probing */ + curr_instance.dag.urgent_probing_target = NULL; /* Return best if it is fresh */ return best; } else { @@ -369,7 +382,7 @@ rpl_neighbor_select_best(void) LOG_WARN_6ADDR(rpl_neighbor_get_ipaddr(best)); LOG_WARN_("\n"); curr_instance.dag.urgent_probing_target = best; - rpl_schedule_probing(); + rpl_schedule_probing_now(); } /* The best is our preferred parent. It is not fresh but used to be, diff --git a/os/net/routing/rpl-lite/rpl-timers.c b/os/net/routing/rpl-lite/rpl-timers.c index f7a50b858..6fb00ca17 100644 --- a/os/net/routing/rpl-lite/rpl-timers.c +++ b/os/net/routing/rpl-lite/rpl-timers.c @@ -150,11 +150,11 @@ rpl_timers_dio_reset(const char *str) { if(rpl_dag_ready_to_advertise()) { LOG_INFO("reset DIO timer (%s)\n", str); -#if !RPL_LEAF_ONLY - curr_instance.dag.dio_counter = 0; - curr_instance.dag.dio_intcurrent = curr_instance.dio_intmin; - new_dio_interval(); -#endif /* RPL_LEAF_ONLY */ + if(!rpl_get_leaf_only()) { + curr_instance.dag.dio_counter = 0; + curr_instance.dag.dio_intcurrent = curr_instance.dio_intmin; + new_dio_interval(); + } } } /*---------------------------------------------------------------------------*/ @@ -342,13 +342,7 @@ handle_dao_ack_timer(void *ptr) clock_time_t get_probing_delay(void) { - if(curr_instance.used && curr_instance.dag.urgent_probing_target != NULL) { - /* Urgent probing needed (to find out if a neighbor may become preferred parent) */ - return random_rand() % (CLOCK_SECOND * 4); - } else { - /* Else, use normal probing interval */ - return ((RPL_PROBING_INTERVAL) / 2) + random_rand() % (RPL_PROBING_INTERVAL); - } + return ((RPL_PROBING_INTERVAL) / 2) + random_rand() % (RPL_PROBING_INTERVAL); } /*---------------------------------------------------------------------------*/ rpl_nbr_t * @@ -435,12 +429,12 @@ handle_probing_timer(void *ptr) LOG_INFO_6ADDR(target_ipaddr); LOG_INFO_(" %s last tx %u min ago\n", curr_instance.dag.urgent_probing_target != NULL ? "(urgent)" : "", - probing_target != NULL ? + stats != NULL ? (unsigned)((clock_time() - stats->last_tx_time) / (60 * CLOCK_SECOND)) : 0 ); /* Send probe, e.g. unicast DIO or DIS */ RPL_PROBING_SEND_FUNC(target_ipaddr); - curr_instance.dag.urgent_probing_target = NULL; + /* urgent_probing_target will be NULLed in the packet_sent callback */ } else { LOG_INFO("no neighbor needs probing\n"); } @@ -457,6 +451,15 @@ rpl_schedule_probing(void) handle_probing_timer, NULL); } } +/*---------------------------------------------------------------------------*/ +void +rpl_schedule_probing_now(void) +{ + if(curr_instance.used) { + ctimer_set(&curr_instance.dag.probing_timer, + random_rand() % (CLOCK_SECOND * 4), handle_probing_timer, NULL); + } +} #endif /* RPL_WITH_PROBING */ /*---------------------------------------------------------------------------*/ /*------------------------------- Leaving-- -------------------------------- */ diff --git a/os/net/routing/rpl-lite/rpl-timers.h b/os/net/routing/rpl-lite/rpl-timers.h index 884a55696..e153858fc 100644 --- a/os/net/routing/rpl-lite/rpl-timers.h +++ b/os/net/routing/rpl-lite/rpl-timers.h @@ -104,6 +104,11 @@ void rpl_timers_schedule_dao_ack(uip_ipaddr_t *target, uint16_t sequence); */ void rpl_schedule_probing(void); +/** + * Schedule probing within a few seconds +*/ +void rpl_schedule_probing_now(void); + /** * Schedule a state update ASAP. Useful to force an update from a context * where updating directly would be unsafe. diff --git a/os/net/routing/rpl-lite/rpl.c b/os/net/routing/rpl-lite/rpl.c index acfe94c37..47ffc5387 100644 --- a/os/net/routing/rpl-lite/rpl.c +++ b/os/net/routing/rpl-lite/rpl.c @@ -50,6 +50,7 @@ #define LOG_LEVEL LOG_LEVEL_RPL uip_ipaddr_t rpl_multicast_addr; +static uint8_t rpl_leaf_only = RPL_DEFAULT_LEAF_ONLY; /*---------------------------------------------------------------------------*/ int @@ -98,6 +99,11 @@ rpl_link_callback(const linkaddr_t *addr, int status, int numtx) if(curr_instance.used == 1 ) { rpl_nbr_t *nbr = rpl_neighbor_get_from_lladdr((uip_lladdr_t *)addr); if(nbr != NULL) { + /* If this is the neighbor we were probing urgently, mark urgent + probing as done */ + if(curr_instance.dag.urgent_probing_target == nbr) { + curr_instance.dag.urgent_probing_target = NULL; + } /* Link stats were updated, and we need to update our internal state. Updating from here is unsafe; postpone */ LOG_INFO("packet sent to "); @@ -223,6 +229,18 @@ drop_route(uip_ds6_route_t *route) /* Do nothing. RPL-lite only supports non-storing mode, i.e. no routes */ } /*---------------------------------------------------------------------------*/ +void +rpl_set_leaf_only(uint8_t value) +{ + rpl_leaf_only = value; +} +/*---------------------------------------------------------------------------*/ +uint8_t +rpl_get_leaf_only(void) +{ + return rpl_leaf_only; +} +/*---------------------------------------------------------------------------*/ const struct routing_driver rpl_lite_driver = { "RPL Lite", init, diff --git a/os/net/routing/rpl-lite/rpl.h b/os/net/routing/rpl-lite/rpl.h index 25ac3863e..e39c825c4 100644 --- a/os/net/routing/rpl-lite/rpl.h +++ b/os/net/routing/rpl-lite/rpl.h @@ -133,6 +133,20 @@ int rpl_lollipop_greater_than(int a, int b); */ void rpl_refresh_routes(const char *str); +/** + * Changes the value of the rpl_leaf_only flag, which determines if a node acts + * only as a leaf in the network + * + * \param value the value to set: 0-disable, 1-enable + */ +void rpl_set_leaf_only(uint8_t value); + +/** + * Get the value of the rpl_leaf_only flag + * + * \return The value of the rpl_leaf_only flag + */ +uint8_t rpl_get_leaf_only(void); /** @} */ #endif /* RPL_H */ diff --git a/os/services/ip64/ip64-slip-interface.c b/os/services/ip64/ip64-slip-interface.c index 7ad4d4789..10422f2c7 100644 --- a/os/services/ip64/ip64-slip-interface.c +++ b/os/services/ip64/ip64-slip-interface.c @@ -57,24 +57,24 @@ static void input_callback(void) { /*PRINTF("SIN: %u\n", uip_len);*/ - if(uip_buf[0] == '!') { - PRINTF("Got configuration message of type %c\n", uip_buf[1]); + if(uip_buf[UIP_LLH_LEN] == '!') { + PRINTF("Got configuration message of type %c\n", uip_buf[UIP_LLH_LEN + 1]); uip_clear_buf(); #if 0 - if(uip_buf[1] == 'P') { + if(uip_buf[UIP_LLH_LEN + 1] == 'P') { uip_ipaddr_t prefix; /* Here we set a prefix !!! */ memset(&prefix, 0, 16); - memcpy(&prefix, &uip_buf[2], 8); + memcpy(&prefix, &uip_buf[UIP_LLH_LEN + 2], 8); PRINTF("Setting prefix "); PRINT6ADDR(&prefix); PRINTF("\n"); set_prefix_64(&prefix); } #endif - } else if(uip_buf[0] == '?') { - PRINTF("Got request message of type %c\n", uip_buf[1]); - if(uip_buf[1] == 'M') { + } else if(uip_buf[UIP_LLH_LEN] == '?') { + PRINTF("Got request message of type %c\n", uip_buf[UIP_LLH_LEN + 1]); + if(uip_buf[UIP_LLH_LEN + 1] == 'M') { const char *hexchar = "0123456789abcdef"; int j; /* this is just a test so far... just to see if it works */ @@ -84,8 +84,7 @@ input_callback(void) uip_buf[3 + j * 2] = hexchar[uip_lladdr.addr[j] & 15]; } uip_len = 18; - slip_send(); - + slip_write(uip_buf, uip_len); } uip_clear_buf(); } else { @@ -147,6 +146,3 @@ const struct uip_fallback_interface ip64_slip_interface = { init, output }; /*---------------------------------------------------------------------------*/ - - - diff --git a/os/services/lwm2m/lwm2m-device.c b/os/services/lwm2m/lwm2m-device.c index 9e91b37fd..4183c59ca 100644 --- a/os/services/lwm2m/lwm2m-device.c +++ b/os/services/lwm2m/lwm2m-device.c @@ -48,7 +48,7 @@ /* Log configuration */ #include "coap-log.h" -#define LOG_MODULE "lwm2m-device" +#define LOG_MODULE "lwm2m-dev" #define LOG_LEVEL LOG_LEVEL_LWM2M static const lwm2m_resource_id_t resources[] = diff --git a/os/services/lwm2m/lwm2m-engine.c b/os/services/lwm2m/lwm2m-engine.c index b96674215..6f2aeefd8 100644 --- a/os/services/lwm2m/lwm2m-engine.c +++ b/os/services/lwm2m/lwm2m-engine.c @@ -63,7 +63,7 @@ /* Log configuration */ #include "coap-log.h" -#define LOG_MODULE "lwm2m-engine" +#define LOG_MODULE "lwm2m-eng" #define LOG_LEVEL LOG_LEVEL_LWM2M #ifndef LWM2M_ENGINE_CLIENT_ENDPOINT_PREFIX @@ -543,6 +543,9 @@ lwm2m_engine_init(void) #endif /* LWM2M_ENGINE_CLIENT_ENDPOINT_NAME */ + /* Initialize CoAP engine. Contiki-NG already does that from the main, + * but for standalone use of lwm2m, this is required here. coap_engine_init() + * checks for double-initialization and can be called twice safely. */ coap_engine_init(); /* Register the CoAP handler for lightweight object handling */ diff --git a/os/services/lwm2m/lwm2m-firmware.c b/os/services/lwm2m/lwm2m-firmware.c index e89c3dab4..87815d684 100644 --- a/os/services/lwm2m/lwm2m-firmware.c +++ b/os/services/lwm2m/lwm2m-firmware.c @@ -44,7 +44,7 @@ /* Log configuration */ #include "coap-log.h" -#define LOG_MODULE "lwm2m-firmware" +#define LOG_MODULE "lwm2m-fw" #define LOG_LEVEL LOG_LEVEL_LWM2M #define UPDATE_PACKAGE 0 diff --git a/os/services/lwm2m/lwm2m-plain-text.c b/os/services/lwm2m/lwm2m-plain-text.c index bbd293aa0..3dc816ddc 100644 --- a/os/services/lwm2m/lwm2m-plain-text.c +++ b/os/services/lwm2m/lwm2m-plain-text.c @@ -49,7 +49,7 @@ /* Log configuration */ #include "coap-log.h" -#define LOG_MODULE "lwm2m-plain-text" +#define LOG_MODULE "lwm2m-text" #define LOG_LEVEL LOG_LEVEL_NONE /*---------------------------------------------------------------------------*/ diff --git a/os/services/lwm2m/lwm2m-rd-client.c b/os/services/lwm2m/lwm2m-rd-client.c index 0f904ee4d..03d21e33e 100644 --- a/os/services/lwm2m/lwm2m-rd-client.c +++ b/os/services/lwm2m/lwm2m-rd-client.c @@ -64,7 +64,7 @@ /* Log configuration */ #include "coap-log.h" -#define LOG_MODULE "lwm2m-rd-client" +#define LOG_MODULE "lwm2m-rd" #define LOG_LEVEL LOG_LEVEL_LWM2M #ifndef LWM2M_DEFAULT_CLIENT_LIFETIME diff --git a/os/services/lwm2m/lwm2m-security.c b/os/services/lwm2m/lwm2m-security.c index 5fe0c31cb..e4275f280 100644 --- a/os/services/lwm2m/lwm2m-security.c +++ b/os/services/lwm2m/lwm2m-security.c @@ -54,7 +54,7 @@ /* Log configuration */ #include "coap-log.h" -#define LOG_MODULE "lwm2m-security" +#define LOG_MODULE "lwm2m-sec" #define LOG_LEVEL LOG_LEVEL_LWM2M #define MAX_COUNT LWM2M_SERVER_MAX_COUNT diff --git a/os/services/lwm2m/lwm2m-server.c b/os/services/lwm2m/lwm2m-server.c index 67b2c45ba..bf0398b4f 100644 --- a/os/services/lwm2m/lwm2m-server.c +++ b/os/services/lwm2m/lwm2m-server.c @@ -51,7 +51,7 @@ /* Log configuration */ #include "coap-log.h" -#define LOG_MODULE "lwm2m-server" +#define LOG_MODULE "lwm2m-srv" #define LOG_LEVEL LOG_LEVEL_LWM2M #define MAX_COUNT LWM2M_SERVER_MAX_COUNT diff --git a/os/services/lwm2m/lwm2m-tlv-writer.c b/os/services/lwm2m/lwm2m-tlv-writer.c index 6df16447e..41bdc2f6c 100644 --- a/os/services/lwm2m/lwm2m-tlv-writer.c +++ b/os/services/lwm2m/lwm2m-tlv-writer.c @@ -47,7 +47,7 @@ /* Log configuration */ #include "coap-log.h" -#define LOG_MODULE "lwm2m-tlv-writer" +#define LOG_MODULE "lwm2m-tlv" #define LOG_LEVEL LOG_LEVEL_NONE /*---------------------------------------------------------------------------*/ diff --git a/os/services/rpl-border-router/embedded/slip-bridge.c b/os/services/rpl-border-router/embedded/slip-bridge.c index cb85793f0..d1f97339d 100644 --- a/os/services/rpl-border-router/embedded/slip-bridge.c +++ b/os/services/rpl-border-router/embedded/slip-bridge.c @@ -62,7 +62,7 @@ request_prefix(void) uip_buf[0] = '?'; uip_buf[1] = 'P'; uip_len = 2; - slip_send(); + slip_write(uip_buf, uip_len); uip_clear_buf(); } /*---------------------------------------------------------------------------*/ @@ -70,38 +70,44 @@ static void slip_input_callback(void) { LOG_DBG("SIN: %u\n", uip_len); - if(uip_buf[0] == '!') { - LOG_INFO("Got configuration message of type %c\n", uip_buf[1]); - uip_clear_buf(); - if(uip_buf[1] == 'P') { + if(uip_buf[UIP_LLH_LEN] == '!') { + LOG_INFO("Got configuration message of type %c\n", + uip_buf[UIP_LLH_LEN + 1]); + if(uip_buf[UIP_LLH_LEN + 1] == 'P') { uip_ipaddr_t prefix; /* Here we set a prefix !!! */ memset(&prefix, 0, 16); - memcpy(&prefix, &uip_buf[2], 8); + memcpy(&prefix, &uip_buf[UIP_LLH_LEN + 2], 8); + + uip_clear_buf(); + LOG_INFO("Setting prefix "); LOG_INFO_6ADDR(&prefix); LOG_INFO_("\n"); set_prefix_64(&prefix); } - } else if(uip_buf[0] == '?') { - LOG_INFO("Got request message of type %c\n", uip_buf[1]); - if(uip_buf[1] == 'M') { + uip_clear_buf(); + + } else if(uip_buf[UIP_LLH_LEN] == '?') { + LOG_INFO("Got request message of type %c\n", uip_buf[UIP_LLH_LEN + 1]); + if(uip_buf[UIP_LLH_LEN + 1] == 'M') { char *hexchar = "0123456789abcdef"; int j; /* this is just a test so far... just to see if it works */ uip_buf[0] = '!'; - for(j = 0; j < 8; j++) { + for(j = 0; j < UIP_LLADDR_LEN; j++) { uip_buf[2 + j * 2] = hexchar[uip_lladdr.addr[j] >> 4]; uip_buf[3 + j * 2] = hexchar[uip_lladdr.addr[j] & 15]; } uip_len = 18; - slip_send(); + slip_write(uip_buf, uip_len); } uip_clear_buf(); + } else { + /* Save the last sender received over SLIP to avoid bouncing the + packet back if no route is found */ + uip_ipaddr_copy(&last_sender, &UIP_IP_BUF->srcipaddr); } - /* Save the last sender received over SLIP to avoid bouncing the - packet back if no route is found */ - uip_ipaddr_copy(&last_sender, &UIP_IP_BUF->srcipaddr); } /*---------------------------------------------------------------------------*/ static void diff --git a/os/services/rpl-border-router/native/Makefile.native b/os/services/rpl-border-router/native/Makefile.native index a225e1666..3f758c1be 100644 --- a/os/services/rpl-border-router/native/Makefile.native +++ b/os/services/rpl-border-router/native/Makefile.native @@ -7,7 +7,7 @@ MAKE_NET = MAKE_NET_IPV6 PREFIX ?= fd00::1/64 connect-router: border-router.native - sudo ./border-router.native $(PREFIX) + sudo rlwrap ./border-router.native $(PREFIX) connect-router-cooja: border-router.native - sudo ./border-router.native -a localhost $(PREFIX) + sudo rlwrap ./border-router.native -a localhost $(PREFIX) diff --git a/os/services/rpl-border-router/native/border-router-cmds.c b/os/services/rpl-border-router/native/border-router-cmds.c index 9d0e2eb9f..aa0d44710 100644 --- a/os/services/rpl-border-router/native/border-router-cmds.c +++ b/os/services/rpl-border-router/native/border-router-cmds.c @@ -46,8 +46,11 @@ #include "shell.h" #include -#define DEBUG DEBUG_NONE -#include "net/ipv6/uip-debug.h" +/*---------------------------------------------------------------------------*/ +/* Log configuration */ +#include "sys/log.h" +#define LOG_MODULE "BR" +#define LOG_LEVEL LOG_LEVEL_NONE uint8_t command_context; @@ -115,7 +118,7 @@ border_router_cmd_handler(const uint8_t *data, int len) { /* handle global repair, etc here */ if(data[0] == '!') { - PRINTF("Got configuration message of type %c\n", data[1]); + LOG_DBG("Got configuration message of type %c\n", data[1]); if(command_context == CMD_CONTEXT_STDIO) { switch(data[1]) { case 'G': @@ -151,7 +154,7 @@ border_router_cmd_handler(const uint8_t *data, int len) /* We need to know that this is from the slip-radio here. */ switch(data[1]) { case 'M': - PRINTF("Setting MAC address\n"); + LOG_DBG("Setting MAC address\n"); border_router_set_mac(&data[2]); return 1; case 'V': @@ -163,7 +166,7 @@ border_router_cmd_handler(const uint8_t *data, int len) } return 1; case 'R': - PRINTF("Packet data report for sid:%d st:%d tx:%d\n", + LOG_DBG("Packet data report for sid:%d st:%d tx:%d\n", data[2], data[3], data[4]); packet_sent(data[2], data[3], data[4]); return 1; @@ -172,7 +175,7 @@ border_router_cmd_handler(const uint8_t *data, int len) } } } else if(data[0] == '?') { - PRINTF("Got request message of type %c\n", data[1]); + LOG_DBG("Got request message of type %c\n", data[1]); if(data[1] == 'M' && command_context == CMD_CONTEXT_STDIO) { uint8_t buf[20]; char *hexchar = "0123456789abcdef"; @@ -180,7 +183,7 @@ border_router_cmd_handler(const uint8_t *data, int len) /* this is just a test so far... just to see if it works */ buf[0] = '!'; buf[1] = 'M'; - for(j = 0; j < 8; j++) { + for(j = 0; j < UIP_LLADDR_LEN; j++) { buf[2 + j * 2] = hexchar[uip_lladdr.addr[j] >> 4]; buf[3 + j * 2] = hexchar[uip_lladdr.addr[j] & 15]; } @@ -226,15 +229,14 @@ PROCESS_THREAD(border_router_cmd_process, ev, data) { static struct pt shell_input_pt; PROCESS_BEGIN(); - PRINTF("Started br-cmd process\n"); shell_init(); while(1) { PROCESS_YIELD(); if(ev == serial_line_event_message && data != NULL) { - PRINTF("Got serial data!!! %s of len: %lu\n", - (char *)data, strlen((char *)data)); + LOG_DBG("Got serial data!!! %s of len: %u\n", + (char *)data, (unsigned)strlen((char *)data)); command_context = CMD_CONTEXT_STDIO; if(cmd_input(data, strlen((char *)data))) { /* Commnand executed - all is fine */ diff --git a/os/services/rpl-border-router/native/border-router-mac.c b/os/services/rpl-border-router/native/border-router-mac.c index bcfb829b7..83debbab6 100644 --- a/os/services/rpl-border-router/native/border-router-mac.c +++ b/os/services/rpl-border-router/native/border-router-mac.c @@ -44,13 +44,11 @@ #include "border-router.h" #include -#define DEBUG 0 -#if DEBUG -#include -#define PRINTF(...) printf(__VA_ARGS__) -#else -#define PRINTF(...) -#endif +/*---------------------------------------------------------------------------*/ +/* Log configuration */ +#include "sys/log.h" +#define LOG_MODULE "BR" +#define LOG_LEVEL LOG_LEVEL_NONE #define MAX_CALLBACKS 16 static int callback_pos; @@ -76,7 +74,7 @@ packet_sent(uint8_t sessionid, uint8_t status, uint8_t tx) packetbuf_attr_copyfrom(callback->attrs, callback->addrs); mac_call_sent_callback(callback->cback, callback->ptr, status, tx); } else { - PRINTF("*** ERROR: too high session id %d\n", sessionid); + LOG_ERR("Session id to high (%d)\n", sessionid); } } /*---------------------------------------------------------------------------*/ @@ -117,7 +115,7 @@ send_packet(mac_callback_t sent, void *ptr) if(NETSTACK_FRAMER.create() < 0) { /* Failed to allocate space for headers */ - PRINTF("br-rdc: send failed, too large header\n"); + LOG_WARN("br-rdc: send failed, too large header\n"); mac_call_sent_callback(sent, ptr, MAC_TX_ERR_FATAL, 1); } else { /* here we send the data over SLIP to the radio-chip */ @@ -126,7 +124,7 @@ send_packet(mac_callback_t sent, void *ptr) size = packetutils_serialize_atts(&buf[3], sizeof(buf) - 3); #endif if(size < 0 || size + packetbuf_totlen() + 3 > sizeof(buf)) { - PRINTF("br-rdc: send failed, too large header\n"); + LOG_WARN("br-rdc: send failed, too large header\n"); mac_call_sent_callback(sent, ptr, MAC_TX_ERR_FATAL, 1); } else { sid = setup_callback(sent, ptr); @@ -147,7 +145,7 @@ static void packet_input(void) { if(NETSTACK_FRAMER.parse() < 0) { - PRINTF("br-rdc: failed to parse %u\n", packetbuf_datalen()); + LOG_DBG("br-rdc: failed to parse %u\n", packetbuf_datalen()); } else { NETSTACK_NETWORK.input(); } diff --git a/os/services/rpl-border-router/native/border-router-native.c b/os/services/rpl-border-router/native/border-router-native.c index 3da0ef000..2adebe121 100644 --- a/os/services/rpl-border-router/native/border-router-native.c +++ b/os/services/rpl-border-router/native/border-router-native.c @@ -47,8 +47,11 @@ #include "border-router.h" #include "border-router-cmds.h" -#define DEBUG DEBUG_FULL -#include "net/ipv6/uip-debug.h" +/*---------------------------------------------------------------------------*/ +/* Log configuration */ +#include "sys/log.h" +#define LOG_MODULE "BR" +#define LOG_LEVEL LOG_LEVEL_INFO #include @@ -106,7 +109,7 @@ PROCESS_THREAD(border_router_process, ev, data) process_start(&border_router_cmd_process, NULL); - PRINTF("RPL-Border router started\n"); + LOG_INFO("RPL-Border router started\n"); slip_config_handle_arguments(contiki_argc, contiki_argv); @@ -123,12 +126,12 @@ PROCESS_THREAD(border_router_process, ev, data) uip_ipaddr_t prefix; if(uiplib_ipaddrconv((const char *)slip_config_ipaddr, &prefix)) { - PRINTF("Setting prefix "); - PRINT6ADDR(&prefix); - PRINTF("\n"); + LOG_INFO("Setting prefix "); + LOG_INFO_6ADDR(&prefix); + LOG_INFO_("\n"); set_prefix_64(&prefix); } else { - PRINTF("Parse error: %s\n", slip_config_ipaddr); + LOG_ERR("Parse error: %s\n", slip_config_ipaddr); exit(0); } } diff --git a/os/services/rpl-border-router/native/tun-bridge.c b/os/services/rpl-border-router/native/tun-bridge.c index a60819b26..f321577b3 100644 --- a/os/services/rpl-border-router/native/tun-bridge.c +++ b/os/services/rpl-border-router/native/tun-bridge.c @@ -50,8 +50,11 @@ #include #include -#define DEBUG DEBUG_FULL -#include "net/ipv6/uip-debug.h" +/*---------------------------------------------------------------------------*/ +/* Log configuration */ +#include "sys/log.h" +#define LOG_MODULE "BR" +#define LOG_LEVEL LOG_LEVEL_NONE #ifdef linux #include @@ -202,7 +205,7 @@ tun_init() slip_init(); - PRINTF("Opening tun interface:%s\n", slip_config_tundev); + LOG_INFO("Opening tun interface:%s\n", slip_config_tundev); tunfd = tun_alloc(slip_config_tundev); @@ -251,7 +254,7 @@ init(void) static int output(void) { - PRINTF("SUT: %u\n", uip_len); + LOG_DBG("SUT: %u\n", uip_len); if(uip_len > 0) { return tun_output(&uip_buf[UIP_LLH_LEN], uip_len); } diff --git a/os/services/shell/shell-commands.c b/os/services/shell/shell-commands.c index 46ee92fe5..3dbce09f2 100644 --- a/os/services/shell/shell-commands.c +++ b/os/services/shell/shell-commands.c @@ -173,8 +173,12 @@ PT_THREAD(cmd_rpl_status(struct pt *pt, shell_output_func output, char *args)) SHELL_OUTPUT(output, "-- State: %s\n", rpl_state_to_str(curr_instance.dag.state)); SHELL_OUTPUT(output, "-- Preferred parent: "); - shell_output_6addr(output, rpl_neighbor_get_ipaddr(curr_instance.dag.preferred_parent)); - SHELL_OUTPUT(output, "\n"); + if(curr_instance.dag.preferred_parent) { + shell_output_6addr(output, rpl_neighbor_get_ipaddr(curr_instance.dag.preferred_parent)); + SHELL_OUTPUT(output, " (last DTSN: %u)\n", curr_instance.dag.preferred_parent->dtsn); + } else { + SHELL_OUTPUT(output, "None\n"); + } SHELL_OUTPUT(output, "-- Rank: %u\n", curr_instance.dag.rank); SHELL_OUTPUT(output, "-- Lowest rank: %u (%u)\n", curr_instance.dag.lowest_rank, curr_instance.max_rankinc); SHELL_OUTPUT(output, "-- DTSN out: %u\n", curr_instance.dtsn_out); @@ -413,6 +417,7 @@ PT_THREAD(cmd_rpl_local_repair(struct pt *pt, shell_output_func output, char *ar PT_END(pt); } /*---------------------------------------------------------------------------*/ +#if ROUTING_CONF_RPL_LITE static PT_THREAD(cmd_rpl_refresh_routes(struct pt *pt, shell_output_func output, char *args)) { @@ -423,6 +428,7 @@ PT_THREAD(cmd_rpl_refresh_routes(struct pt *pt, shell_output_func output, char * PT_END(pt); } +#endif /* ROUTING_CONF_RPL_LITE */ #endif /* UIP_CONF_IPV6_RPL */ /*---------------------------------------------------------------------------*/ static @@ -732,7 +738,9 @@ struct shell_command_t shell_commands[] = { #if UIP_CONF_IPV6_RPL { "rpl-set-root", cmd_rpl_set_root, "'> rpl-set-root 0/1 [prefix]': Sets node as root (1) or not (0). A /64 prefix can be optionally specified." }, { "rpl-local-repair", cmd_rpl_local_repair, "'> rpl-local-repair': Triggers a RPL local repair" }, +#if ROUTING_CONF_RPL_LITE { "rpl-refresh-routes", cmd_rpl_refresh_routes, "'> rpl-refresh-routes': Refreshes all routes through a DTSN increment" }, +#endif /* ROUTING_CONF_RPL_LITE */ { "rpl-global-repair", cmd_rpl_global_repair, "'> rpl-global-repair': Triggers a RPL global repair" }, #endif /* UIP_CONF_IPV6_RPL */ #if ROUTING_CONF_RPL_LITE diff --git a/os/storage/antelope/db-options.h b/os/storage/antelope/db-options.h index f82c72edc..2be415f4e 100644 --- a/os/storage/antelope/db-options.h +++ b/os/storage/antelope/db-options.h @@ -38,6 +38,7 @@ #define DB_OPTIONS_H #include "contiki.h" +#include "cfs-coffee-arch.h" /*----------------------------------------------------------------------------*/ @@ -143,9 +144,17 @@ /* The default relation file size to reserve when using Coffee. */ #ifndef DB_COFFEE_RESERVE_SIZE -#define DB_COFFEE_RESERVE_SIZE (128 * 1024UL) +#define DB_COFFEE_RESERVE_SIZE (COFFEE_SIZE / 8) #endif /* DB_COFFEE_RESERVE_SIZE */ +/* + * Ensure that the default size of Coffee file reservations is suitable + * for the file system size. + */ +#if DB_COFFEE_RESERVE_SIZE > (COFFEE_SIZE / 2) +#error DB_COFFEE_RESERVE_SIZE is too large for the file system. +#endif + /* The maximum size of the physical storage of a tuple (labelled a "row" in Antelope's terminology. */ #ifndef DB_MAX_CHAR_SIZE_PER_ROW diff --git a/os/sys/log.c b/os/sys/log.c index 90709ec5f..05613e5c6 100644 --- a/os/sys/log.c +++ b/os/sys/log.c @@ -155,7 +155,11 @@ log_lladdr_compact(const linkaddr_t *lladdr) if(lladdr == NULL || linkaddr_cmp(lladdr, &linkaddr_null)) { LOG_OUTPUT("LL-NULL"); } else { +#if LINKADDR_SIZE == 8 LOG_OUTPUT("LL-%04x", UIP_HTONS(lladdr->u16[LINKADDR_SIZE/2-1])); +#elif LINKADDR_SIZE == 2 + LOG_OUTPUT("LL-%04x", UIP_HTONS(lladdr->u16)); +#endif } } /*---------------------------------------------------------------------------*/ diff --git a/os/sys/rtimer.h b/os/sys/rtimer.h index 95d11c33d..44ad92a2f 100644 --- a/os/sys/rtimer.h +++ b/os/sys/rtimer.h @@ -55,11 +55,34 @@ #include "contiki.h" -#ifndef RTIMER_CLOCK_DIFF -typedef unsigned short rtimer_clock_t; -#define RTIMER_CLOCK_DIFF(a,b) ((signed short)((a)-(b))) -#endif /* RTIMER_CLOCK_DIFF */ +/** \brief The rtimer size (in bytes) */ +#ifdef RTIMER_CONF_CLOCK_SIZE +#define RTIMER_CLOCK_SIZE RTIMER_CONF_CLOCK_SIZE +#else /* RTIMER_CONF_CLOCK_SIZE */ +/* Default: 32bit rtimer*/ +#define RTIMER_CLOCK_SIZE 4 +#endif /* RTIMER_CONF_CLOCK_SIZE */ +#if RTIMER_CLOCK_SIZE == 2 +/* 16-bit rtimer */ +typedef uint16_t rtimer_clock_t; +#define RTIMER_CLOCK_DIFF(a,b) ((int16_t)((a)-(b))) + +#elif RTIMER_CLOCK_SIZE == 4 +/* 32-bit rtimer */ +typedef uint32_t rtimer_clock_t; +#define RTIMER_CLOCK_DIFF(a, b) ((int32_t)((a) - (b))) + +#elif RTIMER_CLOCK_SIZE == 8 +/* 64-bit rtimer */ +typedef uint64_t rtimer_clock_t; +#define RTIMER_CLOCK_DIFF(a,b) ((int64_t)((a)-(b))) + +#else +#error Unsupported rtimer size (check RTIMER_CLOCK_SIZE) +#endif + +#define RTIMER_CLOCK_MAX ((rtimer_clock_t)-1) #define RTIMER_CLOCK_LT(a, b) (RTIMER_CLOCK_DIFF((a),(b)) < 0) #include "rtimer-arch.h" diff --git a/os/sys/stack-check.h b/os/sys/stack-check.h index a9068f216..805c4b7da 100644 --- a/os/sys/stack-check.h +++ b/os/sys/stack-check.h @@ -45,7 +45,6 @@ * On startup, fills the area between the stack and the heap with a known pattern. * During execution, the fill can be checked in order to find out * the extent to which the stack has been used. - * * * @{ */ diff --git a/tests/01-compile-base/Makefile b/tests/01-compile-base/Makefile index 0c7e248e0..eae930138 100644 --- a/tests/01-compile-base/Makefile +++ b/tests/01-compile-base/Makefile @@ -7,21 +7,25 @@ hello-world/native:MAKE_NET=MAKE_NET_NULLNET \ hello-world/native:MAKE_ROUTING=MAKE_ROUTING_RPL_CLASSIC \ hello-world/sky \ storage/eeprom-test/native \ -multicast/sky \ libs/logging/native \ libs/energest/native \ libs/energest/sky \ libs/data-structures/native \ libs/data-structures/sky \ libs/stack-check/sky \ -ipso-objects/native \ -ipso-objects/native:MAKE_WITH_DTLS=1 \ +lwm2m-ipso-objects/native \ +lwm2m-ipso-objects/native:MAKE_WITH_DTLS=1 \ rpl-udp/sky \ rpl-border-router/native \ +rpl-border-router/native:MAKE_ROUTING=MAKE_ROUTING_RPL_CLASSIC \ rpl-border-router/sky \ slip-radio/sky \ -ipv6-hooks/sky \ +libs/ipv6-hooks/sky \ nullnet/native \ +mqtt-client/native \ +coap/coap-example-client/native \ +coap/coap-example-server/native \ +coap/coap-plugtest-server/native \ TOOLS= diff --git a/tests/02-compile-arm-ports-01/Makefile b/tests/02-compile-arm-ports-01/Makefile index 51b232173..5e73c4ecb 100644 --- a/tests/02-compile-arm-ports-01/Makefile +++ b/tests/02-compile-arm-ports-01/Makefile @@ -3,6 +3,7 @@ TOOLSDIR=../../tools EXAMPLES = \ platform-specific/cc26xx/cc26xx-web-demo/srf06-cc26xx \ +platform-specific/cc26xx/cc26xx-web-demo/srf06-cc26xx:MAKE_ROUTING=MAKE_ROUTING_RPL_CLASSIC \ platform-specific/cc26xx/very-sleepy-demo/srf06-cc26xx:BOARD=sensortag/cc2650 \ platform-specific/cc26xx/cc26xx-web-demo/srf06-cc26xx:BOARD=sensortag/cc2650 \ platform-specific/cc26xx/cc26xx-web-demo/srf06-cc26xx:BOARD=sensortag/cc1350 \ @@ -38,9 +39,10 @@ mqtt-client/cc2538dk \ storage/cfs-coffee/cc2538dk \ sensniff/cc2538dk \ rpl-udp/cc2538dk \ -coap/cc2538dk \ +coap/coap-example-client/cc2538dk \ +coap/coap-example-server/cc2538dk \ slip-radio/cc2538dk \ -ipso-objects/cc2538dk \ +lwm2m-ipso-objects/cc2538dk \ multicast/cc2538dk \ dev/gpio-hal/cc2538dk \ dev/leds/cc2538dk \ diff --git a/tests/03-compile-arm-ports-02/Makefile b/tests/03-compile-arm-ports-02/Makefile index a69ec44a0..db016afaa 100644 --- a/tests/03-compile-arm-ports-02/Makefile +++ b/tests/03-compile-arm-ports-02/Makefile @@ -12,10 +12,11 @@ platform-specific/zoul/rev-b/zoul:BOARD=remote-revb \ platform-specific/zoul/at-test/zoul \ platform-specific/zoul/rtcc/zoul \ platform-specific/zoul/zoul \ -coap/zoul \ +coap/coap-example-client/zoul \ +coap/coap-example-server/zoul \ multicast/zoul \ -ipso-objects/zoul \ -ipso-objects/zoul:MAKE_WITH_DTLS=1 \ +lwm2m-ipso-objects/zoul \ +lwm2m-ipso-objects/zoul:MAKE_WITH_DTLS=1 \ hello-world/zoul \ sensniff/zoul \ sensniff/zoul:ZOUL_CONF_SUB_GHZ_SNIFFER=1 \ @@ -28,7 +29,7 @@ libs/logging/zoul \ 6tisch/etsi-plugtest-2017/zoul:BOARD=remote \ 6tisch/6p-packet/zoul \ 6tisch/sixtop/zoul \ -http-socket/zoul \ +websocket/zoul \ libs/timers/zoul \ libs/energest/zoul \ libs/trickle-library/zoul \ @@ -59,7 +60,7 @@ rpl-udp/openmote-cc2538 \ dev/gpio-hal/openmote-cc2538 \ dev/leds/openmote-cc2538 \ rpl-border-router/openmote-cc2538 \ -ipv6-hooks/openmote-cc2538 \ +libs/ipv6-hooks/openmote-cc2538 \ TOOLS= diff --git a/tests/04-compile-nxp-ports/Makefile b/tests/04-compile-nxp-ports/Makefile index cec1f91af..214bced26 100644 --- a/tests/04-compile-nxp-ports/Makefile +++ b/tests/04-compile-nxp-ports/Makefile @@ -12,6 +12,8 @@ platform-specific/jn516x/rpl/coap-dr1199-node/jn516x \ platform-specific/jn516x/tsch/simple-sensor-network/node/jn516x \ platform-specific/jn516x/tsch/tx-power-verification/node/jn516x \ platform-specific/jn516x/tsch/uart1-test-node/jn516x \ +coap/coap-example-client/jn516x \ +coap/coap-example-server/jn516x \ sensniff/jn516x \ rpl-border-router/jn516x \ 6tisch/simple-node/jn516x \ diff --git a/tests/07-simulation-base/code-ringbufindex/project-conf.h b/tests/07-simulation-base/code-ringbufindex/project-conf.h index a7683dbb5..e745536d9 100644 --- a/tests/07-simulation-base/code-ringbufindex/project-conf.h +++ b/tests/07-simulation-base/code-ringbufindex/project-conf.h @@ -29,9 +29,9 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _PROJECT_CONF_H_ -#define _PROJECT_CONF_H_ +#ifndef PROJECT_CONF_H_ +#define PROJECT_CONF_H_ #define UNIT_TEST_PRINT_FUNCTION test_print_report -#endif /* !_PROJECT_CONF_H_ */ +#endif /* !PROJECT_CONF_H_ */ diff --git a/tests/07-simulation-base/code-slip-radio/project-conf.h b/tests/07-simulation-base/code-slip-radio/project-conf.h index 616601c1c..e8af03208 100644 --- a/tests/07-simulation-base/code-slip-radio/project-conf.h +++ b/tests/07-simulation-base/code-slip-radio/project-conf.h @@ -1,6 +1,6 @@ -#ifndef __PROJECT_CONF_H__ -#define __PROJECT_CONF_H__ +#ifndef PROJECT_CONF_H_ +#define PROJECT_CONF_H_ #define RPL_CONF_DAO_ACK 1 -#endif /* __PROJECT_CONF_H__ */ +#endif /* PROJECT_CONF_H_ */ diff --git a/tests/07-simulation-base/js/04-ringbufindex.js b/tests/07-simulation-base/js/04-ringbufindex.js index 153f920af..5acb27f11 100644 --- a/tests/07-simulation-base/js/04-ringbufindex.js +++ b/tests/07-simulation-base/js/04-ringbufindex.js @@ -6,7 +6,7 @@ while(true) { YIELD(); log.log(time + " " + "node-" + id + " "+ msg + "\n"); - + if(msg.contains("=check-me=") == false) { continue; } @@ -23,4 +23,3 @@ if(failed) { log.testFailed(); } log.testOK(); - diff --git a/tests/07-simulation-base/js/22-stack-check.js b/tests/07-simulation-base/js/22-stack-check.js index c6915cc66..3dd0b381c 100644 --- a/tests/07-simulation-base/js/22-stack-check.js +++ b/tests/07-simulation-base/js/22-stack-check.js @@ -11,12 +11,12 @@ while(true) { log.log("> " + msg + "\n"); var found = msg.match(re); - + if(found) { var n = parseInt(found[1]); minusage = minusage < n ? minusage : n; maxusage = maxusage > n ? maxusage : n; - + if(minusage < 800 && maxusage >= 1000) { log.testOK(); } diff --git a/tests/09-ipv6/01-ping-lla-csma-w-rpl.csc b/tests/09-ipv6/01-ping-lla-csma-w-rpl.csc new file mode 100644 index 000000000..0a6e3a376 --- /dev/null +++ b/tests/09-ipv6/01-ping-lla-csma-w-rpl.csc @@ -0,0 +1,108 @@ + + + [APPS_DIR]/mrm + [APPS_DIR]/mspsim + [APPS_DIR]/avrora + [APPS_DIR]/serial_socket + [APPS_DIR]/powertracker + + My simulation + 1.0 + 123456 + 1000000 + + org.contikios.cooja.radiomediums.UDGM + 50.0 + 100.0 + 1.0 + 1.0 + + + 40000 + + + org.contikios.cooja.contikimote.ContikiMoteType + mtype787 + Cooja Mote Type #1 + [CONTIKI_DIR]/tests/09-ipv6/code/node.c + make clean + make WITH_CSMA=1 node.cooja + org.contikios.cooja.interfaces.Position + org.contikios.cooja.interfaces.Battery + org.contikios.cooja.contikimote.interfaces.ContikiVib + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + org.contikios.cooja.contikimote.interfaces.ContikiRS232 + org.contikios.cooja.contikimote.interfaces.ContikiBeeper + org.contikios.cooja.interfaces.RimeAddress + org.contikios.cooja.contikimote.interfaces.ContikiIPAddress + org.contikios.cooja.contikimote.interfaces.ContikiRadio + org.contikios.cooja.contikimote.interfaces.ContikiButton + org.contikios.cooja.contikimote.interfaces.ContikiPIR + org.contikios.cooja.contikimote.interfaces.ContikiClock + org.contikios.cooja.contikimote.interfaces.ContikiLED + org.contikios.cooja.contikimote.interfaces.ContikiCFS + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + org.contikios.cooja.interfaces.Mote2MoteRelations + org.contikios.cooja.interfaces.MoteAttributes + false + + + + org.contikios.cooja.interfaces.Position + 14.03051207883138 + 82.02801380504546 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 1 + + + org.contikios.cooja.contikimote.interfaces.ContikiRS232 + ip-nbr~;ping fe80::202:2:2:2~;ip-nbr~;help~;je;p~;ping da~;ping~;help~; + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== + + mtype787 + + + + org.contikios.cooja.interfaces.Position + 28.22612889898729 + 43.60027658221718 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 2 + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== + + mtype787 + + + + org.contikios.cooja.plugins.ScriptRunner + + [CONTIKI_DIR]/tests/09-ipv6/js/ping-test-lla.js + true + + 495 + 0 + 525 + 190 + 18 + + diff --git a/tests/09-ipv6/02-ping-ula-csma-w-rpl.csc b/tests/09-ipv6/02-ping-ula-csma-w-rpl.csc new file mode 100644 index 000000000..802f068cc --- /dev/null +++ b/tests/09-ipv6/02-ping-ula-csma-w-rpl.csc @@ -0,0 +1,108 @@ + + + [APPS_DIR]/mrm + [APPS_DIR]/mspsim + [APPS_DIR]/avrora + [APPS_DIR]/serial_socket + [APPS_DIR]/powertracker + + My simulation + 1.0 + 123456 + 1000000 + + org.contikios.cooja.radiomediums.UDGM + 50.0 + 100.0 + 1.0 + 1.0 + + + 40000 + + + org.contikios.cooja.contikimote.ContikiMoteType + mtype787 + Cooja Mote Type #1 + [CONTIKI_DIR]/tests/09-ipv6/code/node.c + make clean + make WITH_ULA=1 WITH_CSMA=1 node.cooja + org.contikios.cooja.interfaces.Position + org.contikios.cooja.interfaces.Battery + org.contikios.cooja.contikimote.interfaces.ContikiVib + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + org.contikios.cooja.contikimote.interfaces.ContikiRS232 + org.contikios.cooja.contikimote.interfaces.ContikiBeeper + org.contikios.cooja.interfaces.RimeAddress + org.contikios.cooja.contikimote.interfaces.ContikiIPAddress + org.contikios.cooja.contikimote.interfaces.ContikiRadio + org.contikios.cooja.contikimote.interfaces.ContikiButton + org.contikios.cooja.contikimote.interfaces.ContikiPIR + org.contikios.cooja.contikimote.interfaces.ContikiClock + org.contikios.cooja.contikimote.interfaces.ContikiLED + org.contikios.cooja.contikimote.interfaces.ContikiCFS + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + org.contikios.cooja.interfaces.Mote2MoteRelations + org.contikios.cooja.interfaces.MoteAttributes + false + + + + org.contikios.cooja.interfaces.Position + 14.03051207883138 + 82.02801380504546 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 1 + + + org.contikios.cooja.contikimote.interfaces.ContikiRS232 + ip-nbr~;ping fe80::202:2:2:2~;ip-nbr~;help~;je;p~;ping da~;ping~;help~; + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== + + mtype787 + + + + org.contikios.cooja.interfaces.Position + 28.22612889898729 + 43.60027658221718 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 2 + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== + + mtype787 + + + + org.contikios.cooja.plugins.ScriptRunner + + [CONTIKI_DIR]/tests/09-ipv6/js/ping-test-ula.js + true + + 495 + 0 + 525 + 190 + 18 + + diff --git a/tests/09-ipv6/03-ping-lla-tsch-w-rpl.csc b/tests/09-ipv6/03-ping-lla-tsch-w-rpl.csc new file mode 100644 index 000000000..2642f363d --- /dev/null +++ b/tests/09-ipv6/03-ping-lla-tsch-w-rpl.csc @@ -0,0 +1,108 @@ + + + [APPS_DIR]/mrm + [APPS_DIR]/mspsim + [APPS_DIR]/avrora + [APPS_DIR]/serial_socket + [APPS_DIR]/powertracker + + My simulation + 1.0 + 123456 + 1000000 + + org.contikios.cooja.radiomediums.UDGM + 50.0 + 100.0 + 1.0 + 1.0 + + + 40000 + + + org.contikios.cooja.contikimote.ContikiMoteType + mtype787 + Cooja Mote Type #1 + [CONTIKI_DIR]/tests/09-ipv6/code/node.c + make clean + make WITH_TSCH=1 node.cooja + org.contikios.cooja.interfaces.Position + org.contikios.cooja.interfaces.Battery + org.contikios.cooja.contikimote.interfaces.ContikiVib + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + org.contikios.cooja.contikimote.interfaces.ContikiRS232 + org.contikios.cooja.contikimote.interfaces.ContikiBeeper + org.contikios.cooja.interfaces.RimeAddress + org.contikios.cooja.contikimote.interfaces.ContikiIPAddress + org.contikios.cooja.contikimote.interfaces.ContikiRadio + org.contikios.cooja.contikimote.interfaces.ContikiButton + org.contikios.cooja.contikimote.interfaces.ContikiPIR + org.contikios.cooja.contikimote.interfaces.ContikiClock + org.contikios.cooja.contikimote.interfaces.ContikiLED + org.contikios.cooja.contikimote.interfaces.ContikiCFS + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + org.contikios.cooja.interfaces.Mote2MoteRelations + org.contikios.cooja.interfaces.MoteAttributes + false + + + + org.contikios.cooja.interfaces.Position + 14.03051207883138 + 82.02801380504546 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 1 + + + org.contikios.cooja.contikimote.interfaces.ContikiRS232 + ip-nbr~;ping fe80::202:2:2:2~;ip-nbr~;help~;je;p~;ping da~;ping~;help~; + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== + + mtype787 + + + + org.contikios.cooja.interfaces.Position + 28.22612889898729 + 43.60027658221718 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 2 + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== + + mtype787 + + + + org.contikios.cooja.plugins.ScriptRunner + + [CONTIKI_DIR]/tests/09-ipv6/js/ping-test-lla.js + true + + 495 + 0 + 525 + 190 + 18 + + diff --git a/tests/09-ipv6/04-ping-ula-tsch-w-rpl.csc b/tests/09-ipv6/04-ping-ula-tsch-w-rpl.csc new file mode 100644 index 000000000..c18f8ac0b --- /dev/null +++ b/tests/09-ipv6/04-ping-ula-tsch-w-rpl.csc @@ -0,0 +1,108 @@ + + + [APPS_DIR]/mrm + [APPS_DIR]/mspsim + [APPS_DIR]/avrora + [APPS_DIR]/serial_socket + [APPS_DIR]/powertracker + + My simulation + 1.0 + 123456 + 1000000 + + org.contikios.cooja.radiomediums.UDGM + 50.0 + 100.0 + 1.0 + 1.0 + + + 40000 + + + org.contikios.cooja.contikimote.ContikiMoteType + mtype787 + Cooja Mote Type #1 + [CONTIKI_DIR]/tests/09-ipv6/code/node.c + make clean + make WITH_ULA=1 WITH_TSCH=1 node.cooja + org.contikios.cooja.interfaces.Position + org.contikios.cooja.interfaces.Battery + org.contikios.cooja.contikimote.interfaces.ContikiVib + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + org.contikios.cooja.contikimote.interfaces.ContikiRS232 + org.contikios.cooja.contikimote.interfaces.ContikiBeeper + org.contikios.cooja.interfaces.RimeAddress + org.contikios.cooja.contikimote.interfaces.ContikiIPAddress + org.contikios.cooja.contikimote.interfaces.ContikiRadio + org.contikios.cooja.contikimote.interfaces.ContikiButton + org.contikios.cooja.contikimote.interfaces.ContikiPIR + org.contikios.cooja.contikimote.interfaces.ContikiClock + org.contikios.cooja.contikimote.interfaces.ContikiLED + org.contikios.cooja.contikimote.interfaces.ContikiCFS + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + org.contikios.cooja.interfaces.Mote2MoteRelations + org.contikios.cooja.interfaces.MoteAttributes + false + + + + org.contikios.cooja.interfaces.Position + 14.03051207883138 + 82.02801380504546 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 1 + + + org.contikios.cooja.contikimote.interfaces.ContikiRS232 + ip-nbr~;ping fe80::202:2:2:2~;ip-nbr~;help~;je;p~;ping da~;ping~;help~; + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== + + mtype787 + + + + org.contikios.cooja.interfaces.Position + 28.22612889898729 + 43.60027658221718 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 2 + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== + + mtype787 + + + + org.contikios.cooja.plugins.ScriptRunner + + [CONTIKI_DIR]/tests/09-ipv6/js/ping-test-ula.js + true + + 495 + 0 + 525 + 190 + 18 + + diff --git a/tests/09-ipv6/05-ping-lla-csma-wo-rpl.csc b/tests/09-ipv6/05-ping-lla-csma-wo-rpl.csc new file mode 100644 index 000000000..9b3d1c50f --- /dev/null +++ b/tests/09-ipv6/05-ping-lla-csma-wo-rpl.csc @@ -0,0 +1,108 @@ + + + [APPS_DIR]/mrm + [APPS_DIR]/mspsim + [APPS_DIR]/avrora + [APPS_DIR]/serial_socket + [APPS_DIR]/powertracker + + My simulation + 1.0 + 123456 + 1000000 + + org.contikios.cooja.radiomediums.UDGM + 50.0 + 100.0 + 1.0 + 1.0 + + + 40000 + + + org.contikios.cooja.contikimote.ContikiMoteType + mtype787 + Cooja Mote Type #1 + [CONTIKI_DIR]/tests/09-ipv6/code/node.c + make clean + make WITH_CSMA=1 WITHOUT_RPL=1 node.cooja + org.contikios.cooja.interfaces.Position + org.contikios.cooja.interfaces.Battery + org.contikios.cooja.contikimote.interfaces.ContikiVib + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + org.contikios.cooja.contikimote.interfaces.ContikiRS232 + org.contikios.cooja.contikimote.interfaces.ContikiBeeper + org.contikios.cooja.interfaces.RimeAddress + org.contikios.cooja.contikimote.interfaces.ContikiIPAddress + org.contikios.cooja.contikimote.interfaces.ContikiRadio + org.contikios.cooja.contikimote.interfaces.ContikiButton + org.contikios.cooja.contikimote.interfaces.ContikiPIR + org.contikios.cooja.contikimote.interfaces.ContikiClock + org.contikios.cooja.contikimote.interfaces.ContikiLED + org.contikios.cooja.contikimote.interfaces.ContikiCFS + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + org.contikios.cooja.interfaces.Mote2MoteRelations + org.contikios.cooja.interfaces.MoteAttributes + false + + + + org.contikios.cooja.interfaces.Position + 14.03051207883138 + 82.02801380504546 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 1 + + + org.contikios.cooja.contikimote.interfaces.ContikiRS232 + ip-nbr~;ping fe80::202:2:2:2~;ip-nbr~;help~;je;p~;ping da~;ping~;help~; + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== + + mtype787 + + + + org.contikios.cooja.interfaces.Position + 28.22612889898729 + 43.60027658221718 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 2 + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== + + mtype787 + + + + org.contikios.cooja.plugins.ScriptRunner + + [CONTIKI_DIR]/tests/09-ipv6/js/ping-test-lla.js + true + + 495 + 0 + 525 + 190 + 18 + + diff --git a/tests/09-ipv6/06-ping-ula-csma-wo-rpl.csc b/tests/09-ipv6/06-ping-ula-csma-wo-rpl.csc new file mode 100644 index 000000000..3640cbb1f --- /dev/null +++ b/tests/09-ipv6/06-ping-ula-csma-wo-rpl.csc @@ -0,0 +1,108 @@ + + + [APPS_DIR]/mrm + [APPS_DIR]/mspsim + [APPS_DIR]/avrora + [APPS_DIR]/serial_socket + [APPS_DIR]/powertracker + + My simulation + 1.0 + 123456 + 1000000 + + org.contikios.cooja.radiomediums.UDGM + 50.0 + 100.0 + 1.0 + 1.0 + + + 40000 + + + org.contikios.cooja.contikimote.ContikiMoteType + mtype787 + Cooja Mote Type #1 + [CONTIKI_DIR]/tests/09-ipv6/code/node.c + make clean + make WITH_ULA=1 WITH_CSMA=1 WITHOUT_RPL=1 node.cooja + org.contikios.cooja.interfaces.Position + org.contikios.cooja.interfaces.Battery + org.contikios.cooja.contikimote.interfaces.ContikiVib + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + org.contikios.cooja.contikimote.interfaces.ContikiRS232 + org.contikios.cooja.contikimote.interfaces.ContikiBeeper + org.contikios.cooja.interfaces.RimeAddress + org.contikios.cooja.contikimote.interfaces.ContikiIPAddress + org.contikios.cooja.contikimote.interfaces.ContikiRadio + org.contikios.cooja.contikimote.interfaces.ContikiButton + org.contikios.cooja.contikimote.interfaces.ContikiPIR + org.contikios.cooja.contikimote.interfaces.ContikiClock + org.contikios.cooja.contikimote.interfaces.ContikiLED + org.contikios.cooja.contikimote.interfaces.ContikiCFS + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + org.contikios.cooja.interfaces.Mote2MoteRelations + org.contikios.cooja.interfaces.MoteAttributes + false + + + + org.contikios.cooja.interfaces.Position + 14.03051207883138 + 82.02801380504546 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 1 + + + org.contikios.cooja.contikimote.interfaces.ContikiRS232 + ip-nbr~;ping fe80::202:2:2:2~;ip-nbr~;help~;je;p~;ping da~;ping~;help~; + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== + + mtype787 + + + + org.contikios.cooja.interfaces.Position + 28.22612889898729 + 43.60027658221718 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 2 + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== + + mtype787 + + + + org.contikios.cooja.plugins.ScriptRunner + + [CONTIKI_DIR]/tests/09-ipv6/js/ping-test-ula.js + true + + 495 + 0 + 525 + 190 + 18 + + diff --git a/tests/09-ipv6/07-ping-lla-tsch-wo-rpl.csc b/tests/09-ipv6/07-ping-lla-tsch-wo-rpl.csc new file mode 100644 index 000000000..2960bacaf --- /dev/null +++ b/tests/09-ipv6/07-ping-lla-tsch-wo-rpl.csc @@ -0,0 +1,108 @@ + + + [APPS_DIR]/mrm + [APPS_DIR]/mspsim + [APPS_DIR]/avrora + [APPS_DIR]/serial_socket + [APPS_DIR]/powertracker + + My simulation + 1.0 + 123456 + 1000000 + + org.contikios.cooja.radiomediums.UDGM + 50.0 + 100.0 + 1.0 + 1.0 + + + 40000 + + + org.contikios.cooja.contikimote.ContikiMoteType + mtype787 + Cooja Mote Type #1 + [CONTIKI_DIR]/tests/09-ipv6/code/node.c + make clean + make WITH_TSCH=1 WITHOUT_RPL=1 node.cooja + org.contikios.cooja.interfaces.Position + org.contikios.cooja.interfaces.Battery + org.contikios.cooja.contikimote.interfaces.ContikiVib + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + org.contikios.cooja.contikimote.interfaces.ContikiRS232 + org.contikios.cooja.contikimote.interfaces.ContikiBeeper + org.contikios.cooja.interfaces.RimeAddress + org.contikios.cooja.contikimote.interfaces.ContikiIPAddress + org.contikios.cooja.contikimote.interfaces.ContikiRadio + org.contikios.cooja.contikimote.interfaces.ContikiButton + org.contikios.cooja.contikimote.interfaces.ContikiPIR + org.contikios.cooja.contikimote.interfaces.ContikiClock + org.contikios.cooja.contikimote.interfaces.ContikiLED + org.contikios.cooja.contikimote.interfaces.ContikiCFS + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + org.contikios.cooja.interfaces.Mote2MoteRelations + org.contikios.cooja.interfaces.MoteAttributes + false + + + + org.contikios.cooja.interfaces.Position + 14.03051207883138 + 82.02801380504546 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 1 + + + org.contikios.cooja.contikimote.interfaces.ContikiRS232 + ip-nbr~;ping fe80::202:2:2:2~;ip-nbr~;help~;je;p~;ping da~;ping~;help~; + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== + + mtype787 + + + + org.contikios.cooja.interfaces.Position + 28.22612889898729 + 43.60027658221718 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 2 + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== + + mtype787 + + + + org.contikios.cooja.plugins.ScriptRunner + + [CONTIKI_DIR]/tests/09-ipv6/js/ping-test-lla.js + true + + 495 + 0 + 525 + 190 + 18 + + diff --git a/tests/09-ipv6/08-ping-ula-tsch-wo-rpl.csc b/tests/09-ipv6/08-ping-ula-tsch-wo-rpl.csc new file mode 100644 index 000000000..73953b0b3 --- /dev/null +++ b/tests/09-ipv6/08-ping-ula-tsch-wo-rpl.csc @@ -0,0 +1,108 @@ + + + [APPS_DIR]/mrm + [APPS_DIR]/mspsim + [APPS_DIR]/avrora + [APPS_DIR]/serial_socket + [APPS_DIR]/powertracker + + My simulation + 1.0 + 123456 + 1000000 + + org.contikios.cooja.radiomediums.UDGM + 50.0 + 100.0 + 1.0 + 1.0 + + + 40000 + + + org.contikios.cooja.contikimote.ContikiMoteType + mtype787 + Cooja Mote Type #1 + [CONTIKI_DIR]/tests/09-ipv6/code/node.c + make clean + make WITH_ULA=1 WITH_TSCH=1 WITHOUT_RPL=1 node.cooja + org.contikios.cooja.interfaces.Position + org.contikios.cooja.interfaces.Battery + org.contikios.cooja.contikimote.interfaces.ContikiVib + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + org.contikios.cooja.contikimote.interfaces.ContikiRS232 + org.contikios.cooja.contikimote.interfaces.ContikiBeeper + org.contikios.cooja.interfaces.RimeAddress + org.contikios.cooja.contikimote.interfaces.ContikiIPAddress + org.contikios.cooja.contikimote.interfaces.ContikiRadio + org.contikios.cooja.contikimote.interfaces.ContikiButton + org.contikios.cooja.contikimote.interfaces.ContikiPIR + org.contikios.cooja.contikimote.interfaces.ContikiClock + org.contikios.cooja.contikimote.interfaces.ContikiLED + org.contikios.cooja.contikimote.interfaces.ContikiCFS + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + org.contikios.cooja.interfaces.Mote2MoteRelations + org.contikios.cooja.interfaces.MoteAttributes + false + + + + org.contikios.cooja.interfaces.Position + 14.03051207883138 + 82.02801380504546 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 1 + + + org.contikios.cooja.contikimote.interfaces.ContikiRS232 + ip-nbr~;ping fe80::202:2:2:2~;ip-nbr~;help~;je;p~;ping da~;ping~;help~; + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== + + mtype787 + + + + org.contikios.cooja.interfaces.Position + 28.22612889898729 + 43.60027658221718 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 2 + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== + + mtype787 + + + + org.contikios.cooja.plugins.ScriptRunner + + [CONTIKI_DIR]/tests/09-ipv6/js/ping-test-ula.js + true + + 495 + 0 + 525 + 190 + 18 + + diff --git a/tests/09-ipv6/Makefile b/tests/09-ipv6/Makefile new file mode 100644 index 000000000..272bc7da1 --- /dev/null +++ b/tests/09-ipv6/Makefile @@ -0,0 +1 @@ +include ../Makefile.simulation-test diff --git a/tests/09-ipv6/code/Makefile b/tests/09-ipv6/code/Makefile new file mode 100644 index 000000000..2c910f1cd --- /dev/null +++ b/tests/09-ipv6/code/Makefile @@ -0,0 +1,35 @@ +CONTIKI_PRJECT = node +all: $(CONTIKI_PROJECT) + +MODULES += os/services/shell +CFLAGS += -DLOG_CONF_LEVEL_RPL=LOG_LEVEL_INFO +CFLAGS += -DLOG_CONF_LEVEL_TCPIP=LOG_LEVEL_INFO +CFLAGS += -DLOG_CONF_LEVEL_IPV6=LOG_LEVEL_DBG +CFLAGS += -DLOG_CONF_LEVEL_MAC=LOG_LEVEL_INFO + +ifeq ($(WITH_ULA),1) + CFLAGS += -DWITH_ULA=1 +endif + +ifeq ($(WITHOUT_RPL),1) + MAKE_ROUTING = MAKE_ROUTING_NULLROUTING +else + CFLAGS += -DRPL_CONF_DAO_DELAY=1 +endif + +ifeq ($WITH_CSMA),1) + MAKE_MAC = MAKE_MAC_CSMA +endif + +ifeq ($(WITH_TSCH),1) + MAKE_MAC = MAKE_MAC_TSCH + CFLAGS += -DWITH_TSCH=1 + CFLAGS += -DTSCH_CONF_AUTOSTART=1 + CFLAGS += -DTSCH_CONF_DEFAULT_HOPPING_SEQUENCE=TSCH_HOPPING_SEQUENCE_1_1 +endif + +PLATFORM_ONLY = cooja +TARGET = cooja + +CONTIKI = ../../../ +include $(CONTIKI)/Makefile.include diff --git a/tests/09-ipv6/code/node.c b/tests/09-ipv6/code/node.c new file mode 100644 index 000000000..f465e2642 --- /dev/null +++ b/tests/09-ipv6/code/node.c @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2016, Yasuyuki Tanaka + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include + +#include + +PROCESS(node_process, "Node"); +AUTOSTART_PROCESSES(&node_process); + +PROCESS_THREAD(node_process, ev, data) +{ + static struct etimer et; +#if WITH_ULA + static uip_ipaddr_t ipaddr; +#endif /* WITH_ULA */ + +#if WITH_TSCH + static linkaddr_t coordinator_addr = {{0x00, 0x01, 0x00, 0x01, + 0x00, 0x01, 0x00, 0x01}}; +#endif /* WITH_TSCH */ + + PROCESS_BEGIN(); + +#if WITH_TSCH + if(linkaddr_cmp(&coordinator_addr, &linkaddr_node_addr)) { + tsch_set_coordinator(1); + } +#endif /* WITH_TSCH */ + +#if WITH_ULA + uip_ip6addr(&ipaddr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0); + uip_ds6_prefix_add(&ipaddr, UIP_DEFAULT_PREFIX_LEN, 0, 0, 0, 0); + uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr); + uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF); +#endif /* WITH_ULA */ + + serial_shell_init(); + + etimer_set(&et, CLOCK_SECOND); + while(1) { + /* + * keep doing something so that simulation runs until its timeout + */ + PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et)); + printf(".\n"); + etimer_reset(&et); + } + + PROCESS_END(); +} diff --git a/tests/09-ipv6/js/ping-test-lla.js b/tests/09-ipv6/js/ping-test-lla.js new file mode 100644 index 000000000..1823d87b2 --- /dev/null +++ b/tests/09-ipv6/js/ping-test-lla.js @@ -0,0 +1,45 @@ +TIMEOUT(20000, log.testFailed()); + +dst_lla = "fe80::202:2:2:2"; +dst_mac = "0002.0002.0002.0002"; +step = 0; + +while(1) { + YIELD(); + log.log(time + " " + id + " "+ msg + "\n"); + + if(msg.contains("Node id is set to")) { + if(id == 1) { + write(sim.getMoteWithID(1), "rpl-set-root 1"); + } + step += 1; + } + + if(step == 2 && time > 15000000) { + write(sim.getMoteWithID(1), "ping " + dst_lla); + step += 1; + } + + if(msg.contains("Received ping reply")) { + write(sim.getMoteWithID(1), "ip-nbr"); + } + + if(msg.contains("<->")) { + re = /-- | <-> |, router|, state /; + nc = msg.split(re); + ip_addr = nc[1]; + ll_addr = nc[2]; + is_router = nc[3]; + state = nc[4].trim(); + if(ip_addr == dst_lla && + ll_addr == dst_mac && + state == "Reachable") { + log.testOK(); + } else { + log.log(ip_addr + "\n"); + log.log(ll_addr + "\n"); + log.log(state + "\n"); + log.testFailed(); + } + } +} diff --git a/tests/09-ipv6/js/ping-test-ula.js b/tests/09-ipv6/js/ping-test-ula.js new file mode 100644 index 000000000..b78f0342a --- /dev/null +++ b/tests/09-ipv6/js/ping-test-ula.js @@ -0,0 +1,47 @@ +;TIMEOUT(20000, log.testFailed()); + +dst_lla = "fe80::202:2:2:2"; +dst_ula = "fd00::202:2:2:2"; +dst_mac = "0002.0002.0002.0002"; +step = 0; + +while(1) { + YIELD(); + log.log(time + " " + id + " "+ msg + "\n"); + + if(msg.contains("Node id is set to")) { + if(id == 1) { + write(sim.getMoteWithID(1), "rpl-set-root 1"); + } + step += 1; + } + + if(step == 2 && time > 15000000) { + write(sim.getMoteWithID(1), "ping " + dst_ula); + step += 1; + } + + if(msg.contains("Received ping reply")) { + write(sim.getMoteWithID(1), "ip-nbr"); + } + + if(msg.contains("<->")) { + re = /-- | <-> |, router|, state /; + nc = msg.split(re); + ip_addr = nc[1]; + ll_addr = nc[2]; + is_router = nc[3]; + state = nc[4].trim(); + /* in RPL case, nbr doesn't have ula. */ + if((ip_addr == dst_lla || ip_addr == dst_ula) && + ll_addr == dst_mac && + state == "Reachable") { + log.testOK(); + } else { + log.log(ip_addr + "\n"); + log.log(ll_addr + "\n"); + log.log(state + "\n"); + log.testFailed(); + } + } +} diff --git a/tests/13-ieee802154/code-6tisch/project-conf.h b/tests/13-ieee802154/code-6tisch/project-conf.h index 657244d5a..acf60cbab 100644 --- a/tests/13-ieee802154/code-6tisch/project-conf.h +++ b/tests/13-ieee802154/code-6tisch/project-conf.h @@ -28,8 +28,8 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _PROJECT_CONF_H_ -#define _PROJECT_CONF_H_ +#ifndef PROJECT_CONF_H_ +#define PROJECT_CONF_H_ #define SIXTOP_CONF_MAX_SCHEDULING_FUNCTIONS 2 @@ -52,4 +52,4 @@ /* Custom MAC layer */ #define NETSTACK_CONF_MAC test_mac_driver -#endif /* __PROJECT_CONF_H__ */ +#endif /* PROJECT_CONF_H_ */ diff --git a/tests/13-ieee802154/code-flush-nbr-queue/project-conf.h b/tests/13-ieee802154/code-flush-nbr-queue/project-conf.h index 6923ae6fb..039bc7c49 100644 --- a/tests/13-ieee802154/code-flush-nbr-queue/project-conf.h +++ b/tests/13-ieee802154/code-flush-nbr-queue/project-conf.h @@ -29,8 +29,8 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _PROJECT_CONF_H_ -#define _PROJECT_CONF_H_ +#ifndef PROJECT_CONF_H_ +#define PROJECT_CONF_H_ #define UNIT_TEST_PRINT_FUNCTION test_print_report @@ -41,4 +41,4 @@ #define TSCH_CONF_WITH_SIXTOP 1 -#endif /* __PROJECT_CONF_H__ */ +#endif /* PROJECT_CONF_H_ */ diff --git a/tests/13-ieee802154/code-panid-handling/project-conf.h b/tests/13-ieee802154/code-panid-handling/project-conf.h index 5c17b28a2..89b2c289e 100644 --- a/tests/13-ieee802154/code-panid-handling/project-conf.h +++ b/tests/13-ieee802154/code-panid-handling/project-conf.h @@ -29,8 +29,8 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _PROJECT_CONF_H_ -#define _PROJECT_CONF_H_ +#ifndef PROJECT_CONF_H_ +#define PROJECT_CONF_H_ #define UNIT_TEST_PRINT_FUNCTION test_print_report @@ -38,4 +38,4 @@ #include "project-tsch-conf.h" #endif /* MAC_CONF_WITH_TSCH */ -#endif /* !_PROJECT_CONF_H_ */ +#endif /* !PROJECT_CONF_H_ */ diff --git a/tests/13-ieee802154/js/sixtop-test.js b/tests/13-ieee802154/js/sixtop-test.js index 962182e33..c410644ec 100644 --- a/tests/13-ieee802154/js/sixtop-test.js +++ b/tests/13-ieee802154/js/sixtop-test.js @@ -24,4 +24,3 @@ if(failed) { log.testFailed(); } log.testOK(); - diff --git a/tests/17-tun-rpl-br/06-native-coap.sh b/tests/17-tun-rpl-br/06-native-coap.sh index 16dd8aab7..88627ec19 100755 --- a/tests/17-tun-rpl-br/06-native-coap.sh +++ b/tests/17-tun-rpl-br/06-native-coap.sh @@ -12,8 +12,8 @@ declare -i TESTCOUNT=0 # Starting Contiki-NG native node echo "Starting native CoAP server" -make -C $CONTIKI/examples/coap > make.log 2> make.err -sudo $CONTIKI/examples/coap/coap-example-server.native > node.log 2> node.err & +make -C $CONTIKI/examples/coap/coap-example-server > make.log 2> make.err +sudo $CONTIKI/examples/coap/coap-example-server/coap-example-server.native > node.log 2> node.err & CPID=$! sleep 2 @@ -41,7 +41,7 @@ sleep 2 pgrep coap-example | sudo xargs kill -9 if [ $TESTCOUNT -eq $OKCOUNT ] ; then - printf "%-32s TEST OK %3d/%d\n" "$BASENAME" "$OKCOUNT" "$TESTCOUNT" > $BASENAME.testlog; + printf "%-32s TEST OK %3d/%d\n" "$BASENAME" "$OKCOUNT" "$TESTCOUNT" | tee $BASENAME.testlog; else echo "==== make.log ====" ; cat make.log; echo "==== make.err ====" ; cat make.err; @@ -49,7 +49,7 @@ else echo "==== node.err ====" ; cat node.err; echo "==== $BASENAME.log ====" ; cat $BASENAME.log; - printf "%-32s TEST FAIL %3d/%d\n" "$BASENAME" "$OKCOUNT" "$TESTCOUNT" > $BASENAME.testlog; + printf "%-32s TEST FAIL %3d/%d\n" "$BASENAME" "$OKCOUNT" "$TESTCOUNT" | tee $BASENAME.testlog; fi rm -f make.log make.err node.log node.err coap.log diff --git a/tests/18-coap-lwm2m/06-lwm2m-ipso-test.sh b/tests/18-coap-lwm2m/06-lwm2m-ipso-test.sh index 15fd96243..9aacc2976 100755 --- a/tests/18-coap-lwm2m/06-lwm2m-ipso-test.sh +++ b/tests/18-coap-lwm2m/06-lwm2m-ipso-test.sh @@ -3,14 +3,15 @@ # Contiki directory CONTIKI=$1 # Test basename -BASENAME=06-lwm2m-test +BASENAME=06-lwm2m-ipso-test IPADDR=fd00::302:304:506:708 # Starting Contiki-NG native node echo "Starting native node - lwm2m/ipso objects" -make -C $CONTIKI/examples/ipso-objects > make.log 2> make.err -sudo $CONTIKI/examples/ipso-objects/example-ipso-objects.native > node.log 2> node.err & +make -C $CONTIKI/examples/lwm2m-ipso-objects clean >/dev/null +make -C $CONTIKI/examples/lwm2m-ipso-objects > make.log 2> make.err +sudo $CONTIKI/examples/lwm2m-ipso-objects/example-ipso-objects.native > node.log 2> node.err & CPID=$! sleep 10 @@ -19,7 +20,15 @@ wget -nc https://joakimeriksson.github.io/resources/leshan-server-demo-1.0.0-SNA echo "Starting leshan server" java -jar leshan-server-demo-1.0.0-SNAPSHOT-jar-with-dependencies.jar >leshan.log 2>leshan.err & LESHID=$! -sleep 50 + +COUNTER=10 +while [ $COUNTER -gt 0 ]; do + sleep 5 + if grep -q 'OK' leshan.err ; then + break + fi + let COUNTER-=1 +done echo "Closing native node" sleep 1 diff --git a/tests/18-coap-lwm2m/07-lwm2m-standalone-test.sh b/tests/18-coap-lwm2m/07-lwm2m-standalone-test.sh index 5516eeb46..b13352447 100755 --- a/tests/18-coap-lwm2m/07-lwm2m-standalone-test.sh +++ b/tests/18-coap-lwm2m/07-lwm2m-standalone-test.sh @@ -5,9 +5,10 @@ CONTIKI=$1 # Test basename BASENAME=07-lwm2m-standalone-test -git clone https://github.com/contiki-ng/example-lwm2m-standalone.git # Building standalone posix example -make -C example-lwm2m-standalone/lwm2m > make.log 2> make.err +echo "Compiling standalone posix example" +make CONTIKI_NG=../../$CONTIKI -C example-lwm2m-standalone/lwm2m clean >/dev/null +make CONTIKI_NG=../../$CONTIKI -C example-lwm2m-standalone/lwm2m >make.log 2>make.err echo "Downloading leshan" wget -nc https://joakimeriksson.github.io/resources/leshan-server-demo-1.0.0-SNAPSHOT-jar-with-dependencies.jar @@ -20,11 +21,19 @@ example-lwm2m-standalone/lwm2m/lwm2m-example coap://127.0.0.1:5686 > node.log 2> CPID=$! -sleep 50 +COUNTER=10 +while [ $COUNTER -gt 0 ]; do + sleep 5 + if grep -q 'OK' leshan.err ; then + echo OK with $COUNTER + break + fi + let COUNTER-=1 +done -echo "Closing native node" +echo "Closing standalone example" sleep 1 -pgrep ipso | sudo xargs kill -9 +pgrep lwm2m-example | sudo xargs kill -9 echo "Closing leshan" sleep 1 diff --git a/tests/18-coap-lwm2m/example-lwm2m-standalone b/tests/18-coap-lwm2m/example-lwm2m-standalone index 7ab51eaaa..67b858437 160000 --- a/tests/18-coap-lwm2m/example-lwm2m-standalone +++ b/tests/18-coap-lwm2m/example-lwm2m-standalone @@ -1 +1 @@ -Subproject commit 7ab51eaaa309c123fbd318c6ad3338cce1e48e48 +Subproject commit 67b858437f7cf1e4e027d821c4c2ac15fdf2ab44 diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile index d8e9c0a79..be28bf682 100644 --- a/tools/docker/Dockerfile +++ b/tools/docker/Dockerfile @@ -4,8 +4,9 @@ FROM 32bit/ubuntu:16.04 RUN apt-get update && \ apt-get install -y --no-install-recommends \ build-essential doxygen git wget unzip python-serial \ - default-jdk ant srecord iputils-tracepath && \ - apt-get clean + default-jdk ant srecord iputils-tracepath rlwrap \ + mosquitto mosquitto-clients \ + && apt-get clean # Install ARM toolchain RUN wget https://launchpad.net/gcc-arm-embedded/5.0/5-2015-q4-major/+download/gcc-arm-none-eabi-5_2-2015q4-20151219-linux.tar.bz2 && \ @@ -73,6 +74,20 @@ RUN sudo apt-get install -y npm \ && sudo npm install coap-cli -g \ && sudo ln -s /usr/bin/nodejs /usr/bin/node +# Install Mono and libcanberra-gtk:i386 (for Renode) +RUN sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF \ + && echo "deb http://download.mono-project.com/repo/ubuntu xenial main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list \ + && sudo apt-get update \ + && sudo apt-get install -y mono-complete gksu libgtk2.0-0 screen uml-utilities gtk-sharp2 libcanberra-gtk-module:i386 \ + && sudo apt-get clean + +# Download, build and install Renode +RUN git clone https://github.com/renode/renode.git \ + && cd ${HOME}/renode \ + && git checkout v1.3 \ + && ./build.sh +ENV PATH="${HOME}/renode:${PATH}" + # Optional: download Contiki-NG and pre-compile Cooja. # Else, use a Docker bind mount to share the repo with the host. # Docker run option: @@ -83,8 +98,8 @@ RUN ant -q -f ${CONTIKI_NG}/tools/cooja/build.xml jar # Working directory WORKDIR ${CONTIKI_NG} -# Enable IPv6 -- must be done at runtime, not in Dockerfile -RUN echo "sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0 > /dev/null" >> /home/user/.profile +# Enable IPv6 -- must be done at runtime, hence added to .profile +RUN echo "sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0 > /dev/null" >> ${HOME}/.profile # Start a bash CMD bash --login diff --git a/tools/ip64/jool-start.sh b/tools/ip64/jool-start.sh new file mode 100755 index 000000000..b9c0c9850 --- /dev/null +++ b/tools/ip64/jool-start.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +defaultInterface=$(route | grep default | awk '{print $(NF)}') +myIP=$(ifconfig $defaultInterface | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}') +echo "Configuring jool for $myIP" + +sudo sysctl -w net.ipv4.conf.all.forwarding=1 +sudo sysctl -w net.ipv6.conf.all.forwarding=1 + +sudo /sbin/modprobe jool pool6=64:ff9b::/96 disabled + +# Assuming that we are on this IP +sudo jool -4 --add $myIP 15000-25000 +sudo jool --enable diff --git a/tools/tools-utils.c b/tools/tools-utils.c index 6ad0a9365..50a50c025 100644 --- a/tools/tools-utils.c +++ b/tools/tools-utils.c @@ -104,6 +104,7 @@ select_baudrate(int baudrate) { return B115200; #endif #ifdef B230400 + case 230400: return B230400; #endif #ifdef B460800 diff --git a/tools/vagrant/bootstrap.sh b/tools/vagrant/bootstrap.sh index 996ffb12e..c6cbd3d3c 100755 --- a/tools/vagrant/bootstrap.sh +++ b/tools/vagrant/bootstrap.sh @@ -8,7 +8,7 @@ sudo apt install -y --no-install-recommends \ # Tools sudo apt-get install -y --no-install-recommends \ - build-essential doxygen git wget unzip python-serial \ + build-essential doxygen git wget unzip python-serial rlwrap \ default-jdk ant srecord python-pip iputils-tracepath uncrustify python-magic sudo apt-get clean sudo python2 -m pip install intelhex diff --git a/tools/viewconf.c b/tools/viewconf.c index 5e6ee3d5e..678663ee1 100644 --- a/tools/viewconf.c +++ b/tools/viewconf.c @@ -16,18 +16,18 @@ ##### "CONTIKI_VERSION_STRING": ________________ == CONTIKI_VERSION_STRING -#ifdef IEEE802154_CONF_PANID -##### "IEEE802154_CONF_PANID":__________________ == IEEE802154_CONF_PANID -#else -##### "IEEE802154_CONF_PANID":__________________ == IEEE802154_PANID -#endif - #ifdef FRAME802154_CONF_VERSION ##### "FRAME802154_CONF_VERSION":_______________ == FRAME802154_CONF_VERSION #else ##### "FRAME802154_CONF_VERSION":_______________ == FRAME802154_VERSION #endif +#ifdef IEEE802154_CONF_PANID +##### "IEEE802154_CONF_PANID":__________________ == IEEE802154_CONF_PANID +#else +##### "IEEE802154_CONF_PANID":__________________ == IEEE802154_PANID +#endif + #if MAC_CONF_WITH_TSCH #ifdef TSCH_CONF_DEFAULT_HOPPING_SEQUENCE @@ -68,10 +68,10 @@ #else /* MAC_CONF_WITH_TSCH */ -#ifdef RF_CHANNEL -##### "RF_CHANNEL": ____________________________ == RF_CHANNEL +#ifdef IEEE802154_CONF_DEFAULT_CHANNEL +##### "IEEE802154_CONF_DEFAULT_CHANNEL": _______ == IEEE802154_CONF_DEFAULT_CHANNEL #else -##### "RF_CHANNEL": ____________________________ >< +##### "IEEE802154_CONF_DEFAULT_CHANNEL": _______ -> IEEE802154_DEFAULT_CHANNEL #endif #endif /*MAC_CONF_WITH_TSCH */