Skip to content

Commit

Permalink
coap: Update to latest libcoap code (4.3.2rc1)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdeep1 committed Jul 23, 2023
1 parent 10a1fdd commit f201d9b
Show file tree
Hide file tree
Showing 16 changed files with 139 additions and 2,595 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
sbom-supplier = Organization: libcoap <https://libcoap.net/>
sbom-url = https://github.com/obgm/libcoap
sbom-description = A CoAP (RFC 7252) implementation in C
sbom-hash = c694baead2f9b408a7598e0b85c2f257ea8c9651
sbom-hash = c35c0783e298de956ae6b334b768dd5de4c6b035

[submodule "usb/usb_host_uvc/libuvc"]
path = usb/usb_host_uvc/libuvc
Expand Down
31 changes: 14 additions & 17 deletions coap/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,38 +1,35 @@
if(NOT CONFIG_LWIP_IPV6 AND NOT CMAKE_BUILD_EARLY_EXPANSION)
message(STATUS "IPV6 support is disabled so the coap component will not be built")
# note: the component is still included in the build so it can become visible again in config
# without needing to re-run CMake. However no source or header files are built.
idf_component_register()
return()
endif()

set(include_dirs port/include port/include libcoap/include)

set(srcs
"port/src/block.c"
"libcoap/src/coap_address.c"
"libcoap/src/coap_asn1.c"
"libcoap/src/coap_async.c"
"libcoap/src/coap_block.c"
"libcoap/src/coap_cache.c"
"libcoap/src/coap_debug.c"
"libcoap/src/coap_dtls.c"
"libcoap/src/coap_encode.c"
"libcoap/src/coap_event.c"
"libcoap/src/coap_hashkey.c"
"libcoap/src/coap_io.c"
"libcoap/src/coap_layers.c"
"libcoap/src/coap_mbedtls.c"
"libcoap/src/coap_mem.c"
"libcoap/src/coap_net.c"
"libcoap/src/coap_netif.c"
"libcoap/src/coap_notls.c"
"libcoap/src/coap_option.c"
"libcoap/src/coap_oscore.c"
"libcoap/src/coap_pdu.c"
"libcoap/src/coap_prng.c"
"libcoap/src/coap_resource.c"
"libcoap/src/coap_session.c"
"libcoap/src/coap_str.c"
"libcoap/src/coap_subscribe.c"
"libcoap/src/coap_tcp.c"
"libcoap/src/coap_time.c"
"libcoap/src/encode.c"
"libcoap/src/mem.c"
"libcoap/src/net.c"
"libcoap/src/pdu.c"
"libcoap/src/resource.c"
"libcoap/src/str.c"
"libcoap/src/uri.c"
"libcoap/src/coap_mbedtls.c")
"libcoap/src/coap_uri.c"
"libcoap/src/coap_ws.c")

idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS "${include_dirs}"
Expand Down
38 changes: 31 additions & 7 deletions coap/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ menu "CoAP Configuration"

endchoice #COAP_MBEDTLS_ENCRYPTION_MODE

config COAP_MBEDTLS_DEBUG
config COAP_DEBUGGING
bool "Enable CoAP debugging"
default n
help
Expand All @@ -33,9 +33,9 @@ menu "CoAP Configuration"
configuration, but logging level mbedTLS must be set for CoAP
to log it.

choice COAP_MBEDTLS_DEBUG_LEVEL
choice COAP_DEBUGGING_LEVEL
bool "Set CoAP debugging level"
depends on COAP_MBEDTLS_DEBUG
depends on COAP_DEBUGGING
default COAP_LOG_WARNING
help
Set CoAP debugging level
Expand All @@ -56,13 +56,13 @@ menu "CoAP Configuration"
bool "Info"
config COAP_LOG_DEBUG
bool "Debug"
config COAP_LOG_MBEDTLS
bool "mbedTLS"
config COAP_LOG_OSCORE
bool "OSCORE"
endchoice

config COAP_LOG_DEFAULT_LEVEL
int
default 0 if !COAP_MBEDTLS_DEBUG
default 0 if !COAP_DEBUGGING
default 0 if COAP_LOG_EMERG
default 1 if COAP_LOG_ALERT
default 2 if COAP_LOG_CRIT
Expand All @@ -71,7 +71,7 @@ menu "CoAP Configuration"
default 5 if COAP_LOG_NOTICE
default 6 if COAP_LOG_INFO
default 7 if COAP_LOG_DEBUG
default 9 if COAP_LOG_MBEDTLS
default 8 if COAP_LOG_OSCORE

config COAP_TCP_SUPPORT
bool "Enable TCP within CoAP"
Expand All @@ -82,6 +82,30 @@ menu "CoAP Configuration"

If this option is disabled, redundent CoAP TCP code is removed.

config COAP_OSCORE_SUPPORT
bool "Enable OSCORE support within CoAP"
default n
help
Enable OSCORE functionality for CoAP.

If this option is disabled, redundent CoAP OSCORE code is removed.

config COAP_OBSERVE_PERSIST
bool "Enable Server Observe Persist support within CoAP"
default n
help
Enable Server Observe Persist support for CoAP.

If this option is disabled, redundent CoAP Observe Persist code is removed.

config COAP_WEBSOCKETS
bool "Enable WebSockets support within CoAP"
default n
help
Enable WebSockets support for CoAP.

If this option is disabled, redundent CoAP WebSocket code is removed.

config COAP_CLIENT_SUPPORT
bool "Enable Client functionality within CoAP"
default n
Expand Down
2 changes: 1 addition & 1 deletion coap/examples/coap_client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ published under EPL+EDL: http://www.eclipse.org/californium/

## libcoap Documentation
This can be found at [libcoap Documentation](https://libcoap.net/documentation.html).
The current API is 4.3.0.
The current API is 4.3.2.

## libcoap Specific Issues
These can be raised at [libcoap Issues](https://github.com/obgm/libcoap/issues).
Expand Down
12 changes: 9 additions & 3 deletions coap/examples/coap_client/main/coap_client_example_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
If you'd rather not, just change the below entry to a value
that is between 0 and 7 with
the config you want - ie #define EXAMPLE_COAP_LOG_DEFAULT_LEVEL 7
Caution: Logging is enabled in libcoap only up to level as defined
by 'idf.py menuconfig' to reduce code size.
*/
#define EXAMPLE_COAP_LOG_DEFAULT_LEVEL CONFIG_COAP_LOG_DEFAULT_LEVEL

Expand Down Expand Up @@ -143,8 +146,8 @@ verify_cn_callback(const char *cn,
void *arg
)
{
coap_log(LOG_INFO, "CN '%s' presented by server (%s)\n",
cn, depth ? "CA" : "Certificate");
coap_log_info("CN '%s' presented by server (%s)\n",
cn, depth ? "CA" : "Certificate");
return 1;
}
#endif /* CONFIG_COAP_MBEDTLS_PKI */
Expand Down Expand Up @@ -371,6 +374,9 @@ static void coap_example_client(void *p)
unsigned char token[8];
size_t tokenlength;

/* Initialize libcoap library */
coap_startup();

/* Set up the CoAP logging */
coap_set_log_handler(coap_log_handler);
coap_set_log_level(EXAMPLE_COAP_LOG_DEFAULT_LEVEL);
Expand All @@ -387,7 +393,7 @@ static void coap_example_client(void *p)
coap_register_response_handler(ctx, message_handler);

if (coap_split_uri((const uint8_t *)server_uri, strlen(server_uri), &uri) == -1) {
ESP_LOGE(TAG, "CoAP server uri error");
ESP_LOGE(TAG, "CoAP server uri %s error", server_uri);
goto clean_up;
}
if (!coap_build_optlist(&uri)) {
Expand Down
2 changes: 1 addition & 1 deletion coap/examples/coap_client/main/idf_component.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ version: "1.0.0"
description: CoAP Client Example
dependencies:
espressif/coap:
version: "^4.3.0"
version: "^4.3.2"
override_path: '../../../'
2 changes: 1 addition & 1 deletion coap/examples/coap_server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ until a CoAP client does a PUT with different data.

## libcoap Documentation
This can be found at [libcoap Documentation](https://libcoap.net/documentation.html).
The current API is 4.3.0.
The current API is 4.3.2.

## libcoap Specific Issues
These can be raised at [libcoap Issues](https://github.com/obgm/libcoap/issues).
Expand Down
7 changes: 6 additions & 1 deletion coap/examples/coap_server/main/Kconfig.projbuild
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,29 @@ menu "Example CoAP Server Configuration"

config EXAMPLE_COAP_MCAST_IPV4_V6
bool "IPV4 & IPV6"
depends on LWIP_IPV4 && LWIP_IPV6
select EXAMPLE_COAP_MCAST_IPV4
select EXAMPLE_COAP_MCAST_IPV6

config EXAMPLE_COAP_MCAST_IPV4_ONLY
bool "IPV4"
depends on LWIP_IPV4
select EXAMPLE_COAP_MCAST_IPV4

config EXAMPLE_COAP_MCAST_IPV6_ONLY
bool "IPV6"
depends on LWIP_IPV6
select EXAMPLE_COAP_MCAST_IPV6

endchoice

config EXAMPLE_COAP_MCAST_IPV4
bool
depends on LWIP_IPV4

config EXAMPLE_COAP_MCAST_IPV6
bool
select EXAMPLE_CONNECT_IPV6 if IDF_TARGET_ESP32
depends on LWIP_IPV6

config EXAMPLE_COAP_MULTICAST_IPV4_ADDR
string "CoAP Multicast IPV4 Address (receive)"
Expand Down
10 changes: 8 additions & 2 deletions coap/examples/coap_server/main/coap_server_example_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
If you'd rather not, just change the below entry to a value
that is between 0 and 7 with
the config you want - ie #define EXAMPLE_COAP_LOG_DEFAULT_LEVEL 7
Caution: Logging is enabled in libcoap only up to level as defined
by 'idf.py menuconfig' to reduce code size.
*/
#define EXAMPLE_COAP_LOG_DEFAULT_LEVEL CONFIG_COAP_LOG_DEFAULT_LEVEL

Expand Down Expand Up @@ -159,8 +162,8 @@ verify_cn_callback(const char *cn,
void *arg
)
{
coap_log(LOG_INFO, "CN '%s' presented by server (%s)\n",
cn, depth ? "CA" : "Certificate");
coap_log_info("CN '%s' presented by server (%s)\n",
cn, depth ? "CA" : "Certificate");
return 1;
}
#endif /* CONFIG_COAP_MBEDTLS_PKI */
Expand All @@ -184,6 +187,9 @@ static void coap_example_server(void *p)
coap_address_t serv_addr;
coap_resource_t *resource = NULL;

/* Initialize libcoap library */
coap_startup();

snprintf(espressif_data, sizeof(espressif_data), INITIAL_DATA);
espressif_data_len = strlen(espressif_data);
coap_set_log_handler(coap_log_handler);
Expand Down
2 changes: 1 addition & 1 deletion coap/examples/coap_server/main/idf_component.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ version: "1.0.0"
description: CoAP Server Example
dependencies:
espressif/coap:
version: "^4.3.0"
version: "^4.3.2"
override_path: '../../../'
2 changes: 1 addition & 1 deletion coap/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "4.3.1~3"
version: "4.3.2~0"
description: Constrained Application Protocol (CoAP) C Library
url: https://github.com/espressif/idf-extra-components/tree/master/coap
dependencies:
Expand Down
2 changes: 1 addition & 1 deletion coap/libcoap
Submodule libcoap updated 252 files
29 changes: 21 additions & 8 deletions coap/port/include/coap3/coap.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,41 @@
extern "C" {
#endif

#ifdef LWIP_IPV4
#define COAP_IPV4_SUPPORT 1
#else /* ! _LWIP_IPV4 */
struct sockaddr_in {
u8_t sin_len;
sa_family_t sin_family;
in_port_t sin_port;
struct in_addr sin_addr;
};
#endif /* ! LWIP_IPV4 */

#include "coap3/libcoap.h"

#include "coap3/coap_forward_decls.h"
#include "coap3/block.h"
#include "coap3/coap_address.h"
#include "coap3/coap_async.h"
#include "coap3/coap_block.h"
#include "coap3/coap_cache.h"
#include "coap3/coap_debug.h"
#include "coap3/coap_dtls.h"
#include "coap3/coap_encode.h"
#include "coap3/coap_event.h"
#include "coap3/coap_io.h"
#include "coap3/coap_mem.h"
#include "coap3/coap_net.h"
#include "coap3/coap_option.h"
#include "coap3/coap_oscore.h"
#include "coap3/coap_pdu.h"
#include "coap3/coap_prng.h"
#include "coap3/coap_str.h"
#include "coap3/coap_resource.h"
#include "coap3/coap_subscribe.h"
#include "coap3/coap_time.h"
#include "coap3/encode.h"
#include "coap3/mem.h"
#include "coap3/net.h"
#include "coap3/pdu.h"
#include "coap3/resource.h"
#include "coap3/str.h"
#include "coap3/uri.h"
#include "coap3/coap_uri.h"
#include "coap3/coap_ws.h"

#ifdef __cplusplus
}
Expand Down
38 changes: 38 additions & 0 deletions coap/port/include/coap_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,48 @@
#define COAP_SERVER_SUPPORT 1
#endif /* CONFIG_COAP_SERVER_SUPPORT */

#ifdef CONFIG_LWIP_IPV4
#define COAP_IPV4_SUPPORT 1
#endif /* CONFIG_LWIP_IPV4 */

#ifdef CONFIG_LWIP_IPV6
#define COAP_IPV6_SUPPORT 1
#endif /* CONFIG_LWIP_IPV6 */

#ifdef CONFIG_COAP_TCP_SUPPORT
#define COAP_DISABLE_TCP 0
#else /* ! CONFIG_COAP_TCP_SUPPORT */
#define COAP_DISABLE_TCP 1
#endif /* ! CONFIG_COAP_TCP_SUPPORT */

#ifdef CONFIG_COAP_OSCORE_SUPPORT
#define COAP_OSCORE_SUPPORT 1
#else /* ! CONFIG_COAP_OSCORE_SUPPORT */
#define COAP_OSCORE_SUPPORT 0
#endif /* ! CONFIG_COAP_OSCORE_SUPPORT */

#ifdef CONFIG_COAP_WEBSOCKETS
#define COAP_WS_SUPPORT 1
#else /* ! CONFIG_COAP_WEBSOCKETS */
#define COAP_WS_SUPPORT 0
#endif /* ! CONFIG_COAP_WEBSOCKETS */

#ifdef CONFIG_COAP_OBSERVE_PERSIST
#define COAP_WITH_OBSERVE_PERSIST 1
#else /* ! CONFIG_COAP_OBSERVE_PERSIST */
#define COAP_WITH_OBSERVE_PERSIST 0
#endif /* ! CONFIG_COAP_OBSERVE_PERSIST */

#ifdef CONFIG_COAP_Q_BLOCK
#define COAP_Q_BLOCK_SUPPORT 1
#else /* ! CONFIG_COAP_Q_BLOCK */
#define COAP_Q_BLOCK_SUPPORT 0
#endif /* ! CONFIG_COAP_Q_BLOCK */

#ifdef CONFIG_COAP_DEBUGGING
#define COAP_MAX_LOGGING_LEVEL CONFIG_COAP_LOG_DEFAULT_LEVEL
#else /* ! CONFIG_COAP_DEBUGGING */
#define COAP_MAX_LOGGING_LEVEL 0
#endif /* ! CONFIG_COAP_DEBUGGING */

#endif /* _CONFIG_H_ */
Loading

0 comments on commit f201d9b

Please sign in to comment.