Skip to content

Commit ce735f4

Browse files
zhhyu7xiaoxiang781216
authored andcommitted
libcoap: add makefile and Kconfig
server: when ipv6 is enable: ap> coap_server only ipv4 is enable, we need to specify the ip address of the network card: ap> coap_server -A [ipv4 address] client: ap> coap_client -m get coap://[ipv4/6 address]/time Dec 26 06:41:12 Other Examples: coap_client -m get coap://[::1]/ coap_client -m get coap://[::1]/.well-known/core coap_client -m get coap+tcp://[::1]/.well-known/core coap_client -m get coap://%2Funix%2Fdomain%2Fpath%2Fdgram/.well-known/core coap_client -m get coap+tcp://%2Funix%2Fdomain%2Fpath%2Fstream/.well-known/core coap_client -m get coaps://[::1]/.well-known/core coap_client -m get coaps+tcp://[::1]/.well-known/core coap_client -m get coaps://%2Funix%2Fdomain%2Fpath%2Fdtls/.well-known/core coap_client -m get coaps+tcp://%2Funix%2Fdomain%2Fpath%2Ftls/.well-known/core coap_client -m get -T cafe coap://[::1]/time echo -n 1000 | coap-client -m put -T cafe coap://[::1]/time -f - Signed-off-by: zhanghongyu <[email protected]>
1 parent cf27f08 commit ce735f4

File tree

5 files changed

+394
-0
lines changed

5 files changed

+394
-0
lines changed

netutils/libcoap/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/libcoap*

netutils/libcoap/Kconfig

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#
2+
# For a description of the syntax of this configuration file,
3+
# see the file kconfig-language.txt in the NuttX tools repository.
4+
#
5+
6+
config NETUTILS_LIBCOAP
7+
bool "LIBCOAP"
8+
default n
9+
---help---
10+
libcoap is a C implementation of a lightweight application-protocol
11+
for devices that are constrained their resources such as computing
12+
power, RF range, memory, bandwidth, or network packet sizes. This
13+
protocol, CoAP, is standardized by the IETF as RFC 7252.
14+
15+
if NETUTILS_LIBCOAP
16+
17+
config LIBCOAP_VERSION
18+
string "libcoap version"
19+
default "4.3.4"
20+
21+
config NETUTILS_LIBCOAP_EXAMPLE
22+
tristate "Example coap-server and coap-client"
23+
default n
24+
25+
if NETUTILS_LIBCOAP_EXAMPLE
26+
27+
config NETUTILS_LIBCOAP_EXAMPLE_PRIORITY
28+
int "libcoap example priority"
29+
default 100
30+
31+
config NETUTILS_LIBCOAP_EXAMPLE_STACKSIZE
32+
int "libcoap example stacksize"
33+
default 2048
34+
35+
endif # NETUTILS_LIBCOAP_EXAMPLE
36+
37+
endif # NETUTILS_LIBCOAP

netutils/libcoap/Make.defs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
############################################################################
2+
# apps/netutils/libcoap/Make.defs
3+
#
4+
# Licensed to the Apache Software Foundation (ASF) under one or more
5+
# contributor license agreements. See the NOTICE file distributed with
6+
# this work for additional information regarding copyright ownership. The
7+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance with the
9+
# License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16+
# License for the specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
############################################################################
20+
21+
ifneq ($(CONFIG_NETUTILS_LIBCOAP),)
22+
CONFIGURED_APPS += $(APPDIR)/netutils/libcoap
23+
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)$(DELIM)netutils$(DELIM)libcoap$(DELIM)libcoap$(DELIM)include
24+
endif

netutils/libcoap/Makefile

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
############################################################################
2+
# apps/netutils/libcoap/Makefile
3+
#
4+
# Licensed to the Apache Software Foundation (ASF) under one or more
5+
# contributor license agreements. See the NOTICE file distributed with
6+
# this work for additional information regarding copyright ownership. The
7+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance with the
9+
# License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16+
# License for the specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
############################################################################
20+
21+
include $(APPDIR)/Make.defs
22+
23+
COAP_URL ?= "https://codeload.github.com/obgm/libcoap/zip/refs/tags"
24+
25+
COAP_ZIP = libcoap-$(CONFIG_LIBCOAP_VERSION).zip
26+
27+
COAP_UNPACKNAME = libcoap
28+
UNPACK ?= unzip -q -o
29+
30+
$(COAP_ZIP):
31+
@echo "Downloading: $(COAP_URL)/v$(CONFIG_LIBCOAP_VERSION)"
32+
$(Q) curl -o $(COAP_ZIP) -L $(COAP_URL)/v$(CONFIG_LIBCOAP_VERSION)
33+
34+
$(COAP_UNPACKNAME): $(COAP_ZIP)
35+
@echo "Unpacking: $(COAP_ZIP) -> $(COAP_UNPACKNAME)"
36+
$(Q) $(UNPACK) $(COAP_ZIP)
37+
@echo "Unpacking: $(COAP_ZIP) -> $(COAP_UNPACKNAME)"
38+
$(Q) mv libcoap-$(CONFIG_LIBCOAP_VERSION) $(COAP_UNPACKNAME)
39+
$(Q) touch $(COAP_UNPACKNAME)
40+
41+
# Download and unpack tarball if no git repo found
42+
ifeq ($(wildcard $(COAP_UNPACKNAME)/.git),)
43+
context:: $(COAP_UNPACKNAME)
44+
45+
distclean::
46+
$(call DELDIR, $(COAP_UNPACKNAME))
47+
$(call DELFILE, $(COAP_ZIP))
48+
endif
49+
50+
context:: $(COAP_UNPACKNAME)/include/coap3/coap.h
51+
52+
$(COAP_UNPACKNAME)/include/coap3/coap.h:: $(COAP_UNPACKNAME)
53+
cd $(COAP_UNPACKNAME) && ./autogen.sh && \
54+
./configure --disable-doxygen --disable-manpages
55+
56+
CSRCS += libcoap/src/coap_address.c
57+
CSRCS += libcoap/src/coap_asn1.c
58+
CSRCS += libcoap/src/coap_async.c
59+
CSRCS += libcoap/src/coap_block.c
60+
CSRCS += libcoap/src/coap_cache.c
61+
CSRCS += libcoap/src/coap_debug.c
62+
CSRCS += libcoap/src/coap_dtls.c
63+
CSRCS += libcoap/src/coap_encode.c
64+
CSRCS += libcoap/src/coap_event.c
65+
CSRCS += libcoap/src/coap_hashkey.c
66+
CSRCS += libcoap/src/coap_gnutls.c
67+
CSRCS += libcoap/src/coap_io.c
68+
CSRCS += libcoap/src/coap_layers.c
69+
CSRCS += libcoap/src/coap_mbedtls.c
70+
CSRCS += libcoap/src/coap_mem.c
71+
CSRCS += libcoap/src/coap_net.c
72+
CSRCS += libcoap/src/coap_netif.c
73+
CSRCS += libcoap/src/coap_notls.c
74+
CSRCS += libcoap/src/coap_openssl.c
75+
CSRCS += libcoap/src/coap_option.c
76+
CSRCS += libcoap/src/coap_oscore.c
77+
CSRCS += libcoap/src/coap_pdu.c
78+
CSRCS += libcoap/src/coap_prng.c
79+
CSRCS += libcoap/src/coap_resource.c
80+
CSRCS += libcoap/src/coap_session.c
81+
CSRCS += libcoap/src/coap_str.c
82+
CSRCS += libcoap/src/coap_subscribe.c
83+
CSRCS += libcoap/src/coap_tcp.c
84+
CSRCS += libcoap/src/coap_time.c
85+
CSRCS += libcoap/src/coap_tinydtls.c
86+
CSRCS += libcoap/src/coap_uri.c
87+
CSRCS += libcoap/src/coap_ws.c
88+
CSRCS += libcoap/src/oscore/oscore.c
89+
CSRCS += libcoap/src/oscore/oscore_cbor.c
90+
CSRCS += libcoap/src/oscore/oscore_context.c
91+
CSRCS += libcoap/src/oscore/oscore_cose.c
92+
CSRCS += libcoap/src/oscore/oscore_crypto.c
93+
94+
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)$(DELIM)netutils$(DELIM)libcoap
95+
CFLAGS += -Wno-undef
96+
97+
ifneq ($(CONFIG_NETUTILS_LIBCOAP_EXAMPLE),)
98+
PROGNAME += coap_server coap_client
99+
PRIORITY = $(CONFIG_NETUTILS_LIBCOAP_EXAMPLE_PRIORITY)
100+
STACKSIZE = $(CONFIG_NETUTILS_LIBCOAP_EXAMPLE_STACKSIZE)
101+
MODULE = $(CONFIG_NETUTILS_LIBCOAP_EXAMPLE)
102+
MAINSRC = libcoap/examples/coap-server.c libcoap/examples/coap-client.c
103+
endif
104+
105+
include $(APPDIR)/Application.mk

netutils/libcoap/coap_config.h

Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
/****************************************************************************
2+
* apps/netutils/libcoap/coap_config.h
3+
*
4+
* Copyright (C) 2020 Carlos Gomes Martinho
5+
6+
* Copyright (C) 2021-2023 Jon Shallow <[email protected]>
7+
*
8+
* SPDX-License-Identifier: BSD-2-Clause
9+
*
10+
* This file is part of the CoAP library libcoap. Please see README for terms
11+
* of use.
12+
****************************************************************************/
13+
14+
#ifndef COAP_CONFIG_H_
15+
#define COAP_CONFIG_H_
16+
17+
#if ! defined(_WIN32)
18+
#define _GNU_SOURCE
19+
#endif
20+
21+
/* Define to 1 if you have <ws2tcpip.h> header file. */
22+
23+
/* #undef HAVE_WS2TCPIP_H */
24+
25+
/* Define to 1 if the system has small stack size. */
26+
27+
/* #undef COAP_CONSTRAINED_STACK */
28+
29+
/* Define to 1 if you have <winsock2.h> header file. */
30+
31+
/* #undef HAVE_WINSOCK2_H */
32+
33+
#ifdef CONFIG_LIBCOAP_EXAMPLE_CLIENT
34+
/* Define to 1 if the library has client support. */
35+
#define COAP_CLIENT_SUPPORT 1
36+
37+
/* Define to 1 if the library has server support. */
38+
#define COAP_SERVER_SUPPORT 1
39+
#endif
40+
41+
/* Define to 1 if the library is to have observe persistence. */
42+
#define COAP_WITH_OBSERVE_PERSIST 1
43+
44+
/* Define to 1 if the system has epoll support. */
45+
46+
/* #undef COAP_EPOLL_SUPPORT */
47+
48+
/* Define to 1 if the library has OSCORE support. */
49+
#define COAP_OSCORE_SUPPORT 1
50+
51+
/* Define to 1 if the library has WebSockets support. */
52+
53+
/* #undef COAP_WS_SUPPORT */
54+
55+
/* Define to 1 if the library has async separate response support. */
56+
#define COAP_ASYNC_SUPPORT 1
57+
58+
/* Define to 0-8 for maximum logging level. */
59+
60+
/* #undef COAP_MAX_LOGGING_LEVEL */
61+
62+
/* Define to 1 to build without TCP support. */
63+
#define COAP_DISABLE_TCP 0
64+
65+
#ifdef CONFIG_NET_IPv4
66+
/* Define to 1 to build with IPv4 support. */
67+
#define COAP_IPV4_SUPPORT 1
68+
#endif
69+
70+
#ifdef CONFIG_NET_IPv6
71+
/* Define to 1 to build with IPv6 support. */
72+
#define COAP_IPV6_SUPPORT 1
73+
#endif
74+
75+
/* Define to 1 to build with Unix socket support. */
76+
#define COAP_AF_UNIX_SUPPORT 1
77+
78+
/* Define to 1 to build with Q-Block (RFC 9177) support. */
79+
#define COAP_Q_BLOCK_SUPPORT 1
80+
81+
/* Define to 1 if you have the <arpa/inet.h> header file. */
82+
#define HAVE_ARPA_INET_H 1
83+
84+
/* Define to 1 if you have the <assert.h> header file. */
85+
#define HAVE_ASSERT_H 1
86+
87+
/* Define to 1 if you have the <dlfcn.h> header file. */
88+
89+
/* #undef HAVE_DLFCN_H */
90+
91+
/* Define to 1 if you have the `getaddrinfo' function. */
92+
#define HAVE_GETADDRINFO 1
93+
94+
/* Define to 1 if you have the <inttypes.h> header file. */
95+
#define HAVE_INTTYPES_H 1
96+
97+
/* Define to 1 if you have the <erno.h> header file. */
98+
#define HAVE_ERRNO_H 1
99+
100+
/* Define to 1 if the system has openssl */
101+
102+
/* #undef COAP_WITH_LIBOPENSSL */
103+
104+
/* Define to 1 if the system has libgnutls28 */
105+
106+
/* #undef COAP_WITH_LIBGNUTLS */
107+
108+
/* Define to 1 if the system has libtinydtls */
109+
110+
/* #undef COAP_WITH_LIBTINYDTLS */
111+
112+
/* Define to 1 if the system has libmbedtls */
113+
#define COAP_WITH_LIBMBEDTLS 1
114+
115+
/* Define to 1 if you have the <limits.h> header file. */
116+
#define HAVE_LIMITS_H 1
117+
118+
/* Define to 1 if you have the `malloc' function. */
119+
#define HAVE_MALLOC 1
120+
121+
/* Define to 1 if you have the <memory.h> header file. */
122+
#define HAVE_MEMORY_H 1
123+
124+
/* Define to 1 if you have the `memset' function. */
125+
#define HAVE_MEMSET 1
126+
127+
/* Define to 1 if you have the `if_nametoindex' function. */
128+
#define HAVE_IF_NAMETOINDEX 1
129+
130+
/* Define to 1 if you have the <netdb.h> header file. */
131+
#define HAVE_NETDB_H 1
132+
133+
/* Define to 1 if you have the <net/if.h> header file. */
134+
#define HAVE_NET_IF_H 1
135+
136+
/* Define to 1 if you have the <netinet/in.h> header file. */
137+
#define HAVE_NETINET_IN_H 1
138+
139+
/* Define to 1 if you have the <pthread.h> header file. */
140+
#define HAVE_PTHREAD_H 1
141+
142+
/* Define to 1 if you have the `pthread_mutex_lock' function. */
143+
#define HAVE_PTHREAD_MUTEX_LOCK 1
144+
145+
/* Define to 1 if you have the `select' function. */
146+
#define HAVE_SELECT 1
147+
148+
/* Define to 1 if you have the `socket' function. */
149+
#define HAVE_SOCKET 1
150+
151+
/* Define to 1 if you have the <stdint.h> header file. */
152+
#define HAVE_STDINT_H 1
153+
154+
/* Define to 1 if you have the <stdlib.h> header file. */
155+
#define HAVE_STDLIB_H 1
156+
157+
/* Define to 1 if you have the `strcasecmp' function. */
158+
#define HAVE_STRCASECMP 1
159+
160+
/* Define to 1 if you have the <strings.h> header file. */
161+
#define HAVE_STRINGS_H 1
162+
163+
/* Define to 1 if you have the <string.h> header file. */
164+
#define HAVE_STRING_H 1
165+
166+
/* Define to 1 if you have the `strnlen' function. */
167+
#define HAVE_STRNLEN 1
168+
169+
/* Define to 1 if you have the `strrchr' function. */
170+
#define HAVE_STRRCHR 1
171+
172+
/* Define to 1 if you have the `getrandom' function. */
173+
#define HAVE_GETRANDOM 1
174+
175+
/* Define to 1 if you have the `randon' function. */
176+
#define HAVE_RANDOM 1
177+
178+
/* Define to 1 if the system has the type `struct cmsghdr'. */
179+
#define HAVE_STRUCT_CMSGHDR 1
180+
181+
/* Define to 1 if you have the <sys/ioctl.h> header file. */
182+
#define HAVE_SYS_IOCTL_H 1
183+
184+
/* Define to 1 if you have the <sys/socket.h> header file. */
185+
#define HAVE_SYS_SOCKET_H 1
186+
187+
/* Define to 1 if you have the <sys/stat.h> header file. */
188+
#define HAVE_SYS_STAT_H 1
189+
190+
/* Define to 1 if you have the <sys/time.h> header file. */
191+
#define HAVE_SYS_TIME_H 1
192+
193+
/* Define to 1 if you have the <sys/types.h> header file. */
194+
#define HAVE_SYS_TYPES_H 1
195+
196+
/* Define to 1 if you have the <sys/unistd.h> header file. */
197+
#define HAVE_SYS_UNISTD_H 1
198+
199+
/* Define to 1 if you have the <time.h> header file. */
200+
#define HAVE_TIME_H 1
201+
202+
/* Define to 1 if you have the <unistd.h> header file. */
203+
#define HAVE_UNISTD_H 1
204+
205+
/* Define to the address where bug reports for this package should be sent. */
206+
#define PACKAGE_BUGREPORT "[email protected]"
207+
208+
/* Define to the full name of this package. */
209+
#define PACKAGE_NAME "libcoap"
210+
211+
/* Define to the full name and version of this package. */
212+
#define PACKAGE_STRING "libcoap 4.3.4"
213+
214+
/* Define to the one symbol short name of this package. */
215+
#define PACKAGE_TARNAME "libcoap"
216+
217+
/* Define to the home page for this package. */
218+
#define PACKAGE_URL "https://libcoap.net/"
219+
220+
/* Define to the version of this package. */
221+
#define PACKAGE_VERSION "4.3.4"
222+
223+
#if defined(_MSC_VER) && (_MSC_VER < 1900) && !defined(snprintf)
224+
#define snprintf _snprintf
225+
#endif
226+
227+
#endif /* COAP_CONFIG_H_ */

0 commit comments

Comments
 (0)