Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lwm2m_remove_object(...) return removed object #713

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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