anjay
lwm2m_send.h File Reference
#include <anjay/anjay.h>

Go to the source code of this file.

Data Structures

struct  anjay_send_resource_path_t
 

Macros

#define ANJAY_SEND_DEFERRED_ERROR   (-3)
 
#define ANJAY_SEND_ABORT   (-2)
 
#define ANJAY_SEND_TIMEOUT   (-1)
 
#define ANJAY_SEND_SUCCESS   0
 

Typedefs

typedef struct anjay_send_batch_builder_struct anjay_send_batch_builder_t
 
typedef struct anjay_send_batch_struct anjay_send_batch_t
 
typedef void anjay_send_finished_handler_t(anjay_t *anjay, anjay_ssid_t ssid, const anjay_send_batch_t *batch, int result, void *data)
 

Enumerations

enum  anjay_send_result_t {
  ANJAY_SEND_OK = 0 , ANJAY_SEND_ERR_UNSUPPORTED , ANJAY_SEND_ERR_MUTED , ANJAY_SEND_ERR_OFFLINE ,
  ANJAY_SEND_ERR_BOOTSTRAP , ANJAY_SEND_ERR_SSID , ANJAY_SEND_ERR_PROTOCOL , ANJAY_SEND_ERR_INTERNAL
}
 

Functions

anjay_send_batch_builder_tanjay_send_batch_builder_new (void)
 
void anjay_send_batch_builder_cleanup (anjay_send_batch_builder_t **builder)
 
int anjay_send_batch_add_int (anjay_send_batch_builder_t *builder, anjay_oid_t oid, anjay_iid_t iid, anjay_rid_t rid, anjay_riid_t riid, avs_time_real_t timestamp, int64_t value)
 
int anjay_send_batch_add_uint (anjay_send_batch_builder_t *builder, anjay_oid_t oid, anjay_iid_t iid, anjay_rid_t rid, anjay_riid_t riid, avs_time_real_t timestamp, uint64_t value)
 
int anjay_send_batch_add_double (anjay_send_batch_builder_t *builder, anjay_oid_t oid, anjay_iid_t iid, anjay_rid_t rid, anjay_riid_t riid, avs_time_real_t timestamp, double value)
 
int anjay_send_batch_add_bool (anjay_send_batch_builder_t *builder, anjay_oid_t oid, anjay_iid_t iid, anjay_rid_t rid, anjay_riid_t riid, avs_time_real_t timestamp, bool value)
 
int anjay_send_batch_add_string (anjay_send_batch_builder_t *builder, anjay_oid_t oid, anjay_iid_t iid, anjay_rid_t rid, anjay_riid_t riid, avs_time_real_t timestamp, const char *str)
 
int anjay_send_batch_add_bytes (anjay_send_batch_builder_t *builder, anjay_oid_t oid, anjay_iid_t iid, anjay_rid_t rid, anjay_riid_t riid, avs_time_real_t timestamp, const void *data, size_t length)
 
int anjay_send_batch_add_objlnk (anjay_send_batch_builder_t *builder, anjay_oid_t oid, anjay_iid_t iid, anjay_rid_t rid, anjay_riid_t riid, avs_time_real_t timestamp, anjay_oid_t objlnk_oid, anjay_iid_t objlnk_iid)
 
int anjay_send_batch_data_add_current (anjay_send_batch_builder_t *builder, anjay_t *anjay, anjay_oid_t oid, anjay_iid_t iid, anjay_rid_t rid)
 
int anjay_send_batch_data_add_current_multiple (anjay_send_batch_builder_t *builder, anjay_t *anjay, const anjay_send_resource_path_t *paths, size_t paths_length)
 
int anjay_send_batch_data_add_current_multiple_ignore_not_found (anjay_send_batch_builder_t *builder, anjay_t *anjay, const anjay_send_resource_path_t *paths, size_t paths_length)
 
anjay_send_batch_tanjay_send_batch_builder_compile (anjay_send_batch_builder_t **builder)
 
anjay_send_batch_tanjay_send_batch_acquire (const anjay_send_batch_t *batch)
 
void anjay_send_batch_release (anjay_send_batch_t **batch)
 
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)
 
anjay_send_result_t anjay_send_deferrable (anjay_t *anjay, anjay_ssid_t ssid, const anjay_send_batch_t *data, anjay_send_finished_handler_t *finished_handler, void *finished_handler_data)
 

Macro Definition Documentation

◆ ANJAY_SEND_ABORT

#define ANJAY_SEND_ABORT   (-2)

Result passed to anjay_send_finished_handler_t: No response from Server was received and further retransmissions are aborted due to library cleanup or because the socket used to communicate with the server is being disconnected (e.g. when entering offline mode).

◆ ANJAY_SEND_DEFERRED_ERROR

#define ANJAY_SEND_DEFERRED_ERROR   (-3)

Send request has previously been deferred, the factors that caused it to be deferred are no longer valid, but it could not be initiated for other reasons.

EXAMPLE: anjay_send_deferrable may have been called when the server was offline. The server is now online, but the Send request have been rejected due to the registration having been performed with the LwM2M TS 1.0 protocol version.

NOTE: Any of the errors defined in anjay_send_result_t may be mapped onto this error code. There is currently no way to determine more detailed reason.

◆ ANJAY_SEND_SUCCESS

#define ANJAY_SEND_SUCCESS   0

Result passed to anjay_send_finished_handler_t: Server confirmed successful message delivery.

◆ ANJAY_SEND_TIMEOUT

#define ANJAY_SEND_TIMEOUT   (-1)

Result passed to anjay_send_finished_handler_t: No response from Server was received in expected time, or connection with the server has been lost. Retransmissions will not continue - you may try to send the same batch again using anjay_send .

Typedef Documentation

◆ anjay_send_batch_builder_t

typedef struct anjay_send_batch_builder_struct anjay_send_batch_builder_t

◆ anjay_send_batch_t

typedef struct anjay_send_batch_struct anjay_send_batch_t

◆ anjay_send_finished_handler_t

typedef void anjay_send_finished_handler_t(anjay_t *anjay, anjay_ssid_t ssid, const anjay_send_batch_t *batch, int result, void *data)

A handler called if acknowledgement for LwM2M Send operation is received from the Server or all retransmissions of LwM2M Send have failed.

Parameters
anjayAnjay object for which the Send operation was attempted.
ssidShort Server ID of the server to which the batch was being sent.
batchPointer to a batch that was being sent. This pointer may be passed to anjay_send for sending again; if you wish to store it for later usage, anjay_send_batch_acquire MUST be used.
resultResult of the Send message delivery attempt. May be one of:
  • ANJAY_SEND_SUCCESS (0) - Server confirmed successful message delivery.
  • A negative value if any kind of error occured:
    • One of ANJAY_SEND_* constants for conditions described by
    • A negated ANJAY_COAP_STATUS (i.e., one of ANJAY_ERR_* constants) if there was an unexpected (non-success) CoAP response from the server.
dataData defined by user passed into the handler.

Enumeration Type Documentation

◆ anjay_send_result_t

All possible error codes that will be returned by the anjay_send()

Enumerator
ANJAY_SEND_OK 
ANJAY_SEND_ERR_UNSUPPORTED 

This version of Anjay does not support LwM2M Send operation.

ANJAY_SEND_ERR_MUTED 

LwM2M Send cannot be performed because of "Mute Send" Resource is set to true.

NOTE: The value of "Mute Send" Resource is controlled by the LwM2M Server itself.

ANJAY_SEND_ERR_OFFLINE 

Passed Short Server ID refers to a server, connection to which is currently offline. The LwM2M Send operation may be retried after making the connection back online.

ANJAY_SEND_ERR_BOOTSTRAP 

Anjay is in process of a Bootstrap. The LwM2M Send operation may be retried after finishing the Bootstrap stage.

ANJAY_SEND_ERR_SSID 

Passed Short Server ID does not correspond to any existing / connected, non-Bootstrap Server. Especially passing ANJAY_SSID_ANY or ANJAY_SSID_BOOTSTRAP causes this error to be returned.

ANJAY_SEND_ERR_PROTOCOL 

The LwM2M protocol version used to connect to an LwM2M Server does not support the LwM2M Send operation.

ANJAY_SEND_ERR_INTERNAL 

Internal error. Very likely caused by the out-of-memory condition. The LwM2M Send operation may be retried after freeing some memory.

Function Documentation

◆ anjay_send()

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(anjay, ssid, empty_batch, NULL, NULL);
anjay_send_batch_t * anjay_send_batch_builder_compile(anjay_send_batch_builder_t **builder)
struct anjay_send_batch_builder_struct anjay_send_batch_builder_t
Definition: lwm2m_send.h:21
struct anjay_send_batch_struct anjay_send_batch_t
Definition: lwm2m_send.h:23
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)
anjay_send_batch_builder_t * anjay_send_batch_builder_new(void)

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
anjayAnjay object to operate on.
ssidShort Server ID of target LwM2M Server. Cannot be ANJAY_SSID_ANY or ANJAY_SSID_BOOTSTRAP.
dataContent of the message compiled previously with anjay_send_batch_builder_compile .
finished_handlerHandler called if the server confirmed message delivery or if no response was received in expected time (handler can be NULL).
finished_handler_dataData for the handler.
Returns
one of the anjay_send_result_t enum values.

◆ anjay_send_batch_acquire()

anjay_send_batch_t* anjay_send_batch_acquire ( const anjay_send_batch_t batch)

Increments the refcount for a *batch. Must always be used if batch would be referenced out of current scope, especially when the pointer would be saved to an object that is dynamically allocated. Each call of this function must have complementary anjay_send_batch_release call at some point.

Parameters
batchNon-null batch which refcount will be incremented
Returns
batch

◆ anjay_send_batch_add_bool()

int anjay_send_batch_add_bool ( anjay_send_batch_builder_t builder,
anjay_oid_t  oid,
anjay_iid_t  iid,
anjay_rid_t  rid,
anjay_riid_t  riid,
avs_time_real_t  timestamp,
bool  value 
)

Adds a value to batch builder.

IMPORTANT NOTE: If timestamp is earlier than 1978-07-04 21:24:16 UTC (2**28 seconds since Unix epoch), then it's assumed to be relative to some arbitrary point in time, and will be encoded as relative to "now". Otherwise, the time is assumed to be an Unix timestamp, and encoded as time since Unix epoch. See also: RFC 8428, "Requirements and Design Goals"

Parameters
builderPointer to batch builder
oidObject ID, MUST NOT be UINT16_MAX
iidInstance ID, MUST NOT be UINT16_MAX
ridResource ID, MUST NOT be UINT16_MAX
riidResource Instance ID, UINT16_MAX for no RIID
timestampTime related to value being sent (e.g. when the measurement corresponding to the passed value was made)
valueValue to add to the batch.
Returns
0 on success, negative value otherwise. In case of failure, the builder is left unchanged.

◆ anjay_send_batch_add_bytes()

int anjay_send_batch_add_bytes ( anjay_send_batch_builder_t builder,
anjay_oid_t  oid,
anjay_iid_t  iid,
anjay_rid_t  rid,
anjay_riid_t  riid,
avs_time_real_t  timestamp,
const void *  data,
size_t  length 
)

Adds bytes to batch builder.

IMPORTANT NOTE: If timestamp is earlier than 1978-07-04 21:24:16 UTC (2**28 seconds since Unix epoch), then it's assumed to be relative to some arbitrary point in time, and will be encoded as relative to "now". Otherwise, the time is assumed to be an Unix timestamp, and encoded as time since Unix epoch. See also: RFC 8428, "Requirements and Design Goals"

Parameters
builderPointer to batch builder
oidObject ID, MUST NOT be UINT16_MAX
iidInstance ID, MUST NOT be UINT16_MAX
ridResource ID, MUST NOT be UINT16_MAX
riidResource Instance ID, UINT16_MAX for no RIID
timestampTime related to bytes being send (e.g. when the measurement corresponding to the passed bytes was made)
dataPointer to data. No longer required by batch builder after call to this function, because internal copy is made. Can be NULL only if length is 0.
lengthLength of data in bytes.
Returns
0 on success, negative value otherwise. In case of failure, the builder is left unchanged.

◆ anjay_send_batch_add_double()

int anjay_send_batch_add_double ( anjay_send_batch_builder_t builder,
anjay_oid_t  oid,
anjay_iid_t  iid,
anjay_rid_t  rid,
anjay_riid_t  riid,
avs_time_real_t  timestamp,
double  value 
)

Adds a value to batch builder.

IMPORTANT NOTE: If timestamp is earlier than 1978-07-04 21:24:16 UTC (2**28 seconds since Unix epoch), then it's assumed to be relative to some arbitrary point in time, and will be encoded as relative to "now". Otherwise, the time is assumed to be an Unix timestamp, and encoded as time since Unix epoch. See also: RFC 8428, "Requirements and Design Goals"

Parameters
builderPointer to batch builder
oidObject ID, MUST NOT be UINT16_MAX
iidInstance ID, MUST NOT be UINT16_MAX
ridResource ID, MUST NOT be UINT16_MAX
riidResource Instance ID, UINT16_MAX for no RIID
timestampTime related to value being sent (e.g. when the measurement corresponding to the passed value was made)
valueValue to add to the batch.
Returns
0 on success, negative value otherwise. In case of failure, the builder is left unchanged.

◆ anjay_send_batch_add_int()

int anjay_send_batch_add_int ( anjay_send_batch_builder_t builder,
anjay_oid_t  oid,
anjay_iid_t  iid,
anjay_rid_t  rid,
anjay_riid_t  riid,
avs_time_real_t  timestamp,
int64_t  value 
)

Adds a value to batch builder.

IMPORTANT NOTE: If timestamp is earlier than 1978-07-04 21:24:16 UTC (2**28 seconds since Unix epoch), then it's assumed to be relative to some arbitrary point in time, and will be encoded as relative to "now". Otherwise, the time is assumed to be an Unix timestamp, and encoded as time since Unix epoch. See also: RFC 8428, "Requirements and Design Goals"

Parameters
builderPointer to batch builder
oidObject ID, MUST NOT be UINT16_MAX
iidInstance ID, MUST NOT be UINT16_MAX
ridResource ID, MUST NOT be UINT16_MAX
riidResource Instance ID, UINT16_MAX for no RIID
timestampTime related to value being sent (e.g. when the measurement corresponding to the passed value was made)
valueValue to add to the batch.
Returns
0 on success, negative value otherwise. In case of failure, the builder is left unchanged.

◆ anjay_send_batch_add_objlnk()

int anjay_send_batch_add_objlnk ( anjay_send_batch_builder_t builder,
anjay_oid_t  oid,
anjay_iid_t  iid,
anjay_rid_t  rid,
anjay_riid_t  riid,
avs_time_real_t  timestamp,
anjay_oid_t  objlnk_oid,
anjay_iid_t  objlnk_iid 
)

Adds an Object Link to batch builder.

IMPORTANT NOTE: If timestamp is earlier than 1978-07-04 21:24:16 UTC (2**28 seconds since Unix epoch), then it's assumed to be relative to some arbitrary point in time, and will be encoded as relative to "now". Otherwise, the time is assumed to be an Unix timestamp, and encoded as time since Unix epoch. See also: RFC 8428, "Requirements and Design Goals"

Parameters
builderPointer to batch builder
oidObject ID, MUST NOT be UINT16_MAX
iidInstance ID, MUST NOT be UINT16_MAX
ridResource ID, MUST NOT be UINT16_MAX
riidResource Instance ID, UINT16_MAX for no RIID
timestampTime related to Object Link being send (e.g. when the measurement corresponding to the passed Object Link was made)
objlnk_oidOID of Object Link
objlnk_iidIID of Object Link
Returns
0 on success, negative value otherwise. In case of failure, the builder is left unchanged.

◆ anjay_send_batch_add_string()

int anjay_send_batch_add_string ( anjay_send_batch_builder_t builder,
anjay_oid_t  oid,
anjay_iid_t  iid,
anjay_rid_t  rid,
anjay_riid_t  riid,
avs_time_real_t  timestamp,
const char *  str 
)

Adds a string to batch builder.

IMPORTANT NOTE: If timestamp is earlier than 1978-07-04 21:24:16 UTC (2**28 seconds since Unix epoch), then it's assumed to be relative to some arbitrary point in time, and will be encoded as relative to "now". Otherwise, the time is assumed to be an Unix timestamp, and encoded as time since Unix epoch. See also: RFC 8428, "Requirements and Design Goals"

Parameters
builderPointer to batch builder
oidObject ID, MUST NOT be UINT16_MAX
iidInstance ID, MUST NOT be UINT16_MAX
ridResource ID, MUST NOT be UINT16_MAX
riidResource Instance ID, UINT16_MAX for no RIID
timestampTime related to string being send (e.g. when the measurement corresponding to the passed string was made)
strPointer to a NULL-terminated string. Must not be NULL. No longer required by batch builder after call to this function, because internal copy is made.
Returns
0 on success, negative value otherwise. In case of failure, the builder is left unchanged.

◆ anjay_send_batch_add_uint()

int anjay_send_batch_add_uint ( anjay_send_batch_builder_t builder,
anjay_oid_t  oid,
anjay_iid_t  iid,
anjay_rid_t  rid,
anjay_riid_t  riid,
avs_time_real_t  timestamp,
uint64_t  value 
)

Adds a value to batch builder.

IMPORTANT NOTE: If timestamp is earlier than 1978-07-04 21:24:16 UTC (2**28 seconds since Unix epoch), then it's assumed to be relative to some arbitrary point in time, and will be encoded as relative to "now". Otherwise, the time is assumed to be an Unix timestamp, and encoded as time since Unix epoch. See also: RFC 8428, "Requirements and Design Goals"

Parameters
builderPointer to batch builder
oidObject ID, MUST NOT be UINT16_MAX
iidInstance ID, MUST NOT be UINT16_MAX
ridResource ID, MUST NOT be UINT16_MAX
riidResource Instance ID, UINT16_MAX for no RIID
timestampTime related to value being sent (e.g. when the measurement corresponding to the passed value was made)
valueValue to add to the batch.
Returns
0 on success, negative value otherwise. In case of failure, the builder is left unchanged.

◆ anjay_send_batch_builder_cleanup()

void anjay_send_batch_builder_cleanup ( anjay_send_batch_builder_t **  builder)

Releases batch builder and discards all data. It has no effect if builder was previously compiled.

Parameters
builderPointer to pointer to data builder. Set to NULL after cleanup.

◆ anjay_send_batch_builder_compile()

anjay_send_batch_t* anjay_send_batch_builder_compile ( anjay_send_batch_builder_t **  builder)

Makes a dynamically-allocated, reference-counted immutable data batch using data from batch builder. Created batch can be used for multiple calls of anjay_send().

Parameters
builderPointer to pointer to batch builder. Set to NULL after successful return.
Returns
Pointer to compiled batch in case of success, NULL otherwise. If this function fails, batch builder is not modified and must be freed manually with anjay_send_batch_builder_cleanup() if it's not to be used anymore.

◆ anjay_send_batch_builder_new()

anjay_send_batch_builder_t* anjay_send_batch_builder_new ( void  )

Creates a batch builder that may be used to build a payload with the data to be sent to the LwM2M Server by means of LwM2M Send operation.

Intended use of the batch builder may be divided into four steps, as follows:

  1. Create a batch builder.
  2. Fill in the builder with data, by calling anjay_send_batch_add_* functions (possibly multiple times).
  3. Convert the builder into the final, immutable batch by anjay_send_batch_builder_compile function call.
  4. Pass the resulting batch to anjay_send .

Example use (error checking omitted for brevity):

// Creates a builder for a batch.
// Adds signed integer value to batch builder, without checking if such
// resource (oid=1, iid=2, rid=3) exists in datamodel.
builder, 1, 2, 3, UINT16_MAX, avs_time_real_now(), 123);
// Adds value from datamodel (oid=4, iid=5, rid=6) to batch builder if it
// exists.
anjay_send_batch_data_add_current(builder, anjay, 4, 5, 6);
// Creates immutable data batch and releases builder.
// Puts LwM2M Send request on the scheduler queue. During next call to
// anjay_sched_run content of the batch will be sent to server with SSID=1
anjay_send(anjay, 1, batch, NULL, NULL);
// Releases the batch if it's not used by some send operation.
int anjay_send_batch_data_add_current(anjay_send_batch_builder_t *builder, anjay_t *anjay, anjay_oid_t oid, anjay_iid_t iid, anjay_rid_t rid)
int anjay_send_batch_add_int(anjay_send_batch_builder_t *builder, anjay_oid_t oid, anjay_iid_t iid, anjay_rid_t rid, anjay_riid_t riid, avs_time_real_t timestamp, int64_t value)
void anjay_send_batch_release(anjay_send_batch_t **batch)
Returns
Pointer to dynamically allocated batch builder, which is freed implicitly in anjay_send_batch_builder_compile() or has to be freed manually by calling anjay_send_batch_builder_cleanup() . NULL in case of allocation failure.

◆ anjay_send_batch_data_add_current()

int anjay_send_batch_data_add_current ( anjay_send_batch_builder_t builder,
anjay_t anjay,
anjay_oid_t  oid,
anjay_iid_t  iid,
anjay_rid_t  rid 
)

Reads value from data model of object anjay (without checking access privileges) and adds it to the builder with timestamp set to avs_time_real_now().

May possibly add multiple entries if /oid/iid/rid is a Multiple Resource.

Parameters
builderPointer to batch builder, MUST NOT be NULL
anjayPointer to Anjay object, MUST NOT be NULL
oidObject ID, MUST NOT be UINT16_MAX , 0 (Security object ID) or 21 (OSCORE object ID).
iidInstance ID, MUST NOT be UINT16_MAX
ridResource ID, MUST NOT be UINT16_MAX
Returns
0 on success, negative value otherwise. In case of failure, the builder is left unchanged.

◆ anjay_send_batch_data_add_current_multiple()

int anjay_send_batch_data_add_current_multiple ( anjay_send_batch_builder_t builder,
anjay_t anjay,
const anjay_send_resource_path_t paths,
size_t  paths_length 
)

Reads values from data model of object anjay (without checking access privileges) and adds them to the builder with the same timestamp for every value. Timestamp is set to avs_time_real_now().

Parameters
builderPointer to batch builder, MUST NOT be NULL
anjayPointer to Anjay object, MUST NOT be NULL
pathsPointer to array of anjay_send_resource_path_t .
paths_lengthLength of paths array.
Returns
0 on success, negative value otherwise. In case of failure, the builder is left unchanged.

◆ anjay_send_batch_data_add_current_multiple_ignore_not_found()

int anjay_send_batch_data_add_current_multiple_ignore_not_found ( anjay_send_batch_builder_t builder,
anjay_t anjay,
const anjay_send_resource_path_t paths,
size_t  paths_length 
)

Reads values from data model of object anjay (without checking access privileges) and adds them to the builder with the same timestamp for every value. Timestamp is set to avs_time_real_now().

If a resource is not found, it's ignored, the error isn't returned and the function adds next resources from the paths.

Parameters
builderPointer to batch builder, MUST NOT be NULL
anjayPointer to Anjay object, MUST NOT be NULL
pathsPointer to array of anjay_send_resource_path_t .
paths_lengthLength of paths array.
Returns
0 on success, negative value otherwise. In case of failure, the builder is left unchanged.

◆ anjay_send_batch_release()

void anjay_send_batch_release ( anjay_send_batch_t **  batch)

Decreases the refcount for a *batch, sets it to NULL, and frees it if the refcount has reached zero.

Parameters
*batchPointer to compiled data batch.

◆ anjay_send_deferrable()

anjay_send_result_t anjay_send_deferrable ( 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, either immediately, or deferring it until such operation will be possible.

This function is equivalent to anjay_send, but in cases when the former would return ANJAY_SEND_ERR_OFFLINE or ANJAY_SEND_ERR_BOOTSTRAP, this variant returns success and postpones the actual Send operation until the server connection identified by ssid is online.

If at that time, the server in question will be removed from the data model, registered using a LwM2M version that does not support the Send operation (i.e., LwM2M 1.0), or the Mute Send resource changes while the Send is deferred, the operation is cancelled and finished_handler is called with the result argument set to ANJAY_SEND_DEFERRED_ERROR.

Parameters
anjayAnjay object to operate on.
ssidShort Server ID of target LwM2M Server. Cannot be ANJAY_SSID_ANY or ANJAY_SSID_BOOTSTRAP.
dataContent of the message compiled previously with anjay_send_batch_builder_compile .
finished_handlerHandler called if the server confirmed message delivery or if no response was received in expected time (handler can be NULL).
finished_handler_dataData for the handler.
Returns
one of the anjay_send_result_t enum values.