• CoapPdu
  • CoapPdu Class

    Represents a CoAP protocol data unit (PDU). More...

    Header: #include <CoapPdu>
    Inherits:

    Public Types

    enum ContentType { TextPlain, ApplicationLink, ApplicationXml, ApplicationOctet, ApplicationExi, ApplicationJson }
    enum Error { NoError, InvalidTokenError, InvalidPduSizeError, InvalidOptionDeltaError, InvalidOptionLengthError, UnknownOptionError }
    enum MessageType { Confirmable, NonConfirmable, Acknowledgement, Reset }
    enum StatusCode { Empty, Get, Post, Put, ..., ProxyingNotSupported }

    Public Functions

    CoapPdu(QObject * parent = 0)
    CoapPdu(const QByteArray & data, QObject * parent = 0)
    void addOption(const CoapOption::Option & option, const QByteArray & data)
    CoapPduBlock block() const
    void clear()
    ContentType contentType() const
    void createMessageId()
    void createToken()
    bool hasOption(const CoapOption::Option & option) const
    bool isValid() const
    quint16 messageId() const
    MessageType messageType() const
    QList<CoapOption> options() const
    QByteArray pack() const
    QByteArray payload() const
    void setContentType(const ContentType & contentType)
    void setMessageId(const quint16 & messageId)
    void setMessageType(const MessageType & messageType)
    void setPayload(const QByteArray & payload)
    void setStatusCode(const StatusCode & statusCode)
    void setToken(const QByteArray & token)
    void setVersion(const quint8 & version)
    StatusCode statusCode() const
    QByteArray token() const
    quint8 version() const

    Static Public Members

    QString getStatusCodeString(const StatusCode & statusCode)

    Detailed Description

    Represents a CoAP protocol data unit (PDU).

    Member Type Documentation

    enum CoapPdu::ContentType

    The CoAP content types.

    ConstantValue
    CoapPdu::TextPlain0
    CoapPdu::ApplicationLink40
    CoapPdu::ApplicationXml41
    CoapPdu::ApplicationOctet42
    CoapPdu::ApplicationExi47
    CoapPdu::ApplicationJson50

    enum CoapPdu::Error

    ConstantValue
    CoapPdu::NoError0
    CoapPdu::InvalidTokenError1
    CoapPdu::InvalidPduSizeError2
    CoapPdu::InvalidOptionDeltaError3
    CoapPdu::InvalidOptionLengthError4
    CoapPdu::UnknownOptionError5

    enum CoapPdu::MessageType

    ConstantValue
    CoapPdu::Confirmable0x00
    CoapPdu::NonConfirmable0x01
    CoapPdu::Acknowledgement0x02
    CoapPdu::Reset0x03

    enum CoapPdu::StatusCode

    The CoAP status codes.

    Methods: https://tools.ietf.org/html/rfc7252#section-5.8

    Status codes: https://tools.ietf.org/html/rfc7252#section-12.1.2

    ConstantValueDescription
    CoapPdu::Empty0x000.00 Empty (i.e. response to ping request)
    CoapPdu::Get0x01The GET method
    CoapPdu::Post0x02The POST method
    CoapPdu::Put0x03The PUT method
    CoapPdu::Delete0x04The DELETE method
    CoapPdu::Created0x412.01 Created
    CoapPdu::Deleted0x422.02 Deleted
    CoapPdu::Valid0x432.03 Valid
    CoapPdu::Changed0x442.04 Changed
    CoapPdu::Content0x452.05 Content
    CoapPdu::Continue0x5f2.31 Continue (from Blockwise V18)
    CoapPdu::BadRequest0x804.00 Bad Request
    CoapPdu::Unauthorized0x814.01 Unauthorized
    CoapPdu::BadOption0x824.02 Bad Option
    CoapPdu::Forbidden0x834.03 Forbidden
    CoapPdu::NotFound0x844.04 Not Found
    CoapPdu::MethodNotAllowed0x854.05 Method Not Allowed
    CoapPdu::NotAcceptable0x864.06 Not Acceptable
    CoapPdu::RequestEntityIncomplete0x884.08 Request Entity Incomplete (from Blockwise V18)
    CoapPdu::PreconditionFailed0x8c4.12 Precondition Failed
    CoapPdu::RequestEntityTooLarge0x8d4.13 Request Entity Too Large (from Blockwise V18)
    CoapPdu::UnsupportedContentFormat0x8f4.15 UnsupportedContentFormat
    CoapPdu::InternalServerError0xa05.00 Internal Server Error
    CoapPdu::NotImplemented0xa15.01 Not Implemented
    CoapPdu::BadGateway0xa25.02 Bad Gateway
    CoapPdu::ServiceUnavailabl0xa35.03 Service Unavailabl
    CoapPdu::GatewayTimeout0xa45.04 Gateway Timeout
    CoapPdu::ProxyingNotSupported0xa55.05 Proxying Not Supported

    Member Function Documentation

    CoapPdu::CoapPdu(QObject * parent = 0)

    Constructs a CoapPdu with the given parent.

    CoapPdu::CoapPdu(const QByteArray & data, QObject * parent = 0)

    Constructs a CoapPdu from the given data with the given parent.

    void CoapPdu::addOption(const CoapOption::Option & option, const QByteArray & data)

    Adds the given option with the given data to this CoapPdu.

    See also CoapOption.

    CoapPduBlock CoapPdu::block() const

    Returns the block of this CoapPdu.

    void CoapPdu::clear()

    Resets this CoapPdu to the default values.

    ContentType CoapPdu::contentType() const

    Returns the CoapPdu::ContentType of this CoapPdu.

    See also setContentType().

    void CoapPdu::createMessageId()

    Creates a random message id for this CoapPdu and sets the message id to the created value.

    See also setMessageId().

    void CoapPdu::createToken()

    Creates a random token for this CoapPdu and sets the token to the created value.

    See also setToken().

    [static] QString CoapPdu::getStatusCodeString(const StatusCode & statusCode)

    Returns the human readable status code for the given statusCode.

    bool CoapPdu::hasOption(const CoapOption::Option & option) const

    Returns true if this CoapPdu has the given option.

    bool CoapPdu::isValid() const

    Returns true if this CoapPdu has no errors.

    quint16 CoapPdu::messageId() const

    Returns the messageId of this CoapPdu.

    See also setMessageId().

    MessageType CoapPdu::messageType() const

    Returns the CoapPdu::MessageType of this CoapPdu.

    See also setMessageType().

    QList<CoapOption> CoapPdu::options() const

    Returns the list of CoapOptions of this CoapPdu.

    QByteArray CoapPdu::pack() const

    Returns the packed CoapPdu as byte array which are ready to send to the server.

    QByteArray CoapPdu::payload() const

    Returns the payload of this CoapPdu.

    See also setPayload().

    void CoapPdu::setContentType(const ContentType & contentType)

    Sets the content type of this CoapPdu to the given contentType.

    See also contentType() and CoapPdu::ContentType.

    void CoapPdu::setMessageId(const quint16 & messageId)

    Sets the messageId of this CoapPdu to the given messageId.

    See also messageId().

    void CoapPdu::setMessageType(const MessageType & messageType)

    Sets the message type of this CoapPdu to the given messageType.

    See also messageType() and CoapPdu::MessageType.

    void CoapPdu::setPayload(const QByteArray & payload)

    Sets the payload of this CoapPdu to the given payload.

    See also payload().

    void CoapPdu::setStatusCode(const StatusCode & statusCode)

    Sets the message type of this CoapPdu to the given statusCode.

    See also statusCode() and CoapPdu::StatusCode.

    void CoapPdu::setToken(const QByteArray & token)

    Sets the token of this CoapPdu to the given token.

    See also token().

    void CoapPdu::setVersion(const quint8 & version)

    Sets the version of this CoapPdu to the given version.

    See also version().

    StatusCode CoapPdu::statusCode() const

    Returns the CoapPdu::StatusCode of this CoapPdu.

    See also setStatusCode().

    QByteArray CoapPdu::token() const

    Returns the token of this CoapPdu.

    See also setToken().

    quint8 CoapPdu::version() const

    Returns the version of this CoapPdu.

    See also setVersion().