Skip to content

Commit 351ba30

Browse files
broglep-workLukasWoodtli
authored andcommitted
Add send callback to lwm2mserver example
The send callback has been added to the server example to demonstrate its use.
1 parent 535230c commit 351ba30

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

examples/server/lwm2mserver.c

+7-4
Original file line numberDiff line numberDiff line change
@@ -989,20 +989,22 @@ static void prv_monitor_callback(lwm2m_context_t *lwm2mH, uint16_t clientID, lwm
989989
fflush(stdout);
990990
}
991991

992-
#ifndef LWM2M_VERSION_1_0
993992
static void prv_reporting_send_callback(lwm2m_context_t *lwm2mH, uint16_t clientID, lwm2m_uri_t *uriP, int status,
994993
block_info_t *block_info, lwm2m_media_type_t format, uint8_t *data,
995994
size_t dataLength, void *userData) {
995+
lwm2m_client_t *clientP;
996+
996997
/* unused parameter */
997998
(void)userData;
998999

999-
fprintf(stdout, "\r\nClient #%d send.\r\n", clientID);
1000-
output_data(stdout, block_info, format, data, dataLength, 1);
1000+
clientP = (lwm2m_client_t *)LWM2M_LIST_FIND(lwm2mH->clientList, clientID);
1001+
1002+
fprintf(stdout, "\r\nSend callback called with status: %d.\r\n", status);
1003+
prv_dump_client(clientP);
10011004

10021005
fprintf(stdout, "\r\n> ");
10031006
fflush(stdout);
10041007
}
1005-
#endif
10061008

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

11751177
lwm2m_set_monitoring_callback(lwm2mH, prv_monitor_callback, NULL);
1178+
lwm2m_reporting_set_send_callback(lwm2mH, prv_reporting_send_callback, NULL);
11761179

11771180
#ifndef LWM2M_VERSION_1_0
11781181
lwm2m_reporting_set_send_callback(lwm2mH, prv_reporting_send_callback, NULL);

0 commit comments

Comments
 (0)