Anjay Lite
Loading...
Searching...
No Matches
lwm2m_send.h File Reference

Public API for composing and queuing LwM2M Send messages. More...

#include <anj/init.h>
#include <anj/defs.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_NETWORK   -4
 
#define ANJ_SEND_ERR_INTERNAL   -5
 
#define ANJ_SEND_ERR_NO_REQUEST_FOUND   -6
 
#define ANJ_SEND_ERR_NO_SPACE   -7
 
#define ANJ_SEND_ERR_NOT_ALLOWED   -8
 
#define ANJ_SEND_ERR_DATA_NOT_VALID   -9
 

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)
 

Detailed Description

Public API for composing and queuing LwM2M Send messages.

The Send operation allows a client to proactively transmit Resource values to the LwM2M Server (without a preceding request). Requests are queued and sent when a registration session is active and no higher-priority CoAP exchange is in progress.

Macro Definition Documentation

◆ ANJ_SEND_ID_ALL

#define ANJ_SEND_ID_ALL   UINT16_MAX

Special ID that matches all queued/active Send requests.

See also
anj_send_abort

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)

Completion handler for a Send request.

Parameters
anjayAnjay object.
send_idID of the Send request.
resultOne of LwM2M Send error codes.
dataUser pointer from anj_send_request_t::data.

Enumeration Type Documentation

◆ anj_send_content_format_t

Content format of the Send payload.

Requires the corresponding build-time support to be enabled.

  • SenML CBOR supports timestamps (useful for time series).
  • LwM2M CBOR is typically more compact; paths must be unique within one payload (duplicate paths are invalid even if timestamps differ).
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 
)

Abort a queued or in-flight Send request.

  • If the request is queued, it is removed from the queue.
  • If the request is in progress, the exchange is cancelled.

In both cases, ANJ_SEND_ERR_ABORT is reported to the completion handler.

Parameters
anjAnjay object.
send_idID of the Send request to abort. Use ANJ_SEND_ID_ALL to abort all pending requests.
Returns
0 on success; ANJ_SEND_ERR_NO_REQUEST_FOUND if no matching request exists; ANJ_SEND_ERR_ABORT if abort 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 
)

Queue a new LwM2M Send request.

If this function returns 0, the request is queued and the finish handler will be called with the final result. The request is processed when:

  • a registration session is active, and
  • no higher-priority CoAP exchange is in progress.

When multiple requests are queued, they are processed FIFO; only one Send request is processed at a time.

Note
Timestamps: Only SenML CBOR supports timestamps. In non-SenML formats, anj_io_out_entry_t::timestamp is ignored.
Duplicate paths when using LwM2M CBOR: LwM2M CBOR uses a CBOR map keyed by paths; keys must be unique. A request with duplicate paths is invalid, even if timestamps differ.
The send_request object is not copied. All referenced memory (including the anj_send_request_t::records array) must remain valid and unchanged until the operation completes and the finish handler returns.
Parameters
anjAnjay object.
send_requestDescription of the message to send (must remain valid until completion).
[out]out_send_idIf non-NULL, receives the assigned Send request ID (valid until the finish handler is invoked).
Returns
0 on success, otherwise one of LwM2M Send error codes :