QCoapMessage#

The QCoapMessage class holds information about a CoAP message that can be a request or a reply. More

Inheritance diagram of PySide6.QtCoap.QCoapMessage

Inherited by: QCoapRequest

Synopsis#

Functions#

Detailed Description#

It holds information such as the message type, message id, token and other ancillary data.

class PySide6.QtCoap.QCoapMessage#

PySide6.QtCoap.QCoapMessage(other)

Parameters

otherPySide6.QtCoap.QCoapMessage

Constructs a new QCoapMessage .

Constructs a shallow copy of other.

PySide6.QtCoap.QCoapMessage.Type#

Indicates the type of the message.

Constant

Description

QCoapMessage.Type.Confirmable

A Confirmable message. The destination endpoint needs to acknowledge the message.

QCoapMessage.Type.NonConfirmable

A Non-Confirmable message. The destination endpoint does not need to acknowledge the message.

QCoapMessage.Type.Acknowledgment

An Acknowledgment message. A message sent or received in reply to a Confirmable message.

QCoapMessage.Type.Reset

A Reset message. This message type is used in case of errors or to stop the ongoing transmission. (For example, it is used to cancel an observation).

PySide6.QtCoap.QCoapMessage.addOption(name[, value=QByteArray()])#
Parameters

This is an overloaded function.

Adds the CoAP option with the given name and value.

PySide6.QtCoap.QCoapMessage.addOption(option)
Parameters

optionPySide6.QtCoap.QCoapOption

Adds the given CoAP option.

PySide6.QtCoap.QCoapMessage.clearOptions()#

Removes all options.

PySide6.QtCoap.QCoapMessage.hasOption(name)#
Parameters

nameOptionName

Return type

bool

Returns true if the message contains at last one option with name.

PySide6.QtCoap.QCoapMessage.messageId()#
Return type

quint16

Returns the message id.

See also

setMessageId()

PySide6.QtCoap.QCoapMessage.option(name)#
Parameters

nameOptionName

Return type

PySide6.QtCoap.QCoapOption

Finds and returns the first option with the given name. If there is no such option, returns an invalid QCoapOption with an empty value.

PySide6.QtCoap.QCoapMessage.optionAt(index)#
Parameters

index – int

Return type

PySide6.QtCoap.QCoapOption

Returns the option at index position.

PySide6.QtCoap.QCoapMessage.optionCount()#
Return type

int

Returns the number of options.

PySide6.QtCoap.QCoapMessage.options()#
Return type

Returns the list of options.

See also

setOptions()

PySide6.QtCoap.QCoapMessage.options(name)
Parameters

nameOptionName

Return type

Finds and returns the list of options with the given name.

PySide6.QtCoap.QCoapMessage.payload()#
Return type

PySide6.QtCore.QByteArray

Returns the payload.

See also

setPayload()

PySide6.QtCoap.QCoapMessage.removeOption(name)#
Parameters

nameOptionName

Removes all options with the given name. The CoAP protocol allows for the same option to repeat.

PySide6.QtCoap.QCoapMessage.removeOption(option)
Parameters

optionPySide6.QtCoap.QCoapOption

Removes the given option.

PySide6.QtCoap.QCoapMessage.setMessageId(arg__1)#
Parameters

arg__1quint16

Sets the message ID to id.

See also

messageId()

PySide6.QtCoap.QCoapMessage.setOptions(options)#
Parameters

options

Sets the message options to options.

See also

options()

PySide6.QtCoap.QCoapMessage.setPayload(payload)#
Parameters

payloadPySide6.QtCore.QByteArray

Sets the message payload to payload. The payload can be represented in one of the content formats defined in CoAP Content-Formats Registry .

Note

CoAP supports common content formats such as XML, JSON, and so on, but these are text based and consequently heavy both in payload and in processing. One of the recommended content formats to use with CoAP is CBOR, which is designed to be used in such contexts.

See also

payload() QCborStreamWriter QCborStreamReader

PySide6.QtCoap.QCoapMessage.setToken(token)#
Parameters

tokenPySide6.QtCore.QByteArray

Sets the message token to token.

See also

token()

PySide6.QtCoap.QCoapMessage.setType(type)#
Parameters

typeType

Sets the message type to type.

See also

type()

PySide6.QtCoap.QCoapMessage.setVersion(version)#
Parameters

versionquint8

Sets the CoAP version to version.

See also

version()

PySide6.QtCoap.QCoapMessage.swap(other)#
Parameters

otherPySide6.QtCoap.QCoapMessage

Swaps this message with other. This operation is very fast and never fails.

PySide6.QtCoap.QCoapMessage.token()#
Return type

PySide6.QtCore.QByteArray

Returns the message token.

See also

setToken()

PySide6.QtCoap.QCoapMessage.tokenLength()#
Return type

quint8

Returns the token length.

PySide6.QtCoap.QCoapMessage.type()#
Return type

Type

Returns the message type.

See also

setType()

PySide6.QtCoap.QCoapMessage.version()#
Return type

quint8

Returns the CoAP version.

See also

setVersion()