IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

QCoapMessage Class

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

All functions in this class are reentrant.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

QCoapMessage Class

  • Header: QCoapMessage

  • qmake: QT += coap

Detailed Description

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

See Also

Member Type Documentation

 

enum QCoapMessage::Type

Indicates the type of the message.

Constant

Value

Description

QCoapMessage::Type::Confirmable

0

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

QCoapMessage::Type::NonConfirmable

1

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

QCoapMessage::Type::Acknowledgment

2

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

QCoapMessage::Type::Reset

3

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).

Member Function Documentation

 

QCoapMessage::QCoapMessage()

Constructs a new QCoapMessage.

QCoapMessage::QCoapMessage(const QCoapMessage &other)

Constructs a shallow copy of other.

QCoapMessage::~QCoapMessage()

Destroys the QCoapMessage.

void QCoapMessage::addOption(const QCoapOption &option)

Adds the given CoAP option.

void QCoapMessage::addOption(QCoapOption::OptionName name, const QByteArray &value = QByteArray())

This is an overloaded function.

Adds the CoAP option with the given name and value.

void QCoapMessage::clearOptions()

Removes all options.

bool QCoapMessage::hasOption(QCoapOption::OptionName name) const

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

quint16 QCoapMessage::messageId() const

Returns the message id.

See Also

See also setMessageId()

QCoapOption QCoapMessage::option(QCoapOption::OptionName name) const

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

QCoapOption QCoapMessage::optionAt(int index) const

Returns the option at index position.

int QCoapMessage::optionCount() const

Returns the number of options.

const QList<QCoapOption> &QCoapMessage::options() const

Returns the list of options.

See Also

See also setOptions()

QList<QCoapOption> QCoapMessage::options(QCoapOption::OptionName name) const

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

QByteArray QCoapMessage::payload() const

Returns the payload.

See Also

See also setPayload()

void QCoapMessage::removeOption(const QCoapOption &option)

Removes the given option.

void QCoapMessage::removeOption(QCoapOption::OptionName name)

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

void QCoapMessage::setMessageId(quint16 id)

Sets the message ID to id.

See Also

See also messageId()

void QCoapMessage::setOptions(const QList<QCoapOption> &options)

Sets the message options to options.

See Also

See also options()

void QCoapMessage::setPayload(const QByteArray &payload)

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

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

void QCoapMessage::setToken(const QByteArray &token)

Sets the message token to token.

See Also

See also token()

void QCoapMessage::setType(const QCoapMessage::Type &type)

Sets the message type to type.

See Also

See also type()

void QCoapMessage::setVersion(quint8 version)

Sets the CoAP version to version.

See Also

See also version()

void QCoapMessage::swap(QCoapMessage &other)

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

QByteArray QCoapMessage::token() const

Returns the message token.

See Also

See also setToken()

quint8 QCoapMessage::tokenLength() const

Returns the token length.

QCoapMessage::Type QCoapMessage::type() const

Returns the message type.

See Also

See also setType()

quint8 QCoapMessage::version() const

Returns the CoAP version.

See Also

See also setVersion()

QCoapMessage &QCoapMessage::operator=(const QCoapMessage &other)

Copies the contents of other into this message. Returns a reference to this QCoapMessage.

QCoapMessage &QCoapMessage::operator=(QCoapMessage &&other)

Move-assignment operator.

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+