CoAP#

This module includes functions that control CoAP communication.

The functions in this module are available when CoAP API feature (OPENTHREAD_CONFIG_COAP_API_ENABLE) is enabled.

Modules#

otCoapOption

otCoapOptionIterator

otCoapResource

otCoapBlockwiseResource

otCoapTxParameters

Enumerations#

enum
OT_COAP_TYPE_CONFIRMABLE = 0
OT_COAP_TYPE_NON_CONFIRMABLE = 1
OT_COAP_TYPE_ACKNOWLEDGMENT = 2
OT_COAP_TYPE_RESET = 3
}

CoAP Type values (2 bit unsigned integer).

enum
OT_COAP_CODE_EMPTY = OT_COAP_CODE(0, 0)
OT_COAP_CODE_GET = OT_COAP_CODE(0, 1)
OT_COAP_CODE_POST = OT_COAP_CODE(0, 2)
OT_COAP_CODE_PUT = OT_COAP_CODE(0, 3)
OT_COAP_CODE_DELETE = OT_COAP_CODE(0, 4)
OT_COAP_CODE_RESPONSE_MIN = OT_COAP_CODE(2, 0)
OT_COAP_CODE_CREATED = OT_COAP_CODE(2, 1)
OT_COAP_CODE_DELETED = OT_COAP_CODE(2, 2)
OT_COAP_CODE_VALID = OT_COAP_CODE(2, 3)
OT_COAP_CODE_CHANGED = OT_COAP_CODE(2, 4)
OT_COAP_CODE_CONTENT = OT_COAP_CODE(2, 5)
OT_COAP_CODE_CONTINUE = OT_COAP_CODE(2, 31)
OT_COAP_CODE_BAD_REQUEST = OT_COAP_CODE(4, 0)
OT_COAP_CODE_UNAUTHORIZED = OT_COAP_CODE(4, 1)
OT_COAP_CODE_BAD_OPTION = OT_COAP_CODE(4, 2)
OT_COAP_CODE_FORBIDDEN = OT_COAP_CODE(4, 3)
OT_COAP_CODE_NOT_FOUND = OT_COAP_CODE(4, 4)
OT_COAP_CODE_METHOD_NOT_ALLOWED = OT_COAP_CODE(4, 5)
OT_COAP_CODE_NOT_ACCEPTABLE = OT_COAP_CODE(4, 6)
OT_COAP_CODE_REQUEST_INCOMPLETE = OT_COAP_CODE(4, 8)
OT_COAP_CODE_PRECONDITION_FAILED = OT_COAP_CODE(4, 12)
OT_COAP_CODE_REQUEST_TOO_LARGE = OT_COAP_CODE(4, 13)
OT_COAP_CODE_UNSUPPORTED_FORMAT = OT_COAP_CODE(4, 15)
OT_COAP_CODE_INTERNAL_ERROR = OT_COAP_CODE(5, 0)
OT_COAP_CODE_NOT_IMPLEMENTED = OT_COAP_CODE(5, 1)
OT_COAP_CODE_BAD_GATEWAY = OT_COAP_CODE(5, 2)
OT_COAP_CODE_SERVICE_UNAVAILABLE = OT_COAP_CODE(5, 3)
OT_COAP_CODE_GATEWAY_TIMEOUT = OT_COAP_CODE(5, 4)
OT_COAP_CODE_PROXY_NOT_SUPPORTED = OT_COAP_CODE(5, 5)
}

CoAP Code values.

enum
OT_COAP_OPTION_IF_MATCH = 1
OT_COAP_OPTION_URI_HOST = 3
OT_COAP_OPTION_E_TAG = 4
OT_COAP_OPTION_IF_NONE_MATCH = 5
OT_COAP_OPTION_OBSERVE = 6
OT_COAP_OPTION_URI_PORT = 7
OT_COAP_OPTION_LOCATION_PATH = 8
OT_COAP_OPTION_URI_PATH = 11
OT_COAP_OPTION_CONTENT_FORMAT = 12
OT_COAP_OPTION_MAX_AGE = 14
OT_COAP_OPTION_URI_QUERY = 15
OT_COAP_OPTION_ACCEPT = 17
OT_COAP_OPTION_LOCATION_QUERY = 20
OT_COAP_OPTION_BLOCK2 = 23
OT_COAP_OPTION_BLOCK1 = 27
OT_COAP_OPTION_SIZE2 = 28
OT_COAP_OPTION_PROXY_URI = 35
OT_COAP_OPTION_PROXY_SCHEME = 39
OT_COAP_OPTION_SIZE1 = 60
}

CoAP Option Numbers.

enum
OT_COAP_OPTION_CONTENT_FORMAT_TEXT_PLAIN = 0
OT_COAP_OPTION_CONTENT_FORMAT_COSE_ENCRYPT0 = 16
OT_COAP_OPTION_CONTENT_FORMAT_COSE_MAC0 = 17
OT_COAP_OPTION_CONTENT_FORMAT_COSE_SIGN1 = 18
OT_COAP_OPTION_CONTENT_FORMAT_LINK_FORMAT = 40
OT_COAP_OPTION_CONTENT_FORMAT_XML = 41
OT_COAP_OPTION_CONTENT_FORMAT_OCTET_STREAM = 42
OT_COAP_OPTION_CONTENT_FORMAT_EXI = 47
OT_COAP_OPTION_CONTENT_FORMAT_JSON = 50
OT_COAP_OPTION_CONTENT_FORMAT_JSON_PATCH_JSON = 51
OT_COAP_OPTION_CONTENT_FORMAT_MERGE_PATCH_JSON = 52
OT_COAP_OPTION_CONTENT_FORMAT_CBOR = 60
OT_COAP_OPTION_CONTENT_FORMAT_CWT = 61
OT_COAP_OPTION_CONTENT_FORMAT_COSE_ENCRYPT = 96
OT_COAP_OPTION_CONTENT_FORMAT_COSE_MAC = 97
OT_COAP_OPTION_CONTENT_FORMAT_COSE_SIGN = 98
OT_COAP_OPTION_CONTENT_FORMAT_COSE_KEY = 101
OT_COAP_OPTION_CONTENT_FORMAT_COSE_KEY_SET = 102
OT_COAP_OPTION_CONTENT_FORMAT_SENML_JSON = 110
OT_COAP_OPTION_CONTENT_FORMAT_SENSML_JSON = 111
OT_COAP_OPTION_CONTENT_FORMAT_SENML_CBOR = 112
OT_COAP_OPTION_CONTENT_FORMAT_SENSML_CBOR = 113
OT_COAP_OPTION_CONTENT_FORMAT_SENML_EXI = 114
OT_COAP_OPTION_CONTENT_FORMAT_SENSML_EXI = 115
OT_COAP_OPTION_CONTENT_FORMAT_COAP_GROUP_JSON = 256
OT_COAP_OPTION_CONTENT_FORMAT_SENML_XML = 310
OT_COAP_OPTION_CONTENT_FORMAT_SENSML_XML = 311
}

CoAP Content Format codes.

enum
OT_COAP_OPTION_BLOCK_SZX_16 = 0
OT_COAP_OPTION_BLOCK_SZX_32 = 1
OT_COAP_OPTION_BLOCK_SZX_64 = 2
OT_COAP_OPTION_BLOCK_SZX_128 = 3
OT_COAP_OPTION_BLOCK_SZX_256 = 4
OT_COAP_OPTION_BLOCK_SZX_512 = 5
OT_COAP_OPTION_BLOCK_SZX_1024 = 6
}

CoAP Block Size Exponents.

Typedefs#

typedef enum otCoapType

CoAP Type values (2 bit unsigned integer).

typedef enum otCoapCode

CoAP Code values.

typedef enum otCoapOptionType

CoAP Option Numbers.

typedef struct otCoapOption

Represents a CoAP option.

typedef struct otCoapOptionIterator

Acts as an iterator for CoAP options.

CoAP Content Format codes.

typedef enum otCoapBlockSzx

CoAP Block Size Exponents.

typedef void(*
otCoapResponseHandler)(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo, otError aResult)

Pointer is called when a CoAP response is received or on the request timeout.

typedef void(*
otCoapRequestHandler)(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo)

Pointer is called when a CoAP request with a given Uri-Path is received.

typedef otError(*
otCoapBlockwiseReceiveHook)(void *aContext, const uint8_t *aBlock, uint32_t aPosition, uint16_t aBlockLength, bool aMore, uint32_t aTotalLength)

Pointer is called when a CoAP message with a block-wise transfer option is received.

typedef otError(*
otCoapBlockwiseTransmitHook)(void *aContext, uint8_t *aBlock, uint32_t aPosition, uint16_t *aBlockLength, bool *aMore)

Pointer is called before the next block in a block-wise transfer is sent.

typedef struct otCoapResource

Represents a CoAP resource.

Represents a CoAP resource with block-wise transfer.

typedef struct otCoapTxParameters

Represents the CoAP transmission parameters.

Functions#

void
otCoapMessageInit(otMessage *aMessage, otCoapType aType, otCoapCode aCode)

Initializes the CoAP header.

otCoapMessageInitResponse(otMessage *aResponse, const otMessage *aRequest, otCoapType aType, otCoapCode aCode)

Initializes a response message.

otCoapMessageSetToken(otMessage *aMessage, const uint8_t *aToken, uint8_t aTokenLength)

Sets the Token value and length in a header.

void
otCoapMessageGenerateToken(otMessage *aMessage, uint8_t aTokenLength)

Sets the Token length and randomizes its value.

otCoapMessageAppendContentFormatOption(otMessage *aMessage, otCoapOptionContentFormat aContentFormat)

Appends the Content Format CoAP option as specified in https://tools.ietf.org/html/rfc7252#page-92.

otCoapMessageAppendOption(otMessage *aMessage, uint16_t aNumber, uint16_t aLength, const void *aValue)

Appends a CoAP option in a header.

otCoapMessageAppendUintOption(otMessage *aMessage, uint16_t aNumber, uint32_t aValue)

Appends an unsigned integer CoAP option as specified in https://tools.ietf.org/html/rfc7252#section-3.2.

otCoapMessageAppendObserveOption(otMessage *aMessage, uint32_t aObserve)

Appends an Observe option.

otCoapMessageAppendUriPathOptions(otMessage *aMessage, const char *aUriPath)

Appends a Uri-Path option.

otCoapMessageAppendUriQueryOptions(otMessage *aMessage, const char *aUriQuery)

Appends a Uri-Query option.

uint16_t
otCoapBlockSizeFromExponent(otCoapBlockSzx aSize)

Converts a CoAP Block option SZX field to the actual block size.

otCoapMessageAppendBlock2Option(otMessage *aMessage, uint32_t aNum, bool aMore, otCoapBlockSzx aSize)

Appends a Block2 option.

otCoapMessageAppendBlock1Option(otMessage *aMessage, uint32_t aNum, bool aMore, otCoapBlockSzx aSize)

Appends a Block1 option.

otCoapMessageAppendProxyUriOption(otMessage *aMessage, const char *aUriPath)

Appends a Proxy-Uri option.

otCoapMessageAppendMaxAgeOption(otMessage *aMessage, uint32_t aMaxAge)

Appends a Max-Age option.

otCoapMessageAppendUriQueryOption(otMessage *aMessage, const char *aUriQuery)

Appends a single Uri-Query option.

otCoapMessageSetPayloadMarker(otMessage *aMessage)

Adds Payload Marker indicating beginning of the payload to the CoAP header.

otCoapMessageGetType(const otMessage *aMessage)

Returns the Type value.

otCoapMessageGetCode(const otMessage *aMessage)

Returns the Code value.

void
otCoapMessageSetCode(otMessage *aMessage, otCoapCode aCode)

Sets the Code value.

const char *
otCoapMessageCodeToString(const otMessage *aMessage)

Returns the CoAP Code as human readable string.

uint16_t
otCoapMessageGetMessageId(const otMessage *aMessage)

Returns the Message ID value.

uint8_t
otCoapMessageGetTokenLength(const otMessage *aMessage)

Returns the Token length.

const uint8_t *
otCoapMessageGetToken(const otMessage *aMessage)

Returns a pointer to the Token value.

otCoapOptionIteratorInit(otCoapOptionIterator *aIterator, const otMessage *aMessage)

Initialises an iterator for the options in the given message.

const otCoapOption *
otCoapOptionIteratorGetFirstOptionMatching(otCoapOptionIterator *aIterator, uint16_t aOption)

Returns a pointer to the first option matching the specified option number.

const otCoapOption *
otCoapOptionIteratorGetFirstOption(otCoapOptionIterator *aIterator)

Returns a pointer to the first option.

const otCoapOption *
otCoapOptionIteratorGetNextOptionMatching(otCoapOptionIterator *aIterator, uint16_t aOption)

Returns a pointer to the next option matching the specified option number.

const otCoapOption *
otCoapOptionIteratorGetNextOption(otCoapOptionIterator *aIterator)

Returns a pointer to the next option.

otCoapOptionIteratorGetOptionUintValue(otCoapOptionIterator *aIterator, uint64_t *aValue)

Fills current option value into aValue assuming the current value is an unsigned integer encoded according to https://tools.ietf.org/html/rfc7252#section-3.2.

otCoapOptionIteratorGetOptionValue(otCoapOptionIterator *aIterator, void *aValue)

Fills current option value into aValue.

otCoapNewMessage(otInstance *aInstance, const otMessageSettings *aSettings)

Creates a new CoAP message.

otCoapSendRequestWithParameters(otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo, otCoapResponseHandler aHandler, void *aContext, const otCoapTxParameters *aTxParameters)

Sends a CoAP request with custom transmission parameters.

otCoapSendRequestBlockWiseWithParameters(otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo, otCoapResponseHandler aHandler, void *aContext, const otCoapTxParameters *aTxParameters, otCoapBlockwiseTransmitHook aTransmitHook, otCoapBlockwiseReceiveHook aReceiveHook)

Sends a CoAP request block-wise with custom transmission parameters.

otCoapSendRequestBlockWise(otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo, otCoapResponseHandler aHandler, void *aContext, otCoapBlockwiseTransmitHook aTransmitHook, otCoapBlockwiseReceiveHook aReceiveHook)

Sends a CoAP request block-wise.

otCoapSendRequest(otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo, otCoapResponseHandler aHandler, void *aContext)

Sends a CoAP request.

otCoapStart(otInstance *aInstance, uint16_t aPort)

Starts the CoAP server.

otCoapStop(otInstance *aInstance)

Stops the CoAP server.

void
otCoapAddResource(otInstance *aInstance, otCoapResource *aResource)

Adds a resource to the CoAP server.

void
otCoapRemoveResource(otInstance *aInstance, otCoapResource *aResource)

Removes a resource from the CoAP server.

void
otCoapAddBlockWiseResource(otInstance *aInstance, otCoapBlockwiseResource *aResource)

Adds a block-wise resource to the CoAP server.

void
otCoapRemoveBlockWiseResource(otInstance *aInstance, otCoapBlockwiseResource *aResource)

Removes a block-wise resource from the CoAP server.

void
otCoapSetDefaultHandler(otInstance *aInstance, otCoapRequestHandler aHandler, void *aContext)

Sets the default handler for unhandled CoAP requests.

otCoapSendResponseWithParameters(otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo, const otCoapTxParameters *aTxParameters)

Sends a CoAP response from the server with custom transmission parameters.

otCoapSendResponseBlockWiseWithParameters(otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo, const otCoapTxParameters *aTxParameters, void *aContext, otCoapBlockwiseTransmitHook aTransmitHook)

Sends a CoAP response block-wise from the server with custom transmission parameters.

otCoapSendResponseBlockWise(otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo, void *aContext, otCoapBlockwiseTransmitHook aTransmitHook)

Sends a CoAP response block-wise from the server.

otCoapSendResponse(otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo)

Sends a CoAP response from the server.

Macros#

#define

Default CoAP port, as specified in RFC 7252.

#define

Default token length.

#define

Max token length as specified (RFC 7252).

#define

Max retransmit supported by OpenThread.

#define

Minimal ACK timeout in milliseconds supported by OpenThread.

#define

Helper macro to define CoAP Code values.

Enumeration Documentation#

otCoapType#

otCoapType

CoAP Type values (2 bit unsigned integer).

Enumerator
OT_COAP_TYPE_CONFIRMABLE

Confirmable.

OT_COAP_TYPE_NON_CONFIRMABLE

Non-confirmable.

OT_COAP_TYPE_ACKNOWLEDGMENT

Acknowledgment.

OT_COAP_TYPE_RESET

Reset.


Definition at line 71 of file include/openthread/coap.h

otCoapCode#

otCoapCode

CoAP Code values.

Enumerator
OT_COAP_CODE_EMPTY

Empty message code.

OT_COAP_CODE_GET

Get.

OT_COAP_CODE_POST

Post.

OT_COAP_CODE_PUT

Put.

OT_COAP_CODE_DELETE

Delete.

OT_COAP_CODE_RESPONSE_MIN

2.00

OT_COAP_CODE_CREATED

Created.

OT_COAP_CODE_DELETED

Deleted.

OT_COAP_CODE_VALID

Valid.

OT_COAP_CODE_CHANGED

Changed.

OT_COAP_CODE_CONTENT

Content.

OT_COAP_CODE_CONTINUE

RFC7959 Continue.

OT_COAP_CODE_BAD_REQUEST

Bad Request.

OT_COAP_CODE_UNAUTHORIZED

Unauthorized.

OT_COAP_CODE_BAD_OPTION

Bad Option.

OT_COAP_CODE_FORBIDDEN

Forbidden.

OT_COAP_CODE_NOT_FOUND

Not Found.

OT_COAP_CODE_METHOD_NOT_ALLOWED

Method Not Allowed.

OT_COAP_CODE_NOT_ACCEPTABLE

Not Acceptable.

OT_COAP_CODE_REQUEST_INCOMPLETE

RFC7959 Request Entity Incomplete.

OT_COAP_CODE_PRECONDITION_FAILED

Precondition Failed.

OT_COAP_CODE_REQUEST_TOO_LARGE

Request Entity Too Large.

OT_COAP_CODE_UNSUPPORTED_FORMAT

Unsupported Content-Format.

OT_COAP_CODE_INTERNAL_ERROR

Internal Server Error.

OT_COAP_CODE_NOT_IMPLEMENTED

Not Implemented.

OT_COAP_CODE_BAD_GATEWAY

Bad Gateway.

OT_COAP_CODE_SERVICE_UNAVAILABLE

Service Unavailable.

OT_COAP_CODE_GATEWAY_TIMEOUT

Gateway Timeout.

OT_COAP_CODE_PROXY_NOT_SUPPORTED

Proxying Not Supported.


Definition at line 87 of file include/openthread/coap.h

otCoapOptionType#

otCoapOptionType

CoAP Option Numbers.

Enumerator
OT_COAP_OPTION_IF_MATCH

If-Match.

OT_COAP_OPTION_URI_HOST

Uri-Host.

OT_COAP_OPTION_E_TAG

ETag.

OT_COAP_OPTION_IF_NONE_MATCH

If-None-Match.

OT_COAP_OPTION_OBSERVE

Observe [RFC7641].

OT_COAP_OPTION_URI_PORT

Uri-Port.

OT_COAP_OPTION_LOCATION_PATH

Location-Path.

OT_COAP_OPTION_URI_PATH

Uri-Path.

OT_COAP_OPTION_CONTENT_FORMAT

Content-Format.

OT_COAP_OPTION_MAX_AGE

Max-Age.

OT_COAP_OPTION_URI_QUERY

Uri-Query.

OT_COAP_OPTION_ACCEPT

Accept.

OT_COAP_OPTION_LOCATION_QUERY

Location-Query.

OT_COAP_OPTION_BLOCK2

Block2 (RFC7959)

OT_COAP_OPTION_BLOCK1

Block1 (RFC7959)

OT_COAP_OPTION_SIZE2

Size2 (RFC7959)

OT_COAP_OPTION_PROXY_URI

Proxy-Uri.

OT_COAP_OPTION_PROXY_SCHEME

Proxy-Scheme.

OT_COAP_OPTION_SIZE1

Size1.


Definition at line 126 of file include/openthread/coap.h

otCoapOptionContentFormat#

otCoapOptionContentFormat

CoAP Content Format codes.

The full list is documented at https://www.iana.org/assignments/core-parameters/core-parameters.xhtml#content-formats

Enumerator
OT_COAP_OPTION_CONTENT_FORMAT_TEXT_PLAIN

text/plain; charset=utf-8: [RFC2046][RFC3676][RFC5147]

OT_COAP_OPTION_CONTENT_FORMAT_COSE_ENCRYPT0

application/cose; cose-type="cose-encrypt0": [RFC8152]

OT_COAP_OPTION_CONTENT_FORMAT_COSE_MAC0

application/cose; cose-type="cose-mac0": [RFC8152]

OT_COAP_OPTION_CONTENT_FORMAT_COSE_SIGN1

application/cose; cose-type="cose-sign1": [RFC8152]

OT_COAP_OPTION_CONTENT_FORMAT_LINK_FORMAT

application/link-format: [RFC6690]

OT_COAP_OPTION_CONTENT_FORMAT_XML

application/xml: [RFC3023]

OT_COAP_OPTION_CONTENT_FORMAT_OCTET_STREAM

application/octet-stream: [RFC2045][RFC2046]

OT_COAP_OPTION_CONTENT_FORMAT_EXI

application/exi: ["Efficient XML Interchange (EXI) Format 1.0 (Second Edition)", February 2014]

OT_COAP_OPTION_CONTENT_FORMAT_JSON

application/json: [RFC7159]

OT_COAP_OPTION_CONTENT_FORMAT_JSON_PATCH_JSON

application/json-patch+json: [RFC6902]

OT_COAP_OPTION_CONTENT_FORMAT_MERGE_PATCH_JSON

application/merge-patch+json: [RFC7396]

OT_COAP_OPTION_CONTENT_FORMAT_CBOR

application/cbor: [RFC7049]

OT_COAP_OPTION_CONTENT_FORMAT_CWT

application/cwt: [RFC8392]

OT_COAP_OPTION_CONTENT_FORMAT_COSE_ENCRYPT

application/cose; cose-type="cose-encrypt": [RFC8152]

OT_COAP_OPTION_CONTENT_FORMAT_COSE_MAC

application/cose; cose-type="cose-mac": [RFC8152]

OT_COAP_OPTION_CONTENT_FORMAT_COSE_SIGN

application/cose; cose-type="cose-sign": [RFC8152]

OT_COAP_OPTION_CONTENT_FORMAT_COSE_KEY

application/cose-key: [RFC8152]

OT_COAP_OPTION_CONTENT_FORMAT_COSE_KEY_SET

application/cose-key-set: [RFC8152]

OT_COAP_OPTION_CONTENT_FORMAT_SENML_JSON

application/senml+json: [RFC8428]

OT_COAP_OPTION_CONTENT_FORMAT_SENSML_JSON

application/sensml+json: [RFC8428]

OT_COAP_OPTION_CONTENT_FORMAT_SENML_CBOR

application/senml+cbor: [RFC8428]

OT_COAP_OPTION_CONTENT_FORMAT_SENSML_CBOR

application/sensml+cbor: [RFC8428]

OT_COAP_OPTION_CONTENT_FORMAT_SENML_EXI

application/senml-exi: [RFC8428]

OT_COAP_OPTION_CONTENT_FORMAT_SENSML_EXI

application/sensml-exi: [RFC8428]

OT_COAP_OPTION_CONTENT_FORMAT_COAP_GROUP_JSON

application/coap-group+json: [RFC7390]

OT_COAP_OPTION_CONTENT_FORMAT_SENML_XML

application/senml+xml: [RFC8428]

OT_COAP_OPTION_CONTENT_FORMAT_SENSML_XML

application/sensml+xml: [RFC8428]


Definition at line 172 of file include/openthread/coap.h

otCoapBlockSzx#

otCoapBlockSzx

CoAP Block Size Exponents.

Enumerator
OT_COAP_OPTION_BLOCK_SZX_16
OT_COAP_OPTION_BLOCK_SZX_32
OT_COAP_OPTION_BLOCK_SZX_64
OT_COAP_OPTION_BLOCK_SZX_128
OT_COAP_OPTION_BLOCK_SZX_256
OT_COAP_OPTION_BLOCK_SZX_512
OT_COAP_OPTION_BLOCK_SZX_1024

Definition at line 314 of file include/openthread/coap.h

Typedef Documentation#

otCoapType#

typedef enum otCoapType otCoapType

CoAP Type values (2 bit unsigned integer).


Definition at line 77 of file include/openthread/coap.h

otCoapCode#

typedef enum otCoapCode otCoapCode

CoAP Code values.


Definition at line 121 of file include/openthread/coap.h

otCoapOptionType#

typedef enum otCoapOptionType otCoapOptionType

CoAP Option Numbers.


Definition at line 147 of file include/openthread/coap.h

otCoapOption#

typedef struct otCoapOption otCoapOption

Represents a CoAP option.


Definition at line 156 of file include/openthread/coap.h

otCoapOptionIterator#

typedef struct otCoapOptionIterator otCoapOptionIterator

Acts as an iterator for CoAP options.


Definition at line 166 of file include/openthread/coap.h

otCoapOptionContentFormat#

typedef enum otCoapOptionContentFormat otCoapOptionContentFormat

CoAP Content Format codes.

The full list is documented at https://www.iana.org/assignments/core-parameters/core-parameters.xhtml#content-formats


Definition at line 309 of file include/openthread/coap.h

otCoapBlockSzx#

typedef enum otCoapBlockSzx otCoapBlockSzx

CoAP Block Size Exponents.


Definition at line 323 of file include/openthread/coap.h

otCoapResponseHandler#

typedef void(* otCoapResponseHandler) (void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo, otError aResult) )(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo, otError aResult)

Pointer is called when a CoAP response is received or on the request timeout.

Parameters
[in]aContext

A pointer to application-specific context.

[in]aMessage

A pointer to the message buffer containing the response. NULL if no response was received.

[in]aMessageInfo

A pointer to the message info for aMessage. NULL if no response was received.

[in]aResult

A result of the CoAP transaction.


Definition at line 337 of file include/openthread/coap.h

otCoapRequestHandler#

typedef void(* otCoapRequestHandler) (void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo) )(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo)

Pointer is called when a CoAP request with a given Uri-Path is received.

Parameters
[in]aContext

A pointer to arbitrary context information.

[in]aMessage

A pointer to the message.

[in]aMessageInfo

A pointer to the message info for aMessage.


Definition at line 349 of file include/openthread/coap.h

otCoapBlockwiseReceiveHook#

typedef otError(* otCoapBlockwiseReceiveHook) (void *aContext, const uint8_t *aBlock, uint32_t aPosition, uint16_t aBlockLength, bool aMore, uint32_t aTotalLength) )(void *aContext, const uint8_t *aBlock, uint32_t aPosition, uint16_t aBlockLength, bool aMore, uint32_t aTotalLength)

Pointer is called when a CoAP message with a block-wise transfer option is received.

Parameters
[in]aContext

A pointer to application-specific context.

[in]aBlock

A pointer to the block segment.

[in]aPosition

The position of aBlock in a sequence in bytes.

[in]aBlockLength

The length of the block segment in bytes.

[in]aMore

Flag if more block segments are following.

[in]aTotalLength

The total length in bytes of the transferred information (indicated by a Size1 or Size2 option).

Is available when OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE configuration is enabled.


Definition at line 369 of file include/openthread/coap.h

otCoapBlockwiseTransmitHook#

typedef otError(* otCoapBlockwiseTransmitHook) (void *aContext, uint8_t *aBlock, uint32_t aPosition, uint16_t *aBlockLength, bool *aMore) )(void *aContext, uint8_t *aBlock, uint32_t aPosition, uint16_t *aBlockLength, bool *aMore)

Pointer is called before the next block in a block-wise transfer is sent.

Parameters
[in]aContext

A pointer to application-specific context.

[inout]aBlock

A pointer to where the block segment can be written to.

[in]aPosition

The position in a sequence from which to obtain the block segment.

[inout]aBlockLength

On entry, the maximum block segment length in bytes.

[out]aMore

A pointer to the flag if more block segments will follow.

Is available when OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE configuration is enabled.

Warnings

  • By changing the value of aBlockLength, the block size of the whole exchange is renegotiated. It is recommended to do this after the first block has been received as later changes could cause problems with other CoAP implementations.


Definition at line 395 of file include/openthread/coap.h

otCoapResource#

typedef struct otCoapResource otCoapResource

Represents a CoAP resource.


Definition at line 410 of file include/openthread/coap.h

otCoapBlockwiseResource#

typedef struct otCoapBlockwiseResource otCoapBlockwiseResource

Represents a CoAP resource with block-wise transfer.


Definition at line 433 of file include/openthread/coap.h

otCoapTxParameters#

typedef struct otCoapTxParameters otCoapTxParameters

Represents the CoAP transmission parameters.

Note

  • mAckTimeout * ((2 ** (mMaxRetransmit + 1)) - 1) * (mAckRandomFactorNumerator / mAckRandomFactorDenominator) must not exceed what can be represented by a uint32_t (0xffffffff). This limitation allows OpenThread to avoid 64-bit arithmetic.


Definition at line 466 of file include/openthread/coap.h

Function Documentation#

otCoapMessageInit#

void otCoapMessageInit (otMessage * aMessage, otCoapType aType, otCoapCode aCode)

Initializes the CoAP header.

Parameters
[inout]aMessage

A pointer to the CoAP message to initialize.

[in]aType

CoAP message type.

[in]aCode

CoAP message code.


Definition at line 475 of file include/openthread/coap.h

otCoapMessageInitResponse#

otError otCoapMessageInitResponse (otMessage * aResponse, const otMessage * aRequest, otCoapType aType, otCoapCode aCode)

Initializes a response message.

Parameters
[inout]aResponse

A pointer to the CoAP response message.

[in]aRequest

A pointer to the CoAP request message.

[in]aType

CoAP message type.

[in]aCode

CoAP message code.

Note

  • Both message ID and token are set according to aRequest.


Definition at line 490 of file include/openthread/coap.h

otCoapMessageSetToken#

otError otCoapMessageSetToken (otMessage * aMessage, const uint8_t * aToken, uint8_t aTokenLength)

Sets the Token value and length in a header.

Parameters
[inout]aMessage

A pointer to the CoAP message.

[in]aToken

A pointer to the Token value.

[in]aTokenLength

The Length of aToken.


Definition at line 502 of file include/openthread/coap.h

otCoapMessageGenerateToken#

void otCoapMessageGenerateToken (otMessage * aMessage, uint8_t aTokenLength)

Sets the Token length and randomizes its value.

Parameters
[inout]aMessage

A pointer to the CoAP message.

[in]aTokenLength

The Length of a Token to set.


Definition at line 510 of file include/openthread/coap.h

otCoapMessageAppendContentFormatOption#

otError otCoapMessageAppendContentFormatOption (otMessage * aMessage, otCoapOptionContentFormat aContentFormat)

Appends the Content Format CoAP option as specified in https://tools.ietf.org/html/rfc7252#page-92.

Parameters
[inout]aMessage

A pointer to the CoAP message.

[in]aContentFormat

One of the content formats listed in otCoapOptionContentFormat above.

This must be called before setting otCoapMessageSetPayloadMarker if a payload is to be included in the message.

The function is a convenience wrapper around otCoapMessageAppendUintOption, and if the desired format type code isn't listed in otCoapOptionContentFormat, this base function should be used instead.


Definition at line 530 of file include/openthread/coap.h

otCoapMessageAppendOption#

otError otCoapMessageAppendOption (otMessage * aMessage, uint16_t aNumber, uint16_t aLength, const void * aValue)

Appends a CoAP option in a header.

Parameters
[inout]aMessage

A pointer to the CoAP message.

[in]aNumber

The CoAP Option number.

[in]aLength

The CoAP Option length.

[in]aValue

A pointer to the CoAP value.


Definition at line 544 of file include/openthread/coap.h

otCoapMessageAppendUintOption#

otError otCoapMessageAppendUintOption (otMessage * aMessage, uint16_t aNumber, uint32_t aValue)

Appends an unsigned integer CoAP option as specified in https://tools.ietf.org/html/rfc7252#section-3.2.

Parameters
[inout]aMessage

A pointer to the CoAP message.

[in]aNumber

The CoAP Option number.

[in]aValue

The CoAP Option unsigned integer value.

See Also

  • otCoapMessageGetOptionUintValue


Definition at line 560 of file include/openthread/coap.h

otCoapMessageAppendObserveOption#

otError otCoapMessageAppendObserveOption (otMessage * aMessage, uint32_t aObserve)

Appends an Observe option.

Parameters
[inout]aMessage

A pointer to the CoAP message.

[in]aObserve

Observe field value.


Definition at line 572 of file include/openthread/coap.h

otCoapMessageAppendUriPathOptions#

otError otCoapMessageAppendUriPathOptions (otMessage * aMessage, const char * aUriPath)

Appends a Uri-Path option.

Parameters
[inout]aMessage

A pointer to the CoAP message.

[in]aUriPath

A pointer to a NULL-terminated string.


Definition at line 584 of file include/openthread/coap.h

otCoapMessageAppendUriQueryOptions#

otError otCoapMessageAppendUriQueryOptions (otMessage * aMessage, const char * aUriQuery)

Appends a Uri-Query option.

Parameters
[inout]aMessage

A pointer to the CoAP message.

[in]aUriQuery

A pointer to a NULL-terminated string.


Definition at line 596 of file include/openthread/coap.h

otCoapBlockSizeFromExponent#

uint16_t otCoapBlockSizeFromExponent (otCoapBlockSzx aSize)

Converts a CoAP Block option SZX field to the actual block size.

Parameters
[in]aSize

Block size exponent.

Returns

  • The actual size exponent value.


Definition at line 605 of file include/openthread/coap.h

otCoapMessageAppendBlock2Option#

otError otCoapMessageAppendBlock2Option (otMessage * aMessage, uint32_t aNum, bool aMore, otCoapBlockSzx aSize)

Appends a Block2 option.

Parameters
[inout]aMessage

A pointer to the CoAP message.

[in]aNum

Current block number.

[in]aMore

Boolean to indicate more blocks are to be sent.

[in]aSize

Block Size Exponent.


Definition at line 619 of file include/openthread/coap.h

otCoapMessageAppendBlock1Option#

otError otCoapMessageAppendBlock1Option (otMessage * aMessage, uint32_t aNum, bool aMore, otCoapBlockSzx aSize)

Appends a Block1 option.

Parameters
[inout]aMessage

A pointer to the CoAP message.

[in]aNum

Current block number.

[in]aMore

Boolean to indicate more blocks are to be sent.

[in]aSize

Block Size Exponent.


Definition at line 633 of file include/openthread/coap.h

otCoapMessageAppendProxyUriOption#

otError otCoapMessageAppendProxyUriOption (otMessage * aMessage, const char * aUriPath)

Appends a Proxy-Uri option.

Parameters
[inout]aMessage

A pointer to the CoAP message.

[in]aUriPath

A pointer to a NULL-terminated string.


Definition at line 645 of file include/openthread/coap.h

otCoapMessageAppendMaxAgeOption#

otError otCoapMessageAppendMaxAgeOption (otMessage * aMessage, uint32_t aMaxAge)

Appends a Max-Age option.

Parameters
[inout]aMessage

A pointer to the CoAP message.

[in]aMaxAge

The Max-Age value.


Definition at line 657 of file include/openthread/coap.h

otCoapMessageAppendUriQueryOption#

otError otCoapMessageAppendUriQueryOption (otMessage * aMessage, const char * aUriQuery)

Appends a single Uri-Query option.

Parameters
[inout]aMessage

A pointer to the CoAP message.

[in]aUriQuery

A pointer to NULL-terminated string, which should contain a single key=value pair.


Definition at line 669 of file include/openthread/coap.h

otCoapMessageSetPayloadMarker#

otError otCoapMessageSetPayloadMarker (otMessage * aMessage)

Adds Payload Marker indicating beginning of the payload to the CoAP header.

Parameters
[inout]aMessage

A pointer to the CoAP message.


Definition at line 679 of file include/openthread/coap.h

otCoapMessageGetType#

otCoapType otCoapMessageGetType (const otMessage * aMessage)

Returns the Type value.

Parameters
[in]aMessage

A pointer to the CoAP message.

Returns

  • The Type value.


Definition at line 688 of file include/openthread/coap.h

otCoapMessageGetCode#

otCoapCode otCoapMessageGetCode (const otMessage * aMessage)

Returns the Code value.

Parameters
[in]aMessage

A pointer to the CoAP message.

Returns

  • The Code value.


Definition at line 697 of file include/openthread/coap.h

otCoapMessageSetCode#

void otCoapMessageSetCode (otMessage * aMessage, otCoapCode aCode)

Sets the Code value.

Parameters
[inout]aMessage

A pointer to the CoAP message to initialize.

[in]aCode

CoAP message code.


Definition at line 705 of file include/openthread/coap.h

otCoapMessageCodeToString#

const char * otCoapMessageCodeToString (const otMessage * aMessage)

Returns the CoAP Code as human readable string.

Parameters
[in]aMessage

A pointer to the CoAP message.

@ returns The CoAP Code as string.


Definition at line 714 of file include/openthread/coap.h

otCoapMessageGetMessageId#

uint16_t otCoapMessageGetMessageId (const otMessage * aMessage)

Returns the Message ID value.

Parameters
[in]aMessage

A pointer to the CoAP message.

Returns

  • The Message ID value.


Definition at line 723 of file include/openthread/coap.h

otCoapMessageGetTokenLength#

uint8_t otCoapMessageGetTokenLength (const otMessage * aMessage)

Returns the Token length.

Parameters
[in]aMessage

A pointer to the CoAP message.

Returns

  • The Token length.


Definition at line 732 of file include/openthread/coap.h

otCoapMessageGetToken#

const uint8_t * otCoapMessageGetToken (const otMessage * aMessage)

Returns a pointer to the Token value.

Parameters
[in]aMessage

A pointer to the CoAP message.

Returns

  • A pointer to the Token value.


Definition at line 741 of file include/openthread/coap.h

otCoapOptionIteratorInit#

otError otCoapOptionIteratorInit (otCoapOptionIterator * aIterator, const otMessage * aMessage)

Initialises an iterator for the options in the given message.

Parameters
[inout]aIterator

A pointer to the CoAP message option iterator.

[in]aMessage

A pointer to the CoAP message.


Definition at line 752 of file include/openthread/coap.h

otCoapOptionIteratorGetFirstOptionMatching#

const otCoapOption * otCoapOptionIteratorGetFirstOptionMatching (otCoapOptionIterator * aIterator, uint16_t aOption)

Returns a pointer to the first option matching the specified option number.

Parameters
[in]aIterator

A pointer to the CoAP message option iterator.

[in]aOption

The option number sought.

Returns

  • A pointer to the first matching option. If no matching option is present NULL pointer is returned.


Definition at line 762 of file include/openthread/coap.h

otCoapOptionIteratorGetFirstOption#

const otCoapOption * otCoapOptionIteratorGetFirstOption (otCoapOptionIterator * aIterator)

Returns a pointer to the first option.

Parameters
[inout]aIterator

A pointer to the CoAP message option iterator.

Returns

  • A pointer to the first option. If no option is present NULL pointer is returned.


Definition at line 771 of file include/openthread/coap.h

otCoapOptionIteratorGetNextOptionMatching#

const otCoapOption * otCoapOptionIteratorGetNextOptionMatching (otCoapOptionIterator * aIterator, uint16_t aOption)

Returns a pointer to the next option matching the specified option number.

Parameters
[in]aIterator

A pointer to the CoAP message option iterator.

[in]aOption

The option number sought.

Returns

  • A pointer to the next matching option. If no further matching option is present NULL pointer is returned.


Definition at line 781 of file include/openthread/coap.h

otCoapOptionIteratorGetNextOption#

const otCoapOption * otCoapOptionIteratorGetNextOption (otCoapOptionIterator * aIterator)

Returns a pointer to the next option.

Parameters
[inout]aIterator

A pointer to the CoAP message option iterator.

Returns

  • A pointer to the next option. If no more options are present NULL pointer is returned.


Definition at line 790 of file include/openthread/coap.h

otCoapOptionIteratorGetOptionUintValue#

otError otCoapOptionIteratorGetOptionUintValue (otCoapOptionIterator * aIterator, uint64_t * aValue)

Fills current option value into aValue assuming the current value is an unsigned integer encoded according to https://tools.ietf.org/html/rfc7252#section-3.2.

Parameters
[inout]aIterator

A pointer to the CoAP message option iterator.

[out]aValue

A pointer to an unsigned integer to receive the option value.

See Also


Definition at line 805 of file include/openthread/coap.h

otCoapOptionIteratorGetOptionValue#

otError otCoapOptionIteratorGetOptionValue (otCoapOptionIterator * aIterator, void * aValue)

Fills current option value into aValue.

Parameters
[inout]aIterator

A pointer to the CoAP message option iterator.

[out]aValue

A pointer to a buffer to receive the option value.


Definition at line 816 of file include/openthread/coap.h

otCoapNewMessage#

otMessage * otCoapNewMessage (otInstance * aInstance, const otMessageSettings * aSettings)

Creates a new CoAP message.

Parameters
[in]aInstance

A pointer to an OpenThread instance.

[in]aSettings

A pointer to the message settings or NULL to set default settings.

Note

  • If aSettings is 'NULL', the link layer security is enabled and the message priority is set to OT_MESSAGE_PRIORITY_NORMAL by default.

Returns

  • A pointer to the message buffer or NULL if no message buffers are available or parameters are invalid.


Definition at line 829 of file include/openthread/coap.h

otCoapSendRequestWithParameters#

otError otCoapSendRequestWithParameters (otInstance * aInstance, otMessage * aMessage, const otMessageInfo * aMessageInfo, otCoapResponseHandler aHandler, void * aContext, const otCoapTxParameters * aTxParameters)

Sends a CoAP request with custom transmission parameters.

Parameters
[in]aInstance

A pointer to an OpenThread instance.

[in]aMessage

A pointer to the message to send.

[in]aMessageInfo

A pointer to the message info associated with aMessage.

[in]aHandler

A function pointer that shall be called on response reception or timeout.

[in]aContext

A pointer to arbitrary context information. May be NULL if not used.

[in]aTxParameters

A pointer to transmission parameters for this request. Use NULL for defaults. Otherwise, parameters given must meet the following conditions:

  1. mMaxRetransmit is no more than OT_COAP_MAX_RETRANSMIT.

  2. mAckRandomFactorNumerator / mAckRandomFactorDenominator must not be below 1.0.

  3. The calculated exchange life time must not overflow uint32_t.

If a response for a request is expected, respective function and context information should be provided. If no response is expected, these arguments should be NULL pointers.


Definition at line 852 of file include/openthread/coap.h

otCoapSendRequestBlockWiseWithParameters#

otError otCoapSendRequestBlockWiseWithParameters (otInstance * aInstance, otMessage * aMessage, const otMessageInfo * aMessageInfo, otCoapResponseHandler aHandler, void * aContext, const otCoapTxParameters * aTxParameters, otCoapBlockwiseTransmitHook aTransmitHook, otCoapBlockwiseReceiveHook aReceiveHook)

Sends a CoAP request block-wise with custom transmission parameters.

Parameters
[in]aInstance

A pointer to an OpenThread instance.

[in]aMessage

A pointer to the message to send.

[in]aMessageInfo

A pointer to the message info associated with aMessage.

[in]aHandler

A function pointer that shall be called on response reception or timeout.

[in]aContext

A pointer to arbitrary context information. May be NULL if not used.

[in]aTxParameters

A pointer to transmission parameters for this request. Use NULL for defaults.

[in]aTransmitHook

A pointer to a hook function for outgoing block-wise transfer.

[in]aReceiveHook

A pointer to a hook function for incoming block-wise transfer.

Is available when OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE configuration is enabled.

If a response for a request is expected, respective function and context information should be provided. If the response is expected to be block-wise, a respective hook function should be provided. If no response is expected, these arguments should be NULL pointers.


Definition at line 882 of file include/openthread/coap.h

otCoapSendRequestBlockWise#

static otError otCoapSendRequestBlockWise (otInstance * aInstance, otMessage * aMessage, const otMessageInfo * aMessageInfo, otCoapResponseHandler aHandler, void * aContext, otCoapBlockwiseTransmitHook aTransmitHook, otCoapBlockwiseReceiveHook aReceiveHook)

Sends a CoAP request block-wise.

Parameters
[in]aInstance

A pointer to an OpenThread instance.

[in]aMessage

A pointer to the message to send.

[in]aMessageInfo

A pointer to the message info associated with aMessage.

[in]aHandler

A function pointer that shall be called on response reception or timeout.

[in]aContext

A pointer to arbitrary context information. May be NULL if not used.

[in]aTransmitHook

A pointer to a hook function for outgoing block-wise transfer.

[in]aReceiveHook

A pointer to a hook function for incoming block-wise transfer.

Is available when OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE configuration is enabled.

If a response for a request is expected, respective function and context information should be provided. If the response is expected to be block-wise, a respective hook function should be provided. If no response is expected, these arguments should be NULL pointers.


Definition at line 912 of file include/openthread/coap.h

otCoapSendRequest#

static otError otCoapSendRequest (otInstance * aInstance, otMessage * aMessage, const otMessageInfo * aMessageInfo, otCoapResponseHandler aHandler, void * aContext)

Sends a CoAP request.

Parameters
[in]aInstance

A pointer to an OpenThread instance.

[in]aMessage

A pointer to the message to send.

[in]aMessageInfo

A pointer to the message info associated with aMessage.

[in]aHandler

A function pointer that shall be called on response reception or timeout.

[in]aContext

A pointer to arbitrary context information. May be NULL if not used.

If a response for a request is expected, respective function and context information should be provided. If no response is expected, these arguments should be NULL pointers.


Definition at line 940 of file include/openthread/coap.h

otCoapStart#

otError otCoapStart (otInstance * aInstance, uint16_t aPort)

Starts the CoAP server.

Parameters
[in]aInstance

A pointer to an OpenThread instance.

[in]aPort

The local UDP port to bind to.


Definition at line 959 of file include/openthread/coap.h

otCoapStop#

otError otCoapStop (otInstance * aInstance)

Stops the CoAP server.

Parameters
[in]aInstance

A pointer to an OpenThread instance.


Definition at line 968 of file include/openthread/coap.h

otCoapAddResource#

void otCoapAddResource (otInstance * aInstance, otCoapResource * aResource)

Adds a resource to the CoAP server.

Parameters
[in]aInstance

A pointer to an OpenThread instance.

[in]aResource

A pointer to the resource.


Definition at line 976 of file include/openthread/coap.h

otCoapRemoveResource#

void otCoapRemoveResource (otInstance * aInstance, otCoapResource * aResource)

Removes a resource from the CoAP server.

Parameters
[in]aInstance

A pointer to an OpenThread instance.

[in]aResource

A pointer to the resource.


Definition at line 984 of file include/openthread/coap.h

otCoapAddBlockWiseResource#

void otCoapAddBlockWiseResource (otInstance * aInstance, otCoapBlockwiseResource * aResource)

Adds a block-wise resource to the CoAP server.

Parameters
[in]aInstance

A pointer to an OpenThread instance.

[in]aResource

A pointer to the resource.


Definition at line 992 of file include/openthread/coap.h

otCoapRemoveBlockWiseResource#

void otCoapRemoveBlockWiseResource (otInstance * aInstance, otCoapBlockwiseResource * aResource)

Removes a block-wise resource from the CoAP server.

Parameters
[in]aInstance

A pointer to an OpenThread instance.

[in]aResource

A pointer to the resource.


Definition at line 1000 of file include/openthread/coap.h

otCoapSetDefaultHandler#

void otCoapSetDefaultHandler (otInstance * aInstance, otCoapRequestHandler aHandler, void * aContext)

Sets the default handler for unhandled CoAP requests.

Parameters
[in]aInstance

A pointer to an OpenThread instance.

[in]aHandler

A function pointer that shall be called when an unhandled request arrives.

[in]aContext

A pointer to arbitrary context information. May be NULL if not used.


Definition at line 1009 of file include/openthread/coap.h

otCoapSendResponseWithParameters#

otError otCoapSendResponseWithParameters (otInstance * aInstance, otMessage * aMessage, const otMessageInfo * aMessageInfo, const otCoapTxParameters * aTxParameters)

Sends a CoAP response from the server with custom transmission parameters.

Parameters
[in]aInstance

A pointer to an OpenThread instance.

[in]aMessage

A pointer to the CoAP response to send.

[in]aMessageInfo

A pointer to the message info associated with aMessage.

[in]aTxParameters

A pointer to transmission parameters for this response. Use NULL for defaults.


Definition at line 1023 of file include/openthread/coap.h

otCoapSendResponseBlockWiseWithParameters#

otError otCoapSendResponseBlockWiseWithParameters (otInstance * aInstance, otMessage * aMessage, const otMessageInfo * aMessageInfo, const otCoapTxParameters * aTxParameters, void * aContext, otCoapBlockwiseTransmitHook aTransmitHook)

Sends a CoAP response block-wise from the server with custom transmission parameters.

Parameters
[in]aInstance

A pointer to an OpenThread instance.

[in]aMessage

A pointer to the CoAP response to send.

[in]aMessageInfo

A pointer to the message info associated with aMessage.

[in]aTxParameters

A pointer to transmission parameters for this response. Use NULL for defaults.

[in]aContext

A pointer to arbitrary context information. May be NULL if not used.

[in]aTransmitHook

A pointer to a hook function for outgoing block-wise transfer.

Is available when OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE configuration is enabled.


Definition at line 1045 of file include/openthread/coap.h

otCoapSendResponseBlockWise#

static otError otCoapSendResponseBlockWise (otInstance * aInstance, otMessage * aMessage, const otMessageInfo * aMessageInfo, void * aContext, otCoapBlockwiseTransmitHook aTransmitHook)

Sends a CoAP response block-wise from the server.

Parameters
[in]aInstance

A pointer to an OpenThread instance.

[in]aMessage

A pointer to the CoAP response to send.

[in]aMessageInfo

A pointer to the message info associated with aMessage.

[in]aContext

A pointer to arbitrary context information. May be NULL if not used.

[in]aTransmitHook

A pointer to a hook function for outgoing block-wise transfer.

Is available when OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE configuration is enabled.


Definition at line 1067 of file include/openthread/coap.h

otCoapSendResponse#

static otError otCoapSendResponse (otInstance * aInstance, otMessage * aMessage, const otMessageInfo * aMessageInfo)

Sends a CoAP response from the server.

Parameters
[in]aInstance

A pointer to an OpenThread instance.

[in]aMessage

A pointer to the CoAP response to send.

[in]aMessageInfo

A pointer to the message info associated with aMessage.


Definition at line 1087 of file include/openthread/coap.h

Macro Definition Documentation#

OT_DEFAULT_COAP_PORT#

#define OT_DEFAULT_COAP_PORT
Value:
5683

Default CoAP port, as specified in RFC 7252.


Definition at line 58 of file include/openthread/coap.h

OT_COAP_DEFAULT_TOKEN_LENGTH#

#define OT_COAP_DEFAULT_TOKEN_LENGTH
Value:
2

Default token length.


Definition at line 60 of file include/openthread/coap.h

OT_COAP_MAX_TOKEN_LENGTH#

#define OT_COAP_MAX_TOKEN_LENGTH
Value:
8

Max token length as specified (RFC 7252).


Definition at line 62 of file include/openthread/coap.h

OT_COAP_MAX_RETRANSMIT#

#define OT_COAP_MAX_RETRANSMIT
Value:
20

Max retransmit supported by OpenThread.


Definition at line 64 of file include/openthread/coap.h

OT_COAP_MIN_ACK_TIMEOUT#

#define OT_COAP_MIN_ACK_TIMEOUT
Value:
1000

Minimal ACK timeout in milliseconds supported by OpenThread.


Definition at line 66 of file include/openthread/coap.h

OT_COAP_CODE#

#define OT_COAP_CODE
Value:
(c, d)

Helper macro to define CoAP Code values.


Definition at line 82 of file include/openthread/coap.h