QCoapMessage#
The QCoapMessage
class holds information about a CoAP message that can be a request or a reply. More…
Inherited by: QCoapRequest
Synopsis#
Functions#
def
addOption
(option)def
addOption
(name[, value=QByteArray()])def
clearOptions
()def
hasOption
(name)def
messageId
()def
option
(name)def
optionAt
(index)def
optionCount
()def
options
()def
options
(name)def
payload
()def
removeOption
(option)def
removeOption
(name)def
setMessageId
(arg__1)def
setOptions
(options)def
setPayload
(payload)def
setToken
(token)def
setType
(type)def
setVersion
(version)def
swap
(other)def
token
()def
tokenLength
()def
type
()def
version
()
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Detailed Description#
It holds information such as the message type, message id, token and other ancillary data.
See also
- class PySide6.QtCoap.QCoapMessage#
PySide6.QtCoap.QCoapMessage(other)
- Parameters:
other –
PySide6.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(option)#
- Parameters:
option –
PySide6.QtCoap.QCoapOption
Adds the given CoAP option
.
- PySide6.QtCoap.QCoapMessage.addOption(name[, value=QByteArray()])
- Parameters:
name –
OptionName
value –
PySide6.QtCore.QByteArray
This is an overloaded function.
Adds the CoAP option with the given name
and value
.
- PySide6.QtCoap.QCoapMessage.clearOptions()#
Removes all options.
- PySide6.QtCoap.QCoapMessage.hasOption(name)#
- Parameters:
name –
OptionName
- 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
- PySide6.QtCoap.QCoapMessage.option(name)#
- Parameters:
name –
OptionName
- Return type:
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:
Returns the option at index
position.
- PySide6.QtCoap.QCoapMessage.optionCount()#
- Return type:
int
Returns the number of options.
- PySide6.QtCoap.QCoapMessage.options()#
Returns the list of options.
See also
- PySide6.QtCoap.QCoapMessage.options(name)
- Parameters:
name –
OptionName
Finds and returns the list of options with the given name
.
- PySide6.QtCoap.QCoapMessage.payload()#
- Return type:
Returns the payload.
See also
- PySide6.QtCoap.QCoapMessage.removeOption(option)#
- Parameters:
option –
PySide6.QtCoap.QCoapOption
Removes the given option
.
- PySide6.QtCoap.QCoapMessage.removeOption(name)
- Parameters:
name –
OptionName
Removes all options with the given name
. The CoAP protocol allows for the same option to repeat.
- PySide6.QtCoap.QCoapMessage.setMessageId(arg__1)#
- Parameters:
arg__1 –
quint16
Sets the message ID to id
.
See also
- PySide6.QtCoap.QCoapMessage.setOptions(options)#
- Parameters:
options –
Sets the message options to options
.
See also
- PySide6.QtCoap.QCoapMessage.setPayload(payload)#
- Parameters:
payload –
PySide6.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:
token –
PySide6.QtCore.QByteArray
Sets the message token to token
.
See also
Sets the message type to type
.
See also
- PySide6.QtCoap.QCoapMessage.setVersion(version)#
- Parameters:
version –
quint8
Sets the CoAP version to version
.
See also
- PySide6.QtCoap.QCoapMessage.swap(other)#
- Parameters:
other –
PySide6.QtCoap.QCoapMessage
Swaps this message with other
. This operation is very fast and never fails.
- PySide6.QtCoap.QCoapMessage.token()#
- Return type:
Returns the message token.
See also
- PySide6.QtCoap.QCoapMessage.tokenLength()#
- Return type:
quint8
Returns the token length.
Returns the message type.
See also
- PySide6.QtCoap.QCoapMessage.version()#
- Return type:
quint8
Returns the CoAP version.
See also