Package-level declarations

Types

Link copied to clipboard

A CoAP endpoint: the messaging layers and the exchange layer that matches responses to requests by peer and token. dev.kcoap.coap.client.CoapClient and dev.kcoap.coap.server.CoapServer are built on it and can share one endpoint, so a device can be client and server on the same port.

Link copied to clipboard

How a CoapEndpoint runs its messaging layers.

Link copied to clipboard
class CoapException(message: String, val reason: CoapException.Reason, cause: Throwable? = null, val response: CoapResponse? = null) : KcoapException

A CoAP exchange that could not complete because of the peer, the network, message security or the endpoint itself: no acknowledgement or a Reset over datagrams, a secure session or connection that ended, a response that violates the protocol or could not be verified, a request that message security could not protect, a host that could not be resolved, or an endpoint that is closed, has no transport for the peer, or whose transport failed. reason says which; the reasons of one transport shape say so. This is the one exception type that CoapClient, CoapEndpoint and CoapServer calls fail with at runtime, a KcoapException like the exceptions of kcoap's other protocols; IllegalArgumentException and IllegalStateException are kept for mistakes of the caller, such as a malformed URI string.

Link copied to clipboard
sealed interface EndpointEvent

Something that happened on a CoapEndpoint, for metrics and diagnostics. Messages themselves are seen through a MessageInterceptor; events cover what has no message of its own.

Link copied to clipboard
fun interface EndpointEventListener

Receives EndpointEvents. Called synchronously on the endpoint's coroutines, outside its locks, so it must be quick and must not throw; exceptions are caught and logged. Hand the work to a queue or count with atomics; for several listeners, combine them with plus.

Link copied to clipboard

How much a CoapEndpoint holds at the moment CoapEndpoint.stats was called, for gauges in metrics and for diagnostics; set each against the bound of CoapEndpointConfig it names. Every value is a count of what is held now, not of what happened: count what happened from EndpointEvents, such as EndpointEvent.RequestCompleted and EndpointEvent.LimitReached.

Link copied to clipboard

Sees, and may change or drop, every message at the wire: after OSCORE protection on the way out, before deduplication and OSCORE verification on the way in. Use it for tracing, metrics or fault injection.

Link copied to clipboard
class ReliableTransportConfig(val maxMessageSize: Long = DEFAULT_MAX_MESSAGE_SIZE, val blockWiseTransfer: Boolean = true, val csmTimeout: Duration = 10.seconds, val connectTimeout: Duration = 30.seconds, val idleTimeout: Duration? = 30.seconds, val releaseTimeout: Duration = 5.seconds, val pingTimeout: Duration = 30.seconds, val keepAliveInterval: Duration? = null, val maxPendingConnections: Int = DEFAULT_MAX_PENDING_CONNECTIONS, val maxConnections: Int = DEFAULT_MAX_CONNECTIONS)

How a CoapEndpoint runs CoAP over reliable transports (RFC 8323): what its Capabilities and Settings Message announces, and how it manages connections, which RFC 8323 §3 leaves to the implementation.

Link copied to clipboard
fun interface TokenGenerator

Chooses tokens for new requests (RFC 7252 §5.3.1). The endpoint asks again when a token is already in use towards the same peer, so a generator only needs to make collisions unlikely.

Link copied to clipboard
class TransmissionParameters(val ackTimeout: Duration = 2.seconds, val ackRandomFactor: Double = 1.5, val maxRetransmit: Int = 4, val nstart: Int = 1, val defaultLeisure: Duration = 5.seconds, val probingRate: Int = 1, val maxLatency: Duration = 100.seconds, val maxPayloads: Int = 10, val nonTimeout: Duration = ackTimeout, val nonReceiveTimeout: Duration = maxOf(nonTimeout * 2, nonTimeout * ackRandomFactor + 1.seconds), val nonMaxRetransmit: Int = maxRetransmit)

The CoAP transmission parameters of RFC 7252 §4.8 and the time values derived from them (§4.8.2).

Functions

Link copied to clipboard

The CoapEndpointConfig that block sets up on a CoapEndpointConfig.Builder; what is not set keeps its default:

Link copied to clipboard

Sends each event to this listener and then to other, as LogSink.plus does for log records. A listener that throws does not keep the event from the others: each is called, and the first exception is thrown afterwards, for the endpoint to log. EndpointEventListener.None adds nothing.