#include "common/logger.h"
#include "common/platform_exception.h"
#include "common/scope_exit.h"
+#include "common/tools.h"
#include "iotcon/iotcon_server_manager.h"
namespace extension {
namespace iotcon {
+namespace {
+
+#define IOTCON_CONNECTIVITY_TYPE_E \
+ X(IOTCON_CONNECTIVITY_IPV4, "IPV4") \
+ X(IOTCON_CONNECTIVITY_IPV6, "IPV6") \
+ X(IOTCON_CONNECTIVITY_BT_EDR, "BT_EDR") \
+ X(IOTCON_CONNECTIVITY_BT_LE, "BT_LE") \
+ X(IOTCON_CONNECTIVITY_ALL, "ALL") \
+ XD(IOTCON_CONNECTIVITY_ALL, "unknown")
+
+#define IOTCON_REQUEST_TYPE_E \
+ X(IOTCON_REQUEST_UNKNOWN, "unknown") \
+ X(IOTCON_REQUEST_GET, "GET") \
+ X(IOTCON_REQUEST_PUT, "PUT") \
+ X(IOTCON_REQUEST_POST, "POST") \
+ X(IOTCON_REQUEST_DELETE, "DELETE") \
+ XD(IOTCON_REQUEST_UNKNOWN, "unknown")
+
+#define IOTCON_OBSERVE_TYPE_E \
+ X(IOTCON_OBSERVE_NO_TYPE, "NO_TYPE") \
+ X(IOTCON_OBSERVE_REGISTER, "REGISTER") \
+ X(IOTCON_OBSERVE_DEREGISTER, "DEREGISTER") \
+ XD(IOTCON_OBSERVE_NO_TYPE, "unknown")
+
+#define IOTCON_INTERFACE_E \
+ X(IOTCON_INTERFACE_NONE, "NONE") \
+ X(IOTCON_INTERFACE_DEFAULT, "DEFAULT") \
+ X(IOTCON_INTERFACE_LINK, "LINK") \
+ X(IOTCON_INTERFACE_BATCH, "BATCH") \
+ X(IOTCON_INTERFACE_GROUP, "GROUP") \
+ X(IOTCON_INTERFACE_READONLY, "READONLY") \
+ XD(IOTCON_INTERFACE_NONE, "unknown")
+
+} // namespace
+
const std::string kIsDiscoverable = "isDiscoverable";
const std::string kIsObservable = "isObservable";
const std::string kIsActive = "isActive";
const std::string kResourceInterfaces = "resourceInterfaces";
const std::string kResourceChildren = "resources";
const std::string kUriPath = "uriPath";
-const std::string kResourceId = "id";
+const std::string kStates = "states";
+const std::string kId = "id";
-const std::string kInterfaceDefault = "DEFAULT";
-const std::string kInterfaceLink = "LINK";
-const std::string kInterfaceBatch = "BATCH";
-const std::string kInterfaceGroup = "GROUP";
+const std::string kHostAddress = "hostAddress";
+const std::string kConnectivityType = "connectivityType";
+const std::string kRepresentation = "representation";
+const std::string kRepresentations = "representations";
+const std::string kRequestType = "type";
+const std::string kOptions = "options";
+const std::string kQuery = "query";
+const std::string kObserverId = "observerId";
+const std::string kObserveType = "observeType";
-using common::TizenResult;
-using common::TizenSuccess;
+const std::string kOptionsId = "id";
+const std::string kOptionsData = "data";
-TizenResult IotconUtils::StringToInterface(const std::string& interface, iotcon_interface_e* res) {
- ScopeLogger();
+const std::string kResourceType = "resourceType";
+const std::string kResourceInterface = "resourceInterface";
+const std::string kFilter = "filter";
- if (kInterfaceDefault == interface) {
- *res = IOTCON_INTERFACE_DEFAULT;
- } else if (kInterfaceLink == interface) {
- *res = IOTCON_INTERFACE_LINK;
- } else if (kInterfaceBatch == interface) {
- *res = IOTCON_INTERFACE_BATCH;
- } else if (kInterfaceGroup == interface) {
- *res = IOTCON_INTERFACE_GROUP;
- } else {
- return LogAndCreateTizenError(InvalidValuesError, "Not supported interface name");
- }
- return TizenSuccess();
-}
+const std::string kHexPrefix = "0x";
+
+using common::TizenResult;
+using common::TizenSuccess;
TizenResult IotconUtils::ArrayToInterfaces(const picojson::array& interfaces, int* res) {
ScopeLogger();
if (!iter->is<std::string>()) {
return LogAndCreateTizenError(InvalidValuesError, "Array holds incorrect interface names");
} else {
- iotcon_interface_e interface = IOTCON_INTERFACE_NONE;
- auto ret = StringToInterface(iter->get<std::string>(), &interface);
- if (!ret) {
- return ret;
- }
+ iotcon_interface_e interface = ToInterface(iter->get<std::string>());
result_value |= interface;
}
}
picojson::array res;
if (interfaces & IOTCON_INTERFACE_DEFAULT) {
- res.push_back(picojson::value(kInterfaceDefault));
+ res.push_back(picojson::value(FromInterface(IOTCON_INTERFACE_DEFAULT)));
}
if (interfaces & IOTCON_INTERFACE_LINK) {
- res.push_back(picojson::value(kInterfaceLink));
+ res.push_back(picojson::value(FromInterface(IOTCON_INTERFACE_LINK)));
}
if (interfaces & IOTCON_INTERFACE_BATCH) {
- res.push_back(picojson::value(kInterfaceBatch));
+ res.push_back(picojson::value(FromInterface(IOTCON_INTERFACE_BATCH)));
}
if (interfaces & IOTCON_INTERFACE_GROUP) {
- res.push_back(picojson::value(kInterfaceGroup));
+ res.push_back(picojson::value(FromInterface(IOTCON_INTERFACE_GROUP)));
+ }
+ if (interfaces & IOTCON_INTERFACE_READONLY) {
+ res.push_back(picojson::value(FromInterface(IOTCON_INTERFACE_READONLY)));
}
return res;
}
if (!ret){
return ret;
}
- res->insert(std::make_pair(kResourceId, picojson::value(static_cast<double>(pointer->id))));
+ res->insert(std::make_pair(kId, picojson::value(static_cast<double>(pointer->id))));
res->insert(std::make_pair(kUriPath, picojson::value(uri_path)));
picojson::array types;
return TizenSuccess();
}
+common::TizenResult IotconUtils::RequestToJson(iotcon_request_h request,
+ picojson::object* out) {
+ ScopeLogger();
+
+ {
+ // hostAddress
+ char* host_address = nullptr;
+ auto result = ConvertIotconError(iotcon_request_get_host_address(request, &host_address));
+ if (!result || !host_address) {
+ LogAndReturnTizenError(result, ("iotcon_request_get_host_address() failed"));
+ }
+ out->insert(std::make_pair(kHostAddress, picojson::value{host_address}));
+ }
+
+ {
+ // connectivityType
+ iotcon_connectivity_type_e connectivity_type = IOTCON_CONNECTIVITY_ALL;
+ auto result = ConvertIotconError(iotcon_request_get_connectivity_type(request, &connectivity_type));
+ if (!result) {
+ LogAndReturnTizenError(result, ("iotcon_request_get_connectivity_type() failed"));
+ }
+ out->insert(std::make_pair(kConnectivityType, picojson::value{FromConnectivityType(connectivity_type)}));
+ }
+
+ {
+ // representation
+ iotcon_representation_h representation = nullptr;
+ auto result = ConvertIotconError(iotcon_request_get_representation(request, &representation));
+ if (!result) {
+ LogAndReturnTizenError(result, ("iotcon_request_get_representation() failed"));
+ }
+ picojson::value v{picojson::object{}};
+ result = RepresentationToJson(representation, &v.get<picojson::object>());
+ if (!result) {
+ LogAndReturnTizenError(result, ("RepresentationToJson() failed"));
+ }
+ out->insert(std::make_pair(kRepresentation, v));
+ }
+
+ {
+ // requestType
+ iotcon_request_type_e request_type = IOTCON_REQUEST_UNKNOWN;
+ auto result = ConvertIotconError(iotcon_request_get_request_type(request, &request_type));
+ if (!result) {
+ LogAndReturnTizenError(result, ("iotcon_request_get_request_type() failed"));
+ }
+ out->insert(std::make_pair(kRequestType, picojson::value{FromRequestType(request_type)}));
+ }
+
+ {
+ // options
+ iotcon_options_h options = nullptr;
+ auto result = ConvertIotconError(iotcon_request_get_options(request, &options));
+ if (!result) {
+ LogAndReturnTizenError(result, ("iotcon_request_get_options() failed"));
+ }
+ picojson::value v{picojson::array{}};
+ result = OptionsToJson(options, &v.get<picojson::array>());
+ if (!result) {
+ LogAndReturnTizenError(result, ("OptionsToJson() failed"));
+ }
+ out->insert(std::make_pair(kOptions, v));
+ }
+
+ {
+ // query
+ iotcon_query_h query = nullptr;
+ auto result = ConvertIotconError(iotcon_request_get_query(request, &query));
+ if (!result) {
+ LogAndReturnTizenError(result, ("iotcon_request_get_query() failed"));
+ }
+ picojson::value v{picojson::object{}};
+ result = QueryToJson(query, &v.get<picojson::object>());
+ if (!result) {
+ LogAndReturnTizenError(result, ("QueryToJson() failed"));
+ }
+ out->insert(std::make_pair(kQuery, v));
+ }
+
+ {
+ // observerId
+ int observer_id = -1;
+ auto result = ConvertIotconError(iotcon_request_get_observe_id(request, &observer_id));
+ if (!result) {
+ LogAndReturnTizenError(result, ("iotcon_request_get_observe_id() failed"));
+ }
+ out->insert(std::make_pair(kObserverId, picojson::value{static_cast<double>(observer_id)}));
+ }
+
+ {
+ // observeType
+ iotcon_observe_type_e observe_type = IOTCON_OBSERVE_NO_TYPE;
+ auto result = ConvertIotconError(iotcon_request_get_observe_type(request, &observe_type));
+ if (!result) {
+ LogAndReturnTizenError(result, ("iotcon_request_get_observe_type() failed"));
+ }
+ out->insert(std::make_pair(kRequestType, picojson::value{FromObserveType(observe_type)}));
+ }
+
+ return TizenSuccess();
+}
+
+common::TizenResult IotconUtils::RepresentationToJson(iotcon_representation_h representation,
+ picojson::object* out) {
+ ScopeLogger();
+
+ {
+ // hostAddress
+ char* uri_path = nullptr;
+ auto result = ConvertIotconError(iotcon_representation_get_uri_path(representation, &uri_path));
+ if (!result || !uri_path) {
+ LogAndReturnTizenError(result, ("iotcon_representation_get_uri_path() failed"));
+ }
+ out->insert(std::make_pair(kUriPath, picojson::value{uri_path}));
+ }
+
+ {
+ // resourceTypes
+ iotcon_resource_types_h resource_types = nullptr;
+ auto result = ConvertIotconError(iotcon_representation_get_resource_types(representation, &resource_types));
+ if (!result) {
+ LogAndReturnTizenError(result, ("iotcon_representation_get_resource_types() failed"));
+ }
+ picojson::value v{picojson::array{}};
+ iotcon_resource_types_foreach(resource_types, ResourceTypeIterator, &v.get<picojson::array>());
+ out->insert(std::make_pair(kResourceTypes, v));
+ }
+
+ {
+ // resourceInterfaces
+ int interfaces = 0;
+ auto result = ConvertIotconError(iotcon_representation_get_resource_interfaces(representation, &interfaces));
+ if (!result) {
+ LogAndReturnTizenError(result, ("iotcon_representation_get_resource_interfaces() failed"));
+ }
+ out->insert(std::make_pair(kResourceInterfaces, picojson::value{InterfacesToArray(interfaces)}));
+ }
+
+ {
+ // states
+ iotcon_state_h state = nullptr;
+ auto result = ConvertIotconError(iotcon_representation_get_state(representation, &state));
+ if (!result) {
+ LogAndReturnTizenError(result, ("iotcon_representation_get_state() failed"));
+ }
+ picojson::value v{picojson::object{}};
+ result = StateToJson(state, &v.get<picojson::object>());
+ if (!result) {
+ LogAndReturnTizenError(result, ("StateToJson() failed"));
+ }
+ out->insert(std::make_pair(kStates, v));
+ }
+
+ {
+ // representations
+ picojson::value v{picojson::array{}};
+ auto result = ConvertIotconError(iotcon_representation_foreach_children(representation, [](iotcon_representation_h child, void* user_data) -> bool {
+ auto arr = static_cast<picojson::array*>(user_data);
+ arr->push_back(picojson::value{picojson::object{}});
+ auto result = RepresentationToJson(child, &arr->back().get<picojson::object>());
+ if (!result) {
+ LoggerE("Failed to convert child representation");
+ }
+ // always continue with iteration
+ return true;
+ }, &v.get<picojson::array>()));
+ if (!result) {
+ LogAndReturnTizenError(result, ("iotcon_representation_foreach_children() failed"));
+ }
+ out->insert(std::make_pair(kRepresentations, v));
+ }
+
+ return TizenSuccess();
+}
+
+common::TizenResult IotconUtils::StateToJson(iotcon_state_h state,
+ picojson::object* out) {
+ ScopeLogger();
+
+ auto result = ConvertIotconError(iotcon_state_foreach(state, [](iotcon_state_h state, const char* key, void* user_data) -> bool {
+ iotcon_type_e type = IOTCON_TYPE_NONE;
+ auto result = ConvertIotconError(iotcon_state_get_type(state, key, &type));
+
+ if (result) {
+ auto out = static_cast<picojson::object*>(user_data);
+
+ switch (type) {
+ case IOTCON_TYPE_NONE:
+ LoggerE("Key %s has type NONE", key);
+ break;
+
+ case IOTCON_TYPE_INT:
+ {
+ int value = 0;
+ result = ConvertIotconError(iotcon_state_get_int(state, key, &value));
+ if (result) {
+ out->insert(std::make_pair(key, picojson::value{static_cast<double>(value)}));
+ } else {
+ LoggerE("iotcon_state_get_int() failed");
+ }
+ }
+ break;
+
+ case IOTCON_TYPE_BOOL:
+ {
+ bool value = false;
+ result = ConvertIotconError(iotcon_state_get_bool(state, key, &value));
+ if (result) {
+ out->insert(std::make_pair(key, picojson::value{value}));
+ } else {
+ LoggerE("iotcon_state_get_bool() failed");
+ }
+ }
+ break;
+
+ case IOTCON_TYPE_DOUBLE:
+ {
+ double value = 0.0;
+ result = ConvertIotconError(iotcon_state_get_double(state, key, &value));
+ if (result) {
+ out->insert(std::make_pair(key, picojson::value{value}));
+ } else {
+ LoggerE("iotcon_state_get_double() failed");
+ }
+ }
+ break;
+
+ case IOTCON_TYPE_STR:
+ {
+ char* value = nullptr;
+ result = ConvertIotconError(iotcon_state_get_str(state, key, &value));
+ if (result && value) {
+ out->insert(std::make_pair(key, picojson::value{value}));
+ } else {
+ LoggerE("iotcon_state_get_str() failed");
+ }
+ }
+ break;
+
+ case IOTCON_TYPE_BYTE_STR:
+ {
+ unsigned char* value = nullptr;
+ int length = 0;
+ result = ConvertIotconError(iotcon_state_get_byte_str(state, key, &value, &length));
+
+ if (result && length) {
+ std::unique_ptr<char[]> data{new char[2 * length]};
+ common::tools::BinToHex(value, length, data.get(), 2 * length);
+ out->insert(std::make_pair(key, picojson::value{kHexPrefix + data.get()}));
+ } else {
+ LoggerE("iotcon_state_get_byte_str() failed");
+ }
+ }
+ break;
+
+ case IOTCON_TYPE_NULL:
+ out->insert(std::make_pair(key, picojson::value{}));
+ break;
+
+ case IOTCON_TYPE_LIST:
+ {
+ iotcon_list_h list = nullptr;
+ result = ConvertIotconError(iotcon_state_get_list(state, key, &list));
+ if (result) {
+ picojson::value value{picojson::array{}};
+
+ result = StateListToJson(list, &value.get<picojson::array>());
+ if (result) {
+ out->insert(std::make_pair(key, picojson::value{value}));
+ } else {
+ LoggerE("StateListToJson() failed");
+ }
+ } else {
+ LoggerE("iotcon_state_get_list() failed");
+ }
+ }
+ break;
+
+ case IOTCON_TYPE_STATE:
+ {
+ iotcon_state_h child = nullptr;
+ result = ConvertIotconError(iotcon_state_get_state(state, key, &child));
+ if (result) {
+ picojson::value value{picojson::object{}};
+
+ result = StateToJson(child, &value.get<picojson::object>());
+ if (result) {
+ out->insert(std::make_pair(key, picojson::value{value}));
+ } else {
+ LoggerE("StateToJson() failed");
+ }
+ } else {
+ LoggerE("iotcon_state_get_state() failed");
+ }
+ }
+ break;
+ }
+ } else {
+ LoggerE("iotcon_state_get_type() failed");
+ }
+
+ // always continue with iteration
+ return true;
+ }, out));
+
+ if (!result) {
+ LogAndReturnTizenError(result, ("iotcon_state_foreach() failed"));
+ }
+
+ return TizenSuccess();
+}
+
+common::TizenResult IotconUtils::StateListToJson(iotcon_list_h list,
+ picojson::array* out) {
+ ScopeLogger();
+
+ iotcon_type_e type = IOTCON_TYPE_NONE;
+ auto result = ConvertIotconError(iotcon_list_get_type(list, &type));
+
+ if (!result) {
+ LogAndReturnTizenError(result, ("iotcon_list_get_type() failed"));
+ }
+
+ switch (type) {
+ case IOTCON_TYPE_NONE:
+ LoggerE("List has type NONE");
+ break;
+
+ case IOTCON_TYPE_INT:
+ result = ConvertIotconError(iotcon_list_foreach_int(list, [](int, int value, void* user_data) -> bool {
+ auto out = static_cast<picojson::array*>(user_data);
+ out->push_back(picojson::value{static_cast<double>(value)});
+ // always continue with iteration
+ return true;
+ }, out));
+ if (!result) {
+ LogAndReturnTizenError(result, ("iotcon_list_foreach_int() failed"));
+ }
+ break;
+
+ case IOTCON_TYPE_BOOL:
+ result = ConvertIotconError(iotcon_list_foreach_bool(list, [](int, bool value, void* user_data) -> bool {
+ auto out = static_cast<picojson::array*>(user_data);
+ out->push_back(picojson::value{value});
+ // always continue with iteration
+ return true;
+ }, out));
+ if (!result) {
+ LogAndReturnTizenError(result, ("iotcon_list_foreach_bool() failed"));
+ }
+ break;
+
+ case IOTCON_TYPE_DOUBLE:
+ result = ConvertIotconError(iotcon_list_foreach_double(list, [](int, double value, void* user_data) -> bool {
+ auto out = static_cast<picojson::array*>(user_data);
+ out->push_back(picojson::value{value});
+ // always continue with iteration
+ return true;
+ }, out));
+ if (!result) {
+ LogAndReturnTizenError(result, ("iotcon_list_foreach_double() failed"));
+ }
+ break;
+
+ case IOTCON_TYPE_STR:
+ result = ConvertIotconError(iotcon_list_foreach_str(list, [](int, const char* value, void* user_data) -> bool {
+ if (value) {
+ auto out = static_cast<picojson::array*>(user_data);
+ out->push_back(picojson::value{value});
+ }
+ // always continue with iteration
+ return true;
+ }, out));
+ if (!result) {
+ LogAndReturnTizenError(result, ("iotcon_list_foreach_str() failed"));
+ }
+ break;
+
+ case IOTCON_TYPE_BYTE_STR:
+ result = ConvertIotconError(iotcon_list_foreach_byte_str(list, [](int, const unsigned char* value, int length, void* user_data) -> bool {
+ if (length) {
+ std::unique_ptr<char[]> data{new char[2 * length]};
+ common::tools::BinToHex(value, length, data.get(), 2 * length);
+
+ auto out = static_cast<picojson::array*>(user_data);
+ out->push_back(picojson::value{kHexPrefix + data.get()});
+ }
+ // always continue with iteration
+ return true;
+ }, out));
+ if (!result) {
+ LogAndReturnTizenError(result, ("iotcon_list_foreach_str() failed"));
+ }
+ break;
+
+ case IOTCON_TYPE_NULL:
+ LoggerE("List has type NULL");
+ break;
+
+ case IOTCON_TYPE_LIST:
+ result = ConvertIotconError(iotcon_list_foreach_list(list, [](int, iotcon_list_h list, void* user_data) -> bool {
+ picojson::value value{picojson::array{}};
+ auto result = StateListToJson(list, &value.get<picojson::array>());
+ if (result) {
+ auto out = static_cast<picojson::array*>(user_data);
+ out->push_back(picojson::value{value});
+ } else {
+ LoggerE("StateListToJson() failed");
+ }
+ // always continue with iteration
+ return true;
+ }, out));
+ if (!result) {
+ LogAndReturnTizenError(result, ("iotcon_list_foreach_list() failed"));
+ }
+ break;
+
+ case IOTCON_TYPE_STATE:
+ result = ConvertIotconError(iotcon_list_foreach_state(list, [](int, iotcon_state_h state, void* user_data) -> bool {
+ picojson::value value{picojson::object{}};
+ auto result = StateToJson(state, &value.get<picojson::object>());
+ if (result) {
+ auto out = static_cast<picojson::array*>(user_data);
+ out->push_back(picojson::value{value});
+ } else {
+ LoggerE("StateToJson() failed");
+ }
+ // always continue with iteration
+ return true;
+ }, out));
+ if (!result) {
+ LogAndReturnTizenError(result, ("iotcon_list_foreach_state() failed"));
+ }
+ break;
+ }
+
+ return TizenSuccess();
+}
+
+common::TizenResult IotconUtils::OptionsToJson(iotcon_options_h options,
+ picojson::array* out) {
+ ScopeLogger();
+
+ auto result = ConvertIotconError(iotcon_options_foreach(options, [](unsigned short id, const char *data, void* user_data) -> bool {
+ if (data) {
+ picojson::value v{picojson::object{}};
+ auto& obj = v.get<picojson::object>();
+
+ obj.insert(std::make_pair(kOptionsId, picojson::value{static_cast<double>(id)}));
+ obj.insert(std::make_pair(kOptionsData, picojson::value{data}));
+
+ auto out = static_cast<picojson::array*>(user_data);
+ out->push_back(v);
+ }
+ // always continue with iteration
+ return true;
+ }, out));
+
+ if (!result) {
+ LogAndReturnTizenError(result, ("iotcon_options_foreach() failed"));
+ }
+
+ return TizenSuccess();
+}
+
+common::TizenResult IotconUtils::QueryToJson(iotcon_query_h query,
+ picojson::object* out) {
+ ScopeLogger();
+
+ {
+ // resourceType
+ char* resource_type = nullptr;
+ auto result = ConvertIotconError(iotcon_query_get_resource_type(query, &resource_type));
+ if (!result || !resource_type) {
+ LogAndReturnTizenError(result, ("iotcon_query_get_resource_type() failed"));
+ }
+ out->insert(std::make_pair(kResourceType, picojson::value{resource_type}));
+ }
+
+ {
+ // resourceInterface
+ iotcon_interface_e interface = IOTCON_INTERFACE_NONE;
+ auto result = ConvertIotconError(iotcon_query_get_interface(query, &interface));
+ if (!result) {
+ LogAndReturnTizenError(result, ("iotcon_query_get_interface() failed"));
+ }
+ out->insert(std::make_pair(kResourceInterface, picojson::value{FromInterface(interface)}));
+ }
+
+ {
+ // filter
+ picojson::value v{picojson::object{}};
+ auto result = ConvertIotconError(iotcon_query_foreach(query, [](const char* key, const char* value, void* user_data) -> bool {
+ if (key && value) {
+ auto obj = static_cast<picojson::object*>(user_data);
+ obj->insert(std::make_pair(key, picojson::value{value}));
+ }
+ // always continue with iteration
+ return true;
+ }, &v.get<picojson::object>()));
+ if (!result) {
+ LogAndReturnTizenError(result, ("iotcon_query_foreach() failed"));
+ }
+ out->insert(std::make_pair(kFilter, v));
+ }
+
+ return TizenSuccess();
+}
+
common::TizenResult IotconUtils::ConvertIotconError(int error) {
switch (error) {
case IOTCON_ERROR_NONE:
}
}
+#define X(v, s) case v: return s;
+#define XD(v, s) \
+ default: \
+ LoggerE("Unknown value: %d, returning default: %s", e, s); \
+ return s;
+
+std::string IotconUtils::FromConnectivityType(iotcon_connectivity_type_e e) {
+ ScopeLogger();
+
+ switch (e) {
+ IOTCON_CONNECTIVITY_TYPE_E
+ }
+}
+
+std::string IotconUtils::FromRequestType(iotcon_request_type_e e) {
+ ScopeLogger();
+
+ switch (e) {
+ IOTCON_REQUEST_TYPE_E
+ }
+}
+
+std::string IotconUtils::FromObserveType(iotcon_observe_type_e e) {
+ ScopeLogger();
+
+ switch (e) {
+ IOTCON_OBSERVE_TYPE_E
+ }
+}
+
+std::string IotconUtils::FromInterface(iotcon_interface_e e) {
+ ScopeLogger();
+
+ switch (e) {
+ IOTCON_INTERFACE_E
+ }
+}
+
+#undef X
+#undef XD
+
+#define X(v, s) if (e == s) return v;
+#define XD(v, s) \
+ LoggerE("Unknown value: %s, returning default: %d", e.c_str(), v); \
+ return v;
+
+iotcon_interface_e IotconUtils::ToInterface(const std::string& e) {
+ ScopeLogger();
+
+ IOTCON_INTERFACE_E
+}
+
+#undef X
+#undef XD
+
} // namespace iotcon
} // namespace extension