Represents a CoAP protocol data unit (PDU). More...
Header: | #include <CoapPdu> |
Inherits: |
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 } |
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 |
QString | getStatusCodeString(const StatusCode & statusCode) |
Represents a CoAP protocol data unit (PDU).
The CoAP content types.
Constant | Value |
---|---|
CoapPdu::TextPlain | 0 |
CoapPdu::ApplicationLink | 40 |
CoapPdu::ApplicationXml | 41 |
CoapPdu::ApplicationOctet | 42 |
CoapPdu::ApplicationExi | 47 |
CoapPdu::ApplicationJson | 50 |
Constant | Value |
---|---|
CoapPdu::NoError | 0 |
CoapPdu::InvalidTokenError | 1 |
CoapPdu::InvalidPduSizeError | 2 |
CoapPdu::InvalidOptionDeltaError | 3 |
CoapPdu::InvalidOptionLengthError | 4 |
CoapPdu::UnknownOptionError | 5 |
Constant | Value |
---|---|
CoapPdu::Confirmable | 0x00 |
CoapPdu::NonConfirmable | 0x01 |
CoapPdu::Acknowledgement | 0x02 |
CoapPdu::Reset | 0x03 |
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
Constant | Value | Description |
---|---|---|
CoapPdu::Empty | 0x00 | 0.00 Empty (i.e. response to ping request) |
CoapPdu::Get | 0x01 | The GET method |
CoapPdu::Post | 0x02 | The POST method |
CoapPdu::Put | 0x03 | The PUT method |
CoapPdu::Delete | 0x04 | The DELETE method |
CoapPdu::Created | 0x41 | 2.01 Created |
CoapPdu::Deleted | 0x42 | 2.02 Deleted |
CoapPdu::Valid | 0x43 | 2.03 Valid |
CoapPdu::Changed | 0x44 | 2.04 Changed |
CoapPdu::Content | 0x45 | 2.05 Content |
CoapPdu::Continue | 0x5f | 2.31 Continue (from Blockwise V18) |
CoapPdu::BadRequest | 0x80 | 4.00 Bad Request |
CoapPdu::Unauthorized | 0x81 | 4.01 Unauthorized |
CoapPdu::BadOption | 0x82 | 4.02 Bad Option |
CoapPdu::Forbidden | 0x83 | 4.03 Forbidden |
CoapPdu::NotFound | 0x84 | 4.04 Not Found |
CoapPdu::MethodNotAllowed | 0x85 | 4.05 Method Not Allowed |
CoapPdu::NotAcceptable | 0x86 | 4.06 Not Acceptable |
CoapPdu::RequestEntityIncomplete | 0x88 | 4.08 Request Entity Incomplete (from Blockwise V18) |
CoapPdu::PreconditionFailed | 0x8c | 4.12 Precondition Failed |
CoapPdu::RequestEntityTooLarge | 0x8d | 4.13 Request Entity Too Large (from Blockwise V18) |
CoapPdu::UnsupportedContentFormat | 0x8f | 4.15 UnsupportedContentFormat |
CoapPdu::InternalServerError | 0xa0 | 5.00 Internal Server Error |
CoapPdu::NotImplemented | 0xa1 | 5.01 Not Implemented |
CoapPdu::BadGateway | 0xa2 | 5.02 Bad Gateway |
CoapPdu::ServiceUnavailabl | 0xa3 | 5.03 Service Unavailabl |
CoapPdu::GatewayTimeout | 0xa4 | 5.04 Gateway Timeout |
CoapPdu::ProxyingNotSupported | 0xa5 | 5.05 Proxying Not Supported |
Constructs a CoapPdu with the given parent.
Constructs a CoapPdu from the given data with the given parent.
Adds the given option with the given data to this CoapPdu.
See also CoapOption.
Returns the block of this CoapPdu.
Resets this CoapPdu to the default values.
Returns the CoapPdu::ContentType of this CoapPdu.
See also setContentType().
Creates a random message id for this CoapPdu and sets the message id to the created value.
See also setMessageId().
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.
Returns true if this CoapPdu has the given option.
Returns true if this CoapPdu has no errors.
Returns the messageId of this CoapPdu.
See also setMessageId().
Returns the CoapPdu::MessageType of this CoapPdu.
See also setMessageType().
Returns the list of CoapOptions of this CoapPdu.
Returns the packed CoapPdu as byte array which are ready to send to the server.
Returns the payload of this CoapPdu.
See also setPayload().
Sets the content type of this CoapPdu to the given contentType.
See also contentType() and CoapPdu::ContentType.
Sets the messageId of this CoapPdu to the given messageId.
See also messageId().
Sets the message type of this CoapPdu to the given messageType.
See also messageType() and CoapPdu::MessageType.
Sets the payload of this CoapPdu to the given payload.
See also payload().
Sets the message type of this CoapPdu to the given statusCode.
See also statusCode() and CoapPdu::StatusCode.
Sets the token of this CoapPdu to the given token.
See also token().
Sets the version of this CoapPdu to the given version.
See also version().
Returns the CoapPdu::StatusCode of this CoapPdu.
See also setStatusCode().
Returns the token of this CoapPdu.
See also setToken().
Returns the version of this CoapPdu.
See also setVersion().