Package-level declarations

Types

Link copied to clipboard
class BlockOption(val number: Long, val more: Boolean, val sizeExponent: Int)

The value of a Block1 or Block2 option (RFC 7959 §2.2): block number, more flag and size exponent. Size exponent 7 is BERT, defined only for reliable transports (RFC 8323 §6).

Link copied to clipboard
value class CoapCode(val value: Int)

A CoAP code: a 3-bit class and a 5-bit detail, written c.dd (RFC 7252 §3, §12.1).

Link copied to clipboard
class CoapMessage(val type: CoapMessageType, val code: CoapCode, val messageId: Int, token: ByteArray, val options: OptionSet, payload: ByteArray)

A CoAP message (RFC 7252 §3): header fields, token, options and payload. Immutable; derive changed copies with toBuilder.

Link copied to clipboard

Message types of CoAP over UDP (RFC 7252 §3). Reliable transports have no type (RFC 8323 §3.2).

Link copied to clipboard
class CoapOption(val number: Int, value: ByteArray)

One option in a message: a number and its raw value (RFC 7252 §5.4). The meaning of the number, if registered, is in definition.

Link copied to clipboard

Options from RFC 7252 and the extensions this library targets.

Link copied to clipboard
class CoapRequest(val method: CoapCode, val uri: CoapUri, val options: OptionSet = OptionSet.EMPTY, payload: ByteArray = ByteArray(0), val isConfirmable: Boolean = true)

A request as the client application states it: method, target URI, further options and the whole body. The client turns the URI into Uri-* options (RFC 7252 §6.4), splits a large body into Block1 transfers and assigns token and Message ID. Immutable; build one with Builder or the client's method shortcuts. Two requests are equal when method, URI, options, body (by content) and isConfirmable are, as two CoapResponses are by their parts.

Link copied to clipboard
class CoapResponse(val code: CoapCode, val options: OptionSet = OptionSet.EMPTY, payload: ByteArray = ByteArray(0))

A response as the application sees it: code, options and the whole body. Block-wise transfers are already reassembled, and the messaging-layer fields (type, Message ID, token) are not part of it.

Link copied to clipboard
class CoapUri(val scheme: CoapScheme, val host: String, val port: Int = scheme.defaultPort, pathSegments: List<String> = emptyList(), querySegments: List<String> = emptyList())

A CoAP URI (RFC 7252 §6, RFC 8323 §8) and its mapping to request options.

Link copied to clipboard

Content-Format identifiers (IANA "CoAP Content-Formats", RFC 7252 §12.3) used across kcoap.

Link copied to clipboard
object LinkFormat

The CoRE Link Format of RFC 6690, application/link-format (ContentFormat.LINK_FORMAT), as served by /.well-known/core.

Link copied to clipboard
class OptionDefinition(val number: Int, val name: String, val format: OptionFormat, val minLength: Int, val maxLength: Int, val repeatable: Boolean, val oscoreClasses: Set<OscoreClass>, val reference: String)

A registered CoAP option. Critical / Unsafe / NoCacheKey are derived from the option number (RFC 7252 §5.4.6), so they cannot drift from the registry.

Link copied to clipboard

Option value formats, RFC 7252 §3.2.

Link copied to clipboard

The options of a message, kept in ascending number order as they are encoded. Repeated options keep their relative order, which matters for Uri-Path and the like (RFC 7252 §5.4.5).

Link copied to clipboard

How OSCORE protects an option, RFC 8613 §4.1. Some options may appear both as Inner and Outer.

Link copied to clipboard
class SignalingOptionDefinition(val codes: Set<CoapCode>, val number: Int, val name: String, val format: OptionFormat, val minLength: Int, val maxLength: Int, val repeatable: Boolean, val reference: String = "RFC 8323")

A Signaling Option (RFC 8323 §5.2, §11.2). Signaling option numbers are scoped to their signaling code: 2 is Max-Message-Size in a CSM, Custody in a Ping or Pong, Alternative-Address in a Release and Bad-CSM-Option in an Abort. They share no number space with the request and response options of CoapOptions. Critical or elective follows from the number as in RFC 7252 §5.4.6.

Link copied to clipboard

The CoAP Signaling Option Numbers registry of RFC 8323 §11.2.

Link copied to clipboard
class WebLink(val target: String, attributes: List<Pair<String, String?>> = emptyList())

One link of the CoRE Link Format (RFC 6690 §2): a target URI-reference and its attributes in order. An attribute without a value, such as obs (RFC 7641 §6), has a null value. Values are unquoted.