1 //******************************************************************
3 // Copyright 2016 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 #include "OCDirectPairing.h"
26 static const char COAP[] = "coap://";
27 static const char COAPS[] = "coaps://";
28 static const int UUID_LENGTH = (128/8); //UUID length
30 OCDirectPairing::OCDirectPairing(OCDPDev_t *ptr):m_devPtr(ptr)
34 std::string OCDirectPairing::getHost()
37 std::ostringstream host("");
38 if (m_devPtr->connType & CT_IP_USE_V6)
43 host << COAPS << (ipv6?"[":"") << m_devPtr->endpoint.addr;
44 host << (ipv6?"]:":":") << m_devPtr->securePort;
49 std::string OCDirectPairing::getDeviceID()
51 std::ostringstream deviceId("");
53 for (int i = 0; i < UUID_LENGTH; i++)
55 if (i == 4 || i == 6 || i == 8 || i == 10)
59 deviceId << std::hex << std::setfill('0') << std::setw(2) << static_cast<unsigned>(m_devPtr->deviceID.id[i]);
62 return deviceId.str();
65 std::vector<OCPrm_t> OCDirectPairing::getPairingMethods()
67 std::vector<OCPrm_t> prms;
69 for (size_t i = 0; i < m_devPtr->prmLen; i++)
71 prms.push_back(m_devPtr->prm[i]);
76 OCConnectivityType OCDirectPairing::getConnType()
78 return m_devPtr->connType;
81 OCDPDev_t* OCDirectPairing::getDev()