Merge branch 'develop' into contrib/default-prefix-as-variable
This commit is contained in:
commit
4243836e85
|
@ -82,7 +82,10 @@ uniq = $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1)))
|
|||
|
||||
### Include target makefile (TODO Unsafe?)
|
||||
|
||||
target_makefile := $(wildcard $(CONTIKI)/arch/platform/$(TARGET)/Makefile.$(TARGET) ${foreach TDIR, $(TARGETDIRS), $(TDIR)/$(TARGET)/Makefile.$(TARGET)})
|
||||
# Configurable arch path
|
||||
ARCH_PATH ?= $(CONTIKI)/arch
|
||||
|
||||
target_makefile := $(wildcard $(ARCH_PATH)/platform/$(TARGET)/Makefile.$(TARGET) ${foreach TDIR, $(TARGETDIRS), $(TDIR)/$(TARGET)/Makefile.$(TARGET)})
|
||||
|
||||
# Check if the target makefile exists, and create the object directory if necessary.
|
||||
ifeq ($(strip $(target_makefile)),)
|
||||
|
@ -326,13 +329,13 @@ clean:
|
|||
@echo Target $(TARGET) cleaned
|
||||
|
||||
distclean:
|
||||
@for TARG in `ls $(CONTIKI)/arch/platform $(TARGETDIRS)`; do \
|
||||
@for TARG in `ls $(ARCH_PATH)/platform $(TARGETDIRS)`; do \
|
||||
echo Running: $(MAKE) TARGET=$$TARG clean; \
|
||||
$(MAKE) TARGET=$$TARG clean; \
|
||||
done
|
||||
-$(Q)rm -rf $(BUILD_DIR)
|
||||
|
||||
-include $(CONTIKI)/arch/platform/$(TARGET)/Makefile.customrules-$(TARGET)
|
||||
-include $(ARCH_PATH)/platform/$(TARGET)/Makefile.customrules-$(TARGET)
|
||||
|
||||
ifndef CUSTOM_RULE_C_TO_OBJECTDIR_O
|
||||
$(OBJECTDIR)/%.o: %.c | $(OBJECTDIR)
|
||||
|
@ -414,7 +417,7 @@ endif
|
|||
include $(CONTIKI)/Makefile.help
|
||||
|
||||
targets:
|
||||
@ls $(CONTIKI)/arch/platform $(TARGETDIRS)
|
||||
@ls $(ARCH_PATH)/platform $(TARGETDIRS)
|
||||
|
||||
boards:
|
||||
ifdef BOARD
|
||||
|
|
|
@ -25,4 +25,4 @@ $(OUT_ELF): $(CPU_STARTFILES) $$(CONTIKI_OBJECTFILES) %.o $(PROJECT_OBJECTFILES)
|
|||
$(TRACE_LD)
|
||||
$(Q)$(LD) $(LDFLAGS) ${filter-out $(LDSCRIPT) %.a,$^} ${filter %.a,$^} $(TARGET_LIBFLAGS) -o $@
|
||||
|
||||
include $(CONTIKI)/arch/cpu/arm/Makefile.arm
|
||||
include $(ARCH_PATH)/cpu/arm/Makefile.arm
|
||||
|
|
|
@ -6,4 +6,4 @@ LDFLAGS += -mcpu=cortex-m3 -nostartfiles
|
|||
|
||||
TARGET_LIBFILES += -lm
|
||||
|
||||
include $(CONTIKI)/arch/cpu/arm/cortex-m/Makefile.cortex-m
|
||||
include $(ARCH_PATH)/cpu/arm/cortex-m/Makefile.cortex-m
|
||||
|
|
|
@ -4,4 +4,4 @@ CFLAGS += -mcpu=cortex-m4
|
|||
|
||||
LDFLAGS += -mcpu=cortex-m4
|
||||
|
||||
include $(CONTIKI)/arch/cpu/arm/cortex-m/Makefile.cortex-m
|
||||
include $(ARCH_PATH)/cpu/arm/cortex-m/Makefile.cortex-m
|
||||
|
|
|
@ -52,4 +52,4 @@ $(LDSCRIPT): $(SOURCE_LDSCRIPT) FORCE | $(OBJECTDIR)
|
|||
$(TRACE_CC)
|
||||
$(Q)$(CC) $(LDGENFLAGS) $< | grep -v '^\s*#\s*pragma\>' > $@
|
||||
|
||||
include $(CONTIKI)/arch/cpu/arm/cortex-m/cm3/Makefile.cm3
|
||||
include $(ARCH_PATH)/cpu/arm/cortex-m/cm3/Makefile.cm3
|
||||
|
|
|
@ -24,7 +24,7 @@ CFLAGS += -I$(TI_XXWARE) -I$(CONTIKI)/$(TI_XXWARE_SRC)
|
|||
CFLAGS += -I$(TI_XXWARE)/inc
|
||||
MODULES += $(TI_XXWARE_SRC)
|
||||
|
||||
LDSCRIPT = $(CONTIKI_CPU)/cc26xx.ld
|
||||
LDSCRIPT ?= $(CONTIKI_CPU)/cc26xx.ld
|
||||
|
||||
### If the user-specified a Node ID, pass a define
|
||||
ifdef NODEID
|
||||
|
@ -81,7 +81,7 @@ STACK_SIZE = 0
|
|||
@$(SIZE) -A $< | egrep "data|bss" | awk '{s+=$$2} END {s=s+$(STACK_SIZE); f=$(RAM_SIZE)-s; printf "[RAM] used %6d, free %6d\n",s,f;}'
|
||||
@$(SIZE) -A $< | egrep "text|isr_vector" | awk '{s+=$$2} END {f=$(FLASH_SIZE)-s; printf "[Flash] used %6d, free %6d\n",s,f;}'
|
||||
|
||||
include $(CONTIKI)/arch/cpu/arm/cortex-m/cm3/Makefile.cm3
|
||||
include $(ARCH_PATH)/cpu/arm/cortex-m/cm3/Makefile.cm3
|
||||
|
||||
ifeq ($(BOARD_SUPPORTS_BSL),1)
|
||||
%.upload: $(OUT_BIN)
|
||||
|
|
|
@ -11,7 +11,7 @@ CFLAGS += -gstabs+
|
|||
.SUFFIXES:
|
||||
|
||||
### Define the CPU directory
|
||||
CONTIKI_CPU=$(CONTIKI)/arch/cpu/msp430
|
||||
CONTIKI_CPU=$(ARCH_PATH)/cpu/msp430
|
||||
|
||||
### Define the source files we have in the MSP430 port
|
||||
|
||||
|
|
|
@ -25,9 +25,9 @@ ifneq ($(NRF52_WITHOUT_SOFTDEVICE),1)
|
|||
NRF52_SOFTDEVICE := $(shell find $(NRF52_SDK_ROOT) -name *iot*_softdevice.hex | head -n 1)
|
||||
endif
|
||||
$(info SoftDevice: $(NRF52_SOFTDEVICE))
|
||||
LDSCRIPT := $(CONTIKI_CPU)/ld/nrf52-$(NRF52_DK_REVISION)-sd.ld
|
||||
LDSCRIPT ?= $(CONTIKI_CPU)/ld/nrf52-$(NRF52_DK_REVISION)-sd.ld
|
||||
else
|
||||
LDSCRIPT := $(CONTIKI_CPU)/ld/nrf52.ld
|
||||
LDSCRIPT ?= $(CONTIKI_CPU)/ld/nrf52.ld
|
||||
endif
|
||||
|
||||
OUTPUT_FILENAME := $(CONTIKI_PROJECT)
|
||||
|
@ -204,4 +204,4 @@ erase:
|
|||
|
||||
.PHONY: softdevice.jlink
|
||||
|
||||
include $(CONTIKI)/arch/cpu/arm/cortex-m/cm4/Makefile.cm4
|
||||
include $(ARCH_PATH)/cpu/arm/cortex-m/cm4/Makefile.cm4
|
||||
|
|
|
@ -120,7 +120,7 @@ LDFLAGS += -nostartfiles
|
|||
LDFLAGS += -static
|
||||
|
||||
# Linker script
|
||||
LDSCRIPT := $(CONTIKI_CPU)/$(SUBFAMILY)/$(SUBFAMILY).lds
|
||||
LDSCRIPT ?= $(CONTIKI_CPU)/$(SUBFAMILY)/$(SUBFAMILY).lds
|
||||
|
||||
# Globally linked libraries
|
||||
TARGET_LIBFILES += -lc -lgcc -lnosys -lm
|
||||
|
|
|
@ -8,4 +8,4 @@ TARGET_LIBFILES += $(SDK_DRIVERS)/lib/drivers_$(SDK_LIB_NAME).am3g
|
|||
TARGET_LIBFILES += $(SDK_DEVICES)/driverlib/bin/gcc/driverlib.lib
|
||||
|
||||
# CC13x0/CC26x0 is a Cortex-M3 architecture
|
||||
include $(CONTIKI)/arch/cpu/arm/cortex-m/cm3/Makefile.cm3
|
||||
include $(ARCH_PATH)/cpu/arm/cortex-m/cm3/Makefile.cm3
|
||||
|
|
|
@ -95,42 +95,42 @@ SECTIONS {
|
|||
* --------- DO NOT MODIFY -----------
|
||||
*/
|
||||
UDMACC26XX_dmaSpi0RxControlTableEntry_is_placed = 0;
|
||||
.dmaSpi0RxControlTableEntry DMA_SPI0_RX_CTEA : AT (DMA_SPI0_RX_CTEA) {
|
||||
.dmaSpi0RxControlTableEntry DMA_SPI0_RX_CTEA (NOLOAD) : AT (DMA_SPI0_RX_CTEA) {
|
||||
*(.dmaSpi0RxControlTableEntry)
|
||||
} > REGION_DATA
|
||||
|
||||
UDMACC26XX_dmaSpi0TxControlTableEntry_is_placed = 0;
|
||||
.dmaSpi0TxControlTableEntry DMA_SPI0_TX_CTEA : AT (DMA_SPI0_TX_CTEA) {
|
||||
.dmaSpi0TxControlTableEntry DMA_SPI0_TX_CTEA (NOLOAD) : AT (DMA_SPI0_TX_CTEA) {
|
||||
*(.dmaSpi0TxControlTableEntry)
|
||||
} > REGION_DATA
|
||||
|
||||
UDMACC26XX_dmaADCPriControlTableEntry_is_placed = 0;
|
||||
.dmaADCPriControlTableEntry DMA_ADC_PRI_CTEA : AT (DMA_ADC_PRI_CTEA) {
|
||||
.dmaADCPriControlTableEntry DMA_ADC_PRI_CTEA (NOLOAD) : AT (DMA_ADC_PRI_CTEA) {
|
||||
*(.dmaADCPriControlTableEntry)
|
||||
} > REGION_DATA
|
||||
|
||||
UDMACC26XX_dmaGPT0APriControlTableEntry_is_placed = 0;
|
||||
.dmaGPT0APriControlTableEntry DMA_GPT0A_PRI_CTEA : AT (DMA_GPT0A_PRI_CTEA) {
|
||||
.dmaGPT0APriControlTableEntry DMA_GPT0A_PRI_CTEA (NOLOAD) : AT (DMA_GPT0A_PRI_CTEA) {
|
||||
*(.dmaGPT0APriControlTableEntry)
|
||||
} > REGION_DATA
|
||||
|
||||
UDMACC26XX_dmaSpi1RxControlTableEntry_is_placed = 0;
|
||||
.dmaSpi1RxControlTableEntry DMA_SPI1_RX_CTEA : AT (DMA_SPI1_RX_CTEA) {
|
||||
.dmaSpi1RxControlTableEntry DMA_SPI1_RX_CTEA (NOLOAD) : AT (DMA_SPI1_RX_CTEA) {
|
||||
*(.dmaSpi1RxControlTableEntry)
|
||||
} > REGION_DATA
|
||||
|
||||
UDMACC26XX_dmaSpi1TxControlTableEntry_is_placed = 0;
|
||||
.dmaSpi1TxControlTableEntry DMA_SPI1_TX_CTEA : AT (DMA_SPI1_TX_CTEA) {
|
||||
.dmaSpi1TxControlTableEntry DMA_SPI1_TX_CTEA (NOLOAD) : AT (DMA_SPI1_TX_CTEA) {
|
||||
*(.dmaSpi1TxControlTableEntry)
|
||||
} > REGION_DATA
|
||||
|
||||
UDMACC26XX_dmaADCAltControlTableEntry_is_placed = 0;
|
||||
.dmaADCAltControlTableEntry DMA_ADC_ALT_CTEA : AT (DMA_ADC_ALT_CTEA) {
|
||||
.dmaADCAltControlTableEntry DMA_ADC_ALT_CTEA (NOLOAD) : AT (DMA_ADC_ALT_CTEA) {
|
||||
*(.dmaADCAltControlTableEntry)
|
||||
} > REGION_DATA
|
||||
|
||||
UDMACC26XX_dmaGPT0AAltControlTableEntry_is_placed = 0;
|
||||
.dmaGPT0AAltControlTableEntry DMA_GPT0A_ALT_CTEA : AT (DMA_GPT0A_ALT_CTEA) {
|
||||
.dmaGPT0AAltControlTableEntry DMA_GPT0A_ALT_CTEA (NOLOAD) : AT (DMA_GPT0A_ALT_CTEA) {
|
||||
*(.dmaGPT0AAltControlTableEntry)
|
||||
} > REGION_DATA
|
||||
|
||||
|
|
|
@ -8,4 +8,4 @@ TARGET_LIBFILES += $(SDK_DRIVERS)/lib/drivers_$(SDK_LIB_NAME).am4fg
|
|||
TARGET_LIBFILES += $(SDK_DEVICES)/driverlib/bin/gcc/driverlib.lib
|
||||
|
||||
# CC13x2/CC26x2 is a Cortex-M4 architecture
|
||||
include $(CONTIKI)/arch/cpu/arm/cortex-m/cm4/Makefile.cm4
|
||||
include $(ARCH_PATH)/cpu/arm/cortex-m/cm4/Makefile.cm4
|
||||
|
|
|
@ -95,42 +95,42 @@ SECTIONS {
|
|||
* --------- DO NOT MODIFY -----------
|
||||
*/
|
||||
UDMACC26XX_dmaSpi0RxControlTableEntry_is_placed = 0;
|
||||
.dmaSpi0RxControlTableEntry DMA_SPI0_RX_CTEA : AT (DMA_SPI0_RX_CTEA) {
|
||||
.dmaSpi0RxControlTableEntry DMA_SPI0_RX_CTEA (NOLOAD) : AT (DMA_SPI0_RX_CTEA) {
|
||||
*(.dmaSpi0RxControlTableEntry)
|
||||
} > REGION_DATA
|
||||
|
||||
UDMACC26XX_dmaSpi0TxControlTableEntry_is_placed = 0;
|
||||
.dmaSpi0TxControlTableEntry DMA_SPI0_TX_CTEA : AT (DMA_SPI0_TX_CTEA) {
|
||||
.dmaSpi0TxControlTableEntry DMA_SPI0_TX_CTEA (NOLOAD) : AT (DMA_SPI0_TX_CTEA) {
|
||||
*(.dmaSpi0TxControlTableEntry)
|
||||
} > REGION_DATA
|
||||
|
||||
UDMACC26XX_dmaADCPriControlTableEntry_is_placed = 0;
|
||||
.dmaADCPriControlTableEntry DMA_ADC_PRI_CTEA : AT (DMA_ADC_PRI_CTEA) {
|
||||
.dmaADCPriControlTableEntry DMA_ADC_PRI_CTEA (NOLOAD) : AT (DMA_ADC_PRI_CTEA) {
|
||||
*(.dmaADCPriControlTableEntry)
|
||||
} > REGION_DATA
|
||||
|
||||
UDMACC26XX_dmaGPT0APriControlTableEntry_is_placed = 0;
|
||||
.dmaGPT0APriControlTableEntry DMA_GPT0A_PRI_CTEA : AT (DMA_GPT0A_PRI_CTEA) {
|
||||
.dmaGPT0APriControlTableEntry DMA_GPT0A_PRI_CTEA (NOLOAD) : AT (DMA_GPT0A_PRI_CTEA) {
|
||||
*(.dmaGPT0APriControlTableEntry)
|
||||
} > REGION_DATA
|
||||
|
||||
UDMACC26XX_dmaSpi1RxControlTableEntry_is_placed = 0;
|
||||
.dmaSpi1RxControlTableEntry DMA_SPI1_RX_CTEA : AT (DMA_SPI1_RX_CTEA) {
|
||||
.dmaSpi1RxControlTableEntry DMA_SPI1_RX_CTEA (NOLOAD) : AT (DMA_SPI1_RX_CTEA) {
|
||||
*(.dmaSpi1RxControlTableEntry)
|
||||
} > REGION_DATA
|
||||
|
||||
UDMACC26XX_dmaSpi1TxControlTableEntry_is_placed = 0;
|
||||
.dmaSpi1TxControlTableEntry DMA_SPI1_TX_CTEA : AT (DMA_SPI1_TX_CTEA) {
|
||||
.dmaSpi1TxControlTableEntry DMA_SPI1_TX_CTEA (NOLOAD) : AT (DMA_SPI1_TX_CTEA) {
|
||||
*(.dmaSpi1TxControlTableEntry)
|
||||
} > REGION_DATA
|
||||
|
||||
UDMACC26XX_dmaADCAltControlTableEntry_is_placed = 0;
|
||||
.dmaADCAltControlTableEntry DMA_ADC_ALT_CTEA : AT (DMA_ADC_ALT_CTEA) {
|
||||
.dmaADCAltControlTableEntry DMA_ADC_ALT_CTEA (NOLOAD) : AT (DMA_ADC_ALT_CTEA) {
|
||||
*(.dmaADCAltControlTableEntry)
|
||||
} > REGION_DATA
|
||||
|
||||
UDMACC26XX_dmaGPT0AAltControlTableEntry_is_placed = 0;
|
||||
.dmaGPT0AAltControlTableEntry DMA_GPT0A_ALT_CTEA : AT (DMA_GPT0A_ALT_CTEA) {
|
||||
.dmaGPT0AAltControlTableEntry DMA_GPT0A_ALT_CTEA (NOLOAD) : AT (DMA_GPT0A_ALT_CTEA) {
|
||||
*(.dmaGPT0AAltControlTableEntry)
|
||||
} > REGION_DATA
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ CONTIKI_TARGET_SOURCEFILES += board-buttons.c als-sensor.c
|
|||
CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)
|
||||
|
||||
### Define the CPU directory
|
||||
CONTIKI_CPU=$(CONTIKI)/arch/cpu/cc2538
|
||||
CONTIKI_CPU=$(ARCH_PATH)/cpu/cc2538
|
||||
include $(CONTIKI_CPU)/Makefile.cc2538
|
||||
|
||||
MODULES += os/storage/cfs
|
||||
|
|
|
@ -11,7 +11,7 @@ BOARDS = srf06/cc26x0 srf06/cc13x0 launchpad/cc2640r2 launchpad/cc2650 launchpad
|
|||
CONTIKI_TARGET_DIRS += .
|
||||
|
||||
### Include the board-specific makefile
|
||||
PLATFORM_ROOT_DIR = $(CONTIKI)/arch/platform/$(TARGET)
|
||||
PLATFORM_ROOT_DIR = $(ARCH_PATH)/platform/$(TARGET)
|
||||
-include $(PLATFORM_ROOT_DIR)/$(BOARD)/Makefile.$(notdir $(BOARD))
|
||||
|
||||
CONTIKI_TARGET_SOURCEFILES += platform.c leds-arch.c
|
||||
|
@ -25,5 +25,5 @@ SMALL ?= 0
|
|||
### Define the CPU directory and pull in the correct CPU makefile. This will
|
||||
### be defined by one of the makefiles included above and it can be either
|
||||
### Makefile.cc26xx or Makefile.cc13xx
|
||||
CONTIKI_CPU=$(CONTIKI)/arch/cpu/cc26x0-cc13x0
|
||||
CONTIKI_CPU=$(ARCH_PATH)/cpu/cc26x0-cc13x0
|
||||
include $(CONTIKI_CPU)/Makefile.$(CPU_FAMILY)
|
||||
|
|
|
@ -41,7 +41,7 @@ JNILIB = $(BUILD_DIR_BOARD)/$(LIBNAME).$(TARGET)
|
|||
CONTIKI_APP_OBJ = $(CONTIKI_APP).o
|
||||
|
||||
### COOJA platform sources
|
||||
COOJA = $(CONTIKI)/arch/platform/$(TARGET)
|
||||
COOJA = $(ARCH_PATH)/platform/$(TARGET)
|
||||
CONTIKI_TARGET_DIRS = . dev lib sys cfs net
|
||||
|
||||
# (COOJA_SOURCEDIRS contains additional sources dirs set from simulator)
|
||||
|
@ -67,7 +67,7 @@ CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)
|
|||
CLEAN += COOJA.log
|
||||
|
||||
### Define the CPU directory
|
||||
CONTIKI_CPU=$(CONTIKI)/arch/cpu/x86
|
||||
CONTIKI_CPU=$(ARCH_PATH)/cpu/x86
|
||||
|
||||
### Compiler arguments
|
||||
#CC = gcc
|
||||
|
|
|
@ -28,5 +28,5 @@ CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)
|
|||
MAKE_MAC ?= MAKE_MAC_NULLMAC
|
||||
|
||||
### Define the CPU directory
|
||||
CONTIKI_CPU=$(CONTIKI)/arch/cpu/native
|
||||
include $(CONTIKI)/arch/cpu/native/Makefile.native
|
||||
CONTIKI_CPU=$(ARCH_PATH)/cpu/native
|
||||
include $(ARCH_PATH)/cpu/native/Makefile.native
|
||||
|
|
|
@ -3,7 +3,7 @@ ifndef CONTIKI
|
|||
endif
|
||||
|
||||
### Include the board-specific makefile
|
||||
PLATFORM_ROOT_DIR = $(CONTIKI)/arch/platform/$(TARGET)
|
||||
PLATFORM_ROOT_DIR = $(ARCH_PATH)/platform/$(TARGET)
|
||||
|
||||
CONTIKI_TARGET_DIRS += . dev config
|
||||
CONTIKI_SOURCEFILES += platform.c leds-arch.c nrf52dk-sensors.c button-sensor.c temperature-sensor.c
|
||||
|
@ -21,5 +21,5 @@ endif
|
|||
SMALL ?= 0
|
||||
|
||||
### Define the CPU directory and pull in the correct CPU makefile.
|
||||
CONTIKI_CPU=$(CONTIKI)/arch/cpu/nrf52832
|
||||
CONTIKI_CPU=$(ARCH_PATH)/cpu/nrf52832
|
||||
include $(CONTIKI_CPU)/Makefile.nrf52832
|
||||
|
|
|
@ -11,7 +11,7 @@ endif
|
|||
|
||||
### Configure the build for the board and pull in board-specific sources
|
||||
CONTIKI_TARGET_DIRS += . dev
|
||||
PLATFORM_ROOT_DIR = $(CONTIKI)/arch/platform/$(TARGET)
|
||||
PLATFORM_ROOT_DIR = $(ARCH_PATH)/platform/$(TARGET)
|
||||
|
||||
### Include
|
||||
CONTIKI_TARGET_SOURCEFILES += platform.c board.c
|
||||
|
@ -21,7 +21,7 @@ CONTIKI_TARGET_SOURCEFILES += antenna.c adxl346.c max44009.c sht21.c tps62730.c
|
|||
CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)
|
||||
|
||||
### Define the CPU directory
|
||||
CONTIKI_CPU=$(CONTIKI)/arch/cpu/cc2538
|
||||
CONTIKI_CPU=$(ARCH_PATH)/cpu/cc2538
|
||||
include $(CONTIKI_CPU)/Makefile.cc2538
|
||||
|
||||
MODULES += os/storage/cfs
|
||||
|
|
|
@ -51,7 +51,7 @@ CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)
|
|||
CPU_FAMILY = cc13xx-cc26xx
|
||||
|
||||
# Define the CPU directory and pull in the correct CPU Makefile
|
||||
CONTIKI_CPU := $(realpath $(CONTIKI)/arch/cpu/simplelink-$(CPU_FAMILY))
|
||||
CONTIKI_CPU := $(realpath $(ARCH_PATH)/cpu/simplelink-$(CPU_FAMILY))
|
||||
include $(CONTIKI_CPU)/Makefile.$(CPU_FAMILY)
|
||||
|
||||
MODULES += os/net os/net/mac os/net/mac/framer
|
||||
|
|
|
@ -18,7 +18,7 @@ endif
|
|||
CONTIKI_TARGET_SOURCEFILES += $(ARCH) $(UIPDRIVERS)
|
||||
|
||||
MCU=msp430f1611
|
||||
include $(CONTIKI)/arch/cpu/msp430/Makefile.msp430
|
||||
include $(ARCH_PATH)/cpu/msp430/Makefile.msp430
|
||||
|
||||
|
||||
ifdef IAR
|
||||
|
|
|
@ -4,6 +4,6 @@ CONTIKI_TARGET_SOURCEFILES += contiki-sky-platform.c \
|
|||
sht11.c sht11-sensor.c light-sensor.c battery-sensor.c \
|
||||
button-sensor.c
|
||||
|
||||
include $(CONTIKI)/arch/platform/sky/Makefile.common
|
||||
include $(ARCH_PATH)/platform/sky/Makefile.common
|
||||
|
||||
MODULES += arch/dev/cc2420 arch/dev/sht11 arch/dev/ds2411 os/storage/cfs
|
||||
|
|
|
@ -25,7 +25,7 @@ CFLAGS += -DDATE="\"`date +"%02u %02d %02m %02y %02H %02M %02S"`\""
|
|||
### Configure the build for the board and pull in board-specific sources
|
||||
CONTIKI_TARGET_DIRS += . dev
|
||||
CONTIKI_TARGET_DIRS += . $(BOARD)
|
||||
PLATFORM_ROOT_DIR = $(CONTIKI)/arch/platform/$(TARGET)
|
||||
PLATFORM_ROOT_DIR = $(ARCH_PATH)/platform/$(TARGET)
|
||||
|
||||
### Include the board dir if one exists
|
||||
-include $(PLATFORM_ROOT_DIR)/$(BOARD)/Makefile.$(BOARD)
|
||||
|
@ -39,7 +39,7 @@ CONTIKI_TARGET_SOURCEFILES += $(BOARD_SOURCEFILES)
|
|||
CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)
|
||||
|
||||
### Define the CPU directory
|
||||
CONTIKI_CPU=$(CONTIKI)/arch/cpu/cc2538
|
||||
CONTIKI_CPU=$(ARCH_PATH)/cpu/cc2538
|
||||
include $(CONTIKI_CPU)/Makefile.cc2538
|
||||
|
||||
MODULES += arch/dev/cc1200 arch/dev/rgb-led os/storage/cfs
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
#include "contiki-net.h"
|
||||
#include "services/deployment/deployment.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
/* Log configuration */
|
||||
#include "sys/log.h"
|
||||
#define LOG_MODULE "App"
|
||||
|
|
|
@ -70,6 +70,9 @@ def parseRPL(log):
|
|||
if res:
|
||||
# This was the last line, commit full topology
|
||||
return {'event': 'topology' }
|
||||
res = re.compile('initialized DAG').match(log)
|
||||
if res:
|
||||
return {'event': 'DAGinit' }
|
||||
return None
|
||||
|
||||
def parseEnergest(log):
|
||||
|
@ -123,6 +126,7 @@ def doParse(file):
|
|||
"ranks": [],
|
||||
"trickle": [],
|
||||
"switches": [],
|
||||
"DAGinits": [],
|
||||
"topology": [],
|
||||
}
|
||||
|
||||
|
@ -178,6 +182,8 @@ def doParse(file):
|
|||
arrays["trickle"].append(entry)
|
||||
elif(ret['event'] == 'switch'):
|
||||
arrays["switches"].append(entry)
|
||||
elif(ret['event'] == 'DAGinit'):
|
||||
arrays["DAGinits"].append(entry)
|
||||
elif(ret['event'] == 'sending'):
|
||||
if not ret['message'] in arrays:
|
||||
arrays[ret['message']] = []
|
||||
|
@ -255,6 +261,7 @@ def main():
|
|||
|
||||
outputStats(dfs, "ranks", "rank", "mean", "RPL rank (ETX-128)")
|
||||
outputStats(dfs, "switches", "pswitch", "count", "RPL parent switches (#)")
|
||||
outputStats(dfs, "DAGinits", "event", "count", "RPL joining DAG (#)")
|
||||
outputStats(dfs, "trickle", "trickle", "mean", "RPL Trickle period (min)")
|
||||
|
||||
outputStats(dfs, "DIS", "message", "count", "RPL DIS sent (#)", "rpl-dis")
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
* \author
|
||||
* Joakim Eriksson, joakime@sics.se
|
||||
* Niclas Finne, nfi@sics.se
|
||||
* Carlos Gonzalo Peces, carlosgp143@gmail.com
|
||||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
|
@ -51,18 +52,28 @@
|
|||
#define DEBUG DEBUG_NONE
|
||||
#include "net/ipv6/uip-debug.h"
|
||||
|
||||
/* Define this macro to non-zero to register via a bootstrap server */
|
||||
#ifndef REGISTER_WITH_LWM2M_BOOTSTRAP_SERVER
|
||||
#define REGISTER_WITH_LWM2M_BOOTSTRAP_SERVER 0
|
||||
#endif
|
||||
|
||||
#ifndef REGISTER_WITH_LWM2M_SERVER
|
||||
#define REGISTER_WITH_LWM2M_SERVER 1
|
||||
#if REGISTER_WITH_LWM2M_BOOTSTRAP_SERVER
|
||||
#define SERVER_TYPE LWM2M_RD_CLIENT_BOOTSTRAP_SERVER
|
||||
#else
|
||||
#define SERVER_TYPE LWM2M_RD_CLIENT_LWM2M_SERVER
|
||||
#endif
|
||||
|
||||
#ifndef LWM2M_SERVER_ADDRESS
|
||||
#define LWM2M_SERVER_ADDRESS "coap://[fd00::1]"
|
||||
#endif
|
||||
|
||||
static lwm2m_session_info_t session_info;
|
||||
|
||||
/* Define this macro to register with a second LWM2M server */
|
||||
#ifdef LWM2M_SERVER_ADDRESS_SECOND
|
||||
static lwm2m_session_info_t session_info_second;
|
||||
#endif
|
||||
|
||||
#if BOARD_SENSORTAG
|
||||
#include "board-peripherals.h"
|
||||
|
||||
|
@ -148,13 +159,17 @@ setup_lwm2m_servers(void)
|
|||
coap_endpoint_t server_ep;
|
||||
if(coap_endpoint_parse(LWM2M_SERVER_ADDRESS, strlen(LWM2M_SERVER_ADDRESS),
|
||||
&server_ep) != 0) {
|
||||
lwm2m_rd_client_register_with_bootstrap_server(&server_ep);
|
||||
lwm2m_rd_client_register_with_server(&server_ep);
|
||||
lwm2m_rd_client_register_with_server(&session_info, &server_ep, SERVER_TYPE);
|
||||
}
|
||||
#endif /* LWM2M_SERVER_ADDRESS */
|
||||
|
||||
lwm2m_rd_client_use_bootstrap_server(REGISTER_WITH_LWM2M_BOOTSTRAP_SERVER);
|
||||
lwm2m_rd_client_use_registration_server(REGISTER_WITH_LWM2M_SERVER);
|
||||
#ifdef LWM2M_SERVER_ADDRESS_SECOND
|
||||
coap_endpoint_t server_ep_second;
|
||||
if(coap_endpoint_parse(LWM2M_SERVER_ADDRESS_SECOND, strlen(LWM2M_SERVER_ADDRESS_SECOND),
|
||||
&server_ep_second) != 0) {
|
||||
lwm2m_rd_client_register_with_server(&session_info_second, &server_ep_second, SERVER_TYPE);
|
||||
}
|
||||
#endif /* LWM2M_SERVER_ADDRESS_SECOND */
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(example_ipso_objects, ev, data)
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 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 CC2530_CC2531_IO_H_
|
||||
#define CC2530_CC2531_IO_H_
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/io-arch.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define sensniff_io_byte_out(b) io_arch_writeb(b)
|
||||
#define sensniff_io_flush() io_arch_flush()
|
||||
#define sensniff_io_set_input(f) io_arch_set_input(f)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* CC2530_CC2531_IO_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -45,6 +45,7 @@
|
|||
|
||||
#include "net/mac/tsch/tsch.h"
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#if TSCH_ADAPTIVE_TIMESYNC
|
||||
|
||||
|
|
|
@ -368,7 +368,7 @@ rpl_set_root(uint8_t instance_id, uip_ipaddr_t *dag_id)
|
|||
if(uip_ipaddr_cmp(&dag->dag_id, dag_id)) {
|
||||
version = dag->version;
|
||||
RPL_LOLLIPOP_INCREMENT(version);
|
||||
}
|
||||
} else {
|
||||
if(dag == dag->instance->current_dag) {
|
||||
LOG_INFO("Dropping a joined DAG when setting this node as root\n");
|
||||
rpl_set_default_route(instance, NULL);
|
||||
|
@ -380,6 +380,7 @@ rpl_set_root(uint8_t instance_id, uip_ipaddr_t *dag_id)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dag = rpl_alloc_dag(instance_id, dag_id);
|
||||
if(dag == NULL) {
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
#include "coap-endpoint.h"
|
||||
#include "coap-callback-api.h"
|
||||
#include "lwm2m-security.h"
|
||||
#include "lib/list.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
|
@ -76,18 +77,11 @@
|
|||
#define LWM2M_DEFAULT_CLIENT_LIFETIME 30 /* sec */
|
||||
#endif
|
||||
|
||||
#define MAX_RD_UPDATE_WAIT 5000
|
||||
|
||||
#define REMOTE_PORT UIP_HTONS(COAP_DEFAULT_PORT)
|
||||
#define BS_REMOTE_PORT UIP_HTONS(5685)
|
||||
|
||||
#define STATE_MACHINE_UPDATE_INTERVAL 500
|
||||
|
||||
static struct lwm2m_session_info session_info;
|
||||
static coap_callback_request_state_t rd_request_state;
|
||||
|
||||
static coap_message_t request[1]; /* This way the message can be treated as pointer as usual. */
|
||||
|
||||
/* The states for the RD client state machine */
|
||||
/* When node is unregistered it ends up in UNREGISTERED
|
||||
and this is going to be there until use X or Y kicks it
|
||||
|
@ -114,20 +108,14 @@ static coap_message_t request[1]; /* This way the message can be treated as
|
|||
#define FLAG_RD_DATA_UPDATE_TRIGGERED 0x02
|
||||
#define FLAG_RD_DATA_UPDATE_ON_DIRTY 0x10
|
||||
|
||||
static uint8_t rd_state = 0;
|
||||
static uint8_t rd_flags = FLAG_RD_DATA_UPDATE_ON_DIRTY;
|
||||
static uint64_t wait_until_network_check = 0;
|
||||
static uint64_t last_update;
|
||||
LIST(session_info_list);
|
||||
|
||||
/* Shared by all sessions, used by only one at a time in the FSM */
|
||||
static char query_data[64]; /* allocate some data for queries and updates */
|
||||
static uint8_t rd_data[128]; /* allocate some data for the RD */
|
||||
|
||||
static uint32_t rd_block1;
|
||||
static uint8_t rd_more;
|
||||
static coap_timer_t rd_timer;
|
||||
static void (*rd_callback)(coap_callback_request_state_t *callback_state);
|
||||
|
||||
static coap_timer_t block1_timer;
|
||||
static coap_timer_t rd_timer; /* Timer to tick the FSM periodically */
|
||||
static char default_ep[20];
|
||||
|
||||
#if LWM2M_QUEUE_MODE_ENABLED
|
||||
static coap_timer_t queue_mode_client_awake_timer; /* Timer to control the client's
|
||||
|
@ -143,9 +131,9 @@ static void queue_mode_awake_timer_callback(coap_timer_t *timer);
|
|||
|
||||
static void check_periodic_observations();
|
||||
static void update_callback(coap_callback_request_state_t *callback_state);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
set_rd_data(coap_message_t *request)
|
||||
set_rd_data(lwm2m_session_info_t *session_info)
|
||||
{
|
||||
lwm2m_buffer_t outbuf;
|
||||
|
||||
|
@ -155,31 +143,31 @@ set_rd_data(coap_message_t *request)
|
|||
outbuf.len = 0;
|
||||
|
||||
/* this will also set the request payload */
|
||||
rd_more = lwm2m_engine_set_rd_data(&outbuf, 0);
|
||||
coap_set_payload(request, rd_data, outbuf.len);
|
||||
session_info->rd_more = lwm2m_engine_set_rd_data(&outbuf, 0);
|
||||
coap_set_payload(session_info->request, rd_data, outbuf.len);
|
||||
|
||||
if(rd_more) {
|
||||
if(session_info->rd_more) {
|
||||
/* set the first block here */
|
||||
LOG_DBG("Setting block1 in request\n");
|
||||
coap_set_header_block1(request, 0, 1, sizeof(rd_data));
|
||||
coap_set_header_block1(session_info->request, 0, 1, sizeof(rd_data));
|
||||
}
|
||||
return outbuf.len;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
prepare_update(coap_message_t *request, int triggered)
|
||||
prepare_update(lwm2m_session_info_t *session_info, int triggered)
|
||||
{
|
||||
coap_init_message(request, COAP_TYPE_CON, COAP_POST, 0);
|
||||
coap_set_header_uri_path(request, session_info.assigned_ep);
|
||||
coap_init_message(session_info->request, COAP_TYPE_CON, COAP_POST, 0);
|
||||
coap_set_header_uri_path(session_info->request, session_info->assigned_ep);
|
||||
|
||||
snprintf(query_data, sizeof(query_data) - 1, "?lt=%d&b=%s", session_info.lifetime, session_info.binding);
|
||||
LOG_DBG("UPDATE:%s %s\n", session_info.assigned_ep, query_data);
|
||||
coap_set_header_uri_query(request, query_data);
|
||||
snprintf(query_data, sizeof(query_data) - 1, "?lt=%d&b=%s", session_info->lifetime, session_info->binding);
|
||||
LOG_DBG("UPDATE:%s %s\n", session_info->assigned_ep, query_data);
|
||||
coap_set_header_uri_query(session_info->request, query_data);
|
||||
|
||||
if((triggered || rd_flags & FLAG_RD_DATA_UPDATE_ON_DIRTY) && (rd_flags & FLAG_RD_DATA_DIRTY)) {
|
||||
rd_flags &= ~FLAG_RD_DATA_DIRTY;
|
||||
set_rd_data(request);
|
||||
rd_callback = update_callback;
|
||||
if((triggered || session_info->rd_flags & FLAG_RD_DATA_UPDATE_ON_DIRTY) && (session_info->rd_flags & FLAG_RD_DATA_DIRTY)) {
|
||||
session_info->rd_flags &= ~FLAG_RD_DATA_DIRTY;
|
||||
set_rd_data(session_info);
|
||||
session_info->rd_callback = update_callback;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -198,164 +186,152 @@ has_network_access(void)
|
|||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
lwm2m_rd_client_is_registered(void)
|
||||
lwm2m_rd_client_is_registered(lwm2m_session_info_t *session_info)
|
||||
{
|
||||
return rd_state == REGISTRATION_DONE || rd_state == UPDATE_SENT;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
lwm2m_rd_client_use_bootstrap_server(int use)
|
||||
{
|
||||
session_info.use_bootstrap = use != 0;
|
||||
if(session_info.use_bootstrap) {
|
||||
rd_state = INIT;
|
||||
}
|
||||
return session_info->rd_state == REGISTRATION_DONE || session_info->rd_state == UPDATE_SENT;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* will take another argument when we support multiple sessions */
|
||||
void
|
||||
lwm2m_rd_client_set_session_callback(session_callback_t cb)
|
||||
lwm2m_rd_client_set_session_callback(lwm2m_session_info_t *session_info, session_callback_t cb)
|
||||
{
|
||||
session_info.callback = cb;
|
||||
session_info->callback = cb;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
perform_session_callback(int state)
|
||||
perform_session_callback(lwm2m_session_info_t *session_info, int state)
|
||||
{
|
||||
if(session_info.callback != NULL) {
|
||||
if(session_info->callback != NULL) {
|
||||
LOG_DBG("Performing session callback: %d cb:%p\n",
|
||||
state, session_info.callback);
|
||||
session_info.callback(&session_info, state);
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
lwm2m_rd_client_use_registration_server(int use)
|
||||
{
|
||||
session_info.use_registration = use != 0;
|
||||
if(session_info.use_registration) {
|
||||
rd_state = INIT;
|
||||
state, session_info->callback);
|
||||
session_info->callback(session_info, state);
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
uint16_t
|
||||
lwm2m_rd_client_get_lifetime(void)
|
||||
lwm2m_rd_client_get_lifetime(lwm2m_session_info_t *session_info)
|
||||
{
|
||||
return session_info.lifetime;
|
||||
return session_info->lifetime;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
lwm2m_rd_client_set_lifetime(uint16_t lifetime)
|
||||
lwm2m_rd_client_set_lifetime(lwm2m_session_info_t *session_info, uint16_t lifetime)
|
||||
{
|
||||
if(lifetime > 0) {
|
||||
session_info.lifetime = lifetime;
|
||||
session_info->lifetime = lifetime;
|
||||
} else {
|
||||
session_info.lifetime = LWM2M_DEFAULT_CLIENT_LIFETIME;
|
||||
session_info->lifetime = LWM2M_DEFAULT_CLIENT_LIFETIME;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
lwm2m_rd_client_set_endpoint_name(lwm2m_session_info_t *session_info, const char *endpoint)
|
||||
{
|
||||
if(endpoint != NULL) {
|
||||
session_info->ep = endpoint;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
lwm2m_rd_client_set_default_endpoint_name(const char *endpoint)
|
||||
{
|
||||
strncpy(default_ep, endpoint, sizeof(default_ep) - 1);
|
||||
default_ep[sizeof(default_ep) - 1] = '\0';
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
lwm2m_rd_client_set_update_rd(void)
|
||||
{
|
||||
rd_flags |= FLAG_RD_DATA_DIRTY;
|
||||
lwm2m_session_info_t *session_info = (lwm2m_session_info_t *)list_head(session_info_list);
|
||||
while(session_info != NULL) {
|
||||
session_info->rd_flags |= FLAG_RD_DATA_DIRTY;
|
||||
session_info = session_info->next;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
lwm2m_rd_client_set_automatic_update(int update)
|
||||
lwm2m_rd_client_set_automatic_update(lwm2m_session_info_t *session_info, int update)
|
||||
{
|
||||
rd_flags = (rd_flags & ~FLAG_RD_DATA_UPDATE_ON_DIRTY) |
|
||||
session_info->rd_flags = (session_info->rd_flags & ~FLAG_RD_DATA_UPDATE_ON_DIRTY) |
|
||||
(update != 0 ? FLAG_RD_DATA_UPDATE_ON_DIRTY : 0);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
lwm2m_rd_client_register_with_server(const coap_endpoint_t *server)
|
||||
lwm2m_rd_client_register_with_server(lwm2m_session_info_t *session_info,
|
||||
const coap_endpoint_t *server,
|
||||
lwm2m_rd_client_server_type_t server_type)
|
||||
{
|
||||
coap_endpoint_copy(&session_info.server_ep, server);
|
||||
session_info.has_registration_server_info = 1;
|
||||
session_info.registered = 0;
|
||||
if(session_info.use_registration) {
|
||||
rd_state = INIT;
|
||||
if(session_info->ep == NULL) {
|
||||
session_info->ep = default_ep;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
update_registration_server(void)
|
||||
{
|
||||
if(session_info.has_registration_server_info) {
|
||||
return 1;
|
||||
/* default binding U = UDP, UQ = UDP Q-mode*/
|
||||
#if LWM2M_QUEUE_MODE_CONF_ENABLED
|
||||
session_info->binding = "UQ";
|
||||
/* Enough margin to ensure that the client is not unregistered (we
|
||||
* do not know the time it can stay awake)
|
||||
*/
|
||||
session_info->lifetime = (LWM2M_QUEUE_MODE_DEFAULT_CLIENT_SLEEP_TIME / 1000) * 2;
|
||||
#else
|
||||
session_info->binding = "U";
|
||||
if(session_info->lifetime == 0) {
|
||||
session_info->lifetime = LWM2M_DEFAULT_CLIENT_LIFETIME;
|
||||
}
|
||||
#endif /* LWM2M_QUEUE_MODE_CONF_ENABLED */
|
||||
|
||||
session_info->rd_flags = FLAG_RD_DATA_UPDATE_ON_DIRTY;
|
||||
session_info->has_bs_server_info = 0;
|
||||
session_info->has_registration_server_info = 0;
|
||||
session_info->wait_until_network_check = 0;
|
||||
session_info->last_update = 0;
|
||||
session_info->last_rd_progress = 0;
|
||||
session_info->bootstrapped = 0;
|
||||
session_info->rd_state = INIT;
|
||||
|
||||
if(server_type == LWM2M_RD_CLIENT_BOOTSTRAP_SERVER) {
|
||||
coap_endpoint_copy(&session_info->bs_server_ep, server);
|
||||
session_info->has_bs_server_info = 1;
|
||||
session_info->use_server_type = LWM2M_RD_CLIENT_BOOTSTRAP_SERVER;
|
||||
} else {
|
||||
coap_endpoint_copy(&session_info->server_ep, server);
|
||||
session_info->use_server_type = LWM2M_RD_CLIENT_LWM2M_SERVER;
|
||||
session_info->has_registration_server_info = 1;
|
||||
}
|
||||
|
||||
#if UIP_CONF_IPV6_RPL
|
||||
{
|
||||
rpl_dag_t *dag;
|
||||
|
||||
/* Use the DAG id as server address if no other has been specified */
|
||||
dag = rpl_get_any_dag();
|
||||
if(dag != NULL) {
|
||||
/* create coap-endpoint? */
|
||||
/* uip_ipaddr_copy(&server_ipaddr, &dag->dag_id); */
|
||||
/* server_port = REMOTE_PORT; */
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
#endif /* UIP_CONF_IPV6_RPL */
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
lwm2m_rd_client_register_with_bootstrap_server(const coap_endpoint_t *server)
|
||||
{
|
||||
coap_endpoint_copy(&session_info.bs_server_ep, server);
|
||||
session_info.has_bs_server_info = 1;
|
||||
session_info.bootstrapped = 0;
|
||||
session_info.registered = 0;
|
||||
if(session_info.use_bootstrap) {
|
||||
rd_state = INIT;
|
||||
}
|
||||
list_add(session_info_list, session_info); /* Add to the list of sessions */
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
lwm2m_rd_client_deregister(void)
|
||||
lwm2m_rd_client_deregister(lwm2m_session_info_t *session_info)
|
||||
{
|
||||
if(lwm2m_rd_client_is_registered()) {
|
||||
rd_state = DEREGISTER;
|
||||
if(lwm2m_rd_client_is_registered(session_info)) {
|
||||
session_info->rd_state = DEREGISTER;
|
||||
return 1;
|
||||
}
|
||||
/* Not registered */
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
lwm2m_rd_client_update_triggered(void)
|
||||
static lwm2m_session_info_t *
|
||||
get_session_info_from_server_ep(const coap_endpoint_t *server_ep)
|
||||
{
|
||||
rd_flags |= FLAG_RD_DATA_UPDATE_TRIGGERED;
|
||||
/* Here we need to do an CoAP timer poll - to get a quick request transmission! */
|
||||
lwm2m_session_info_t *session_info = (lwm2m_session_info_t *)list_head(session_info_list);
|
||||
while(session_info != NULL) {
|
||||
if(coap_endpoint_cmp(&session_info->server_ep, server_ep)) {
|
||||
return session_info;
|
||||
}
|
||||
session_info = session_info->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
update_bootstrap_server(void)
|
||||
void
|
||||
lwm2m_rd_client_update_triggered(const coap_endpoint_t *server_ep)
|
||||
{
|
||||
if(session_info.has_bs_server_info) {
|
||||
return 1;
|
||||
lwm2m_session_info_t *session_info = get_session_info_from_server_ep(server_ep);
|
||||
if(session_info) {
|
||||
session_info->rd_flags |= FLAG_RD_DATA_UPDATE_TRIGGERED;
|
||||
}
|
||||
|
||||
#if UIP_CONF_IPV6_RPL
|
||||
{
|
||||
rpl_dag_t *dag;
|
||||
|
||||
/* Use the DAG id as server address if no other has been specified */
|
||||
dag = rpl_get_any_dag();
|
||||
if(dag != NULL) {
|
||||
/* create coap endpoint */
|
||||
/* uip_ipaddr_copy(&bs_server_ipaddr, &dag->dag_id); */
|
||||
/* bs_server_port = REMOTE_PORT; */
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
#endif /* UIP_CONF_IPV6_RPL */
|
||||
|
||||
return 0;
|
||||
/* Here we need to do an CoAP timer poll - to get a quick request transmission! */
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
|
@ -373,29 +349,32 @@ bootstrap_callback(coap_callback_request_state_t *callback_state)
|
|||
{
|
||||
coap_request_state_t *state = &callback_state->state;
|
||||
LOG_DBG("Bootstrap callback Response: %d, ", state->response != NULL);
|
||||
|
||||
lwm2m_session_info_t *session_info = (lwm2m_session_info_t *)state->user_data;
|
||||
|
||||
if(state->status == COAP_REQUEST_STATUS_RESPONSE) {
|
||||
if(CHANGED_2_04 == state->response->code) {
|
||||
LOG_DBG_("Considered done!\n");
|
||||
rd_state = BOOTSTRAP_DONE;
|
||||
session_info->rd_state = BOOTSTRAP_DONE;
|
||||
return;
|
||||
}
|
||||
/* Possible error response codes are 4.00 Bad request & 4.15 Unsupported content format */
|
||||
LOG_DBG_("Failed with code %d. Retrying\n", state->response->code);
|
||||
/* TODO Application callback? */
|
||||
rd_state = INIT;
|
||||
session_info->rd_state = INIT;
|
||||
} else if(state->status == COAP_REQUEST_STATUS_TIMEOUT) {
|
||||
LOG_DBG_("Server not responding! Retry?");
|
||||
rd_state = DO_BOOTSTRAP;
|
||||
session_info->rd_state = DO_BOOTSTRAP;
|
||||
} else if(state->status == COAP_REQUEST_STATUS_FINISHED) {
|
||||
LOG_DBG_("Request finished. Ignore\n");
|
||||
} else {
|
||||
LOG_DBG_("Unexpected error! Retry?");
|
||||
rd_state = DO_BOOTSTRAP;
|
||||
session_info->rd_state = DO_BOOTSTRAP;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
produce_more_rd(void)
|
||||
produce_more_rd(lwm2m_session_info_t *session_info)
|
||||
{
|
||||
lwm2m_buffer_t outbuf;
|
||||
|
||||
|
@ -406,23 +385,23 @@ produce_more_rd(void)
|
|||
outbuf.size = sizeof(rd_data);
|
||||
outbuf.len = 0;
|
||||
|
||||
rd_block1++;
|
||||
session_info->rd_block1++;
|
||||
|
||||
/* this will also set the request payload */
|
||||
rd_more = lwm2m_engine_set_rd_data(&outbuf, rd_block1);
|
||||
coap_set_payload(request, rd_data, outbuf.len);
|
||||
session_info->rd_more = lwm2m_engine_set_rd_data(&outbuf, session_info->rd_block1);
|
||||
coap_set_payload(session_info->request, rd_data, outbuf.len);
|
||||
|
||||
LOG_DBG("Setting block1 in request - block: %d more: %d\n",
|
||||
(int)rd_block1, (int)rd_more);
|
||||
coap_set_header_block1(request, rd_block1, rd_more, sizeof(rd_data));
|
||||
(int)session_info->rd_block1, (int)session_info->rd_more);
|
||||
coap_set_header_block1(session_info->request, session_info->rd_block1, session_info->rd_more, sizeof(rd_data));
|
||||
|
||||
coap_send_request(&rd_request_state, &session_info.server_ep, request, rd_callback);
|
||||
coap_send_request(&session_info->rd_request_state, &session_info->server_ep, session_info->request, session_info->rd_callback);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
block1_rd_callback(coap_timer_t *timer)
|
||||
{
|
||||
produce_more_rd();
|
||||
produce_more_rd((lwm2m_session_info_t *)timer->user_data);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
|
@ -433,20 +412,24 @@ registration_callback(coap_callback_request_state_t *callback_state)
|
|||
{
|
||||
coap_request_state_t *state = &callback_state->state;
|
||||
LOG_DBG("Registration callback. Status: %d. Response: %d, ", state->status, state->response != NULL);
|
||||
lwm2m_session_info_t *session_info = (lwm2m_session_info_t *)state->user_data;
|
||||
|
||||
if(state->status == COAP_REQUEST_STATUS_RESPONSE) {
|
||||
/* check state and possibly set registration to done */
|
||||
/* If we get a continue - we need to call the rd generator one more time */
|
||||
|
||||
if(CONTINUE_2_31 == state->response->code) {
|
||||
/* We assume that size never change?! */
|
||||
coap_get_header_block1(state->response, &rd_block1, NULL, NULL, NULL);
|
||||
coap_timer_set_callback(&block1_timer, block1_rd_callback);
|
||||
coap_timer_set(&block1_timer, 1); /* delay 1 ms */
|
||||
coap_get_header_block1(state->response, &session_info->rd_block1, NULL, NULL, NULL);
|
||||
coap_timer_set_user_data(&session_info->block1_timer, (void *)session_info);
|
||||
coap_timer_set_callback(&session_info->block1_timer, block1_rd_callback);
|
||||
coap_timer_set(&session_info->block1_timer, 1); /* delay 1 ms */
|
||||
LOG_DBG_("Continue\n");
|
||||
} else if(CREATED_2_01 == state->response->code) {
|
||||
if(state->response->location_path_len < LWM2M_RD_CLIENT_ASSIGNED_ENDPOINT_MAX_LEN) {
|
||||
memcpy(session_info.assigned_ep, state->response->location_path,
|
||||
memcpy(session_info->assigned_ep, state->response->location_path,
|
||||
state->response->location_path_len);
|
||||
session_info.assigned_ep[state->response->location_path_len] = 0;
|
||||
session_info->assigned_ep[state->response->location_path_len] = 0;
|
||||
/* if we decide to not pass the lt-argument on registration, we should force an initial "update" to register lifetime with server */
|
||||
#if LWM2M_QUEUE_MODE_ENABLED
|
||||
#if LWM2M_QUEUE_MODE_INCLUDE_DYNAMIC_ADAPTATION
|
||||
|
@ -454,14 +437,14 @@ registration_callback(coap_callback_request_state_t *callback_state)
|
|||
lwm2m_queue_mode_set_first_request();
|
||||
}
|
||||
#endif
|
||||
lwm2m_rd_client_fsm_execute_queue_mode_awake(); /* Avoid 500 ms delay and move directly to the state*/
|
||||
lwm2m_rd_client_fsm_execute_queue_mode_awake(session_info); /* Avoid 500 ms delay and move directly to the state*/
|
||||
#else
|
||||
rd_state = REGISTRATION_DONE;
|
||||
session_info->rd_state = REGISTRATION_DONE;
|
||||
#endif
|
||||
/* remember the last reg time */
|
||||
last_update = coap_timer_uptime();
|
||||
LOG_DBG_("Done (assigned EP='%s')!\n", session_info.assigned_ep);
|
||||
perform_session_callback(LWM2M_RD_CLIENT_REGISTERED);
|
||||
session_info->last_update = coap_timer_uptime();
|
||||
LOG_DBG_("Done (assigned EP='%s')!\n", session_info->assigned_ep);
|
||||
perform_session_callback(session_info, LWM2M_RD_CLIENT_REGISTERED);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -474,15 +457,15 @@ registration_callback(coap_callback_request_state_t *callback_state)
|
|||
LOG_DBG_("failed with code %d. Re-init network\n", state->response->code);
|
||||
}
|
||||
/* TODO Application callback? */
|
||||
rd_state = INIT;
|
||||
session_info->rd_state = INIT;
|
||||
} else if(state->status == COAP_REQUEST_STATUS_TIMEOUT) {
|
||||
LOG_DBG_("Server not responding, trying to reconnect\n");
|
||||
rd_state = INIT;
|
||||
} else if(state->status == COAP_REQUEST_STATUS_FINISHED){
|
||||
session_info->rd_state = INIT;
|
||||
} else if(state->status == COAP_REQUEST_STATUS_FINISHED) {
|
||||
LOG_DBG_("Request finished. Ignore\n");
|
||||
} else {
|
||||
LOG_DBG_("Unexpected error, trying to reconnect\n");
|
||||
rd_state = INIT;
|
||||
session_info->rd_state = INIT;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -495,18 +478,20 @@ update_callback(coap_callback_request_state_t *callback_state)
|
|||
coap_request_state_t *state = &callback_state->state;
|
||||
LOG_DBG("Update callback. Status: %d. Response: %d, ", state->status, state->response != NULL);
|
||||
|
||||
lwm2m_session_info_t *session_info = (lwm2m_session_info_t *)state->user_data;
|
||||
|
||||
if(state->status == COAP_REQUEST_STATUS_RESPONSE) {
|
||||
/* If we get a continue - we need to call the rd generator one more time */
|
||||
if(CONTINUE_2_31 == state->response->code) {
|
||||
/* We assume that size never change?! */
|
||||
LOG_DBG_("Continue\n");
|
||||
coap_get_header_block1(state->response, &rd_block1, NULL, NULL, NULL);
|
||||
coap_timer_set_callback(&block1_timer, block1_rd_callback);
|
||||
coap_timer_set(&block1_timer, 1); /* delay 1 ms */
|
||||
coap_get_header_block1(state->response, &session_info->rd_block1, NULL, NULL, NULL);
|
||||
coap_timer_set_callback(&session_info->block1_timer, block1_rd_callback);
|
||||
coap_timer_set(&session_info->block1_timer, 1); /* delay 1 ms */
|
||||
} else if(CHANGED_2_04 == state->response->code) {
|
||||
LOG_DBG_("Done!\n");
|
||||
/* remember the last reg time */
|
||||
last_update = coap_timer_uptime();
|
||||
session_info->last_update = coap_timer_uptime();
|
||||
#if LWM2M_QUEUE_MODE_ENABLED
|
||||
/* If it has been waked up by a notification, send the stored notifications in queue */
|
||||
if(lwm2m_queue_mode_is_waked_up_by_notification()) {
|
||||
|
@ -519,25 +504,26 @@ update_callback(coap_callback_request_state_t *callback_state)
|
|||
lwm2m_queue_mode_set_first_request();
|
||||
}
|
||||
#endif /* LWM2M_QUEUE_MODE_INCLUDE_DYNAMIC_ADAPTATION */
|
||||
lwm2m_rd_client_fsm_execute_queue_mode_awake(); /* Avoid 500 ms delay and move directly to the state*/
|
||||
lwm2m_rd_client_fsm_execute_queue_mode_awake(session_info); /* Avoid 500 ms delay and move directly to the state*/
|
||||
#else
|
||||
rd_state = REGISTRATION_DONE;
|
||||
rd_flags &= ~FLAG_RD_DATA_UPDATE_TRIGGERED;
|
||||
#endif /* LWM2M_QUEUE_MODE_ENABLED */
|
||||
|
||||
session_info->rd_state = REGISTRATION_DONE;
|
||||
session_info->rd_flags &= ~FLAG_RD_DATA_UPDATE_TRIGGERED;
|
||||
#endif /* LWM2M_QUEUE_MODE_DEFAULT_CLIENT_SLEEP_TIME */
|
||||
} else {
|
||||
/* Possible error response codes are 4.00 Bad request & 4.04 Not Found */
|
||||
LOG_DBG_("Failed with code %d. Retrying registration\n",
|
||||
state->response->code);
|
||||
rd_state = DO_REGISTRATION;
|
||||
session_info->rd_state = DO_REGISTRATION;
|
||||
}
|
||||
} else if(state->status == COAP_REQUEST_STATUS_TIMEOUT) {
|
||||
LOG_DBG_("Server not responding, trying to reconnect\n");
|
||||
rd_state = INIT;
|
||||
} else if(state->status == COAP_REQUEST_STATUS_FINISHED){
|
||||
session_info->rd_state = INIT;
|
||||
} else if(state->status == COAP_REQUEST_STATUS_FINISHED) {
|
||||
LOG_DBG_("Request finished. Ignore\n");
|
||||
} else {
|
||||
LOG_DBG_("Unexpected error, trying to reconnect\n");
|
||||
rd_state = INIT;
|
||||
session_info->rd_state = INIT;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -549,19 +535,49 @@ deregister_callback(coap_callback_request_state_t *callback_state)
|
|||
state->status,
|
||||
state->response != NULL ? state->response->code : 0);
|
||||
|
||||
lwm2m_session_info_t *session_info = (lwm2m_session_info_t *)state->user_data;
|
||||
|
||||
if(state->status == COAP_REQUEST_STATUS_RESPONSE && (DELETED_2_02 == state->response->code)) {
|
||||
LOG_DBG("Deregistration success\n");
|
||||
rd_state = DEREGISTERED;
|
||||
perform_session_callback(LWM2M_RD_CLIENT_DEREGISTERED);
|
||||
session_info->rd_state = DEREGISTERED;
|
||||
perform_session_callback(session_info, LWM2M_RD_CLIENT_DEREGISTERED);
|
||||
} else {
|
||||
LOG_DBG("Deregistration failed\n");
|
||||
if(rd_state == DEREGISTER_SENT) {
|
||||
rd_state = DEREGISTER_FAILED;
|
||||
perform_session_callback(LWM2M_RD_CLIENT_DEREGISTER_FAILED);
|
||||
if(session_info->rd_state == DEREGISTER_SENT) {
|
||||
session_info->rd_state = DEREGISTER_FAILED;
|
||||
perform_session_callback(session_info, LWM2M_RD_CLIENT_DEREGISTER_FAILED);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if LWM2M_QUEUE_MODE_ENABLED
|
||||
static int
|
||||
all_sessions_in_queue_mode_state(void)
|
||||
{
|
||||
lwm2m_session_info_t *session_info = (lwm2m_session_info_t *)list_head(session_info_list);
|
||||
while(session_info != NULL) {
|
||||
if(((session_info->rd_state & 0xF) != 0xE)) {
|
||||
return 0;
|
||||
}
|
||||
session_info = session_info->next;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
all_sessions_in_queue_mode_awake(void)
|
||||
{
|
||||
lwm2m_session_info_t *session_info = (lwm2m_session_info_t *)list_head(session_info_list);
|
||||
while(session_info != NULL) {
|
||||
if(session_info->rd_state != QUEUE_MODE_AWAKE) {
|
||||
return 0;
|
||||
}
|
||||
session_info = session_info->next;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
#endif /* LWM2M_QUEUE_MODE_ENABLED */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CoAP timer callback */
|
||||
static void
|
||||
periodic_process(coap_timer_t *timer)
|
||||
|
@ -571,7 +587,7 @@ periodic_process(coap_timer_t *timer)
|
|||
/* reschedule the CoAP timer */
|
||||
#if LWM2M_QUEUE_MODE_ENABLED
|
||||
/* In Queue Mode, the machine is not executed periodically, but with the awake/sleeping times */
|
||||
if(!((rd_state & 0xF) == 0xE)) {
|
||||
if(!all_sessions_in_queue_mode_state()) {
|
||||
coap_timer_reset(&rd_timer, STATE_MACHINE_UPDATE_INTERVAL);
|
||||
}
|
||||
#else
|
||||
|
@ -580,48 +596,53 @@ periodic_process(coap_timer_t *timer)
|
|||
|
||||
now = coap_timer_uptime();
|
||||
|
||||
LOG_DBG("RD Client - state: %d, ms: %lu\n", rd_state,
|
||||
lwm2m_session_info_t *session_info = (lwm2m_session_info_t *)list_head(session_info_list);
|
||||
while(session_info != NULL) {
|
||||
|
||||
LOG_DBG("RD Client with assigned ep: %s - state: %d, ms: %lu\n", session_info->assigned_ep, session_info->rd_state,
|
||||
(unsigned long)coap_timer_uptime());
|
||||
|
||||
switch(rd_state) {
|
||||
switch(session_info->rd_state) {
|
||||
case INIT:
|
||||
LOG_DBG("RD Client started with endpoint '%s' and client lifetime %d\n", session_info.ep, session_info.lifetime);
|
||||
rd_state = WAIT_NETWORK;
|
||||
LOG_DBG("RD Client started with endpoint '%s' and client lifetime %d\n", session_info->ep, session_info->lifetime);
|
||||
session_info->rd_state = WAIT_NETWORK;
|
||||
break;
|
||||
case WAIT_NETWORK:
|
||||
if(now > wait_until_network_check) {
|
||||
if(now > session_info->wait_until_network_check) {
|
||||
/* check each 10 seconds before next check */
|
||||
LOG_DBG("Checking for network... %lu\n",
|
||||
(unsigned long)wait_until_network_check);
|
||||
wait_until_network_check = now + 10000;
|
||||
(unsigned long)session_info->wait_until_network_check);
|
||||
session_info->wait_until_network_check = now + 10000;
|
||||
if(has_network_access()) {
|
||||
/* Either do bootstrap then registration */
|
||||
if(session_info.use_bootstrap) {
|
||||
rd_state = DO_BOOTSTRAP;
|
||||
if(session_info->use_server_type == LWM2M_RD_CLIENT_BOOTSTRAP_SERVER) {
|
||||
session_info->rd_state = DO_BOOTSTRAP;
|
||||
} else {
|
||||
rd_state = DO_REGISTRATION;
|
||||
session_info->rd_state = DO_REGISTRATION;
|
||||
}
|
||||
}
|
||||
/* Otherwise wait until for a network to join */
|
||||
}
|
||||
break;
|
||||
case DO_BOOTSTRAP:
|
||||
if(session_info.use_bootstrap && session_info.bootstrapped == 0) {
|
||||
if(update_bootstrap_server()) {
|
||||
if(session_info->use_server_type == LWM2M_RD_CLIENT_BOOTSTRAP_SERVER &&
|
||||
session_info->bootstrapped == 0 &&
|
||||
session_info->has_bs_server_info) {
|
||||
|
||||
/* prepare request, TID is set by COAP_BLOCKING_REQUEST() */
|
||||
coap_init_message(request, COAP_TYPE_CON, COAP_POST, 0);
|
||||
coap_set_header_uri_path(request, "/bs");
|
||||
coap_init_message(session_info->request, COAP_TYPE_CON, COAP_POST, 0);
|
||||
coap_set_header_uri_path(session_info->request, "/bs");
|
||||
|
||||
snprintf(query_data, sizeof(query_data) - 1, "?ep=%s", session_info.ep);
|
||||
coap_set_header_uri_query(request, query_data);
|
||||
snprintf(query_data, sizeof(query_data) - 1, "?ep=%s", session_info->ep);
|
||||
coap_set_header_uri_query(session_info->request, query_data);
|
||||
LOG_INFO("Registering ID with bootstrap server [");
|
||||
LOG_INFO_COAP_EP(&session_info.bs_server_ep);
|
||||
LOG_INFO_COAP_EP(&session_info->bs_server_ep);
|
||||
LOG_INFO_("] as '%s'\n", query_data);
|
||||
|
||||
if(coap_send_request(&rd_request_state, &session_info.bs_server_ep,
|
||||
request, bootstrap_callback)) {
|
||||
rd_state = BOOTSTRAP_SENT;
|
||||
}
|
||||
/* Add session info as user data to use it in the callbacks */
|
||||
session_info->rd_request_state.state.user_data = (void *)session_info;
|
||||
if(coap_send_request(&session_info->rd_request_state, &session_info->bs_server_ep,
|
||||
session_info->request, bootstrap_callback)) {
|
||||
session_info->rd_state = BOOTSTRAP_SENT;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -630,7 +651,7 @@ periodic_process(coap_timer_t *timer)
|
|||
break;
|
||||
case BOOTSTRAP_DONE:
|
||||
/* check that we should still use bootstrap */
|
||||
if(session_info.use_bootstrap) {
|
||||
if(session_info->use_server_type == LWM2M_RD_CLIENT_BOOTSTRAP_SERVER) {
|
||||
lwm2m_security_server_t *security;
|
||||
LOG_DBG("*** Bootstrap - checking for server info...\n");
|
||||
/* get the security object - ignore bootstrap servers */
|
||||
|
@ -658,17 +679,17 @@ periodic_process(coap_timer_t *timer)
|
|||
|
||||
if(!coap_endpoint_parse((const char *)security->server_uri,
|
||||
security->server_uri_len,
|
||||
&session_info.server_ep)) {
|
||||
&session_info->server_ep)) {
|
||||
LOG_DBG("Failed to parse server URI!\n");
|
||||
} else {
|
||||
LOG_DBG("Server address:");
|
||||
LOG_DBG_COAP_EP(&session_info.server_ep);
|
||||
LOG_DBG_COAP_EP(&session_info->server_ep);
|
||||
LOG_DBG_("\n");
|
||||
if(secure) {
|
||||
LOG_DBG("Secure CoAP requested but not supported - can not bootstrap\n");
|
||||
} else {
|
||||
lwm2m_rd_client_register_with_server(&session_info.server_ep);
|
||||
session_info.bootstrapped++;
|
||||
lwm2m_rd_client_register_with_server(session_info, &session_info->server_ep, LWM2M_RD_CLIENT_LWM2M_SERVER);
|
||||
session_info->bootstrapped++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -680,47 +701,53 @@ periodic_process(coap_timer_t *timer)
|
|||
}
|
||||
|
||||
/* if we did not register above - then fail this and restart... */
|
||||
if(session_info.bootstrapped == 0) {
|
||||
if(session_info->bootstrapped == 0) {
|
||||
/* Not ready. Lets retry with the bootstrap server again */
|
||||
rd_state = DO_BOOTSTRAP;
|
||||
session_info->rd_state = DO_BOOTSTRAP;
|
||||
} else {
|
||||
rd_state = DO_REGISTRATION;
|
||||
session_info->rd_state = DO_REGISTRATION;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DO_REGISTRATION:
|
||||
if(!coap_endpoint_is_connected(&session_info.server_ep)) {
|
||||
if(!coap_endpoint_is_connected(&session_info->server_ep)) {
|
||||
/* Not connected... wait a bit... and retry connection */
|
||||
coap_endpoint_connect(&session_info.server_ep);
|
||||
coap_endpoint_connect(&session_info->server_ep);
|
||||
LOG_DBG("Wait until connected... \n");
|
||||
return;
|
||||
}
|
||||
if(session_info.use_registration && !session_info.registered &&
|
||||
update_registration_server()) {
|
||||
|
||||
if(session_info->use_server_type == LWM2M_RD_CLIENT_LWM2M_SERVER &&
|
||||
!lwm2m_rd_client_is_registered(session_info) &&
|
||||
session_info->has_registration_server_info) {
|
||||
int len;
|
||||
|
||||
/* prepare request, TID was set by COAP_BLOCKING_REQUEST() */
|
||||
coap_init_message(request, COAP_TYPE_CON, COAP_POST, 0);
|
||||
coap_set_header_uri_path(request, "/rd");
|
||||
coap_init_message(session_info->request, COAP_TYPE_CON, COAP_POST, 0);
|
||||
coap_set_header_uri_path(session_info->request, "/rd");
|
||||
|
||||
snprintf(query_data, sizeof(query_data) - 1, "?ep=%s<=%d&b=%s", session_info.ep, session_info.lifetime, session_info.binding);
|
||||
coap_set_header_uri_query(request, query_data);
|
||||
snprintf(query_data, sizeof(query_data) - 1, "?ep=%s<=%d&b=%s", session_info->ep, session_info->lifetime, session_info->binding);
|
||||
coap_set_header_uri_query(session_info->request, query_data);
|
||||
|
||||
len = set_rd_data(request);
|
||||
rd_callback = registration_callback;
|
||||
len = set_rd_data(session_info);
|
||||
session_info->rd_callback = registration_callback;
|
||||
|
||||
LOG_INFO("Registering with [");
|
||||
LOG_INFO_COAP_EP(&session_info.server_ep);
|
||||
LOG_INFO_COAP_EP(&session_info->server_ep);
|
||||
LOG_INFO_("] lwm2m endpoint '%s': '", query_data);
|
||||
if(len) {
|
||||
LOG_INFO_COAP_STRING((const char *)rd_data, len);
|
||||
}
|
||||
LOG_INFO_("' More:%d\n", rd_more);
|
||||
LOG_INFO_("' More:%d\n", session_info->rd_more);
|
||||
|
||||
if(coap_send_request(&rd_request_state, &session_info.server_ep,
|
||||
request, registration_callback)){
|
||||
rd_state = REGISTRATION_SENT;
|
||||
/* Add session info as user data to use it in the callbacks */
|
||||
session_info->rd_request_state.state.user_data = (void *)session_info;
|
||||
if(coap_send_request(&session_info->rd_request_state, &session_info->server_ep,
|
||||
session_info->request, registration_callback)) {
|
||||
|
||||
session_info->rd_state = REGISTRATION_SENT;
|
||||
}
|
||||
session_info->last_rd_progress = coap_timer_uptime();
|
||||
}
|
||||
break;
|
||||
case REGISTRATION_SENT:
|
||||
|
@ -732,35 +759,44 @@ periodic_process(coap_timer_t *timer)
|
|||
check_periodic_observations(); /* TODO: manage periodic observations */
|
||||
|
||||
/* check if it is time for the next update */
|
||||
if((rd_flags & FLAG_RD_DATA_UPDATE_TRIGGERED) ||
|
||||
((uint32_t)session_info.lifetime * 500) <= now - last_update) {
|
||||
if((session_info->rd_flags & FLAG_RD_DATA_UPDATE_TRIGGERED) ||
|
||||
((uint32_t)session_info->lifetime * 500) <= now - session_info->last_update) {
|
||||
/* triggered or time to send an update to the server, at half-time! sec vs ms */
|
||||
prepare_update(request, rd_flags & FLAG_RD_DATA_UPDATE_TRIGGERED);
|
||||
if(coap_send_request(&rd_request_state, &session_info.server_ep, request,
|
||||
prepare_update(session_info, session_info->rd_flags & FLAG_RD_DATA_UPDATE_TRIGGERED);
|
||||
|
||||
/* Add session info as user data to use it in the callbacks */
|
||||
session_info->rd_request_state.state.user_data = (void *)session_info;
|
||||
if(coap_send_request(&session_info->rd_request_state, &session_info->server_ep, session_info->request,
|
||||
update_callback)) {
|
||||
rd_state = UPDATE_SENT;
|
||||
session_info->rd_state = UPDATE_SENT;
|
||||
}
|
||||
session_info->last_rd_progress = coap_timer_uptime();
|
||||
}
|
||||
break;
|
||||
|
||||
#if LWM2M_QUEUE_MODE_ENABLED
|
||||
case QUEUE_MODE_AWAKE:
|
||||
LOG_DBG("Queue Mode: Client is AWAKE at %lu\n", (unsigned long)coap_timer_uptime());
|
||||
queue_mode_client_awake = 1;
|
||||
if((queue_mode_client_awake = all_sessions_in_queue_mode_awake())) {
|
||||
queue_mode_client_awake_time = lwm2m_queue_mode_get_awake_time();
|
||||
coap_timer_set(&queue_mode_client_awake_timer, queue_mode_client_awake_time);
|
||||
}
|
||||
break;
|
||||
case QUEUE_MODE_SEND_UPDATE:
|
||||
/* Define this macro to make the necessary actions for waking up,
|
||||
/* Define this macro to make the necessary actions for waking up,
|
||||
* depending on the platform
|
||||
*/
|
||||
#ifdef LWM2M_QUEUE_MODE_WAKE_UP
|
||||
LWM2M_QUEUE_MODE_WAKE_UP();
|
||||
#endif /* LWM2M_QUEUE_MODE_WAKE_UP */
|
||||
prepare_update(request, rd_flags & FLAG_RD_DATA_UPDATE_TRIGGERED);
|
||||
if(coap_send_request(&rd_request_state, &session_info.server_ep, request,
|
||||
prepare_update(session_info, session_info->rd_flags & FLAG_RD_DATA_UPDATE_TRIGGERED);
|
||||
/* Add session info as user data to use it in the callbacks */
|
||||
session_info->rd_request_state.state.user_data = (void *)session_info;
|
||||
if(coap_send_request(&session_info->rd_request_state, &session_info->server_ep, session_info->request,
|
||||
update_callback)) {
|
||||
rd_state = UPDATE_SENT;
|
||||
session_info->rd_state = UPDATE_SENT;
|
||||
}
|
||||
session_info->last_rd_progress = coap_timer_uptime();
|
||||
break;
|
||||
#endif /* LWM2M_QUEUE_MODE_ENABLED */
|
||||
|
||||
|
@ -768,12 +804,15 @@ periodic_process(coap_timer_t *timer)
|
|||
/* just wait until the callback kicks us to the next state... */
|
||||
break;
|
||||
case DEREGISTER:
|
||||
LOG_INFO("DEREGISTER %s\n", session_info.assigned_ep);
|
||||
coap_init_message(request, COAP_TYPE_CON, COAP_DELETE, 0);
|
||||
coap_set_header_uri_path(request, session_info.assigned_ep);
|
||||
if(coap_send_request(&rd_request_state, &session_info.server_ep, request,
|
||||
LOG_INFO("DEREGISTER %s\n", session_info->assigned_ep);
|
||||
coap_init_message(session_info->request, COAP_TYPE_CON, COAP_DELETE, 0);
|
||||
coap_set_header_uri_path(session_info->request, session_info->assigned_ep);
|
||||
|
||||
/* Add session info as user data to use it in the callbacks */
|
||||
session_info->rd_request_state.state.user_data = (void *)session_info;
|
||||
if(coap_send_request(&session_info->rd_request_state, &session_info->server_ep, session_info->request,
|
||||
deregister_callback)) {
|
||||
rd_state = DEREGISTER_SENT;
|
||||
session_info->rd_state = DEREGISTER_SENT;
|
||||
}
|
||||
break;
|
||||
case DEREGISTER_SENT:
|
||||
|
@ -784,29 +823,16 @@ periodic_process(coap_timer_t *timer)
|
|||
break;
|
||||
|
||||
default:
|
||||
LOG_WARN("Unhandled state: %d\n", rd_state);
|
||||
LOG_WARN("Unhandled state: %d\n", session_info->rd_state);
|
||||
}
|
||||
session_info = session_info->next;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
lwm2m_rd_client_init(const char *ep)
|
||||
{
|
||||
session_info.ep = ep;
|
||||
/* default binding U = UDP, UQ = UDP Q-mode*/
|
||||
#if LWM2M_QUEUE_MODE_ENABLED
|
||||
session_info.binding = "UQ";
|
||||
/* Enough margin to ensure that the client is not unregistered (we
|
||||
* do not know the time it can stay awake)
|
||||
*/
|
||||
session_info.lifetime = (LWM2M_QUEUE_MODE_DEFAULT_CLIENT_SLEEP_TIME / 1000) * 2;
|
||||
#else
|
||||
session_info.binding = "U";
|
||||
if(session_info.lifetime == 0) {
|
||||
session_info.lifetime = LWM2M_DEFAULT_CLIENT_LIFETIME;
|
||||
}
|
||||
#endif
|
||||
|
||||
rd_state = INIT;
|
||||
lwm2m_rd_client_set_default_endpoint_name(ep);
|
||||
|
||||
/* call the RD client periodically */
|
||||
coap_timer_set_callback(&rd_timer, periodic_process);
|
||||
|
@ -823,7 +849,7 @@ check_periodic_observations(void)
|
|||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
*Queue Mode Support
|
||||
* Queue Mode Support
|
||||
*/
|
||||
#if LWM2M_QUEUE_MODE_ENABLED
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -846,27 +872,31 @@ queue_mode_awake_timer_callback(coap_timer_t *timer)
|
|||
LOG_DBG("Queue Mode: Client is SLEEPING at %lu\n", (unsigned long)coap_timer_uptime());
|
||||
queue_mode_client_awake = 0;
|
||||
|
||||
/* Define this macro to enter sleep mode depending on the platform */
|
||||
lwm2m_session_info_t *session_info = (lwm2m_session_info_t *)list_head(session_info_list);
|
||||
while(session_info != NULL) {
|
||||
session_info->rd_state = QUEUE_MODE_SEND_UPDATE;
|
||||
session_info = session_info->next;
|
||||
}
|
||||
coap_timer_set(&rd_timer, lwm2m_queue_mode_get_sleep_time());
|
||||
/* Define this macro to enter sleep mode depending on the platform */
|
||||
#ifdef LWM2M_QUEUE_MODE_SLEEP_MS
|
||||
LWM2M_QUEUE_MODE_SLEEP_MS(lwm2m_queue_mode_get_sleep_time());
|
||||
#endif /* LWM2M_QUEUE_MODE_SLEEP_MS */
|
||||
rd_state = QUEUE_MODE_SEND_UPDATE;
|
||||
coap_timer_set(&rd_timer, lwm2m_queue_mode_get_sleep_time());
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
lwm2m_rd_client_fsm_execute_queue_mode_awake()
|
||||
lwm2m_rd_client_fsm_execute_queue_mode_awake(lwm2m_session_info_t *session_info)
|
||||
{
|
||||
coap_timer_stop(&rd_timer);
|
||||
rd_state = QUEUE_MODE_AWAKE;
|
||||
session_info->rd_state = QUEUE_MODE_AWAKE;
|
||||
periodic_process(&rd_timer);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
lwm2m_rd_client_fsm_execute_queue_mode_update()
|
||||
lwm2m_rd_client_fsm_execute_queue_mode_update(lwm2m_session_info_t *session_info)
|
||||
{
|
||||
coap_timer_stop(&rd_timer);
|
||||
rd_state = QUEUE_MODE_SEND_UPDATE;
|
||||
session_info->rd_state = QUEUE_MODE_SEND_UPDATE;
|
||||
periodic_process(&rd_timer);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
|
@ -46,6 +46,13 @@
|
|||
#ifndef LWM2M_RD_CLIENT_H_
|
||||
#define LWM2M_RD_CLIENT_H_
|
||||
|
||||
/* The type of server to use for registration: bootstrap or LWM2M */
|
||||
typedef enum {
|
||||
LWM2M_RD_CLIENT_BOOTSTRAP_SERVER,
|
||||
LWM2M_RD_CLIENT_LWM2M_SERVER
|
||||
} lwm2m_rd_client_server_type_t;
|
||||
|
||||
/* Session callback states */
|
||||
#define LWM2M_RD_CLIENT_BOOTSTRAPPED 1
|
||||
#define LWM2M_RD_CLIENT_REGISTERED 2
|
||||
#define LWM2M_RD_CLIENT_DEREGISTERED 3
|
||||
|
@ -54,28 +61,70 @@
|
|||
|
||||
#include "lwm2m-object.h"
|
||||
#include "lwm2m-queue-mode-conf.h"
|
||||
#include "coap-endpoint.h"
|
||||
#include "coap-callback-api.h"
|
||||
|
||||
struct lwm2m_session_info;
|
||||
typedef void (*session_callback_t)(struct lwm2m_session_info *session, int status);
|
||||
|
||||
int lwm2m_rd_client_is_registered(void);
|
||||
void lwm2m_rd_client_use_bootstrap_server(int use);
|
||||
void lwm2m_rd_client_use_registration_server(int use);
|
||||
void lwm2m_rd_client_register_with_server(const coap_endpoint_t *server);
|
||||
void lwm2m_rd_client_register_with_bootstrap_server(const coap_endpoint_t *server);
|
||||
uint16_t lwm2m_rd_client_get_lifetime(void);
|
||||
void lwm2m_rd_client_set_lifetime(uint16_t lifetime);
|
||||
#ifndef LWM2M_RD_CLIENT_ASSIGNED_ENDPOINT_MAX_LEN
|
||||
#define LWM2M_RD_CLIENT_ASSIGNED_ENDPOINT_MAX_LEN 15
|
||||
#endif /* LWM2M_RD_CLIENT_ASSIGNED_ENDPOINT_MAX_LEN */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*- Server session----------------------------*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
typedef struct lwm2m_session_info {
|
||||
|
||||
struct lwm2m_session_info *next;
|
||||
/* Information */
|
||||
const char *ep;
|
||||
const char *binding;
|
||||
char assigned_ep[LWM2M_RD_CLIENT_ASSIGNED_ENDPOINT_MAX_LEN];
|
||||
uint16_t lifetime;
|
||||
coap_endpoint_t bs_server_ep;
|
||||
coap_endpoint_t server_ep;
|
||||
lwm2m_rd_client_server_type_t use_server_type;
|
||||
uint8_t has_bs_server_info;
|
||||
uint8_t has_registration_server_info;
|
||||
uint8_t bootstrapped; /* bootstrap done */
|
||||
session_callback_t callback;
|
||||
|
||||
/* CoAP Request */
|
||||
coap_callback_request_state_t rd_request_state;
|
||||
coap_message_t request[1]; /* This way the message can be treated as pointer as usual. */
|
||||
|
||||
/* RD parameters */
|
||||
uint8_t rd_state;
|
||||
uint8_t rd_flags;
|
||||
uint64_t wait_until_network_check;
|
||||
uint64_t last_update;
|
||||
uint64_t last_rd_progress;
|
||||
|
||||
/* Blosk Transfer */
|
||||
uint32_t rd_block1;
|
||||
uint8_t rd_more;
|
||||
void (*rd_callback)(coap_callback_request_state_t *state);
|
||||
coap_timer_t block1_timer;
|
||||
} lwm2m_session_info_t;
|
||||
|
||||
int lwm2m_rd_client_is_registered(lwm2m_session_info_t *session_info);
|
||||
void lwm2m_rd_client_register_with_server(lwm2m_session_info_t *session_info, const coap_endpoint_t *server, lwm2m_rd_client_server_type_t server_type);
|
||||
uint16_t lwm2m_rd_client_get_lifetime(lwm2m_session_info_t *session_info);
|
||||
void lwm2m_rd_client_set_lifetime(lwm2m_session_info_t *session_info, uint16_t lifetime);
|
||||
void lwm2m_rd_client_set_endpoint_name(lwm2m_session_info_t *session_info, const char *endpoint);
|
||||
void lwm2m_rd_client_set_default_endpoint_name(const char *endpoint);
|
||||
|
||||
/* Indicate that something in the object list have changed */
|
||||
void lwm2m_rd_client_set_update_rd(void);
|
||||
/* Control if the object list should be automatically updated at updates of lifetime */
|
||||
void lwm2m_rd_client_set_automatic_update(int update);
|
||||
void lwm2m_rd_client_set_automatic_update(lwm2m_session_info_t *session_info, int update);
|
||||
/* trigger an immediate update */
|
||||
void lwm2m_rd_client_update_triggered(void);
|
||||
void lwm2m_rd_client_update_triggered(const coap_endpoint_t *server_ep);
|
||||
|
||||
int lwm2m_rd_client_deregister(void);
|
||||
int lwm2m_rd_client_deregister(lwm2m_session_info_t *session_info);
|
||||
void lwm2m_rd_client_init(const char *ep);
|
||||
|
||||
void lwm2m_rd_client_set_session_callback(session_callback_t cb);
|
||||
void lwm2m_rd_client_set_session_callback(lwm2m_session_info_t *session_info, session_callback_t cb);
|
||||
|
||||
#if LWM2M_QUEUE_MODE_ENABLED
|
||||
uint8_t lwm2m_rd_client_is_client_awake(void);
|
||||
|
@ -84,28 +133,5 @@ void lwm2m_rd_client_fsm_execute_queue_mode_awake();
|
|||
void lwm2m_rd_client_fsm_execute_queue_mode_update();
|
||||
#endif
|
||||
|
||||
#ifndef LWM2M_RD_CLIENT_ASSIGNED_ENDPOINT_MAX_LEN
|
||||
#define LWM2M_RD_CLIENT_ASSIGNED_ENDPOINT_MAX_LEN 15
|
||||
#endif /* LWM2M_RD_CLIENT_ASSIGNED_ENDPOINT_MAX_LEN */
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*- Server session-*Currently single session only*---------------------------*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
struct lwm2m_session_info {
|
||||
const char *ep;
|
||||
const char *binding;
|
||||
char assigned_ep[LWM2M_RD_CLIENT_ASSIGNED_ENDPOINT_MAX_LEN];
|
||||
uint16_t lifetime;
|
||||
coap_endpoint_t bs_server_ep;
|
||||
coap_endpoint_t server_ep;
|
||||
uint8_t use_bootstrap;
|
||||
uint8_t has_bs_server_info;
|
||||
uint8_t use_registration;
|
||||
uint8_t has_registration_server_info;
|
||||
uint8_t registered;
|
||||
uint8_t bootstrapped; /* bootstrap done */
|
||||
session_callback_t callback;
|
||||
};
|
||||
|
||||
#endif /* LWM2M_RD_CLIENT_H_ */
|
||||
/** @} */
|
||||
|
|
|
@ -221,7 +221,7 @@ lwm2m_callback(lwm2m_object_instance_t *object,
|
|||
} else if(ctx->operation == LWM2M_OP_EXECUTE) {
|
||||
switch(ctx->resource_id) {
|
||||
case LWM2M_SERVER_REG_UPDATE_TRIGGER_ID:
|
||||
lwm2m_rd_client_update_triggered();
|
||||
lwm2m_rd_client_update_triggered(ctx->request->src_ep);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -142,14 +142,20 @@ slip_config_handle_arguments(int argc, char **argv)
|
|||
fprintf(stderr, " -a host Connect via TCP to server at <host>\n");
|
||||
fprintf(stderr, " -p port Connect via TCP to server at <host>:<port>\n");
|
||||
fprintf(stderr, " -t tundev Name of interface (default tun0)\n");
|
||||
#ifdef __APPLE__
|
||||
fprintf(stderr, " -v level Verbosity level\n");
|
||||
#else
|
||||
fprintf(stderr, " -v[level] Verbosity level\n");
|
||||
#endif
|
||||
fprintf(stderr, " -v0 No messages\n");
|
||||
fprintf(stderr, " -v1 Encapsulated SLIP debug messages (default)\n");
|
||||
fprintf(stderr, " -v2 Printable strings after they are received\n");
|
||||
fprintf(stderr, " -v3 Printable strings and SLIP packet notifications\n");
|
||||
fprintf(stderr, " -v4 All printable characters as they are received\n");
|
||||
fprintf(stderr, " -v5 All SLIP packets in hex\n");
|
||||
#ifndef __APPLE__
|
||||
fprintf(stderr, " -v Equivalent to -v3\n");
|
||||
#endif
|
||||
fprintf(stderr, " -d[basedelay] Minimum delay between outgoing SLIP packets.\n");
|
||||
fprintf(stderr, " Actual delay is basedelay*(#6LowPAN fragments) milliseconds.\n");
|
||||
fprintf(stderr, " -d is equivalent to -d10.\n");
|
||||
|
|
|
@ -0,0 +1,294 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<simconf>
|
||||
<project EXPORT="discard">[APPS_DIR]/mrm</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/mspsim</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/avrora</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/serial_socket</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/powertracker</project>
|
||||
<simulation>
|
||||
<title>My simulation</title>
|
||||
<speedlimit>10.0</speedlimit>
|
||||
<randomseed>123456</randomseed>
|
||||
<motedelay_us>1000000</motedelay_us>
|
||||
<radiomedium>
|
||||
org.contikios.cooja.radiomediums.UDGM
|
||||
<transmitting_range>50.0</transmitting_range>
|
||||
<interference_range>100.0</interference_range>
|
||||
<success_ratio_tx>1.0</success_ratio_tx>
|
||||
<success_ratio_rx>1.0</success_ratio_rx>
|
||||
</radiomedium>
|
||||
<events>
|
||||
<logoutput>40000</logoutput>
|
||||
</events>
|
||||
<motetype>
|
||||
org.contikios.cooja.contikimote.ContikiMoteType
|
||||
<identifier>mtype34</identifier>
|
||||
<description>mote</description>
|
||||
<source>[CONTIKI_DIR]/examples/libs/shell/example.c</source>
|
||||
<commands>make example.cooja TARGET=cooja MAKE_ROUTING=MAKE_ROUTING_RPL_LITE -j</commands>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Battery</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiVib</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiMoteID</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRS232</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiBeeper</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiIPAddress</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRadio</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiButton</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiPIR</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiClock</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiLED</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiCFS</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiEEPROM</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface>
|
||||
<symbols>false</symbols>
|
||||
</motetype>
|
||||
<mote>
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>50.0</x>
|
||||
<y>0.0</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiMoteID
|
||||
<id>3</id>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiRadio
|
||||
<bitrate>250.0</bitrate>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiEEPROM
|
||||
<eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom>
|
||||
</interface_config>
|
||||
<motetype_identifier>mtype34</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>100.0</x>
|
||||
<y>0.0</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiMoteID
|
||||
<id>2</id>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiRadio
|
||||
<bitrate>250.0</bitrate>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiEEPROM
|
||||
<eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom>
|
||||
</interface_config>
|
||||
<motetype_identifier>mtype34</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>150.0</x>
|
||||
<y>0.0</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiMoteID
|
||||
<id>1</id>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiRS232
|
||||
<history>ip-addr~;routes~;routing~;</history>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiRadio
|
||||
<bitrate>250.0</bitrate>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiEEPROM
|
||||
<eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom>
|
||||
</interface_config>
|
||||
<motetype_identifier>mtype34</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>0.0</x>
|
||||
<y>0.0</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiMoteID
|
||||
<id>4</id>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiRadio
|
||||
<bitrate>250.0</bitrate>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiEEPROM
|
||||
<eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom>
|
||||
</interface_config>
|
||||
<motetype_identifier>mtype34</motetype_identifier>
|
||||
</mote>
|
||||
</simulation>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.SimControl
|
||||
<width>280</width>
|
||||
<z>0</z>
|
||||
<height>160</height>
|
||||
<location_x>400</location_x>
|
||||
<location_y>0</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.Visualizer
|
||||
<plugin_config>
|
||||
<moterelations>true</moterelations>
|
||||
<skin>org.contikios.cooja.plugins.skins.IDVisualizerSkin</skin>
|
||||
<skin>org.contikios.cooja.plugins.skins.GridVisualizerSkin</skin>
|
||||
<skin>org.contikios.cooja.plugins.skins.TrafficVisualizerSkin</skin>
|
||||
<skin>org.contikios.cooja.plugins.skins.UDGMVisualizerSkin</skin>
|
||||
<skin>org.contikios.cooja.plugins.skins.MoteTypeVisualizerSkin</skin>
|
||||
<viewport>0.9090909090909091 0.0 0.0 0.9090909090909091 125.81818181818181 173.0</viewport>
|
||||
</plugin_config>
|
||||
<width>400</width>
|
||||
<z>4</z>
|
||||
<height>400</height>
|
||||
<location_x>1</location_x>
|
||||
<location_y>1</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.LogListener
|
||||
<plugin_config>
|
||||
<filter />
|
||||
<formatted_time />
|
||||
<coloring />
|
||||
</plugin_config>
|
||||
<width>604</width>
|
||||
<z>3</z>
|
||||
<height>784</height>
|
||||
<location_x>400</location_x>
|
||||
<location_y>160</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.Notes
|
||||
<plugin_config>
|
||||
<notes>Enter notes here</notes>
|
||||
<decorations>true</decorations>
|
||||
</plugin_config>
|
||||
<width>944</width>
|
||||
<z>1</z>
|
||||
<height>160</height>
|
||||
<location_x>680</location_x>
|
||||
<location_y>0</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.ScriptRunner
|
||||
<plugin_config>
|
||||
<script>var last_msg = 0;
|
||||
var root_id = 4;
|
||||
var ip_addresses = [];
|
||||
var rpl_done = 60000; // 1 minute - expected time for all motes to be part of rpl instance
|
||||
|
||||
function MY_GENERATE_MSG(wait, string)
|
||||
{
|
||||
last_msg += wait;
|
||||
GENERATE_MSG(last_msg, string);
|
||||
}
|
||||
|
||||
/* All motes starts from scratch */
|
||||
MY_GENERATE_MSG(1000, "set root");
|
||||
MY_GENERATE_MSG(rpl_done, "get ip addresses");
|
||||
MY_GENERATE_MSG(1000, "check ip addresses");
|
||||
|
||||
/* Root restarts and acts as root before rejoining existing rpl instance */
|
||||
MY_GENERATE_MSG(1000, "remove root " + root_id);
|
||||
MY_GENERATE_MSG(1000, "add root " + root_id);
|
||||
MY_GENERATE_MSG(1000, "set root");
|
||||
MY_GENERATE_MSG(rpl_done, "get ip addresses");
|
||||
MY_GENERATE_MSG(1000, "check ip addresses");
|
||||
/* Set root 2nd time should be ignored */
|
||||
MY_GENERATE_MSG(100, "set root");
|
||||
MY_GENERATE_MSG(1000, "get ip addresses");
|
||||
MY_GENERATE_MSG(1000, "check ip addresses");
|
||||
|
||||
/* Root restarts and rejoins existing rpl instance */
|
||||
MY_GENERATE_MSG(1000, "remove root " + root_id);
|
||||
MY_GENERATE_MSG(1000, "add root " + root_id);
|
||||
MY_GENERATE_MSG(rpl_done, "get ip addresses");
|
||||
MY_GENERATE_MSG(1000, "check ip addresses");
|
||||
/* Root starts acting as root again */
|
||||
MY_GENERATE_MSG(1000, "set root");
|
||||
MY_GENERATE_MSG(rpl_done, "get ip addresses");
|
||||
MY_GENERATE_MSG(1000, "check ip addresses");
|
||||
|
||||
/* Sink test */
|
||||
|
||||
/* End test */
|
||||
MY_GENERATE_MSG(1000, "end test");
|
||||
|
||||
while(true) {
|
||||
YIELD();
|
||||
if(msg.equals("set root")) {
|
||||
m = sim.getMoteWithID(root_id);
|
||||
write(m, "rpl-set-root 1");
|
||||
log.log("root set\n");
|
||||
} else if(msg.contains("get ip addresses")) {
|
||||
var motes = sim.getMotes();
|
||||
for(var i in motes) {
|
||||
write(motes[i], "ip-addr");
|
||||
}
|
||||
} else if(msg.contains("-- fd00::20")) {
|
||||
ip_addresses.push(msg);
|
||||
} else if(msg.startsWith("check ip addresses")) {
|
||||
var motes = sim.getMotes();
|
||||
var motes_found = [];
|
||||
for(var i in motes) {
|
||||
var ip_address = "fd00::" + (motes[i].getID() + 200);
|
||||
for(var j in ip_addresses) {
|
||||
if(ip_addresses[j].contains(ip_address)) {
|
||||
motes_found.push(motes[i].getID());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(motes.length == motes_found.length) {
|
||||
log.log("all motes are in rpl\n");
|
||||
} else {
|
||||
log.log("some motes is missing, found:\n" + motes_found + "\n");
|
||||
if(!msg.contains("skip fail")) {
|
||||
log.testFailed(); /* Report test failure and quit */
|
||||
}
|
||||
}
|
||||
ip_addresses = [];
|
||||
} else if(msg.startsWith("remove root")) {
|
||||
//TODO: Use id from generated msg
|
||||
m = sim.getMoteWithID(root_id);
|
||||
sim.removeMote(m);
|
||||
log.log("root removed\n");
|
||||
//TODO: Save type and position, so it can be used in add
|
||||
} else if(msg.startsWith("add root")) {
|
||||
//TODO: Use id from generated msg
|
||||
//TODO: Use saved type and position
|
||||
m = sim.getMoteTypes()[0].generateMote(sim);
|
||||
m.getInterfaces().getMoteID().setMoteID(root_id);
|
||||
sim.addMote(m);
|
||||
log.log("root added\n");
|
||||
} else if(msg.equals("end test")) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
log.testOK(); /* Report test success and quit */</script>
|
||||
<active>true</active>
|
||||
</plugin_config>
|
||||
<width>617</width>
|
||||
<z>2</z>
|
||||
<height>785</height>
|
||||
<location_x>1007</location_x>
|
||||
<location_y>160</location_y>
|
||||
</plugin>
|
||||
</simconf>
|
||||
|
|
@ -0,0 +1,294 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<simconf>
|
||||
<project EXPORT="discard">[APPS_DIR]/mrm</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/mspsim</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/avrora</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/serial_socket</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/powertracker</project>
|
||||
<simulation>
|
||||
<title>My simulation</title>
|
||||
<speedlimit>10.0</speedlimit>
|
||||
<randomseed>123456</randomseed>
|
||||
<motedelay_us>1000000</motedelay_us>
|
||||
<radiomedium>
|
||||
org.contikios.cooja.radiomediums.UDGM
|
||||
<transmitting_range>50.0</transmitting_range>
|
||||
<interference_range>100.0</interference_range>
|
||||
<success_ratio_tx>1.0</success_ratio_tx>
|
||||
<success_ratio_rx>1.0</success_ratio_rx>
|
||||
</radiomedium>
|
||||
<events>
|
||||
<logoutput>40000</logoutput>
|
||||
</events>
|
||||
<motetype>
|
||||
org.contikios.cooja.contikimote.ContikiMoteType
|
||||
<identifier>mtype512</identifier>
|
||||
<description>mote</description>
|
||||
<source>[CONTIKI_DIR]/examples/libs/shell/example.c</source>
|
||||
<commands>make example.cooja TARGET=cooja MAKE_ROUTING=MAKE_ROUTING_RPL_CLASSIC -j</commands>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Battery</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiVib</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiMoteID</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRS232</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiBeeper</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiIPAddress</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRadio</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiButton</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiPIR</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiClock</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiLED</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiCFS</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiEEPROM</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface>
|
||||
<symbols>false</symbols>
|
||||
</motetype>
|
||||
<mote>
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>50.0</x>
|
||||
<y>0.0</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiMoteID
|
||||
<id>3</id>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiRadio
|
||||
<bitrate>250.0</bitrate>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiEEPROM
|
||||
<eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom>
|
||||
</interface_config>
|
||||
<motetype_identifier>mtype512</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>100.0</x>
|
||||
<y>0.0</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiMoteID
|
||||
<id>2</id>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiRadio
|
||||
<bitrate>250.0</bitrate>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiEEPROM
|
||||
<eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom>
|
||||
</interface_config>
|
||||
<motetype_identifier>mtype512</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>150.0</x>
|
||||
<y>0.0</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiMoteID
|
||||
<id>1</id>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiRS232
|
||||
<history>ip-addr~;routes~;routing~;</history>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiRadio
|
||||
<bitrate>250.0</bitrate>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiEEPROM
|
||||
<eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom>
|
||||
</interface_config>
|
||||
<motetype_identifier>mtype512</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>0.0</x>
|
||||
<y>0.0</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiMoteID
|
||||
<id>4</id>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiRadio
|
||||
<bitrate>250.0</bitrate>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiEEPROM
|
||||
<eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom>
|
||||
</interface_config>
|
||||
<motetype_identifier>mtype512</motetype_identifier>
|
||||
</mote>
|
||||
</simulation>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.SimControl
|
||||
<width>280</width>
|
||||
<z>0</z>
|
||||
<height>160</height>
|
||||
<location_x>400</location_x>
|
||||
<location_y>0</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.Visualizer
|
||||
<plugin_config>
|
||||
<moterelations>true</moterelations>
|
||||
<skin>org.contikios.cooja.plugins.skins.IDVisualizerSkin</skin>
|
||||
<skin>org.contikios.cooja.plugins.skins.GridVisualizerSkin</skin>
|
||||
<skin>org.contikios.cooja.plugins.skins.TrafficVisualizerSkin</skin>
|
||||
<skin>org.contikios.cooja.plugins.skins.UDGMVisualizerSkin</skin>
|
||||
<skin>org.contikios.cooja.plugins.skins.MoteTypeVisualizerSkin</skin>
|
||||
<viewport>0.9090909090909091 0.0 0.0 0.9090909090909091 125.81818181818181 173.0</viewport>
|
||||
</plugin_config>
|
||||
<width>400</width>
|
||||
<z>4</z>
|
||||
<height>400</height>
|
||||
<location_x>1</location_x>
|
||||
<location_y>1</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.LogListener
|
||||
<plugin_config>
|
||||
<filter />
|
||||
<formatted_time />
|
||||
<coloring />
|
||||
</plugin_config>
|
||||
<width>604</width>
|
||||
<z>3</z>
|
||||
<height>784</height>
|
||||
<location_x>400</location_x>
|
||||
<location_y>160</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.Notes
|
||||
<plugin_config>
|
||||
<notes>Enter notes here</notes>
|
||||
<decorations>true</decorations>
|
||||
</plugin_config>
|
||||
<width>944</width>
|
||||
<z>1</z>
|
||||
<height>160</height>
|
||||
<location_x>680</location_x>
|
||||
<location_y>0</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.ScriptRunner
|
||||
<plugin_config>
|
||||
<script>var last_msg = 0;
|
||||
var root_id = 4;
|
||||
var ip_addresses = [];
|
||||
var rpl_done = 60000; // 1 minute - expected time for all motes to be part of rpl instance
|
||||
|
||||
function MY_GENERATE_MSG(wait, string)
|
||||
{
|
||||
last_msg += wait;
|
||||
GENERATE_MSG(last_msg, string);
|
||||
}
|
||||
|
||||
/* All motes starts from scratch */
|
||||
MY_GENERATE_MSG(1000, "set root");
|
||||
MY_GENERATE_MSG(rpl_done, "get ip addresses");
|
||||
MY_GENERATE_MSG(1000, "check ip addresses");
|
||||
|
||||
/* Root restarts and acts as root before rejoining existing rpl instance */
|
||||
MY_GENERATE_MSG(1000, "remove root " + root_id);
|
||||
MY_GENERATE_MSG(1000, "add root " + root_id);
|
||||
MY_GENERATE_MSG(1000, "set root");
|
||||
MY_GENERATE_MSG(rpl_done, "get ip addresses");
|
||||
MY_GENERATE_MSG(1000, "check ip addresses");
|
||||
/* Set root 2nd time should be ignored */
|
||||
MY_GENERATE_MSG(100, "set root");
|
||||
MY_GENERATE_MSG(1000, "get ip addresses");
|
||||
MY_GENERATE_MSG(1000, "check ip addresses");
|
||||
|
||||
/* Root restarts and rejoins existing rpl instance */
|
||||
MY_GENERATE_MSG(1000, "remove root " + root_id);
|
||||
MY_GENERATE_MSG(1000, "add root " + root_id);
|
||||
MY_GENERATE_MSG(rpl_done, "get ip addresses");
|
||||
MY_GENERATE_MSG(1000, "check ip addresses");
|
||||
/* Root starts acting as root again */
|
||||
MY_GENERATE_MSG(1000, "set root");
|
||||
MY_GENERATE_MSG(rpl_done, "get ip addresses");
|
||||
MY_GENERATE_MSG(1000, "check ip addresses");
|
||||
|
||||
/* Sink test */
|
||||
|
||||
/* End test */
|
||||
MY_GENERATE_MSG(1000, "end test");
|
||||
|
||||
while(true) {
|
||||
YIELD();
|
||||
if(msg.equals("set root")) {
|
||||
m = sim.getMoteWithID(root_id);
|
||||
write(m, "rpl-set-root 1");
|
||||
log.log("root set\n");
|
||||
} else if(msg.contains("get ip addresses")) {
|
||||
var motes = sim.getMotes();
|
||||
for(var i in motes) {
|
||||
write(motes[i], "ip-addr");
|
||||
}
|
||||
} else if(msg.contains("-- fd00::20")) {
|
||||
ip_addresses.push(msg);
|
||||
} else if(msg.startsWith("check ip addresses")) {
|
||||
var motes = sim.getMotes();
|
||||
var motes_found = [];
|
||||
for(var i in motes) {
|
||||
var ip_address = "fd00::" + (motes[i].getID() + 200);
|
||||
for(var j in ip_addresses) {
|
||||
if(ip_addresses[j].contains(ip_address)) {
|
||||
motes_found.push(motes[i].getID());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(motes.length == motes_found.length) {
|
||||
log.log("all motes are in rpl\n");
|
||||
} else {
|
||||
log.log("some motes is missing, found:\n" + motes_found + "\n");
|
||||
if(!msg.contains("skip fail")) {
|
||||
log.testFailed(); /* Report test failure and quit */
|
||||
}
|
||||
}
|
||||
ip_addresses = [];
|
||||
} else if(msg.startsWith("remove root")) {
|
||||
//TODO: Use id from generated msg
|
||||
m = sim.getMoteWithID(root_id);
|
||||
sim.removeMote(m);
|
||||
log.log("root removed\n");
|
||||
//TODO: Save type and position, so it can be used in add
|
||||
} else if(msg.startsWith("add root")) {
|
||||
//TODO: Use id from generated msg
|
||||
//TODO: Use saved type and position
|
||||
m = sim.getMoteTypes()[0].generateMote(sim);
|
||||
m.getInterfaces().getMoteID().setMoteID(root_id);
|
||||
sim.addMote(m);
|
||||
log.log("root added\n");
|
||||
} else if(msg.equals("end test")) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
log.testOK(); /* Report test success and quit */</script>
|
||||
<active>true</active>
|
||||
</plugin_config>
|
||||
<width>617</width>
|
||||
<z>2</z>
|
||||
<height>785</height>
|
||||
<location_x>1007</location_x>
|
||||
<location_y>160</location_y>
|
||||
</plugin>
|
||||
</simconf>
|
||||
|
|
@ -1 +1 @@
|
|||
Subproject commit 67b858437f7cf1e4e027d821c4c2ac15fdf2ab44
|
||||
Subproject commit 3b23ca8d6a19d281b6330d3f24afc2e1bb14ddb7
|
|
@ -856,14 +856,20 @@ fprintf(stderr," -s siodev Serial device (default /dev/ttyUSB0)\n");
|
|||
fprintf(stderr," -M Interface MTU (default and min: 1280)\n");
|
||||
fprintf(stderr," -T Make tap interface (default is tun interface)\n");
|
||||
fprintf(stderr," -t tundev Name of interface (default tap0 or tun0)\n");
|
||||
#ifdef __APPLE__
|
||||
fprintf(stderr," -v level Verbosity level\n");
|
||||
#else
|
||||
fprintf(stderr," -v[level] Verbosity level\n");
|
||||
#endif
|
||||
fprintf(stderr," -v0 No messages\n");
|
||||
fprintf(stderr," -v1 Encapsulated SLIP debug messages (default)\n");
|
||||
fprintf(stderr," -v2 Printable strings after they are received\n");
|
||||
fprintf(stderr," -v3 Printable strings and SLIP packet notifications\n");
|
||||
fprintf(stderr," -v4 All printable characters as they are received\n");
|
||||
fprintf(stderr," -v5 All SLIP packets in hex\n");
|
||||
#ifndef __APPLE__
|
||||
fprintf(stderr," -v Equivalent to -v3\n");
|
||||
#endif
|
||||
fprintf(stderr," -d[basedelay] Minimum delay between outgoing SLIP packets.\n");
|
||||
fprintf(stderr," Actual delay is basedelay*(#6LowPAN fragments) milliseconds.\n");
|
||||
fprintf(stderr," -d is equivalent to -d10.\n");
|
||||
|
|
Loading…
Reference in New Issue