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

Core type and constant definitions for Anjay Lite. More...

#include <anj/init.h>
#include <assert.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <anj/time.h>

Go to the source code of this file.

Data Structures

struct  anj_communication_retry_res_t
 
struct  anj_exchange_udp_tx_params_t
 
struct  anj_uri_path_t
 
struct  anj_bytes_or_string_value_t
 
struct  anj_objlnk_value_t
 
union  anj_res_value_t
 
struct  anj_io_out_entry_struct
 

Macros

#define ANJ_COAP_CODE_CLASS_MASK   0xE0
 
#define ANJ_COAP_CODE_CLASS_SHIFT   5
 
#define ANJ_COAP_CODE_DETAIL_MASK   0x1F
 
#define ANJ_COAP_CODE_DETAIL_SHIFT   0
 
#define ANJ_COAP_CODE(cls, detail)
 
#define ANJ_COAP_CODE_EMPTY   ANJ_COAP_CODE(0, 0)
 
#define ANJ_COAP_CODE_GET   ANJ_COAP_CODE(0, 1)
 
#define ANJ_COAP_CODE_POST   ANJ_COAP_CODE(0, 2)
 
#define ANJ_COAP_CODE_PUT   ANJ_COAP_CODE(0, 3)
 
#define ANJ_COAP_CODE_DELETE   ANJ_COAP_CODE(0, 4)
 
#define ANJ_COAP_CODE_FETCH   ANJ_COAP_CODE(0, 5)
 
#define ANJ_COAP_CODE_PATCH   ANJ_COAP_CODE(0, 6)
 
#define ANJ_COAP_CODE_IPATCH   ANJ_COAP_CODE(0, 7)
 
#define ANJ_COAP_CODE_CREATED   ANJ_COAP_CODE(2, 1)
 
#define ANJ_COAP_CODE_DELETED   ANJ_COAP_CODE(2, 2)
 
#define ANJ_COAP_CODE_VALID   ANJ_COAP_CODE(2, 3)
 
#define ANJ_COAP_CODE_CHANGED   ANJ_COAP_CODE(2, 4)
 
#define ANJ_COAP_CODE_CONTENT   ANJ_COAP_CODE(2, 5)
 
#define ANJ_COAP_CODE_CONTINUE   ANJ_COAP_CODE(2, 31)
 
#define ANJ_COAP_CODE_BAD_REQUEST   ANJ_COAP_CODE(4, 0)
 
#define ANJ_COAP_CODE_UNAUTHORIZED   ANJ_COAP_CODE(4, 1)
 
#define ANJ_COAP_CODE_BAD_OPTION   ANJ_COAP_CODE(4, 2)
 
#define ANJ_COAP_CODE_FORBIDDEN   ANJ_COAP_CODE(4, 3)
 
#define ANJ_COAP_CODE_NOT_FOUND   ANJ_COAP_CODE(4, 4)
 
#define ANJ_COAP_CODE_METHOD_NOT_ALLOWED   ANJ_COAP_CODE(4, 5)
 
#define ANJ_COAP_CODE_NOT_ACCEPTABLE   ANJ_COAP_CODE(4, 6)
 
#define ANJ_COAP_CODE_REQUEST_ENTITY_INCOMPLETE   ANJ_COAP_CODE(4, 8)
 
#define ANJ_COAP_CODE_PRECONDITION_FAILED   ANJ_COAP_CODE(4, 12)
 
#define ANJ_COAP_CODE_REQUEST_ENTITY_TOO_LARGE   ANJ_COAP_CODE(4, 13)
 
#define ANJ_COAP_CODE_UNSUPPORTED_CONTENT_FORMAT   ANJ_COAP_CODE(4, 15)
 
#define ANJ_COAP_CODE_INTERNAL_SERVER_ERROR   ANJ_COAP_CODE(5, 0)
 
#define ANJ_COAP_CODE_NOT_IMPLEMENTED   ANJ_COAP_CODE(5, 1)
 
#define ANJ_COAP_CODE_BAD_GATEWAY   ANJ_COAP_CODE(5, 2)
 
#define ANJ_COAP_CODE_SERVICE_UNAVAILABLE   ANJ_COAP_CODE(5, 3)
 
#define ANJ_COAP_CODE_GATEWAY_TIMEOUT   ANJ_COAP_CODE(5, 4)
 
#define ANJ_COAP_CODE_PROXYING_NOT_SUPPORTED   ANJ_COAP_CODE(5, 5)
 
#define ANJ_COAP_CODE_CSM   ANJ_COAP_CODE(7, 1)
 
#define ANJ_COAP_CODE_PING   ANJ_COAP_CODE(7, 2)
 
#define ANJ_COAP_CODE_PONG   ANJ_COAP_CODE(7, 3)
 
#define ANJ_COAP_CODE_RELEASE   ANJ_COAP_CODE(7, 4)
 
#define ANJ_COAP_CODE_ABORT   ANJ_COAP_CODE(7, 5)
 
#define ANJ_OBJ_ID_SECURITY   0U
 
#define ANJ_OBJ_ID_SERVER   1U
 
#define ANJ_OBJ_ID_ACCESS_CONTROL   2U
 
#define ANJ_OBJ_ID_DEVICE   3U
 
#define ANJ_OBJ_ID_FIRMWARE_UPDATE   5U
 
#define ANJ_OBJ_ID_OSCORE   21U
 
#define ANJ_I64_STR_MAX_LEN   (sizeof("-9223372036854775808") - 1)
 
#define ANJ_U16_STR_MAX_LEN   (sizeof("65535") - 1)
 
#define ANJ_U32_STR_MAX_LEN   (sizeof("4294967295") - 1)
 
#define ANJ_U64_STR_MAX_LEN   (sizeof("18446744073709551615") - 1)
 
#define ANJ_DOUBLE_STR_MAX_LEN   (sizeof("-2.2250738585072014E-308") - 1)
 
#define ANJ_ATTR_UINT_NONE   (UINT32_MAX)
 
#define ANJ_ATTR_DOUBLE_NONE   (NAN)
 
#define ANJ_IO_NEED_NEXT_CALL   4
 
#define ANJ_SERVER_URI_MAX_SIZE   256
 
#define ANJ_DISABLE_TIMEOUT_DEFAULT_VALUE   86400
 
#define ANJ_COMMUNICATION_RETRY_RES_DEFAULT
 
#define ANJ_EXCHANGE_SERVER_REQUEST_TIMEOUT    anj_time_duration_new(50, ANJ_TIME_UNIT_S)
 
#define ANJ_EXCHANGE_UDP_TX_PARAMS_DEFAULT
 
#define ANJ_DATA_TYPE_NULL   ((anj_data_type_t) 0)
 
#define ANJ_DATA_TYPE_BYTES   ((anj_data_type_t) (1 << 0))
 
#define ANJ_DATA_TYPE_STRING   ((anj_data_type_t) (1 << 1))
 
#define ANJ_DATA_TYPE_INT   ((anj_data_type_t) (1 << 2))
 
#define ANJ_DATA_TYPE_DOUBLE   ((anj_data_type_t) (1 << 3))
 
#define ANJ_DATA_TYPE_BOOL   ((anj_data_type_t) (1 << 4))
 
#define ANJ_DATA_TYPE_OBJLNK   ((anj_data_type_t) (1 << 5))
 
#define ANJ_DATA_TYPE_UINT   ((anj_data_type_t) (1 << 6))
 
#define ANJ_DATA_TYPE_TIME   ((anj_data_type_t) (1 << 7))
 
#define ANJ_DATA_TYPE_ANY
 
#define ANJ_DATA_TYPE_FLAG_EXTERNAL   ((anj_data_type_t) (1 << 15))
 
#define ANJ_DATA_TYPE_EXTERNAL_BYTES
 
#define ANJ_DATA_TYPE_EXTERNAL_STRING
 

Typedefs

typedef uint16_t anj_oid_t
 
typedef uint16_t anj_iid_t
 
typedef uint16_t anj_rid_t
 
typedef uint16_t anj_riid_t
 
typedef struct anj_struct anj_t
 
typedef struct anj_coap_downloader_struct anj_coap_downloader_t
 
typedef uint16_t anj_data_type_t
 
typedef int anj_get_external_data_t(void *buffer, size_t *inout_size, size_t offset, void *user_args)
 
typedef int anj_open_external_data_t(void *user_args)
 
typedef void anj_close_external_data_t(void *user_args)
 
typedef struct anj_io_out_entry_struct anj_io_out_entry_t
 

Enumerations

enum  anj_id_type_t {
  ANJ_ID_OID , ANJ_ID_IID , ANJ_ID_RID , ANJ_ID_RIID ,
  ANJ_URI_PATH_MAX_LENGTH
}
 

Detailed Description

Core type and constant definitions for Anjay Lite.

Defines LwM2M identifiers, CoAP codes, data types, and utility structures shared across the library.

Macro Definition Documentation

◆ ANJ_ATTR_DOUBLE_NONE

#define ANJ_ATTR_DOUBLE_NONE   (NAN)

◆ ANJ_ATTR_UINT_NONE

#define ANJ_ATTR_UINT_NONE   (UINT32_MAX)

◆ ANJ_COAP_CODE

#define ANJ_COAP_CODE (   cls,
  detail 
)
Value:
| (((detail) << ANJ_COAP_CODE_DETAIL_SHIFT) \
#define ANJ_COAP_CODE_DETAIL_SHIFT
Definition defs.h:38
#define ANJ_COAP_CODE_CLASS_SHIFT
Definition defs.h:36
#define ANJ_COAP_CODE_CLASS_MASK
Definition defs.h:35
#define ANJ_COAP_CODE_DETAIL_MASK
Definition defs.h:37

◆ ANJ_COAP_CODE_CLASS_MASK

#define ANJ_COAP_CODE_CLASS_MASK   0xE0

◆ ANJ_COAP_CODE_CLASS_SHIFT

#define ANJ_COAP_CODE_CLASS_SHIFT   5

◆ ANJ_COAP_CODE_DETAIL_MASK

#define ANJ_COAP_CODE_DETAIL_MASK   0x1F

◆ ANJ_COAP_CODE_DETAIL_SHIFT

#define ANJ_COAP_CODE_DETAIL_SHIFT   0

◆ ANJ_COMMUNICATION_RETRY_RES_DEFAULT

#define ANJ_COMMUNICATION_RETRY_RES_DEFAULT
Value:
.retry_count = 5, \
.retry_timer = 60, \
.seq_delay_timer = 24 * 60 * 60, \
.seq_retry_count = 1 \
}
Definition defs.h:185

Default values for the communication retry mechanism Resources.

◆ ANJ_DISABLE_TIMEOUT_DEFAULT_VALUE

#define ANJ_DISABLE_TIMEOUT_DEFAULT_VALUE   86400

Default value for the Disable Timeout Resource in the Server Object.

See also
OMA LwM2M Core Specification v1.2.2 [OMA-TS-LightweightM2M_Core-V1_2_2-20240613-A] §E.2

◆ ANJ_DOUBLE_STR_MAX_LEN

#define ANJ_DOUBLE_STR_MAX_LEN   (sizeof("-2.2250738585072014E-308") - 1)

◆ ANJ_EXCHANGE_SERVER_REQUEST_TIMEOUT

#define ANJ_EXCHANGE_SERVER_REQUEST_TIMEOUT    anj_time_duration_new(50, ANJ_TIME_UNIT_S)

Default time to wait for the next block of the LwM2M Server request. Can be overridden in anj_configuration_t::exchange_request_timeout.

◆ ANJ_EXCHANGE_UDP_TX_PARAMS_DEFAULT

#define ANJ_EXCHANGE_UDP_TX_PARAMS_DEFAULT
Value:
.ack_timeout = anj_time_duration_new(2, ANJ_TIME_UNIT_S), \
.ack_random_factor = 1.5, \
.max_retransmit = 4 \
}
Definition defs.h:215
@ ANJ_TIME_UNIT_S
Seconds (1000 milliseconds).
Definition time.h:72
anj_time_duration_t anj_time_duration_new(int64_t scalar, anj_time_unit_t unit)
Creates a duration from an integer scalar in the given unit.

Default CoAP transmission parameters as specified in RFC 7252.

◆ ANJ_I64_STR_MAX_LEN

#define ANJ_I64_STR_MAX_LEN   (sizeof("-9223372036854775808") - 1)

The values below do not include the terminating null character

◆ ANJ_IO_NEED_NEXT_CALL

#define ANJ_IO_NEED_NEXT_CALL   4

Returned by anj_get_external_data_t to inform that this callback should be invoked again.

◆ ANJ_OBJ_ID_ACCESS_CONTROL

#define ANJ_OBJ_ID_ACCESS_CONTROL   2U

◆ ANJ_OBJ_ID_DEVICE

#define ANJ_OBJ_ID_DEVICE   3U

◆ ANJ_OBJ_ID_FIRMWARE_UPDATE

#define ANJ_OBJ_ID_FIRMWARE_UPDATE   5U

◆ ANJ_OBJ_ID_OSCORE

#define ANJ_OBJ_ID_OSCORE   21U

◆ ANJ_OBJ_ID_SECURITY

#define ANJ_OBJ_ID_SECURITY   0U

◆ ANJ_OBJ_ID_SERVER

#define ANJ_OBJ_ID_SERVER   1U

◆ ANJ_SERVER_URI_MAX_SIZE

#define ANJ_SERVER_URI_MAX_SIZE   256

LwM2M Server URI maximum size (including null terminator).

See also
OMA LwM2M Core Specification v1.2.2 [OMA-TS-LightweightM2M_Core-V1_2_2-20240613-A] §E.1

◆ ANJ_U16_STR_MAX_LEN

#define ANJ_U16_STR_MAX_LEN   (sizeof("65535") - 1)

◆ ANJ_U32_STR_MAX_LEN

#define ANJ_U32_STR_MAX_LEN   (sizeof("4294967295") - 1)

◆ ANJ_U64_STR_MAX_LEN

#define ANJ_U64_STR_MAX_LEN   (sizeof("18446744073709551615") - 1)

Typedef Documentation

◆ anj_close_external_data_t

typedef void anj_close_external_data_t(void *user_args)

Callback to clean up the external data source.

Invoked after reading completes (successfully or with error), unless anj_open_external_data_t failed. Can be used to close file descriptors, release memory, or reset state.

Parameters
user_argsApplication-defined pointer.

◆ anj_coap_downloader_t

typedef struct anj_coap_downloader_struct anj_coap_downloader_t

◆ anj_get_external_data_t

typedef int anj_get_external_data_t(void *buffer, size_t *inout_size, size_t offset, void *user_args)

Callback to read a chunk of external data.

Called by the library when encoding a resource whose type is ANJ_DATA_TYPE_EXTERNAL_BYTES or ANJ_DATA_TYPE_EXTERNAL_STRING. It may be invoked multiple times until the entire resource value has been streamed.

The library guarantees sequential calls with monotonically increasing offset and no overlaps.

Parameters
bufferOutput buffer to be filled with data.
[in,out]inout_size
  • On input: size of buffer in bytes.
  • On output: number of bytes actually written.
offsetAbsolute offset (in bytes) from the beginning of the resource value.
user_argsApplication-defined pointer passed unchanged to every callback.
Returns
  • 0 if the end of the resource was reached (all data provided),
  • a negative value on error,
  • ANJ_IO_NEED_NEXT_CALL if more data remains. In this case, the implementation must have filled the entire buffer (i.e., left inout_size unchanged).

◆ anj_iid_t

typedef uint16_t anj_iid_t

Object Instance ID

◆ anj_io_out_entry_t

Data structure representing a single entry produced by the data model.

◆ anj_oid_t

typedef uint16_t anj_oid_t

Object ID

◆ anj_open_external_data_t

typedef int anj_open_external_data_t(void *user_args)

Callback to initialize the external data source.

Invoked once before the first call to anj_get_external_data_t. Can be used to open files, initialize peripherals, or allocate state.

Parameters
user_argsApplication-defined pointer.
Returns

◆ anj_rid_t

typedef uint16_t anj_rid_t

Resource ID

◆ anj_riid_t

typedef uint16_t anj_riid_t

Resource Instance ID

◆ anj_t

typedef struct anj_struct anj_t

Enumeration Type Documentation

◆ anj_id_type_t

Identifiers used to index elements of anj_uri_path_t::ids.

These correspond to components of an LwM2M data model path:

ANJ_URI_PATH_MAX_LENGTH gives the size of the array that can store all possible path components.

Enumerator
ANJ_ID_OID 
ANJ_ID_IID 
ANJ_ID_RID 
ANJ_ID_RIID 
ANJ_URI_PATH_MAX_LENGTH