coapthon package¶
Subpackages¶
Submodules¶
coapthon.defines module¶
- coapthon.defines.BLOCKWISE_SIZE = 1024¶
MongoDB parameters
- class coapthon.defines.CodeItem¶
Bases: tuple
CodeItem(number, name)
- name¶
Alias for field number 1
- number¶
Alias for field number 0
- class coapthon.defines.Codes[source]¶
Bases: object
CoAP codes. Every code is represented as (NUMBER, NAME)
- coapthon.defines.MONGO_CONFIG_FILE = '/usr/local/etc/mongod.conf'¶
Message Format
- class coapthon.defines.OptionItem¶
Bases: tuple
OptionItem(number, name, value_type, repeatable, default)
- default¶
Alias for field number 4
- name¶
Alias for field number 1
- number¶
Alias for field number 0
- repeatable¶
Alias for field number 3
- value_type¶
Alias for field number 2
coapthon.serializer module¶
- class coapthon.serializer.Serializer[source]¶
Bases: object
Serializer class to serialize and deserialize CoAP message to/from udp streams.
- static as_sorted_list(options)[source]¶
Returns all options in a list sorted according to their option numbers.
Returns: the sorted list
- static convert_to_raw(number, value, length)[source]¶
Get the value of an option as a ByteArray.
Parameters: - number – the option number
- value – the option value
- length – the option length
Returns: the value of an option as a BitArray
- static deserialize(datagram, source)[source]¶
De-serialize a stream of byte to a message.
Parameters: - datagram – the incoming udp message
- source – the source address and port (ip, port)
Returns: the message
Return type: Message
- static get_option_nibble(optionvalue)[source]¶
Returns the 4-bit option header value.
Parameters: optionvalue – the option value (delta or length) to be encoded. Returns: the 4-bit option header value.
- static int_to_words(int_val, num_words=4, word_size=32)[source]¶
Convert a int value to bytes.
Parameters: - int_val – an arbitrary length Python integer to be split up. Network byte order is assumed. Raises an IndexError if width of integer (in bits) exceeds word_size * num_words.
- num_words – number of words expected in return value tuple.
- word_size – size/width of individual words (in bits).
Returns: a list of fixed width words based on provided parameters.
- static read_option_value_from_nibble(nibble, pos, values)[source]¶
Calculates the value used in the extended option fields.
Parameters: nibble – the 4-bit option header value. Returns: the value calculated from the nibble and the extended option value.
coapthon.transaction module¶
coapthon.utils module¶
- coapthon.utils.byte_len(int_type)[source]¶
Get the number of byte needed to encode the int passed.
Parameters: int_type – the int to be converted Returns: the number of bits needed to encode the int passed.
- coapthon.utils.check_code(code)[source]¶
checks if the response code is one of the valid ones defined in the rfc
Parameters: code – Returns:
- coapthon.utils.check_nocachekey(option)[source]¶
checks if an option is a NoCacheKey option or Etag
Parameters: option – Returns: