#include <anj/init.h>
#include <anj/defs.h>
#include <anj_internal/lwm2m_send.h>
Go to the source code of this file.
◆ 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 |
◆ 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 |
◆ ANJ_SEND_ERR_NOT_ALLOWED
#define ANJ_SEND_ERR_NOT_ALLOWED -6 |
◆ ANJ_SEND_ERR_REJECTED
#define ANJ_SEND_ERR_REJECTED -3 |
◆ ANJ_SEND_ERR_TIMEOUT
#define ANJ_SEND_ERR_TIMEOUT -1 |
◆ ANJ_SEND_ID_ALL
#define ANJ_SEND_ID_ALL UINT16_MAX |
◆ ANJ_SEND_SUCCESS
#define ANJ_SEND_SUCCESS 0 |
◆ 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
-
anjay | Anjay object for which the Send operation was attempted. |
send_id | ID of the Send operation that was attempted. |
result | Result of the Send message delivery attempt. May be one of:
|
data | Data defined by user passed into the handler. |
◆ 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 | |
◆ 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
-
anj | Anjay object to operate on. |
send_id | ID 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()
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
-
| anj | Anjay object to operate on. |
| send_request | Structure representing the message to be sent. Must remain valid until the operation is finished. |
[out] | out_send_id | Pointer 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: