mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-28 23:49:47 +01:00
Merge pull request #20930 from moritzholzer/feature/wakaama_update
Feature/wakaama update on new version
This commit is contained in:
commit
5f661f424a
@ -9,7 +9,7 @@ menu "Application configuration"
|
||||
|
||||
config LWM2M_SERVER_URI
|
||||
string "LwM2M Server URI to register/bootstrap with"
|
||||
default "coap://[fd00:dead:beef::1]:5684"
|
||||
default "coaps://[fd00:dead:beef::1]:5684"
|
||||
help
|
||||
The host part of the URI MUST be a valid IPv6 address.
|
||||
|
||||
|
@ -38,10 +38,10 @@ USEPKG += tinydtls
|
||||
USEMODULE += prng_sha1prng
|
||||
|
||||
## Application-specific Configuration options
|
||||
LWM2M_SERVER_URI ?= '"coap://[fd00:dead:beef::1]:5684"'
|
||||
LWM2M_SERVER_URI ?= '"coaps://[fd00:dead:beef::1]:5684"'
|
||||
LWM2M_SERVER_SHORT_ID ?= 1
|
||||
|
||||
CFLAGS += -DEVENT_THREAD_MEDIUM_STACKSIZE='(3*1024)'
|
||||
CFLAGS += -DEVENT_THREAD_MEDIUM_STACKSIZE='(4*1024)'
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
|
||||
|
@ -2,6 +2,7 @@ BOARD_INSUFFICIENT_MEMORY := \
|
||||
airfy-beacon \
|
||||
arduino-mkr1000 \
|
||||
b-l072z-lrwan1 \
|
||||
bastwan \
|
||||
blackpill-stm32f103c8 \
|
||||
blackpill-stm32f103cb \
|
||||
bluepill-stm32f030c8 \
|
||||
@ -9,16 +10,22 @@ BOARD_INSUFFICIENT_MEMORY := \
|
||||
bluepill-stm32f103cb \
|
||||
calliope-mini \
|
||||
cc1350-launchpad \
|
||||
cc2538dk \
|
||||
cc2650-launchpad \
|
||||
cc2650stk \
|
||||
e104-bt5010a-tb \
|
||||
e104-bt5011a-tb \
|
||||
feather-m0-lora \
|
||||
feather-m0-wifi \
|
||||
firefly \
|
||||
gd32vf103c-start \
|
||||
generic-cc2538-cc2592-dk \
|
||||
hamilton \
|
||||
hifive1 \
|
||||
hifive1b \
|
||||
i-nucleo-lrwan1 \
|
||||
im880b \
|
||||
lobaro-lorabox \
|
||||
lsn50 \
|
||||
maple-mini \
|
||||
microbit \
|
||||
@ -34,16 +41,29 @@ BOARD_INSUFFICIENT_MEMORY := \
|
||||
nucleo-f302r8 \
|
||||
nucleo-f303k8 \
|
||||
nucleo-f334r8 \
|
||||
nucleo-f410rb \
|
||||
nucleo-g070rb \
|
||||
nucleo-g071rb \
|
||||
nucleo-g431rb \
|
||||
nucleo-l011k4 \
|
||||
nucleo-l031k6 \
|
||||
nucleo-l053r8 \
|
||||
nucleo-l073rz \
|
||||
nucleo-l412kb \
|
||||
olimexino-stm32 \
|
||||
omote \
|
||||
opencm904 \
|
||||
openmote-b \
|
||||
openmote-cc2538 \
|
||||
pba-d-01-kw2x \
|
||||
remote-pa \
|
||||
remote-reva \
|
||||
remote-revb \
|
||||
samd10-xmini \
|
||||
saml10-xpro \
|
||||
saml11-xpro \
|
||||
samr21-xpro \
|
||||
samr30-xpro \
|
||||
seeedstudio-gd32 \
|
||||
sipeed-longan-nano \
|
||||
sipeed-longan-nano-tft \
|
||||
|
@ -27,6 +27,14 @@ config LWM2M_DEVICE_TTL
|
||||
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"
|
||||
default "5683"
|
||||
|
@ -1,6 +1,6 @@
|
||||
PKG_NAME=wakaama
|
||||
PKG_URL=https://github.com/eclipse/wakaama.git
|
||||
PKG_VERSION=da74b3c91570b9716fbb424e90935806b2b29814
|
||||
PKG_VERSION=ee0c98da7495e1ab43358b49e970dbc97f73ce3b
|
||||
PKG_LICENSE=EDL-1.0,EPL-1.0
|
||||
|
||||
include $(RIOTBASE)/pkg/pkg.mk
|
||||
@ -12,8 +12,11 @@ CFLAGS += -Wno-cast-align
|
||||
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42145
|
||||
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90710#c1
|
||||
CFLAGS += -Wno-maybe-uninitialized
|
||||
CFLAGS += -DLWM2M_SUPPORT_TLV
|
||||
|
||||
all:
|
||||
$(QQ)"$(MAKE)" -C $(PKG_SOURCE_DIR)/core -f $(RIOTBASE)/Makefile.base MODULE=wakaama_core
|
||||
$(QQ)"$(MAKE)" -C $(PKG_SOURCE_DIR)/core/er-coap-13 -f $(RIOTBASE)/Makefile.base MODULE=wakaama_core_coap13
|
||||
$(QQ)"$(MAKE)" -C $(PKG_SOURCE_DIR)/coap/er-coap-13 -f $(RIOTBASE)/Makefile.base MODULE=wakaama_core_coap13
|
||||
$(QQ)"$(MAKE)" -C $(PKG_SOURCE_DIR)/coap -f $(RIOTBASE)/Makefile.base MODULE=wakaama_core_coap
|
||||
$(QQ)"$(MAKE)" -C $(PKG_SOURCE_DIR)/data -f $(CURDIR)/wakaama_data.mk
|
||||
$(QQ)"$(MAKE)" -C $(PKG_SOURCE_DIR)/examples/client -f $(CURDIR)/wakaama_client.mk
|
||||
|
@ -1,4 +1,4 @@
|
||||
USEMODULE += wakaama_core wakaama_core_coap13 wakaama_client
|
||||
USEMODULE += wakaama_core wakaama_core_coap wakaama_core_coap13 wakaama_data wakaama_client
|
||||
|
||||
# include contrib code (platform adaption and client implementation)
|
||||
USEMODULE += wakaama_contrib
|
||||
@ -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
|
||||
|
@ -1,8 +1,10 @@
|
||||
DIRS += $(RIOTBASE)/pkg/wakaama/contrib
|
||||
|
||||
INCLUDES += -I$(RIOTBASE)/pkg/wakaama/include
|
||||
INCLUDES += -I$(PKGDIRBASE)/wakaama/include
|
||||
INCLUDES += -I$(PKGDIRBASE)/wakaama/core
|
||||
INCLUDES += -I$(PKGDIRBASE)/wakaama/core/er-coap-13
|
||||
INCLUDES += -I$(PKGDIRBASE)/wakaama/data
|
||||
INCLUDES += -I$(PKGDIRBASE)/wakaama/coap/er-coap-13
|
||||
|
||||
# NOTE: Use wakaama in client mode
|
||||
CFLAGS += -DLWM2M_CLIENT_MODE
|
||||
@ -17,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
|
||||
|
@ -119,8 +119,6 @@ static credman_tag_t _get_credential(const sock_udp_ep_t *ep, uint8_t security_m
|
||||
/* prepare query */
|
||||
lwm2m_uri_t query_uri = {
|
||||
.objectId = LWM2M_SECURITY_OBJECT_ID,
|
||||
// .resourceId = LWM2M_SECURITY_URI_ID,
|
||||
.flag = LWM2M_URI_FLAG_OBJECT_ID | LWM2M_URI_FLAG_INSTANCE_ID | LWM2M_URI_FLAG_RESOURCE_ID
|
||||
};
|
||||
|
||||
lwm2m_list_t *instance = sec->instanceList;
|
||||
@ -413,7 +411,6 @@ void lwm2m_client_refresh_dtls_credentials(void)
|
||||
/* prepare query */
|
||||
lwm2m_uri_t query_uri = {
|
||||
.objectId = LWM2M_SECURITY_OBJECT_ID,
|
||||
.flag = LWM2M_URI_FLAG_OBJECT_ID | LWM2M_URI_FLAG_INSTANCE_ID | LWM2M_URI_FLAG_RESOURCE_ID
|
||||
};
|
||||
|
||||
lwm2m_list_t *instance = sec->instanceList;
|
||||
|
@ -284,7 +284,6 @@ static lwm2m_client_connection_t *_connection_create(uint16_t sec_obj_inst_id,
|
||||
.objectId = LWM2M_SECURITY_URI_ID,
|
||||
.instanceId = sec_obj_inst_id,
|
||||
.resourceId = LWM2M_SECURITY_URI_ID,
|
||||
.flag = LWM2M_URI_FLAG_OBJECT_ID | LWM2M_URI_FLAG_INSTANCE_ID | LWM2M_URI_FLAG_RESOURCE_ID
|
||||
};
|
||||
|
||||
int res = lwm2m_get_string(client_data, &resource_uri, uri, &uri_len);
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -76,7 +76,7 @@ static int _get_resource_data(lwm2m_client_data_t *client_data, const lwm2m_uri_
|
||||
data->id = uri->resourceId;
|
||||
|
||||
/* read the resource from the specified instance */
|
||||
uint8_t res = object->readFunc(uri->instanceId, &data_num, &data, object);
|
||||
uint8_t res = object->readFunc(client_data->lwm2m_ctx, uri->instanceId, &data_num, &data, object);
|
||||
if (res != COAP_205_CONTENT || data->type != expected_type) {
|
||||
result = -EINVAL;
|
||||
goto out;
|
||||
@ -245,7 +245,7 @@ static int _set_resource_data(lwm2m_client_data_t *client_data, const lwm2m_uri_
|
||||
}
|
||||
|
||||
/* write the resource of the specified instance */
|
||||
uint8_t res = object->writeFunc(uri->instanceId, 1, data, object);
|
||||
uint8_t res = object->writeFunc(client_data->lwm2m_ctx, uri->instanceId, 1, data, object, LWM2M_WRITE_PARTIAL_UPDATE);
|
||||
lwm2m_resource_value_changed(client_data->lwm2m_ctx, uri);
|
||||
|
||||
if (res != COAP_204_CHANGED) {
|
||||
|
@ -36,6 +36,7 @@ static bool reboot;
|
||||
/**
|
||||
* @brief 'Execute' callback for the Device object.
|
||||
*
|
||||
* @param[in] context LWM2M Context
|
||||
* @param[in] instance_id Instance ID. Should be 0 as a single instance exists.
|
||||
* @param[in] resource_id ID of the resource to execute.
|
||||
* @param[in] buffer Information needed for the execution.
|
||||
@ -47,12 +48,13 @@ static bool reboot;
|
||||
* @return COAP_400_BAD_REQUEST when wrong information has been sent
|
||||
* @return COAP_405_METHOD_NOT_ALLOWED when trying to execute a resource that is not supported
|
||||
*/
|
||||
static uint8_t _execute_cb(uint16_t instance_id, uint16_t resource_id, uint8_t *buffer, int length,
|
||||
lwm2m_object_t *object);
|
||||
static uint8_t _execute_cb(lwm2m_context_t * context, uint16_t instance_id, uint16_t resource_id,
|
||||
uint8_t * buffer, int length, lwm2m_object_t * object);
|
||||
|
||||
/**
|
||||
* @brief 'Read' callback for the Device object.
|
||||
*
|
||||
* @param[in] context LWM2M Context
|
||||
* @param[in] instance_id Instance ID. Should be 0 as a single instance exists.
|
||||
* @param[in, out] num_data Number of resources requested. 0 means all.
|
||||
* @param[in, out] data_array Initialized data array to output the values,
|
||||
@ -63,12 +65,13 @@ static uint8_t _execute_cb(uint16_t instance_id, uint16_t resource_id, uint8_t *
|
||||
* @return COAP_404_NOT_FOUND when resource can't be found
|
||||
* @return COAP_500_INTERNAL_SERVER_ERROR otherwise
|
||||
*/
|
||||
static uint8_t _read_cb(uint16_t instance_id, int *num_data, lwm2m_data_t **data_array,
|
||||
lwm2m_object_t *object);
|
||||
static uint8_t _read_cb(lwm2m_context_t * context, uint16_t instance_id, int * num_data,
|
||||
lwm2m_data_t ** data_array, lwm2m_object_t * object);
|
||||
|
||||
/**
|
||||
* @brief 'Discover' callback for the Device object.
|
||||
*
|
||||
* @param[in] context LWM2M Context
|
||||
* @param[in] instance_id Instance ID. Should be 0 as a single instance exists.
|
||||
* @param[in, out] num_data Number of resources requested. 0 means all.
|
||||
* @param[in, out] data_array Initialized data array to determine if the resource exists,
|
||||
@ -79,8 +82,8 @@ static uint8_t _read_cb(uint16_t instance_id, int *num_data, lwm2m_data_t **data
|
||||
* @return COAP_404_NOT_FOUND when a resource is not supported
|
||||
* @return COAP_500_INTERNAL_SERVER_ERROR otherwise
|
||||
*/
|
||||
static uint8_t _discover_cb(uint16_t instance_id, int *num_data, lwm2m_data_t **data_array,
|
||||
lwm2m_object_t *object);
|
||||
static uint8_t _discover_cb(lwm2m_context_t * context, uint16_t instance_id, int * num_data,
|
||||
lwm2m_data_t ** data_array, lwm2m_object_t * object);
|
||||
|
||||
typedef struct {
|
||||
lwm2m_list_t list; /**< Linked list handle */
|
||||
@ -95,7 +98,7 @@ static lwm2m_object_t _device_object = {
|
||||
.next = NULL,
|
||||
.objID = LWM2M_DEVICE_OBJECT_ID,
|
||||
.instanceList = (lwm2m_list_t *)&_instance,
|
||||
.readFunc = _read_cb,
|
||||
.readFunc = _read_cb,
|
||||
.executeFunc = _execute_cb,
|
||||
.discoverFunc = _discover_cb,
|
||||
.writeFunc = NULL,
|
||||
@ -104,12 +107,13 @@ static lwm2m_object_t _device_object = {
|
||||
.userData = NULL
|
||||
};
|
||||
|
||||
static uint8_t _discover_cb(uint16_t instance_id, int *num_data, lwm2m_data_t **data_array,
|
||||
lwm2m_object_t *object)
|
||||
static uint8_t _discover_cb(lwm2m_context_t * context, uint16_t instance_id, int * num_data,
|
||||
lwm2m_data_t ** data_array, lwm2m_object_t * object)
|
||||
{
|
||||
uint8_t result;
|
||||
int i;
|
||||
|
||||
(void)context;
|
||||
(void)object;
|
||||
|
||||
if (instance_id != 0) {
|
||||
@ -166,9 +170,10 @@ static uint8_t _discover_cb(uint16_t instance_id, int *num_data, lwm2m_data_t **
|
||||
return result;
|
||||
}
|
||||
|
||||
static uint8_t _read_cb(uint16_t instance_id, int *num_data, lwm2m_data_t **data_array,
|
||||
lwm2m_object_t *object)
|
||||
static uint8_t _read_cb(lwm2m_context_t * context, uint16_t instance_id, int * num_data,
|
||||
lwm2m_data_t ** data_array, lwm2m_object_t * object)
|
||||
{
|
||||
(void)context;
|
||||
(void)object;
|
||||
int i;
|
||||
DEBUG("[lwm2m:device:read]\n");
|
||||
@ -264,9 +269,10 @@ static uint8_t _read_cb(uint16_t instance_id, int *num_data, lwm2m_data_t **data
|
||||
return COAP_205_CONTENT;
|
||||
}
|
||||
|
||||
static uint8_t _execute_cb(uint16_t instance_id, uint16_t resource_id, uint8_t *buffer, int length,
|
||||
lwm2m_object_t *object)
|
||||
static uint8_t _execute_cb(lwm2m_context_t * context, uint16_t instance_id, uint16_t resource_id,
|
||||
uint8_t * buffer, int length, lwm2m_object_t * object)
|
||||
{
|
||||
(void)context;
|
||||
(void)buffer;
|
||||
(void)object;
|
||||
|
||||
|
@ -29,6 +29,7 @@
|
||||
/**
|
||||
* @brief 'Read' callback for the LwM2M Illuminance Sensor object implementation.
|
||||
*
|
||||
* @param[in] context LWM2M Context
|
||||
* @param[in] instance_id ID of the instance to read resource from.
|
||||
* @param[in] num_data Number of elements in @p data_array.
|
||||
* @param[in, out] data_array IDs of resources to read. Array of data structures to place values.
|
||||
@ -38,12 +39,13 @@
|
||||
* @return COAP_404_NOT_FOUND if the instance was not found
|
||||
* @return COAP_500_INTERNAL_SERVER_ERROR otherwise
|
||||
*/
|
||||
static uint8_t _read_cb(uint16_t instance_id, int *num_data, lwm2m_data_t **data_array,
|
||||
lwm2m_object_t *object);
|
||||
static uint8_t _read_cb(lwm2m_context_t * context, uint16_t instance_id, int * num_data,
|
||||
lwm2m_data_t ** data_array, lwm2m_object_t * object);
|
||||
|
||||
/**
|
||||
* @brief 'Execute' callback for the LwM2M Illuminance Sensor object implementation.
|
||||
*
|
||||
* @param[in] context LWM2M Context
|
||||
* @param[in] instance_id ID of the instance to execute resource from.
|
||||
* @param[in] resource_id ID of the resource to execute.
|
||||
* @param[in] buffer Pointer to the buffer containing the payload.
|
||||
@ -54,8 +56,8 @@ static uint8_t _read_cb(uint16_t instance_id, int *num_data, lwm2m_data_t **data
|
||||
* @return COAP_404_NOT_FOUND if the instance was not found
|
||||
* @return COAP_405_METHOD_NOT_ALLOWED if the resource is not executable
|
||||
*/
|
||||
static uint8_t _exec_cb(uint16_t instance_id, uint16_t resource_id, uint8_t *buffer, int length,
|
||||
lwm2m_object_t *object);
|
||||
static uint8_t _exec_cb(lwm2m_context_t * context, uint16_t instance_id, uint16_t resource_id,
|
||||
uint8_t * buffer, int length, lwm2m_object_t * object);
|
||||
|
||||
/**
|
||||
* @brief Gets the current value of a given @p instance.
|
||||
@ -193,9 +195,11 @@ static uint8_t _get_value(lwm2m_data_t *data, lwm2m_obj_ipso_sensor_base_inst_t
|
||||
return COAP_205_CONTENT;
|
||||
}
|
||||
|
||||
static uint8_t _read_cb(uint16_t instance_id, int *num_data, lwm2m_data_t **data_array,
|
||||
lwm2m_object_t *object)
|
||||
static uint8_t _read_cb(lwm2m_context_t * context, uint16_t instance_id, int * num_data,
|
||||
lwm2m_data_t ** data_array, lwm2m_object_t * object)
|
||||
{
|
||||
(void)context;
|
||||
|
||||
lwm2m_obj_ipso_sensor_base_inst_t *instance;
|
||||
uint8_t result;
|
||||
int i = 0;
|
||||
@ -252,9 +256,10 @@ out:
|
||||
return result;
|
||||
}
|
||||
|
||||
static uint8_t _exec_cb(uint16_t instance_id, uint16_t resource_id, uint8_t *buffer, int length,
|
||||
lwm2m_object_t *object)
|
||||
static uint8_t _exec_cb(lwm2m_context_t * context, uint16_t instance_id, uint16_t resource_id,
|
||||
uint8_t * buffer, int length, lwm2m_object_t * object);
|
||||
{
|
||||
(void)context;
|
||||
(void)buffer;
|
||||
(void)length;
|
||||
|
||||
|
@ -47,6 +47,7 @@ typedef struct lwm2m_obj_light_control_inst {
|
||||
/**
|
||||
* @brief 'Read' callback for the LwM2M Light Control object implementation.
|
||||
*
|
||||
* @param[in] context LWM2M Context
|
||||
* @param[in] instance_id ID of the instance to read resource from.
|
||||
* @param[in] num_data Number of elements in @p data_array.
|
||||
* @param[in, out] data_array IDs of resources to read. Array of data structures to place values.
|
||||
@ -56,12 +57,13 @@ typedef struct lwm2m_obj_light_control_inst {
|
||||
* @return COAP_404_NOT_FOUND if the instance was not found
|
||||
* @return COAP_500_INTERNAL_SERVER_ERROR otherwise
|
||||
*/
|
||||
static uint8_t _read_cb(uint16_t instance_id, int *num_data, lwm2m_data_t **data_array,
|
||||
lwm2m_object_t *object);
|
||||
static uint8_t _read_cb(lwm2m_context_t * context, uint16_t instance_id, int * num_data,
|
||||
lwm2m_data_t ** data_array, lwm2m_object_t * object);
|
||||
|
||||
/**
|
||||
* @brief 'Write' callback for the LwM2M Light Control object implementation.
|
||||
*
|
||||
* @param[in] context LWM2M Context
|
||||
* @param[in] instance_id ID of the instance to write resource to.
|
||||
* @param[in] num_data Number of elements in @p data_array.
|
||||
* @param[in] data_array IDs of resources to write and values.
|
||||
@ -72,8 +74,8 @@ static uint8_t _read_cb(uint16_t instance_id, int *num_data, lwm2m_data_t **data
|
||||
* @return COAP_400_BAD_REQUEST if a value is not encoded correctly
|
||||
* @return COAP_500_INTERNAL_SERVER_ERROR otherwise
|
||||
*/
|
||||
static uint8_t _write_cb(uint16_t instance_id, int num_data, lwm2m_data_t * data_array,
|
||||
lwm2m_object_t * object);
|
||||
static uint8_t _write_cb(lwm2m_context_t * context, uint16_t instance_id, int num_data,
|
||||
lwm2m_data_t * data_array, lwm2m_object_t * object, lwm2m_write_type_t write_type);
|
||||
|
||||
/**
|
||||
* @brief Gets the current value of a given @p instance.
|
||||
@ -154,9 +156,11 @@ static uint8_t _get_value(lwm2m_data_t *data, lwm2m_obj_light_control_inst_t *in
|
||||
return COAP_205_CONTENT;
|
||||
}
|
||||
|
||||
static uint8_t _read_cb(uint16_t instance_id, int *num_data, lwm2m_data_t **data_array,
|
||||
lwm2m_object_t *object)
|
||||
static uint8_t _read_cb(lwm2m_context_t * context, uint16_t instance_id, int * num_data,
|
||||
lwm2m_data_t ** data_array, lwm2m_object_t * object)
|
||||
{
|
||||
(void)context;
|
||||
|
||||
lwm2m_obj_light_control_inst_t *instance;
|
||||
uint8_t result = COAP_404_NOT_FOUND;
|
||||
int i = 0;
|
||||
@ -214,9 +218,12 @@ free_out:
|
||||
return result;
|
||||
}
|
||||
|
||||
static uint8_t _write_cb(uint16_t instance_id, int num_data, lwm2m_data_t * data_array,
|
||||
lwm2m_object_t * object)
|
||||
static uint8_t _write_cb(lwm2m_context_t * context, uint16_t instance_id, int num_data,
|
||||
lwm2m_data_t * data_array, lwm2m_object_t * object, lwm2m_write_type_t write_type)
|
||||
{
|
||||
(void)context;
|
||||
(void)write_type;
|
||||
|
||||
lwm2m_obj_light_control_inst_t *instance;
|
||||
uint8_t result = COAP_204_CHANGED;
|
||||
bool call_cb = false;
|
||||
@ -336,7 +343,6 @@ free_out:
|
||||
static void _mark_resource_changed(uint16_t instance_id, uint16_t resource_id)
|
||||
{
|
||||
lwm2m_uri_t uri;
|
||||
uri.flag = LWM2M_URI_FLAG_OBJECT_ID | LWM2M_URI_FLAG_INSTANCE_ID | LWM2M_URI_FLAG_RESOURCE_ID;
|
||||
uri.objectId = LWM2M_LIGHT_CONTROL_OBJECT_ID;
|
||||
uri.instanceId = instance_id;
|
||||
uri.resourceId = resource_id;
|
||||
|
@ -119,6 +119,7 @@ typedef struct lwm2m_obj_security_inst {
|
||||
/**
|
||||
* @brief 'Read' callback for the security object.
|
||||
*
|
||||
* @param[in] context LWM2M Context
|
||||
* @param[in] instance_id ID of the instance to read
|
||||
* @param[in, out] num_data Number of resources requested. 0 means all.
|
||||
* @param[in, out] data_array Initialized data array to output the values,
|
||||
@ -129,12 +130,13 @@ typedef struct lwm2m_obj_security_inst {
|
||||
* @retval COAP_404_NOT_FOUND when resource can't be found
|
||||
* @retval COAP_500_INTERNAL_SERVER_ERROR otherwise
|
||||
*/
|
||||
static uint8_t _read_cb(uint16_t instance_id, int *num_data, lwm2m_data_t *data_array[],
|
||||
lwm2m_object_t *object);
|
||||
static uint8_t _read_cb(lwm2m_context_t * context, uint16_t instance_id, int * num_data,
|
||||
lwm2m_data_t ** data_array, lwm2m_object_t * object);
|
||||
|
||||
/**
|
||||
* @brief 'Write' callback for the security object.
|
||||
*
|
||||
|
||||
* @param[in] context LWM2M Context
|
||||
* @param[in] instance_id ID of the instance to write to
|
||||
* @param[in] num_data Number of resources to write
|
||||
* @param[in] data_array Array of data to write
|
||||
@ -143,23 +145,27 @@ static uint8_t _read_cb(uint16_t instance_id, int *num_data, lwm2m_data_t *data_
|
||||
* @retval COAP_204_CHANGED on success
|
||||
* @retval COAP_400_BAD_REQUEST otherwise
|
||||
*/
|
||||
static uint8_t _write_cb(uint16_t instance_id, int num_data, lwm2m_data_t *data_array,
|
||||
lwm2m_object_t *object);
|
||||
static uint8_t _write_cb(lwm2m_context_t * context, uint16_t instance_id, int num_data,
|
||||
lwm2m_data_t * data_array, lwm2m_object_t * object,
|
||||
lwm2m_write_type_t write_type);
|
||||
|
||||
/**
|
||||
* @brief 'Delete' callback for the security object.
|
||||
*
|
||||
* @param[in] context LWM2M Context
|
||||
* @param[in] instance_id ID of the instance to delete
|
||||
* @param[in] object Security object pointer
|
||||
*
|
||||
* @retval COAP_202_DELETED on success
|
||||
* @retval COAP_404_NOT_FOUND when the instance can't be found
|
||||
*/
|
||||
static uint8_t _delete_cb(uint16_t instance_id, lwm2m_object_t *object);
|
||||
static uint8_t _delete_cb(lwm2m_context_t * context, uint16_t instance_id,
|
||||
lwm2m_object_t * object);
|
||||
|
||||
/**
|
||||
* @brief 'Create' callback for the security object.
|
||||
*
|
||||
* @param[in] context LWM2M Context
|
||||
* @param[in] instance_id ID of the instance to create
|
||||
* @param[in] num_data Number of resources to write
|
||||
* @param[in] data_array Array of data to write
|
||||
@ -168,8 +174,8 @@ static uint8_t _delete_cb(uint16_t instance_id, lwm2m_object_t *object);
|
||||
* @retval COAP_201_CREATED on success
|
||||
* @retval COAP_500_INTERNAL_SERVER_ERROR otherwise
|
||||
*/
|
||||
static uint8_t _create_cb(uint16_t instance_id, int num_data, lwm2m_data_t *data_array,
|
||||
lwm2m_object_t *object);
|
||||
static uint8_t _create_cb(lwm2m_context_t * context, uint16_t instance_id, int num_data,
|
||||
lwm2m_data_t * data_array, lwm2m_object_t * object);
|
||||
|
||||
/**
|
||||
* @brief Get a value from a security object instance.
|
||||
@ -392,9 +398,11 @@ static int _get_value(lwm2m_data_t *data, lwm2m_obj_security_inst_t *instance)
|
||||
return COAP_205_CONTENT;
|
||||
}
|
||||
|
||||
static uint8_t _read_cb(uint16_t instance_id, int *num_data, lwm2m_data_t *data_array[],
|
||||
lwm2m_object_t *object)
|
||||
static uint8_t _read_cb(lwm2m_context_t * context, uint16_t instance_id, int * num_data,
|
||||
lwm2m_data_t ** data_array, lwm2m_object_t * object)
|
||||
{
|
||||
(void)context;
|
||||
|
||||
lwm2m_obj_security_inst_t *instance;
|
||||
uint8_t result;
|
||||
int i = 0;
|
||||
@ -458,9 +466,12 @@ out:
|
||||
return result;
|
||||
}
|
||||
|
||||
static uint8_t _write_cb(uint16_t instance_id, int num_data, lwm2m_data_t *data_array,
|
||||
lwm2m_object_t *object)
|
||||
static uint8_t _write_cb(lwm2m_context_t * context, uint16_t instance_id, int num_data,
|
||||
lwm2m_data_t * data_array, lwm2m_object_t * object,
|
||||
lwm2m_write_type_t write_type)
|
||||
{
|
||||
(void)context;
|
||||
(void)write_type;
|
||||
lwm2m_obj_security_inst_t *instance;
|
||||
int64_t value;
|
||||
uint8_t result = COAP_404_NOT_FOUND;
|
||||
@ -641,8 +652,10 @@ out:
|
||||
return result;
|
||||
}
|
||||
|
||||
static uint8_t _delete_cb(uint16_t instance_id, lwm2m_object_t *object)
|
||||
static uint8_t _delete_cb(lwm2m_context_t * context, uint16_t instance_id,
|
||||
lwm2m_object_t * object)
|
||||
{
|
||||
(void)context;
|
||||
uint8_t result = COAP_404_NOT_FOUND;
|
||||
lwm2m_obj_security_inst_t *instance;
|
||||
|
||||
@ -679,9 +692,11 @@ free_out:
|
||||
return result;
|
||||
}
|
||||
|
||||
static uint8_t _create_cb(uint16_t instance_id, int num_data, lwm2m_data_t *data_array,
|
||||
lwm2m_object_t *object)
|
||||
static uint8_t _create_cb(lwm2m_context_t * context, uint16_t instance_id, int num_data,
|
||||
lwm2m_data_t * data_array, lwm2m_object_t * object)
|
||||
{
|
||||
(void)context;
|
||||
|
||||
lwm2m_obj_security_inst_t *instance;
|
||||
uint8_t result;
|
||||
|
||||
@ -718,10 +733,10 @@ static uint8_t _create_cb(uint16_t instance_id, int num_data, lwm2m_data_t *data
|
||||
object->instanceList = LWM2M_LIST_ADD(object->instanceList, instance);
|
||||
|
||||
/* write incoming data to the instance */
|
||||
result = _write_cb(instance_id, num_data, data_array, object);
|
||||
result = _write_cb(context, instance_id, num_data, data_array, object, LWM2M_WRITE_PARTIAL_UPDATE);
|
||||
|
||||
if (result != COAP_204_CHANGED) {
|
||||
_delete_cb(instance_id, object);
|
||||
_delete_cb(context,instance_id, object);
|
||||
}
|
||||
else {
|
||||
result = COAP_201_CREATED;
|
||||
|
@ -67,7 +67,7 @@
|
||||
* obj_list[1] = lwm2m_client_get_server_object(&client_data, CONFIG_LWM2M_SERVER_SHORT_ID);
|
||||
*
|
||||
* // device object has a single instance. All the information for now is defined at compile-time
|
||||
* obj_list[2] = lwm2m_object_device_get();
|
||||
* obj_list[2] = lwm2m_object_device_init(&client_data);
|
||||
*
|
||||
* // run the LwM2M client
|
||||
* lwm2m_client_run(&client_data, obj_list, ARRAY_SIZE(obj_list);
|
||||
|
Binary file not shown.
BIN
pkg/wakaama/patches/0001-fixed-coap-inlcudes.patch
Normal file
BIN
pkg/wakaama/patches/0001-fixed-coap-inlcudes.patch
Normal file
Binary file not shown.
Binary file not shown.
BIN
pkg/wakaama/patches/0002-fixes-unused-variables.patch
Normal file
BIN
pkg/wakaama/patches/0002-fixes-unused-variables.patch
Normal file
Binary file not shown.
BIN
pkg/wakaama/patches/0003-fixed-const-parameter.patch
Normal file
BIN
pkg/wakaama/patches/0003-fixed-const-parameter.patch
Normal file
Binary file not shown.
Binary file not shown.
BIN
pkg/wakaama/patches/0004-define-endianness.patch
Normal file
BIN
pkg/wakaama/patches/0004-define-endianness.patch
Normal file
Binary file not shown.
Binary file not shown.
BIN
pkg/wakaama/patches/0005-fixed-format-specifier.patch
Normal file
BIN
pkg/wakaama/patches/0005-fixed-format-specifier.patch
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
8
pkg/wakaama/wakaama_data.mk
Normal file
8
pkg/wakaama/wakaama_data.mk
Normal file
@ -0,0 +1,8 @@
|
||||
MODULE = wakaama_data
|
||||
|
||||
SRC = \
|
||||
data.c \
|
||||
tlv.c \
|
||||
#
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
Loading…
Reference in New Issue
Block a user