Anjay Lite
Loading...
Searching...
No Matches
lwm2m_send.h File Reference
#include <anj/init.h>
#include <anj/defs.h>
#include <anj_internal/lwm2m_send.h>

Go to the source code of this file.

Data Structures

struct  anj_send_request_t
 

Macros

#define ANJ_SEND_ID_ALL   UINT16_MAX
 
#define ANJ_SEND_SUCCESS   0
 
#define ANJ_SEND_ERR_TIMEOUT   -1
 
#define ANJ_SEND_ERR_ABORT   -2
 
#define ANJ_SEND_ERR_REJECTED   -3
 
#define ANJ_SEND_ERR_NO_REQUEST_FOUND   -4
 
#define ANJ_SEND_ERR_NO_SPACE   -5
 
#define ANJ_SEND_ERR_NOT_ALLOWED   -6
 
#define ANJ_SEND_ERR_DATA_NOT_VALID   -7
 
#define ANJ_INTERNAL_INCLUDE_SEND
 

Typedefs

typedef void anj_send_finished_handler_t(anj_t *anjay, uint16_t send_id, int result, void *data)
 

Enumerations

enum  anj_send_content_format_t { ANJ_SEND_CONTENT_FORMAT_SENML_CBOR , ANJ_SEND_CONTENT_FORMAT_LWM2M_CBOR }
 

Functions

int anj_send_new_request (anj_t *anj, const anj_send_request_t *send_request, uint16_t *out_send_id)
 
int anj_send_abort (anj_t *anj, uint16_t send_id)
 

Macro Definition Documentation

◆ ANJ_INTERNAL_INCLUDE_SEND

#define ANJ_INTERNAL_INCLUDE_SEND

◆ ANJ_SEND_ERR_ABORT

#define ANJ_SEND_ERR_ABORT   -2

Result passed to anj_send_finished_handler_t: Sending the message was aborted. There are several reasons why this might happen:

  • the message was cancelled by the user by calling anj_send_abort
  • because of a network error or other unexpected condition (e,g. Mute Send resource changed),
  • registration session ended.

◆ ANJ_SEND_ERR_DATA_NOT_VALID

#define ANJ_SEND_ERR_DATA_NOT_VALID   -7

Can be returned by anj_send_new_request because provided data is not valid.

◆ ANJ_SEND_ERR_NO_REQUEST_FOUND

#define ANJ_SEND_ERR_NO_REQUEST_FOUND   -4

Can be returned by anj_send_abort if no request with given ID was found.

◆ ANJ_SEND_ERR_NO_SPACE

#define ANJ_SEND_ERR_NO_SPACE   -5

Can be returned by anj_send_new_request if there is no space for new request - ANJ_LWM2M_SEND_QUEUE_SIZE has been reached.

◆ ANJ_SEND_ERR_NOT_ALLOWED

#define ANJ_SEND_ERR_NOT_ALLOWED   -6

Can be returned by anj_send_new_request if request can't be sent in current state of the library:

◆ ANJ_SEND_ERR_REJECTED

#define ANJ_SEND_ERR_REJECTED   -3

Result passed to anj_send_finished_handler_t: Server rejected the message and response with 4.xx code.

◆ ANJ_SEND_ERR_TIMEOUT

#define ANJ_SEND_ERR_TIMEOUT   -1

Result passed to anj_send_finished_handler_t: No response from Server was received in expected time.

◆ ANJ_SEND_ID_ALL

#define ANJ_SEND_ID_ALL   UINT16_MAX

◆ ANJ_SEND_SUCCESS

#define ANJ_SEND_SUCCESS   0

Result passed to anj_send_finished_handler_t: Server confirmed successful message delivery.

Typedef Documentation

◆ anj_send_finished_handler_t

typedef void anj_send_finished_handler_t(anj_t *anjay, uint16_t send_id, int result, void *data)

A handler called if acknowledgement for LwM2M Send operation is received from the Server or message delivery fails.

Parameters
anjayAnjay object for which the Send operation was attempted.
send_idID of the Send operation that was attempted.
resultResult of the Send message delivery attempt. May be one of:
dataData defined by user passed into the handler.

Enumeration Type Documentation

◆ anj_send_content_format_t

Content format of the message payload to be sent.

Enumerator
ANJ_SEND_CONTENT_FORMAT_SENML_CBOR 
ANJ_SEND_CONTENT_FORMAT_LWM2M_CBOR 

Function Documentation

◆ anj_send_abort()

int anj_send_abort ( anj_t anj,
uint16_t  send_id 
)

Aborts a LwM2M Send request with given ID. If the request is still in the queue to be sent, it will be removed. If the request is already being sent, the exchange will be cancelled first. For both cases ANJ_SEND_ERR_ABORT will be passed to the anj_send_finished_handler_t as a result.

Parameters
anjAnjay object to operate on.
send_idID of the Send operation to be aborted. If ANJ_SEND_ID_ALL is passed, all pending requests will be aborted.
Returns
0 on success, ANJ_SEND_ERR_NO_REQUEST_FOUND if no request with given ID was found, ANJ_SEND_ERR_ABORT if aborting is already in progress.

◆ anj_send_new_request()

int anj_send_new_request ( anj_t anj,
const anj_send_request_t send_request,
uint16_t *  out_send_id 
)

Registers a new LwM2M Send request to be sent.

If this function returns 0, the finish handler will be called with the result of the operation. A Send request is allowed only if a registration session is active. The request will be processed when possible — if there is no ongoing exchange, only Update messages have higher priority.

If multiple Send requests are queued, the oldest one is sent first. Only one Send request is processed at a time.

Note
Only SenML CBOR provides support for timestamps.
If send_request contains multiple records with the same path listed more than once, the request will fail when encoded as LwM2M CBOR — even if the records have different timestamps.

This is because LwM2M CBOR maps resource paths to keys in a CBOR map, which requires keys (i.e., paths) to be unique. Having duplicate paths in the encoded structure is invalid and not supported.

Note
The send_request structure is not copied internally. The pointer must remain valid and unchanged until the send operation completes and the associated finish handler has been called.
Parameters
anjAnjay object to operate on.
send_requestStructure representing the message to be sent. Must remain valid until the operation is finished.
[out]out_send_idPointer to a variable where the ID of the new Send operation will be stored. May be NULL if the ID is not needed. The ID remains valid until the associated anj_send_finished_handler_t is invoked.
Returns
0 on success, a negative value in case of an error: