Modules#
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.
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.
This structure represents a CoAP option.
This structure acts as an iterator for CoAP options.
CoAP Content Format codes.
CoAP Block Size Exponents.
This function pointer is called when a CoAP response is received or on the request timeout.
This function pointer is called when a CoAP request with a given Uri-Path is received.
This function pointer is called when a CoAP message with an block-wise transfer option is received.
This function pointer is called before the next block in a block-wise transfer is sent.
This structure represents a CoAP resource.
This structure represents a CoAP resource with block-wise transfer.
This structure represents the CoAP transmission parameters.
Functions#
This function initializes the CoAP header.
This function initializes a response message.
This function sets the Token value and length in a header.
This function sets the Token length and randomizes its value.
This function appends the Content Format CoAP option as specified in https://tools.ietf.org/html/rfc7252#page-92.
This function appends a CoAP option in a header.
This function appends an unsigned integer CoAP option as specified in https://tools.ietf.org/html/rfc7252#section-3.2.
This function appends an Observe option.
This function appends a Uri-Path option.
This function converts a CoAP Block option SZX field to the actual block size.
This function appends a Block2 option.
This function appends a Block1 option.
This function appends a Proxy-Uri option.
This function appends a Max-Age option.
This function appends a single Uri-Query option.
This function adds Payload Marker indicating beginning of the payload to the CoAP header.
This function returns the Type value.
This function returns the Code value.
This function sets the Code value.
This method returns the CoAP Code as human readable string.
This function returns the Message ID value.
This function returns the Token length.
This function returns a pointer to the Token value.
This function initialises an iterator for the options in the given message.
This function returns a pointer to the first option matching the specified option number.
This function returns a pointer to the first option.
This function returns a pointer to the next option matching the specified option number.
This function returns a pointer to the next option.
This function 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.
This function fills current option value into aValue
.
This function creates a new CoAP message.
This function sends a CoAP request with custom transmission parameters.
This function sends a CoAP request block-wise with custom transmission parameters.
This function sends a CoAP request block-wise.
This function sends a CoAP request.
This function starts the CoAP server.
This function stops the CoAP server.
This function adds a resource to the CoAP server.
This function removes a resource from the CoAP server.
This function adds a block-wise resource to the CoAP server.
This function removes a block-wise resource from the CoAP server.
This function sets the default handler for unhandled CoAP requests.
This function sends a CoAP response from the server with custom transmission parameters.
This function sends a CoAP response block-wise from the server with custom transmission parameters.
This function sends a CoAP response block-wise from the server.
This function 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. |
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. |
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. |
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] |
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 |
Typedef Documentation#
otCoapOptionIterator#
typedef struct otCoapOptionIterator otCoapOptionIterator
This structure acts as an iterator for CoAP options.
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
otCoapResponseHandler#
typedef void(* otCoapResponseHandler) (void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo, otError aResult) )(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo, otError aResult)
This function pointer is called when a CoAP response is received or on the request timeout.
Type | Direction | Argument Name | Description |
---|---|---|---|
[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. |
otCoapRequestHandler#
typedef void(* otCoapRequestHandler) (void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo) )(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo)
This function pointer is called when a CoAP request with a given Uri-Path is received.
Type | Direction | Argument Name | Description |
---|---|---|---|
[in] | aContext | A pointer to arbitrary context information. | |
[in] | aMessage | A pointer to the message. | |
[in] | aMessageInfo | A pointer to the message info for |
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)
This function pointer is called when a CoAP message with an block-wise transfer option is received.
Type | Direction | Argument Name | Description |
---|---|---|---|
[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). |
This function is available when OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE configuration is enabled.
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)
This function pointer is called before the next block in a block-wise transfer is sent.
Type | Direction | Argument Name | Description |
---|---|---|---|
[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. |
This function 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.
otCoapResource#
typedef struct otCoapResource otCoapResource
This structure represents a CoAP resource.
otCoapBlockwiseResource#
typedef struct otCoapBlockwiseResource otCoapBlockwiseResource
This structure represents a CoAP resource with block-wise transfer.
otCoapTxParameters#
typedef struct otCoapTxParameters otCoapTxParameters
This structure 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.
Function Documentation#
otCoapMessageInit#
void otCoapMessageInit (otMessage * aMessage, otCoapType aType, otCoapCode aCode)
This function initializes the CoAP header.
Type | Direction | Argument Name | Description |
---|---|---|---|
otMessage * | [inout] | aMessage | A pointer to the CoAP message to initialize. |
otCoapType | [in] | aType | CoAP message type. |
otCoapCode | [in] | aCode | CoAP message code. |
otCoapMessageInitResponse#
otError otCoapMessageInitResponse (otMessage * aResponse, const otMessage * aRequest, otCoapType aType, otCoapCode aCode)
This function initializes a response message.
Type | Direction | Argument Name | Description |
---|---|---|---|
otMessage * | [inout] | aResponse | A pointer to the CoAP response message. |
const otMessage * | [in] | aRequest | A pointer to the CoAP request message. |
otCoapType | [in] | aType | CoAP message type. |
otCoapCode | [in] | aCode | CoAP message code. |
Note
Both message ID and token are set according to
aRequest
.
otCoapMessageSetToken#
otError otCoapMessageSetToken (otMessage * aMessage, const uint8_t * aToken, uint8_t aTokenLength)
This function sets the Token value and length in a header.
Type | Direction | Argument Name | Description |
---|---|---|---|
otMessage * | [inout] | aMessage | A pointer to the CoAP message. |
const uint8_t * | [in] | aToken | A pointer to the Token value. |
uint8_t | [in] | aTokenLength | The Length of |
otCoapMessageGenerateToken#
void otCoapMessageGenerateToken (otMessage * aMessage, uint8_t aTokenLength)
This function sets the Token length and randomizes its value.
Type | Direction | Argument Name | Description |
---|---|---|---|
otMessage * | [inout] | aMessage | A pointer to the CoAP message. |
uint8_t | [in] | aTokenLength | The Length of a Token to set. |
otCoapMessageAppendContentFormatOption#
otError otCoapMessageAppendContentFormatOption (otMessage * aMessage, otCoapOptionContentFormat aContentFormat)
This function appends the Content Format CoAP option as specified in https://tools.ietf.org/html/rfc7252#page-92.
Type | Direction | Argument Name | Description |
---|---|---|---|
otMessage * | [inout] | aMessage | A pointer to the CoAP message. |
otCoapOptionContentFormat | [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.
otCoapMessageAppendOption#
otError otCoapMessageAppendOption (otMessage * aMessage, uint16_t aNumber, uint16_t aLength, const void * aValue)
This function appends a CoAP option in a header.
Type | Direction | Argument Name | Description |
---|---|---|---|
otMessage * | [inout] | aMessage | A pointer to the CoAP message. |
uint16_t | [in] | aNumber | The CoAP Option number. |
uint16_t | [in] | aLength | The CoAP Option length. |
const void * | [in] | aValue | A pointer to the CoAP value. |
otCoapMessageAppendUintOption#
otError otCoapMessageAppendUintOption (otMessage * aMessage, uint16_t aNumber, uint32_t aValue)
This function appends an unsigned integer CoAP option as specified in https://tools.ietf.org/html/rfc7252#section-3.2.
Type | Direction | Argument Name | Description |
---|---|---|---|
otMessage * | [inout] | aMessage | A pointer to the CoAP message. |
uint16_t | [in] | aNumber | The CoAP Option number. |
uint32_t | [in] | aValue | The CoAP Option unsigned integer value. |
See Also
otCoapMessageGetOptionUintValue
otCoapMessageAppendObserveOption#
otError otCoapMessageAppendObserveOption (otMessage * aMessage, uint32_t aObserve)
This function appends an Observe option.
Type | Direction | Argument Name | Description |
---|---|---|---|
otMessage * | [inout] | aMessage | A pointer to the CoAP message. |
uint32_t | [in] | aObserve | Observe field value. |
otCoapMessageAppendUriPathOptions#
otError otCoapMessageAppendUriPathOptions (otMessage * aMessage, const char * aUriPath)
This function appends a Uri-Path option.
Type | Direction | Argument Name | Description |
---|---|---|---|
otMessage * | [inout] | aMessage | A pointer to the CoAP message. |
const char * | [in] | aUriPath | A pointer to a NULL-terminated string. |
otCoapBlockSizeFromExponent#
uint16_t otCoapBlockSizeFromExponent (otCoapBlockSzx aSize)
This function converts a CoAP Block option SZX field to the actual block size.
Type | Direction | Argument Name | Description |
---|---|---|---|
otCoapBlockSzx | [in] | aSize | Block size exponent. |
Returns
The actual size exponent value.
otCoapMessageAppendBlock2Option#
otError otCoapMessageAppendBlock2Option (otMessage * aMessage, uint32_t aNum, bool aMore, otCoapBlockSzx aSize)
This function appends a Block2 option.
Type | Direction | Argument Name | Description |
---|---|---|---|
otMessage * | [inout] | aMessage | A pointer to the CoAP message. |
uint32_t | [in] | aNum | Current block number. |
bool | [in] | aMore | Boolean to indicate more blocks are to be sent. |
otCoapBlockSzx | [in] | aSize | Block Size Exponent. |
otCoapMessageAppendBlock1Option#
otError otCoapMessageAppendBlock1Option (otMessage * aMessage, uint32_t aNum, bool aMore, otCoapBlockSzx aSize)
This function appends a Block1 option.
Type | Direction | Argument Name | Description |
---|---|---|---|
otMessage * | [inout] | aMessage | A pointer to the CoAP message. |
uint32_t | [in] | aNum | Current block number. |
bool | [in] | aMore | Boolean to indicate more blocks are to be sent. |
otCoapBlockSzx | [in] | aSize | Block Size Exponent. |
otCoapMessageAppendProxyUriOption#
otError otCoapMessageAppendProxyUriOption (otMessage * aMessage, const char * aUriPath)
This function appends a Proxy-Uri option.
Type | Direction | Argument Name | Description |
---|---|---|---|
otMessage * | [inout] | aMessage | A pointer to the CoAP message. |
const char * | [in] | aUriPath | A pointer to a NULL-terminated string. |
otCoapMessageAppendMaxAgeOption#
otError otCoapMessageAppendMaxAgeOption (otMessage * aMessage, uint32_t aMaxAge)
This function appends a Max-Age option.
Type | Direction | Argument Name | Description |
---|---|---|---|
otMessage * | [inout] | aMessage | A pointer to the CoAP message. |
uint32_t | [in] | aMaxAge | The Max-Age value. |
otCoapMessageAppendUriQueryOption#
otError otCoapMessageAppendUriQueryOption (otMessage * aMessage, const char * aUriQuery)
This function appends a single Uri-Query option.
Type | Direction | Argument Name | Description |
---|---|---|---|
otMessage * | [inout] | aMessage | A pointer to the CoAP message. |
const char * | [in] | aUriQuery | A pointer to NULL-terminated string, which should contain a single key=value pair. |
otCoapMessageSetPayloadMarker#
otError otCoapMessageSetPayloadMarker (otMessage * aMessage)
This function adds Payload Marker indicating beginning of the payload to the CoAP header.
Type | Direction | Argument Name | Description |
---|---|---|---|
otMessage * | [inout] | aMessage | A pointer to the CoAP message. |
otCoapMessageGetType#
otCoapType otCoapMessageGetType (const otMessage * aMessage)
This function returns the Type value.
Type | Direction | Argument Name | Description |
---|---|---|---|
const otMessage * | [in] | aMessage | A pointer to the CoAP message. |
Returns
The Type value.
otCoapMessageGetCode#
otCoapCode otCoapMessageGetCode (const otMessage * aMessage)
This function returns the Code value.
Type | Direction | Argument Name | Description |
---|---|---|---|
const otMessage * | [in] | aMessage | A pointer to the CoAP message. |
Returns
The Code value.
otCoapMessageSetCode#
void otCoapMessageSetCode (otMessage * aMessage, otCoapCode aCode)
This function sets the Code value.
Type | Direction | Argument Name | Description |
---|---|---|---|
otMessage * | [inout] | aMessage | A pointer to the CoAP message to initialize. |
otCoapCode | [in] | aCode | CoAP message code. |
otCoapMessageCodeToString#
const char * otCoapMessageCodeToString (const otMessage * aMessage)
This method returns the CoAP Code as human readable string.
Type | Direction | Argument Name | Description |
---|---|---|---|
const otMessage * | [in] | aMessage | A pointer to the CoAP message. |
@ returns The CoAP Code as string.
otCoapMessageGetMessageId#
uint16_t otCoapMessageGetMessageId (const otMessage * aMessage)
This function returns the Message ID value.
Type | Direction | Argument Name | Description |
---|---|---|---|
const otMessage * | [in] | aMessage | A pointer to the CoAP message. |
Returns
The Message ID value.
otCoapMessageGetTokenLength#
uint8_t otCoapMessageGetTokenLength (const otMessage * aMessage)
This function returns the Token length.
Type | Direction | Argument Name | Description |
---|---|---|---|
const otMessage * | [in] | aMessage | A pointer to the CoAP message. |
Returns
The Token length.
otCoapMessageGetToken#
const uint8_t * otCoapMessageGetToken (const otMessage * aMessage)
This function returns a pointer to the Token value.
Type | Direction | Argument Name | Description |
---|---|---|---|
const otMessage * | [in] | aMessage | A pointer to the CoAP message. |
Returns
A pointer to the Token value.
otCoapOptionIteratorInit#
otError otCoapOptionIteratorInit (otCoapOptionIterator * aIterator, const otMessage * aMessage)
This function initialises an iterator for the options in the given message.
Type | Direction | Argument Name | Description |
---|---|---|---|
otCoapOptionIterator * | [inout] | aIterator | A pointer to the CoAP message option iterator. |
const otMessage * | [in] | aMessage | A pointer to the CoAP message. |
otCoapOptionIteratorGetFirstOptionMatching#
const otCoapOption * otCoapOptionIteratorGetFirstOptionMatching (otCoapOptionIterator * aIterator, uint16_t aOption)
This function returns a pointer to the first option matching the specified option number.
Type | Direction | Argument Name | Description |
---|---|---|---|
otCoapOptionIterator * | [in] | aIterator | A pointer to the CoAP message option iterator. |
uint16_t | [in] | aOption | The option number sought. |
Returns
A pointer to the first matching option. If no matching option is present NULL pointer is returned.
otCoapOptionIteratorGetFirstOption#
const otCoapOption * otCoapOptionIteratorGetFirstOption (otCoapOptionIterator * aIterator)
This function returns a pointer to the first option.
Type | Direction | Argument Name | Description |
---|---|---|---|
otCoapOptionIterator * | [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.
otCoapOptionIteratorGetNextOptionMatching#
const otCoapOption * otCoapOptionIteratorGetNextOptionMatching (otCoapOptionIterator * aIterator, uint16_t aOption)
This function returns a pointer to the next option matching the specified option number.
Type | Direction | Argument Name | Description |
---|---|---|---|
otCoapOptionIterator * | [in] | aIterator | A pointer to the CoAP message option iterator. |
uint16_t | [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.
otCoapOptionIteratorGetNextOption#
const otCoapOption * otCoapOptionIteratorGetNextOption (otCoapOptionIterator * aIterator)
This function returns a pointer to the next option.
Type | Direction | Argument Name | Description |
---|---|---|---|
otCoapOptionIterator * | [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.
otCoapOptionIteratorGetOptionUintValue#
otError otCoapOptionIteratorGetOptionUintValue (otCoapOptionIterator * aIterator, uint64_t * aValue)
This function 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.
Type | Direction | Argument Name | Description |
---|---|---|---|
otCoapOptionIterator * | [inout] | aIterator | A pointer to the CoAP message option iterator. |
uint64_t * | [out] | aValue | A pointer to an unsigned integer to receive the option value. |
See Also
otCoapOptionIteratorGetOptionValue#
otError otCoapOptionIteratorGetOptionValue (otCoapOptionIterator * aIterator, void * aValue)
This function fills current option value into aValue
.
Type | Direction | Argument Name | Description |
---|---|---|---|
otCoapOptionIterator * | [inout] | aIterator | A pointer to the CoAP message option iterator. |
void * | [out] | aValue | A pointer to a buffer to receive the option value. |
otCoapNewMessage#
otMessage * otCoapNewMessage (otInstance * aInstance, const otMessageSettings * aSettings)
This function creates a new CoAP message.
Type | Direction | Argument Name | Description |
---|---|---|---|
otInstance * | [in] | aInstance | A pointer to an OpenThread instance. |
const otMessageSettings * | [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.
otCoapSendRequestWithParameters#
otError otCoapSendRequestWithParameters (otInstance * aInstance, otMessage * aMessage, const otMessageInfo * aMessageInfo, otCoapResponseHandler aHandler, void * aContext, const otCoapTxParameters * aTxParameters)
This function sends a CoAP request with custom transmission parameters.
Type | Direction | Argument Name | Description |
---|---|---|---|
otInstance * | [in] | aInstance | A pointer to an OpenThread instance. |
otMessage * | [in] | aMessage | A pointer to the message to send. |
const otMessageInfo * | [in] | aMessageInfo | A pointer to the message info associated with |
otCoapResponseHandler | [in] | aHandler | A function pointer that shall be called on response reception or timeout. |
void * | [in] | aContext | A pointer to arbitrary context information. May be NULL if not used. |
const otCoapTxParameters * | [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.
otCoapSendRequestBlockWiseWithParameters#
otError otCoapSendRequestBlockWiseWithParameters (otInstance * aInstance, otMessage * aMessage, const otMessageInfo * aMessageInfo, otCoapResponseHandler aHandler, void * aContext, const otCoapTxParameters * aTxParameters, otCoapBlockwiseTransmitHook aTransmitHook, otCoapBlockwiseReceiveHook aReceiveHook)
This function sends a CoAP request block-wise with custom transmission parameters.
Type | Direction | Argument Name | Description |
---|---|---|---|
otInstance * | [in] | aInstance | A pointer to an OpenThread instance. |
otMessage * | [in] | aMessage | A pointer to the message to send. |
const otMessageInfo * | [in] | aMessageInfo | A pointer to the message info associated with |
otCoapResponseHandler | [in] | aHandler | A function pointer that shall be called on response reception or timeout. |
void * | [in] | aContext | A pointer to arbitrary context information. May be NULL if not used. |
const otCoapTxParameters * | [in] | aTxParameters | A pointer to transmission parameters for this request. Use NULL for defaults. |
otCoapBlockwiseTransmitHook | [in] | aTransmitHook | A pointer to a hook function for outgoing block-wise transfer. |
otCoapBlockwiseReceiveHook | [in] | aReceiveHook | A pointer to a hook function for incoming block-wise transfer. |
This function 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.
otCoapSendRequestBlockWise#
static otError otCoapSendRequestBlockWise (otInstance * aInstance, otMessage * aMessage, const otMessageInfo * aMessageInfo, otCoapResponseHandler aHandler, void * aContext, otCoapBlockwiseTransmitHook aTransmitHook, otCoapBlockwiseReceiveHook aReceiveHook)
This function sends a CoAP request block-wise.
Type | Direction | Argument Name | Description |
---|---|---|---|
otInstance * | [in] | aInstance | A pointer to an OpenThread instance. |
otMessage * | [in] | aMessage | A pointer to the message to send. |
const otMessageInfo * | [in] | aMessageInfo | A pointer to the message info associated with |
otCoapResponseHandler | [in] | aHandler | A function pointer that shall be called on response reception or timeout. |
void * | [in] | aContext | A pointer to arbitrary context information. May be NULL if not used. |
otCoapBlockwiseTransmitHook | [in] | aTransmitHook | A pointer to a hook function for outgoing block-wise transfer. |
otCoapBlockwiseReceiveHook | [in] | aReceiveHook | A pointer to a hook function for incoming block-wise transfer. |
This function 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.
otCoapSendRequest#
static otError otCoapSendRequest (otInstance * aInstance, otMessage * aMessage, const otMessageInfo * aMessageInfo, otCoapResponseHandler aHandler, void * aContext)
This function sends a CoAP request.
Type | Direction | Argument Name | Description |
---|---|---|---|
otInstance * | [in] | aInstance | A pointer to an OpenThread instance. |
otMessage * | [in] | aMessage | A pointer to the message to send. |
const otMessageInfo * | [in] | aMessageInfo | A pointer to the message info associated with |
otCoapResponseHandler | [in] | aHandler | A function pointer that shall be called on response reception or timeout. |
void * | [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.
otCoapStart#
otError otCoapStart (otInstance * aInstance, uint16_t aPort)
This function starts the CoAP server.
Type | Direction | Argument Name | Description |
---|---|---|---|
otInstance * | [in] | aInstance | A pointer to an OpenThread instance. |
uint16_t | [in] | aPort | The local UDP port to bind to. |
otCoapStop#
otError otCoapStop (otInstance * aInstance)
This function stops the CoAP server.
Type | Direction | Argument Name | Description |
---|---|---|---|
otInstance * | [in] | aInstance | A pointer to an OpenThread instance. |
otCoapAddResource#
void otCoapAddResource (otInstance * aInstance, otCoapResource * aResource)
This function adds a resource to the CoAP server.
Type | Direction | Argument Name | Description |
---|---|---|---|
otInstance * | [in] | aInstance | A pointer to an OpenThread instance. |
otCoapResource * | [in] | aResource | A pointer to the resource. |
otCoapRemoveResource#
void otCoapRemoveResource (otInstance * aInstance, otCoapResource * aResource)
This function removes a resource from the CoAP server.
Type | Direction | Argument Name | Description |
---|---|---|---|
otInstance * | [in] | aInstance | A pointer to an OpenThread instance. |
otCoapResource * | [in] | aResource | A pointer to the resource. |
otCoapAddBlockWiseResource#
void otCoapAddBlockWiseResource (otInstance * aInstance, otCoapBlockwiseResource * aResource)
This function adds a block-wise resource to the CoAP server.
Type | Direction | Argument Name | Description |
---|---|---|---|
otInstance * | [in] | aInstance | A pointer to an OpenThread instance. |
otCoapBlockwiseResource * | [in] | aResource | A pointer to the resource. |
otCoapRemoveBlockWiseResource#
void otCoapRemoveBlockWiseResource (otInstance * aInstance, otCoapBlockwiseResource * aResource)
This function removes a block-wise resource from the CoAP server.
Type | Direction | Argument Name | Description |
---|---|---|---|
otInstance * | [in] | aInstance | A pointer to an OpenThread instance. |
otCoapBlockwiseResource * | [in] | aResource | A pointer to the resource. |
otCoapSetDefaultHandler#
void otCoapSetDefaultHandler (otInstance * aInstance, otCoapRequestHandler aHandler, void * aContext)
This function sets the default handler for unhandled CoAP requests.
Type | Direction | Argument Name | Description |
---|---|---|---|
otInstance * | [in] | aInstance | A pointer to an OpenThread instance. |
otCoapRequestHandler | [in] | aHandler | A function pointer that shall be called when an unhandled request arrives. |
void * | [in] | aContext | A pointer to arbitrary context information. May be NULL if not used. |
otCoapSendResponseWithParameters#
otError otCoapSendResponseWithParameters (otInstance * aInstance, otMessage * aMessage, const otMessageInfo * aMessageInfo, const otCoapTxParameters * aTxParameters)
This function sends a CoAP response from the server with custom transmission parameters.
Type | Direction | Argument Name | Description |
---|---|---|---|
otInstance * | [in] | aInstance | A pointer to an OpenThread instance. |
otMessage * | [in] | aMessage | A pointer to the CoAP response to send. |
const otMessageInfo * | [in] | aMessageInfo | A pointer to the message info associated with |
const otCoapTxParameters * | [in] | aTxParameters | A pointer to transmission parameters for this response. Use NULL for defaults. |
otCoapSendResponseBlockWiseWithParameters#
otError otCoapSendResponseBlockWiseWithParameters (otInstance * aInstance, otMessage * aMessage, const otMessageInfo * aMessageInfo, const otCoapTxParameters * aTxParameters, void * aContext, otCoapBlockwiseTransmitHook aTransmitHook)
This function sends a CoAP response block-wise from the server with custom transmission parameters.
Type | Direction | Argument Name | Description |
---|---|---|---|
otInstance * | [in] | aInstance | A pointer to an OpenThread instance. |
otMessage * | [in] | aMessage | A pointer to the CoAP response to send. |
const otMessageInfo * | [in] | aMessageInfo | A pointer to the message info associated with |
const otCoapTxParameters * | [in] | aTxParameters | A pointer to transmission parameters for this response. Use NULL for defaults. |
void * | [in] | aContext | A pointer to arbitrary context information. May be NULL if not used. |
otCoapBlockwiseTransmitHook | [in] | aTransmitHook | A pointer to a hook function for outgoing block-wise transfer. |
This function is available when OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE configuration is enabled.
otCoapSendResponseBlockWise#
static otError otCoapSendResponseBlockWise (otInstance * aInstance, otMessage * aMessage, const otMessageInfo * aMessageInfo, void * aContext, otCoapBlockwiseTransmitHook aTransmitHook)
This function sends a CoAP response block-wise from the server.
Type | Direction | Argument Name | Description |
---|---|---|---|
otInstance * | [in] | aInstance | A pointer to an OpenThread instance. |
otMessage * | [in] | aMessage | A pointer to the CoAP response to send. |
const otMessageInfo * | [in] | aMessageInfo | A pointer to the message info associated with |
void * | [in] | aContext | A pointer to arbitrary context information. May be NULL if not used. |
otCoapBlockwiseTransmitHook | [in] | aTransmitHook | A pointer to a hook function for outgoing block-wise transfer. |
This function is available when OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE configuration is enabled.
otCoapSendResponse#
static otError otCoapSendResponse (otInstance * aInstance, otMessage * aMessage, const otMessageInfo * aMessageInfo)
This function sends a CoAP response from the server.
Type | Direction | Argument Name | Description |
---|---|---|---|
otInstance * | [in] | aInstance | A pointer to an OpenThread instance. |
otMessage * | [in] | aMessage | A pointer to the CoAP response to send. |
const otMessageInfo * | [in] | aMessageInfo | A pointer to the message info associated with |