//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-#include "EasySetup.h"
+#include "EasySetup.hpp"
#include "OCPlatform.h"
#include "logger.h"
{
namespace Service
{
- #define EASYSETUP_TAG "EASY_SETUP"
+ #define EASYSETUP_TAG "ES_EASY_SETUP"
EasySetup * EasySetup::s_instance = nullptr;
EasySetup::EasySetup()
{
-
}
EasySetup* EasySetup::getInstance ()
std::shared_ptr<RemoteEnrollee> EasySetup::createRemoteEnrollee (std::shared_ptr< OC::OCResource > resource)
{
+ OIC_LOG(INFO, EASYSETUP_TAG, "createRemoteEnrollee IN");
+
if(resource)
{
- if(resource->getResourceTypes().at(0) != OC_RSRVD_ES_RES_TYPE_PROV)
+ if(resource->getResourceTypes().at(0) != OC_RSRVD_ES_RES_TYPE_EASYSETUP ||
+ resource->connectivityType() & CT_ADAPTER_TCP)
{
- OIC_LOG_V (DEBUG, EASYSETUP_TAG, "createRemoteEnrollee : invalid reousrce");
+ OIC_LOG (ERROR, EASYSETUP_TAG, "Given resource is not valid due to wrong rt or conntype");
return nullptr;
}
- return std::shared_ptr< RemoteEnrollee > (new RemoteEnrollee(resource));
+
+ auto interfaces = resource->getResourceInterfaces();
+ for(auto interface : interfaces)
+ {
+ if(interface.compare(BATCH_INTERFACE) == 0)
+ {
+ OIC_LOG (INFO, EASYSETUP_TAG, "RemoteEnrollee object is succeessfully created");
+ OIC_LOG_V (INFO_PRIVATE, EASYSETUP_TAG, "HOST: %s", resource->host().c_str());
+ OIC_LOG_V (INFO_PRIVATE, EASYSETUP_TAG, "URI: %s", resource->uri().c_str());
+ OIC_LOG_V (INFO_PRIVATE, EASYSETUP_TAG, "SID: %s", resource->sid().c_str());
+ OIC_LOG_V (INFO_PRIVATE, EASYSETUP_TAG, "CONNECTIVITY: %d", resource->connectivityType());
+ return std::shared_ptr< RemoteEnrollee > (new RemoteEnrollee(resource));
+ }
+ }
}
+
+ OIC_LOG (ERROR, EASYSETUP_TAG, "Given resource is NULL");
return nullptr;
}
}