Hello Abhishek,
Thank you for the information about getAllHosts(). I used it along with
setHost() to set the host to coaps in the C++ code.
foo( std::shared_ptr<OC::OCResource> resource )
{
//
// Find the first secure coaps endpoint in the list of hosts. If it's there
// then use it; otherwise use the unsecure coap endpoint.
//
auto resourceHostList = resource->getAllHosts();
for (auto &host : resourceHostList)
{
if (std::string::npos != host.find("coaps://"))
{
resource->setHost(host);
break;
}
}
}
The coaps wasn’t chosen as default host by IoTivity stack for client-side
operations even though secure resources and thus secure endpoints are default
for server-side operations.
-Michael
From: ABHISHEK PANDEY [mailto:[email protected]]
Sent: Tuesday, December 12, 2017 22:13
To: Morrow, Joseph L <[email protected]>; Matthews, Michael L
<[email protected]>; [email protected]
Subject: RE: Re: [dev] How to determine if an OC::OCResource object endpoint is
using COAP or COAPS?
Hi,
You can check OC::OCResource:: getAllHosts() API which returns a
vector<std::string> of endpoint strings.
Below is a sample of items inside returned vector for a resource which supports
multiple endpoints :
1. coaps://192.168.1.102:35307
2. coaps://[fe80::ea11:32ff:fe67:7f5d%25p10p1]:46421
3. coaps+tcp://192.168.1.102:40013
4. coaps+tcp://[fe80::ea11:32ff:fe67:7f5d%25p10p1]:44938
One can parse above endpoint strings to know whether endpoint is using CoAP or
CoAPS.
"iotivity\resource\examples\simpleclient.cpp" contains usage example code.
Hope this helps..
--
Thanks and Regards,
Abhishek Pandey.
--------- Original Message ---------
Sender : Morrow, Joseph L <[email protected]>
Date : 2017-12-13 03:13 (GMT+5:30)
Title : Re: [dev] How to determine if an OC::OCResource object endpoint is
using COAP or COAPS?
It should be added that this appears to only be possible with the C SDK, not
the C++ SDK since the Discovery Callback function signature doesn’t provide
endpoint information.
If the client has to choose which version of a discovered resource to store and
act on (ie. Get/Post) later, there should be a sample app in the C++ SDK that
shows how to do this. We have only found a sample in the C SDK that shows this
and it’s not merged into 1.3-rel or master as of the last time we’ve checked
(last week). This means, no one knows how to perform a Secure Request as a
client unless you’re using the C SDK. This quite odd.
Thanks,
Joey Morrow
From:
<[email protected]<mailto:[email protected]>>
on behalf of "Matthews, Michael L"
<[email protected]<mailto:[email protected]>>
Date: Tuesday, December 12, 2017 at 1:38 PM
To: "[email protected]<mailto:[email protected]>"
<[email protected]<mailto:[email protected]>>
Subject: [dev] How to determine if an OC::OCResource object endpoint is using
COAP or COAPS?
Hello,
The code I am working with has a pointer to a C++ OC::OCResource object and I
am trying to determine if the IoTivity endpoint is using COAP or COAPS. The
eps->tps member of the OCResourcePayload data structure can be used to
determine the transport type (i.e., COAP or COAPS). I don't know how to convert
OC::OCResource to type OCResourcePayload so that the connection type can be
determined with the eps->tps member. Is there a way to determine if an
OC::OCResource object is using COAP or COAPS?
-Michael
_______________________________________________
iotivity-dev mailing list
[email protected]
https://lists.iotivity.org/mailman/listinfo/iotivity-dev
[cid:[email protected]]
[Image removed by sender.]
_______________________________________________
iotivity-dev mailing list
[email protected]
https://lists.iotivity.org/mailman/listinfo/iotivity-dev