35 #ifndef OPENTHREAD_COAP_H_ 36 #define OPENTHREAD_COAP_H_ 60 #define OT_DEFAULT_COAP_PORT 5683 78 #define OT_COAP_CODE(c, d) ((((c) & 0x7) << 5) | ((d) & 0x1f)) 166 #define OT_COAP_HEADER_MAX_LENGTH 128 uint16_t mLength
Option Length.
Definition: coap.h:148
void otCoapHeaderSetToken(otCoapHeader *aHeader, const uint8_t *aToken, uint8_t aTokenLength)
This function sets the Token value and length in a header.
Uri-Query.
Definition: coap.h:133
This type represents all the static / global variables used by OpenThread allocated in one place...
Definition: openthread-instance.h:59
This file defines the types and structures used in the OpenThread library API.
otCoapCode
CoAP Code values.
Definition: coap.h:84
const uint8_t * mValue
A pointer to the Option Value.
Definition: coap.h:149
otCoapOptionType
CoAP Option Numbers.
Definition: coap.h:121
otError otCoapHeaderAppendMaxAgeOption(otCoapHeader *aHeader, uint32_t aMaxAge)
This function appends a Max-Age option.
Delete.
Definition: coap.h:90
otCoapType otCoapHeaderGetType(const otCoapHeader *aHeader)
This function returns the Type value.
Content.
Definition: coap.h:97
const char * mUriPath
The URI Path string.
Definition: coap.h:226
struct otCoapResource otCoapResource
This structure represents a CoAP resource.
Location-Path.
Definition: coap.h:129
Acknowledgment.
Definition: coap.h:70
Changed.
Definition: coap.h:96
Unauthorized.
Definition: coap.h:100
Internal Server Error.
Definition: coap.h:110
void otCoapHeaderSetPayloadMarker(otCoapHeader *aHeader)
This function adds Payload Marker indicating beginning of the payload to the CoAP header...
otCoapCode otCoapHeaderGetCode(const otCoapHeader *aHeader)
This function returns the Code value.
This structure represents a CoAP option.
Definition: coap.h:145
void otCoapHeaderInit(otCoapHeader *aHeader, otCoapType aType, otCoapCode aCode)
This function initializes the CoAP header.
otError otCoapHeaderAppendUriPathOptions(otCoapHeader *aHeader, const char *aUriPath)
This function appends an Uri-Path option.
const otCoapOption * otCoapHeaderGetNextOption(otCoapHeader *aHeader)
This function returns a pointer to the next option.
struct otCoapHeader otCoapHeader
This structure represents a CoAP header.
otError otCoapSendRequest(otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo, otCoapResponseHandler aHandler, void *aContext)
This function sends a CoAP request.
This file defines the top-level OpenThread APIs related to message buffer and queues.
Reset.
Definition: coap.h:71
struct otCoapResource * mNext
The next CoAP resource in the list.
Definition: coap.h:229
Valid.
Definition: coap.h:95
Max-Age.
Definition: coap.h:132
Put.
Definition: coap.h:89
otError otCoapStop(otInstance *aInstance)
This function stops the CoAP server.
2.00
Definition: coap.h:92
This type points to an OpenThread message buffer.
Definition: types.h:479
application/exi
Definition: coap.h:162
Size1.
Definition: coap.h:138
application/link-format
Definition: coap.h:159
void otCoapSetDefaultHandler(otInstance *aInstance, otCoapRequestHandler aHandler, void *aContext)
This function sets the default handler for unhandled CoAP requests.
Proxy-Scheme.
Definition: coap.h:137
Empty message code.
Definition: coap.h:86
otCoapType
CoAP Type values.
Definition: coap.h:66
This structure represents a CoAP resource.
Definition: coap.h:224
Uri-Path.
Definition: coap.h:130
struct otCoapOption otCoapOption
This structure represents a CoAP option.
Bad Request.
Definition: coap.h:99
Not Found.
Definition: coap.h:103
#define OT_COAP_HEADER_MAX_LENGTH
Max CoAP header length (bytes)
Definition: coap.h:166
otError otCoapHeaderAppendUriQueryOption(otCoapHeader *aHeader, const char *aUriQuery)
This function appends a single Uri-Query option.
otError otCoapHeaderAppendObserveOption(otCoapHeader *aHeader, uint32_t aObserve)
This function appends an Observe option.
If-Match.
Definition: coap.h:123
void otCoapHeaderGenerateToken(otCoapHeader *aHeader, uint8_t aTokenLength)
This function sets the Token length and randomizes its value.
otError otCoapHeaderAppendContentFormatOption(otCoapHeader *aHeader, otCoapOptionContentFormat aContentFormat)
This function appends the Content Format CoAP option as specified in https://tools.ietf.org/html/rfc7252#page-92.
void otCoapHeaderSetMessageId(otCoapHeader *aHeader, uint16_t aMessageId)
This function sets the Message ID value.
void otCoapRemoveResource(otInstance *aInstance, otCoapResource *aResource)
This function removes a resource from the CoAP server.
Non-confirmable.
Definition: coap.h:69
ETag.
Definition: coap.h:125
const otCoapOption * otCoapHeaderGetFirstOption(otCoapHeader *aHeader)
This function returns a pointer to the first option.
Bad Option.
Definition: coap.h:101
otError otCoapHeaderAppendOption(otCoapHeader *aHeader, const otCoapOption *aOption)
This function appends a CoAP option in a header.
Forbidden.
Definition: coap.h:102
Get.
Definition: coap.h:87
Precondition Failed.
Definition: coap.h:106
otError otCoapSendResponse(otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo)
This function sends a CoAP response from the server.
Unsupported Content-Format.
Definition: coap.h:108
If-None-Match.
Definition: coap.h:126
otCoapRequestHandler mHandler
The callback for handling a received request.
Definition: coap.h:227
Uri-Host.
Definition: coap.h:124
Service Unavailable.
Definition: coap.h:113
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...
Definition: coap.h:205
const uint8_t * otCoapHeaderGetToken(const otCoapHeader *aHeader)
This function returns a pointer to the Token value.
Uri-Port.
Definition: coap.h:128
This structure represents the local and peer IPv6 socket addresses.
Definition: types.h:436
Not Acceptable.
Definition: coap.h:105
Created.
Definition: coap.h:93
Observe.
Definition: coap.h:127
text/plain
Definition: coap.h:158
Deleted.
Definition: coap.h:94
Location-Query.
Definition: coap.h:135
void * mContext
Application-specific context.
Definition: coap.h:228
application/json
Definition: coap.h:163
Request Entity Too Large.
Definition: coap.h:107
#define OT_COAP_CODE(c, d)
Helper macro to define CoAP Code values.
Definition: coap.h:78
Method Not Allowed.
Definition: coap.h:104
otMessage * otCoapNewMessage(otInstance *aInstance, const otCoapHeader *aHeader)
This function creates a new message with a CoAP header.
Content-Format.
Definition: coap.h:131
application/xml
Definition: coap.h:160
uint16_t otCoapHeaderGetMessageId(const otCoapHeader *aHeader)
This function returns the Message ID value.
otError otCoapStart(otInstance *aInstance, uint16_t aPort)
This function starts the CoAP server.
uint8_t otCoapHeaderGetTokenLength(const otCoapHeader *aHeader)
This function returns the Token length.
Proxying Not Supported.
Definition: coap.h:115
Bad Gateway.
Definition: coap.h:112
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.
Definition: coap.h:217
otError otCoapAddResource(otInstance *aInstance, otCoapResource *aResource)
This function adds a resource to the CoAP server.
Accept.
Definition: coap.h:134
otCoapOptionContentFormat
CoAP Content Format codes.
Definition: coap.h:156
application/octet-stream
Definition: coap.h:161
Confirmable.
Definition: coap.h:68
otError
This enumeration represents error codes used throughout OpenThread.
Definition: types.h:107
uint16_t mNumber
Option Number.
Definition: coap.h:147
Not Implemented.
Definition: coap.h:111
otError otCoapHeaderAppendUintOption(otCoapHeader *aHeader, 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.
Proxy-Uri.
Definition: coap.h:136
Gateway Timeout.
Definition: coap.h:114
Post.
Definition: coap.h:88