aiocoap.numbers.optionnumbers module

Known values for CoAP option numbers

The values defined in OptionNumber correspond to the IANA registry “CoRE Parameters”, subregistries “CoAP Method Codes” and “CoAP Response Codes”.

The option numbers come with methods that can be used to evaluate their properties, see the OptionNumber class for details.

class aiocoap.numbers.optionnumbers.OptionNumber(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: ExtensibleIntEnum

A CoAP option number.

As the option number contains information on whether the option is critical, and whether it is safe-to-forward, those properties can be queried using the is_* group of methods.

Note that whether an option may be repeated or not does not only depend on the option, but also on the context, and is thus handled in the Options object instead.

IF_MATCH = 1
URI_HOST = 3
ETAG = 4
IF_NONE_MATCH = 5
OBSERVE = 6
URI_PORT = 7
LOCATION_PATH = 8
OSCORE = 9
URI_PATH = 11
CONTENT_FORMAT = 12
MAX_AGE = 14
URI_QUERY = 15
HOP_LIMIT = 16
ACCEPT = 17
Q_BLOCK1 = 19
LOCATION_QUERY = 20
EDHOC = 21
BLOCK2 = 23
BLOCK1 = 27
SIZE2 = 28
Q_BLOCK2 = 31
PROXY_URI = 35
PROXY_SCHEME = 39
SIZE1 = 60
ECHO = 252
NO_RESPONSE = 258
REQUEST_TAG = 292
REQUEST_HASH = 548
property OBJECT_SECURITY
is_critical()
is_elective()
is_unsafe()
is_safetoforward()
is_nocachekey()
is_cachekey()
set_format(value)

Set the serialization format.

This affects any use of the option throughout the program; existing options should not be altered incompatibly. Use this on custom or experimental options.

This is available as a setter function in addition to write access through the format property to satisfy requirements imposed by mypy’s special handling of enums.

property format

Serialization format; see set_format()

create_option(decode=None, value=None)

Return an Option element of the appropriate class from this option number.

An initial value may be set using the decode or value options, and will be fed to the resulting object’s decode method or value property, respectively.