Namespace for the library. More...
Namespaces | |
| namespace | Detail |
| Internal details of the library. Not for public use. | |
Classes | |
| class | Message |
| A CoAP message. More... | |
| class | Node |
| The CoAP node that runs on this device. More... | |
| class | Observer |
| A remote CoAP observer, actively observing a resource. More... | |
| class | ObserverRegistry |
| A resource observer registry. More... | |
| struct | Option |
| A CoAP option. More... | |
| class | OptionIterator |
| The option iterator. More... | |
Typedefs | |
| typedef void(* | Callback) (Message &message, IPAddress ip, uint16_t port) |
| Callback function type for handling incoming messages. | |
Enumerations | |
| enum class | MessageType : uint8_t { CON = 0 , NON = 1 , ACK = 2 , RST = 3 } |
| The CoAP message type. More... | |
| enum class | MessageCode : uint8_t { EMPTY = COAP_CODE_ENCODE(0, 0) , GET = COAP_CODE_ENCODE(0, 1) , POST = COAP_CODE_ENCODE(0, 2) , PUT = COAP_CODE_ENCODE(0, 3) , DELETE = COAP_CODE_ENCODE(0, 4) , CREATED = COAP_CODE_ENCODE(2, 1) , DELETED = COAP_CODE_ENCODE(2, 2) , VALID = COAP_CODE_ENCODE(2, 3) , CHANGED = COAP_CODE_ENCODE(2, 4) , CONTENT = COAP_CODE_ENCODE(2, 5) , BAD_REQUEST = COAP_CODE_ENCODE(4, 0) , UNAUTHORIZED = COAP_CODE_ENCODE(4, 1) , BAD_OPTION = COAP_CODE_ENCODE(4, 2) , FORBIDDEN = COAP_CODE_ENCODE(4, 3) , NOT_FOUND = COAP_CODE_ENCODE(4, 4) , METHOD_NOT_ALLOWED = COAP_CODE_ENCODE(4, 5) , NOT_ACCEPTABLE = COAP_CODE_ENCODE(4, 6) , PRECONDITION_FAILED = COAP_CODE_ENCODE(4, 12) , REQUEST_ENTITY_TOO_LARGE = COAP_CODE_ENCODE(4, 13) , UNSUPPORTED_CONTENT_FORMAT = COAP_CODE_ENCODE(4, 15) , INTERNAL_SERVER_ERROR = COAP_CODE_ENCODE(5, 0) , NOT_IMPLEMENTED = COAP_CODE_ENCODE(5, 1) , BAD_GATEWAY = COAP_CODE_ENCODE(5, 2) , SERVICE_UNAVAILABLE = COAP_CODE_ENCODE(5, 3) , GATEWAY_TIMEOUT = COAP_CODE_ENCODE(5, 4) , PROXYING_NOT_SUPPORTED = COAP_CODE_ENCODE(5, 5) } |
| The CoAP code. More... | |
| enum class | OptionNumber : uint16_t { IF_MATCH = 1 , URI_HOST = 3 , E_TAG = 4 , IF_NONE_MATCH = 5 , OBSERVE = 6 , URI_PORT = 7 , LOCATION_PATH = 8 , URI_PATH = 11 , CONTENT_FORMAT = 12 , MAX_AGE = 14 , URI_QUERY = 15 , ACCEPT = 17 , LOCATION_QUERY = 20 , PROXY_URI = 35 , PROXY_SCHEME = 39 , SIZE1 = 60 } |
| enum class | ContentFormat : uint16_t { TEXT_PLAIN = 0 , APPLICATION_LINK_FORMAT = 40 , APPLICATION_XML = 41 , APPLICATION_OCTET_STREAM = 42 , APPLICATION_EXI = 47 , APPLICATION_JSON = 50 , APPLICATION_CBOR = 60 } |
| The CoAP content format. More... | |
| enum class | ObserveValue : uint8_t { REGISTER = 0 , DEREGISTER = 1 } |
| Represents possible Observe option values. More... | |
| enum class | ErrorCode : int8_t { OK = 0 , NOT_FOUND = -1 , MESSAGE_TOO_LARGE = -2 , MALFORMED_MESSAGE = -3 , INVALID_ARGUMENT = -4 , NOT_SUPPORTED = -5 , NETWORK = -6 , UNEXPECTED = -99 } |
| Error codes used in the library. More... | |
Functions | |
| ErrorCode | getRandomToken (size_t length, uint8_t *buffer) |
| Generate a random token of the given length. | |
Namespace for the library.
All library enums, classes and functions are defined within this namespace.
Callback function type for handling incoming messages.
| message | The received CoAP message. |
| ip | The IP address of the sender. |
| port | The UDP port of the sender. |
|
strong |
The CoAP content format.
The numeric identifier can be in the range 0-65535. See https://datatracker.ietf.org/doc/html/rfc7252#section-5.10.3 and the relative initial registry at https://datatracker.ietf.org/doc/html/rfc7252#section-12.3
REVIEW: Expand as needed based on https://www.iana.org/assignments/core-parameters/core-parameters.xhtml#content-formats
| Enumerator | |
|---|---|
| TEXT_PLAIN | |
| APPLICATION_LINK_FORMAT | |
| APPLICATION_XML | |
| APPLICATION_OCTET_STREAM | |
| APPLICATION_EXI | |
| APPLICATION_JSON | |
| APPLICATION_CBOR | |
|
strong |
Error codes used in the library.
Negative values indicate errors.
| Enumerator | |
|---|---|
| OK | No error |
| NOT_FOUND | The requested resource was not found. |
| MESSAGE_TOO_LARGE | The message is too large to fit in the allocated buffer. The operation could not be performed because the message size will exceed COAP_MAX_MESSAGE_SIZE. |
| MALFORMED_MESSAGE | The message is malformed. |
| INVALID_ARGUMENT | One (or more) of the supplied arguments is invalid. |
| NOT_SUPPORTED | The operation is not supported. |
| NETWORK | A network error occurred. |
| UNEXPECTED | General unexpected failure. |
|
strong |
The CoAP code.
The code is defined in Section 3 of RFC 7252 as an 8-bit unsigned integer, split into a 3-bit class (most significant bits) and a 5-bit detail (least significant bits). The class 0 indicates a request, classes 2.xx, 4.xx, and 5.xx indicate responses.
The list of allowed codes is specified in the CoAP MessageCode Registries (https://datatracker.ietf.org/doc/html/rfc7252#section-12.1).
| Enumerator | |
|---|---|
| EMPTY | Empty message |
| GET | |
| POST | |
| PUT | |
| DELETE | |
| CREATED | Like HTTP 201 "Created", only used in response to POST and PUT requests. |
| DELETED | Like HTTP 204 "No Content", only used in response to DELETE or POST requests that cause the resource to cease being available. |
| VALID | Related to HTTP 304 "Not Modified", indicates the response identified by the entity-tag is valid. |
| CHANGED | Like HTTP 204 "No Content", only used in response to POST and PUT requests. |
| CONTENT | Like HTTP 200 "OK", only used in response to GET requests. |
| BAD_REQUEST | Like HTTP 400 "Bad Request". |
| UNAUTHORIZED | The client is not authorized to perform the requested action. |
| BAD_OPTION | The request could not be understood due to one or more unrecognized or malformed options. |
| FORBIDDEN | Like HTTP 403 "Forbidden". |
| NOT_FOUND | Like HTTP 404 "Not Found". |
| METHOD_NOT_ALLOWED | Like HTTP 405 "Method Not Allowed" but with no parallel to the "Allow" header field. |
| NOT_ACCEPTABLE | Like HTTP 406 "Not Acceptable", but with no response entity. |
| PRECONDITION_FAILED | Like HTTP 412 "Precondition Failed". |
| REQUEST_ENTITY_TOO_LARGE | Like HTTP 413 "Request Entity Too Large". |
| UNSUPPORTED_CONTENT_FORMAT | Like HTTP 415 "Unsupported Media MessageType". |
| INTERNAL_SERVER_ERROR | Like HTTP 500 "Internal Server Error". |
| NOT_IMPLEMENTED | Like HTTP 501 "Not Implemented". |
| BAD_GATEWAY | Like HTTP 502 "Bad Gateway". |
| SERVICE_UNAVAILABLE | Like HTTP 503 "Service Unavailable" but uses Max-Age Option instead of "Retry-After" header. |
| GATEWAY_TIMEOUT | Like HTTP 504 "Gateway Timeout". |
| PROXYING_NOT_SUPPORTED | The server is unable or unwilling to act as a forward-proxy for the URI specified in the Proxy-Uri Option. |
|
strong |
The CoAP message type.
It consists of 2 bits used to represent the message type in the CoAP header. See https://datatracker.ietf.org/doc/html/rfc7252#section-3
| Enumerator | |
|---|---|
| CON | Confirmable message |
| NON | Non-confirmable message |
| ACK | Acknowledgement message |
| RST | Reset message |
|
strong |
Represents possible Observe option values.
| Enumerator | |
|---|---|
| REGISTER | The register value for the Observe option. |
| DEREGISTER | The deregister value for the Observe option. |
|
strong |
CoAP Option Numbers Registry
https://datatracker.ietf.org/doc/html/rfc7252#section-12.2
| Enumerator | |
|---|---|
| IF_MATCH | |
| URI_HOST | |
| E_TAG | |
| IF_NONE_MATCH | |
| OBSERVE | |
| URI_PORT | |
| LOCATION_PATH | |
| URI_PATH | |
| CONTENT_FORMAT | |
| MAX_AGE | |
| URI_QUERY | |
| ACCEPT | |
| LOCATION_QUERY | |
| PROXY_URI | |
| PROXY_SCHEME | |
| SIZE1 | |