Merge branch 'develop' into lafka-cortex-makefile-relpath

This commit is contained in:
Simon Duquennoy 2018-05-04 21:29:16 +02:00 committed by GitHub
commit ed5eb17f68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
187 changed files with 1361 additions and 925 deletions

View File

@ -300,14 +300,15 @@ CONTIKI_NG_PROJECT_MAP = $(addsuffix -$(TARGET).map, $(basename $@))
.PHONY: clean distclean usage help targets boards savetarget savedefines viewconf
clean:
-rm -f *.d *.e *.o $(CONTIKI_NG_TARGET_LIB) $(CLEAN)
-rm -rf $(OBJECTDIR)
-rm -f $(addsuffix -$(TARGET).map, $(CONTIKI_PROJECT))
-rm -f $(addsuffix .$(TARGET), $(CONTIKI_PROJECT))
-$(Q)rm -f *.d *.e *.o $(CONTIKI_NG_TARGET_LIB) $(CLEAN)
-$(Q)rm -rf $(OBJECTDIR)
-$(Q)rm -f $(addsuffix -$(TARGET).map, $(CONTIKI_PROJECT))
-$(Q)rm -f $(addsuffix .$(TARGET), $(CONTIKI_PROJECT))
@echo Target $(TARGET) cleaned
distclean:
@for TARG in `ls $(CONTIKI)/arch/platform $(TARGETDIRS)`; do \
echo make $$TARG clean; \
echo Running: make TARGET=$$TARG clean; \
make TARGET=$$TARG clean; \
done

View File

@ -1,7 +1,7 @@
# Contiki-NG: The OS for Next Generation IoT Devices
[![Build Status](https://travis-ci.org/contiki-ng/contiki-ng.svg?branch=master)](https://travis-ci.org/contiki-ng/contiki-ng/branches)
[![License](https://img.shields.io/badge/License-3--Clause%20BSD-brightgreen.svg)](https://github.com/contiki-ng/contiki-ng/blob/master/LICENSE.md)
[![license](https://img.shields.io/badge/license-3--clause%20bsd-brightgreen.svg)](https://github.com/contiki-ng/contiki-ng/blob/master/LICENSE.md)
[![Latest release](https://img.shields.io/github/release/contiki-ng/contiki-ng.svg)](https://github.com/contiki-ng/contiki-ng/releases/latest)
[![GitHub Release Date](https://img.shields.io/github/release-date/contiki-ng/contiki-ng.svg)](https://github.com/contiki-ng/contiki-ng/releases/latest)
[![Last commit](https://img.shields.io/github/last-commit/contiki-ng/contiki-ng.svg)](https://github.com/contiki-ng/contiki-ng/commit/HEAD)
@ -9,7 +9,7 @@
Contiki-NG is an open-source, cross-platform operating system for Next-Generation IoT devices. It focuses on dependable (secure and reliable) low-power communication and standard protocols, such as IPv6/6LoWPAN, 6TiSCH, RPL, and CoAP. Contiki-NG comes with extensive documentation, tutorials, a roadmap, release cycle, and well-defined development flow for smooth integration of community contributions.
Unless excplicitly stated otherwise, Contiki-NG sources are distributed under
the terms of the [3-clause BSD license](LICENSE.md).
the terms of the [3-clause BSD license](LICENSE.md).
Contiki-NG started as a fork of the Contiki OS and retains some of its original features.

View File

@ -219,14 +219,6 @@
*/
/* RF Config */
#ifdef RF_CHANNEL
#define CC2538_RF_CONF_CHANNEL RF_CHANNEL
#endif
#ifndef CC2538_RF_CONF_CHANNEL
#define CC2538_RF_CONF_CHANNEL 26
#endif /* CC2538_RF_CONF_CHANNEL */
#ifndef CC2538_RF_CONF_AUTOACK
#define CC2538_RF_CONF_AUTOACK 1 /**< RF H/W generates ACKs */
#endif /* CC2538_CONF_AUTOACK */

View File

@ -113,7 +113,7 @@ static int8_t rssi;
static uint8_t crc_corr;
/*---------------------------------------------------------------------------*/
static uint8_t rf_flags;
static uint8_t rf_channel = CC2538_RF_CHANNEL;
static uint8_t rf_channel = IEEE802154_DEFAULT_CHANNEL;
static int on(void);
static int off(void);

View File

@ -74,12 +74,6 @@
#define CC2538_RF_CCA_THRES CC2538_RF_CCA_THRES_USER_GUIDE
#endif /* CC2538_RF_CONF_CCA_THRES */
#ifdef CC2538_RF_CONF_CHANNEL
#define CC2538_RF_CHANNEL CC2538_RF_CONF_CHANNEL
#else
#define CC2538_RF_CHANNEL 18
#endif /* CC2538_RF_CONF_CHANNEL */
#ifdef CC2538_RF_CONF_AUTOACK
#define CC2538_RF_AUTOACK CC2538_RF_CONF_AUTOACK
#else

View File

@ -55,7 +55,7 @@
* - SPIX_FLUSH(x)
*
* Some of the old functions and macros are still supported.
* When using these deprecated functions, the SSI module to use
* When using these deprecated functions, the SSI module to use
* has to be be selected by means of the macro SPI_CONF_DEFAULT_INSTANCE.
*
* This SPI driver depends on the following defines:
@ -95,14 +95,14 @@
#endif
/*---------------------------------------------------------------------------*/
/* Default values for the clock rate divider */
#ifdef SPI0_CONF_CPRS_CPSDVSR
#define SPI0_CPRS_CPSDVSR SPI0_CONF_CPRS_CPSDVSR
#ifdef SPI0_CONF_CPRS_CPSDVSR
#define SPI0_CPRS_CPSDVSR SPI0_CONF_CPRS_CPSDVSR
#else
#define SPI0_CPRS_CPSDVSR 2
#endif
#ifdef SPI1_CONF_CPRS_CPSDVSR
#define SPI1_CPRS_CPSDVSR SPI1_CONF_CPRS_CPSDVSR
#ifdef SPI1_CONF_CPRS_CPSDVSR
#define SPI1_CPRS_CPSDVSR SPI1_CONF_CPRS_CPSDVSR
#else
#define SPI1_CPRS_CPSDVSR 2
#endif
@ -120,7 +120,7 @@
} while(0)
#define SPIX_FLUSH(spi) do { \
while(REG(SSI_BASE(spi) + SSI_SR) & SSI_SR_RNE) { \
SPIX_BUF(spi); \
SPIX_BUF(spi); \
} \
} while(0)
#define SPIX_CS_CLR(port, pin) do { \
@ -144,7 +144,7 @@
#endif
#define SPI_CS_CLR(port, pin) SPIX_CS_CLR(port, pin)
#define SPI_CS_SET(port, pin) SPIX_CS_SET(port, pin)
#endif /* #ifdef SPI_DEFAULT_INSTANCE */
#endif /* #ifdef SPI_DEFAULT_INSTANCE */
/*---------------------------------------------------------------------------*/
/** \name Arch-specific SPI functions
* @{
@ -183,7 +183,7 @@ void spix_disable(uint8_t spi);
*
* See section 19.4.4 in the CC2538 user guide for more information.
*
* \param spi The SSI instance to use.
* \param spi The SSI instance to use.
* \param frame_format Set the SSI frame format. Use SSI_CR0_FRF_MOTOROLA,
* SSI_CR0_FRF_TI, or SSI_CR0_FRF_MICROWIRE.
* \param clock_polarity In Motorola mode, set whether the clock is high or low

View File

@ -93,10 +93,10 @@ ifeq ($(HOST_OS),Windows)
SERIALDUMP ?= $(CONTIKI)/tools/sky/serialdump-windows
else
ifeq ($(HOST_OS),Darwin)
SERIALDUMP ?= $(CONTIKI)/tools/sky/serialdump-macos
SERIALDUMP ?= rlwrap $(CONTIKI)/tools/sky/serialdump-macos
else
# Else assume Linux
SERIALDUMP ?= $(CONTIKI)/tools/sky/serialdump-linux
SERIALDUMP ?= rlwrap $(CONTIKI)/tools/sky/serialdump-linux
endif
endif

View File

@ -54,14 +54,6 @@
#define CC2650_FAST_RADIO_STARTUP (MAC_CONF_WITH_TSCH)
#endif
#ifdef RF_CHANNEL
#define RF_CORE_CONF_CHANNEL RF_CHANNEL
#endif
#ifndef RF_CORE_CONF_CHANNEL
#define RF_CORE_CONF_CHANNEL 25
#endif
/* Number of Prop Mode RX buffers */
#ifndef PROP_MODE_CONF_RX_BUF_CNT
#define PROP_MODE_CONF_RX_BUF_CNT 4
@ -81,13 +73,22 @@
#if CC13XX_CONF_PROP_MODE
#define NETSTACK_CONF_RADIO prop_mode_driver
#ifndef RF_CORE_CONF_CHANNEL
#define RF_CORE_CONF_CHANNEL 0
#endif
/* Channels count from 0 upwards in IEEE 802.15.4g */
#ifndef IEEE802154_CONF_DEFAULT_CHANNEL
#define IEEE802154_CONF_DEFAULT_CHANNEL 0
#endif /* IEEE802154_CONF_DEFAULT_CHANNEL */
#ifndef CSMA_CONF_ACK_WAIT_TIME
#define CSMA_CONF_ACK_WAIT_TIME (RTIMER_SECOND / 400)
#endif /* CSMA_CONF_ACK_WAIT_TIME */
#ifndef CSMA_CONF_AFTER_ACK_DETECTED_WAIT_TIME
#define CSMA_CONF_AFTER_ACK_DETECTED_WAIT_TIME (RTIMER_SECOND / 1000)
#endif /* CSMA_CONF_AFTER_ACK_DETECTED_WAIT_TIME */
#ifndef CSMA_CONF_SEND_SOFT_ACK
#define CSMA_CONF_SEND_SOFT_ACK 1
#endif /* CSMA_CONF_SEND_SOFT_ACK */
#else /* CC13XX_CONF_PROP_MODE */
#ifndef NETSTACK_CONF_RADIO
@ -197,7 +198,7 @@
* @{
*/
#ifndef ROM_BOOTLOADER_ENABLE
#define ROM_BOOTLOADER_ENABLE 0
#define ROM_BOOTLOADER_ENABLE 1
#endif
/** @} */
/*---------------------------------------------------------------------------*/

View File

@ -49,20 +49,21 @@
#include "driverlib/rf_mailbox.h"
/*---------------------------------------------------------------------------*/
/* IEEE 802.15.4g frequency band identifiers (Table 68f) */
#define DOT_15_4G_FREQUENCY_BAND_169 0 /* 169.400169.475 (Europe) - 169 MHz band */
#define DOT_15_4G_FREQUENCY_BAND_450 1 /* 450470 (US FCC Part 22/90) - 450 MHz band */
#define DOT_15_4G_FREQUENCY_BAND_470 2 /* 470510 (China) - 470 MHz band */
#define DOT_15_4G_FREQUENCY_BAND_780 3 /* 779787 (China) - 780 MHz band */
#define DOT_15_4G_FREQUENCY_BAND_863 4 /* 863870 (Europe) - 863 MHz band */
#define DOT_15_4G_FREQUENCY_BAND_896 5 /* 896901 (US FCC Part 90) - 896 MHz band */
#define DOT_15_4G_FREQUENCY_BAND_901 6 /* 901902 (US FCC Part 24) - 901 MHz band */
#define DOT_15_4G_FREQUENCY_BAND_915 7 /* 902928 (US) - 915 MHz band */
#define DOT_15_4G_FREQUENCY_BAND_917 8 /* 917923.5 (Korea) - 917 MHz band */
#define DOT_15_4G_FREQUENCY_BAND_920 9 /* 920928 (Japan) - 920 MHz band */
#define DOT_15_4G_FREQUENCY_BAND_928 10 /* 928960 (US, non-contiguous) - 928 MHz band */
#define DOT_15_4G_FREQUENCY_BAND_950 11 /* 950958 (Japan) - 950 MHz band */
#define DOT_15_4G_FREQUENCY_BAND_1427 12 /* 14271518 (US and Canada, non-contiguous) - 1427 MHz band */
#define DOT_15_4G_FREQUENCY_BAND_2450 13 /* 24002483.5 2450 MHz band */
#define DOT_15_4G_FREQUENCY_BAND_169 0 /* 169.400169.475 (Europe) - 169 MHz band */
#define DOT_15_4G_FREQUENCY_BAND_450 1 /* 450470 (US FCC Part 22/90) - 450 MHz band */
#define DOT_15_4G_FREQUENCY_BAND_470 2 /* 470510 (China) - 470 MHz band */
#define DOT_15_4G_FREQUENCY_BAND_780 3 /* 779787 (China) - 780 MHz band */
#define DOT_15_4G_FREQUENCY_BAND_863 4 /* 863870 (Europe) - 863 MHz band */
#define DOT_15_4G_FREQUENCY_BAND_896 5 /* 896901 (US FCC Part 90) - 896 MHz band */
#define DOT_15_4G_FREQUENCY_BAND_901 6 /* 901902 (US FCC Part 24) - 901 MHz band */
#define DOT_15_4G_FREQUENCY_BAND_915 7 /* 902928 (US) - 915 MHz band */
#define DOT_15_4G_FREQUENCY_BAND_917 8 /* 917923.5 (Korea) - 917 MHz band */
#define DOT_15_4G_FREQUENCY_BAND_920 9 /* 920928 (Japan) - 920 MHz band */
#define DOT_15_4G_FREQUENCY_BAND_928 10 /* 928960 (US, non-contiguous) - 928 MHz band */
#define DOT_15_4G_FREQUENCY_BAND_950 11 /* 950958 (Japan) - 950 MHz band */
#define DOT_15_4G_FREQUENCY_BAND_1427 12 /* 14271518 (US and Canada, non-contiguous) - 1427 MHz band */
#define DOT_15_4G_FREQUENCY_BAND_2450 13 /* 24002483.5 2450 MHz band */
#define DOT_15_4G_FREQUENCY_BAND_CUSTOM 14 /* For use with custom frequency band settings */
/*---------------------------------------------------------------------------*/
/* Default band selection to band 4 - 863MHz */
#ifdef DOT_15_4G_CONF_FREQUENCY_BAND_ID
@ -77,6 +78,18 @@
* bands we only support operating mode #1 (Table 134).
*
* DOT_15_4G_CHAN0_FREQUENCY is specified here in KHz
*
* Custom bands and configuration can be used with DOT_15_4G_FREQUENCY_BAND_CUSTOM.
*
* Example of custom setup for the 868Mhz sub-band in Europe with 11 channels,
* center frequency at 868.050MHz and channel spacing at 100KHz.
* These should be put in project-config.h or similar.
*
* #define DOT_15_4G_FREQUENCY_BAND_ID DOT_15_4G_FREQUENCY_BAND_CUSTOM
* #define DOT_15_4G_CHAN0_FREQUENCY 868050
* #define DOT_15_4G_CHANNEL_SPACING 100
* #define DOT_15_4G_CHANNEL_MAX 11
* #define PROP_MODE_CONF_LO_DIVIDER 0x05
*/
#if DOT_15_4G_FREQUENCY_BAND_ID==DOT_15_4G_FREQUENCY_BAND_470
#define DOT_15_4G_CHANNEL_MAX 198
@ -116,6 +129,22 @@
#define DOT_15_4G_CHAN0_FREQUENCY 951000
#define PROP_MODE_CONF_LO_DIVIDER 0x05
#elif DOT_15_4G_FREQUENCY_BAND_ID==DOT_15_4G_FREQUENCY_BAND_CUSTOM
#ifndef DOT_15_4G_CHANNEL_MAX
#error DOT_15_4G_CHANNEL_MAX must be manually set when using custom frequency band
#endif
#ifndef DOT_15_4G_CHANNEL_SPACING
#error DOT_15_4G_CHANNEL_SPACING must be manually set when using custom frequency band
#endif
#ifndef DOT_15_4G_CHAN0_FREQUENCY
#error DOT_15_4G_CHAN0_FREQUENCY must be manually set when using custom frequency band
#endif
#ifndef PROP_MODE_CONF_LO_DIVIDER
#error PROP_MODE_CONF_LO_DIVIDER must be manually set when using custom frequency band
#endif
#else
#error The selected frequency band is not supported
#endif

View File

@ -610,7 +610,7 @@ init_rf_params(void)
cmd->startTime = 0x00000000;
cmd->startTrigger.triggerType = TRIG_NOW;
cmd->condition.rule = COND_NEVER;
cmd->channel = RF_CORE_CHANNEL;
cmd->channel = IEEE802154_DEFAULT_CHANNEL;
cmd->rxConfig.bAutoFlushCrc = 1;
cmd->rxConfig.bAutoFlushIgn = 0;

View File

@ -629,7 +629,7 @@ init(void)
smartrf_settings_cmd_prop_rx_adv.pQueue = &rx_data_queue;
smartrf_settings_cmd_prop_rx_adv.pOutput = (uint8_t *)&rx_stats;
set_channel(RF_CORE_CHANNEL);
set_channel(IEEE802154_DEFAULT_CHANNEL);
if(on() != RF_CORE_CMD_OK) {
PRINTF("init: on() failed\n");

View File

@ -57,13 +57,6 @@
#include <stdint.h>
#include <stdbool.h>
/*---------------------------------------------------------------------------*/
/* The channel to use in IEEE or prop mode. */
#ifdef RF_CORE_CONF_CHANNEL
#define RF_CORE_CHANNEL RF_CORE_CONF_CHANNEL
#else
#define RF_CORE_CHANNEL 25
#endif /* RF_CORE_CONF_IEEE_MODE_CHANNEL */
/*---------------------------------------------------------------------------*/
#define RF_CORE_FRONT_END_MODE_DIFFERENTIAL 0
#define RF_CORE_FRONT_END_MODE_SINGLE_RFP 1
#define RF_CORE_FRONT_END_MODE_SINGLE_RFN 2

View File

@ -1,30 +1,30 @@
/*
* Copyright (c) 2006, Swedish Institute of Computer Science
* All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
@ -35,7 +35,7 @@
* exclusive. Set spi_busy so that interrupt handlers can check if
* they are allowed to use the bus or not. Only the CC2420 radio needs
* this in practice.
*
*
*/
unsigned char spi_busy = 0;

View File

@ -1,30 +1,30 @@
/*
* Copyright (c) 2007, Swedish Institute of Computer Science
* All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef MSP430_DEF_H_

View File

@ -1,6 +1,7 @@
CONTIKI_CPU_DIRS = . net dev
CONTIKI_SOURCEFILES += rtimer-arch.c watchdog.c eeprom.c
CONTIKI_SOURCEFILES += rtimer-arch.c watchdog.c eeprom.c int-master.c
CONTIKI_SOURCEFILES += gpio-hal-arch.c
### Compiler definitions
CC ?= gcc

View File

@ -0,0 +1,216 @@
/*
* Copyright (c) 2018, George Oikonomou - http://www.spd.gr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
#include "dev/gpio-hal.h"
#include "sys/log.h"
#include <stdint.h>
/*---------------------------------------------------------------------------*/
/* Log configuration */
#define LOG_MODULE "GPIO arch"
#define LOG_LEVEL LOG_LEVEL_NONE
/*---------------------------------------------------------------------------*/
static gpio_hal_pin_cfg_t pin_cfg[GPIO_HAL_PIN_COUNT];
static uint8_t pin_state[GPIO_HAL_PIN_COUNT];
/*---------------------------------------------------------------------------*/
void
gpio_hal_arch_interrupt_enable(gpio_hal_pin_t pin)
{
if(pin >= GPIO_HAL_PIN_COUNT) {
LOG_ERR("Pin %u out of bounds\n", pin);
return;
}
LOG_DBG("Pin %u: Enabled interrupt\n", pin);
}
/*---------------------------------------------------------------------------*/
void
gpio_hal_arch_interrupt_disable(gpio_hal_pin_t pin)
{
if(pin >= GPIO_HAL_PIN_COUNT) {
LOG_ERR("Pin %u out of bounds\n", pin);
return;
}
LOG_DBG("Pin %u: Disabled interrupt\n", pin);
}
/*---------------------------------------------------------------------------*/
void
gpio_hal_arch_pin_cfg_set(gpio_hal_pin_t pin, gpio_hal_pin_cfg_t cfg)
{
if(pin >= GPIO_HAL_PIN_COUNT) {
LOG_ERR("Pin %u out of bounds\n", pin);
return;
}
pin_cfg[pin] = cfg;
LOG_DBG("Pin %u: Set config=0x%02x\n", pin, pin_cfg[pin]);
}
/*---------------------------------------------------------------------------*/
gpio_hal_pin_cfg_t
gpio_hal_arch_pin_cfg_get(gpio_hal_pin_t pin)
{
if(pin >= GPIO_HAL_PIN_COUNT) {
LOG_ERR("Pin %u out of bounds\n", pin);
return 0;
}
LOG_DBG("Pin %u: Config=0x%02x\n", pin, pin_cfg[pin]);
return pin_cfg[pin];
}
/*---------------------------------------------------------------------------*/
void
gpio_hal_arch_pin_set_input(gpio_hal_pin_t pin)
{
if(pin >= GPIO_HAL_PIN_COUNT) {
LOG_ERR("Pin %u out of bounds\n", pin);
return;
}
LOG_DBG("Pin %u: Set input\n", pin);
}
/*---------------------------------------------------------------------------*/
void
gpio_hal_arch_pin_set_output(gpio_hal_pin_t pin)
{
if(pin >= GPIO_HAL_PIN_COUNT) {
LOG_ERR("Pin %u out of bounds\n", pin);
return;
}
LOG_DBG("Pin %u: Set output\n", pin);
}
/*---------------------------------------------------------------------------*/
void
gpio_hal_arch_set_pin(gpio_hal_pin_t pin)
{
if(pin >= GPIO_HAL_PIN_COUNT) {
LOG_ERR("Pin %u out of bounds\n", pin);
return;
}
pin_state[pin] = 1;
LOG_DBG("Pin %u: Set\n", pin);
}
/*---------------------------------------------------------------------------*/
void
gpio_hal_arch_clear_pin(gpio_hal_pin_t pin)
{
if(pin >= GPIO_HAL_PIN_COUNT) {
LOG_ERR("Pin %u out of bounds\n", pin);
return;
}
pin_state[pin] = 0;
LOG_DBG("Pin %u: Clear\n", pin);
}
/*---------------------------------------------------------------------------*/
uint8_t
gpio_hal_arch_read_pin(gpio_hal_pin_t pin)
{
if(pin >= GPIO_HAL_PIN_COUNT) {
LOG_ERR("Pin %u out of bounds\n", pin);
return 0;
}
LOG_DBG("Pin %u: Read=%u\n", pin, pin_state[pin]);
return pin_state[pin];
}
/*---------------------------------------------------------------------------*/
void
gpio_hal_arch_write_pin(gpio_hal_pin_t pin, uint8_t value)
{
if(pin >= GPIO_HAL_PIN_COUNT) {
LOG_ERR("Pin %u out of bounds\n", pin);
return;
}
pin_state[pin] = value;
LOG_DBG("Pin %u: Write=%u\n", pin, pin_state[pin]);
}
/*---------------------------------------------------------------------------*/
void
gpio_hal_arch_set_pins(gpio_hal_pin_mask_t pins)
{
gpio_hal_pin_t pin;
for(pin = 0; pin < GPIO_HAL_PIN_COUNT; pin++) {
if(pins & (1 << pin)) {
pin_state[pin] = 1;
}
}
LOG_DBG("Set pins 0x%08" PRIx32 "\n", pins);
}
/*---------------------------------------------------------------------------*/
void
gpio_hal_arch_clear_pins(gpio_hal_pin_mask_t pins)
{
gpio_hal_pin_t pin;
for(pin = 0; pin < GPIO_HAL_PIN_COUNT; pin++) {
if(pins & (1 << pin)) {
pin_state[pin] = 0;
}
}
LOG_DBG("Clear pins 0x%08" PRIx32 "\n", pins);
}
/*---------------------------------------------------------------------------*/
gpio_hal_pin_mask_t
gpio_hal_arch_read_pins(gpio_hal_pin_mask_t pins)
{
gpio_hal_pin_t pin;
gpio_hal_pin_mask_t state = 0;
for(pin = 0; pin < GPIO_HAL_PIN_COUNT; pin++) {
state |= (pin_state[pin] << pin);
}
LOG_DBG("Read pins 0x%08" PRIx32 "\n", state);
return state;
}
/*---------------------------------------------------------------------------*/
void
gpio_hal_arch_write_pins(gpio_hal_pin_mask_t pins, gpio_hal_pin_mask_t value)
{
gpio_hal_pin_t pin;
for(pin = 0; pin < GPIO_HAL_PIN_COUNT; pin++) {
if(pins & (1 << pin)) {
pin_state[pin] = (value & (1 << pin)) == 0 ? 0 : 1;
}
}
LOG_DBG("Write pins 0x%08" PRIx32 "->0x%08" PRIx32 "\n", pins, value);
}
/*---------------------------------------------------------------------------*/

View File

@ -0,0 +1,67 @@
/*
* Copyright (c) 2018, George Oikonomou - http://www.spd.gr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
#include "sys/int-master.h"
#include <stdbool.h>
/*---------------------------------------------------------------------------*/
#define DISABLED 0
#define ENABLED 1
/*---------------------------------------------------------------------------*/
static int_master_status_t stat = DISABLED;
/*---------------------------------------------------------------------------*/
void
int_master_enable(void)
{
stat = ENABLED;
}
/*---------------------------------------------------------------------------*/
int_master_status_t
int_master_read_and_disable(void)
{
int_master_status_t rv = stat;
stat = DISABLED;
return rv;
}
/*---------------------------------------------------------------------------*/
void
int_master_status_set(int_master_status_t status)
{
stat = status;
}
/*---------------------------------------------------------------------------*/
bool
int_master_is_enabled(void)
{
return stat == DISABLED ? false : true;
}
/*---------------------------------------------------------------------------*/

View File

@ -0,0 +1,38 @@
/*
* Copyright (c) 2018, George Oikonomou - http://www.spd.gr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
#ifndef NATIVE_DEF_H_
#define NATIVE_DEF_H_
/*---------------------------------------------------------------------------*/
#define GPIO_HAL_CONF_ARCH_SW_TOGGLE 1
/*---------------------------------------------------------------------------*/
#endif /* NATIVE_DEF_H_ */
/*---------------------------------------------------------------------------*/

View File

@ -641,7 +641,7 @@ cc2420_init(void)
init_security();
cc2420_set_pan_addr(0xffff, 0x0000, NULL);
cc2420_set_channel(CC2420_CONF_CHANNEL);
cc2420_set_channel(IEEE802154_DEFAULT_CHANNEL);
cc2420_set_cca_threshold(CC2420_CONF_CCA_THRESH);
flushrx();

View File

@ -50,10 +50,6 @@
#define WITH_SEND_CCA 1
#ifndef CC2420_CONF_CHANNEL
#define CC2420_CONF_CHANNEL 26
#endif /* CC2420_CONF_CHANNEL */
#ifndef CC2420_CONF_CCA_THRESH
#define CC2420_CONF_CCA_THRESH -45
#endif /* CC2420_CONF_CCA_THRESH */

View File

@ -113,13 +113,15 @@ static spi_device_t flash_spi_configuration_default = {
/**
* Get spi configuration, return default configuration if NULL
*/
static spi_device_t*
get_spi_conf(spi_device_t *conf) {
static spi_device_t *
get_spi_conf(spi_device_t *conf)
{
if(conf == NULL) {
return &flash_spi_configuration_default;
}
return conf;
}/*---------------------------------------------------------------------------*/
}
/*---------------------------------------------------------------------------*/
/**
* Clear external flash CSN line
*/
@ -334,7 +336,7 @@ ext_flash_open(spi_device_t *conf)
/* Put the part is standby mode */
power_standby(flash_spi_configuration);
if (verify_part(flash_spi_configuration) == VERIFY_PART_OK) {
if(verify_part(flash_spi_configuration) == VERIFY_PART_OK) {
return true;
}
@ -353,7 +355,7 @@ ext_flash_close(spi_device_t *conf)
/* Put the part in low power mode */
ret = power_down(flash_spi_configuration);
/* SPI is released no matter if power_down() succeeds or fails */
if(spi_release(flash_spi_configuration) != SPI_DEV_STATUS_OK) {
return false;
@ -474,7 +476,7 @@ ext_flash_erase(spi_device_t *conf, uint32_t offset, uint32_t length)
uint8_t wbuf[4];
uint32_t i, numsectors;
uint32_t endoffset = offset + length - 1;
spi_device_t *flash_spi_configuration;
flash_spi_configuration = get_spi_conf(conf);

View File

@ -37,3 +37,17 @@ else
sort -g | head -1))
$(PYTHON) $(BSL) $(BSL_FLAGS) $(BSL_ADDRESS_ARG) $<
endif
ifeq ($(HOST_OS),Darwin)
RENODE = mono /Applications/Renode.app/Contents/MacOS/bin/Renode.exe
else
RENODE = renode
endif
SCRIPT ?= $(notdir $(CURDIR)).resc
.PHONY: renode
renode: all
$(RENODE) $(SCRIPT)

View File

@ -57,5 +57,3 @@ const leds_t leds_arch_leds[] = {
#endif
};
/*---------------------------------------------------------------------------*/

View File

@ -106,7 +106,7 @@ set_rf_params(void)
NETSTACK_RADIO.set_value(RADIO_PARAM_PAN_ID, IEEE802154_PANID);
NETSTACK_RADIO.set_value(RADIO_PARAM_16BIT_ADDR, short_addr);
NETSTACK_RADIO.set_value(RADIO_PARAM_CHANNEL, CC2538_RF_CHANNEL);
NETSTACK_RADIO.set_value(RADIO_PARAM_CHANNEL, IEEE802154_DEFAULT_CHANNEL);
NETSTACK_RADIO.set_object(RADIO_PARAM_64BIT_ADDR, ext_addr, 8);
}
/*---------------------------------------------------------------------------*/

View File

@ -133,7 +133,6 @@ typedef uint64_t rtimer_clock_t;
#define CFS_CONF_OFFSET_TYPE long
#define RF_CHANNEL 26
#define NETSTACK_RADIO_MAX_PAYLOAD_LEN 125
#define PLATFORM_CONF_SUPPORTS_STACK_CHECK 0

View File

@ -180,12 +180,12 @@ else
ifeq ($(HOST_OS),Darwin)
USBDEVPREFIX=
USBDEVBASENAME=/dev/tty.usbserial-
SERIALDUMP ?= $(CONTIKI)/tools/jn516x/serialdump-macos
SERIALDUMP ?= rlwrap $(CONTIKI)/tools/jn516x/serialdump-macos
else
# Else we assume Linux
USBDEVPREFIX=
USBDEVBASENAME=/dev/ttyUSB
SERIALDUMP ?= $(CONTIKI)/tools/jn516x/serialdump-linux
SERIALDUMP ?= rlwrap $(CONTIKI)/tools/jn516x/serialdump-linux
endif
endif

View File

@ -40,14 +40,6 @@
#include "jn516x-def.h"
#ifdef RF_CHANNEL
#define MICROMAC_CONF_CHANNEL RF_CHANNEL
#endif
#ifndef MICROMAC_CONF_CHANNEL
#define MICROMAC_CONF_CHANNEL 26
#endif
/* Configure radio driver */
#ifndef NETSTACK_CONF_RADIO
#define NETSTACK_CONF_RADIO micromac_radio_driver

View File

@ -100,11 +100,6 @@
#define MIRCOMAC_CONF_BUF_NUM 2
#endif /* MIRCOMAC_CONF_BUF_NUM */
/* Init radio channel */
#ifndef MICROMAC_CONF_CHANNEL
#define MICROMAC_CONF_CHANNEL 26
#endif
/* Default energy level threshold for clear channel detection */
#ifndef MICROMAC_CONF_CCA_THR
#define MICROMAC_CONF_CCA_THR 39 /* approximately -85 dBm */
@ -159,7 +154,7 @@ static uint8_t autoack_enabled = MICROMAC_CONF_AUTOACK;
static uint8_t send_on_cca = 0;
/* Current radio channel */
static int current_channel = MICROMAC_CONF_CHANNEL;
static int current_channel = IEEE802154_DEFAULT_CHANNEL;
/* Current set point tx power
Actual tx power may be different. Use get_txpower() for actual power */

View File

@ -6,8 +6,8 @@ endif
CONTIKI_TARGET_DIRS = . dev
CONTIKI_TARGET_MAIN = ${addprefix $(OBJECTDIR)/,contiki-main.o}
CONTIKI_TARGET_SOURCEFILES += platform.c clock.c xmem.c leds-arch.c
CONTIKI_TARGET_SOURCEFILES += cfs-posix.c cfs-posix-dir.c
CONTIKI_TARGET_SOURCEFILES += platform.c clock.c xmem.c
CONTIKI_TARGET_SOURCEFILES += cfs-posix.c cfs-posix-dir.c buttons.c
ifeq ($(HOST_OS),Windows)
CONTIKI_TARGET_SOURCEFILES += wpcap-drv.c wpcap.c

View File

@ -37,7 +37,9 @@
#ifdef PROJECT_CONF_PATH
#include PROJECT_CONF_PATH
#endif /* PROJECT_CONF_PATH */
/*---------------------------------------------------------------------------*/
#include "native-def.h"
/*---------------------------------------------------------------------------*/
#include <inttypes.h>
#ifndef WIN32_LEAN_AND_MEAN
#include <sys/select.h>
@ -60,8 +62,6 @@ int select_set_callback(int fd, const struct select_callback *callback);
typedef unsigned int uip_stats_t;
#define LEDS_CONF_LEGACY_API 1
#ifndef UIP_CONF_BYTE_ORDER
#define UIP_CONF_BYTE_ORDER UIP_LITTLE_ENDIAN
#endif
@ -91,6 +91,8 @@ typedef unsigned long clock_time_t;
#define LOG_CONF_ENABLED 1
#define PLATFORM_SUPPORTS_BUTTON_HAL 1
/* Not part of C99 but actually present */
int strcasecmp(const char*, const char*);

View File

@ -1,10 +1,11 @@
/*
* Copyright (c) 2018, RISE SICS AB.
* Copyright (c) 2018, George Oikonomou - http://www.spd.gr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
@ -14,10 +15,10 @@
* 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 HOLDER AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* 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
* 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
@ -27,21 +28,13 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#error The CoAP example no longer fits the limited ROM in the Tmote Sky. \
Please select another platform with more ROM to compile the CoAP example.
/*---------------------------------------------------------------------------*/
#define COAP_OBSERVE_CLIENT 0
#include "contiki.h"
#include "dev/button-hal.h"
#define COAP_MAX_CHUNK_SIZE 48
/* Turn off DAO-ACK and probing to make code smaller */
#define RPL_CONF_WITH_DAO_ACK 0
#define LOG_CONF_LEVEL_MAIN 0
#define DCOSYNCH_CONF_ENABLED 0
#define PROCESS_CONF_NUMEVENTS 8
#include <stdint.h>
#include <string.h>
/*---------------------------------------------------------------------------*/
button_hal_button_t *button_hal_buttons[] = { NULL };
const uint8_t button_hal_button_count = 0;
/*---------------------------------------------------------------------------*/

View File

@ -56,6 +56,9 @@
#include "net/netstack.h"
#include "dev/serial-line.h"
#include "dev/button-hal.h"
#include "dev/gpio-hal.h"
#include "dev/leds.h"
#include "net/ipv6/uip.h"
#include "net/ipv6/uip-debug.h"
@ -251,6 +254,9 @@ platform_process_args(int argc, char**argv)
void
platform_init_stage_one()
{
gpio_hal_init();
button_hal_init();
leds_init();
return;
}
/*---------------------------------------------------------------------------*/

View File

@ -54,5 +54,3 @@ const leds_t leds_arch_leds[] = {
},
};
/*---------------------------------------------------------------------------*/

View File

@ -115,7 +115,7 @@ set_rf_params(void)
NETSTACK_RADIO.set_value(RADIO_PARAM_PAN_ID, IEEE802154_PANID);
NETSTACK_RADIO.set_value(RADIO_PARAM_16BIT_ADDR, short_addr);
NETSTACK_RADIO.set_value(RADIO_PARAM_CHANNEL, CC2538_RF_CHANNEL);
NETSTACK_RADIO.set_value(RADIO_PARAM_CHANNEL, IEEE802154_DEFAULT_CHANNEL);
NETSTACK_RADIO.set_object(RADIO_PARAM_64BIT_ADDR, ext_addr, 8);
}
/*---------------------------------------------------------------------------*/

View File

@ -54,7 +54,7 @@ else
ifeq ($(HOST_OS),Darwin)
ifndef MOTELIST
USBDEVPREFIX=
SERIALDUMP = $(CONTIKI)/tools/sky/serialdump-macos
SERIALDUMP = rlwrap $(CONTIKI)/tools/sky/serialdump-macos
MOTELIST = $(CONTIKI)/tools/sky/motelist-macos
TMOTE_BSL_FILE = tmote-bsl-linux
TMOTE_BSL=$(if $(wildcard $(CONTIKI)/tools/sky/$(TMOTE_BSL_FILE)),1,0)
@ -75,7 +75,7 @@ else
# Else we assume Linux
ifndef MOTELIST
USBDEVPREFIX=
SERIALDUMP = $(CONTIKI)/tools/sky/serialdump-linux
SERIALDUMP = rlwrap $(CONTIKI)/tools/sky/serialdump-linux
MOTELIST = $(CONTIKI)/tools/sky/motelist-linux
TMOTE_BSL_FILE = tmote-bsl-linux
TMOTE_BSL=$(if $(wildcard $(CONTIKI)/tools/sky/$(TMOTE_BSL_FILE)),1,0)

View File

@ -11,10 +11,6 @@
#include "sky-def.h"
#include "msp430-def.h"
/*---------------------------------------------------------------------------*/
/* Map RF_CHANNEL to cc2420 default channel */
#ifdef RF_CHANNEL
#define CC2420_CONF_CHANNEL RF_CHANNEL
#endif /* RF_CHANNEL */
/* Configure radio driver */
#ifndef NETSTACK_CONF_RADIO

View File

@ -204,15 +204,7 @@ platform_init_stage_three(void)
LOG_INFO("Node id: N/A\n");
}
#if NETSTACK_CONF_WITH_IPV6
LOG_INFO("%s, rf channel %u, CCA threshold %i\n",
NETSTACK_MAC.name,
CC2420_CONF_CHANNEL,
CC2420_CONF_CCA_THRESH);
#else /* NETSTACK_CONF_WITH_IPV6 */
LOG_INFO("%s, rf channel %u\n",
NETSTACK_MAC.name, CC2420_CONF_CHANNEL);
#endif /* NETSTACK_CONF_WITH_IPV6 */
LOG_INFO("CC2420 CCA threshold %i\n", CC2420_CONF_CCA_THRESH);
#if !NETSTACK_CONF_WITH_IPV6
uart1_set_input(serial_line_input_byte);

View File

@ -43,44 +43,41 @@
#include "contiki-conf.h"
#include "dev/xmem.h"
/*** MX25R8035F Memory Organization
The memory is organized as:
8Mbit = 1048576 bytes (8 bits each)
256 sectors (32 Kbits, 4096 bytes each)
4096 pages (256 bytes each).
Each page can be individually programmed (bits are programmed from 1 to 0). The device is
sector or bulk erasable (bits are erased from 0 to 1) but not page erasable
*/
#define COFFEE_XMEM_TOTAL_SIZE_KB 1024UL //Total size of the External Flash Memory in the Z1
/*
* MX25R8035F Memory Organization
* The memory is organized as:
* 8Mbit = 1048576 bytes (8 bits each)
* 256 sectors (32 Kbits, 4096 bytes each)
* 4096 pages (256 bytes each).
* Each page can be individually programmed (bits are programmed from 1 to 0).
* The device is sector or bulk erasable (bits are erased from 0 to 1) but not
* page erasable
*/
#define COFFEE_XMEM_TOTAL_SIZE_KB 1024UL /* Total size of the External Flash Memory in the Z1 */
/* Coffee configuration parameters. */
#define COFFEE_SECTOR_SIZE 4096UL
#define COFFEE_SECTOR_SIZE 4096UL
#define COFFEE_PAGE_SIZE 256UL
#define COFFEE_START 0UL //COFFEE_SECTOR_SIZE
#define COFFEE_START 0UL /* COFFEE_SECTOR_SIZE */
#define COFFEE_SIZE (COFFEE_XMEM_TOTAL_SIZE_KB * 1024UL - COFFEE_START)
#define COFFEE_NAME_LENGTH 16
#define COFFEE_MAX_OPEN_FILES 6
#define COFFEE_FD_SET_SIZE 8
#define COFFEE_LOG_TABLE_LIMIT 256
#define COFFEE_DYN_SIZE 2*1024
#define COFFEE_DYN_SIZE 2 * 1024
#define COFFEE_LOG_SIZE 1024
#define COFFEE_MICRO_LOGS 1
/* Flash operations. */
#define COFFEE_WRITE(buf, size, offset) \
xmem_pwrite((char *)(buf), (size), COFFEE_START + (offset))
#define COFFEE_WRITE(buf, size, offset) \
xmem_pwrite((char *)(buf), (size), COFFEE_START + (offset))
#define COFFEE_READ(buf, size, offset) \
xmem_pread((char *)(buf), (size), COFFEE_START + (offset))
#define COFFEE_READ(buf, size, offset) \
xmem_pread((char *)(buf), (size), COFFEE_START + (offset))
#define COFFEE_ERASE(sector) \
xmem_erase(COFFEE_SECTOR_SIZE, COFFEE_START + (sector) * COFFEE_SECTOR_SIZE)
#define COFFEE_ERASE(sector) \
xmem_erase(COFFEE_SECTOR_SIZE, COFFEE_START + (sector) * COFFEE_SECTOR_SIZE)
/* Coffee types. */
typedef int16_t coffee_page_t;

View File

@ -49,21 +49,17 @@
#define XMEM_BUFF_LENGHT 128
#if 0
#define PRINTF(...) printf(__VA_ARGS__)
#else
#define PRINTF(...) do {} while (0)
#define PRINTF(...) do {} while(0)
#endif
void
xmem_init(void)
{
ext_flash_open(NULL);
}
int
xmem_pread(void *_p, int size, unsigned long addr)
{
@ -80,21 +76,20 @@ xmem_pread(void *_p, int size, unsigned long addr)
}
rv = ext_flash_read(NULL, addr, size, _p);
for (i = 0; i < size; i++){
for(i = 0; i < size; i++) {
x = ~*((uint8_t *)_p + i);
*((uint8_t *)_p+i) = x;
*((uint8_t *)_p + i) = x;
}
ext_flash_close(NULL);
if(rv)
if(rv) {
return size;
}
PRINTF("Could not read flash memory!\n");
return -1;
}
}
int
xmem_pwrite(const void *_buf, int size, unsigned long addr)
{
@ -112,13 +107,13 @@ xmem_pwrite(const void *_buf, int size, unsigned long addr)
return -1;
}
for (remain = size, j = 0; remain > 0; remain -= XMEM_BUFF_LENGHT, j += XMEM_BUFF_LENGHT) {
for(remain = size, j = 0; remain > 0; remain -= XMEM_BUFF_LENGHT, j += XMEM_BUFF_LENGHT) {
int to_write = MIN(XMEM_BUFF_LENGHT, remain);
for (i = 0; i < to_write; i++) {
for(i = 0; i < to_write; i++) {
tmp_buf[i] = ~*((uint8_t *)_buf + j + i);
}
rv = ext_flash_write(NULL, addr + j, to_write, tmp_buf);
if (!rv) {
if(!rv) {
PRINTF("Could not write flash memory!\n");
return size - remain;
}
@ -128,8 +123,6 @@ xmem_pwrite(const void *_buf, int size, unsigned long addr)
return size;
}
int
xmem_erase(long size, unsigned long addr)
{
@ -137,7 +130,6 @@ xmem_erase(long size, unsigned long addr)
rv = ext_flash_open(NULL);
if(!rv) {
PRINTF("Could not open flash to save config\n");
ext_flash_close(NULL);
@ -160,8 +152,9 @@ xmem_erase(long size, unsigned long addr)
watchdog_periodic();
if(rv)
if(rv) {
return size;
}
PRINTF("Could not erase flash memory\n");
return -1;

View File

@ -41,5 +41,3 @@ const leds_t leds_arch_leds[] = {
{ .pin = BOARD_IOID_LED_2, .negative_logic = false },
};
/*---------------------------------------------------------------------------*/

View File

@ -128,7 +128,7 @@ set_rf_params(void)
NETSTACK_RADIO.set_value(RADIO_PARAM_PAN_ID, IEEE802154_PANID);
NETSTACK_RADIO.set_value(RADIO_PARAM_16BIT_ADDR, short_addr);
NETSTACK_RADIO.set_value(RADIO_PARAM_CHANNEL, RF_CORE_CHANNEL);
NETSTACK_RADIO.set_value(RADIO_PARAM_CHANNEL, IEEE802154_DEFAULT_CHANNEL);
NETSTACK_RADIO.set_object(RADIO_PARAM_64BIT_ADDR, ext_addr, 8);
/* also set the global node id */

View File

@ -39,5 +39,3 @@ const leds_t leds_arch_leds[] = {
{ .pin = BOARD_IOID_LED_1, .negative_logic = false },
};
/*---------------------------------------------------------------------------*/

View File

@ -40,5 +40,3 @@ const leds_t leds_arch_leds[] = {
{ .pin = BOARD_IOID_LED_2, .negative_logic = false },
};
/*---------------------------------------------------------------------------*/

View File

@ -42,5 +42,3 @@ const leds_t leds_arch_leds[] = {
{ .pin = BOARD_IOID_LED_4, .negative_logic = false },
};
/*---------------------------------------------------------------------------*/

View File

@ -56,11 +56,11 @@ ifeq ($(HOST_OS),Darwin)
USBDEVPREFIX=
MOTELIST := $(CONTIKI)/tools/zolertia/motelist-zolertia-macos
MOTES := $(shell $(MOTELIST) -c 2>&- | cut -f 2 -d ,)
SERIALDUMP := $(CONTIKI)/tools/sky/serialdump-macos
SERIALDUMP := rlwrap $(CONTIKI)/tools/sky/serialdump-macos
else
### If we are not running under Mac, we assume Linux
USBDEVPREFIX=
SERIALDUMP := $(CONTIKI)/tools/sky/serialdump-linux
SERIALDUMP := rlwrap $(CONTIKI)/tools/sky/serialdump-linux
MOTELIST := $(CONTIKI)/tools/zolertia/motelist-zolertia
MOTES := $(shell $(MOTELIST) -b $(MOTELIST_ZOLERTIA) -c 2>&- | cut -f 2 -d , | \
perl -ne 'print $$1 . " " if(m-(/dev/\w+)-);')

View File

@ -50,5 +50,3 @@ const leds_t leds_arch_leds[] = {
},
};
/*---------------------------------------------------------------------------*/

View File

@ -171,7 +171,7 @@ set_rf_params(void)
NETSTACK_RADIO.set_value(RADIO_PARAM_PAN_ID, IEEE802154_PANID);
NETSTACK_RADIO.set_value(RADIO_PARAM_16BIT_ADDR, short_addr);
NETSTACK_RADIO.set_value(RADIO_PARAM_CHANNEL, CC2538_RF_CHANNEL);
NETSTACK_RADIO.set_value(RADIO_PARAM_CHANNEL, IEEE802154_DEFAULT_CHANNEL);
NETSTACK_RADIO.set_object(RADIO_PARAM_64BIT_ADDR, ext_addr, 8);
}
/*---------------------------------------------------------------------------*/

View File

@ -28,8 +28,8 @@
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _PROJECT_CONF_H_
#define _PROJECT_CONF_H_
#ifndef PROJECT_CONF_H_
#define PROJECT_CONF_H_
#define UIP_CONF_ND6_SEND_RA 0
@ -39,4 +39,4 @@
#define LOG_CONF_LEVEL_6TOP LOG_LEVEL_DBG
#endif /* _PROJECT_CONF_H_ */
#endif /* PROJECT_CONF_H_ */

View File

@ -32,8 +32,8 @@
* \author Simon Duquennoy <simonduq@sics.se>
*/
#ifndef __PROJECT_CONF_H__
#define __PROJECT_CONF_H__
#ifndef PROJECT_CONF_H_
#define PROJECT_CONF_H_
/* Set to enable TSCH security */
#ifndef WITH_SECURITY
@ -115,4 +115,4 @@
#define LOG_CONF_LEVEL_6TOP LOG_LEVEL_DBG
#define TSCH_LOG_CONF_PER_SLOT 1
#endif /* __PROJECT_CONF_H__ */
#endif /* PROJECT_CONF_H_ */

View File

@ -32,8 +32,8 @@
* \author Simon Duquennoy <simonduq@sics.se>
*/
#ifndef __PROJECT_CONF_H__
#define __PROJECT_CONF_H__
#ifndef PROJECT_CONF_H_
#define PROJECT_CONF_H_
/* Set to enable TSCH security */
#ifndef WITH_SECURITY
@ -78,4 +78,4 @@
#define LOG_CONF_LEVEL_FRAMER LOG_LEVEL_DBG
#define TSCH_LOG_CONF_PER_SLOT 1
#endif /* __PROJECT_CONF_H__ */
#endif /* PROJECT_CONF_H_ */

View File

@ -28,8 +28,8 @@
*
*/
#ifndef __PROJECT_CONF_H__
#define __PROJECT_CONF_H__
#ifndef PROJECT_CONF_H_
#define PROJECT_CONF_H_
/* Set to enable TSCH security */
#ifndef WITH_SECURITY
@ -103,4 +103,4 @@
#endif /* CONTIKI_TARGET_CC2538DK || CONTIKI_TARGET_ZOUL \
|| CONTIKI_TARGET_OPENMOTE_CC2538 */
#endif /* __PROJECT_CONF_H__ */
#endif /* PROJECT_CONF_H_ */

View File

@ -1,38 +0,0 @@
CONTIKI_PROJECT = coap-example-server coap-example-client
# use target "plugtest-server" explicitly when required
all: $(CONTIKI_PROJECT)
CONTIKI=../..
# Do not try to build on Sky because of code size limitation
PLATFORMS_EXCLUDE = sky
# build RESTful resources
include $(CONTIKI)/Makefile.identify-target
ifeq ($(TARGET),native)
MODULES_REL += ./resources-plugtest
endif
MODULES_REL += ./resources
MODULES_REL += $(TARGET)
# Include the CoAP implementation
MODULES += os/net/app-layer/coap
include $(CONTIKI)/Makefile.include
# border router rules
$(CONTIKI)/tools/tunslip6: $(CONTIKI)/tools/tunslip6.c
(cd $(CONTIKI)/tools && $(MAKE) tunslip6)
connect-router: $(CONTIKI)/tools/tunslip6
sudo $(CONTIKI)/tools/tunslip6 fd00::1/64
connect-router-cooja: $(CONTIKI)/tools/tunslip6
sudo $(CONTIKI)/tools/tunslip6 -a 127.0.0.1 -p 60001 fd00::1/64
connect-router-native: $(CONTIKI)/examples/rpl-border-router/border-router.native
sudo $(CONTIKI)/examples/rpl-border-router/border-router.native -a 127.0.0.1 -p 60001 fd00::1/64
connect-native:
sudo ip address add fdfd::1/64 dev tun0

View File

@ -1,83 +1,9 @@
A Quick Introduction to the Erbium (Er) CoAP Engine
===================================================
# CoAP examples: client, server, and plugtest server
EXAMPLE FILES
-------------
* coap-example-server: A CoAP server example showing how to use the CoAP layer to develop server-side applications.
* coap-example-client: A CoAP client that polls the /actuators/toggle resource every 10 seconds and cycles through 4 resources on button press (target address is hard-coded).
* coap-plugtest-server: The server used for draft compliance testing at ETSI IoT CoAP Plugtests. Erbium (Er) participated in Paris, France, March 2012 and Sophia-Antipolis, France, November 2012 (configured for native).
- coap-example-server.c: A CoAP server example showing how to use the CoAP
layer to develop server-side applications.
- coap-example-client.c: A CoAP client that polls the /actuators/toggle resource
every 10 seconds and cycles through 4 resources on button press (target
address is hard-coded).
- plugtest-server.c: The server used for draft compliance testing at ETSI
IoT CoAP Plugtests. Erbium (Er) participated in Paris, France, March 2012 and
Sophia-Antipolis, France, November 2012 (configured for native).
PRELIMINARIES
-------------
- Get the Copper (Cu) CoAP user-agent from
[https://addons.mozilla.org/en-US/firefox/addon/copper-270430](https://addons.mozilla.org/en-US/firefox/addon/copper-270430)
TMOTE SKY HOWTO
---------------
The CoAP example no longer fits in the limited ROM of the Tmote Sky.
Please use a platform with larger ROM instead.
NATIVE HOWTO
------------
With the target native you can test your CoAP applications without
constraints, i.e., with large buffers, debug output, memory protection, etc.
The plugtest-server is thought for the native platform, as it requires
an 1280-byte IP buffer and 1024-byte blocks.
make TARGET=native plugtest-server
sudo ./plugtest-server.native
Open new terminal
make connect-native
- Start Copper and discover resources at coap://[fdfd::ff:fe00:10]:5683/
- You can enable the ETSI Plugtest menu in Copper's preferences
Under Windows/Cygwin, WPCAP might need a patch in
<cygwin>\usr\include\w32api\in6addr.h:
21,23c21
< #ifdef __INSIDE_CYGWIN__
< uint32_t __s6_addr32[4];
< #endif
---
> u_int __s6_addr32[4];
36d33
< #ifdef __INSIDE_CYGWIN__
39d35
< #endif
DETAILS
-------
Erbium implements the Proposed Standard of CoAP. Central features are commented
in coap-example-server.c. In general, coap supports:
- All draft-18 header options
- CON Retransmissions (note COAP_MAX_OPEN_TRANSACTIONS)
- Blockwise Transfers (note COAP_MAX_CHUNK_SIZE, see plugtest-server.c for
Block1 uploads)
- Separate Responses (no rest_set_pre_handler() required anymore, note
coap_separate_accept(), _reject(), and _resume())
- Resource Discovery
- Observing Resources (see EVENT_ and PERIODIC_RESOURCE, note
COAP_MAX_OBSERVERS)
TODOs
-----
- Dedicated Observe buffers
- Optimize message struct variable access (directly access struct without copying)
- Observe client
- Multiple If-Match ETags
- (Message deduplication)
The examples can run either on a real device or as native.
In the latter case, just start the executable with enough permissions (e.g. sudo), and you will then be able to reach the node via tun.
A tutorial for setting up the CoAP server example and querying it is provided on the wiki.

View File

@ -0,0 +1,12 @@
CONTIKI_PROJECT = coap-example-client
# coap-example-observe-client is outdated but will be ported at a later point
all: $(CONTIKI_PROJECT)
# Do not try to build on Sky because of code size limitation
PLATFORMS_EXCLUDE = sky
# Include the CoAP implementation
MODULES += os/net/app-layer/coap
CONTIKI=../../..
include $(CONTIKI)/Makefile.include

View File

@ -51,8 +51,8 @@
/* Log configuration */
#include "coap-log.h"
#define LOG_MODULE "client"
#define LOG_LEVEL LOG_LEVEL_COAP
#define LOG_MODULE "App"
#define LOG_LEVEL LOG_LEVEL_APP
/* FIXME: This server address is hard-coded for Cooja and link-local for unconnected border router. */
#define SERVER_EP "coap://[fe80::212:7402:0002:0202]"
@ -92,9 +92,6 @@ PROCESS_THREAD(er_example_client, ev, data)
coap_endpoint_parse(SERVER_EP, strlen(SERVER_EP), &server_ep);
/* receives all CoAP messages */
coap_engine_init();
etimer_set(&et, TOGGLE_INTERVAL * CLOCK_SECOND);
#if PLATFORM_HAS_BUTTON

View File

@ -47,15 +47,11 @@
#else
#include "dev/button-sensor.h"
#endif
/*----------------------------------------------------------------------------*/
#define DEBUG 0
#if DEBUG
#define PRINTF(...) printf(__VA_ARGS__)
#define PRINTFLN(format, ...) printf(format "\n", ##__VA_ARGS__)
#else
#define PRINTF(...)
#define PRINTFLN(...)
#endif
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "App"
#define LOG_LEVEL LOG_LEVEL_APP
/*----------------------------------------------------------------------------*/
/* FIXME: This server address is hard-coded for Cooja */
@ -145,8 +141,6 @@ PROCESS_THREAD(er_example_observe_client, ev, data)
/* store server address in server_ipaddr */
SERVER_NODE(server_ipaddr);
/* receives all CoAP messages */
coap_init_engine();
/* init timer and button (if available) */
etimer_set(&et, TOGGLE_INTERVAL * CLOCK_SECOND);
#if PLATFORM_HAS_BUTTON

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, Swedish Institute of Computer Science.
* Copyright (c) 2013, Institute for Pervasive Computing, ETH Zurich
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -27,34 +27,21 @@
* SUCH DAMAGE.
*
* This file is part of the Contiki operating system.
*
*/
/**
* \file
* A brief description of what this file is.
* Erbium (Er) example project configuration.
* \author
* Adam Dunkels <adam@sics.se>
* Matthias Kovatsch <kovatsch@inf.ethz.ch>
*/
#include "dev/leds.h"
static leds_mask_t leds;
/*---------------------------------------------------------------------------*/
void
leds_arch_init(void)
{
leds = 0;
}
/*---------------------------------------------------------------------------*/
leds_mask_t
leds_arch_get(void)
{
return leds;
}
/*---------------------------------------------------------------------------*/
void
leds_arch_set(leds_mask_t l)
{
leds = l;
}
/*---------------------------------------------------------------------------*/
#ifndef PROJECT_CONF_H_
#define PROJECT_CONF_H_
#define LOG_LEVEL_APP LOG_LEVEL_DBG
/* Enable client-side support for COAP observe */
#define COAP_OBSERVE_CLIENT 1
#endif /* PROJECT_CONF_H_ */

View File

@ -0,0 +1,14 @@
CONTIKI_PROJECT = coap-example-server
all: $(CONTIKI_PROJECT)
# Do not try to build on Sky because of code size limitation
PLATFORMS_EXCLUDE = sky
# Include the CoAP implementation
MODULES += os/net/app-layer/coap
# Include CoAP resources
MODULES_REL += ./resources
CONTIKI=../../..
include $(CONTIKI)/Makefile.include

View File

@ -48,14 +48,10 @@
#include "dev/button-sensor.h"
#endif
#define DEBUG 0
#if DEBUG
#include <stdio.h>
#define PRINTF(...) printf(__VA_ARGS__)
#else
#define PRINTF(...)
#endif
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "App"
#define LOG_LEVEL LOG_LEVEL_APP
/*
* Resources to be activated need to be imported through the extern keyword.
* The build system automatically compiles the resources in the corresponding sub-directory.
@ -84,17 +80,6 @@ extern coap_resource_t res_battery;
#include "dev/temperature-sensor.h"
extern coap_resource_t res_temperature;
#endif
/*
extern coap_resource_t res_battery;
#endif
#if PLATFORM_HAS_RADIO
extern coap_resource_t res_radio;
#endif
#if PLATFORM_HAS_SHT11
#include "dev/sht11/sht11-sensor.h"
extern coap_resource_t res_sht11;
#endif
*/
PROCESS(er_example_server, "Erbium Example Server");
AUTOSTART_PROCESSES(&er_example_server);
@ -105,22 +90,7 @@ PROCESS_THREAD(er_example_server, ev, data)
PROCESS_PAUSE();
PRINTF("Starting Erbium Example Server\n");
#ifdef RF_CHANNEL
PRINTF("RF channel: %u\n", RF_CHANNEL);
#endif
#ifdef IEEE802154_PANID
PRINTF("PAN ID: 0x%04X\n", IEEE802154_PANID);
#endif
PRINTF("uIP buffer: %u\n", UIP_BUFSIZE);
PRINTF("LL header: %u\n", UIP_LLH_LEN);
PRINTF("IP+UDP header: %u\n", UIP_IPUDPH_LEN);
PRINTF("CoAP max chunk: %u\n", COAP_MAX_CHUNK_SIZE);
/* Initialize the REST engine. */
coap_engine_init();
LOG_INFO("Starting Erbium Example Server\n");
/*
* Bind the resources to their Uri-Path.
@ -128,15 +98,15 @@ PROCESS_THREAD(er_example_server, ev, data)
* All static variables are the same for each URI path.
*/
coap_activate_resource(&res_hello, "test/hello");
coap_activate_resource(&res_mirror, "debug/mirror");
coap_activate_resource(&res_chunks, "test/chunks");
coap_activate_resource(&res_separate, "test/separate");
coap_activate_resource(&res_push, "test/push");
coap_activate_resource(&res_mirror, "debug/mirror");
coap_activate_resource(&res_chunks, "test/chunks");
coap_activate_resource(&res_separate, "test/separate");
coap_activate_resource(&res_push, "test/push");
#if PLATFORM_HAS_BUTTON
coap_activate_resource(&res_event, "sensors/button");
coap_activate_resource(&res_event, "sensors/button");
#endif /* PLATFORM_HAS_BUTTON */
coap_activate_resource(&res_sub, "test/sub");
coap_activate_resource(&res_b1_sep_b2, "test/b1sepb2");
coap_activate_resource(&res_sub, "test/sub");
coap_activate_resource(&res_b1_sep_b2, "test/b1sepb2");
#if PLATFORM_HAS_LEDS
/* coap_activate_resource(&res_leds, "actuators/leds"); */
coap_activate_resource(&res_toggle, "actuators/toggle");
@ -153,15 +123,6 @@ PROCESS_THREAD(er_example_server, ev, data)
coap_activate_resource(&res_temperature, "sensors/temperature");
SENSORS_ACTIVATE(temperature_sensor);
#endif
/*
#if PLATFORM_HAS_RADIO
coap_activate_resource(&res_radio, "sensors/radio");
#endif
#if PLATFORM_HAS_SHT11
coap_activate_resource(&res_sht11, "sensors/sht11");
SENSORS_ACTIVATE(sht11_sensor);
#endif
*/
/* Define application-specific events here. */
while(1) {
@ -172,7 +133,7 @@ PROCESS_THREAD(er_example_server, ev, data)
#else
if(ev == sensors_event && data == &button_sensor) {
#endif
PRINTF("*******BUTTON*******\n");
LOG_DBG("*******BUTTON*******\n");
/* Call the event_handler for this application-specific event. */
res_event.trigger();

View File

@ -36,37 +36,9 @@
* Matthias Kovatsch <kovatsch@inf.ethz.ch>
*/
#ifndef PROJECT_ERBIUM_CONF_H_
#define PROJECT_ERBIUM_CONF_H_
#ifndef PROJECT_CONF_H_
#define PROJECT_CONF_H_
/* Custom channel and PAN ID configuration for your project. */
/* #define RF_CHANNEL 26 */
/* #define IEEE802154_CONF_PANID 0xABCD */
#define LOG_LEVEL_APP LOG_LEVEL_DBG
/* IP buffer size must match all other hops, in particular the border router. */
/* #define UIP_CONF_BUFFER_SIZE 256 */
/* Increase rpl-border-router IP-buffer when using more than 64. */
#define COAP_MAX_CHUNK_SIZE 48
/* Estimate your header size, especially when using Proxy-Uri. */
/* #define COAP_MAX_HEADER_SIZE 70 */
/* Multiplies with chunk size, be aware of memory constraints. */
#ifndef COAP_MAX_OPEN_TRANSACTIONS
#define COAP_MAX_OPEN_TRANSACTIONS 4
#endif /* COAP_MAX_OPEN_TRANSACTIONS */
/* Must be <= open transactions, default is COAP_MAX_OPEN_TRANSACTIONS-1. */
/* #define COAP_MAX_OBSERVERS 2 */
/* Filtering .well-known/core per query can be disabled to save space. */
#define COAP_LINK_FORMAT_FILTERING 0
#define COAP_PROXY_OPTION_PROCESSING 0
/* Enable client-side support for COAP observe */
#ifndef COAP_OBSERVE_CLIENT
#define COAP_OBSERVE_CLIENT 1
#endif /* COAP_OBSERVE_CLIENT */
#endif /* PROJECT_ERBIUM_CONF_H_ */
#endif /* PROJECT_CONF_H_ */

View File

@ -41,17 +41,10 @@
#include "coap-engine.h"
#include "coap.h"
#define DEBUG 0
#if DEBUG
#include <stdio.h>
#define PRINTF(...) printf(__VA_ARGS__)
#define PRINT6ADDR(addr) PRINTF("[%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x]", ((uint8_t *)addr)[0], ((uint8_t *)addr)[1], ((uint8_t *)addr)[2], ((uint8_t *)addr)[3], ((uint8_t *)addr)[4], ((uint8_t *)addr)[5], ((uint8_t *)addr)[6], ((uint8_t *)addr)[7], ((uint8_t *)addr)[8], ((uint8_t *)addr)[9], ((uint8_t *)addr)[10], ((uint8_t *)addr)[11], ((uint8_t *)addr)[12], ((uint8_t *)addr)[13], ((uint8_t *)addr)[14], ((uint8_t *)addr)[15])
#define PRINTLLADDR(lladdr) PRINTF("[%02x:%02x:%02x:%02x:%02x:%02x]", (lladdr)->addr[0], (lladdr)->addr[1], (lladdr)->addr[2], (lladdr)->addr[3], (lladdr)->addr[4], (lladdr)->addr[5])
#else
#define PRINTF(...)
#define PRINT6ADDR(addr)
#define PRINTLLADDR(addr)
#endif
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "App"
#define LOG_LEVEL LOG_LEVEL_APP
static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void res_event_handler(void);
@ -94,7 +87,7 @@ res_event_handler(void)
/* Usually a condition is defined under with subscribers are notified, e.g., event was above a threshold. */
if(1) {
PRINTF("TICK %u for /%s\n", event_counter, res_event.url);
LOG_DBG("TICK %u for /%s\n", (unsigned)event_counter, res_event.url);
/* Notify the registered observers which will trigger the res_get_handler to create the response. */
coap_notify_observers(&res_event);

View File

@ -75,7 +75,9 @@ res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff
memcpy(buffer, message, length);
} else {
memcpy(buffer, message, length);
} coap_set_header_content_format(response, TEXT_PLAIN); /* text/plain is the default, hence this option could be omitted. */
}
coap_set_header_content_format(response, TEXT_PLAIN); /* text/plain is the default, hence this option could be omitted. */
coap_set_header_etag(response, (uint8_t *)&length, 1);
coap_set_payload(response, buffer, length);
}

View File

@ -44,17 +44,10 @@
#if PLATFORM_HAS_LEDS || LEDS_COUNT
#define DEBUG 0
#if DEBUG
#include <stdio.h>
#define PRINTF(...) printf(__VA_ARGS__)
#define PRINT6ADDR(addr) PRINTF("[%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x]", ((uint8_t *)addr)[0], ((uint8_t *)addr)[1], ((uint8_t *)addr)[2], ((uint8_t *)addr)[3], ((uint8_t *)addr)[4], ((uint8_t *)addr)[5], ((uint8_t *)addr)[6], ((uint8_t *)addr)[7], ((uint8_t *)addr)[8], ((uint8_t *)addr)[9], ((uint8_t *)addr)[10], ((uint8_t *)addr)[11], ((uint8_t *)addr)[12], ((uint8_t *)addr)[13], ((uint8_t *)addr)[14], ((uint8_t *)addr)[15])
#define PRINTLLADDR(lladdr) PRINTF("[%02x:%02x:%02x:%02x:%02x:%02x]", (lladdr)->addr[0], (lladdr)->addr[1], (lladdr)->addr[2], (lladdr)->addr[3], (lladdr)->addr[4], (lladdr)->addr[5])
#else
#define PRINTF(...)
#define PRINT6ADDR(addr)
#define PRINTLLADDR(addr)
#endif
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "App"
#define LOG_LEVEL LOG_LEVEL_APP
static void res_post_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
@ -76,7 +69,7 @@ res_post_put_handler(coap_message_t *request, coap_message_t *response, uint8_t
int success = 1;
if((len = coap_get_query_variable(request, "color", &color))) {
PRINTF("color %.*s\n", len, color);
LOG_DBG("color %.*s\n", (int)len, color);
if(strncmp(color, "r", len) == 0) {
led = LEDS_RED;
@ -90,7 +83,7 @@ res_post_put_handler(coap_message_t *request, coap_message_t *response, uint8_t
} else {
success = 0;
} if(success && (len = coap_get_post_variable(request, "mode", &mode))) {
PRINTF("mode %s\n", mode);
LOG_DBG("mode %s\n", mode);
if(strncmp(mode, "on", len) == 0) {
leds_on(led);

View File

@ -41,17 +41,10 @@
#include "coap-engine.h"
#include "coap.h"
#define DEBUG 0
#if DEBUG
#include <stdio.h>
#define PRINTF(...) printf(__VA_ARGS__)
#define PRINT6ADDR(addr) PRINTF("[%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x]", ((uint8_t *)addr)[0], ((uint8_t *)addr)[1], ((uint8_t *)addr)[2], ((uint8_t *)addr)[3], ((uint8_t *)addr)[4], ((uint8_t *)addr)[5], ((uint8_t *)addr)[6], ((uint8_t *)addr)[7], ((uint8_t *)addr)[8], ((uint8_t *)addr)[9], ((uint8_t *)addr)[10], ((uint8_t *)addr)[11], ((uint8_t *)addr)[12], ((uint8_t *)addr)[13], ((uint8_t *)addr)[14], ((uint8_t *)addr)[15])
#define PRINTLLADDR(lladdr) PRINTF("[%02x:%02x:%02x:%02x:%02x:%02x]", (lladdr)->addr[0], (lladdr)->addr[1], (lladdr)->addr[2], (lladdr)->addr[3], (lladdr)->addr[4], (lladdr)->addr[5])
#else
#define PRINTF(...)
#define PRINT6ADDR(addr)
#define PRINTLLADDR(addr)
#endif
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "App"
#define LOG_LEVEL LOG_LEVEL_APP
static void res_any_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
@ -158,7 +151,7 @@ res_any_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff
}
coap_set_payload(response, buffer, strpos);
PRINTF("/mirror options received: %s\n", buffer);
LOG_DBG("/mirror options received: %s\n", buffer);
/* Set dummy header options for response. Like getters, some setters are not implemented for HTTP and have no effect. */
coap_set_header_content_format(response, TEXT_PLAIN);

View File

@ -0,0 +1,14 @@
CONTIKI_PROJECT = coap-plugtest-server
all: $(CONTIKI_PROJECT)
# Only intended for native
PLATFORMS_ONLY = native
# Include the CoAP implementation
MODULES += os/net/app-layer/coap
# Include CoAP resources
MODULES_REL += ./resources
CONTIKI=../../..
include $(CONTIKI)/Makefile.include

View File

@ -45,7 +45,11 @@
#include "coap-transactions.h"
#include "coap-separate.h"
#include "coap-engine.h"
#include "plugtest.h"
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "Plugtest"
#define LOG_LEVEL LOG_LEVEL_PLUGTEST
/*
* Resources to be activated need to be imported through the extern keyword.
@ -80,22 +84,7 @@ PROCESS_THREAD(plugtest_server, ev, data)
{
PROCESS_BEGIN();
PRINTF("ETSI IoT CoAP Plugtests Server\n");
#ifdef RF_CHANNEL
PRINTF("RF channel: %u\n", RF_CHANNEL);
#endif
#ifdef IEEE802154_PANID
PRINTF("PAN ID: 0x%04X\n", IEEE802154_PANID);
#endif
PRINTF("uIP buffer: %u\n", UIP_BUFSIZE);
PRINTF("LL header: %u\n", UIP_LLH_LEN);
PRINTF("IP+UDP header: %u\n", UIP_IPUDPH_LEN);
PRINTF("REST max chunk: %u\n", REST_MAX_CHUNK_SIZE);
/* Initialize the REST engine. */
coap_engine_init();
LOG_INFO("ETSI IoT CoAP Plugtests Server\n");
/* Activate the application-specific resources. */
coap_activate_resource(&res_plugtest_test, "test");

View File

@ -36,20 +36,10 @@
* Matthias Kovatsch <kovatsch@inf.ethz.ch>
*/
#ifndef PLUGTEST_H_
#define PLUGTEST_H_
#ifndef PROJECT_CONF_H_
#define PROJECT_CONF_H_
#if !defined(CONTIKI_TARGET_NATIVE)
#warning "Should only be compiled for native!"
#endif
#define DEBUG 0
#if DEBUG
#include <stdio.h>
#define PRINTF(...) printf(__VA_ARGS__)
#else
#define PRINTF(...)
#endif
#define LOG_LEVEL_PLUGTEST LOG_LEVEL_DBG
/* double expansion */
#define TO_STRING2(x) # x
@ -59,4 +49,4 @@
#define MAX_PLUGFEST_BODY 2048
#define CHUNKS_TOTAL 2012
#endif /* PLUGTEST_H_ */
#endif /* PROJECT_CONF_H_ */

View File

@ -0,0 +1,171 @@
/*
* Copyright (c) 2013, Institute for Pervasive Computing, ETH Zurich
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the Contiki operating system.
*/
/**
* \file
* Example resource
* \author
* Matthias Kovatsch <kovatsch@inf.ethz.ch>
*/
#include <stdio.h>
#include <string.h>
#include "coap-engine.h"
#include "coap.h"
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "Plugtest"
#define LOG_LEVEL LOG_LEVEL_PLUGTEST
static void res_any_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
/* This resource mirrors the incoming request. It shows how to access the options and how to set them for the response. */
RESOURCE(res_mirror,
"title=\"Returns your decoded message\";rt=\"Debug\"",
res_any_handler,
res_any_handler,
res_any_handler,
res_any_handler);
static void
res_any_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
/* The ETag and Token is copied to the header. */
uint8_t opaque[] = { 0x0A, 0xBC, 0xDE };
/* Strings are not copied, so use static string buffers or strings in .text memory (char *str = "string in .text";). */
static char location[] = { '/', 'f', '/', 'a', '?', 'k', '&', 'e', 0 };
/* No default my be assumed for the Content-Format. (Unsigned -1 means all bits set.) */
unsigned int content_format = -1;
/* The other getters copy the value (or string/array pointer) to the given pointers and return 1 for success or the length of strings/arrays. */
uint32_t longint = 0;
const char *str = NULL;
const uint8_t *bytes = NULL;
uint32_t block_num = 0;
uint8_t block_more = 0;
uint16_t block_size = 0;
int len = 0;
/* Mirror the received header options in the response payload. Unsupported getters (e.g., rest_get_header_observe() with HTTP) will return 0. */
int strpos = 0;
/* snprintf() counts the terminating '\0' to the size parameter.
* The additional byte is taken care of by allocating REST_MAX_CHUNK_SIZE+1 bytes in the REST framework.
* Add +1 to fill the complete buffer, as the payload does not need a terminating '\0'. */
if(coap_get_header_content_format(request, &content_format)) {
strpos += snprintf((char *)buffer, REST_MAX_CHUNK_SIZE + 1, "CF %u\n", content_format);
}
if(strpos <= REST_MAX_CHUNK_SIZE && (len = coap_get_header_accept(request, &content_format))) {
strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "Ac %u\n", content_format);
/* Some getters such as for ETag or Location are omitted, as these options should not appear in a request.
* Max-Age might appear in HTTP requests or used for special purposes in CoAP. */
}
if(strpos <= REST_MAX_CHUNK_SIZE && coap_get_header_max_age(request, &longint)) {
strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "MA %lu\n", (unsigned long) longint);
/* For HTTP this is the Length option, for CoAP it is the Size option. */
}
if(strpos <= REST_MAX_CHUNK_SIZE && coap_get_header_size1(request, &longint)) {
strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "SZ %lu\n", (unsigned long) longint);
}
if(strpos <= REST_MAX_CHUNK_SIZE && (len = coap_get_header_uri_host(request, &str))) {
strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "UH %.*s\n", len, str);
}
if(strpos <= REST_MAX_CHUNK_SIZE && (len = coap_get_header_uri_path(request, &str))) {
strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "UP %.*s\n", len, str);
}
if(strpos <= REST_MAX_CHUNK_SIZE && (len = coap_get_header_uri_query(request, &str))) {
strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "UQ %.*s\n", len, str);
/* Undefined request options for debugging: actions not required for normal RESTful Web service. */
}
if(strpos <= REST_MAX_CHUNK_SIZE && (len = coap_get_header_location_path(request, &str))) {
strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "LP %.*s\n", len, str);
}
if(strpos <= REST_MAX_CHUNK_SIZE && (len = coap_get_header_location_query(request, &str))) {
strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "LQ %.*s\n", len, str);
/* CoAP-specific example: actions not required for normal RESTful Web service. */
}
coap_message_t *const coap_pkt = (coap_message_t *)request;
if(strpos <= REST_MAX_CHUNK_SIZE && coap_pkt->token_len > 0) {
strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "To 0x");
int index = 0;
for(index = 0; index < coap_pkt->token_len; ++index) {
strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "%02X", coap_pkt->token[index]);
}
strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "\n");
}
if(strpos <= REST_MAX_CHUNK_SIZE && coap_is_option(coap_pkt, COAP_OPTION_OBSERVE)) {
strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "Ob %lu\n", (unsigned long) coap_pkt->observe);
}
if(strpos <= REST_MAX_CHUNK_SIZE && coap_is_option(coap_pkt, COAP_OPTION_ETAG)) {
strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "ET 0x");
int index = 0;
for(index = 0; index < coap_pkt->etag_len; ++index) {
strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "%02X", coap_pkt->etag[index]);
}
strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "\n");
}
if(strpos <= REST_MAX_CHUNK_SIZE && coap_get_header_block2(request, &block_num, &block_more, &block_size, NULL)) { /* This getter allows NULL pointers to get only a subset of the block parameters. */
strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "B2 %lu%s (%u)\n", (unsigned long) block_num, block_more ? "+" : "", block_size);
}
if(strpos <= REST_MAX_CHUNK_SIZE && coap_get_header_block1(request, &block_num, &block_more, &block_size, NULL)) {
strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "B1 %lu%s (%u)\n", (unsigned long) block_num, block_more ? "+" : "", block_size);
}
if(strpos <= REST_MAX_CHUNK_SIZE && (len = coap_get_payload(request, &bytes))) {
strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "%.*s", len, bytes);
}
if(strpos >= REST_MAX_CHUNK_SIZE) {
buffer[REST_MAX_CHUNK_SIZE - 1] = 0xBB; /* '»' to indicate truncation */
}
coap_set_payload(response, buffer, strpos);
LOG_DBG("/mirror options received: %s\n", buffer);
/* Set dummy header options for response. Like getters, some setters are not implemented for HTTP and have no effect. */
coap_set_header_content_format(response, TEXT_PLAIN);
coap_set_header_max_age(response, 17); /* For HTTP, browsers will not re-request the page for 17 seconds. */
coap_set_header_etag(response, opaque, 2);
coap_set_header_location_path(response, location); /* Initial slash is omitted by framework */
coap_set_header_size1(response, strpos); /* For HTTP, browsers will not re-request the page for 10 s. CoAP action depends on the client. */
/* CoAP-specific example: actions not required for normal RESTful Web service. */
coap_set_header_uri_host(response, "tiki");
coap_set_header_observe(response, 10);
coap_set_header_proxy_uri(response, "ftp://x");
coap_set_header_block2(response, 42, 0, 64); /* The block option might be overwritten by the framework when blockwise transfer is requested. */
coap_set_header_block1(response, 23, 0, 16);
coap_set_header_accept(response, TEXT_PLAIN);
coap_set_header_if_none_match(response);
}

View File

@ -39,7 +39,11 @@
#include <string.h>
#include "coap-engine.h"
#include "coap.h"
#include "plugtest.h"
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "Plugtest"
#define LOG_LEVEL LOG_LEVEL_PLUGTEST
static void res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void res_delete_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
@ -56,7 +60,7 @@ static uint8_t create1_exists = 0;
static void
res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
PRINTF("/create1 PUT");
LOG_DBG("/create1 PUT");
if(coap_get_header_if_none_match(request)) {
if(!create1_exists) {
@ -73,7 +77,7 @@ res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff
static void
res_delete_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
PRINTF("/create1 DELETE ");
LOG_DBG("/create1 DELETE ");
coap_set_status_code(response, DELETED_2_02);
create1_exists = 0;

View File

@ -39,7 +39,11 @@
#include <string.h>
#include "coap-engine.h"
#include "coap.h"
#include "plugtest.h"
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "Plugtest"
#define LOG_LEVEL LOG_LEVEL_PLUGTEST
static void res_post_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
@ -53,7 +57,7 @@ RESOURCE(res_plugtest_create2,
static void
res_post_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
PRINTF("/create2 ");
LOG_DBG("/create2 ");
coap_set_status_code(response, CREATED_2_01);
coap_set_header_location_path(response, "/location1/location2/location3");

View File

@ -39,7 +39,11 @@
#include <string.h>
#include "coap-engine.h"
#include "coap.h"
#include "plugtest.h"
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "Plugtest"
#define LOG_LEVEL LOG_LEVEL_PLUGTEST
static void res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void res_delete_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
@ -56,7 +60,7 @@ static uint8_t create3_exists = 0;
static void
res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
PRINTF("/create3 PUT ");
LOG_DBG("/create3 PUT ");
if(coap_get_header_if_none_match(request)) {
if(!create3_exists) {
@ -73,7 +77,7 @@ res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff
static void
res_delete_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
PRINTF("/create3 DELETE ");
LOG_DBG("/create3 DELETE ");
coap_set_status_code(response, DELETED_2_02);
create3_exists = 0;

View File

@ -39,7 +39,11 @@
#include <string.h>
#include "coap-engine.h"
#include "coap.h"
#include "plugtest.h"
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "Plugtest"
#define LOG_LEVEL LOG_LEVEL_PLUGTEST
static void res_post_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);

View File

@ -41,7 +41,11 @@
#include "sys/cc.h"
#include "coap-engine.h"
#include "coap.h"
#include "plugtest.h"
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "Plugtest"
#define LOG_LEVEL LOG_LEVEL_PLUGTEST
static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);

View File

@ -40,7 +40,11 @@
#include <string.h>
#include "coap-engine.h"
#include "coap.h"
#include "plugtest.h"
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "Plugtest"
#define LOG_LEVEL LOG_LEVEL_PLUGTEST
static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);

View File

@ -39,7 +39,11 @@
#include <string.h>
#include "coap-engine.h"
#include "coap.h"
#include "plugtest.h"
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "Plugtest"
#define LOG_LEVEL LOG_LEVEL_PLUGTEST
static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);

View File

@ -39,7 +39,11 @@
#include <string.h>
#include "coap-engine.h"
#include "coap.h"
#include "plugtest.h"
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "Plugtest"
#define LOG_LEVEL LOG_LEVEL_PLUGTEST
static void res_post_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
@ -53,11 +57,9 @@ RESOURCE(res_plugtest_locquery,
static void
res_post_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
#if DEBUG
coap_message_t *const coap_req = (coap_message_t *)request;
#endif
PRINTF(
LOG_DBG(
"/location-query POST (%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid);
coap_set_status_code(response, CREATED_2_01);

View File

@ -41,7 +41,11 @@
#include <string.h>
#include "coap-engine.h"
#include "coap.h"
#include "plugtest.h"
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "Plugtest"
#define LOG_LEVEL LOG_LEVEL_PLUGTEST
static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
@ -57,7 +61,7 @@ res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff
{
coap_message_t *const coap_req = (coap_message_t *)request;
PRINTF("/seg1/seg2/seg3 GET ");
LOG_DBG("/seg1/seg2/seg3 GET ");
/* Code 2.05 CONTENT is default. */
coap_set_header_content_format(response, TEXT_PLAIN);
coap_set_payload(
@ -66,5 +70,5 @@ res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff
snprintf((char *)buffer, MAX_PLUGFEST_PAYLOAD,
"Type: %u\nCode: %u\nMID: %u", coap_req->type, coap_req->code, coap_req->mid));
PRINTF("(%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid);
LOG_DBG_("(%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid);
}

View File

@ -40,7 +40,11 @@
#include <string.h>
#include "coap-engine.h"
#include "coap.h"
#include "plugtest.h"
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "Plugtest"
#define LOG_LEVEL LOG_LEVEL_PLUGTEST
static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
@ -59,7 +63,7 @@ res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff
unsigned int accept = -1;
coap_get_header_accept(request, &accept);
PRINTF("/multi-format GET (%s %u) ", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid);
LOG_DBG("/multi-format GET (%s %u) ", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid);
if(accept == -1 || accept == TEXT_PLAIN) {
coap_set_header_content_format(response, TEXT_PLAIN);
@ -69,7 +73,7 @@ res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff
snprintf((char *)buffer, MAX_PLUGFEST_PAYLOAD,
"Type: %u\nCode: %u\nMID: %u%s", coap_req->type, coap_req->code,
coap_req->mid, accept != -1 ? "\nAccept: 0" : ""));
PRINTF("PLAIN\n");
LOG_DBG_("PLAIN\n");
} else if(accept == APPLICATION_XML) {
coap_set_header_content_format(response, APPLICATION_XML);
coap_set_payload(
@ -78,11 +82,11 @@ res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff
snprintf((char *)buffer, MAX_PLUGFEST_PAYLOAD,
"<status type=\"%u\" code=\"%u\" mid=\"%u\" accept=\"%u\"/>",
coap_req->type, coap_req->code, coap_req->mid, accept));
PRINTF("XML\n");
LOG_DBG_("XML\n");
} else {
coap_set_status_code(response, NOT_ACCEPTABLE_4_06);
const char *msg = "Supporting content-types text/plain and application/xml";
coap_set_payload(response, msg, strlen(msg));
PRINTF("ERROR\n");
LOG_DBG_("ERROR\n");
}
}

View File

@ -41,7 +41,11 @@
#include "coap-engine.h"
#include "coap.h"
#include "coap-observe.h"
#include "plugtest.h"
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "Plugtest"
#define LOG_LEVEL LOG_LEVEL_PLUGTEST
static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
@ -67,7 +71,7 @@ static char obs_status = 0;
static void
obs_purge_list()
{
PRINTF("### SERVER ACTION ### Purging obs list");
LOG_DBG("### SERVER ACTION ### Purging obs list\n");
coap_remove_observer_by_uri(NULL, res_plugtest_obs.url);
}
static void
@ -75,7 +79,7 @@ res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff
{
/* Keep server log clean from ticking events */
if(request != NULL) {
PRINTF("/obs GET\n");
LOG_DBG("/obs GET\n");
}
coap_set_header_content_format(response, obs_format);
coap_set_header_max_age(response, 5);
@ -98,7 +102,7 @@ res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff
coap_get_header_content_format(request, &ct);
PRINTF("/obs PUT\n");
LOG_DBG("/obs PUT\n");
if(ct != obs_format) {
obs_status = 1;
@ -115,7 +119,7 @@ res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff
static void
res_delete_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
PRINTF("/obs DELETE\n");
LOG_DBG("/obs DELETE\n");
obs_status = 2;
@ -130,14 +134,12 @@ res_periodic_handler()
{
++obs_counter;
/* PRINTF("TICK %u for /%s\n", obs_counter, r->url); */
if(obs_status == 1) {
/* Notify the registered observers with the given message type, observe option, and payload. */
coap_notify_observers(&res_plugtest_obs);
PRINTF("######### sending 5.00\n");
LOG_DBG("######### sending 5.00\n");
obs_purge_list();
} else if(obs_status == 2) {

View File

@ -40,7 +40,11 @@
#include <string.h>
#include "coap-engine.h"
#include "coap.h"
#include "plugtest.h"
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "Plugtest"
#define LOG_LEVEL LOG_LEVEL_PLUGTEST
static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);

View File

@ -40,7 +40,11 @@
#include <string.h>
#include "coap-engine.h"
#include "coap.h"
#include "plugtest.h"
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "Plugtest"
#define LOG_LEVEL LOG_LEVEL_PLUGTEST
static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
@ -58,11 +62,11 @@ res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff
int len = 0;
const char *query = NULL;
PRINTF(
LOG_DBG(
"/query GET (%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid);
if((len = coap_get_header_uri_query(request, &query))) {
PRINTF("Query: %.*s\n", len, query);
LOG_DBG("Query: %.*s\n", len, query);
/* Code 2.05 CONTENT is default. */
}
coap_set_header_content_format(response,

View File

@ -42,7 +42,11 @@
#include "coap.h"
#include "coap-transactions.h"
#include "coap-separate.h"
#include "plugtest.h"
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "Plugtest"
#define LOG_LEVEL LOG_LEVEL_PLUGTEST
static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void res_resume_handler(void);
@ -72,12 +76,12 @@ res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff
{
coap_message_t *const coap_req = (coap_message_t *)request;
PRINTF("/separate ");
LOG_DBG("/separate ");
if(separate_active) {
PRINTF("REJECTED ");
LOG_DBG_("REJECTED ");
coap_separate_reject();
} else {
PRINTF("STORED ");
LOG_DBG_("STORED ");
separate_active = 1;
/* Take over and skip response by engine. */
@ -89,17 +93,17 @@ res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff
coap_req->mid);
}
PRINTF("(%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid);
LOG_DBG_("(%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid);
}
static void
res_resume_handler()
{
if(separate_active) {
PRINTF("/separate ");
LOG_DBG("/separate ");
coap_transaction_t *transaction = NULL;
if((transaction = coap_new_transaction(separate_store->request_metadata.mid,
&separate_store->request_metadata.endpoint))) {
PRINTF(
LOG_DBG_(
"RESPONSE (%s %u)\n", separate_store->request_metadata.type == COAP_TYPE_CON ? "CON" : "NON", separate_store->request_metadata.mid);
coap_message_t response[1]; /* This way the message can be treated as pointer as usual. */
@ -127,7 +131,7 @@ res_resume_handler()
separate_active = 0;
} else {
PRINTF("ERROR (transaction)\n");
LOG_DBG_("ERROR (transaction)\n");
}
} /* if (separate_active) */
}

View File

@ -40,9 +40,13 @@
#include <string.h>
#include "coap-engine.h"
#include "coap.h"
#include "plugtest.h"
#include "random.h"
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "Plugtest"
#define LOG_LEVEL LOG_LEVEL_PLUGTEST
static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void res_post_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
@ -68,7 +72,7 @@ test_update_etag()
}
test_change = 0;
PRINTF("### SERVER ACTION ### Changed ETag %u [0x%02X%02X%02X%02X%02X%02X%02X%02X]\n", test_etag_len, test_etag[0], test_etag[1], test_etag[2], test_etag[3], test_etag[4], test_etag[5], test_etag[6], test_etag[7]);
LOG_DBG("### SERVER ACTION ### Changed ETag %u [0x%02X%02X%02X%02X%02X%02X%02X%02X]\n", test_etag_len, test_etag[0], test_etag[1], test_etag[2], test_etag[3], test_etag[4], test_etag[5], test_etag[6], test_etag[7]);
}
static void
res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
@ -78,17 +82,17 @@ res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff
if(test_change) {
test_update_etag();
}
PRINTF("/test GET (%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid);
LOG_DBG("/test GET (%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid);
if((len = coap_get_header_etag(request, &bytes)) > 0
&& len == test_etag_len
&& memcmp(test_etag, bytes, len) == 0) {
PRINTF("validate ");
LOG_DBG("validate\n");
coap_set_status_code(response, VALID_2_03);
coap_set_header_etag(response, test_etag, test_etag_len);
test_change = 1;
PRINTF("### SERVER ACTION ### Resource will change\n");
LOG_DBG("### SERVER ACTION ### Resource will change\n");
} else {
/* Code 2.05 CONTENT is default. */
coap_set_header_content_format(response, TEXT_PLAIN);
@ -103,32 +107,28 @@ res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff
static void
res_post_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
#if DEBUG
coap_message_t *const coap_req = (coap_message_t *)request;
PRINTF("/test POST (%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid);
#endif
coap_message_t *const coap_req = (coap_message_t *)request;
LOG_DBG("/test POST (%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid);
coap_set_status_code(response, CREATED_2_01);
coap_set_header_location_path(response, "/location1/location2/location3");
}
static void
res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
#if DEBUG
coap_message_t *const coap_req = (coap_message_t *)request;
PRINTF("/test PUT (%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid);
#endif
LOG_DBG("/test PUT (%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid);
if(coap_get_header_if_none_match(request)) {
if(test_none_match_okay) {
coap_set_status_code(response, CREATED_2_01);
test_none_match_okay = 0;
PRINTF("### SERVER ACTION ### If-None-Match will FAIL\n");
LOG_DBG("### SERVER ACTION ### If-None-Match will FAIL\n");
} else {
coap_set_status_code(response, PRECONDITION_FAILED_4_12);
test_none_match_okay = 1;
PRINTF("### SERVER ACTION ### If-None-Match will SUCCEED\n");
LOG_DBG("### SERVER ACTION ### If-None-Match will SUCCEED\n");
}
} else if(((len = coap_get_header_if_match(request, &bytes)) > 0
&& (len == test_etag_len
@ -141,12 +141,12 @@ res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff
if(len > 0) {
test_change = 1;
PRINTF("### SERVER ACTION ### Resource will change\n");
LOG_DBG("### SERVER ACTION ### Resource will change\n");
}
} else {
PRINTF("Check %u/%u\n [0x%02X%02X%02X%02X%02X%02X%02X%02X]\n [0x%02X%02X%02X%02X%02X%02X%02X%02X]\n",
len,
test_etag_len,
LOG_DBG("Check %u/%u\n [0x%02X%02X%02X%02X%02X%02X%02X%02X]\n [0x%02X%02X%02X%02X%02X%02X%02X%02X]\n",
(unsigned)len,
(unsigned)test_etag_len,
bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7],
test_etag[0], test_etag[1], test_etag[2], test_etag[3], test_etag[4], test_etag[5], test_etag[6], test_etag[7]);
@ -156,9 +156,7 @@ res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff
static void
res_delete_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
#if DEBUG
coap_message_t *const coap_req = (coap_message_t *)request;
PRINTF("/test DELETE (%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid);
#endif
LOG_DBG("/test DELETE (%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid);
coap_set_status_code(response, DELETED_2_02);
}

View File

@ -40,9 +40,13 @@
#include <string.h>
#include "coap-engine.h"
#include "coap.h"
#include "plugtest.h"
#include "random.h"
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "Plugtest"
#define LOG_LEVEL LOG_LEVEL_PLUGTEST
static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
@ -70,7 +74,7 @@ validate_update_etag()
}
validate_change = 0;
PRINTF("### SERVER ACTION ### Changed ETag %u [0x%02X%02X%02X%02X%02X%02X%02X%02X]\n",
LOG_DBG("### SERVER ACTION ### Changed ETag %u [0x%02X%02X%02X%02X%02X%02X%02X%02X]\n",
validate_etag_len, validate_etag[0], validate_etag[1], validate_etag[2], validate_etag[3], validate_etag[4], validate_etag[5], validate_etag[6], validate_etag[7]);
}
static void
@ -81,17 +85,17 @@ res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff
if(validate_change) {
validate_update_etag();
}
PRINTF("/validate GET");
PRINTF("(%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid);
LOG_DBG("/validate GET");
LOG_DBG_("(%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid);
if((len = coap_get_header_etag(request, &bytes)) > 0
&& len == validate_etag_len && memcmp(validate_etag, bytes, len) == 0) {
PRINTF("validate ");
LOG_DBG("validate\n");
coap_set_status_code(response, VALID_2_03);
coap_set_header_etag(response, validate_etag, validate_etag_len);
validate_change = 1;
PRINTF("### SERVER ACTION ### Resouce will change\n");
LOG_DBG("### SERVER ACTION ### Resouce will change\n");
} else {
/* Code 2.05 CONTENT is default. */
coap_set_header_content_format(response, TEXT_PLAIN);
@ -108,12 +112,10 @@ res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff
static void
res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
#if DEBUG
coap_message_t *const coap_req = (coap_message_t *)request;
#endif
PRINTF("/validate PUT ");
PRINTF("(%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid);
LOG_DBG("/validate PUT ");
LOG_DBG_("(%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid);
if(((len = coap_get_header_if_match(request, &bytes)) > 0
&& (len == validate_etag_len
@ -126,13 +128,13 @@ res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buff
if(len > 0) {
validate_change = 1;
PRINTF("### SERVER ACTION ### Resouce will change\n");
LOG_DBG("### SERVER ACTION ### Resouce will change\n");
}
} else {
PRINTF(
"Check %u/%u\n [0x%02X%02X%02X%02X%02X%02X%02X%02X]\n [0x%02X%02X%02X%02X%02X%02X%02X%02X] ",
len,
validate_etag_len,
LOG_DBG(
"Check %u/%u\n [0x%02X%02X%02X%02X%02X%02X%02X%02X]\n [0x%02X%02X%02X%02X%02X%02X%02X%02X]\n",
(unsigned)len,
(unsigned)validate_etag_len,
bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7],
validate_etag[0], validate_etag[1], validate_etag[2], validate_etag[3], validate_etag[4], validate_etag[5], validate_etag[6], validate_etag[7]);

View File

@ -3,6 +3,6 @@ CONTIKI = ../../..
all: $(CONTIKI_PROJECT)
PLATFORMS_ONLY = srf06-cc26xx cc2538dk openmote-cc2538 zoul
PLATFORMS_ONLY = srf06-cc26xx cc2538dk openmote-cc2538 zoul native
include $(CONTIKI)/Makefile.include

View File

@ -47,10 +47,13 @@ PROCESS_THREAD(button_hal_example, ev, data)
printf("Button HAL example.\n");
printf("Device button count: %u.\n", button_hal_button_count);
printf("%s on pin %u with ID=0, Logic=%s, Pull=%s\n",
BUTTON_HAL_GET_DESCRIPTION(btn), btn->pin,
btn->negative_logic ? "Negative" : "Positive",
btn->pull == GPIO_HAL_PIN_CFG_PULL_UP ? "Pull Up" : "Pull Down");
if(btn) {
printf("%s on pin %u with ID=0, Logic=%s, Pull=%s\n",
BUTTON_HAL_GET_DESCRIPTION(btn), btn->pin,
btn->negative_logic ? "Negative" : "Positive",
btn->pull == GPIO_HAL_PIN_CFG_PULL_UP ? "Pull Up" : "Pull Down");
}
while(1) {

View File

@ -1,7 +1,7 @@
CONTIKI_PROJECT = gpio-hal-example
CONTIKI = ../../..
PLATFORMS_ONLY = srf06-cc26xx cc2538dk openmote-cc2538 zoul
PLATFORMS_ONLY = srf06-cc26xx cc2538dk openmote-cc2538 zoul native
include $(CONTIKI)/Makefile.identify-target

View File

@ -36,6 +36,7 @@
#include "dev/button-hal.h"
#include <stdio.h>
#include <inttypes.h>
/*---------------------------------------------------------------------------*/
extern gpio_hal_pin_t out_pin1, out_pin2, out_pin3;
extern gpio_hal_pin_t btn_pin;
@ -43,6 +44,13 @@ extern gpio_hal_pin_t btn_pin;
static struct etimer et;
static uint8_t counter;
/*---------------------------------------------------------------------------*/
/* Print gpio_hal_pin_mask_t using the correct format */
#if GPIO_HAL_PIN_COUNT > 32
#define PIN_MASK_FMT PRIx64
#else
#define PIN_MASK_FMT PRIx32
#endif
/*---------------------------------------------------------------------------*/
PROCESS(gpio_hal_example, "GPIO HAL Example");
AUTOSTART_PROCESSES(&gpio_hal_example);
/*---------------------------------------------------------------------------*/
@ -119,7 +127,8 @@ PROCESS_THREAD(gpio_hal_example, ev, data)
}
/* Test read */
printf("%u: Pins are 1-%u, 2=%u, 3=%u, mask=0x%08lx\n", counter & 7,
printf("%u: Pins are 1-%u, 2=%u, 3=%u, mask=0x%08" PIN_MASK_FMT "\n",
counter & 7,
gpio_hal_arch_read_pin(out_pin1),
gpio_hal_arch_read_pin(out_pin2),
gpio_hal_arch_read_pin(out_pin3),

View File

@ -0,0 +1,40 @@
/*
* Copyright (c) 2018, George Oikonomou - http://www.spd.gr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
#include "dev/gpio-hal.h"
/*---------------------------------------------------------------------------*/
gpio_hal_pin_t out_pin1 = 0;
gpio_hal_pin_t out_pin2 = 1;
gpio_hal_pin_t out_pin3 = 2;
/*---------------------------------------------------------------------------*/
gpio_hal_pin_t btn_pin = 4;
/*---------------------------------------------------------------------------*/

Some files were not shown because too many files have changed in this diff Show More