Skip to content

Commit

Permalink
Add send callbcack to lwm2mserver example
Browse files Browse the repository at this point in the history
The send callback has been added to the server example to demonstrate
its use.
  • Loading branch information
broglep-work authored and LukasWoodtli committed Jan 28, 2025
1 parent 8493582 commit f0dde77
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions examples/server/lwm2mserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -989,20 +989,22 @@ static void prv_monitor_callback(lwm2m_context_t *lwm2mH, uint16_t clientID, lwm
fflush(stdout);
}

#ifndef LWM2M_VERSION_1_0
static void prv_reporting_send_callback(lwm2m_context_t *lwm2mH, uint16_t clientID, lwm2m_uri_t *uriP, int status,
block_info_t *block_info, lwm2m_media_type_t format, uint8_t *data,
size_t dataLength, void *userData) {
lwm2m_client_t *clientP;

/* unused parameter */
(void)userData;

fprintf(stdout, "\r\nClient #%d send.\r\n", clientID);
output_data(stdout, block_info, format, data, dataLength, 1);
clientP = (lwm2m_client_t *)LWM2M_LIST_FIND(lwm2mH->clientList, clientID);

fprintf(stdout, "\r\nSend callback called with status: %d.\r\n", status);
prv_dump_client(clientP);

fprintf(stdout, "\r\n> ");
fflush(stdout);
}
#endif

static void prv_quit(lwm2m_context_t *lwm2mH,
char * buffer,
Expand Down Expand Up @@ -1173,6 +1175,7 @@ int main(int argc, char *argv[])
fprintf(stdout, "> "); fflush(stdout);

lwm2m_set_monitoring_callback(lwm2mH, prv_monitor_callback, NULL);
lwm2m_reporting_set_send_callback(lwm2mH, prv_reporting_send_callback, NULL);

#ifndef LWM2M_VERSION_1_0
lwm2m_reporting_set_send_callback(lwm2mH, prv_reporting_send_callback, NULL);
Expand Down

0 comments on commit f0dde77

Please sign in to comment.