This change is based on the feedback from API review.
Change-Id: I99f00d15e9474b2844a436113ac7771ead7b33c6
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
No need to keep this class public, there is no public API for accessing
it anyway.
Change-Id: I231a560becb5799667819c30eca6372282adeb41
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
At the moment only the QCoapQUdpConnection class implements the
QCoapConnection interface. If later we decide to add other
implementations, and it turns out that the current API is not good
enough, it won't be possible to change it without breaking the source
compatibility. Let's make these classes private, we can make them public
when there is a need for it.
Change-Id: I41336dda0e6eaa762f0eb9c8f4aa98a9c7b62a2c
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
QtCoap::Error is a scoped enum class, so its value names will get the
"Error::" prefix anyway. No need to have it as a suffix for the value
names.
For the same reason replaced QtCoap::Error::NoError by
QtCoap::Error::Ok.
Change-Id: Iaf7b51cdab6ea330e940e5af73ba93a55eb48315
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
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>
This class is intended for internal use only, so it should not have a
public header.
Change-Id: I18f2433d06e978582b470e14dc89a7c0e404f7d4
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
This method doesn't need to be virtual, no one overrides it.
Change-Id: Ia8c06c40fcb7cb97e413da6dc0458553540803cf
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Change-Id: I916ddb226b653aaf563ecf0adc3a1110d6da3132
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Change-Id: I1ebf03d68c267f87ca2b690d4c666c26717f8d07
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>
Change-Id: I4f193b0d65bb3104db6483749cf9dc36547e1861
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
This example demonstrates sending secure CoAP GET requests
in PreSharedKey and Certificate modes.
Change-Id: I90ea8c77232bfca1ca86bdd7a73223b6ba8b0c9b
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
QUrl can have an empty host, but still considered to be valid.
This is possible, for example, when setting an invalid host address or
when the URL is a path. Adjusting such URLs leads to unexpected results.
Added a check for preventing sending requests to URLs with no host.
Fixes: QTBUG-75155
Change-Id: I6c899f824233f32cddb8c9255fd3d1c333bb6385
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Changed th lambda for canceling the resource observation to capture
variables by value instead of capturing by reference. If we capture
'url' by reference, it will be already destroyed, when the lambda is
called.
Fixes: QTBUG-75156
Change-Id: I76792555d4eff8391b0a5075d45cd48b9e3bb918
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
This will allow to specify hostames instead of IP addresses,
when running the example.
Change-Id: Ie7c6e1489508e590351a20b58e6a69510b1c4491
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Change-Id: I00c8d6221aa730051733c48816aed3cc4f79abb4
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Firstly, the current QCoapProtocol interface only supports customizing
some parameters like timeouts, counters, etc., which can also be done
via the QCoapClient class, so there is no need for a setter method for
the protocol.
Secondly, the protocol runs on a separate thread, so it is not a good
idea to allow users to change the protocol at runtime. Even if later we
decide to support custom protocols, it can be set during the
construction of the client. So the setter method is not needed.
Removed the setter method and added the missing methods for customizing
protocol-related parameters.
Change-Id: I89375ac502be4d29d3cb617da9c2f99a3ab410ec
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
This fixes the handling of an empty QCoapPrivateKey.
Change-Id: I0dd92b2edcb0aacf56a8cb1933227f6673404f52
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
This fixes a crash introduced by one of the recent commits.
Change-Id: I4742a77585d764a1da8e07de44869b974009f626
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Change-Id: I600a7d1c933374bb021ee46cd3102408e04fb4b0
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Declaring methods to be invoked via QMetaObject::invokeMethod
in the Q_SLOTS section, makes the API confusing. Use Q_INVOKABLE
instead.
Change-Id: I1a04b279fe2ddb505e63dfd48efa1a3b4cb7ad7a
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
Users should not be able to send "manually" constructed requests
with raw byte array data. Only QCoapProtocol knows how to correctly
construct/send coap messages and make the proper signal/slot
connections.
Change-Id: I8fd64638ea7f8e7b20671b80e6db4e1a7758c4fa
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
- Introduced different log categories and categorized
log messages accordingly.
- Improved logs from console example by:
* Changing debug messages to info or warning,
* Removing extra spaces from the log messages.
Change-Id: Ia6b2006db5e7cce853e59fb7d0a1c20064444c8e
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
For the responses to multicast requests the address of the
sender of the reply does not match with the host address in
the request URI. There should be a way to find out who
has sent the response.
Change-Id: Icbc6c6ae926198870dbc7dbbb92dc319c46d7de7
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
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>
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>
This saves us several checks and "static_cast"s.
Change-Id: I81e2253929f1fe0a7a052e8c2988e28229b0c9db
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Change-Id: I9b26337ba976079608ece4781999ad0ef49a4f19
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>
Change-Id: I3401d7f66f7f14273c07b2df236a047dca4d348f
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
- QtCoap was changed to be a namespace instead of a class.
- Moved the static QtCoap::randomGenerator to a method returning
a reference to a local static object.
- The corresponding documentation and function definitions were
moved to its .cpp file.
- Added the missing documentation.
Change-Id: Ie0c60189b18b8f5e8d9a94f91b6fb7b9259984dd
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Use CoAP multicast group addresses, if the user haven't
provided a group discovery URI.
Change-Id: Id4e4eedc2c4596d738b3e9c3c0461ca3feddf3ef
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>