37#define COAP_DEFAULT_PORT 5683
38#define COAPS_DEFAULT_PORT 5684
39#define COAP_DEFAULT_MAX_AGE 60
40#ifndef COAP_DEFAULT_MTU
41#define COAP_DEFAULT_MTU 1152
44#define COAP_BERT_BASE 1152
46#ifndef COAP_DEFAULT_HOP_LIMIT
47#define COAP_DEFAULT_HOP_LIMIT 16
50#define COAP_DEFAULT_SCHEME "coap"
53#define COAP_DEFAULT_URI_WELLKNOWN ".well-known/core"
56#define COAP_TOKEN_DEFAULT_MAX 8
57#define COAP_TOKEN_EXT_MAX 65804
115#define COAP_OPTION_IF_MATCH 1
116#define COAP_OPTION_URI_HOST 3
117#define COAP_OPTION_ETAG 4
118#define COAP_OPTION_IF_NONE_MATCH 5
119#define COAP_OPTION_OBSERVE 6
120#define COAP_OPTION_URI_PORT 7
121#define COAP_OPTION_LOCATION_PATH 8
122#define COAP_OPTION_OSCORE 9
123#define COAP_OPTION_URI_PATH 11
124#define COAP_OPTION_CONTENT_FORMAT 12
125#define COAP_OPTION_CONTENT_TYPE COAP_OPTION_CONTENT_FORMAT
127#define COAP_OPTION_MAXAGE 14
128#define COAP_OPTION_URI_QUERY 15
129#define COAP_OPTION_HOP_LIMIT 16
130#define COAP_OPTION_ACCEPT 17
131#define COAP_OPTION_Q_BLOCK1 19
132#define COAP_OPTION_LOCATION_QUERY 20
133#define COAP_OPTION_BLOCK2 23
134#define COAP_OPTION_BLOCK1 27
135#define COAP_OPTION_SIZE2 28
136#define COAP_OPTION_Q_BLOCK2 31
137#define COAP_OPTION_PROXY_URI 35
138#define COAP_OPTION_PROXY_SCHEME 39
139#define COAP_OPTION_SIZE1 60
140#define COAP_OPTION_ECHO 252
141#define COAP_OPTION_NORESPONSE 258
142#define COAP_OPTION_RTAG 292
144#define COAP_MAX_OPT 65535
152#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
155#define COAP_RESPONSE_CLASS(C) (((C) >> 5) & 0xFF)
157#ifndef SHORT_ERROR_RESPONSE
170#define COAP_ERROR_PHRASE_LENGTH 32
173#define coap_response_phrase(x) ((char *)NULL)
175#define COAP_ERROR_PHRASE_LENGTH 0
178#define COAP_SIGNALING_CODE(N) (((N)/100 << 5) | (N)%100)
189#define COAP_SIGNALING_OPTION_MAX_MESSAGE_SIZE 2
190#define COAP_SIGNALING_OPTION_BLOCK_WISE_TRANSFER 4
191#define COAP_SIGNALING_OPTION_EXTENDED_TOKEN_LENGTH 6
194#define COAP_SIGNALING_OPTION_CUSTODY 2
197#define COAP_SIGNALING_OPTION_ALTERNATIVE_ADDRESS 2
198#define COAP_SIGNALING_OPTION_HOLD_OFF 4
201#define COAP_SIGNALING_OPTION_BAD_CSM_OPTION 2
205#define COAP_MEDIATYPE_TEXT_PLAIN 0
206#define COAP_MEDIATYPE_APPLICATION_LINK_FORMAT 40
207#define COAP_MEDIATYPE_APPLICATION_XML 41
208#define COAP_MEDIATYPE_APPLICATION_OCTET_STREAM 42
209#define COAP_MEDIATYPE_APPLICATION_RDF_XML 43
210#define COAP_MEDIATYPE_APPLICATION_EXI 47
211#define COAP_MEDIATYPE_APPLICATION_JSON 50
212#define COAP_MEDIATYPE_APPLICATION_CBOR 60
213#define COAP_MEDIATYPE_APPLICATION_CWT 61
216#define COAP_MEDIATYPE_APPLICATION_COAP_GROUP_JSON 256
219#define COAP_MEDIATYPE_APPLICATION_COSE_SIGN 98
220#define COAP_MEDIATYPE_APPLICATION_COSE_SIGN1 18
221#define COAP_MEDIATYPE_APPLICATION_COSE_ENCRYPT 96
222#define COAP_MEDIATYPE_APPLICATION_COSE_ENCRYPT0 16
223#define COAP_MEDIATYPE_APPLICATION_COSE_MAC 97
224#define COAP_MEDIATYPE_APPLICATION_COSE_MAC0 17
226#define COAP_MEDIATYPE_APPLICATION_COSE_KEY 101
227#define COAP_MEDIATYPE_APPLICATION_COSE_KEY_SET 102
230#define COAP_MEDIATYPE_APPLICATION_SENML_JSON 110
231#define COAP_MEDIATYPE_APPLICATION_SENSML_JSON 111
232#define COAP_MEDIATYPE_APPLICATION_SENML_CBOR 112
233#define COAP_MEDIATYPE_APPLICATION_SENSML_CBOR 113
234#define COAP_MEDIATYPE_APPLICATION_SENML_EXI 114
235#define COAP_MEDIATYPE_APPLICATION_SENSML_EXI 115
236#define COAP_MEDIATYPE_APPLICATION_SENML_XML 310
237#define COAP_MEDIATYPE_APPLICATION_SENSML_XML 311
240#define COAP_MEDIATYPE_APPLICATION_DOTS_CBOR 271
243#define COAP_MEDIATYPE_APPLICATION_ACE_CBOR 19
246#define COAP_MEDIATYPE_APPLICATION_MB_CBOR_SEQ 272
249#define COAP_MEDIATYPE_APPLICATION_OSCORE 10001
258#define COAP_INVALID_MID -1
264#define COAP_INVALID_TID COAP_INVALID_MID
278#define COAP_OPTION_KEY(option) (option).key
279#define COAP_OPTION_LENGTH(option) (option).length
280#define COAP_OPTION_DATA(option) ((unsigned char *)&(option) + sizeof(coap_option))
298coap_pdu_t *coap_pdu_from_pbuf(
struct pbuf *pbuf);
420 const uint8_t *token,
458 const uint8_t *data);
484 const uint8_t *data);
499 const uint8_t *data);
529 const uint8_t **data);
550 const uint8_t **data,
Helpers for handling options in CoAP PDUs.
uint16_t coap_option_num_t
Helper functions for URI treatment.
coap_pdu_code_t coap_pdu_get_code(const coap_pdu_t *pdu)
Gets the PDU code associated with pdu.
const char * coap_response_phrase(unsigned char code)
Returns a human-readable response phrase for the specified CoAP response code.
uint8_t * coap_add_data_after(coap_pdu_t *pdu, size_t len)
Adds given data to the pdu that is passed as first parameter but does not.
void coap_delete_pdu(coap_pdu_t *pdu)
Dispose of an CoAP PDU and frees associated storage.
void coap_pdu_set_code(coap_pdu_t *pdu, coap_pdu_code_t code)
Sets the PDU code in the pdu.
int coap_mid_t
coap_mid_t is used to store the CoAP Message ID of a CoAP PDU.
coap_request_t
CoAP PDU Request methods.
#define COAP_RESPONSE_CODE(N)
#define COAP_SIGNALING_CODE(N)
coap_proto_t
CoAP protocol types.
coap_pdu_t * coap_new_pdu(coap_pdu_type_t type, coap_pdu_code_t code, coap_session_t *session)
Creates a new CoAP PDU.
coap_pdu_code_t
Set of codes available for a PDU.
coap_pdu_type_t
CoAP PDU message type definitions.
int coap_add_token(coap_pdu_t *pdu, size_t len, const uint8_t *data)
Adds token of length len to pdu.
void coap_pdu_set_type(coap_pdu_t *pdu, coap_pdu_type_t type)
Sets the PDU type in the pdu.
size_t coap_add_option(coap_pdu_t *pdu, coap_option_num_t number, size_t len, const uint8_t *data)
Adds option of given number to pdu that is passed as first parameter.
coap_pdu_signaling_proto_t
coap_pdu_type_t coap_pdu_get_type(const coap_pdu_t *pdu)
Gets the PDU type associated with pdu.
int coap_get_data(const coap_pdu_t *pdu, size_t *len, const uint8_t **data)
Retrieves the length and data pointer of specified PDU.
int coap_pdu_parse(coap_proto_t proto, const uint8_t *data, size_t length, coap_pdu_t *pdu)
Parses data into the CoAP PDU structure given in result.
void coap_pdu_set_mid(coap_pdu_t *pdu, coap_mid_t mid)
Sets the message id in the pdu.
coap_pdu_t * coap_pdu_duplicate(const coap_pdu_t *old_pdu, coap_session_t *session, size_t token_length, const uint8_t *token, coap_opt_filter_t *drop_options)
Duplicate an existing PDU.
coap_pdu_t * coap_pdu_init(coap_pdu_type_t type, coap_pdu_code_t code, coap_mid_t mid, size_t size)
Creates a new CoAP PDU with at least enough storage space for the given size maximum message size.
int coap_get_data_large(const coap_pdu_t *pdu, size_t *len, const uint8_t **data, size_t *offset, size_t *total)
Retrieves the data from a PDU, with support for large bodies of data that spans multiple PDUs.
coap_mid_t coap_pdu_get_mid(const coap_pdu_t *pdu)
Gets the message id associated with pdu.
int coap_add_data(coap_pdu_t *pdu, size_t len, const uint8_t *data)
Adds given data to the pdu that is passed as first parameter.
coap_bin_const_t coap_pdu_get_token(const coap_pdu_t *pdu)
Gets the token associated with pdu.
@ COAP_RESPONSE_CODE_INTERNAL_ERROR
@ COAP_RESPONSE_CODE_HOP_LIMIT_REACHED
@ COAP_SIGNALING_CODE_ABORT
@ COAP_RESPONSE_CODE_PRECONDITION_FAILED
@ COAP_RESPONSE_CODE_NOT_ALLOWED
@ COAP_RESPONSE_CODE_CHANGED
@ COAP_RESPONSE_CODE_NOT_ACCEPTABLE
@ COAP_SIGNALING_CODE_CSM
@ COAP_REQUEST_CODE_PATCH
@ COAP_RESPONSE_CODE_PROXYING_NOT_SUPPORTED
@ COAP_RESPONSE_CODE_BAD_REQUEST
@ COAP_SIGNALING_CODE_PING
@ COAP_RESPONSE_CODE_INCOMPLETE
@ COAP_REQUEST_CODE_DELETE
@ COAP_SIGNALING_CODE_PONG
@ COAP_RESPONSE_CODE_NOT_IMPLEMENTED
@ COAP_RESPONSE_CODE_NOT_FOUND
@ COAP_RESPONSE_CODE_BAD_GATEWAY
@ COAP_RESPONSE_CODE_BAD_OPTION
@ COAP_RESPONSE_CODE_REQUEST_TOO_LARGE
@ COAP_RESPONSE_CODE_TOO_MANY_REQUESTS
@ COAP_RESPONSE_CODE_CONFLICT
@ COAP_RESPONSE_CODE_DELETED
@ COAP_RESPONSE_CODE_UNAUTHORIZED
@ COAP_RESPONSE_CODE_CREATED
@ COAP_RESPONSE_CODE_CONTENT
@ COAP_RESPONSE_CODE_UNPROCESSABLE
@ COAP_RESPONSE_CODE_CONTINUE
@ COAP_RESPONSE_CODE_VALID
@ COAP_RESPONSE_CODE_UNSUPPORTED_CONTENT_FORMAT
@ COAP_SIGNALING_CODE_RELEASE
@ COAP_REQUEST_CODE_FETCH
@ COAP_RESPONSE_CODE_GATEWAY_TIMEOUT
@ COAP_REQUEST_CODE_IPATCH
@ COAP_RESPONSE_CODE_SERVICE_UNAVAILABLE
@ COAP_RESPONSE_CODE_FORBIDDEN
CoAP binary data definition with const data.
Abstraction of virtual session that can be attached to coap_context_t (client) or coap_endpoint_t (se...