coapthon.messages package

Submodules

coapthon.messages.message module

class coapthon.messages.message.Message[source]

Bases: object

Class to handle the Messages.

acknowledged[source]

Checks if is this message has been acknowledged.

Returns:True, if is acknowledged
add_option(option)[source]

Add an option to the message.

Parameters:option (Option) – the option
Raises TypeError:
 if the option is not repeatable and such option is already present in the message
block1[source]

Get the Block1 option.

Returns:the Block1 value
block2[source]

Get the Block2 option.

Returns:the Block2 value
code[source]

Return the code of the message.

Return type:Codes
Returns:the code
content_type[source]

Get the Content-Type option of a response.

Returns:the Content-Type value or 0 if not specified by the response
del_option(option)[source]

Delete an option from the message

Parameters:option (Option) – the option
del_option_by_name(name)[source]

Delete an option from the message by name

Parameters:name (String) – option name
del_option_by_number(number)[source]

Delete an option from the message by number

Parameters:number (Integer) – option naumber
destination[source]

Return the destination of the message.

Return type:tuple
Returns:(ip, port)
duplicated[source]

Checks if this message is a duplicate.

Returns:True, if is a duplicate
etag[source]

Get the ETag option of the message.

Return type:list
Returns:the ETag values or [] if not specified by the request
line_print[source]

Return the message as a one-line string.

Returns:the string representing the message
mid[source]

Return the mid of the message.

Returns:the MID
observe[source]

Check if the request is an observing request.

Returns:0, if the request is an observing request
options[source]

Return the options of the CoAP message.

Return type:list
Returns:the options
payload[source]

Return the payload.

Returns:the payload
pretty_print()[source]

Return the message as a formatted string.

Returns:the string representing the message
rejected[source]

Checks if this message has been rejected.

Returns:True, if is rejected
source[source]

Return the source of the message.

Return type:tuple
Returns:(ip, port)
timeouted[source]

Checks if this message has timeouted. Confirmable messages in particular might timeout.

Returns:True, if has timeouted
timestamp[source]

Return the timestamp of the message.

token[source]

Get the Token of the message.

Returns:the Token
type[source]

Return the type of the message.

Returns:the type
version[source]

Return the CoAP version

Returns:the version

coapthon.messages.option module

class coapthon.messages.option.Option[source]

Bases: object

Class to handle the CoAP Options.

is_safe()[source]

Check if the option is safe.

:rtype : bool :return: True, if option is safe

length[source]

Return the value length

:rtype : int

name[source]

Return option name.

:rtype : String :return: the option name

number[source]

Return the number of the option.

Returns:the option number
value[source]

Return the option value.

Returns:the option value in the correct format depending on the option

coapthon.messages.request module

class coapthon.messages.request.Request[source]

Bases: coapthon.messages.message.Message

Class to handle the Requests.

accept[source]

Get the Accept option of a request.

Returns:the Accept value or None if not specified by the request

:rtype : String

add_if_none_match()[source]

Add the if-none-match option to the request.

if_match[source]

Get the If-Match option of a request.

Returns:the If-Match values or [] if not specified by the request

:rtype : list

if_none_match[source]

Get the if-none-match option of a request.

Returns:True, if if-none-match is present

:rtype : bool

proxy_schema[source]

Get the Proxy-Schema option of a request.

Returns:the Proxy-Schema values or None if not specified by the request

:rtype : String

proxy_uri[source]

Get the Proxy-Uri option of a request.

Returns:the Proxy-Uri values or None if not specified by the request

:rtype : String

uri_path[source]

Return the Uri-Path of a request

:rtype : String :return: the Uri-Path

uri_query[source]

Get the Uri-Query of a request.

Returns:the Uri-Query

:rtype : String :return: the Uri-Query string

coapthon.messages.response module

class coapthon.messages.response.Response[source]

Bases: coapthon.messages.message.Message

Class to handle the Responses.

location_path[source]

Return the Location-Path of the response.

:rtype : String :return: the Location-Path option

location_query[source]

Return the Location-Query of the response.

:rtype : String :return: the Location-Query option

max_age[source]

Return the MaxAge of the response.

:rtype : int :return: the MaxAge option

Module contents