diff --git a/core/liblwm2m.c b/core/liblwm2m.c index 8a2d69ec1..4fd8cb00e 100644 --- a/core/liblwm2m.c +++ b/core/liblwm2m.c @@ -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; @@ -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); diff --git a/examples/client/lwm2mclient.c b/examples/client/lwm2mclient.c index 0dbb3847f..ba15ab975 100644 --- a/examples/client/lwm2mclient.c +++ b/examples/client/lwm2mclient.c @@ -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: "); diff --git a/include/liblwm2m.h b/include/liblwm2m.h index 50d0d0435..d7f091674 100644 --- a/include/liblwm2m.h +++ b/include/liblwm2m.h @@ -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.