Commit Graph

7 Commits

Author SHA1 Message Date
Sona Kurazyan e04667b55c Improve the API of QCoapRequest
- Moved internally used methods to the private class.
 - Replaced the internally used protected constructor with a static
   method in the private class.
 - Removed the internally used setMethod(), no need for it anymore.
 - Removed the isValid() method, no point in keeping it.

This change is based on the feedback from API review.

Change-Id: I177efdb1d436266549dea3e8d2b01160648fce90
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-05-14 15:15:34 +00:00
Sona Kurazyan 3d10238a8b Improve the API of QCoapMessage
- Rename QCoapMessage::MessageType -> QCoapMessage::Type
 - Rename option() -> optionAt()
 - Rename removeAllOptions() -> clearOptions()
 - Hide findOption(). option() is more convenient to use instead.
 - Add a setOptions() method.

This change is based on the feedback from API review.

Change-Id: I2093a06ca09eebb95865a82e09d2aa2265379e5d
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-05-14 15:15:24 +00:00
Sona Kurazyan 7a16e8d9b5 Use scoped enums
Execptions are made for QCoapOption::OptionName and QtCoap::Port enums,
because the values of these types are not limited only to the values
listed in the enums. In case of using custom values, it would be more
convenient to use integers directly, instead of using a static_cast each
time the user needs a custom value.

Change-Id: Ibc63e26c59629702c03528dd7e5e5eedc6bcc90a
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2019-05-03 08:36:09 +00:00
Sona Kurazyan 872ab757fd Hide APIs for specifying the request method
Since the request method is set anyway when sending a request
(get, put, post, etc.), allowing users to specify the request
method is fatuous (it will be overridden anyway when sending
the request).

Change-Id: Ibf079bd513f145c791d5d703aa5685bfe66dda7d
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2019-03-11 16:53:31 +00:00
Sona Kurazyan d9d26033bb Fix URL adjustment for URLs with no scheme
Prepend the "scheme://" part a to URL only if it is relative
and doesn't have a host. Non-relative URLs having a host already
contain the "://" part.

Change-Id: If2ac3db4f2eb0d18ffa1893415f44b9d2c85db26
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2019-03-06 10:01:08 +00:00
Sona Kurazyan 14b68fb394 Add DTLS support to CoAP implementation
Added transport layer security based on QDtls.

This implementation supports authentication using pre-shared
keys and X.509 certificates.

Split the QCoapConnection class into a base class to be shared
with other transports and a specialized class that relies on
QUdpSocket using QDtls for security.

Note, that raw public key mode (which is mandatory to implement
according to RFC) is not implemented yet, since the underlying
OpenSSL library does not support it yet. However, if we later
decide to integrate another DTLS implementation, it can be done
with minimal changes, by having the new implementations's connection
type inherit the QCoapConnection class, which hides the implementation
of the transport layer.

Tests and examples will be added in a later commit.

Change-Id: I14b34a9fd978e1993e86d47becbeed74397d1d6e
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
2019-01-30 15:28:38 +00:00
Adrien Leravat 2b3755c8e6 Add the CoAP module, providing a client for Qt
Features:
- Send GET/POST/PUT/DELETE requests
- Discover resources (single server)
- Observe resources and cancel the observation
- Blockwise requests and replies
- Requests (and replies) can be confirmable or non-confirmable
- Some options can be added to the request
- Replies can be received in a separate or piggybacked message

Change-Id: I31e0e20a4f19bdc6d6489281fde73a4ff848eda4
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2018-12-14 12:20:26 +00:00