Skip to content

File syn_lwm2m.h

FileList > proto > syn_lwm2m.h

Go to the source code of this file

Zero-Heap OMA Lightweight M2M (LwM2M v1.1/v1.2) Core Client Engine. More...

  • #include "syntropic/common/syn_defs.h"
  • #include "syntropic/net/syn_coap.h"

Classes

Type Name
struct SYN_LwM2M_Client
LwM2M Client Context.
struct SYN_LwM2M_DeviceContext
Device Object (Object ID 3) state and context.
struct SYN_LwM2M_FirmwareContext
Firmware Update Object (Object ID 5) context.
struct SYN_LwM2M_Object
LwM2M Object Definition.
struct SYN_LwM2M_Observation
Active resource or instance observation (RFC 7641).
struct SYN_LwM2M_ResourceDesc
Resource descriptor defining ID, permissions, and type.
struct SYN_LwM2M_SensorContext
Generic Sensor / Temperature Object (Object ID 3303) context.
struct SYN_LwM2M_TLV
Decoded / to-be-encoded LwM2M TLV item.
struct SYN_LwM2M_Value
LwM2M Generic Value Container.

Public Types

Type Name
enum SYN_LwM2M_ClientState
LwM2M client registration states.
typedef SYN_Status(* SYN_LwM2M_ExecCb
Execute callback: executes an executable resource with optional arguments.
enum SYN_LwM2M_FirmwareResult
Firmware Update Object (Object ID 5) update results.
enum SYN_LwM2M_FirmwareState
Firmware Update Object (Object ID 5) states per OMA LwM2M spec.
typedef SYN_Status(* SYN_LwM2M_ReadCb
Read callback: retrieves current resource value.
enum SYN_LwM2M_TLV_Type
LwM2M TLV Type identifier (Bits 7-6 of TLV header byte).
enum SYN_LwM2M_ValType
LwM2M primitive resource value types.
typedef SYN_Status(* SYN_LwM2M_WriteCb
Write callback: writes new resource value.

Public Functions

Type Name
size_t syn_lwm2m_build_deregister_request (const SYN_LwM2M_Client * client, uint16_t msg_id, const uint8_t * token, uint8_t token_len, SYN_CoapMsg * req, SYN_CoapOption * req_opts, size_t max_req_opts, size_t * req_opt_cnt)
Build a CoAP Deregistration DELETE request ( /rd/<location> ).
size_t syn_lwm2m_build_notify (SYN_LwM2M_Client * client, uint16_t obj_id, uint16_t inst_id, int32_t res_id, uint16_t msg_id, SYN_CoapMsg * resp, SYN_CoapOption * resp_opts, size_t max_resp_opts, size_t * resp_opt_cnt, uint8_t * resp_buf, size_t resp_buf_sz)
Build a CoAP Notification response for an active observation.
size_t syn_lwm2m_build_register_request (const SYN_LwM2M_Client * client, uint16_t msg_id, const uint8_t * token, uint8_t token_len, SYN_CoapMsg * req, SYN_CoapOption * req_opts, size_t max_req_opts, size_t * req_opt_cnt, uint8_t * payload_buf, size_t payload_buf_sz)
Build a CoAP Registration POST request ( /rd?ep=...&lt=... ).
size_t syn_lwm2m_build_update_request (const SYN_LwM2M_Client * client, uint16_t msg_id, const uint8_t * token, uint8_t token_len, uint32_t lifetime_s, SYN_CoapMsg * req, SYN_CoapOption * req_opts, size_t max_req_opts, size_t * req_opt_cnt, uint8_t * payload_buf, size_t payload_buf_sz)
Build a CoAP Registration Update POST request ( /rd/<location> ).
bool syn_lwm2m_client_init (SYN_LwM2M_Client * client, const char * endpoint_name, uint32_t lifetime_s, SYN_Transport * transport)
Initialize a zero-heap LwM2M client context.
size_t syn_lwm2m_generate_link_format (const SYN_LwM2M_Client * client, char * buf, size_t max_len)
Generate CoRE Link Format string listing all registered object instances.
bool syn_lwm2m_handle_register_response (SYN_LwM2M_Client * client, const SYN_CoapMsg * resp, const SYN_CoapOption * resp_opts, size_t resp_opt_cnt)
Handle server response to Registration request (parses Location-Path).
SYN_LwM2M_Object syn_lwm2m_make_device_object (SYN_LwM2M_DeviceContext * ctx)
Create an Object 3 (Device) descriptor bound to ctx .
SYN_LwM2M_Object syn_lwm2m_make_firmware_object (SYN_LwM2M_FirmwareContext * ctx)
Create an Object 5 (Firmware Update) descriptor bound to ctx .
SYN_LwM2M_Object syn_lwm2m_make_temperature_object (SYN_LwM2M_SensorContext * ctx)
Create an Object 3303 (Temperature Sensor) descriptor bound to ctx .
bool syn_lwm2m_observe_add (SYN_LwM2M_Client * client, uint16_t obj_id, uint16_t inst_id, int32_t res_id, const uint8_t * token, uint8_t token_len, uint32_t pmin, uint32_t pmax)
Add or update an observation for an object instance or resource.
bool syn_lwm2m_observe_remove (SYN_LwM2M_Client * client, const uint8_t * token, uint8_t token_len)
Remove an active observation by matching token.
SYN_Status syn_lwm2m_process_request (SYN_LwM2M_Client * client, const SYN_CoapMsg * req, const SYN_CoapOption * req_opts, size_t req_opt_cnt, SYN_CoapMsg * resp, SYN_CoapOption * resp_opts, size_t max_resp_opts, size_t * resp_opt_cnt, uint8_t * resp_buf, size_t resp_buf_sz)
Dispatch and process an incoming CoAP request against registered LwM2M objects.
bool syn_lwm2m_register_object (SYN_LwM2M_Client * client, const SYN_LwM2M_Object * obj)
Register an object definition into the client object registry.
bool syn_lwm2m_tlv_decode (const uint8_t * buf, size_t buf_len, SYN_LwM2M_TLV * tlv, size_t * consumed)
Decode a single TLV item from a byte stream.
bool syn_lwm2m_tlv_decode_bool (const SYN_LwM2M_TLV * tlv, bool * out_val)
Decode a boolean from TLV value bytes.
bool syn_lwm2m_tlv_decode_float (const SYN_LwM2M_TLV * tlv, double * out_val)
Decode a float/double from TLV value bytes.
bool syn_lwm2m_tlv_decode_int (const SYN_LwM2M_TLV * tlv, int64_t * out_val)
Decode a signed integer from TLV value bytes.
bool syn_lwm2m_tlv_decode_string (const SYN_LwM2M_TLV * tlv, char * out_str, size_t max_len)
Decode a string from TLV value bytes into a null-terminated buffer.
bool syn_lwm2m_tlv_decode_value (const SYN_LwM2M_TLV * tlv, SYN_LwM2M_ValType expected_type, SYN_LwM2M_Value * out_val)
Decode a TLV into a typed SYN_LwM2M_Value container.
size_t syn_lwm2m_tlv_encode (const SYN_LwM2M_TLV * tlv, uint8_t * buf, size_t max_len)
Encode a raw TLV header and value into a buffer.
size_t syn_lwm2m_tlv_encode_bool (uint16_t res_id, bool val, uint8_t * buf, size_t max_len)
Encode a boolean resource as TLV (1-byte int 0 or 1).
size_t syn_lwm2m_tlv_encode_float (uint16_t res_id, double val, uint8_t * buf, size_t max_len)
Encode a float/double resource as TLV (Float32 or Float64).
size_t syn_lwm2m_tlv_encode_instance (uint16_t inst_id, const uint8_t * tlv_payload, size_t payload_len, uint8_t * buf, size_t max_len)
Wrap nested resource TLVs inside an Object Instance TLV header.
size_t syn_lwm2m_tlv_encode_int (uint16_t res_id, int64_t val, uint8_t * buf, size_t max_len)
Encode a 64-bit integer resource as TLV.
size_t syn_lwm2m_tlv_encode_opaque (uint16_t res_id, const uint8_t * data, size_t len, uint8_t * buf, size_t max_len)
Encode opaque binary data resource as TLV.
size_t syn_lwm2m_tlv_encode_string (uint16_t res_id, const char * str, uint8_t * buf, size_t max_len)
Encode a string resource as TLV.
size_t syn_lwm2m_tlv_encode_value (uint16_t res_id, const SYN_LwM2M_Value * val, uint8_t * buf, size_t max_len)
Encode a generic SYN_LwM2M_Value as TLV.

Macros

Type Name
define SYN_LWM2M_FORMAT_CBOR 11544U
define SYN_LWM2M_FORMAT_JSON 11543U
define SYN_LWM2M_FORMAT_LINK_FORMAT 40U
define SYN_LWM2M_FORMAT_OPAQUE 42U
define SYN_LWM2M_FORMAT_SENML_CBOR 112U
define SYN_LWM2M_FORMAT_TEXT 0U
define SYN_LWM2M_FORMAT_TLV 11542U
define SYN_LWM2M_MAX_OBJECTS 16U
define SYN_LWM2M_MAX_OBSERVERS 8U
define SYN_LWM2M_MAX_URI_PATH_LEN 64U
define SYN_LWM2M_OBJ_ACCESS_CONTROL 2U
define SYN_LWM2M_OBJ_ACTUATION 3306U
define SYN_LWM2M_OBJ_CONNECTIVITY_MONITORING 4U
define SYN_LWM2M_OBJ_CONNECTIVITY_STATS 7U
define SYN_LWM2M_OBJ_DEVICE 3U
define SYN_LWM2M_OBJ_FIRMWARE_UPDATE 5U
define SYN_LWM2M_OBJ_GENERIC_SENSOR 3300U
define SYN_LWM2M_OBJ_HUMIDITY 3304U
define SYN_LWM2M_OBJ_LOCATION 6U
define SYN_LWM2M_OBJ_SECURITY 0U
define SYN_LWM2M_OBJ_SERVER 1U
define SYN_LWM2M_OBJ_TEMPERATURE 3303U
define SYN_LWM2M_OP_E 0x04U
define SYN_LWM2M_OP_NONE 0x00U
define SYN_LWM2M_OP_R 0x01U
define SYN_LWM2M_OP_RW ([**SYN\_LWM2M\_OP\_R**](syn__lwm2m_8h.md#define-syn_lwm2m_op_r) \| [**SYN\_LWM2M\_OP\_W**](syn__lwm2m_8h.md#define-syn_lwm2m_op_w))
define SYN_LWM2M_OP_W 0x02U

Detailed Description

Implements the OMA LwM2M client specification over CoAP/CoAPS, supporting: * Data formats: Plain Text, Opaque, TLV (Type-Length-Value Content-Format 11542), SenML CBOR (Content-Format 112). * Standard Object & Resource tree routing (/object/instance/resource). * Registration, Registration Update, and Deregistration workflows. * Device Management: Read, Write, Execute, Discover, Observe & Notify (RFC 7641). * Standard Objects: Device (Obj 3), Firmware Update (Obj 5), IPSO Temperature (Obj 3303).

Public Types Documentation

enum SYN_LwM2M_ClientState

LwM2M client registration states.

enum SYN_LwM2M_ClientState {
    SYN_LWM2M_STATE_DEREGISTERED = 0,
    SYN_LWM2M_STATE_REGISTERING,
    SYN_LWM2M_STATE_REGISTERED,
    SYN_LWM2M_STATE_UPDATING
};


typedef SYN_LwM2M_ExecCb

Execute callback: executes an executable resource with optional arguments.

typedef SYN_Status(* SYN_LwM2M_ExecCb) (uint16_t instance_id, uint16_t resource_id, const uint8_t *args, size_t args_len, void *user_ctx);


enum SYN_LwM2M_FirmwareResult

Firmware Update Object (Object ID 5) update results.

enum SYN_LwM2M_FirmwareResult {
    SYN_LWM2M_FW_RESULT_DEFAULT = 0,
    SYN_LWM2M_FW_RESULT_SUCCESS,
    SYN_LWM2M_FW_RESULT_NO_FLASH,
    SYN_LWM2M_FW_RESULT_OUT_OF_RAM,
    SYN_LWM2M_FW_RESULT_CONN_LOST,
    SYN_LWM2M_FW_RESULT_INTEGRITY_FAIL,
    SYN_LWM2M_FW_RESULT_BAD_PKG_TYPE,
    SYN_LWM2M_FW_RESULT_INVALID_URI
};


enum SYN_LwM2M_FirmwareState

Firmware Update Object (Object ID 5) states per OMA LwM2M spec.

enum SYN_LwM2M_FirmwareState {
    SYN_LWM2M_FW_STATE_IDLE = 0,
    SYN_LWM2M_FW_STATE_DOWNLOADING,
    SYN_LWM2M_FW_STATE_DOWNLOADED,
    SYN_LWM2M_FW_STATE_UPDATING
};


typedef SYN_LwM2M_ReadCb

Read callback: retrieves current resource value.

typedef SYN_Status(* SYN_LwM2M_ReadCb) (uint16_t instance_id, uint16_t resource_id, SYN_LwM2M_Value *out_val, void *user_ctx);


enum SYN_LwM2M_TLV_Type

LwM2M TLV Type identifier (Bits 7-6 of TLV header byte).

enum SYN_LwM2M_TLV_Type {
    SYN_LWM2M_TLV_OBJECT_INSTANCE = 0x00U,
    SYN_LWM2M_TLV_RESOURCE_INSTANCE = 0x40U,
    SYN_LWM2M_TLV_MULTIPLE_RESOURCE = 0x80U,
    SYN_LWM2M_TLV_RESOURCE = 0xC0U
};


enum SYN_LwM2M_ValType

LwM2M primitive resource value types.

enum SYN_LwM2M_ValType {
    SYN_LWM2M_TYPE_NONE = 0,
    SYN_LWM2M_TYPE_STRING,
    SYN_LWM2M_TYPE_INT,
    SYN_LWM2M_TYPE_FLOAT,
    SYN_LWM2M_TYPE_BOOL,
    SYN_LWM2M_TYPE_OPAQUE,
    SYN_LWM2M_TYPE_TIME,
    SYN_LWM2M_TYPE_OBJLNK
};


typedef SYN_LwM2M_WriteCb

Write callback: writes new resource value.

typedef SYN_Status(* SYN_LwM2M_WriteCb) (uint16_t instance_id, uint16_t resource_id, const SYN_LwM2M_Value *in_val, void *user_ctx);


Public Functions Documentation

function syn_lwm2m_build_deregister_request

Build a CoAP Deregistration DELETE request ( /rd/<location> ).

size_t syn_lwm2m_build_deregister_request (
    const SYN_LwM2M_Client * client,
    uint16_t msg_id,
    const uint8_t * token,
    uint8_t token_len,
    SYN_CoapMsg * req,
    SYN_CoapOption * req_opts,
    size_t max_req_opts,
    size_t * req_opt_cnt
) 

Parameters:

  • client LwM2M client context.
  • msg_id CoAP message ID.
  • token CoAP token bytes.
  • token_len Length of CoAP token.
  • req [out] Populated CoAP request header.
  • req_opts [out] Populated CoAP options array.
  • max_req_opts Capacity of options array.
  • req_opt_cnt [out] Number of populated options.

Returns:

0 on success.


function syn_lwm2m_build_notify

Build a CoAP Notification response for an active observation.

size_t syn_lwm2m_build_notify (
    SYN_LwM2M_Client * client,
    uint16_t obj_id,
    uint16_t inst_id,
    int32_t res_id,
    uint16_t msg_id,
    SYN_CoapMsg * resp,
    SYN_CoapOption * resp_opts,
    size_t max_resp_opts,
    size_t * resp_opt_cnt,
    uint8_t * resp_buf,
    size_t resp_buf_sz
) 

Parameters:

  • client LwM2M client context.
  • obj_id Object ID.
  • inst_id Instance ID.
  • res_id Resource ID (-1 for entire instance).
  • msg_id CoAP message ID.
  • resp [out] Populated CoAP notification response header.
  • resp_opts [out] Output response options array.
  • max_resp_opts Capacity of response options array.
  • resp_opt_cnt [out] Number of populated response options.
  • resp_buf [out] Buffer for notification payload.
  • resp_buf_sz Capacity of notification buffer.

Returns:

Length of encoded payload in bytes, or 0 on error.


function syn_lwm2m_build_register_request

Build a CoAP Registration POST request ( /rd?ep=...&lt=... ).

size_t syn_lwm2m_build_register_request (
    const SYN_LwM2M_Client * client,
    uint16_t msg_id,
    const uint8_t * token,
    uint8_t token_len,
    SYN_CoapMsg * req,
    SYN_CoapOption * req_opts,
    size_t max_req_opts,
    size_t * req_opt_cnt,
    uint8_t * payload_buf,
    size_t payload_buf_sz
) 

Parameters:

  • client LwM2M client context.
  • msg_id CoAP message ID.
  • token CoAP token bytes.
  • token_len Length of CoAP token.
  • req [out] Populated CoAP request header.
  • req_opts [out] Populated CoAP options array.
  • max_req_opts Capacity of options array.
  • req_opt_cnt [out] Number of populated options.
  • payload_buf [out] Buffer for link format payload.
  • payload_buf_sz Capacity of payload buffer.

Returns:

Length of serialized payload in bytes, or 0 on error.


function syn_lwm2m_build_update_request

Build a CoAP Registration Update POST request ( /rd/<location> ).

size_t syn_lwm2m_build_update_request (
    const SYN_LwM2M_Client * client,
    uint16_t msg_id,
    const uint8_t * token,
    uint8_t token_len,
    uint32_t lifetime_s,
    SYN_CoapMsg * req,
    SYN_CoapOption * req_opts,
    size_t max_req_opts,
    size_t * req_opt_cnt,
    uint8_t * payload_buf,
    size_t payload_buf_sz
) 

Parameters:

  • client LwM2M client context.
  • msg_id CoAP message ID.
  • token CoAP token bytes.
  • token_len Length of CoAP token.
  • lifetime_s Updated registration lifetime in seconds (0 to keep current).
  • req [out] Populated CoAP request header.
  • req_opts [out] Populated CoAP options array.
  • max_req_opts Capacity of options array.
  • req_opt_cnt [out] Number of populated options.
  • payload_buf [out] Optional buffer for updated link format.
  • payload_buf_sz Capacity of payload buffer.

Returns:

Length of payload in bytes (0 if lifetime update only).


function syn_lwm2m_client_init

Initialize a zero-heap LwM2M client context.

bool syn_lwm2m_client_init (
    SYN_LwM2M_Client * client,
    const char * endpoint_name,
    uint32_t lifetime_s,
    SYN_Transport * transport
) 

Parameters:

  • client Client context to initialize.
  • endpoint_name Client endpoint name (e.g. "urn:imei:862415039201923").
  • lifetime_s Registration lifetime in seconds (e.g. 300).
  • transport Underlying datagram transport.

Returns:

true on success, false on invalid parameters.


Generate CoRE Link Format string listing all registered object instances.

size_t syn_lwm2m_generate_link_format (
    const SYN_LwM2M_Client * client,
    char * buf,
    size_t max_len
) 

Example output: </1/0>, </3/0>, </5/0>, </3303/0>

Parameters:

  • client LwM2M client context.
  • buf [out] Buffer to receive link format string.
  • max_len Capacity of link format buffer.

Returns:

Number of characters written (excluding null terminator), or 0 on overflow.


function syn_lwm2m_handle_register_response

Handle server response to Registration request (parses Location-Path).

bool syn_lwm2m_handle_register_response (
    SYN_LwM2M_Client * client,
    const SYN_CoapMsg * resp,
    const SYN_CoapOption * resp_opts,
    size_t resp_opt_cnt
) 

Parameters:

  • client LwM2M client context.
  • resp Received CoAP response.
  • resp_opts Received response options.
  • resp_opt_cnt Number of response options.

Returns:

true if registration succeeded (2.01 Created), false otherwise.


function syn_lwm2m_make_device_object

Create an Object 3 (Device) descriptor bound to ctx .

SYN_LwM2M_Object syn_lwm2m_make_device_object (
    SYN_LwM2M_DeviceContext * ctx
) 

Parameters:

  • ctx Device object context state.

Returns:

Initialized LwM2M object descriptor.


function syn_lwm2m_make_firmware_object

Create an Object 5 (Firmware Update) descriptor bound to ctx .

SYN_LwM2M_Object syn_lwm2m_make_firmware_object (
    SYN_LwM2M_FirmwareContext * ctx
) 

Parameters:

  • ctx Firmware update object context state.

Returns:

Initialized LwM2M object descriptor.


function syn_lwm2m_make_temperature_object

Create an Object 3303 (Temperature Sensor) descriptor bound to ctx .

SYN_LwM2M_Object syn_lwm2m_make_temperature_object (
    SYN_LwM2M_SensorContext * ctx
) 

Parameters:

  • ctx Temperature sensor object context state.

Returns:

Initialized LwM2M object descriptor.


function syn_lwm2m_observe_add

Add or update an observation for an object instance or resource.

bool syn_lwm2m_observe_add (
    SYN_LwM2M_Client * client,
    uint16_t obj_id,
    uint16_t inst_id,
    int32_t res_id,
    const uint8_t * token,
    uint8_t token_len,
    uint32_t pmin,
    uint32_t pmax
) 

Parameters:

  • client LwM2M client context.
  • obj_id Object ID.
  • inst_id Instance ID.
  • res_id Resource ID (-1 for entire instance).
  • token CoAP observation token.
  • token_len Length of token.
  • pmin Minimum period in seconds (0 = immediate).
  • pmax Maximum period in seconds (0 = none).

Returns:

true on success, false if table full.


function syn_lwm2m_observe_remove

Remove an active observation by matching token.

bool syn_lwm2m_observe_remove (
    SYN_LwM2M_Client * client,
    const uint8_t * token,
    uint8_t token_len
) 

Parameters:

  • client LwM2M client context.
  • token CoAP token bytes.
  • token_len Length of token.

Returns:

true if an entry was found and removed, false otherwise.


function syn_lwm2m_process_request

Dispatch and process an incoming CoAP request against registered LwM2M objects.

SYN_Status syn_lwm2m_process_request (
    SYN_LwM2M_Client * client,
    const SYN_CoapMsg * req,
    const SYN_CoapOption * req_opts,
    size_t req_opt_cnt,
    SYN_CoapMsg * resp,
    SYN_CoapOption * resp_opts,
    size_t max_resp_opts,
    size_t * resp_opt_cnt,
    uint8_t * resp_buf,
    size_t resp_buf_sz
) 

Handles GET (Read / Discover), PUT/POST (Write), POST (Execute), DELETE.

Parameters:

  • client LwM2M client context.
  • req Incoming CoAP request.
  • req_opts Request options (Uri-Path, Content-Format, Observe, etc.).
  • req_opt_cnt Number of request options.
  • resp [out] Prepared CoAP response.
  • resp_opts [out] Output response options array.
  • max_resp_opts Capacity of response options array.
  • resp_opt_cnt [out] Number of populated response options.
  • resp_buf [out] Buffer for response payload.
  • resp_buf_sz Capacity of response buffer.

Returns:

SYN_OK on successful request handling, error code otherwise.


function syn_lwm2m_register_object

Register an object definition into the client object registry.

bool syn_lwm2m_register_object (
    SYN_LwM2M_Client * client,
    const SYN_LwM2M_Object * obj
) 

Parameters:

  • client LwM2M client context.
  • obj Object definition descriptor.

Returns:

true on success, false if registry is full or invalid parameters.


function syn_lwm2m_tlv_decode

Decode a single TLV item from a byte stream.

bool syn_lwm2m_tlv_decode (
    const uint8_t * buf,
    size_t buf_len,
    SYN_LwM2M_TLV * tlv,
    size_t * consumed
) 

Parameters:

  • buf Input buffer.
  • buf_len Available bytes in buffer.
  • tlv [out] Decoded TLV header and value pointer.
  • consumed [out] Total bytes consumed for this TLV.

Returns:

true on success, false on format/length error.


function syn_lwm2m_tlv_decode_bool

Decode a boolean from TLV value bytes.

bool syn_lwm2m_tlv_decode_bool (
    const SYN_LwM2M_TLV * tlv,
    bool * out_val
) 

Parameters:

  • tlv Decoded TLV descriptor.
  • out_val [out] Decoded boolean.

Returns:

true on success, false on length error or null parameters.


function syn_lwm2m_tlv_decode_float

Decode a float/double from TLV value bytes.

bool syn_lwm2m_tlv_decode_float (
    const SYN_LwM2M_TLV * tlv,
    double * out_val
) 

Parameters:

  • tlv Decoded TLV descriptor.
  • out_val [out] Decoded double.

Returns:

true on success, false on length error or null parameters.


function syn_lwm2m_tlv_decode_int

Decode a signed integer from TLV value bytes.

bool syn_lwm2m_tlv_decode_int (
    const SYN_LwM2M_TLV * tlv,
    int64_t * out_val
) 

Parameters:

  • tlv Decoded TLV descriptor.
  • out_val [out] Decoded 64-bit integer.

Returns:

true on success, false on length error or null parameters.


function syn_lwm2m_tlv_decode_string

Decode a string from TLV value bytes into a null-terminated buffer.

bool syn_lwm2m_tlv_decode_string (
    const SYN_LwM2M_TLV * tlv,
    char * out_str,
    size_t max_len
) 

Parameters:

  • tlv Decoded TLV descriptor.
  • out_str [out] Target buffer for string.
  • max_len Capacity of target buffer.

Returns:

true on success, false on overflow or null parameters.


function syn_lwm2m_tlv_decode_value

Decode a TLV into a typed SYN_LwM2M_Value container.

bool syn_lwm2m_tlv_decode_value (
    const SYN_LwM2M_TLV * tlv,
    SYN_LwM2M_ValType expected_type,
    SYN_LwM2M_Value * out_val
) 

Parameters:

  • tlv Decoded TLV descriptor.
  • expected_type Expected value type.
  • out_val [out] Decoded value container.

Returns:

true on success, false on decoding failure.


function syn_lwm2m_tlv_encode

Encode a raw TLV header and value into a buffer.

size_t syn_lwm2m_tlv_encode (
    const SYN_LwM2M_TLV * tlv,
    uint8_t * buf,
    size_t max_len
) 

Parameters:

  • tlv TLV item to encode.
  • buf [out] Target buffer.
  • max_len Capacity of target buffer.

Returns:

Number of bytes written, or 0 on buffer overflow.


function syn_lwm2m_tlv_encode_bool

Encode a boolean resource as TLV (1-byte int 0 or 1).

size_t syn_lwm2m_tlv_encode_bool (
    uint16_t res_id,
    bool val,
    uint8_t * buf,
    size_t max_len
) 

Parameters:

  • res_id Resource ID.
  • val Boolean value.
  • buf [out] Target buffer.
  • max_len Capacity of target buffer.

Returns:

Number of bytes written, or 0 on overflow.


function syn_lwm2m_tlv_encode_float

Encode a float/double resource as TLV (Float32 or Float64).

size_t syn_lwm2m_tlv_encode_float (
    uint16_t res_id,
    double val,
    uint8_t * buf,
    size_t max_len
) 

Parameters:

  • res_id Resource ID.
  • val Floating-point value.
  • buf [out] Target buffer.
  • max_len Capacity of target buffer.

Returns:

Number of bytes written, or 0 on overflow.


function syn_lwm2m_tlv_encode_instance

Wrap nested resource TLVs inside an Object Instance TLV header.

size_t syn_lwm2m_tlv_encode_instance (
    uint16_t inst_id,
    const uint8_t * tlv_payload,
    size_t payload_len,
    uint8_t * buf,
    size_t max_len
) 

Parameters:

  • inst_id Object instance ID.
  • tlv_payload Serialized resource TLVs buffer.
  • payload_len Length of resource TLVs.
  • buf [out] Target buffer.
  • max_len Capacity of target buffer.

Returns:

Number of bytes written, or 0 on overflow.


function syn_lwm2m_tlv_encode_int

Encode a 64-bit integer resource as TLV.

size_t syn_lwm2m_tlv_encode_int (
    uint16_t res_id,
    int64_t val,
    uint8_t * buf,
    size_t max_len
) 

Parameters:

  • res_id Resource ID.
  • val Integer value to encode.
  • buf [out] Target buffer.
  • max_len Capacity of target buffer.

Returns:

Number of bytes written, or 0 on overflow.


function syn_lwm2m_tlv_encode_opaque

Encode opaque binary data resource as TLV.

size_t syn_lwm2m_tlv_encode_opaque (
    uint16_t res_id,
    const uint8_t * data,
    size_t len,
    uint8_t * buf,
    size_t max_len
) 

Parameters:

  • res_id Resource ID.
  • data Binary buffer.
  • len Length of binary data.
  • buf [out] Target buffer.
  • max_len Capacity of target buffer.

Returns:

Number of bytes written, or 0 on overflow.


function syn_lwm2m_tlv_encode_string

Encode a string resource as TLV.

size_t syn_lwm2m_tlv_encode_string (
    uint16_t res_id,
    const char * str,
    uint8_t * buf,
    size_t max_len
) 

Parameters:

  • res_id Resource ID.
  • str Null-terminated string.
  • buf [out] Target buffer.
  • max_len Capacity of target buffer.

Returns:

Number of bytes written, or 0 on overflow.


function syn_lwm2m_tlv_encode_value

Encode a generic SYN_LwM2M_Value as TLV.

size_t syn_lwm2m_tlv_encode_value (
    uint16_t res_id,
    const SYN_LwM2M_Value * val,
    uint8_t * buf,
    size_t max_len
) 

Parameters:

  • res_id Resource ID.
  • val Typed resource value container.
  • buf [out] Target buffer.
  • max_len Capacity of target buffer.

Returns:

Number of bytes written, or 0 on overflow.


Macro Definition Documentation

define SYN_LWM2M_FORMAT_CBOR

#define SYN_LWM2M_FORMAT_CBOR `11544U`

application/vnd.oma.lwm2m+cbor


define SYN_LWM2M_FORMAT_JSON

#define SYN_LWM2M_FORMAT_JSON `11543U`

application/vnd.oma.lwm2m+json


#define SYN_LWM2M_FORMAT_LINK_FORMAT `40U`

application/link-format


define SYN_LWM2M_FORMAT_OPAQUE

#define SYN_LWM2M_FORMAT_OPAQUE `42U`

application/octet-stream


define SYN_LWM2M_FORMAT_SENML_CBOR

#define SYN_LWM2M_FORMAT_SENML_CBOR `112U`

application/senml+cbor


define SYN_LWM2M_FORMAT_TEXT

#define SYN_LWM2M_FORMAT_TEXT `0U`

text/plain


define SYN_LWM2M_FORMAT_TLV

#define SYN_LWM2M_FORMAT_TLV `11542U`

application/vnd.oma.lwm2m+tlv


define SYN_LWM2M_MAX_OBJECTS

#define SYN_LWM2M_MAX_OBJECTS `16U`

Maximum registered objects per client


define SYN_LWM2M_MAX_OBSERVERS

#define SYN_LWM2M_MAX_OBSERVERS `8U`

Maximum active resource observations


define SYN_LWM2M_MAX_URI_PATH_LEN

#define SYN_LWM2M_MAX_URI_PATH_LEN `64U`

Max URI path buffer size


define SYN_LWM2M_OBJ_ACCESS_CONTROL

#define SYN_LWM2M_OBJ_ACCESS_CONTROL `2U`

Access Control Object


define SYN_LWM2M_OBJ_ACTUATION

#define SYN_LWM2M_OBJ_ACTUATION `3306U`

IPSO Actuation / Switch


define SYN_LWM2M_OBJ_CONNECTIVITY_MONITORING

#define SYN_LWM2M_OBJ_CONNECTIVITY_MONITORING `4U`

Connectivity Monitoring


define SYN_LWM2M_OBJ_CONNECTIVITY_STATS

#define SYN_LWM2M_OBJ_CONNECTIVITY_STATS `7U`

Connectivity Statistics


define SYN_LWM2M_OBJ_DEVICE

#define SYN_LWM2M_OBJ_DEVICE `3U`

Device Object


define SYN_LWM2M_OBJ_FIRMWARE_UPDATE

#define SYN_LWM2M_OBJ_FIRMWARE_UPDATE `5U`

Firmware Update Object


define SYN_LWM2M_OBJ_GENERIC_SENSOR

#define SYN_LWM2M_OBJ_GENERIC_SENSOR `3300U`

IPSO Generic Sensor


define SYN_LWM2M_OBJ_HUMIDITY

#define SYN_LWM2M_OBJ_HUMIDITY `3304U`

IPSO Humidity Sensor


define SYN_LWM2M_OBJ_LOCATION

#define SYN_LWM2M_OBJ_LOCATION `6U`

Location Object


define SYN_LWM2M_OBJ_SECURITY

#define SYN_LWM2M_OBJ_SECURITY `0U`

LwM2M Security Object


define SYN_LWM2M_OBJ_SERVER

#define SYN_LWM2M_OBJ_SERVER `1U`

LwM2M Server Object


define SYN_LWM2M_OBJ_TEMPERATURE

#define SYN_LWM2M_OBJ_TEMPERATURE `3303U`

IPSO Temperature Sensor


define SYN_LWM2M_OP_E

#define SYN_LWM2M_OP_E `0x04U`

Execute operation allowed


define SYN_LWM2M_OP_NONE

#define SYN_LWM2M_OP_NONE `0x00U`

No access permitted


define SYN_LWM2M_OP_R

#define SYN_LWM2M_OP_R `0x01U`

Read operation allowed


define SYN_LWM2M_OP_RW

#define SYN_LWM2M_OP_RW `( SYN_LWM2M_OP_R | SYN_LWM2M_OP_W )`

Read/Write allowed


define SYN_LWM2M_OP_W

#define SYN_LWM2M_OP_W `0x02U`

Write operation allowed



The documentation for this class was generated from the following file src/syntropic/proto/syn_lwm2m.h