Skip to content

Commit

Permalink
lwm2m_remove_object(...) return removed object
Browse files Browse the repository at this point in the history
  • Loading branch information
parmi93 committed Jun 14, 2023
1 parent 5146594 commit 68cdae0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion core/liblwm2m.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,8 @@ int lwm2m_add_object(lwm2m_context_t * contextP,
}

int lwm2m_remove_object(lwm2m_context_t * contextP,
uint16_t id)
uint16_t id,
lwm2m_object_t **obj_removed)
{
lwm2m_object_t * targetP;

Expand All @@ -362,6 +363,10 @@ int lwm2m_remove_object(lwm2m_context_t * contextP,

if (targetP == NULL) return COAP_404_NOT_FOUND;

if(obj_removed != NULL) {
*obj_removed = targetP;
}

if (contextP->state == STATE_READY)
{
return lwm2m_update_registration(contextP, 0, true);
Expand Down
2 changes: 1 addition & 1 deletion examples/client/lwm2mclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ static void prv_remove(lwm2m_context_t * lwm2mH,
/* unused parameter */
(void)user_data;

res = lwm2m_remove_object(lwm2mH, 31024);
res = lwm2m_remove_object(lwm2mH, 31024, NULL);
if (res != 0)
{
fprintf(stdout, "Removing object 31024 failed: ");
Expand Down
2 changes: 1 addition & 1 deletion include/liblwm2m.h
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ void lwm2m_handle_packet(lwm2m_context_t *contextP, uint8_t *buffer, size_t leng
// its matching LWM2M Server Object (ID 1) instance
int lwm2m_configure(lwm2m_context_t * contextP, const char * endpointName, const char * msisdn, const char * altPath, uint16_t numObject, lwm2m_object_t * objectList[]);
int lwm2m_add_object(lwm2m_context_t * contextP, lwm2m_object_t * objectP);
int lwm2m_remove_object(lwm2m_context_t * contextP, uint16_t id);
int lwm2m_remove_object(lwm2m_context_t * contextP, uint16_t id, lwm2m_object_t **obj_removed);

// send a registration update to the server specified by the server short identifier
// or all if the ID is 0.
Expand Down

0 comments on commit 68cdae0

Please sign in to comment.