--- /dev/null
+/**
+ * @brief TODO
+ * @date Created 16.06.2017
+ * @author Created 2017 in Samsung Ukraine R&D Center (SURC) under a contract
+ * between LLC "Samsung Electronics Ukraine Company" (Kiev, Ukraine)
+ * and "Samsung Electronics Co", Ltd (Seoul, Republic of Korea).
+ * Copyright: (c) Samsung Electronics Co, Ltd 2017. All rights reserved.
+ * @author Mail to: <A HREF="mailto:a.gudz@samsung.com">Andriy Gudz, a.gudz@samsung.com</A>
+ */
+#ifndef IOTUTILS_H
+#define IOTUTILS_H
+
+#include <OCApi.h>
+#include <OCPlatform.h>
+
+/**
+ * @brief The IotUtils class contains utility methods
+ */
+class IotUtils final
+{
+public:
+ /**
+ * @brief IotUtils Constructor
+ */
+ IotUtils();
+
+ /**
+ * @brief printRepresentation used to print complex representaions
+ * @param rep OCRepresentation object
+ */
+ static void printRepresentation(OC::OCRepresentation rep);
+};
+
+#endif // IOTUTILS_H
#include "IOT_DeviceFinder.h"
-std::vector<std::shared_ptr<OC::OCResource>> IOT_DeviceFinder::operator()( const std::string& _host /*= ""*/,
- const std::string& _request_uri /*= "/oic/res?rt=oic.wk.easysetup"*/,
- OCConnectivityType _connectivity_type /*= CT_DEFAULT*/,
- OC::QualityOfService _QoS /*= OC::QualityOfService::LowQos*/,
- int _wait_for_sec /*= 3*/ )
+using namespace std;
+
+vector<shared_ptr<OC::OCResource>> IOT_DeviceFinder::operator()(
+ const std::string& _host /*= ""*/,
+ const std::string& _request_uri /*= "/oic/res?rt=oic.wk.easysetup"*/,
+ OCConnectivityType _connectivity_type /*= CT_DEFAULT*/,
+ OC::QualityOfService _QoS /*= OC::QualityOfService::LowQos*/,
+ int _wait_for_sec /*= 3*/ )
{
auto find_callback = [this, _connectivity_type](std::vector<std::shared_ptr<OC::OCResource>> _resources)
{
std::unique_lock<std::mutex> lock{vector_mtx};
- for (auto resource: _resources)
+
+ for (auto resource : _resources)
{
if (_connectivity_type == CT_DEFAULT || (resource->connectivityType() & _connectivity_type))
{
const std::string dev_info_uri{"/oic/d"};
const std::string dev_type_resource{"oic.d."};
const std::string dev_type_uri{"/oic/res?rt=oic.wk.d"};
-void printRepresentation(OCRepresentation rep)
-{
- for (auto itr = rep.begin(); itr != rep.end(); ++itr)
- {
- std::cout << "\t" << itr->attrname() << ":\t" << itr->getValueToString() << std::endl;
- if (itr->type() == AttributeType::Vector)
- {
- switch (itr->base_type())
- {
- case AttributeType::OCRepresentation:
- for (auto itr2 : (*itr).getValue<std::vector<OCRepresentation> >())
- {
- printRepresentation(itr2);
- }
- break;
-
- case AttributeType::Integer:
- for (auto itr2 : (*itr).getValue<std::vector<int> >())
- {
- std::cout << "\t\t" << itr2 << std::endl;
- }
- break;
-
- case AttributeType::String:
- for (auto itr2 : (*itr).getValue<std::vector<std::string> >())
- {
- std::cout << "\t\t" << itr2 << std::endl;
- }
- break;
-
- default:
- std::cout << "Unhandled base type " << itr->base_type() << std::endl;
- break;
- }
- }
- else if (itr->type() == AttributeType::OCRepresentation)
- {
- printRepresentation((*itr).getValue<OCRepresentation>());
- }
- }
-}
}
namespace NetworkManager
#include "nmlib.h"
#include "report_client.h"
#include "policy_client.h"
+#include "iotutils.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wreorder"
const std::string NOTIF_REQUEST = string(OC_RSRVD_WELL_KNOWN_URI) + "?rt=" + NetworkManager::NOTIFICATION_TYPE;
const std::string REP_LIST{"prslist"};
-
-void printRepresentation(OCRepresentation rep)
-{
- for (auto itr = rep.begin(); itr != rep.end(); ++itr)
- {
- std::cout << "\t" << itr->attrname() << ":\t" << itr->getValueToString() << std::endl;
- if (itr->type() == AttributeType::Vector)
- {
- switch (itr->base_type())
- {
- case AttributeType::OCRepresentation:
- for (auto itr2 : (*itr).getValue<std::vector<OCRepresentation> >())
- {
- printRepresentation(itr2);
- }
- break;
-
- case AttributeType::Integer:
- for (auto itr2 : (*itr).getValue<std::vector<int> >())
- {
- std::cout << "\t\t" << itr2 << std::endl;
- }
- break;
-
- case AttributeType::String:
- for (auto itr2 : (*itr).getValue<std::vector<std::string> >())
- {
- std::cout << "\t\t" << itr2 << std::endl;
- }
- break;
-
- default:
- std::cout << "Unhandled base type " << itr->base_type() << std::endl;
- break;
- }
- }
- else if (itr->type() == AttributeType::OCRepresentation)
- {
- printRepresentation((*itr).getValue<OCRepresentation>());
- }
- }
-}
-
}
namespace NetworkManager
--- /dev/null
+/**
+ * @brief TODO
+ * @date Created 16.06.2017
+ * @author Created 2017 in Samsung Ukraine R&D Center (SURC) under a contract
+ * between LLC "Samsung Electronics Ukraine Company" (Kiev, Ukraine)
+ * and "Samsung Electronics Co", Ltd (Seoul, Republic of Korea).
+ * Copyright: (c) Samsung Electronics Co, Ltd 2017. All rights reserved.
+ * @author Mail to: <A HREF="mailto:a.gudz@samsung.com">Andriy Gudz, a.gudz@samsung.com</A>
+ */
+#include "iotutils.h"
+
+using namespace OC;
+
+void IotUtils::printRepresentation(OCRepresentation rep)
+{
+ for (auto itr = rep.begin(); itr != rep.end(); ++itr)
+ {
+ std::cout << "\t" << itr->attrname() << ":\t" << itr->getValueToString() << std::endl;
+ if (itr->type() == AttributeType::Vector)
+ {
+ switch (itr->base_type())
+ {
+ case AttributeType::OCRepresentation:
+ for (auto itr2 : (*itr).getValue<std::vector<OCRepresentation> >())
+ {
+ printRepresentation(itr2);
+ }
+ break;
+
+ case AttributeType::Integer:
+ for (auto itr2 : (*itr).getValue<std::vector<int> >())
+ {
+ std::cout << "\t\t" << itr2 << std::endl;
+ }
+ break;
+
+ case AttributeType::String:
+ for (auto itr2 : (*itr).getValue<std::vector<std::string> >())
+ {
+ std::cout << "\t\t" << itr2 << std::endl;
+ }
+ break;
+
+ default:
+ std::cout << "Unhandled base type " << itr->base_type() << std::endl;
+ break;
+ }
+ }
+ else if (itr->type() == AttributeType::OCRepresentation)
+ {
+ printRepresentation((*itr).getValue<OCRepresentation>());
+ }
+ }
+}
jsoncpp
)
+if ("${FLAVOR}" STREQUAL "UBUNTU")
+ set (LINK_DLOG "")
+else()
+ set (LINK_DLOG dlog)
+endif()
+
if ("${SCENARIO}" STREQUAL "PRIMITIVE")
- if ("${FLAVOR}" STREQUAL "UBUNTU")
- set (LINK_DLOG "")
- else()
- set (LINK_DLOG dlog)
- endif()
target_link_libraries(${PROJECT_NAME} ${IOTIVITY_LIB_PROJECT_NAME} ${LINK_DLOG})
else()
- set (TEST_LINK_LIBRARIES ${TEST_LINK_LIBRARIES} ${CTRL_APP_LIB_PROJECT_NAME} dlog)
+ set (TEST_LINK_LIBRARIES ${TEST_LINK_LIBRARIES} ${CTRL_APP_LIB_PROJECT_NAME} ${LINK_DLOG})
endif()
target_link_libraries(${PROJECT_NAME} ${TEST_LINK_LIBRARIES})