1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

pkg/wakaama: adaption of contrib to new interface

This commit is contained in:
Moritz 2024-07-04 21:21:19 +02:00 committed by Moritz Holzer
parent 68db9992e0
commit 20d4658f64
8 changed files with 84 additions and 56 deletions

View File

@ -119,8 +119,6 @@ static credman_tag_t _get_credential(const sock_udp_ep_t *ep, uint8_t security_m
/* prepare query */ /* prepare query */
lwm2m_uri_t query_uri = { lwm2m_uri_t query_uri = {
.objectId = LWM2M_SECURITY_OBJECT_ID, .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; lwm2m_list_t *instance = sec->instanceList;
@ -413,7 +411,6 @@ void lwm2m_client_refresh_dtls_credentials(void)
/* prepare query */ /* prepare query */
lwm2m_uri_t query_uri = { lwm2m_uri_t query_uri = {
.objectId = LWM2M_SECURITY_OBJECT_ID, .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; lwm2m_list_t *instance = sec->instanceList;

View File

@ -284,7 +284,6 @@ static lwm2m_client_connection_t *_connection_create(uint16_t sec_obj_inst_id,
.objectId = LWM2M_SECURITY_URI_ID, .objectId = LWM2M_SECURITY_URI_ID,
.instanceId = sec_obj_inst_id, .instanceId = sec_obj_inst_id,
.resourceId = LWM2M_SECURITY_URI_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); int res = lwm2m_get_string(client_data, &resource_uri, uri, &uri_len);

View File

@ -76,7 +76,7 @@ static int _get_resource_data(lwm2m_client_data_t *client_data, const lwm2m_uri_
data->id = uri->resourceId; data->id = uri->resourceId;
/* read the resource from the specified instance */ /* 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) { if (res != COAP_205_CONTENT || data->type != expected_type) {
result = -EINVAL; result = -EINVAL;
goto out; 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 */ /* 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); lwm2m_resource_value_changed(client_data->lwm2m_ctx, uri);
if (res != COAP_204_CHANGED) { if (res != COAP_204_CHANGED) {

View File

@ -36,6 +36,7 @@ static bool reboot;
/** /**
* @brief 'Execute' callback for the Device object. * @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] instance_id Instance ID. Should be 0 as a single instance exists.
* @param[in] resource_id ID of the resource to execute. * @param[in] resource_id ID of the resource to execute.
* @param[in] buffer Information needed for the execution. * @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_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 * @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, static uint8_t _execute_cb(lwm2m_context_t * context, uint16_t instance_id, uint16_t resource_id,
lwm2m_object_t *object); uint8_t * buffer, int length, lwm2m_object_t * object);
/** /**
* @brief 'Read' callback for the Device 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] 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] num_data Number of resources requested. 0 means all.
* @param[in, out] data_array Initialized data array to output the values, * @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_404_NOT_FOUND when resource can't be found
* @return COAP_500_INTERNAL_SERVER_ERROR otherwise * @return COAP_500_INTERNAL_SERVER_ERROR otherwise
*/ */
static uint8_t _read_cb(uint16_t instance_id, int *num_data, lwm2m_data_t **data_array, static uint8_t _read_cb(lwm2m_context_t * context, uint16_t instance_id, int * num_data,
lwm2m_object_t *object); lwm2m_data_t ** data_array, lwm2m_object_t * object);
/** /**
* @brief 'Discover' callback for the Device 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] 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] num_data Number of resources requested. 0 means all.
* @param[in, out] data_array Initialized data array to determine if the resource exists, * @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_404_NOT_FOUND when a resource is not supported
* @return COAP_500_INTERNAL_SERVER_ERROR otherwise * @return COAP_500_INTERNAL_SERVER_ERROR otherwise
*/ */
static uint8_t _discover_cb(uint16_t instance_id, int *num_data, lwm2m_data_t **data_array, static uint8_t _discover_cb(lwm2m_context_t * context, uint16_t instance_id, int * num_data,
lwm2m_object_t *object); lwm2m_data_t ** data_array, lwm2m_object_t * object);
typedef struct { typedef struct {
lwm2m_list_t list; /**< Linked list handle */ lwm2m_list_t list; /**< Linked list handle */
@ -95,7 +98,7 @@ static lwm2m_object_t _device_object = {
.next = NULL, .next = NULL,
.objID = LWM2M_DEVICE_OBJECT_ID, .objID = LWM2M_DEVICE_OBJECT_ID,
.instanceList = (lwm2m_list_t *)&_instance, .instanceList = (lwm2m_list_t *)&_instance,
.readFunc = _read_cb, .readFunc = _read_cb,
.executeFunc = _execute_cb, .executeFunc = _execute_cb,
.discoverFunc = _discover_cb, .discoverFunc = _discover_cb,
.writeFunc = NULL, .writeFunc = NULL,
@ -104,12 +107,13 @@ static lwm2m_object_t _device_object = {
.userData = NULL .userData = NULL
}; };
static uint8_t _discover_cb(uint16_t instance_id, int *num_data, lwm2m_data_t **data_array, static uint8_t _discover_cb(lwm2m_context_t * context, uint16_t instance_id, int * num_data,
lwm2m_object_t *object) lwm2m_data_t ** data_array, lwm2m_object_t * object)
{ {
uint8_t result; uint8_t result;
int i; int i;
(void)context;
(void)object; (void)object;
if (instance_id != 0) { 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; return result;
} }
static uint8_t _read_cb(uint16_t instance_id, int *num_data, lwm2m_data_t **data_array, static uint8_t _read_cb(lwm2m_context_t * context, uint16_t instance_id, int * num_data,
lwm2m_object_t *object) lwm2m_data_t ** data_array, lwm2m_object_t * object)
{ {
(void)context;
(void)object; (void)object;
int i; int i;
DEBUG("[lwm2m:device:read]\n"); 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; return COAP_205_CONTENT;
} }
static uint8_t _execute_cb(uint16_t instance_id, uint16_t resource_id, uint8_t *buffer, int length, static uint8_t _execute_cb(lwm2m_context_t * context, uint16_t instance_id, uint16_t resource_id,
lwm2m_object_t *object) uint8_t * buffer, int length, lwm2m_object_t * object)
{ {
(void)context;
(void)buffer; (void)buffer;
(void)object; (void)object;

View File

@ -28,7 +28,8 @@
/** /**
* @brief 'Read' callback for the LwM2M Illuminance Sensor object implementation. * @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] instance_id ID of the instance to read resource from.
* @param[in] num_data Number of elements in @p data_array. * @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. * @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_404_NOT_FOUND if the instance was not found
* @return COAP_500_INTERNAL_SERVER_ERROR otherwise * @return COAP_500_INTERNAL_SERVER_ERROR otherwise
*/ */
static uint8_t _read_cb(uint16_t instance_id, int *num_data, lwm2m_data_t **data_array, static uint8_t _read_cb(lwm2m_context_t * context, uint16_t instance_id, int * num_data,
lwm2m_object_t *object); lwm2m_data_t ** data_array, lwm2m_object_t * object);
/** /**
* @brief 'Execute' callback for the LwM2M Illuminance Sensor object implementation. * @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] instance_id ID of the instance to execute resource from.
* @param[in] resource_id ID of the resource to execute. * @param[in] resource_id ID of the resource to execute.
* @param[in] buffer Pointer to the buffer containing the payload. * @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_404_NOT_FOUND if the instance was not found
* @return COAP_405_METHOD_NOT_ALLOWED if the resource is not executable * @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, static uint8_t _exec_cb(lwm2m_context_t * context, uint16_t instance_id, uint16_t resource_id,
lwm2m_object_t *object); uint8_t * buffer, int length, lwm2m_object_t * object);
/** /**
* @brief Gets the current value of a given @p instance. * @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; return COAP_205_CONTENT;
} }
static uint8_t _read_cb(uint16_t instance_id, int *num_data, lwm2m_data_t **data_array, static uint8_t _read_cb(lwm2m_context_t * context, uint16_t instance_id, int * num_data,
lwm2m_object_t *object) lwm2m_data_t ** data_array, lwm2m_object_t * object)
{ {
(void)context;
lwm2m_obj_ipso_sensor_base_inst_t *instance; lwm2m_obj_ipso_sensor_base_inst_t *instance;
uint8_t result; uint8_t result;
int i = 0; int i = 0;
@ -252,9 +256,10 @@ out:
return result; return result;
} }
static uint8_t _exec_cb(uint16_t instance_id, uint16_t resource_id, uint8_t *buffer, int length, static uint8_t _exec_cb(lwm2m_context_t * context, uint16_t instance_id, uint16_t resource_id,
lwm2m_object_t *object) uint8_t * buffer, int length, lwm2m_object_t * object);
{ {
(void)context;
(void)buffer; (void)buffer;
(void)length; (void)length;

View File

@ -46,7 +46,8 @@ typedef struct lwm2m_obj_light_control_inst {
/** /**
* @brief 'Read' callback for the LwM2M Light Control object implementation. * @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] instance_id ID of the instance to read resource from.
* @param[in] num_data Number of elements in @p data_array. * @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. * @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_404_NOT_FOUND if the instance was not found
* @return COAP_500_INTERNAL_SERVER_ERROR otherwise * @return COAP_500_INTERNAL_SERVER_ERROR otherwise
*/ */
static uint8_t _read_cb(uint16_t instance_id, int *num_data, lwm2m_data_t **data_array, static uint8_t _read_cb(lwm2m_context_t * context, uint16_t instance_id, int * num_data,
lwm2m_object_t *object); lwm2m_data_t ** data_array, lwm2m_object_t * object);
/** /**
* @brief 'Write' callback for the LwM2M Light Control object implementation. * @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] instance_id ID of the instance to write resource to.
* @param[in] num_data Number of elements in @p data_array. * @param[in] num_data Number of elements in @p data_array.
* @param[in] data_array IDs of resources to write and values. * @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_400_BAD_REQUEST if a value is not encoded correctly
* @return COAP_500_INTERNAL_SERVER_ERROR otherwise * @return COAP_500_INTERNAL_SERVER_ERROR otherwise
*/ */
static uint8_t _write_cb(uint16_t instance_id, int num_data, lwm2m_data_t * data_array, static uint8_t _write_cb(lwm2m_context_t * context, uint16_t instance_id, int num_data,
lwm2m_object_t * object); 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. * @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; return COAP_205_CONTENT;
} }
static uint8_t _read_cb(uint16_t instance_id, int *num_data, lwm2m_data_t **data_array, static uint8_t _read_cb(lwm2m_context_t * context, uint16_t instance_id, int * num_data,
lwm2m_object_t *object) lwm2m_data_t ** data_array, lwm2m_object_t * object)
{ {
(void)context;
lwm2m_obj_light_control_inst_t *instance; lwm2m_obj_light_control_inst_t *instance;
uint8_t result = COAP_404_NOT_FOUND; uint8_t result = COAP_404_NOT_FOUND;
int i = 0; int i = 0;
@ -214,9 +218,12 @@ free_out:
return result; return result;
} }
static uint8_t _write_cb(uint16_t instance_id, int num_data, lwm2m_data_t * data_array, static uint8_t _write_cb(lwm2m_context_t * context, uint16_t instance_id, int num_data,
lwm2m_object_t * object) 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; lwm2m_obj_light_control_inst_t *instance;
uint8_t result = COAP_204_CHANGED; uint8_t result = COAP_204_CHANGED;
bool call_cb = false; bool call_cb = false;
@ -336,7 +343,6 @@ free_out:
static void _mark_resource_changed(uint16_t instance_id, uint16_t resource_id) static void _mark_resource_changed(uint16_t instance_id, uint16_t resource_id)
{ {
lwm2m_uri_t uri; 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.objectId = LWM2M_LIGHT_CONTROL_OBJECT_ID;
uri.instanceId = instance_id; uri.instanceId = instance_id;
uri.resourceId = resource_id; uri.resourceId = resource_id;

View File

@ -119,6 +119,7 @@ typedef struct lwm2m_obj_security_inst {
/** /**
* @brief 'Read' callback for the security object. * @brief 'Read' callback for the security object.
* *
* @param[in] context LWM2M Context
* @param[in] instance_id ID of the instance to read * @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] num_data Number of resources requested. 0 means all.
* @param[in, out] data_array Initialized data array to output the values, * @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_404_NOT_FOUND when resource can't be found
* @retval COAP_500_INTERNAL_SERVER_ERROR otherwise * @retval COAP_500_INTERNAL_SERVER_ERROR otherwise
*/ */
static uint8_t _read_cb(uint16_t instance_id, int *num_data, lwm2m_data_t *data_array[], static uint8_t _read_cb(lwm2m_context_t * context, uint16_t instance_id, int * num_data,
lwm2m_object_t *object); lwm2m_data_t ** data_array, lwm2m_object_t * object);
/** /**
* @brief 'Write' callback for the security 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] instance_id ID of the instance to write to
* @param[in] num_data Number of resources to write * @param[in] num_data Number of resources to write
* @param[in] data_array Array of data 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_204_CHANGED on success
* @retval COAP_400_BAD_REQUEST otherwise * @retval COAP_400_BAD_REQUEST otherwise
*/ */
static uint8_t _write_cb(uint16_t instance_id, int num_data, lwm2m_data_t *data_array, static uint8_t _write_cb(lwm2m_context_t * context, uint16_t instance_id, int num_data,
lwm2m_object_t *object); lwm2m_data_t * data_array, lwm2m_object_t * object,
lwm2m_write_type_t write_type);
/** /**
* @brief 'Delete' callback for the security object. * @brief 'Delete' callback for the security object.
* *
* @param[in] context LWM2M Context
* @param[in] instance_id ID of the instance to delete * @param[in] instance_id ID of the instance to delete
* @param[in] object Security object pointer * @param[in] object Security object pointer
* *
* @retval COAP_202_DELETED on success * @retval COAP_202_DELETED on success
* @retval COAP_404_NOT_FOUND when the instance can't be found * @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. * @brief 'Create' callback for the security object.
* *
* @param[in] context LWM2M Context
* @param[in] instance_id ID of the instance to create * @param[in] instance_id ID of the instance to create
* @param[in] num_data Number of resources to write * @param[in] num_data Number of resources to write
* @param[in] data_array Array of data 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_201_CREATED on success
* @retval COAP_500_INTERNAL_SERVER_ERROR otherwise * @retval COAP_500_INTERNAL_SERVER_ERROR otherwise
*/ */
static uint8_t _create_cb(uint16_t instance_id, int num_data, lwm2m_data_t *data_array, static uint8_t _create_cb(lwm2m_context_t * context, uint16_t instance_id, int num_data,
lwm2m_object_t *object); lwm2m_data_t * data_array, lwm2m_object_t * object);
/** /**
* @brief Get a value from a security object instance. * @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; return COAP_205_CONTENT;
} }
static uint8_t _read_cb(uint16_t instance_id, int *num_data, lwm2m_data_t *data_array[], static uint8_t _read_cb(lwm2m_context_t * context, uint16_t instance_id, int * num_data,
lwm2m_object_t *object) lwm2m_data_t ** data_array, lwm2m_object_t * object)
{ {
(void)context;
lwm2m_obj_security_inst_t *instance; lwm2m_obj_security_inst_t *instance;
uint8_t result; uint8_t result;
int i = 0; int i = 0;
@ -458,9 +466,12 @@ out:
return result; return result;
} }
static uint8_t _write_cb(uint16_t instance_id, int num_data, lwm2m_data_t *data_array, static uint8_t _write_cb(lwm2m_context_t * context, uint16_t instance_id, int num_data,
lwm2m_object_t *object) 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; lwm2m_obj_security_inst_t *instance;
int64_t value; int64_t value;
uint8_t result = COAP_404_NOT_FOUND; uint8_t result = COAP_404_NOT_FOUND;
@ -641,8 +652,10 @@ out:
return result; 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; uint8_t result = COAP_404_NOT_FOUND;
lwm2m_obj_security_inst_t *instance; lwm2m_obj_security_inst_t *instance;
@ -679,9 +692,11 @@ free_out:
return result; return result;
} }
static uint8_t _create_cb(uint16_t instance_id, int num_data, lwm2m_data_t *data_array, static uint8_t _create_cb(lwm2m_context_t * context, uint16_t instance_id, int num_data,
lwm2m_object_t *object) lwm2m_data_t * data_array, lwm2m_object_t * object)
{ {
(void)context;
lwm2m_obj_security_inst_t *instance; lwm2m_obj_security_inst_t *instance;
uint8_t result; 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); object->instanceList = LWM2M_LIST_ADD(object->instanceList, instance);
/* write incoming data to the 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) { if (result != COAP_204_CHANGED) {
_delete_cb(instance_id, object); _delete_cb(context,instance_id, object);
} }
else { else {
result = COAP_201_CREATED; result = COAP_201_CREATED;

View File

@ -67,7 +67,7 @@
* obj_list[1] = lwm2m_client_get_server_object(&client_data, CONFIG_LWM2M_SERVER_SHORT_ID); * 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 * // 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 * // run the LwM2M client
* lwm2m_client_run(&client_data, obj_list, ARRAY_SIZE(obj_list); * lwm2m_client_run(&client_data, obj_list, ARRAY_SIZE(obj_list);