This module includes functions that control CoAP communication. More...
Data Structures | |
struct | otCoapOption |
struct | otCoapHeader |
struct | otCoapResource |
Macros | |
#define | OT_DEFAULT_COAP_PORT 5683 |
Default CoAP port, as specified in RFC 7252. | |
#define | OT_COAP_CODE(c, d) ((((c) & 0x7) << 5) | ((d) & 0x1f)) |
#define | OT_COAP_HEADER_MAX_LENGTH 128 |
Max CoAP header length (bytes) | |
Typedefs | |
typedef enum otCoapType | otCoapType |
typedef enum otCoapCode | otCoapCode |
typedef enum otCoapOptionType | otCoapOptionType |
typedef struct otCoapOption | otCoapOption |
typedef enum otCoapOptionContentFormat | otCoapOptionContentFormat |
typedef struct otCoapHeader | otCoapHeader |
typedef void(* | otCoapResponseHandler )(void *aContext, otCoapHeader *aHeader, otMessage *aMessage, const otMessageInfo *aMessageInfo, otError aResult) |
typedef void(* | otCoapRequestHandler )(void *aContext, otCoapHeader *aHeader, otMessage *aMessage, const otMessageInfo *aMessageInfo) |
typedef struct otCoapResource | otCoapResource |
Enumerations | |
enum | otCoapType { OT_COAP_TYPE_CONFIRMABLE = 0x00, OT_COAP_TYPE_NON_CONFIRMABLE = 0x10, OT_COAP_TYPE_ACKNOWLEDGMENT = 0x20, OT_COAP_TYPE_RESET = 0x30 } |
enum | otCoapCode { OT_COAP_CODE_EMPTY = (((( 0 ) & 0x7) << 5) | (( 0 ) & 0x1f)), OT_COAP_CODE_GET = (((( 0 ) & 0x7) << 5) | (( 1 ) & 0x1f)), OT_COAP_CODE_POST = (((( 0 ) & 0x7) << 5) | (( 2 ) & 0x1f)), OT_COAP_CODE_PUT = (((( 0 ) & 0x7) << 5) | (( 3 ) & 0x1f)), OT_COAP_CODE_DELETE = (((( 0 ) & 0x7) << 5) | (( 4 ) & 0x1f)), OT_COAP_CODE_RESPONSE_MIN = (((( 2 ) & 0x7) << 5) | (( 0 ) & 0x1f)), OT_COAP_CODE_CREATED = (((( 2 ) & 0x7) << 5) | (( 1 ) & 0x1f)), OT_COAP_CODE_DELETED = (((( 2 ) & 0x7) << 5) | (( 2 ) & 0x1f)), OT_COAP_CODE_VALID = (((( 2 ) & 0x7) << 5) | (( 3 ) & 0x1f)), OT_COAP_CODE_CHANGED = (((( 2 ) & 0x7) << 5) | (( 4 ) & 0x1f)), OT_COAP_CODE_CONTENT = (((( 2 ) & 0x7) << 5) | (( 5 ) & 0x1f)), OT_COAP_CODE_BAD_REQUEST = (((( 4 ) & 0x7) << 5) | (( 0 ) & 0x1f)), OT_COAP_CODE_UNAUTHORIZED = (((( 4 ) & 0x7) << 5) | (( 1 ) & 0x1f)), OT_COAP_CODE_BAD_OPTION = (((( 4 ) & 0x7) << 5) | (( 2 ) & 0x1f)), OT_COAP_CODE_FORBIDDEN = (((( 4 ) & 0x7) << 5) | (( 3 ) & 0x1f)), OT_COAP_CODE_NOT_FOUND = (((( 4 ) & 0x7) << 5) | (( 4 ) & 0x1f)), OT_COAP_CODE_METHOD_NOT_ALLOWED = (((( 4 ) & 0x7) << 5) | (( 5 ) & 0x1f)), OT_COAP_CODE_NOT_ACCEPTABLE = (((( 4 ) & 0x7) << 5) | (( 6 ) & 0x1f)), OT_COAP_CODE_PRECONDITION_FAILED = (((( 4 ) & 0x7) << 5) | (( 12 ) & 0x1f)), OT_COAP_CODE_REQUEST_TOO_LARGE = (((( 4 ) & 0x7) << 5) | (( 13 ) & 0x1f)), OT_COAP_CODE_UNSUPPORTED_FORMAT = (((( 4 ) & 0x7) << 5) | (( 15 ) & 0x1f)), OT_COAP_CODE_INTERNAL_ERROR = (((( 5 ) & 0x7) << 5) | (( 0 ) & 0x1f)), OT_COAP_CODE_NOT_IMPLEMENTED = (((( 5 ) & 0x7) << 5) | (( 1 ) & 0x1f)), OT_COAP_CODE_BAD_GATEWAY = (((( 5 ) & 0x7) << 5) | (( 2 ) & 0x1f)), OT_COAP_CODE_SERVICE_UNAVAILABLE = (((( 5 ) & 0x7) << 5) | (( 3 ) & 0x1f)), OT_COAP_CODE_GATEWAY_TIMEOUT = (((( 5 ) & 0x7) << 5) | (( 4 ) & 0x1f)), OT_COAP_CODE_PROXY_NOT_SUPPORTED = (((( 5 ) & 0x7) << 5) | (( 5 ) & 0x1f)) } |
enum | otCoapOptionType { OT_COAP_OPTION_IF_MATCH = 1, OT_COAP_OPTION_URI_HOST = 3, OT_COAP_OPTION_E_TAG = 4, OT_COAP_OPTION_IF_NONE_MATCH = 5, OT_COAP_OPTION_OBSERVE = 6, OT_COAP_OPTION_URI_PORT = 7, OT_COAP_OPTION_LOCATION_PATH = 8, OT_COAP_OPTION_URI_PATH = 11, OT_COAP_OPTION_CONTENT_FORMAT = 12, OT_COAP_OPTION_MAX_AGE = 14, OT_COAP_OPTION_URI_QUERY = 15, OT_COAP_OPTION_ACCEPT = 17, OT_COAP_OPTION_LOCATION_QUERY = 20, OT_COAP_OPTION_PROXY_URI = 35, OT_COAP_OPTION_PROXY_SCHEME = 39, OT_COAP_OPTION_SIZE1 = 60 } |
enum | otCoapOptionContentFormat { OT_COAP_OPTION_CONTENT_FORMAT_TEXT_PLAIN = 0, OT_COAP_OPTION_CONTENT_FORMAT_LINK_FORMAT = 40, OT_COAP_OPTION_CONTENT_FORMAT_XML = 41, OT_COAP_OPTION_CONTENT_FORMAT_OCTET_STREAM = 42, OT_COAP_OPTION_CONTENT_FORMAT_EXI = 47, OT_COAP_OPTION_CONTENT_FORMAT_JSON = 50 } |
This module includes functions that control CoAP communication.
#define OT_COAP_CODE | ( | c, | |
d | |||
) | ((((c) & 0x7) << 5) | ((d) & 0x1f)) |
Helper macro to define CoAP Code values.
typedef enum otCoapCode otCoapCode |
CoAP Code values.
typedef struct otCoapHeader otCoapHeader |
This structure represents a CoAP header.
typedef struct otCoapOption otCoapOption |
This structure represents a CoAP option.
typedef enum otCoapOptionContentFormat otCoapOptionContentFormat |
CoAP Content Format codes. The full list is documented at https://tools.ietf.org/html/rfc7252#page-92
typedef enum otCoapOptionType otCoapOptionType |
CoAP Option Numbers
typedef void(* otCoapRequestHandler)(void *aContext, otCoapHeader *aHeader, otMessage *aMessage, const otMessageInfo *aMessageInfo) |
This function pointer is called when a CoAP request with a given Uri-Path is received.
[in] | aContext | A pointer to arbitrary context information. |
[in] | aHeader | A pointer to the CoAP header. |
[in] | aMessage | A pointer to the message. |
[in] | aMessageInfo | A pointer to the message info for aMessage . |
typedef struct otCoapResource otCoapResource |
This structure represents a CoAP resource.
typedef void(* otCoapResponseHandler)(void *aContext, otCoapHeader *aHeader, otMessage *aMessage, const otMessageInfo *aMessageInfo, otError aResult) |
This function pointer is called when a CoAP response is received or on the request timeout.
[in] | aContext | A pointer to application-specific context. |
[in] | aHeader | A pointer to the received CoAP header. NULL if no response was received. |
[in] | aMessage | A pointer to the message buffer containing the response. NULL if no response was received. |
[in] | aMessageInfo | A pointer to the message info for aMessage . NULL if no response was received. |
[in] | aResult | A result of the CoAP transaction. |
OT_ERROR_NONE | A response was received successfully. |
OT_ERROR_ABORT | A CoAP transaction was reseted by peer. |
OT_ERROR_RESPONSE_TIMEOUT | No response or acknowledgment received during timeout period. |
typedef enum otCoapType otCoapType |
CoAP Type values.
enum otCoapCode |
CoAP Code values.
CoAP Content Format codes. The full list is documented at https://tools.ietf.org/html/rfc7252#page-92
enum otCoapOptionType |
CoAP Option Numbers
enum otCoapType |