Merge branch 'release-4.1' into fix/remove-leftover-coojaip64
This commit is contained in:
commit
0fdacc86ac
@ -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_ */
|
||||
|
@ -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_ */
|
||||
|
@ -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_ */
|
||||
|
@ -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_ */
|
||||
|
@ -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
|
@ -1,83 +1,9 @@
|
||||
A Quick Introduction to the Erbium (Er) CoAP Engine
|
||||
===================================================
|
||||
# CoAP examples: client, server, and plugtest serverA Quick Introduction to the Erbium (Er) CoAP Engine
|
||||
|
||||
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.
|
||||
|
12
examples/coap/coap-example-client/Makefile
Normal file
12
examples/coap/coap-example-client/Makefile
Normal 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
|
@ -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]"
|
@ -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 */
|
@ -36,37 +36,12 @@
|
||||
* 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 */
|
||||
|
||||
/* 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
|
||||
#define LOG_LEVEL_APP LOG_LEVEL_DBG
|
||||
|
||||
/* 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_ */
|
14
examples/coap/coap-example-server/Makefile
Normal file
14
examples/coap/coap-example-server/Makefile
Normal 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
|
@ -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,19 +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);
|
||||
LOG_INFO("Starting Erbium Example Server\n");
|
||||
|
||||
/* Initialize the REST engine. */
|
||||
coap_engine_init();
|
||||
@ -128,15 +101,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 +126,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 +136,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();
|
44
examples/coap/coap-example-server/project-conf.h
Normal file
44
examples/coap/coap-example-server/project-conf.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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
|
||||
* Erbium (Er) example project configuration.
|
||||
* \author
|
||||
* Matthias Kovatsch <kovatsch@inf.ethz.ch>
|
||||
*/
|
||||
|
||||
#ifndef PROJECT_CONF_H_
|
||||
#define PROJECT_CONF_H_
|
||||
|
||||
#define LOG_LEVEL_APP LOG_LEVEL_DBG
|
||||
|
||||
#endif /* PROJECT_CONF_H_ */
|
@ -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);
|
@ -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);
|
||||
}
|
@ -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);
|
@ -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);
|
14
examples/coap/coap-plugtest-server/Makefile
Normal file
14
examples/coap/coap-plugtest-server/Makefile
Normal 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
|
@ -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,19 +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);
|
||||
LOG_INFO("ETSI IoT CoAP Plugtests Server\n");
|
||||
|
||||
/* Initialize the REST engine. */
|
||||
coap_engine_init();
|
@ -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_ */
|
171
examples/coap/coap-plugtest-server/resources/res-mirror.c
Normal file
171
examples/coap/coap-plugtest-server/resources/res-mirror.c
Normal 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);
|
||||
}
|
@ -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;
|
@ -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");
|
@ -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;
|
@ -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);
|
||||
|
@ -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);
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
@ -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);
|
||||
}
|
@ -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");
|
||||
}
|
||||
}
|
@ -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) {
|
@ -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);
|
||||
|
@ -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,
|
@ -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) */
|
||||
}
|
@ -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);
|
||||
}
|
@ -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]);
|
||||
|
@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, RISE SICS AB.
|
||||
* 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 HOLDER 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.
|
||||
*/
|
||||
|
||||
#error The CoAP example no longer fits the limited ROM in the Tmote Sky. \
|
||||
Please select another platform with more ROM to compile the CoAP example.
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define COAP_OBSERVE_CLIENT 0
|
||||
|
||||
#define COAP_MAX_CHUNK_SIZE 48
|
||||
|
||||
/* Turn off DAO-ACK and probing to make code smaller */
|
||||
#define RPL_CONF_WITH_DAO_ACK 0
|
||||
|
||||
#define LOG_CONF_LEVEL_MAIN 0
|
||||
|
||||
#define DCOSYNCH_CONF_ENABLED 0
|
||||
|
||||
#define PROCESS_CONF_NUMEVENTS 8
|
||||
/*---------------------------------------------------------------------------*/
|
@ -36,9 +36,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __PROJECT_CONF_H__
|
||||
#define __PROJECT_CONF_H__
|
||||
#ifndef PROJECT_CONF_H_
|
||||
#define PROJECT_CONF_H_
|
||||
|
||||
#define STACK_CHECK_CONF_ENABLED 1
|
||||
|
||||
#endif /* __PROJECT_CONF_H__ */
|
||||
#endif /* PROJECT_CONF_H_ */
|
||||
|
@ -5,9 +5,14 @@ PLATFORMS_ONLY = srf06-cc26xx
|
||||
|
||||
MODULES_REL += ./resources
|
||||
|
||||
PROJECT_SOURCEFILES += cetic-6lbr-client.c coap-server.c net-uart.c mqtt-client.c
|
||||
PROJECT_SOURCEFILES += coap-server.c net-uart.c mqtt-client.c
|
||||
PROJECT_SOURCEFILES += httpd-simple.c
|
||||
|
||||
ifeq ($(MAKE_ROUTING),MAKE_ROUTING_RPL_CLASSIC)
|
||||
# 6lbr only supports RPL Classic
|
||||
PROJECT_SOURCEFILES += cetic-6lbr-client.c
|
||||
endif
|
||||
|
||||
# REST Engine shall use Erbium CoAP implementation
|
||||
MODULES += os/net/app-layer/mqtt
|
||||
MODULES += os/net/app-layer/coap
|
||||
|
@ -37,10 +37,11 @@
|
||||
#include "contiki-net.h"
|
||||
#include "net/routing/routing.h"
|
||||
#include "net/ipv6/uip.h"
|
||||
#if ROUTING_CONF_RPL_LITE
|
||||
#include "net/routing/rpl-lite/rpl.h"
|
||||
#elif ROUTING_CONF_RPL_CLASSIC
|
||||
#if ROUTING_CONF_RPL_CLASSIC
|
||||
#include "net/routing/rpl-classic/rpl.h"
|
||||
#include "net/routing/rpl-classic/rpl-private.h"
|
||||
#else
|
||||
#error The 6LBR client is only meant for RPL Classic. Set MAKE_ROUTING accordingly.
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
@ -160,8 +161,8 @@ timeout_handler(void)
|
||||
PRINT6ADDR(&client_conn->ripaddr);
|
||||
i = sprintf(buf, "%d | ", ++seq_id);
|
||||
instance = rpl_get_default_instance();
|
||||
if(instance && instance->dag.preferred_parent) {
|
||||
add_ipaddr(buf + i, rpl_parent_get_ipaddr(instance->dag.preferred_parent));
|
||||
if(instance && instance->current_dag->preferred_parent) {
|
||||
add_ipaddr(buf + i, rpl_parent_get_ipaddr(instance->current_dag->preferred_parent));
|
||||
} else {
|
||||
sprintf(buf + i, "(null)");
|
||||
}
|
||||
|
@ -42,7 +42,7 @@
|
||||
|
||||
/* Enable/Disable Components of this Demo */
|
||||
#define CC26XX_WEB_DEMO_CONF_MQTT_CLIENT 1
|
||||
#define CC26XX_WEB_DEMO_CONF_6LBR_CLIENT 1
|
||||
#define CC26XX_WEB_DEMO_CONF_6LBR_CLIENT ROUTING_CONF_RPL_CLASSIC
|
||||
#define CC26XX_WEB_DEMO_CONF_COAP_SERVER 1
|
||||
#define CC26XX_WEB_DEMO_CONF_NET_UART 1
|
||||
|
||||
|
@ -31,11 +31,11 @@
|
||||
* \author Simon Duquennoy <simonduq@sics.se>
|
||||
*/
|
||||
|
||||
#ifndef __PROJECT_CONF_H__
|
||||
#define __PROJECT_CONF_H__
|
||||
#ifndef PROJECT_CONF_H_
|
||||
#define PROJECT_CONF_H_
|
||||
|
||||
#define UIP_CONF_TCP 0
|
||||
|
||||
#include "../common-conf.h"
|
||||
|
||||
#endif /* __PROJECT_CONF_H__ */
|
||||
#endif /* PROJECT_CONF_H_ */
|
||||
|
@ -31,11 +31,11 @@
|
||||
* \author Simon Duquennoy <simonduq@sics.se>
|
||||
*/
|
||||
|
||||
#ifndef __PROJECT_CONF_H__
|
||||
#define __PROJECT_CONF_H__
|
||||
#ifndef PROJECT_CONF_H_
|
||||
#define PROJECT_CONF_H_
|
||||
|
||||
#define UIP_CONF_TCP 0
|
||||
|
||||
#include "../common-conf.h"
|
||||
|
||||
#endif /* __PROJECT_CONF_H__ */
|
||||
#endif /* PROJECT_CONF_H_ */
|
||||
|
@ -31,11 +31,11 @@
|
||||
* \author Simon Duquennoy <simonduq@sics.se>
|
||||
*/
|
||||
|
||||
#ifndef __PROJECT_CONF_H__
|
||||
#define __PROJECT_CONF_H__
|
||||
#ifndef PROJECT_CONF_H_
|
||||
#define PROJECT_CONF_H_
|
||||
|
||||
#define UIP_CONF_TCP 0
|
||||
|
||||
#include "../common-conf.h"
|
||||
|
||||
#endif /* __PROJECT_CONF_H__ */
|
||||
#endif /* PROJECT_CONF_H_ */
|
||||
|
@ -32,9 +32,9 @@
|
||||
* \author Simon Duquennoy <simonduq@sics.se>
|
||||
*/
|
||||
|
||||
#ifndef __PROJECT_CONF_H__
|
||||
#define __PROJECT_CONF_H__
|
||||
#ifndef PROJECT_CONF_H_
|
||||
#define PROJECT_CONF_H_
|
||||
|
||||
#include "../common-conf.h"
|
||||
|
||||
#endif /* __PROJECT_CONF_H__ */
|
||||
#endif /* PROJECT_CONF_H_ */
|
||||
|
@ -32,12 +32,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __PROJECT_CONF_H__
|
||||
#define __PROJECT_CONF_H__
|
||||
#ifndef PROJECT_CONF_H_
|
||||
#define PROJECT_CONF_H_
|
||||
|
||||
#define UIP_CONF_TCP 0
|
||||
#define UART_BAUD_RATE UART_RATE_115200
|
||||
|
||||
#include "../../common-conf.h"
|
||||
|
||||
#endif /* __PROJECT_CONF_H__ */
|
||||
#endif /* PROJECT_CONF_H_ */
|
||||
|
@ -31,12 +31,12 @@
|
||||
* \author Simon Duquennoy <simonduq@sics.se>
|
||||
*/
|
||||
|
||||
#ifndef __PROJECT_CONF_H__
|
||||
#define __PROJECT_CONF_H__
|
||||
#ifndef PROJECT_CONF_H_
|
||||
#define PROJECT_CONF_H_
|
||||
|
||||
#define UIP_CONF_TCP 0
|
||||
#define UART_BAUD_RATE UART_RATE_115200
|
||||
|
||||
#include "../../common-conf.h"
|
||||
|
||||
#endif /* __PROJECT_CONF_H__ */
|
||||
#endif /* PROJECT_CONF_H_ */
|
||||
|
@ -31,8 +31,8 @@
|
||||
* \author Simon Duquennoy <simonduq@sics.se>
|
||||
*/
|
||||
|
||||
#ifndef __PROJECT_CONF_H__
|
||||
#define __PROJECT_CONF_H__
|
||||
#ifndef PROJECT_CONF_H_
|
||||
#define PROJECT_CONF_H_
|
||||
|
||||
#define UIP_CONF_TCP 0
|
||||
|
||||
@ -46,4 +46,4 @@
|
||||
|
||||
#include "../common-conf.h"
|
||||
|
||||
#endif /* __PROJECT_CONF_H__ */
|
||||
#endif /* PROJECT_CONF_H_ */
|
||||
|
@ -44,15 +44,30 @@
|
||||
|
||||
/***** External Variables *****/
|
||||
|
||||
/* The neighbor last used as our time source */
|
||||
/** \brief The neighbor last used as our time source */
|
||||
extern struct tsch_neighbor *last_timesource_neighbor;
|
||||
|
||||
/********** Functions *********/
|
||||
|
||||
/**
|
||||
* \brief Updates timesync information for a given neighbor
|
||||
* \param n The neighbor
|
||||
* \param time_delta_asn ASN time delta since last synchronization, i.e. number of slots elapsed
|
||||
* \param drift_correction The measured drift in ticks since last synchronization
|
||||
*/
|
||||
void tsch_timesync_update(struct tsch_neighbor *n, uint16_t time_delta_asn, int32_t drift_correction);
|
||||
|
||||
/**
|
||||
* \brief Computes time compensation for a given point in the future
|
||||
* \param delta_ticks The number of ticks in the future we want to calculate compensation for
|
||||
* \return The time compensation
|
||||
*/
|
||||
int32_t tsch_timesync_adaptive_compensate(rtimer_clock_t delta_ticks);
|
||||
|
||||
/**
|
||||
* \brief Gives the estimated clock drift w.r.t. the time source in PPM (parts per million)
|
||||
* \return The time drift in PPM
|
||||
*/
|
||||
long int tsch_adaptive_timesync_get_drift_ppm(void);
|
||||
|
||||
#endif /* __TSCH_ADAPTIVE_TIMESYNC_H__ */
|
||||
|
@ -48,13 +48,13 @@
|
||||
|
||||
/************ Types ***********/
|
||||
|
||||
/* The ASN is an absolute slot number over 5 bytes. */
|
||||
/** \brief The ASN is an absolute slot number over 5 bytes. */
|
||||
struct tsch_asn_t {
|
||||
uint32_t ls4b; /* least significant 4 bytes */
|
||||
uint8_t ms1b; /* most significant 1 byte */
|
||||
};
|
||||
|
||||
/* For quick modulo operation on ASN */
|
||||
/** \brief For quick modulo operation on ASN */
|
||||
struct tsch_asn_divisor_t {
|
||||
uint16_t val; /* Divisor value */
|
||||
uint16_t asn_ms1b_remainder; /* Remainder of the operation 0x100000000 / val */
|
||||
@ -62,37 +62,37 @@ struct tsch_asn_divisor_t {
|
||||
|
||||
/************ Macros **********/
|
||||
|
||||
/* Initialize ASN */
|
||||
/** \brief Initialize ASN */
|
||||
#define TSCH_ASN_INIT(asn, ms1b_, ls4b_) do { \
|
||||
(asn).ms1b = (ms1b_); \
|
||||
(asn).ls4b = (ls4b_); \
|
||||
} while(0);
|
||||
|
||||
/* Increment an ASN by inc (32 bits) */
|
||||
/** \brief Increment an ASN by inc (32 bits) */
|
||||
#define TSCH_ASN_INC(asn, inc) do { \
|
||||
uint32_t new_ls4b = (asn).ls4b + (inc); \
|
||||
if(new_ls4b < (asn).ls4b) { (asn).ms1b++; } \
|
||||
(asn).ls4b = new_ls4b; \
|
||||
} while(0);
|
||||
|
||||
/* Decrement an ASN by inc (32 bits) */
|
||||
/** \brief Decrement an ASN by inc (32 bits) */
|
||||
#define TSCH_ASN_DEC(asn, dec) do { \
|
||||
uint32_t new_ls4b = (asn).ls4b - (dec); \
|
||||
if(new_ls4b > (asn).ls4b) { (asn).ms1b--; } \
|
||||
(asn).ls4b = new_ls4b; \
|
||||
} while(0);
|
||||
|
||||
/* Returns the 32-bit diff between asn1 and asn2 */
|
||||
/** \brief Returns the 32-bit diff between asn1 and asn2 */
|
||||
#define TSCH_ASN_DIFF(asn1, asn2) \
|
||||
((asn1).ls4b - (asn2).ls4b)
|
||||
|
||||
/* Initialize a struct asn_divisor_t */
|
||||
/** \brief Initialize a struct asn_divisor_t */
|
||||
#define TSCH_ASN_DIVISOR_INIT(div, val_) do { \
|
||||
(div).val = (val_); \
|
||||
(div).asn_ms1b_remainder = ((0xffffffff % (val_)) + 1) % (val_); \
|
||||
} while(0);
|
||||
|
||||
/* Returns the result (16 bits) of a modulo operation on ASN,
|
||||
/** \brief Returns the result (16 bits) of a modulo operation on ASN,
|
||||
* with divisor being a struct asn_divisor_t */
|
||||
#define TSCH_ASN_MOD(asn, div) \
|
||||
((uint16_t)((asn).ls4b % (div).val) \
|
||||
|
@ -70,7 +70,7 @@
|
||||
|
||||
/************ Types ***********/
|
||||
|
||||
/* Structure for a log. Union of different types of logs */
|
||||
/** \brief Structure for a log. Union of different types of logs */
|
||||
struct tsch_log_t {
|
||||
enum { tsch_log_tx,
|
||||
tsch_log_rx,
|
||||
@ -107,21 +107,31 @@ struct tsch_log_t {
|
||||
|
||||
/********** Functions *********/
|
||||
|
||||
/* Prepare addition of a new log.
|
||||
* Returns pointer to log structure if success, NULL otherwise */
|
||||
/**
|
||||
* \brief Prepare addition of a new log.
|
||||
* \return A pointer to log structure if success, NULL otherwise
|
||||
*/
|
||||
struct tsch_log_t *tsch_log_prepare_add(void);
|
||||
/* Actually add the previously prepared log */
|
||||
/**
|
||||
* \brief Actually add the previously prepared log
|
||||
*/
|
||||
void tsch_log_commit(void);
|
||||
/* Initialize log module */
|
||||
/**
|
||||
* \brief Initialize log module
|
||||
*/
|
||||
void tsch_log_init(void);
|
||||
/* Process pending log messages */
|
||||
/**
|
||||
* \brief Process pending log messages
|
||||
*/
|
||||
void tsch_log_process_pending(void);
|
||||
/* Stop logging module */
|
||||
/**
|
||||
* \brief Stop logging module
|
||||
*/
|
||||
void tsch_log_stop(void);
|
||||
|
||||
/************ Macros **********/
|
||||
|
||||
/* Use this macro to add a log to the queue (will be printed out
|
||||
/** \brief Use this macro to add a log to the queue (will be printed out
|
||||
* later, after leaving interrupt context) */
|
||||
#define TSCH_LOG_ADD(log_type, init_code) do { \
|
||||
struct tsch_log_t *log = tsch_log_prepare_add(); \
|
||||
|
@ -390,8 +390,7 @@ tsch_packet_update_eb(uint8_t *buf, int buf_size, uint8_t tsch_sync_ie_offset)
|
||||
struct ieee802154_ies ies;
|
||||
ies.ie_asn = tsch_current_asn;
|
||||
ies.ie_join_priority = tsch_join_priority;
|
||||
frame80215e_create_ie_tsch_synchronization(buf+tsch_sync_ie_offset, buf_size-tsch_sync_ie_offset, &ies);
|
||||
return 1;
|
||||
return frame80215e_create_ie_tsch_synchronization(buf+tsch_sync_ie_offset, buf_size-tsch_sync_ie_offset, &ies) != -1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Parse a IEEE 802.15.4e TSCH Enhanced Beacon (EB) */
|
||||
|
@ -46,18 +46,56 @@
|
||||
|
||||
/********** Functions *********/
|
||||
|
||||
/* Construct enhanced ACK packet and return ACK length */
|
||||
/**
|
||||
* \brief Construct Enhanced ACK packet
|
||||
* \param buf The buffer where to build the EACK
|
||||
* \param buf_size The buffer size
|
||||
* \param dest_addr The link-layer address of the neighbor we are ACKing
|
||||
* \param seqno The sequence number we are ACKing
|
||||
* \param drift The time offset in usec measured at Rx of the packer we are ACKing
|
||||
* \param nack Value of the NACK bit
|
||||
* \return The length of the packet that was created. -1 if failure.
|
||||
*/
|
||||
int tsch_packet_create_eack(uint8_t *buf, uint16_t buf_size,
|
||||
const linkaddr_t *dest_addr, uint8_t seqno,
|
||||
int16_t drift, int nack);
|
||||
/* Parse enhanced ACK packet, extract drift and nack */
|
||||
/**
|
||||
* \brief Parse enhanced ACK packet
|
||||
* \param buf The buffer where to parse the EACK from
|
||||
* \param buf_size The buffer size
|
||||
* \param seqno The sequence number we are expecting
|
||||
* \param frame The frame structure where to store parsed fields
|
||||
* \param ies The IE structure where to store parsed IEs
|
||||
* \param hdr_len A pointer where to store the length of the parsed header
|
||||
* \return 1 if the EACK is correct and acknowledges the specified frame, 0 otherwise
|
||||
*/
|
||||
int tsch_packet_parse_eack(const uint8_t *buf, int buf_size,
|
||||
uint8_t seqno, frame802154_t *frame, struct ieee802154_ies *ies, uint8_t *hdr_len);
|
||||
/* Create an EB packet */
|
||||
/**
|
||||
* \brief Create an EB packet directly in packetbuf
|
||||
* \param hdr_len A pointer where to store the length of the created header
|
||||
* \param tsch_sync_ie_ptr A pointer where to store the address of the TSCH synchronization IE
|
||||
* \return The total length of the EB
|
||||
*/
|
||||
int tsch_packet_create_eb(uint8_t *hdr_len, uint8_t *tsch_sync_ie_ptr);
|
||||
/* Update ASN in EB packet */
|
||||
/**
|
||||
* \brief Update ASN in EB packet
|
||||
* \param buf The buffer that contains the EB
|
||||
* \param buf_size The buffer size
|
||||
* \param tsch_sync_ie_offset The offset of the TSCH synchronization IE, in which the ASN is to be written
|
||||
* \return 1 if success, 0 otherwise
|
||||
*/
|
||||
int tsch_packet_update_eb(uint8_t *buf, int buf_size, uint8_t tsch_sync_ie_offset);
|
||||
/* Parse EB and extract ASN and join priority */
|
||||
/**
|
||||
* \brief Parse EB
|
||||
* \param buf The buffer where to parse the EB from
|
||||
* \param buf_size The buffer sizecting
|
||||
* \param frame The frame structure where to store parsed fields
|
||||
* \param ies The IE structure where to store parsed IEs
|
||||
* \param hdrlen A pointer where to store the length of the parsed header
|
||||
* \param frame_without_mic When set, the security MIC will not be parsed
|
||||
* \return The length of the parsed EB
|
||||
*/
|
||||
int tsch_packet_parse_eb(const uint8_t *buf, int buf_size,
|
||||
frame802154_t *frame, struct ieee802154_ies *ies,
|
||||
uint8_t *hdrlen, int frame_without_mic);
|
||||
|
@ -53,50 +53,128 @@ extern struct tsch_neighbor *n_eb;
|
||||
|
||||
/********** Functions *********/
|
||||
|
||||
/* Add a TSCH neighbor */
|
||||
/**
|
||||
* \brief Add a TSCH neighbor queue
|
||||
* \param addr The link-layer address of the neighbor to be added
|
||||
*/
|
||||
struct tsch_neighbor *tsch_queue_add_nbr(const linkaddr_t *addr);
|
||||
/* Get a TSCH neighbor */
|
||||
/**
|
||||
* \brief Get a TSCH neighbor
|
||||
* \param addr The link-layer address of the neighbor we are looking for
|
||||
* \return A pointer to the neighbor queue, NULL if not found
|
||||
*/
|
||||
struct tsch_neighbor *tsch_queue_get_nbr(const linkaddr_t *addr);
|
||||
/* Get a TSCH time source (we currently assume there is only one) */
|
||||
/**
|
||||
* \brief Get the TSCH time source (we currently assume there is only one)
|
||||
* \return The neighbor queue associated to the time source
|
||||
*/
|
||||
struct tsch_neighbor *tsch_queue_get_time_source(void);
|
||||
/* Update TSCH time source */
|
||||
/**
|
||||
* \brief Update TSCH time source
|
||||
* \param new_addr The address of the new TSCH time source
|
||||
*/
|
||||
int tsch_queue_update_time_source(const linkaddr_t *new_addr);
|
||||
/* Add packet to neighbor queue. Use same lockfree implementation as ringbuf.c (put is atomic) */
|
||||
/**
|
||||
* \brief Add packet to neighbor queue. Use same lockfree implementation as ringbuf.c (put is atomic)
|
||||
* \param addr The address of the targetted neighbor, &tsch_broadcast_address for broadcast
|
||||
* \param max_transmissions The number of MAC retries
|
||||
* \param sent The MAC packet sent callback
|
||||
* \param ptr The MAC packet send callback parameter
|
||||
* \return The newly created packet if any, NULL otherwise
|
||||
*/
|
||||
struct tsch_packet *tsch_queue_add_packet(const linkaddr_t *addr, uint8_t max_transmissions,
|
||||
mac_callback_t sent, void *ptr);
|
||||
/* Returns the number of packets currently in any TSCH queue */
|
||||
/**
|
||||
* \brief Returns the number of packets currently in all TSCH queues
|
||||
* \return The number of packets currently in all TSCH queues
|
||||
*/
|
||||
int tsch_queue_global_packet_count(void);
|
||||
/* Returns the number of packets currently a given neighbor queue */
|
||||
/**
|
||||
* \brief Returns the number of packets currently a given neighbor queue
|
||||
* \param addr The link-layer address of the neighbor we are interested in
|
||||
* \return The number of packets in the neighbor's queue
|
||||
*/
|
||||
int tsch_queue_packet_count(const linkaddr_t *addr);
|
||||
/* Remove first packet from a neighbor queue. The packet is stored in a separate
|
||||
* dequeued packet list, for later processing. Return the packet. */
|
||||
/**
|
||||
* \brief Remove first packet from a neighbor queue. The packet is stored in a separate
|
||||
* dequeued packet list, for later processing.
|
||||
* \param n The neighbor queue
|
||||
* \return The packet that was removed if any, NULL otherwise
|
||||
*/
|
||||
struct tsch_packet *tsch_queue_remove_packet_from_queue(struct tsch_neighbor *n);
|
||||
/* Free a packet */
|
||||
/**
|
||||
* \brief Free a packet
|
||||
* \param p The packet to be freed
|
||||
*/
|
||||
void tsch_queue_free_packet(struct tsch_packet *p);
|
||||
/* Updates neighbor queue state after a transmission */
|
||||
/**
|
||||
* \brief Updates neighbor queue state after a transmission
|
||||
* \param n The neighbor queue we just sent from
|
||||
* \param p The packet that was just sent
|
||||
* \param link The TSCH link used for Tx
|
||||
* \param mac_tx_status The MAC status (see mac.h)
|
||||
* \return 1 if the packet remains in queue after the call, 0 if it was removed
|
||||
*/
|
||||
int tsch_queue_packet_sent(struct tsch_neighbor *n, struct tsch_packet *p, struct tsch_link *link, uint8_t mac_tx_status);
|
||||
/* Reset neighbor queues */
|
||||
/**
|
||||
* \brief Reset neighbor queues module
|
||||
*/
|
||||
void tsch_queue_reset(void);
|
||||
/* Deallocate neighbors with empty queue */
|
||||
/**
|
||||
* \brief Deallocate all neighbors with empty queue
|
||||
*/
|
||||
void tsch_queue_free_unused_neighbors(void);
|
||||
/* Is the neighbor queue empty? */
|
||||
/**
|
||||
* \brief Is the neighbor queue empty?
|
||||
* \param n The neighbor queue
|
||||
* \return 1 if empty, 0 otherwise
|
||||
*/
|
||||
int tsch_queue_is_empty(const struct tsch_neighbor *n);
|
||||
/* Returns the first packet from a neighbor queue */
|
||||
/**
|
||||
* \brief Returns the first packet that can be sent from a queue on a given link
|
||||
* \param n The neighbor queue
|
||||
* \param link The link
|
||||
* \return The next packet to be sent for the neighbor on the given link, if any, else NULL
|
||||
*/
|
||||
struct tsch_packet *tsch_queue_get_packet_for_nbr(const struct tsch_neighbor *n, struct tsch_link *link);
|
||||
/* Returns the head packet from a neighbor queue (from neighbor address) */
|
||||
/**
|
||||
* \brief Returns the first packet that can be sent to a given address on a given link
|
||||
* \param addr The target link-layer address
|
||||
* \param link The link
|
||||
* \return The next packet to be sent for to the given address on the given link, if any, else NULL
|
||||
*/
|
||||
struct tsch_packet *tsch_queue_get_packet_for_dest_addr(const linkaddr_t *addr, struct tsch_link *link);
|
||||
/* Returns the head packet of any neighbor queue with zero backoff counter.
|
||||
* Writes pointer to the neighbor in *n */
|
||||
/**
|
||||
* \brief Gets the head packet of any neighbor queue with zero backoff counter.
|
||||
* \param n A pointer where to store the neighbor queue to be used for Tx
|
||||
* \param link The link to be used for Tx
|
||||
* \return The packet if any, else NULL
|
||||
*/
|
||||
struct tsch_packet *tsch_queue_get_unicast_packet_for_any(struct tsch_neighbor **n, struct tsch_link *link);
|
||||
/* May the neighbor transmit over a share link? */
|
||||
/**
|
||||
* \brief Is the neighbor backoff timer expired?
|
||||
* \param n The neighbor queue
|
||||
* \return 1 if the backoff has expired (neighbor ready to transmit on a shared link), 0 otherwise
|
||||
*/
|
||||
int tsch_queue_backoff_expired(const struct tsch_neighbor *n);
|
||||
/* Reset neighbor backoff */
|
||||
/**
|
||||
* \brief Reset neighbor backoff
|
||||
* \param n The neighbor queue
|
||||
*/
|
||||
void tsch_queue_backoff_reset(struct tsch_neighbor *n);
|
||||
/* Increment backoff exponent, pick a new window */
|
||||
/**
|
||||
* \brief Increment backoff exponent of a given neighbor queue, pick a new window
|
||||
* \param n The neighbor queue
|
||||
*/
|
||||
void tsch_queue_backoff_inc(struct tsch_neighbor *n);
|
||||
/* Decrement backoff window for all queues directed at dest_addr */
|
||||
/**
|
||||
* \brief Decrement backoff window for the queue(s) able to Tx to a given address
|
||||
* \param dest_addr The target address, &tsch_broadcast_address for broadcast
|
||||
*/
|
||||
void tsch_queue_update_all_backoff_windows(const linkaddr_t *dest_addr);
|
||||
/* Initialize TSCH queue module */
|
||||
/**
|
||||
* \brief Initialize TSCH queue module
|
||||
*/
|
||||
void tsch_queue_init(void);
|
||||
|
||||
#endif /* __TSCH_QUEUE_H__ */
|
||||
|
@ -47,20 +47,35 @@
|
||||
|
||||
/********** Functions *********/
|
||||
|
||||
/* Keep-alives packet sent callback.
|
||||
* To use, set #define TSCH_CALLBACK_KA_SENT tsch_rpl_callback_ka_sent */
|
||||
/**
|
||||
* \brief Report statiscs from KA packet sent in RPL.
|
||||
* To use, set TSCH_CALLBACK_KA_SENT to tsch_rpl_callback_ka_sent
|
||||
* \param status The packet sent status
|
||||
* \param transmissions The total number of transmissions
|
||||
*/
|
||||
void tsch_rpl_callback_ka_sent(int status, int transmissions);
|
||||
/* To use, set #define TSCH_CALLBACK_JOINING_NETWORK tsch_rpl_callback_joining_network */
|
||||
/**
|
||||
* \brief Let RPL know that TSCH joined a new network.
|
||||
* To use, set TSCH_CALLBACK_JOINING_NETWORK to tsch_rpl_callback_joining_network
|
||||
*/
|
||||
void tsch_rpl_callback_joining_network(void);
|
||||
/* Upon leaving a TSCH network, perform a local repair
|
||||
* (cleanup neighbor state, reset Trickle timer etc)
|
||||
* To use, set #define TSCH_CALLBACK_LEAVING_NETWORK tsch_rpl_callback_leaving_network */
|
||||
/**
|
||||
* \brief Let RPL know that TSCH joined a new network. Triggers a local repair.
|
||||
* To use, set TSCH_CALLBACK_LEAVING_NETWORK to tsch_rpl_callback_leaving_network
|
||||
*/
|
||||
void tsch_rpl_callback_leaving_network(void);
|
||||
/* Set TSCH EB period based on current RPL DIO period.
|
||||
* To use, set #define RPL_CALLBACK_NEW_DIO_INTERVAL tsch_rpl_callback_new_dio_interval */
|
||||
/**
|
||||
* \brief Set TSCH EB period based on current RPL DIO period.
|
||||
* To use, set RPL_CALLBACK_NEW_DIO_INTERVAL to tsch_rpl_callback_new_dio_interval
|
||||
* \param dio_interval The new DIO interval in clock ticks
|
||||
*/
|
||||
void tsch_rpl_callback_new_dio_interval(clock_time_t dio_interval);
|
||||
/* Set TSCH time source based on current RPL preferred parent.
|
||||
* To use, set #define RPL_CALLBACK_PARENT_SWITCH tsch_rpl_callback_parent_switch */
|
||||
/**
|
||||
* \brief Set TSCH time source based on current RPL preferred parent.
|
||||
* To use, set RPL_CALLBACK_PARENT_SWITCH to tsch_rpl_callback_parent_switch
|
||||
* \param old The old RPL parent
|
||||
* \param new The new RPL parent
|
||||
*/
|
||||
void tsch_rpl_callback_parent_switch(rpl_parent_t *old, rpl_parent_t *new);
|
||||
|
||||
#endif /* __TSCH_RPL_H__ */
|
||||
|
@ -45,42 +45,115 @@
|
||||
|
||||
/********** Functions *********/
|
||||
|
||||
/* Module initialization, call only once at startup. Returns 1 is success, 0 if failure. */
|
||||
/**
|
||||
* \brief Module initialization, call only once at init
|
||||
* \return 1 if success, 0 if failure
|
||||
*/
|
||||
int tsch_schedule_init(void);
|
||||
/* Create a 6TiSCH minimal schedule */
|
||||
/**
|
||||
* \brief Create a 6tisch minimal schedule with length TSCH_SCHEDULE_DEFAULT_LENGTH
|
||||
*/
|
||||
void tsch_schedule_create_minimal(void);
|
||||
/* Prints out the current schedule (all slotframes and links) */
|
||||
/**
|
||||
* \brief Prints out the current schedule (all slotframes and links)
|
||||
*/
|
||||
void tsch_schedule_print(void);
|
||||
|
||||
/* Adds and returns a slotframe (NULL if failure) */
|
||||
|
||||
/**
|
||||
* \brief Creates and adds a new slotframe
|
||||
* \param handle the slotframe handle
|
||||
* \param size the slotframe size
|
||||
* \return the new slotframe, NULL if failure
|
||||
*/
|
||||
struct tsch_slotframe *tsch_schedule_add_slotframe(uint16_t handle, uint16_t size);
|
||||
/* Looks for a slotframe from a handle */
|
||||
|
||||
/**
|
||||
* \brief Looks up a slotframe by handle
|
||||
* \param handle the slotframe handle
|
||||
* \return the slotframe with required handle, if any. NULL otherwise.
|
||||
*/
|
||||
struct tsch_slotframe *tsch_schedule_get_slotframe_by_handle(uint16_t handle);
|
||||
/* Removes a slotframe Return 1 if success, 0 if failure */
|
||||
|
||||
/**
|
||||
* \brief Removes a slotframe
|
||||
* \param slotframe The slotframe to be removed
|
||||
* \return 1 if success, 0 if failure
|
||||
*/
|
||||
int tsch_schedule_remove_slotframe(struct tsch_slotframe *slotframe);
|
||||
/* Removes all slotframes, resulting in an empty schedule */
|
||||
|
||||
/**
|
||||
* \brief Removes all slotframes, resulting in an empty schedule
|
||||
* \return 1 if success, 0 if failure
|
||||
*/
|
||||
int tsch_schedule_remove_all_slotframes(void);
|
||||
|
||||
/* Returns next slotframe */
|
||||
struct tsch_slotframe *tsch_schedule_slotframes_next(struct tsch_slotframe *sf);
|
||||
/* Adds a link to a slotframe, return a pointer to it (NULL if failure) */
|
||||
/**
|
||||
* \brief Adds a link to a slotframe
|
||||
* \param slotframe The slotframe that will contain the new link
|
||||
* \param link_options The link options, as a bitfield (LINK_OPTION_* flags)
|
||||
* \param link_type The link type (advertising, normal)
|
||||
* \param address The link address of the intended destination. Use &tsch_broadcast_address for a slot towards any neighbor
|
||||
* \param timeslot The link timeslot within the slotframe
|
||||
* \param channel_offset The link channel offset
|
||||
* \return A pointer to the new link, NULL if failure
|
||||
*/
|
||||
struct tsch_link *tsch_schedule_add_link(struct tsch_slotframe *slotframe,
|
||||
uint8_t link_options, enum link_type link_type, const linkaddr_t *address,
|
||||
uint16_t timeslot, uint16_t channel_offset);
|
||||
/* Looks for a link from a handle */
|
||||
/**
|
||||
* \brief Looks for a link from a handle
|
||||
* \param handle The target handle
|
||||
* \return The link with required handle, if any. Otherwise, NULL
|
||||
*/
|
||||
struct tsch_link *tsch_schedule_get_link_by_handle(uint16_t handle);
|
||||
/* Looks within a slotframe for a link with a given timeslot */
|
||||
|
||||
/**
|
||||
* \brief Looks within a slotframe for a link with a given timeslot
|
||||
* \param slotframe The desired slotframe
|
||||
* \param timeslot The desired timeslot
|
||||
* \return The link if found, NULL otherwise
|
||||
*/
|
||||
struct tsch_link *tsch_schedule_get_link_by_timeslot(struct tsch_slotframe *slotframe, uint16_t timeslot);
|
||||
/* Removes a link. Return 1 if success, 0 if failure */
|
||||
|
||||
/**
|
||||
* \brief Removes a link
|
||||
* \param slotframe The slotframe the link belongs to
|
||||
* \param l The link to be removed
|
||||
* \return 1 if success, 0 if failure
|
||||
*/
|
||||
int tsch_schedule_remove_link(struct tsch_slotframe *slotframe, struct tsch_link *l);
|
||||
/* Removes a link from slotframe and timeslot. Return a 1 if success, 0 if failure */
|
||||
|
||||
/**
|
||||
* \brief Removes a link from a slotframe and timeslot
|
||||
* \param slotframe The slotframe where to look for the link
|
||||
* \param timeslot The timeslot where to look for the link within the target slotframe
|
||||
* \return 1 if success, 0 if failure
|
||||
*/
|
||||
int tsch_schedule_remove_link_by_timeslot(struct tsch_slotframe *slotframe, uint16_t timeslot);
|
||||
|
||||
/* Returns the next active link after a given ASN, and a backup link (for the same ASN, with Rx flag) */
|
||||
|
||||
/**
|
||||
* \brief Returns the next active link after a given ASN, and a backup link (for the same ASN, with Rx flag)
|
||||
* \param asn The base ASN, from which we look for the next active link
|
||||
* \param time_offset A pointer to uint16_t where to store the time offset between base ASN and link found
|
||||
* \param backup_link A pointer where to write the address of a backup link, to be executed should the original be no longer active at wakeup
|
||||
* \return The next active link if any, NULL otherwise
|
||||
*/
|
||||
struct tsch_link * tsch_schedule_get_next_active_link(struct tsch_asn_t *asn, uint16_t *time_offset,
|
||||
struct tsch_link **backup_link);
|
||||
/* Access to slotframe list */
|
||||
|
||||
/**
|
||||
* \brief Access the first item in the list of slotframes
|
||||
* \return The first slotframe in the schedule if any, NULL otherwise
|
||||
*/
|
||||
struct tsch_slotframe *tsch_schedule_slotframe_head(void);
|
||||
|
||||
/**
|
||||
* \brief Access the next item in the list of slotframes
|
||||
* \param sf The current slotframe (item in the list)
|
||||
* \return The next slotframe if any, NULL otherwise
|
||||
*/
|
||||
struct tsch_slotframe *tsch_schedule_slotframe_next(struct tsch_slotframe *sf);
|
||||
|
||||
#endif /* __TSCH_SCHEDULE_H__ */
|
||||
|
@ -58,19 +58,45 @@ extern clock_time_t last_sync_time;
|
||||
|
||||
/********** Functions *********/
|
||||
|
||||
/* Returns a 802.15.4 channel from an ASN and channel offset */
|
||||
/**
|
||||
* Returns a 802.15.4 channel from an ASN and channel offset. Basically adds
|
||||
* The offset to the ASN and performs a hopping sequence lookup.
|
||||
*
|
||||
* \param asn A given ASN
|
||||
* \param channel_offset A given channel offset
|
||||
* \return The resulting channel
|
||||
*/
|
||||
uint8_t tsch_calculate_channel(struct tsch_asn_t *asn, uint8_t channel_offset);
|
||||
/* Is TSCH locked? */
|
||||
/**
|
||||
* Checks if the TSCH lock is set. Accesses to global structures outside of
|
||||
* interrupts must be done through the lock, unless the sturcutre has
|
||||
* atomic read/write
|
||||
*
|
||||
* \return 1 if the lock is taken, 0 otherwise
|
||||
*/
|
||||
int tsch_is_locked(void);
|
||||
/* Lock TSCH (no link operation) */
|
||||
/**
|
||||
* Takes the TSCH lock. When the lock is taken, slot operation will be skipped
|
||||
* until release.
|
||||
*
|
||||
* \return 1 if the lock was successfully taken, 0 otherwise
|
||||
*/
|
||||
int tsch_get_lock(void);
|
||||
/* Release TSCH lock */
|
||||
/**
|
||||
* Releases the TSCH lock.
|
||||
*/
|
||||
void tsch_release_lock(void);
|
||||
/* Set global time before starting slot operation,
|
||||
* with a rtimer time and an ASN */
|
||||
/**
|
||||
* Set global time before starting slot operation, with a rtimer time and an ASN
|
||||
*
|
||||
* \param next_slot_start the time to the start of the next slot, in rtimer ticks
|
||||
* \param next_slot_asn the ASN of the next slot
|
||||
*/
|
||||
void tsch_slot_operation_sync(rtimer_clock_t next_slot_start,
|
||||
struct tsch_asn_t *next_slot_asn);
|
||||
/* Start actual slot operation */
|
||||
/**
|
||||
* Start actual slot operation
|
||||
*/
|
||||
void tsch_slot_operation_start(void);
|
||||
|
||||
#endif /* __TSCH_SLOT_OPERATION_H__ */
|
||||
|
@ -53,10 +53,10 @@
|
||||
|
||||
/********** Data types **********/
|
||||
|
||||
/* 802.15.4e link types.
|
||||
* LINK_TYPE_ADVERTISING_ONLY is an extra one: for EB-only links. */
|
||||
/** \brief 802.15.4e link types. LINK_TYPE_ADVERTISING_ONLY is an extra one: for EB-only links. */
|
||||
enum link_type { LINK_TYPE_NORMAL, LINK_TYPE_ADVERTISING, LINK_TYPE_ADVERTISING_ONLY };
|
||||
|
||||
/** \brief An IEEE 802.15.4-2015 TSCH link (also called cell or slot) */
|
||||
struct tsch_link {
|
||||
/* Links are stored as a list: "next" must be the first field */
|
||||
struct tsch_link *next;
|
||||
@ -83,7 +83,7 @@ struct tsch_link {
|
||||
void *data;
|
||||
};
|
||||
|
||||
/* 802.15.4e slotframe (contains links) */
|
||||
/** \brief 802.15.4e slotframe (contains links) */
|
||||
struct tsch_slotframe {
|
||||
/* Slotframes are stored as a list: "next" must be the first field */
|
||||
struct tsch_slotframe *next;
|
||||
@ -96,7 +96,7 @@ struct tsch_slotframe {
|
||||
LIST_STRUCT(links_list);
|
||||
};
|
||||
|
||||
/* TSCH packet information */
|
||||
/** \brief TSCH packet information */
|
||||
struct tsch_packet {
|
||||
struct queuebuf *qb; /* pointer to the queuebuf to be sent */
|
||||
mac_callback_t sent; /* callback for this packet */
|
||||
@ -108,7 +108,7 @@ struct tsch_packet {
|
||||
uint8_t tsch_sync_ie_offset; /* Offset within the frame used for quick update of EB ASN and join priority */
|
||||
};
|
||||
|
||||
/* TSCH neighbor information */
|
||||
/** \brief TSCH neighbor information */
|
||||
struct tsch_neighbor {
|
||||
/* Neighbors are stored as a list: "next" must be the first field */
|
||||
struct tsch_neighbor *next;
|
||||
@ -127,7 +127,7 @@ struct tsch_neighbor {
|
||||
struct ringbufindex tx_ringbuf;
|
||||
};
|
||||
|
||||
/* TSCH timeslot timing elements. Used to index timeslot timing
|
||||
/** \brief TSCH timeslot timing elements. Used to index timeslot timing
|
||||
* of different units, such as rtimer tick or micro-second */
|
||||
enum tsch_timeslot_timing_elements {
|
||||
tsch_ts_cca_offset,
|
||||
@ -145,7 +145,7 @@ enum tsch_timeslot_timing_elements {
|
||||
tsch_ts_elements_count, /* Not a timing element */
|
||||
};
|
||||
|
||||
/* Stores data about an incoming packet */
|
||||
/** \brief Stores data about an incoming packet */
|
||||
struct input_packet {
|
||||
uint8_t payload[TSCH_PACKET_MAX_LEN]; /* Packet payload */
|
||||
struct tsch_asn_t rx_asn; /* ASN when the packet was received */
|
||||
|
@ -180,21 +180,57 @@ PROCESS_NAME(tsch_pending_events_process);
|
||||
|
||||
/********** Functions *********/
|
||||
|
||||
/* The the TSCH join priority */
|
||||
/**
|
||||
* Set the TSCH join priority (JP)
|
||||
*
|
||||
* \param jp the new join priority
|
||||
*/
|
||||
void tsch_set_join_priority(uint8_t jp);
|
||||
/* The period at which EBs are sent */
|
||||
/**
|
||||
* Set the period at wich TSCH enhanced beacons (EBs) are sent. The period can
|
||||
* not be set to exceed TSCH_MAX_EB_PERIOD. Set to 0 to stop sending EBs.
|
||||
* Actual transmissions are jittered, spaced by a random number within
|
||||
* [period*0.75, period[
|
||||
*
|
||||
* \param period The period in Clock ticks.
|
||||
*/
|
||||
void tsch_set_eb_period(uint32_t period);
|
||||
/* The keep-alive timeout */
|
||||
/**
|
||||
* Set the desynchronization timeout after which a node sends a unicasst
|
||||
* keep-alive (KA) to its time source. Set to 0 to stop sending KAs. The
|
||||
* actual timeout is a random number within
|
||||
* [timeout*0.9, timeout[
|
||||
*
|
||||
* \param timeout The timeout in Clock ticks.
|
||||
*/
|
||||
void tsch_set_ka_timeout(uint32_t timeout);
|
||||
/* Set the node as PAN coordinator */
|
||||
/**
|
||||
* Set the node as PAN coordinator
|
||||
*
|
||||
* \param enable 1 to be coordinator, 0 to be a node
|
||||
*/
|
||||
void tsch_set_coordinator(int enable);
|
||||
/* Set the pan as secured or not */
|
||||
/**
|
||||
* Enable/disable security. If done at the coordinator, the Information
|
||||
* will be included in EBs, and all nodes will adopt the same security level.
|
||||
* Enabling requires compilation with LLSEC802154_ENABLED set.
|
||||
* Note: when LLSEC802154_ENABLED is set, nodes boot with security enabled.
|
||||
*
|
||||
* \param enable 1 to enable security, 0 to disable it
|
||||
*/
|
||||
void tsch_set_pan_secured(int enable);
|
||||
/* Set TSCH to send a keepalive message after TSCH_KEEPALIVE_TIMEOUT */
|
||||
/**
|
||||
* Schedule a keep-alive transmission within [timeout*0.9, timeout[
|
||||
* @see tsch_set_ka_timeout
|
||||
*/
|
||||
void tsch_schedule_keepalive(void);
|
||||
/* Set TSCH to send a keepalive message immediately */
|
||||
/**
|
||||
* Schedule a keep-alive immediately
|
||||
*/
|
||||
void tsch_schedule_keepalive_immediately(void);
|
||||
/* Leave the TSCH network */
|
||||
/**
|
||||
* Leave the TSCH network we are currently in
|
||||
*/
|
||||
void tsch_disassociate(void);
|
||||
|
||||
#endif /* __TSCH_H__ */
|
||||
|
@ -23,6 +23,9 @@ slip-radio/sky \
|
||||
libs/ipv6-hooks/sky \
|
||||
nullnet/native \
|
||||
mqtt-client/native \
|
||||
coap/coap-example-client/native \
|
||||
coap/coap-example-server/native \
|
||||
coap/coap-plugtest-server/native \
|
||||
|
||||
TOOLS=
|
||||
|
||||
|
@ -3,6 +3,7 @@ TOOLSDIR=../../tools
|
||||
|
||||
EXAMPLES = \
|
||||
platform-specific/cc26xx/cc26xx-web-demo/srf06-cc26xx \
|
||||
platform-specific/cc26xx/cc26xx-web-demo/srf06-cc26xx:MAKE_ROUTING=MAKE_ROUTING_RPL_CLASSIC \
|
||||
platform-specific/cc26xx/very-sleepy-demo/srf06-cc26xx:BOARD=sensortag/cc2650 \
|
||||
platform-specific/cc26xx/cc26xx-web-demo/srf06-cc26xx:BOARD=sensortag/cc2650 \
|
||||
platform-specific/cc26xx/cc26xx-web-demo/srf06-cc26xx:BOARD=sensortag/cc1350 \
|
||||
@ -38,7 +39,8 @@ mqtt-client/cc2538dk \
|
||||
storage/cfs-coffee/cc2538dk \
|
||||
sensniff/cc2538dk \
|
||||
rpl-udp/cc2538dk \
|
||||
coap/cc2538dk \
|
||||
coap/coap-example-client/cc2538dk \
|
||||
coap/coap-example-server/cc2538dk \
|
||||
slip-radio/cc2538dk \
|
||||
lwm2m-ipso-objects/cc2538dk \
|
||||
multicast/cc2538dk \
|
||||
|
@ -12,7 +12,8 @@ platform-specific/zoul/rev-b/zoul:BOARD=remote-revb \
|
||||
platform-specific/zoul/at-test/zoul \
|
||||
platform-specific/zoul/rtcc/zoul \
|
||||
platform-specific/zoul/zoul \
|
||||
coap/zoul \
|
||||
coap/coap-example-client/zoul \
|
||||
coap/coap-example-server/zoul \
|
||||
multicast/zoul \
|
||||
lwm2m-ipso-objects/zoul \
|
||||
lwm2m-ipso-objects/zoul:MAKE_WITH_DTLS=1 \
|
||||
|
@ -12,6 +12,8 @@ platform-specific/jn516x/rpl/coap-dr1199-node/jn516x \
|
||||
platform-specific/jn516x/tsch/simple-sensor-network/node/jn516x \
|
||||
platform-specific/jn516x/tsch/tx-power-verification/node/jn516x \
|
||||
platform-specific/jn516x/tsch/uart1-test-node/jn516x \
|
||||
coap/coap-example-client/jn516x \
|
||||
coap/coap-example-server/jn516x \
|
||||
sensniff/jn516x \
|
||||
rpl-border-router/jn516x \
|
||||
6tisch/simple-node/jn516x \
|
||||
|
@ -29,9 +29,9 @@
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _PROJECT_CONF_H_
|
||||
#define _PROJECT_CONF_H_
|
||||
#ifndef PROJECT_CONF_H_
|
||||
#define PROJECT_CONF_H_
|
||||
|
||||
#define UNIT_TEST_PRINT_FUNCTION test_print_report
|
||||
|
||||
#endif /* !_PROJECT_CONF_H_ */
|
||||
#endif /* !PROJECT_CONF_H_ */
|
||||
|
@ -1,6 +1,6 @@
|
||||
#ifndef __PROJECT_CONF_H__
|
||||
#define __PROJECT_CONF_H__
|
||||
#ifndef PROJECT_CONF_H_
|
||||
#define PROJECT_CONF_H_
|
||||
|
||||
#define RPL_CONF_DAO_ACK 1
|
||||
|
||||
#endif /* __PROJECT_CONF_H__ */
|
||||
#endif /* PROJECT_CONF_H_ */
|
||||
|
@ -28,8 +28,8 @@
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _PROJECT_CONF_H_
|
||||
#define _PROJECT_CONF_H_
|
||||
#ifndef PROJECT_CONF_H_
|
||||
#define PROJECT_CONF_H_
|
||||
|
||||
#define SIXTOP_CONF_MAX_SCHEDULING_FUNCTIONS 2
|
||||
|
||||
@ -52,4 +52,4 @@
|
||||
/* Custom MAC layer */
|
||||
#define NETSTACK_CONF_MAC test_mac_driver
|
||||
|
||||
#endif /* __PROJECT_CONF_H__ */
|
||||
#endif /* PROJECT_CONF_H_ */
|
||||
|
@ -29,8 +29,8 @@
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _PROJECT_CONF_H_
|
||||
#define _PROJECT_CONF_H_
|
||||
#ifndef PROJECT_CONF_H_
|
||||
#define PROJECT_CONF_H_
|
||||
|
||||
#define UNIT_TEST_PRINT_FUNCTION test_print_report
|
||||
|
||||
@ -41,4 +41,4 @@
|
||||
|
||||
#define TSCH_CONF_WITH_SIXTOP 1
|
||||
|
||||
#endif /* __PROJECT_CONF_H__ */
|
||||
#endif /* PROJECT_CONF_H_ */
|
||||
|
@ -29,8 +29,8 @@
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _PROJECT_CONF_H_
|
||||
#define _PROJECT_CONF_H_
|
||||
#ifndef PROJECT_CONF_H_
|
||||
#define PROJECT_CONF_H_
|
||||
|
||||
#define UNIT_TEST_PRINT_FUNCTION test_print_report
|
||||
|
||||
@ -38,4 +38,4 @@
|
||||
#include "project-tsch-conf.h"
|
||||
#endif /* MAC_CONF_WITH_TSCH */
|
||||
|
||||
#endif /* !_PROJECT_CONF_H_ */
|
||||
#endif /* !PROJECT_CONF_H_ */
|
||||
|
@ -12,8 +12,8 @@ declare -i TESTCOUNT=0
|
||||
|
||||
# Starting Contiki-NG native node
|
||||
echo "Starting native CoAP server"
|
||||
make -C $CONTIKI/examples/coap > make.log 2> make.err
|
||||
sudo $CONTIKI/examples/coap/coap-example-server.native > node.log 2> node.err &
|
||||
make -C $CONTIKI/examples/coap/coap-example-server > make.log 2> make.err
|
||||
sudo $CONTIKI/examples/coap/coap-example-server/coap-example-server.native > node.log 2> node.err &
|
||||
CPID=$!
|
||||
sleep 2
|
||||
|
||||
@ -41,7 +41,7 @@ sleep 2
|
||||
pgrep coap-example | sudo xargs kill -9
|
||||
|
||||
if [ $TESTCOUNT -eq $OKCOUNT ] ; then
|
||||
printf "%-32s TEST OK %3d/%d\n" "$BASENAME" "$OKCOUNT" "$TESTCOUNT" > $BASENAME.testlog;
|
||||
printf "%-32s TEST OK %3d/%d\n" "$BASENAME" "$OKCOUNT" "$TESTCOUNT" | tee $BASENAME.testlog;
|
||||
else
|
||||
echo "==== make.log ====" ; cat make.log;
|
||||
echo "==== make.err ====" ; cat make.err;
|
||||
@ -49,7 +49,7 @@ else
|
||||
echo "==== node.err ====" ; cat node.err;
|
||||
echo "==== $BASENAME.log ====" ; cat $BASENAME.log;
|
||||
|
||||
printf "%-32s TEST FAIL %3d/%d\n" "$BASENAME" "$OKCOUNT" "$TESTCOUNT" > $BASENAME.testlog;
|
||||
printf "%-32s TEST FAIL %3d/%d\n" "$BASENAME" "$OKCOUNT" "$TESTCOUNT" | tee $BASENAME.testlog;
|
||||
fi
|
||||
|
||||
rm -f make.log make.err node.log node.err coap.log
|
||||
|
Loading…
Reference in New Issue
Block a user