Anjay Lite
|
#include <assert.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <anj/anj_config.h>
Go to the source code of this file.
Data Structures | |
struct | anj_communication_retry_res_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_ATTR_DOUBLE_NONE (NAN) |
#define ANJ_ATTR_UINT_NONE (UINT32_MAX) |
#define ANJ_COAP_CODE | ( | cls, | |
detail | |||
) |
#define ANJ_COAP_CODE_ABORT ANJ_COAP_CODE(7, 5) |
#define ANJ_COAP_CODE_BAD_GATEWAY ANJ_COAP_CODE(5, 2) |
#define ANJ_COAP_CODE_BAD_OPTION ANJ_COAP_CODE(4, 2) |
#define ANJ_COAP_CODE_BAD_REQUEST ANJ_COAP_CODE(4, 0) |
#define ANJ_COAP_CODE_CHANGED ANJ_COAP_CODE(2, 4) |
#define ANJ_COAP_CODE_CLASS_MASK 0xE0 |
Macros used for constructing/parsing CoAP codes.
#define ANJ_COAP_CODE_CLASS_SHIFT 5 |
#define ANJ_COAP_CODE_CONTENT ANJ_COAP_CODE(2, 5) |
#define ANJ_COAP_CODE_CONTINUE ANJ_COAP_CODE(2, 31) |
#define ANJ_COAP_CODE_CREATED ANJ_COAP_CODE(2, 1) |
#define ANJ_COAP_CODE_CSM ANJ_COAP_CODE(7, 1) |
#define ANJ_COAP_CODE_DELETE ANJ_COAP_CODE(0, 4) |
#define ANJ_COAP_CODE_DELETED ANJ_COAP_CODE(2, 2) |
#define ANJ_COAP_CODE_DETAIL_MASK 0x1F |
#define ANJ_COAP_CODE_DETAIL_SHIFT 0 |
#define ANJ_COAP_CODE_EMPTY ANJ_COAP_CODE(0, 0) |
#define ANJ_COAP_CODE_FETCH ANJ_COAP_CODE(0, 5) |
#define ANJ_COAP_CODE_FORBIDDEN ANJ_COAP_CODE(4, 3) |
#define ANJ_COAP_CODE_GATEWAY_TIMEOUT ANJ_COAP_CODE(5, 4) |
#define ANJ_COAP_CODE_GET ANJ_COAP_CODE(0, 1) |
#define ANJ_COAP_CODE_INTERNAL_SERVER_ERROR ANJ_COAP_CODE(5, 0) |
#define ANJ_COAP_CODE_IPATCH ANJ_COAP_CODE(0, 7) |
#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_NOT_FOUND ANJ_COAP_CODE(4, 4) |
#define ANJ_COAP_CODE_NOT_IMPLEMENTED ANJ_COAP_CODE(5, 1) |
#define ANJ_COAP_CODE_PATCH ANJ_COAP_CODE(0, 6) |
#define ANJ_COAP_CODE_PING ANJ_COAP_CODE(7, 2) |
#define ANJ_COAP_CODE_PONG ANJ_COAP_CODE(7, 3) |
#define ANJ_COAP_CODE_POST ANJ_COAP_CODE(0, 2) |
#define ANJ_COAP_CODE_PRECONDITION_FAILED ANJ_COAP_CODE(4, 12) |
#define ANJ_COAP_CODE_PROXYING_NOT_SUPPORTED ANJ_COAP_CODE(5, 5) |
#define ANJ_COAP_CODE_PUT ANJ_COAP_CODE(0, 3) |
#define ANJ_COAP_CODE_RELEASE ANJ_COAP_CODE(7, 4) |
#define ANJ_COAP_CODE_REQUEST_ENTITY_INCOMPLETE ANJ_COAP_CODE(4, 8) |
#define ANJ_COAP_CODE_REQUEST_ENTITY_TOO_LARGE ANJ_COAP_CODE(4, 13) |
#define ANJ_COAP_CODE_SERVICE_UNAVAILABLE ANJ_COAP_CODE(5, 3) |
#define ANJ_COAP_CODE_UNAUTHORIZED ANJ_COAP_CODE(4, 1) |
#define ANJ_COAP_CODE_UNSUPPORTED_CONTENT_FORMAT ANJ_COAP_CODE(4, 15) |
#define ANJ_COAP_CODE_VALID ANJ_COAP_CODE(2, 3) |
#define ANJ_COMMUNICATION_RETRY_RES_DEFAULT |
Default values for the communication retry mechanism resources.
#define ANJ_DATA_TYPE_ANY |
When a bit mask of data types is applicable, this constant can be used to specify all supported data types.
Note that it does NOT include ANJ_DATA_TYPE_FLAG_EXTERNAL, and that ANJ_DATA_TYPE_NULL, having a numeric value of 0, does not participate in bit masks.
#define ANJ_DATA_TYPE_BOOL ((anj_data_type_t) (1 << 4)) |
"Boolean" data type, as defined in Appendix C of the LwM2M spec.
The bool_value
field of anj_res_value_t is used to pass the actual data.
#define ANJ_DATA_TYPE_BYTES ((anj_data_type_t) (1 << 0)) |
"Opaque" data type, as defined in Appendix C of the LwM2M spec.
The bytes_or_string
field of anj_res_value_t is used to pass the actual data.
#define ANJ_DATA_TYPE_DOUBLE ((anj_data_type_t) (1 << 3)) |
"Float" data type, as defined in Appendix C of the LwM2M spec.
The double_value
field of anj_res_value_t is used to pass the actual data.
#define ANJ_DATA_TYPE_EXTERNAL_BYTES ((anj_data_type_t) (ANJ_DATA_TYPE_BYTES | ANJ_DATA_TYPE_FLAG_EXTERNAL)) |
"Opaque" data type, as defined in Appendix C of the LwM2M specification, provided via an external callback. Valid only for output contexts.
The external_data
field of anj_res_value_t is used to supply the data.
#define ANJ_DATA_TYPE_EXTERNAL_STRING ((anj_data_type_t) (ANJ_DATA_TYPE_STRING | ANJ_DATA_TYPE_FLAG_EXTERNAL)) |
"String" data type, as defined in Appendix C of the LwM2M specification, provided via an external callback. Valid only for output contexts.
The external_data
field of anj_res_value_t is used to supply the data.
#define ANJ_DATA_TYPE_FLAG_EXTERNAL ((anj_data_type_t) (1 << 15)) |
A flag that can be OR-ed with either ANJ_DATA_TYPE_BYTES or ANJ_DATA_TYPE_STRING to indicate that the data is provided via an external callback. Valid only for output contexts.
When this flag is set, the external_data
field of anj_res_value_t must be used to provide the actual data.
This mechanism is intended for scenarios where:
external_data
callback interface does not require specifying the complete length beforehand.#define ANJ_DATA_TYPE_INT ((anj_data_type_t) (1 << 2)) |
"Integer" data type, as defined in Appendix C of the LwM2M spec.
The int_value
field of anj_res_value_t is used to pass the actual data.
#define ANJ_DATA_TYPE_NULL ((anj_data_type_t) 0) |
Null data type. It will be returned by the input context in the following situations:
anj_res_value_t is not used for null data.
#define ANJ_DATA_TYPE_OBJLNK ((anj_data_type_t) (1 << 5)) |
"Objlnk" data type, as defined in Appendix C of the LwM2M spec.
The objlnk
field of anj_res_value_t is used to pass the actual data.
#define ANJ_DATA_TYPE_STRING ((anj_data_type_t) (1 << 1)) |
"String" data type, as defined in Appendix C of the LwM2M spec.
May also be used to represent the "Corelnk" type, as those two are indistinguishable on the wire.
The bytes_or_string
field of anj_res_value_t is used to pass the actual data.
#define ANJ_DATA_TYPE_TIME ((anj_data_type_t) (1 << 7)) |
"Time" data type, as defined in Appendix C of the LwM2M spec.
The time_value
field of anj_res_value_t is used to pass the actual data.
#define ANJ_DATA_TYPE_UINT ((anj_data_type_t) (1 << 6)) |
"Unsigned Integer" data type, as defined in Appendix C of the LwM2M spec.
The uint_value
field of anj_res_value_t is used to pass the actual data.
#define ANJ_DISABLE_TIMEOUT_DEFAULT_VALUE 86400 |
Default value for the Disable Timeout resource in the Server Object
#define ANJ_DOUBLE_STR_MAX_LEN (sizeof("-2.2250738585072014E-308") - 1) |
#define ANJ_I64_STR_MAX_LEN (sizeof("-9223372036854775808") - 1) |
The values below do not include the terminating null character
#define ANJ_IO_NEED_NEXT_CALL 4 |
Can be returned by anj_get_external_data_t to inform the library that this callback should be invoked again; it is also used internally - do not modify this value!
#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_OBJ_ID_SECURITY 0U |
#define ANJ_OBJ_ID_SERVER 1U |
#define ANJ_SERVER_URI_MAX_SIZE 255 |
LWM2M Server URI maximum size - as defined in LwM2M spec
#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) |
typedef void anj_close_external_data_t(void *user_args) |
This callback will be called when the anj_get_external_data_t callback returns a value different than ANJ_IO_NEED_NEXT_CALL or when an error occurs while reading external data; such errors can originate either inside the library itself or during communication with the server - for example, if a timeout occurs or the server terminates the transfer.
user_args | User-defined context pointer provided by the application. |
typedef uint16_t anj_data_type_t |
defines entry type
typedef int anj_get_external_data_t(void *buffer, size_t *inout_size, size_t offset, void *user_args) |
A handler used to retrieve string or binary data from an external source.
This function is called when the resource's data type is set to ANJ_DATA_TYPE_EXTERNAL_BYTES or ANJ_DATA_TYPE_EXTERNAL_STRING. It may be called multiple times to retrieve subsequent data chunks.
inout_size
must remains unchanged.offset
parameter indicates the absolute position (in bytes) from the beginning of the resource data. The implementation must ensure that the copied data chunk corresponds to this offset, i.e., write exactly *inout_size
bytes from position offset
. The library guarantees sequential calls with increasing offsets and no overlaps.buffer | Pointer to the buffer where data should be copied. | |
[in,out] | inout_size | On input: size of the buffer . On output: number of bytes actually written. |
offset | Offset (in bytes) from the beginning of the data. | |
user_args | User-defined context pointer provided by the application. |
typedef uint16_t anj_iid_t |
Object Instance ID
typedef struct anj_io_out_entry_struct anj_io_out_entry_t |
Data structure used to represent an entry produced by the data model.
typedef uint16_t anj_oid_t |
Object ID
typedef int anj_open_external_data_t(void *user_args) |
This callback is invoked before any invocation of the anj_get_external_data_t callback. It should be used to initialize the external data source.
user_args | User-defined context pointer provided by the application. |
typedef uint16_t anj_rid_t |
Resource ID
typedef uint16_t anj_riid_t |
Resource Instance ID
typedef struct anj_struct anj_t |
Forward declaration of anj_struct, which represents an object containing all statically allocated memory used by the Anjay Lite library.
enum anj_id_type_t |
Enumeration of identifiers used to index the anj_uri_path_t::ids
Enumerator | |
---|---|
ANJ_ID_OID | |
ANJ_ID_IID | |
ANJ_ID_RID | |
ANJ_ID_RIID | |
ANJ_URI_PATH_MAX_LENGTH |