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#
Enumerations#
CoAP Type values (2 bit unsigned integer).
CoAP Code values.
CoAP Option Numbers.
CoAP Content Format codes.
CoAP Block Size Exponents.
Typedefs#
CoAP Type values (2 bit unsigned integer).
CoAP Code values.
CoAP Option Numbers.
Represents a CoAP option.
Acts as an iterator for CoAP options.
CoAP Content Format codes.
CoAP Block Size Exponents.
Pointer is called when a CoAP response is received or on the request timeout.
Pointer is called when a CoAP request with a given Uri-Path is received.
Pointer is called when a CoAP message with a block-wise transfer option is received.
Pointer is called before the next block in a block-wise transfer is sent.
Represents a CoAP resource.
Represents a CoAP resource with block-wise transfer.
Represents the CoAP transmission parameters.
Functions#
Initializes the CoAP header.
Initializes a response message.
Sets the Token value and length in a header.
Sets the Token length and randomizes its value.
Appends the Content Format CoAP option as specified in https://tools.ietf.org/html/rfc7252#page-92.
Appends a CoAP option in a header.
Appends an unsigned integer CoAP option as specified in https://tools.ietf.org/html/rfc7252#section-3.2.
Appends an Observe option.
Appends a Uri-Path option.
Appends a Uri-Query option.
Converts a CoAP Block option SZX field to the actual block size.
Appends a Block2 option.
Appends a Block1 option.
Appends a Proxy-Uri option.
Appends a Max-Age option.
Appends a single Uri-Query option.
Adds Payload Marker indicating beginning of the payload to the CoAP header.
Returns the Type value.
Returns the Code value.
Sets the Code value.
Returns the CoAP Code as human readable string.
Returns the Message ID value.
Returns the Token length.
Returns a pointer to the Token value.
Initialises an iterator for the options in the given message.
Returns a pointer to the first option matching the specified option number.
Returns a pointer to the first option.
Returns a pointer to the next option matching the specified option number.
Returns a pointer to the next option.
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.
Fills current option value into aValue
.
Creates a new CoAP message.
Sends a CoAP request with custom transmission parameters.
Sends a CoAP request block-wise with custom transmission parameters.
Sends a CoAP request block-wise.
Sends a CoAP request.
Starts the CoAP server.
Stops the CoAP server.
Adds a resource to the CoAP server.
Removes a resource from the CoAP server.
Adds a block-wise resource to the CoAP server.
Removes a block-wise resource from the CoAP server.
Sets the default handler for unhandled CoAP requests.
Sends a CoAP response from the server with custom transmission parameters.
Sends a CoAP response block-wise from the server with custom transmission parameters.
Sends a CoAP response block-wise from the server.
Sends a CoAP response from the server.
Macros#
Default CoAP port, as specified in RFC 7252.
Default token length.
Max token length as specified (RFC 7252).
Max retransmit supported by OpenThread.
Minimal ACK timeout in milliseconds supported by OpenThread.
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. |
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. |
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. |
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] |
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 |
314
of file include/openthread/coap.h
Typedef Documentation#
otCoapType#
typedef enum otCoapType otCoapType
CoAP Type values (2 bit unsigned integer).
77
of file include/openthread/coap.h
otCoapCode#
typedef enum otCoapCode otCoapCode
CoAP Code values.
121
of file include/openthread/coap.h
otCoapOptionType#
typedef enum otCoapOptionType otCoapOptionType
CoAP Option Numbers.
147
of file include/openthread/coap.h
otCoapOption#
typedef struct otCoapOption otCoapOption
Represents a CoAP option.
156
of file include/openthread/coap.h
otCoapOptionIterator#
typedef struct otCoapOptionIterator otCoapOptionIterator
Acts as an iterator for CoAP options.
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
309
of file include/openthread/coap.h
otCoapBlockSzx#
typedef enum otCoapBlockSzx otCoapBlockSzx
CoAP Block Size Exponents.
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.
[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 |
[in] | aResult | A result of the CoAP transaction. |
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.
[in] | aContext | A pointer to arbitrary context information. |
[in] | aMessage | A pointer to the message. |
[in] | aMessageInfo | A pointer to the message info for |
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.
[in] | aContext | A pointer to application-specific context. |
[in] | aBlock | A pointer to the block segment. |
[in] | aPosition | The position of |
[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.
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.
[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.
395
of file include/openthread/coap.h
otCoapResource#
typedef struct otCoapResource otCoapResource
Represents a CoAP resource.
410
of file include/openthread/coap.h
otCoapBlockwiseResource#
typedef struct otCoapBlockwiseResource otCoapBlockwiseResource
Represents a CoAP resource with block-wise transfer.
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.
466
of file include/openthread/coap.h
Function Documentation#
otCoapMessageInit#
void otCoapMessageInit (otMessage * aMessage, otCoapType aType, otCoapCode aCode)
Initializes the CoAP header.
[inout] | aMessage | A pointer to the CoAP message to initialize. |
[in] | aType | CoAP message type. |
[in] | aCode | CoAP message code. |
475
of file include/openthread/coap.h
otCoapMessageInitResponse#
otError otCoapMessageInitResponse (otMessage * aResponse, const otMessage * aRequest, otCoapType aType, otCoapCode aCode)
Initializes a response message.
[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
.
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.
[inout] | aMessage | A pointer to the CoAP message. |
[in] | aToken | A pointer to the Token value. |
[in] | aTokenLength | The Length of |
502
of file include/openthread/coap.h
otCoapMessageGenerateToken#
void otCoapMessageGenerateToken (otMessage * aMessage, uint8_t aTokenLength)
Sets the Token length and randomizes its value.
[inout] | aMessage | A pointer to the CoAP message. |
[in] | aTokenLength | The Length of a Token to set. |
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.
[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.
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.
[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. |
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.
[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
560
of file include/openthread/coap.h
otCoapMessageAppendObserveOption#
otError otCoapMessageAppendObserveOption (otMessage * aMessage, uint32_t aObserve)
Appends an Observe option.
[inout] | aMessage | A pointer to the CoAP message. |
[in] | aObserve | Observe field value. |
572
of file include/openthread/coap.h
otCoapMessageAppendUriPathOptions#
otError otCoapMessageAppendUriPathOptions (otMessage * aMessage, const char * aUriPath)
Appends a Uri-Path option.
[inout] | aMessage | A pointer to the CoAP message. |
[in] | aUriPath | A pointer to a NULL-terminated string. |
584
of file include/openthread/coap.h
otCoapMessageAppendUriQueryOptions#
otError otCoapMessageAppendUriQueryOptions (otMessage * aMessage, const char * aUriQuery)
Appends a Uri-Query option.
[inout] | aMessage | A pointer to the CoAP message. |
[in] | aUriQuery | A pointer to a NULL-terminated string. |
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.
[in] | aSize | Block size exponent. |
Returns
The actual size exponent value.
605
of file include/openthread/coap.h
otCoapMessageAppendBlock2Option#
otError otCoapMessageAppendBlock2Option (otMessage * aMessage, uint32_t aNum, bool aMore, otCoapBlockSzx aSize)
Appends a Block2 option.
[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. |
619
of file include/openthread/coap.h
otCoapMessageAppendBlock1Option#
otError otCoapMessageAppendBlock1Option (otMessage * aMessage, uint32_t aNum, bool aMore, otCoapBlockSzx aSize)
Appends a Block1 option.
[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. |
633
of file include/openthread/coap.h
otCoapMessageAppendProxyUriOption#
otError otCoapMessageAppendProxyUriOption (otMessage * aMessage, const char * aUriPath)
Appends a Proxy-Uri option.
[inout] | aMessage | A pointer to the CoAP message. |
[in] | aUriPath | A pointer to a NULL-terminated string. |
645
of file include/openthread/coap.h
otCoapMessageAppendMaxAgeOption#
otError otCoapMessageAppendMaxAgeOption (otMessage * aMessage, uint32_t aMaxAge)
Appends a Max-Age option.
[inout] | aMessage | A pointer to the CoAP message. |
[in] | aMaxAge | The Max-Age value. |
657
of file include/openthread/coap.h
otCoapMessageAppendUriQueryOption#
otError otCoapMessageAppendUriQueryOption (otMessage * aMessage, const char * aUriQuery)
Appends a single Uri-Query option.
[inout] | aMessage | A pointer to the CoAP message. |
[in] | aUriQuery | A pointer to NULL-terminated string, which should contain a single key=value pair. |
669
of file include/openthread/coap.h
otCoapMessageSetPayloadMarker#
otError otCoapMessageSetPayloadMarker (otMessage * aMessage)
Adds Payload Marker indicating beginning of the payload to the CoAP header.
[inout] | aMessage | A pointer to the CoAP message. |
679
of file include/openthread/coap.h
otCoapMessageGetType#
otCoapType otCoapMessageGetType (const otMessage * aMessage)
Returns the Type value.
[in] | aMessage | A pointer to the CoAP message. |
Returns
The Type value.
688
of file include/openthread/coap.h
otCoapMessageGetCode#
otCoapCode otCoapMessageGetCode (const otMessage * aMessage)
Returns the Code value.
[in] | aMessage | A pointer to the CoAP message. |
Returns
The Code value.
697
of file include/openthread/coap.h
otCoapMessageSetCode#
void otCoapMessageSetCode (otMessage * aMessage, otCoapCode aCode)
Sets the Code value.
[inout] | aMessage | A pointer to the CoAP message to initialize. |
[in] | aCode | CoAP message code. |
705
of file include/openthread/coap.h
otCoapMessageCodeToString#
const char * otCoapMessageCodeToString (const otMessage * aMessage)
Returns the CoAP Code as human readable string.
[in] | aMessage | A pointer to the CoAP message. |
@ returns The CoAP Code as string.
714
of file include/openthread/coap.h
otCoapMessageGetMessageId#
uint16_t otCoapMessageGetMessageId (const otMessage * aMessage)
Returns the Message ID value.
[in] | aMessage | A pointer to the CoAP message. |
Returns
The Message ID value.
723
of file include/openthread/coap.h
otCoapMessageGetTokenLength#
uint8_t otCoapMessageGetTokenLength (const otMessage * aMessage)
Returns the Token length.
[in] | aMessage | A pointer to the CoAP message. |
Returns
The Token length.
732
of file include/openthread/coap.h
otCoapMessageGetToken#
const uint8_t * otCoapMessageGetToken (const otMessage * aMessage)
Returns a pointer to the Token value.
[in] | aMessage | A pointer to the CoAP message. |
Returns
A pointer to the Token value.
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.
[inout] | aIterator | A pointer to the CoAP message option iterator. |
[in] | aMessage | A pointer to the CoAP message. |
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.
[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.
762
of file include/openthread/coap.h
otCoapOptionIteratorGetFirstOption#
const otCoapOption * otCoapOptionIteratorGetFirstOption (otCoapOptionIterator * aIterator)
Returns a pointer to the first option.
[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.
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.
[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.
781
of file include/openthread/coap.h
otCoapOptionIteratorGetNextOption#
const otCoapOption * otCoapOptionIteratorGetNextOption (otCoapOptionIterator * aIterator)
Returns a pointer to the next option.
[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.
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.
[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
805
of file include/openthread/coap.h
otCoapOptionIteratorGetOptionValue#
otError otCoapOptionIteratorGetOptionValue (otCoapOptionIterator * aIterator, void * aValue)
Fills current option value into aValue
.
[inout] | aIterator | A pointer to the CoAP message option iterator. |
[out] | aValue | A pointer to a buffer to receive the option value. |
816
of file include/openthread/coap.h
otCoapNewMessage#
otMessage * otCoapNewMessage (otInstance * aInstance, const otMessageSettings * aSettings)
Creates a new CoAP message.
[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.
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.
[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 |
[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:
|
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.
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.
[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 |
[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.
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.
[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 |
[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.
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.
[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 |
[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.
940
of file include/openthread/coap.h
otCoapStart#
otError otCoapStart (otInstance * aInstance, uint16_t aPort)
Starts the CoAP server.
[in] | aInstance | A pointer to an OpenThread instance. |
[in] | aPort | The local UDP port to bind to. |
959
of file include/openthread/coap.h
otCoapStop#
otError otCoapStop (otInstance * aInstance)
Stops the CoAP server.
[in] | aInstance | A pointer to an OpenThread instance. |
968
of file include/openthread/coap.h
otCoapAddResource#
void otCoapAddResource (otInstance * aInstance, otCoapResource * aResource)
Adds a resource to the CoAP server.
[in] | aInstance | A pointer to an OpenThread instance. |
[in] | aResource | A pointer to the resource. |
976
of file include/openthread/coap.h
otCoapRemoveResource#
void otCoapRemoveResource (otInstance * aInstance, otCoapResource * aResource)
Removes a resource from the CoAP server.
[in] | aInstance | A pointer to an OpenThread instance. |
[in] | aResource | A pointer to the resource. |
984
of file include/openthread/coap.h
otCoapAddBlockWiseResource#
void otCoapAddBlockWiseResource (otInstance * aInstance, otCoapBlockwiseResource * aResource)
Adds a block-wise resource to the CoAP server.
[in] | aInstance | A pointer to an OpenThread instance. |
[in] | aResource | A pointer to the resource. |
992
of file include/openthread/coap.h
otCoapRemoveBlockWiseResource#
void otCoapRemoveBlockWiseResource (otInstance * aInstance, otCoapBlockwiseResource * aResource)
Removes a block-wise resource from the CoAP server.
[in] | aInstance | A pointer to an OpenThread instance. |
[in] | aResource | A pointer to the resource. |
1000
of file include/openthread/coap.h
otCoapSetDefaultHandler#
void otCoapSetDefaultHandler (otInstance * aInstance, otCoapRequestHandler aHandler, void * aContext)
Sets the default handler for unhandled CoAP requests.
[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. |
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.
[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 |
[in] | aTxParameters | A pointer to transmission parameters for this response. Use NULL for defaults. |
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.
[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 |
[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.
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.
[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 |
[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.
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.
[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 |
1087
of file include/openthread/coap.h
Macro Definition Documentation#
OT_DEFAULT_COAP_PORT#
#define OT_DEFAULT_COAP_PORTValue:
5683
Default CoAP port, as specified in RFC 7252.
58
of file include/openthread/coap.h
OT_COAP_DEFAULT_TOKEN_LENGTH#
#define OT_COAP_DEFAULT_TOKEN_LENGTHValue:
2
Default token length.
60
of file include/openthread/coap.h
OT_COAP_MAX_TOKEN_LENGTH#
#define OT_COAP_MAX_TOKEN_LENGTHValue:
8
Max token length as specified (RFC 7252).
62
of file include/openthread/coap.h
OT_COAP_MAX_RETRANSMIT#
#define OT_COAP_MAX_RETRANSMITValue:
20
Max retransmit supported by OpenThread.
64
of file include/openthread/coap.h
OT_COAP_MIN_ACK_TIMEOUT#
#define OT_COAP_MIN_ACK_TIMEOUTValue:
1000
Minimal ACK timeout in milliseconds supported by OpenThread.
66
of file include/openthread/coap.h
OT_COAP_CODE#
#define OT_COAP_CODEValue:
(c, d)
Helper macro to define CoAP Code values.
82
of file include/openthread/coap.h