File syn_coap.h¶
FileList > net > syn_coap.h
Go to the source code of this file
Constrained Application Protocol (CoAP - RFC 7252) implementation.
#include "../common/syn_defs.h"#include "../port/syn_port_socket.h"#include "../pt/syn_pt.h"#include "../sched/syn_task.h"#include "../util/syn_backoff.h"#include <stdbool.h>#include <stddef.h>#include <stdint.h>
Classes¶
| Type | Name |
|---|---|
| struct | SYN_CoapMsg Parsed or to-be-serialized CoAP message header. |
| struct | SYN_CoapOption Single CoAP option (number + opaque value). |
| struct | SYN_CoapRequest CoAP client request context. |
Public Functions¶
| Type | Name |
|---|---|
| SYN_Status | syn_coap_parse (SYN_CoapMsg * msg, SYN_CoapOption * options, size_t max_options, size_t * option_count, const uint8_t * buf, size_t buf_len) Parse a raw CoAP packet into a message structure. |
| void | syn_coap_request_init (SYN_CoapRequest * r, const SYN_SockAddr * server_addr, const SYN_CoapMsg * msg, uint32_t timeout_ms, uint8_t retries) Initialize a CoAP request context. |
| SYN_PT_Status | syn_coap_request_task (SYN_PT * pt, SYN_Task * task) Cooperative protothread task to execute a CoAP client request. |
| size_t | syn_coap_serialize (const SYN_CoapMsg * msg, const SYN_CoapOption * options, size_t option_count, uint8_t * buf, size_t max_buf_len) Serialize a CoAP message into a byte buffer. |
Macros¶
| Type | Name |
|---|---|
| define | COAP_VERSION 1 |
Public Functions Documentation¶
function syn_coap_parse¶
Parse a raw CoAP packet into a message structure.
SYN_Status syn_coap_parse (
SYN_CoapMsg * msg,
SYN_CoapOption * options,
size_t max_options,
size_t * option_count,
const uint8_t * buf,
size_t buf_len
)
Parameters:
msg[out] Parsed message header.options[out] Array to receive parsed options.max_optionsCapacity of the options array.option_count[out] Number of options actually parsed.bufRaw packet buffer.buf_lenLength of the raw packet in bytes.
Returns:
SYN_OK on success, SYN_ERROR on malformed input.
function syn_coap_request_init¶
Initialize a CoAP request context.
void syn_coap_request_init (
SYN_CoapRequest * r,
const SYN_SockAddr * server_addr,
const SYN_CoapMsg * msg,
uint32_t timeout_ms,
uint8_t retries
)
Parameters:
rRequest context.server_addrTarget server address.msgRequest header/token/payload.timeout_msInitial retransmit timeout (ms).retriesMaximum number of retransmissions.
function syn_coap_request_task¶
Cooperative protothread task to execute a CoAP client request.
Parameters:
ptProtothread state.taskScheduler task (user_data must point to a SYN_CoapRequest).
Returns:
Protothread status.
function syn_coap_serialize¶
Serialize a CoAP message into a byte buffer.
size_t syn_coap_serialize (
const SYN_CoapMsg * msg,
const SYN_CoapOption * options,
size_t option_count,
uint8_t * buf,
size_t max_buf_len
)
Parameters:
msgMessage header to serialize.optionsOptions array (will be sorted by option number).option_countNumber of options.buf[out] Destination buffer.max_buf_lenCapacity of the destination buffer.
Returns:
Number of bytes written, or 0 on error (buffer too small).
Macro Definition Documentation¶
define COAP_VERSION¶
CoAP protocol version
The documentation for this class was generated from the following file src/syntropic/net/syn_coap.h