Function anjay_send

Function Documentation

anjay_send_result_t anjay_send(anjay_t *anjay, anjay_ssid_t ssid, const anjay_send_batch_t *data, anjay_send_finished_handler_t *finished_handler, void *finished_handler_data)

Sends data to the LwM2M Server without explicit request by that Server.

During the next call to anjay_sched_run data will be sent asynchronously to the Server with specified ssid but only if Mute Send resource of the server instance associated with ssid is set to false. Otherwise nothing is sent and ANJAY_SEND_ERR_MUTED is returned.

data must not be NULL but it can be everything successfully returned from anjay_send_batch_builder_compile . Even empty batch is acceptable:

anjay_send_batch_builder_t *builder = anjay_send_batch_builder_new();
anjay_send_batch_t *empty_batch = anjay_send_batch_builder_compile(&builder);
anjay_send(anjay, ssid, empty_batch, NULL, NULL);
Before sending content of data is filtered according to Access Control permissions of a particular server. The server will get only those entries of data which paths were configured by anjay_access_control_set_acl with enabled ANJAY_ACCESS_MASK_READ .

If finished_handler is not NULL it will always be called at some point - after receiving acknowledgement from the Server or if no response was received in expected time.

Success of this function means only that the data has been sent, not necessarily delivered. Data is delivered if and only if finished_handler with status ANJAY_SEND_SUCCESS is called.

Parameters:
  • anjay – Anjay object to operate on.

  • ssid – Short Server ID of target LwM2M Server. Cannot be ANJAY_SSID_ANY or ANJAY_SSID_BOOTSTRAP.

  • data – Content of the message compiled previously with anjay_send_batch_builder_compile .

  • finished_handler – Handler called if the server confirmed message delivery or if no response was received in expected time (handler can be NULL).

  • finished_handler_data – Data for the handler.

Returns:

one of the anjay_send_result_t enum values.