{
m_enrolleeSecState = EnrolleeSecState::ES_SEC_UNKNOWN;
m_remoteEnrolleeResource = remoteEnrolleeResource;
-
- //Initializing the provisioning client stack using the db path provided by the
- // application.
- // Note : If the path is NULL or empty, the PDM.db should be present in the same path.
- OCStackResult result = OCSecure::provisionInit(secDbPath);
-
- if (result != OC_STACK_OK)
- {
- throw ESPlatformException(result);
- }
}
ESResult EnrolleeSecurity::registerCallbackHandler(EnrolleeSecStatusCb enrolleeSecStatusCb,
return ES_ERROR;
}
- std::shared_ptr< OC::OCSecureResource > EnrolleeSecurity::findEnrollee(std::string host,
- DeviceList_t &list)
+ std::shared_ptr< OC::OCSecureResource > EnrolleeSecurity::getEnrollee(DeviceList_t &list)
{
for (unsigned int i = 0; i < list.size(); i++)
{
list[i]->getDeviceID().c_str());
OIC_LOG_V(DEBUG, ENROLEE_SECURITY_TAG, "From IP :%s", list[i]->getDevAddr().c_str());
- if (list[i]->getDevAddr() == host)
- {
- return list[i];
- }
+ //Always return the first element of the unOwned devices. This is considering that Mediator is
+ // always connected with only one Enrollee for which ownership transfer is being performed.
+ // Incase of multiple Enrollee devices connected to the Mediator via any OnBoarding method (SoftAp
+ // for example), the Enrollee devices will be provisioned in the first come first serve basis in the order
+ // returned by the security layer.
+ return list[i];
}
-
- return nullptr;
}
void EnrolleeSecurity::convertUUIDToString(OicUuid_t uuid, std::string& uuidString)
//Developer note : Always test the mediator and enrollee applications on different devices. Running
// Mediator and Enrollee in same device will result in returning the same device as already owned.
- result = OCSecure::discoverOwnedDevices(ES_SEC_DISCOVERY_TIMEOUT,
+ /*result = OCSecure::discoverOwnedDevices(ES_SEC_DISCOVERY_TIMEOUT,
pOwnedDevList);
if (result != OC_STACK_OK)
{
{
OIC_LOG_V(DEBUG, ENROLEE_SECURITY_TAG, "Found owned devices. Count =%d",
pOwnedDevList.size());
- std::shared_ptr< OC::OCSecureResource > ownedDevice =
- findEnrollee(
- std::string(
- m_remoteEnrolleeResource->m_wifiOnboardingconn.ipAddress),
- pOwnedDevList);
+ std::shared_ptr< OC::OCSecureResource > ownedDevice = getEnrollee(pOwnedDevList);
if (ownedDevice)
{
ownershipStatus = DEVICE_OWNED;
{
OIC_LOG(ERROR, ENROLEE_SECURITY_TAG, "No owned devices found.");
ownershipStatus = DEVICE_NOT_OWNED;
- }
+ }*/
result = OCSecure::discoverUnownedDevices(ES_SEC_DISCOVERY_TIMEOUT, pUnownedDevList);
if (result != OC_STACK_OK)
OIC_LOG_V(DEBUG, ENROLEE_SECURITY_TAG, "Found Unowned devices. Count =%d",
pUnownedDevList.size());
- m_unownedDevice =
- findEnrollee(
- m_remoteEnrolleeResource->m_wifiOnboardingconn.ipAddress,
- pUnownedDevList);
+ m_unownedDevice = getEnrollee(pUnownedDevList);
if (m_unownedDevice)
{
OTMCallbackData_t justWorksCBData;
{
OIC_LOG(ERROR, ENROLEE_SECURITY_TAG, "OwnershipTransferCallback is failed");
ownershipStatus = DEVICE_NOT_OWNED;
- //Throw exception
- throw ESPlatformException(result);
+ return ownershipStatus;
}
ownershipStatus = DEVICE_NOT_OWNED;
}
#include "EasySetup.h"
#include "OCPlatform.h"
#include "logger.h"
+#include "OCProvisioningManager.h"
+
#define ES_SAMPLE_APP_TAG "ES_SAMPLE_APP_TAG"
#define DECLARE_MENU(FUNC, ...) { #FUNC, FUNC }
{
OC::ServiceType::InProc, ModeType::Both, "0.0.0.0", 0, OC::QualityOfService::LowQos, &ps
};
+
OCPlatform::Configure(config);
+#ifdef __WITH_DTLS__
+ //Initializing the provisioning client stack using the db path provided by the application.
+ OCStackResult result = OCSecure::provisionInit("");
+
+ if (result != OC_STACK_OK)
+ {
+ return -1;
+ }
+#endif
+
g_currentRun = runEasySetupMenu;
while (true)