diff --git a/pkg/wakaama/Kconfig b/pkg/wakaama/Kconfig index 609f0f8e31..c6fd07d6ab 100644 --- a/pkg/wakaama/Kconfig +++ b/pkg/wakaama/Kconfig @@ -26,6 +26,14 @@ config LWM2M_DEVICE_TTL default 300 help Lifetime of the device on the LwM2M server, expressed in seconds. + +config LWM2M_COAP_DEFAULT_BLOCK_SIZE + int "CoAP block size" + range 4 10 + default 10 + help + Block transfer options support only power-of-two block sizes, from 2**4 (16) to 2**10 (1024) bytes. + This option represents the exponent of 2, which will be used for the block size. config LWM2M_LOCAL_PORT string "Port for the local LwM2M CoAP" diff --git a/pkg/wakaama/Makefile.dep b/pkg/wakaama/Makefile.dep index 4f9f449e22..ec713ee9e9 100644 --- a/pkg/wakaama/Makefile.dep +++ b/pkg/wakaama/Makefile.dep @@ -12,7 +12,6 @@ USEMODULE += wakaama_objects USEMODULE += wakaama_objects_device USEMODULE += wakaama_objects_security - ifneq (,$(filter wakaama_objects_barometer,$(USEMODULE))) USEMODULE += wakaama_objects_ipso_sensor_base endif @@ -39,6 +38,7 @@ endif USEMODULE += ztimer USEMODULE += ztimer_sec +USEMODULE += random USEPKG += tlsf # If logs for the package are active, we need fmt diff --git a/pkg/wakaama/Makefile.include b/pkg/wakaama/Makefile.include index 8180eb4fc3..69ca42848e 100644 --- a/pkg/wakaama/Makefile.include +++ b/pkg/wakaama/Makefile.include @@ -9,9 +9,6 @@ INCLUDES += -I$(PKGDIRBASE)/wakaama/coap/er-coap-13 # NOTE: Use wakaama in client mode CFLAGS += -DLWM2M_CLIENT_MODE -# NOTE: "Default CoAP block size; Used if not set on a per-target basis" -CFLAGS += -DLWM2M_COAP_DEFAULT_BLOCK_SIZE=1024 - # Translate 'CONFIG_' options to package specific flags. This checks if the # option is being set via Kconfig or CFLAGS ifneq (,$(or $(CONFIG_LWM2M_BOOTSTRAP),$(filter -DCONFIG_LWM2M_BOOTSTRAP=1,$(CFLAGS)))) @@ -22,5 +19,12 @@ ifneq (,$(or $(CONFIG_LWM2M_WITH_LOGS),$(filter -DCONFIG_LWM2M_WITH_LOGS=1,$(CFL CFLAGS += -DLWM2M_WITH_LOGS=1 endif +# NOTE: "Default CoAP block size; Used if not set on a per-target basis" +ifeq (,$(CONFIG_LWM2M_COAP_DEFAULT_BLOCK_SIZE)) + CFLAGS += -DLWM2M_COAP_DEFAULT_BLOCK_SIZE=1024 +else + CFLAGS += -DLWM2M_COAP_DEFAULT_BLOCK_SIZE='1<<$(CONFIG_LWM2M_COAP_DEFAULT_BLOCK_SIZE)' +endif + PSEUDOMODULES += wakaama PSEUDOMODULES += wakaama_client_dtls diff --git a/pkg/wakaama/contrib/lwm2m_platform.c b/pkg/wakaama/contrib/lwm2m_platform.c index 0097398be5..46b9cfc9a2 100644 --- a/pkg/wakaama/contrib/lwm2m_platform.c +++ b/pkg/wakaama/contrib/lwm2m_platform.c @@ -36,6 +36,7 @@ #include "ztimer.h" #include "tlsf.h" +#include "random.h" #include "lwm2m_platform.h" #include "lwm2m_client_config.h" @@ -106,6 +107,10 @@ time_t lwm2m_gettime(void) return (time_t)(ztimer_now(ZTIMER_SEC)); } +int lwm2m_seed(void) { + return random_uint32(); +} + /* For clang we need to specify that the first argument will be a format string * for print */