ProsecCoAP 🥂
 
Loading...
Searching...
No Matches
Definitions.h File Reference
#include <Arduino.h>
#include "Udp.h"

Go to the source code of this file.

Namespaces

namespace  Coap
 Namespace for the library.
 

Macros

#define COAP_MAX_MESSAGE_SIZE   128U
 Maximum size of a CoAP message in bytes.
 
#define COAP_MAX_CALLBACKS   10U
 Maximum number of callbacks that can be registered at runtime.
 
#define COAP_MAX_OBSERVERS   4U
 Maximum number of observers that can be registered at runtime.
 
#define COAP_OBSERVER_LEASE_MS   60000UL
 
#define COAP_ACK_MIN_TIMEOUT_MS   2000UL
 Minimum ACK timeout in milliseconds. See RFC 7252, Section 4.8. Default to 2 seconds (2000 ms).
 
#define COAP_ACK_RANDOM_FACTOR   1.5f
 ACK timeout random factor as per RFC 7252, Section 4.8. Default to 1.5. This value can be overridden.
 
#define COAP_ACK_MAX_TIMEOUT_MS   (unsigned long)(COAP_ACK_MIN_TIMEOUT_MS * COAP_ACK_RANDOM_FACTOR)
 The precomputed maximum ACK timeout derived from the minimum timeout and the random factor.
 
#define COAP_MAX_RETRANSMIT   4U
 The maximum number of retransmission attempts for confirmable messages. Default to 4 as per RFC 7252, Section 4.8. This value can be overridden.
 
#define COAP_CONFIRMABLE_MESSAGE_QUEUE_SIZE   2U
 The maximum number of confirmable messages that are stored for retransmission.
 

Typedefs

typedef void(* Coap::Callback) (Message &message, IPAddress ip, uint16_t port)
 Callback function type for handling incoming messages.
 

Enumerations

enum class  Coap::MessageType : uint8_t { Coap::CON = 0 , Coap::NON = 1 , Coap::ACK = 2 , Coap::RST = 3 }
 The CoAP message type. More...
 
enum class  Coap::MessageCode : uint8_t {
  Coap::EMPTY = COAP_CODE_ENCODE(0, 0) , Coap::GET = COAP_CODE_ENCODE(0, 1) , Coap::POST = COAP_CODE_ENCODE(0, 2) , Coap::PUT = COAP_CODE_ENCODE(0, 3) ,
  Coap::DELETE = COAP_CODE_ENCODE(0, 4) , Coap::CREATED = COAP_CODE_ENCODE(2, 1) , Coap::DELETED = COAP_CODE_ENCODE(2, 2) , Coap::VALID = COAP_CODE_ENCODE(2, 3) ,
  Coap::CHANGED = COAP_CODE_ENCODE(2, 4) , Coap::CONTENT = COAP_CODE_ENCODE(2, 5) , Coap::BAD_REQUEST = COAP_CODE_ENCODE(4, 0) , Coap::UNAUTHORIZED = COAP_CODE_ENCODE(4, 1) ,
  Coap::BAD_OPTION = COAP_CODE_ENCODE(4, 2) , Coap::FORBIDDEN = COAP_CODE_ENCODE(4, 3) , Coap::NOT_FOUND = COAP_CODE_ENCODE(4, 4) , Coap::METHOD_NOT_ALLOWED = COAP_CODE_ENCODE(4, 5) ,
  Coap::NOT_ACCEPTABLE = COAP_CODE_ENCODE(4, 6) , Coap::PRECONDITION_FAILED = COAP_CODE_ENCODE(4, 12) , Coap::REQUEST_ENTITY_TOO_LARGE = COAP_CODE_ENCODE(4, 13) , Coap::UNSUPPORTED_CONTENT_FORMAT = COAP_CODE_ENCODE(4, 15) ,
  Coap::INTERNAL_SERVER_ERROR = COAP_CODE_ENCODE(5, 0) , Coap::NOT_IMPLEMENTED = COAP_CODE_ENCODE(5, 1) , Coap::BAD_GATEWAY = COAP_CODE_ENCODE(5, 2) , Coap::SERVICE_UNAVAILABLE = COAP_CODE_ENCODE(5, 3) ,
  Coap::GATEWAY_TIMEOUT = COAP_CODE_ENCODE(5, 4) , Coap::PROXYING_NOT_SUPPORTED = COAP_CODE_ENCODE(5, 5)
}
 The CoAP code. More...
 
enum class  Coap::OptionNumber : uint16_t {
  Coap::IF_MATCH = 1 , Coap::URI_HOST = 3 , Coap::E_TAG = 4 , Coap::IF_NONE_MATCH = 5 ,
  Coap::OBSERVE = 6 , Coap::URI_PORT = 7 , Coap::LOCATION_PATH = 8 , Coap::URI_PATH = 11 ,
  Coap::CONTENT_FORMAT = 12 , Coap::MAX_AGE = 14 , Coap::URI_QUERY = 15 , Coap::ACCEPT = 17 ,
  Coap::LOCATION_QUERY = 20 , Coap::PROXY_URI = 35 , Coap::PROXY_SCHEME = 39 , Coap::SIZE1 = 60
}
 
enum class  Coap::ContentFormat : uint16_t {
  Coap::TEXT_PLAIN = 0 , Coap::APPLICATION_LINK_FORMAT = 40 , Coap::APPLICATION_XML = 41 , Coap::APPLICATION_OCTET_STREAM = 42 ,
  Coap::APPLICATION_EXI = 47 , Coap::APPLICATION_JSON = 50 , Coap::APPLICATION_CBOR = 60
}
 The CoAP content format. More...
 
enum class  Coap::ObserveValue : uint8_t { Coap::REGISTER = 0 , Coap::DEREGISTER = 1 }
 Represents possible Observe option values. More...
 
enum class  Coap::ErrorCode : int8_t {
  Coap::OK = 0 , Coap::NOT_FOUND = -1 , Coap::MESSAGE_TOO_LARGE = -2 , Coap::MALFORMED_MESSAGE = -3 ,
  Coap::INVALID_ARGUMENT = -4 , Coap::NOT_SUPPORTED = -5 , Coap::NETWORK = -6 , Coap::UNEXPECTED = -99
}
 Error codes used in the library. More...
 

Functions

constexpr uint8_t COAP_CODE_ENCODE (uint8_t class_, uint8_t detail)
 Helper to encode class and detail into a 8-bit response code as defined in RFC 7252.
 

Variables

constexpr uint8_t COAP_VERSION = 0x01
 The CoAP version.
 
constexpr uint8_t COAP_HEADER_SIZE = 4
 The size of the CoAP header in bytes.
 
constexpr uint8_t COAP_PAYLOAD_MARKER = 0xFF
 The payload marker byte.
 
constexpr uint16_t COAP_DEFAULT_PORT = 5683
 The default CoAP port number.
 
constexpr uint8_t COAP_MAX_TOKEN_LENGTH = 8
 The maximum length of a CoAP token.