Skip to content

Commit

Permalink
Updates Contiki-specific code to Contiki-NG
Browse files Browse the repository at this point in the history
  • Loading branch information
kkrentz authored and mrdeep1 committed Feb 8, 2023
1 parent 33ddcc4 commit 79c6670
Show file tree
Hide file tree
Showing 31 changed files with 457 additions and 1,001 deletions.
10 changes: 5 additions & 5 deletions BUILDING
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ get the TinyDTLS code into your project, so the TinyDTLS library can be used.
git submodule init
git submodule update

General Building with cmake for linux/windows/macos/android (not for LwIP or Contiki - see below)
General Building with cmake for linux/windows/macos/android (not for LwIP or Contiki-NG - see below)
================

cmake -E remove_directory build
Expand All @@ -61,7 +61,7 @@ General Building with cmake for linux/windows/macos/android (not for LwIP or Con

Note: Shared Library support is not currently available for Windows.

General Building with autoconf (not for LwIP or Contiki - see below)
General Building with autoconf (not for LwIP or Contiki-NG - see below)
================

./autogen.sh
Expand Down Expand Up @@ -124,15 +124,15 @@ LwIP

Executable is ./server. See examples/lwip/README for further information

Contiki
=======
Contiki-NG
==========

./autogen.sh
./configure --disable-tests --disable-documentation --disable-examples --disable-dtls
cd examples/contiki
make

Executable is ./server.minimal-net. See examples/contiki/README for further
Executable is ./server.native. See examples/contiki/README for further
information

Windows
Expand Down
5 changes: 3 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@ EXTRA_DIST = \
examples/coap_list.h \
examples/getopt.c \
examples/contiki/coap_config.h \
examples/contiki/coap-observer.c \
examples/contiki/Makefile \
examples/contiki/Makefile.contiki \
examples/contiki/radvd.conf.sample \
examples/contiki/project-conf.h \
examples/contiki/README \
examples/contiki/server.c \
examples/lwip/client.c \
Expand Down Expand Up @@ -93,6 +92,7 @@ EXTRA_DIST = \
include/oscore/oscore_cose.h \
include/oscore/oscore_crypto.h \
include/oscore/oscore.h \
src/coap_io_contiki.c \
src/coap_io_lwip.c \
src/coap_io_riot.c \
tests/test_error_response.h \
Expand Down Expand Up @@ -234,6 +234,7 @@ CTAGS_IGNORE=-I " \
coap_pdu_from_pbuf \
coap_lwip_dump_memory_pools \
coap_lwip_set_input_wait_handler \
coap_print_contiki_prefix \
"

# This helper is called by libcoap-$(LIBCOAP_API_VERSION).{map,sym} to see if
Expand Down
12 changes: 5 additions & 7 deletions Makefile.libcoap
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
libcoap_src = pdu.c net.c coap_cache.c coap_debug.c encode.c uri.c coap_subscribe.c resource.c str.c coap_option.c coap_async.c block.c mem.c coap_io.c coap_session.c coap_notls.c coap_hashkey.c coap_address.c coap_tcp.c coap_oscore.c

libcoap_dir := $(filter %libcoap,$(APPDS))
vpath %c $(libcoap_dir)/src

# set include path for coap sources
CFLAGS += -I$(libcoap_dir)/include
LIBCOAP_DIR = os/net/app-layer/libcoap
MODULES += $(LIBCOAP_DIR)/src
MODULES += $(LIBCOAP_DIR)/include
MODULES_SOURCES_EXCLUDES += coap_io_riot.c
MODULES_SOURCES_EXCLUDES += coap_io_lwip.c
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ PACKAGE CONTENTS

This package contains a protocol parser and basic networking
functions for platforms with support for malloc() and BSD-style
sockets. In addition, there is support for Contiki, LwIP and
sockets. In addition, there is support for Contiki-NG, LwIP and
Espressif/ESP-IDF hosted environments.

The following RFCs are supported
Expand Down
237 changes: 49 additions & 188 deletions coap_config.h.contiki
Original file line number Diff line number Diff line change
@@ -1,216 +1,77 @@
#ifndef COAP_CONFIG_H_
#define COAP_CONFIG_H_

#include "contiki.h"
#include "contiki-lib.h"
#include "contiki-net.h"
/* Define if the system has small stack size */
#define COAP_CONSTRAINED_STACK 1

#define WITH_CONTIKI 1
/* Define to 1 if you have the <assert.h> header file. */
#define HAVE_ASSERT_H 1

#ifndef COAP_CONSTRAINED_STACK
#define COAP_CONSTRAINED_STACK 1
#endif
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1

#ifndef COAP_DISABLE_TCP
/* Define to 1 to build without TCP support. */
#define COAP_DISABLE_TCP 1
#endif

#define PACKAGE_STRING "libcoap"
#define PACKAGE_NAME "libcoap"
/* Define to 1 if you have the <limits.h> header file. */
#define HAVE_LIMITS_H 1

#ifndef COAP_DEFAULT_PDU_SIZE
#define COAP_DEFAULT_PDU_SIZE 64
#endif /* COAP_DEFAULT_PDU_SIZE */
#ifndef COAP_RXBUFFER_SIZE
#define COAP_RXBUFFER_SIZE 64
#endif /* COAP_RXBUFFER_SIZE */

/** Number of resources that can be handled by a CoAP server in addition to
* @c /.well-known/core */
#ifndef COAP_MAX_RESOURCES
#define COAP_MAX_RESOURCES 3
#endif /* COAP_MAX_RESOURCES */

/** Number of attributes that can be handled (should be at least
* @c 2 * COAP_MAX_RESOURCES. to carry the content type and the
* resource type. */
#ifndef COAP_MAX_ATTRIBUTES
#define COAP_MAX_ATTRIBUTES 4
#endif /* COAP_MAX_ATTRIBUTES */

/**
* Number of PDUs that can be stored simultaneously. This number
* includes both, the PDUs stored for retransmission as well as the
* PDUs received. Beware that choosing a too small value can lead to
* many retransmissions to be dealt with.
*/
#ifndef COAP_PDU_MAXCNT
#define COAP_PDU_MAXCNT 4
#endif /* COAP_PDU_MAXCNT */

/**
* Maximum number of sessions.
*/
#ifndef COAP_MAX_SESSIONS
#define COAP_MAX_SESSIONS 2
#endif /* COAP_MAX_SESSIONS */

/**
* Maximum number of subscriptions. Every additional subscriber costs
* 36 B.
*/
#ifndef COAP_MAX_SUBSCRIBERS
#define COAP_MAX_SUBSCRIBERS 3
#endif /* COAP_MAX_SUBSCRIBERS */

/**
* The maximum number of cache-key entries that allocate
* fixed-size memory blocks.
*/
#ifndef COAP_MAX_CACHE_KEYS
#define COAP_MAX_CACHE_KEYS (2U)
#endif /* COAP_MAX_CACHE_KEYS */

/**
* The maximum number of cache-entry entries that allocate
* fixed-size memory blocks.
*/
#ifndef COAP_MAX_CACHE_ENTRIES
#define COAP_MAX_CACHE_ENTRIES (2U)
#endif /* COAP_MAX_CACHE_ENTRIES */

/**
* Maximum number of large body transmissions.
*/
#ifndef COAP_MAX_LG_XMIT
#define COAP_MAX_LG_XMIT 2
#endif /* COAP_MAX_LG_XMIT */

/**
* Maximum number of large body client receives.
*/
#ifndef COAP_MAX_LG_CRCV
#define COAP_MAX_LG_CRCV 2
#endif /* COAP_MAX_LG_CRCV */

/**
* Maximum number of large body server receives.
*/
#ifndef COAP_MAX_LG_SRCV
#define COAP_MAX_LG_SRCV 2
#endif /* COAP_MAX_LG_SRCV */

/**
* Number of notifications that may be sent non-confirmable before a confirmable
* message is sent to detect if observers are alive. The maximum allowed value
* here is @c 255.
*/
#ifndef COAP_OBS_MAX_NON
#define COAP_OBS_MAX_NON 5
#endif /* COAP_OBS_MAX_NON */
#if COAP_OBS_MAX_NON > 255
#error COAP_OBS_MAX_NON is too large
#endif /* COAP_OBS_MAX_NON > 255 */

/**
* Number of different confirmable notifications that may fail (i.e. those
* that have hit MAX_RETRANSMIT multiple times) before an observer is removed.
* The maximum value for COAP_OBS_MAX_FAIL is @c 255.
*/
#ifndef COAP_OBS_MAX_FAIL
#define COAP_OBS_MAX_FAIL 1
#endif /* COAP_OBS_MAX_FAIL */
#if COAP_OBS_MAX_FAIL > 255
#error COAP_OBS_MAX_FAIL is too large
#endif /* COAP_OBS_MAX_FAIL > 255 */

#ifndef DEBUG
# define DEBUG DEBUG_PRINT
#endif
/* Define to 1 if you have the `memset' function. */
#define HAVE_MEMSET 1

#define HAVE_STRNLEN 1
#define HAVE_SNPRINTF 1
#define HAVE_STRINGS_H 1
#define HAVE_NETDB_H 1
/* Define to 1 if you have the <stddef.h> header file. */
#define HAVE_STDDEF_H 1

/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1

/* there is no file-oriented output */
#define COAP_DEBUG_FD NULL
#define COAP_ERR_FD NULL
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1

#include "contiki-conf.h"
/* Define to 1 if you have the `strcasecmp' function. */
#define HAVE_STRCASECMP 1

#if (defined(PLATFORM) && PLATFORM == PLATFORM_MC1322X) || defined(CONTIKI_TARGET_ECONOTAG)
/* Redbee econotags get a special treatment here: endianness is set
* explicitly, and
*/
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1

#define BYTE_ORDER UIP_LITTLE_ENDIAN
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1

#define HAVE_ASSERT_H
#define HAVE_UNISTD_H
#define HAVE_SYS_TYPES_H
#define HAVE_LIMITS_H
#endif /* PLATFORM_MC1322X || CONTIKI_TARGET_ECONOTAG */
/* Define to 1 if you have the `strnlen' function. */
#define HAVE_STRNLEN 1

#if defined(TMOTE_SKY) || defined(CONTIKI_TARGET_SKY) || defined(CONTIKI_TARGET_WISMOTE)
/* Need to set the byte order for TMote Sky explicitely */
/* Define to 1 if you have the `strrchr' function. */
#define HAVE_STRRCHR 1

#define BYTE_ORDER UIP_LITTLE_ENDIAN
#undef COAP_DEFAULT_PDU_SIZE
#undef COAP_RXBUFFER_SIZE
#define COAP_DEFAULT_PDU_SIZE 100
#define COAP_RXBUFFER_SIZE 100
/* Define to 1 if you have the `snprintf' function. */
#define HAVE_SNPRINTF 1

#define COAP_MAX_BLOCK_SZX 2
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "libcoap-developers@lists.sourceforge.net"

typedef int ssize_t;
typedef void FILE;
/* Define to the full name of this package. */
#define PACKAGE_NAME "libcoap"

#define HAVE_LIMITS_H 1
#undef HAVE_ASSERT_H
#define HAVE_VPRINTF 1
#endif /* defined(TMOTE_SKY) */

#ifdef CONTIKI_TARGET_MINIMAL_NET
#undef COAP_DEFAULT_PDU_SIZE
#undef COAP_RXBUFFER_SIZE
#define COAP_DEFAULT_PDU_SIZE 1152
#define COAP_RXBUFFER_SIZE 1472
#define HAVE_ASSERT_H 1
#define HAVE_VPRINTF 1
#define HAVE_SYS_TYPES_H 1
#endif /* CONTIKI_TARGET_MINIMAL_NET */
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "libcoap 4.3.0"

#ifdef CONTIKI_TARGET_CC2538DK
#define BYTE_ORDER UIP_LITTLE_ENDIAN
#undef COAP_DEFAULT_PDU_SIZE
#undef COAP_RXBUFFER_SIZE
#define COAP_DEFAULT_PDU_SIZE 100
#define COAP_RXBUFFER_SIZE 100
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "libcoap"

#undef COAP_MAX_BLOCK_SZX
#define COAP_MAX_BLOCK_SZX 2
/* Define to the home page for this package. */
#define PACKAGE_URL "https://libcoap.net/"

#define HAVE_LIMITS_H 1
#endif /* CONTIKI_TARGET_CC2538DK */

#ifndef BYTE_ORDER
# ifdef UIP_CONF_BYTE_ORDER
# define BYTE_ORDER UIP_CONF_BYTE_ORDER
# else
# error "UIP_CONF_BYTE_ORDER not defined"
# endif /* UIP_CONF_BYTE_ORDER */
#endif /* BYTE_ORDER */

/* Define assert() as empty directive unless HAVE_ASSERT_H is given. */
#ifndef HAVE_ASSERT_H
# define assert(x)
#endif
/* Define to the version of this package. */
#define PACKAGE_VERSION "4.3.0"

#define WITH_CONTIKI 1

#define ntohs uip_ntohs

#include <stdio.h>
#define coap_log(fd, ...) printf(__VA_ARGS__)
#define HASH_NONFATAL_OOM 1

#endif /* COAP_CONFIG_H_ */
#ifndef HEAPMEM_CONF_ARENA_SIZE
#define HEAPMEM_CONF_ARENA_SIZE 4096
#endif

#endif /* COAP_CONFIG_H_ */
3 changes: 2 additions & 1 deletion doc/Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,8 @@ RECURSIVE = NO
# Note that relative paths are relative to the directory from which doxygen is
# run.

EXCLUDE = @top_srcdir@/src/coap_io_lwip.c \
EXCLUDE = @top_srcdir@/src/coap_io_contiki.c \
@top_srcdir@/src/coap_io_lwip.c \
@top_srcdir@/src/coap_io_riot.c \
@top_srcdir@/include/coap@LIBCOAP_API_VERSION@/coap_uthash_internal.h \
@top_srcdir@/include/coap@LIBCOAP_API_VERSION@/coap_utlist_internal.h
Expand Down
9 changes: 2 additions & 7 deletions examples/contiki/.gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
contiki-minimal-net.a
contiki-minimal-net.map
contiki/
obj_minimal-net/
server.minimal-net
symbols.c
symbols.h
contiki-ng/
server.native
14 changes: 7 additions & 7 deletions examples/contiki/Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
CONTIKI=contiki
TARGET?=minimal-net
CONTIKI=contiki-ng
TARGET?=native

all: server

$(CONTIKI):
git clone --depth 1 https://github.com/contiki-os/contiki.git $@
cd $(CONTIKI)/apps && ln -s ../../../.. libcoap
git clone --depth 1 https://github.com/contiki-ng/contiki-ng.git $@
cd $(CONTIKI)/os/net/app-layer && rm -rf libcoap && ln -s ../../../../../.. libcoap

server: $(CONTIKI)
$(MAKE) -f Makefile.contiki V=1 CONTIKI=$(CONTIKI) TARGET=$(TARGET) NODE_ADDR=0x1000 server
$(MAKE) -f Makefile.contiki CONTIKI=$(CONTIKI) TARGET=$(TARGET) server

clean:
$(MAKE) -f Makefile.contiki V=1 CONTIKI=$(CONTIKI) TARGET=$(TARGET) clean
rm -f server.minimal-net symbols.c symbols.h
$(MAKE) -f Makefile.contiki CONTIKI=$(CONTIKI) TARGET=$(TARGET) clean
rm -rf build
Loading

0 comments on commit 79c6670

Please sign in to comment.