CoAP
This module includes functions that control CoAP communication.
Summary
The functions in this module are available when CoAP API feature (OPENTHREAD_CONFIG_COAP_API_ENABLE
) is enabled.
Typedefs |
|
---|---|
otCoapBlockSzx
|
typedefenum otCoapBlockSzx
CoAP Block Size Exponents. |
otCoapBlockwiseReceiveHook)(void *aContext, const uint8_t *aBlock, uint32_t aPosition, uint16_t aBlockLength, bool aMore, uint32_t aTotalLength)
|
typedefotError(*
Pointer is called when a CoAP message with a block-wise transfer option is received. |
otCoapBlockwiseResource
|
typedefstruct otCoapBlockwiseResource
Represents a CoAP resource with block-wise transfer. |
otCoapBlockwiseTransmitHook)(void *aContext, uint8_t *aBlock, uint32_t aPosition, uint16_t *aBlockLength, bool *aMore)
|
typedefotError(*
Pointer is called before the next block in a block-wise transfer is sent. |
otCoapCode
|
typedefenum otCoapCode
CoAP Code values. |
otCoapOption
|
typedefstruct otCoapOption
Represents a CoAP option. |
otCoapOptionContentFormat
|
typedef CoAP Content Format codes. |
otCoapOptionIterator
|
typedefstruct otCoapOptionIterator
Acts as an iterator for CoAP options. |
otCoapOptionType
|
typedefenum otCoapOptionType
CoAP Option Numbers. |
otCoapRequestHandler)(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo)
|
typedefvoid(*
Pointer is called when a CoAP request with a given Uri-Path is received. |
otCoapResource
|
typedefstruct otCoapResource
Represents a CoAP resource. |
otCoapResponseHandler)(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo, otError aResult)
|
typedefvoid(*
Pointer is called when a CoAP response is received or on the request timeout. |
otCoapTxParameters
|
typedefstruct otCoapTxParameters
Represents the CoAP transmission parameters. |
otCoapType
|
typedefenum otCoapType
CoAP Type values (2 bit unsigned integer). |
Functions |
|
---|---|
otCoapAddBlockWiseResource(otInstance *aInstance, otCoapBlockwiseResource *aResource)
|
void
Adds a block-wise resource to the CoAP server.
|
otCoapAddResource(otInstance *aInstance, otCoapResource *aResource)
|
void
Adds a resource to the CoAP server.
|
otCoapBlockSizeFromExponent(otCoapBlockSzx aSize)
|
uint16_t
Converts a CoAP Block option SZX field to the actual block size.
|
otCoapMessageAppendBlock1Option(otMessage *aMessage, uint32_t aNum, bool aMore, otCoapBlockSzx aSize)
|
Appends a Block1 option.
|
otCoapMessageAppendBlock2Option(otMessage *aMessage, uint32_t aNum, bool aMore, otCoapBlockSzx aSize)
|
Appends a Block2 option.
|
otCoapMessageAppendContentFormatOption(otMessage *aMessage, otCoapOptionContentFormat aContentFormat)
|
Appends the Content Format CoAP option as specified in https://tools.ietf.org/html/rfc7252#page-92.
|
otCoapMessageAppendMaxAgeOption(otMessage *aMessage, uint32_t aMaxAge)
|
Appends a Max-Age option.
|
otCoapMessageAppendObserveOption(otMessage *aMessage, uint32_t aObserve)
|
Appends an Observe option.
|
otCoapMessageAppendOption(otMessage *aMessage, uint16_t aNumber, uint16_t aLength, const void *aValue)
|
Appends a CoAP option in a header.
|
otCoapMessageAppendProxyUriOption(otMessage *aMessage, const char *aUriPath)
|
Appends a Proxy-Uri option.
|
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.
|
otCoapMessageAppendUriPathOptions(otMessage *aMessage, const char *aUriPath)
|
Appends a Uri-Path option.
|
otCoapMessageAppendUriQueryOption(otMessage *aMessage, const char *aUriQuery)
|
Appends a single Uri-Query option.
|
otCoapMessageAppendUriQueryOptions(otMessage *aMessage, const char *aUriQuery)
|
Appends a Uri-Query option.
|
otCoapMessageCodeToString(const otMessage *aMessage)
|
const char *
Returns the CoAP Code as human readable string.
|
otCoapMessageGenerateToken(otMessage *aMessage, uint8_t aTokenLength)
|
void
Sets the Token length and randomizes its value.
|
otCoapMessageGetCode(const otMessage *aMessage)
|
Returns the Code value.
|
otCoapMessageGetMessageId(const otMessage *aMessage)
|
uint16_t
Returns the Message ID value.
|
otCoapMessageGetToken(const otMessage *aMessage)
|
const uint8_t *
Returns a pointer to the Token value.
|
otCoapMessageGetTokenLength(const otMessage *aMessage)
|
uint8_t
Returns the Token length.
|
otCoapMessageGetType(const otMessage *aMessage)
|
Returns the Type value.
|
otCoapMessageInit(otMessage *aMessage, otCoapType aType, otCoapCode aCode)
|
void
Initializes the CoAP header.
|
otCoapMessageInitResponse(otMessage *aResponse, const otMessage *aRequest, otCoapType aType, otCoapCode aCode)
|
Initializes a response message.
|
otCoapMessageSetCode(otMessage *aMessage, otCoapCode aCode)
|
void
Sets the Code value.
|
otCoapMessageSetPayloadMarker(otMessage *aMessage)
|
Adds Payload Marker indicating beginning of the payload to the CoAP header.
|
otCoapMessageSetToken(otMessage *aMessage, const uint8_t *aToken, uint8_t aTokenLength)
|
Sets the Token value and length in a header.
|
otCoapNewMessage(otInstance *aInstance, const otMessageSettings *aSettings)
|
Creates a new CoAP message.
|
otCoapOptionIteratorGetFirstOption(otCoapOptionIterator *aIterator)
|
const otCoapOption *
Returns a pointer to the first option.
|
otCoapOptionIteratorGetFirstOptionMatching(otCoapOptionIterator *aIterator, uint16_t aOption)
|
const otCoapOption *
Returns a pointer to the first option matching the specified option number.
|
otCoapOptionIteratorGetNextOption(otCoapOptionIterator *aIterator)
|
const otCoapOption *
Returns a pointer to the next option.
|
otCoapOptionIteratorGetNextOptionMatching(otCoapOptionIterator *aIterator, uint16_t aOption)
|
const otCoapOption *
Returns a pointer to the next option matching the specified option number.
|
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 . |
otCoapOptionIteratorInit(otCoapOptionIterator *aIterator, const otMessage *aMessage)
|
Initialises an iterator for the options in the given message.
|
otCoapRemoveBlockWiseResource(otInstance *aInstance, otCoapBlockwiseResource *aResource)
|
void
Removes a block-wise resource from the CoAP server.
|
otCoapRemoveResource(otInstance *aInstance, otCoapResource *aResource)
|
void
Removes a resource from the CoAP server.
|
otCoapSendRequest(otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo, otCoapResponseHandler aHandler, void *aContext)
|
Sends a CoAP request.
|
otCoapSendRequestBlockWise(otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo, otCoapResponseHandler aHandler, void *aContext, otCoapBlockwiseTransmitHook aTransmitHook, otCoapBlockwiseReceiveHook aReceiveHook)
|
Sends a CoAP request block-wise.
|
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.
|
otCoapSendRequestWithParameters(otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo, otCoapResponseHandler aHandler, void *aContext, const otCoapTxParameters *aTxParameters)
|
Sends a CoAP request with custom transmission parameters.
|
otCoapSendResponse(otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo)
|
Sends a CoAP response from the server.
|
otCoapSendResponseBlockWise(otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo, void *aContext, otCoapBlockwiseTransmitHook aTransmitHook)
|
Sends a CoAP response block-wise from the server.
|
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.
|
otCoapSendResponseWithParameters(otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo, const otCoapTxParameters *aTxParameters)
|
Sends a CoAP response from the server with custom transmission parameters.
|
otCoapSetDefaultHandler(otInstance *aInstance, otCoapRequestHandler aHandler, void *aContext)
|
void
Sets the default handler for unhandled CoAP requests.
|
otCoapStart(otInstance *aInstance, uint16_t aPort)
|
Starts the CoAP server.
|
otCoapStop(otInstance *aInstance)
|
Stops the CoAP server.
|
Macros |
|
---|---|
OT_COAP_CODE ((((c)&0x7) << 5) | ((d)&0x1f))
|
Helper macro to define CoAP Code values.
|
OT_COAP_DEFAULT_TOKEN_LENGTH 2
|
Default token length.
|
OT_COAP_MAX_RETRANSMIT 20
|
Max retransmit supported by OpenThread.
|
OT_COAP_MAX_TOKEN_LENGTH 8
|
Max token length as specified (RFC 7252).
|
OT_COAP_MIN_ACK_TIMEOUT 1000
|
Minimal ACK timeout in milliseconds supported by OpenThread.
|
OT_DEFAULT_COAP_PORT 5683
|
Default CoAP port, as specified in RFC 7252.
|
Structs |
|
---|---|
otCoapBlockwiseResource |
Represents a CoAP resource with block-wise transfer. |
otCoapOption |
Represents a CoAP option. |
otCoapOptionIterator |
Acts as an iterator for CoAP options. |
otCoapResource |
Represents a CoAP resource. |
otCoapTxParameters |
Represents the CoAP transmission parameters. |
Enumerations
otCoapBlockSzx
otCoapBlockSzx
CoAP Block Size Exponents.
otCoapCode
otCoapCode
CoAP Code values.
otCoapOptionContentFormat
otCoapOptionContentFormat
CoAP Content Format codes.
The full list is documented at https://www.iana.org/assignments/core-parameters/core-parameters.xhtml#content-formats
otCoapOptionType
otCoapOptionType
CoAP Option Numbers.
otCoapType
otCoapType
Typedefs
otCoapBlockwiseReceiveHook
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.
Is available when OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE configuration is enabled.
Details | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||||||
Return Values |
|
otCoapBlockwiseResource
struct otCoapBlockwiseResource otCoapBlockwiseResource
Represents a CoAP resource with block-wise transfer.
otCoapBlockwiseTransmitHook
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.
Is available when OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE configuration is enabled.
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.
Details | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||||
Return Values |
|
otCoapOptionContentFormat
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
otCoapOptionIterator
struct otCoapOptionIterator otCoapOptionIterator
Acts as an iterator for CoAP options.
otCoapRequestHandler
void(* otCoapRequestHandler)(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo)
Pointer is called when a CoAP request with a given Uri-Path is received.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
otCoapResponseHandler
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.
Details | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||
Return Values |
|
otCoapTxParameters
struct otCoapTxParameters otCoapTxParameters
Represents the CoAP transmission parameters.
Functions
otCoapAddBlockWiseResource
void otCoapAddBlockWiseResource( otInstance *aInstance, otCoapBlockwiseResource *aResource )
Adds a block-wise resource to the CoAP server.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
otCoapAddResource
void otCoapAddResource( otInstance *aInstance, otCoapResource *aResource )
Adds a resource to the CoAP server.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
otCoapBlockSizeFromExponent
uint16_t otCoapBlockSizeFromExponent( otCoapBlockSzx aSize )
Converts a CoAP Block option SZX field to the actual block size.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
The actual size exponent value.
|
otCoapMessageAppendBlock1Option
otError otCoapMessageAppendBlock1Option( otMessage *aMessage, uint32_t aNum, bool aMore, otCoapBlockSzx aSize )
Appends a Block1 option.
Details | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||
Return Values |
|
otCoapMessageAppendBlock2Option
otError otCoapMessageAppendBlock2Option( otMessage *aMessage, uint32_t aNum, bool aMore, otCoapBlockSzx aSize )
Appends a Block2 option.
Details | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||
Return Values |
|
otCoapMessageAppendContentFormatOption
otError otCoapMessageAppendContentFormatOption( otMessage *aMessage, otCoapOptionContentFormat aContentFormat )
Appends the Content Format CoAP option as specified in https://tools.ietf.org/html/rfc7252#page-92.
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.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Return Values |
|
otCoapMessageAppendMaxAgeOption
otError otCoapMessageAppendMaxAgeOption( otMessage *aMessage, uint32_t aMaxAge )
Appends a Max-Age option.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Return Values |
|
otCoapMessageAppendObserveOption
otError otCoapMessageAppendObserveOption( otMessage *aMessage, uint32_t aObserve )
Appends an Observe option.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Return Values |
|
otCoapMessageAppendOption
otError otCoapMessageAppendOption( otMessage *aMessage, uint16_t aNumber, uint16_t aLength, const void *aValue )
Appends a CoAP option in a header.
Details | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||
Return Values |
|
otCoapMessageAppendProxyUriOption
otError otCoapMessageAppendProxyUriOption( otMessage *aMessage, const char *aUriPath )
Appends a Proxy-Uri option.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Return Values |
|
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.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Return Values |
|
otCoapMessageGetOptionUintValue
otCoapMessageAppendUriPathOptions
otError otCoapMessageAppendUriPathOptions( otMessage *aMessage, const char *aUriPath )
Appends a Uri-Path option.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Return Values |
|
otCoapMessageAppendUriQueryOption
otError otCoapMessageAppendUriQueryOption( otMessage *aMessage, const char *aUriQuery )
Appends a single Uri-Query option.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Return Values |
|
otCoapMessageAppendUriQueryOptions
otError otCoapMessageAppendUriQueryOptions( otMessage *aMessage, const char *aUriQuery )
Appends a Uri-Query option.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Return Values |
|
otCoapMessageCodeToString
const char * otCoapMessageCodeToString( const otMessage *aMessage )
Returns the CoAP Code as human readable string.
@ returns The CoAP Code as string.
Details | |||
---|---|---|---|
Parameters |
|
otCoapMessageGenerateToken
void otCoapMessageGenerateToken( otMessage *aMessage, uint8_t aTokenLength )
Sets the Token length and randomizes its value.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
otCoapMessageGetCode
otCoapCode otCoapMessageGetCode( const otMessage *aMessage )
Returns the Code value.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
The Code value.
|
otCoapMessageGetMessageId
uint16_t otCoapMessageGetMessageId( const otMessage *aMessage )
Returns the Message ID value.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
The Message ID value.
|
otCoapMessageGetToken
const uint8_t * otCoapMessageGetToken( const otMessage *aMessage )
Returns a pointer to the Token value.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
A pointer to the Token value.
|
otCoapMessageGetTokenLength
uint8_t otCoapMessageGetTokenLength( const otMessage *aMessage )
Returns the Token length.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
The Token length.
|
otCoapMessageGetType
otCoapType otCoapMessageGetType( const otMessage *aMessage )
Returns the Type value.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
The Type value.
|
otCoapMessageInit
void otCoapMessageInit( otMessage *aMessage, otCoapType aType, otCoapCode aCode )
Initializes the CoAP header.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
otCoapMessageInitResponse
otError otCoapMessageInitResponse( otMessage *aResponse, const otMessage *aRequest, otCoapType aType, otCoapCode aCode )
Initializes a response message.
Details | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||
Return Values |
|
otCoapMessageSetCode
void otCoapMessageSetCode( otMessage *aMessage, otCoapCode aCode )
Sets the Code value.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
otCoapMessageSetPayloadMarker
otError otCoapMessageSetPayloadMarker( otMessage *aMessage )
Adds Payload Marker indicating beginning of the payload to the CoAP header.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Return Values |
|
otCoapMessageSetToken
otError otCoapMessageSetToken( otMessage *aMessage, const uint8_t *aToken, uint8_t aTokenLength )
Sets the Token value and length in a header.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Return Values |
|
otCoapNewMessage
otMessage * otCoapNewMessage( otInstance *aInstance, const otMessageSettings *aSettings )
Creates a new CoAP message.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Returns |
A pointer to the message buffer or NULL if no message buffers are available or parameters are invalid.
|
otCoapOptionIteratorGetFirstOption
const otCoapOption * otCoapOptionIteratorGetFirstOption( otCoapOptionIterator *aIterator )
Returns a pointer to the first option.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
A pointer to the first option. If no option is present NULL pointer is returned.
|
otCoapOptionIteratorGetFirstOptionMatching
const otCoapOption * otCoapOptionIteratorGetFirstOptionMatching( otCoapOptionIterator *aIterator, uint16_t aOption )
Returns a pointer to the first option matching the specified option number.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Returns |
A pointer to the first matching option. If no matching option is present NULL pointer is returned.
|
otCoapOptionIteratorGetNextOption
const otCoapOption * otCoapOptionIteratorGetNextOption( otCoapOptionIterator *aIterator )
Returns a pointer to the next option.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
A pointer to the next option. If no more options are present NULL pointer is returned.
|
otCoapOptionIteratorGetNextOptionMatching
const otCoapOption * otCoapOptionIteratorGetNextOptionMatching( otCoapOptionIterator *aIterator, uint16_t aOption )
Returns a pointer to the next option matching the specified option number.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Returns |
A pointer to the next matching option. If no further matching option is present NULL pointer is returned.
|
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.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Return Values |
|
otCoapMessageAppendUintOption
otCoapOptionIteratorGetOptionValue
otError otCoapOptionIteratorGetOptionValue( otCoapOptionIterator *aIterator, void *aValue )
Fills current option value into aValue
.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Return Values |
|
otCoapOptionIteratorInit
otError otCoapOptionIteratorInit( otCoapOptionIterator *aIterator, const otMessage *aMessage )
Initialises an iterator for the options in the given message.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Return Values |
|
otCoapRemoveBlockWiseResource
void otCoapRemoveBlockWiseResource( otInstance *aInstance, otCoapBlockwiseResource *aResource )
Removes a block-wise resource from the CoAP server.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
otCoapRemoveResource
void otCoapRemoveResource( otInstance *aInstance, otCoapResource *aResource )
Removes a resource from the CoAP server.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
otCoapSendRequest
otError otCoapSendRequest( otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo, otCoapResponseHandler aHandler, void *aContext )
Sends a CoAP request.
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.
Details | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||||
Return Values |
|
otCoapSendRequestBlockWise
otError otCoapSendRequestBlockWise( otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo, otCoapResponseHandler aHandler, void *aContext, otCoapBlockwiseTransmitHook aTransmitHook, otCoapBlockwiseReceiveHook aReceiveHook )
Sends a CoAP request block-wise.
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.
Details | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||||||||
Return Values |
|
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.
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.
Details | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||||||||||
Return Values |
|
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.
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.
Details | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||||||
Return Values |
|
otCoapSendResponse
otError otCoapSendResponse( otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo )
Sends a CoAP response from the server.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Return Values |
|
otCoapSendResponseBlockWise
otError otCoapSendResponseBlockWise( otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo, void *aContext, otCoapBlockwiseTransmitHook aTransmitHook )
Sends a CoAP response block-wise from the server.
Is available when OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE configuration is enabled.
Details | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||||
Return Values |
|
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.
Is available when OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE configuration is enabled.
Details | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||||||
Return Values |
|
otCoapSendResponseWithParameters
otError otCoapSendResponseWithParameters( otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo, const otCoapTxParameters *aTxParameters )
Sends a CoAP response from the server with custom transmission parameters.
Details | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||
Return Values |
|
otCoapSetDefaultHandler
void otCoapSetDefaultHandler( otInstance *aInstance, otCoapRequestHandler aHandler, void *aContext )
Sets the default handler for unhandled CoAP requests.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
otCoapStart
otError otCoapStart( otInstance *aInstance, uint16_t aPort )
Starts the CoAP server.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Return Values |
|
otCoapStop
otError otCoapStop( otInstance *aInstance )
Stops the CoAP server.
Details | |||
---|---|---|---|
Parameters |
|
||
Return Values |
|
Macros
OT_COAP_CODE
OT_COAP_CODE ((((c)&0x7) << 5) | ((d)&0x1f))
Helper macro to define CoAP Code values.
OT_COAP_DEFAULT_TOKEN_LENGTH
OT_COAP_DEFAULT_TOKEN_LENGTH 2
Default token length.
OT_COAP_MAX_RETRANSMIT
OT_COAP_MAX_RETRANSMIT 20
Max retransmit supported by OpenThread.
OT_COAP_MAX_TOKEN_LENGTH
OT_COAP_MAX_TOKEN_LENGTH 8
Max token length as specified (RFC 7252).
OT_COAP_MIN_ACK_TIMEOUT
OT_COAP_MIN_ACK_TIMEOUT 1000
Minimal ACK timeout in milliseconds supported by OpenThread.
OT_DEFAULT_COAP_PORT
OT_DEFAULT_COAP_PORT 5683
Default CoAP port, as specified in RFC 7252.
Resources
OpenThread API Reference topics originate from the source code, available on GitHub. For more information, or to contribute to our documentation, refer to Resources.