Name | Default |
---|---|
Content-type | text/plain |
Max-age | 60 seconds |
Uri-Scheme | coap |
Etag | |
Uri-Authority | |
Location | |
Uri-Path | |
Block EXPERIMENTAL |
Classes and functions related to CoAP header options.
Bases: coapy.options._Base
Support block-wise transfers of large resources.
Warning: | This is an experimental option. See draft-bormann-core-misc |
---|---|
Parameters: |
|
The base-2 exponent defining the size of each (non-final) block.
See MIN_SIZE_EXPONENT and MAX_SIZE_EXPONENT.
Bases: coapy.options._Base
The Internet media type describing the message body.
Access the value using its IANA-assigned media type encoding scheme, e.g. application/xml.
Note: | Only media types that have been assigned CoAP integral values are allowed. |
---|
Bases: coapy.options._StringValue_mixin, coapy.options._Base
An opaque sequence of bytes specifying the version of resource representation.
Bases: coapy.options._UriPath_mixin, coapy.options._Base
The location of a resource.
Normally used in in a response to indicate the location of a newly created resource.
Bases: coapy.options._IntegerValue_mixin, coapy.options._Base
The maximum age of a resource for use in cache control, in seconds.
Bases: coapy.options._StringValue_mixin, coapy.options._Base
The authority (host+port) part of the URI.
Bases: coapy.options._UriPath_mixin, coapy.options._Base
The absolute path part of the URI.
Since all CoAP URI paths are absolute, the leading slash is elided from the option value.
Bases: coapy.options._StringValue_mixin, coapy.options._Base
The schema part of the URI.
Decode a set of CoAP options and extract a message body.
The specified number of options are pulled from the initial octets of the payload, and converted into instances of the corresponding option class. The return value is a pair (options, body) where options is a list of all recognized options in their order of appearance and body is the remainder of the payload after options have been stripped.
Parameters: |
|
---|---|
Returns: | (options, body) |
Return type: | |
Raises: | Exception if an unrecognized critical option is encountered |
Encode a set of CoAP options for transmission.
The options are sorted as required by CoAP. The return value is a pair (num_options, packed) where num_options is the number of options that were encoded, and packed is the octet sequence encoding those options.
Parameters: |
|
---|---|
Returns: | (num_options, packed_options) |
Return type: | |
Raises: | Exception if a packed option exceeds the representable option length |
Parameter: | value – Any non-negative integral value |
---|---|
Returns: | Determine the number of octets required to express value as by pack_vlint(). |
Return type: | int |
Parameter: | type_val – the integral type value for an option |
---|---|
Returns: | True iff an option of Type type_val is elective (can be skipped if unrecognized). |
Pack an integer into a string.
CoAP variable-length integers are packed into a sequence of octets in network byte order. Leading octets that would have a zero value are elided.
Parameter: | value – Any non-negative integral value |
---|---|
Return type: | str |
Extract an integer from a string as created by pack_vlint().
Parameter: | packed – A string of octets containing a packed integer. |
---|---|
Return type: | int |
Base class for all CoAPy option classes.
The default value of the option. None if the option has no default.
Note: | This value is overridden in each class that implements a CoAP option with a default value. |
---|
The standardized name of the option.
Note: | This value is overridden in each class that implements a CoAP option. |
---|
The type code for the option.
Options with an even type code are elective, while those with an odd type code are critical.
Note: | This value is overridden in each class that implements a CoAP option. |
---|
Return True iff the current value of the option is equal to the default value of the option.
This is used by encode to avoid unnececessarily packing options.
The length, in octets, of the packed option.
Note: | This is a read-only property. |
---|
The sequence of octets representing the option value in packed form (i.e., as it appears within an option header).
The sequence does not include the option delta or length, only the value.
Note: | This is a read-only property. |
---|---|
See: | unpack |
Create an instance of this option from a packed representation.
Parameter: | packed – A sequence of octets representing the option value, exclusive of the option type and length. |
---|---|
Return type: | An instance of the leaf class. |
See: | packed |
The option value.
Python objects and type instances assigned as option values are validated within the limitations of the CoAP option’s packed representation. For example, assigning to an instance of UriPath a value that exceeds the length limitation of 270 will result in a ValueError.
In cases where the option value is expected to have an IANA-assigned significance but the specific assigned value is unrecognized, the value assignment is permitted if doing so does not violate the requirements of the packed option representation. For example, assigning a value of 15 to an instance of ContentType would be allowed, though the value 15 is not (currently) associated with a specific media type.
The following classes are mixed-in to CoAP option classes to provide common support for representing and validating the option values.
Mix-in to support options with octet-sequence values.
Mix-in to support options with string values that represent URIs.