PySide6.QtCoap.QCoapMessage¶
- class QCoapMessage¶
The
QCoapMessage
class holds information about a CoAP message that can be a request or a reply. More…Inherited by:
QCoapRequest
Synopsis¶
Methods¶
def
__init__()
def
addOption()
def
clearOptions()
def
hasOption()
def
messageId()
def
option()
def
optionAt()
def
optionCount()
def
options()
def
payload()
def
removeOption()
def
setMessageId()
def
setOptions()
def
setPayload()
def
setToken()
def
setType()
def
setVersion()
def
swap()
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 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).
- __init__()¶
Constructs a new
QCoapMessage
.- __init__(other)
- Parameters:
other –
QCoapMessage
Constructs a shallow copy of
other
.- addOption(option)¶
- Parameters:
option –
QCoapOption
Adds the given CoAP
option
.- addOption(name[, value=QByteArray()])
- Parameters:
name –
OptionName
value –
QByteArray
This is an overloaded function.
Adds the CoAP option with the given
name
andvalue
.- clearOptions()¶
Removes all options.
- hasOption(name)¶
- Parameters:
name –
OptionName
- Return type:
bool
Returns
true
if the message contains at last one option withname
.- messageId()¶
- Return type:
int
Returns the message id.
See also
- 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 invalidQCoapOption
with an empty value.- optionAt(index)¶
- Parameters:
index – int
- Return type:
Returns the option at
index
position.- optionCount()¶
- Return type:
int
Returns the number of options.
- options()¶
- Return type:
.list of QCoapOption
Returns the list of options.
See also
- options(name)
- Parameters:
name –
OptionName
- Return type:
.list of QCoapOption
Finds and returns the list of options with the given
name
.- payload()¶
- Return type:
Returns the payload.
See also
- removeOption(name)¶
- Parameters:
name –
OptionName
Removes all options with the given
name
. The CoAP protocol allows for the same option to repeat.- removeOption(option)
- Parameters:
option –
QCoapOption
Removes the given
option
.- setMessageId(id)¶
- Parameters:
id – int
Sets the message ID to
id
.See also
- setOptions(options)¶
- Parameters:
options – .list of QCoapOption
Sets the message options to
options
.See also
- setPayload(payload)¶
- Parameters:
payload –
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()
QCborStreamWriterQCborStreamReader
- setToken(token)¶
- Parameters:
token –
QByteArray
Sets the message token to
token
.See also
Sets the message type to
type
.See also
- setVersion(version)¶
- Parameters:
version – int
Sets the CoAP version to
version
.See also
- swap(other)¶
- Parameters:
other –
QCoapMessage
Swaps this message with
other
. This operation is very fast and never fails.- token()¶
- Return type:
Returns the message token.
See also
- tokenLength()¶
- Return type:
int
Returns the token length.
Returns the message type.
See also
- version()¶
- Return type:
int
Returns the CoAP version.
See also