*
* @param callback will give the requested status
*
+ * @throws ESInvalidParameterException If callback is null.
* @throws ESBadRequestException If RemoteEnrollee device not created prior to this call.
*
* @see GetStatusCb
*
* @param callback will give the requested configuration
*
+ * @throws ESInvalidParameterException If callback is null.
* @throws ESBadRequestException If RemoteEnrollee device not created prior to this call.
*
* @see GetConfigurationStatusCb
*
* @param callback will give the result if the security provisioning succeeds or fails for some reasons
*
+ * @throws ESInvalidParameterException If callback is null.
* @throws ESBadRequestException If RemoteEnrollee device not created prior to this call.
*
* @see SecurityProvStatusCb
*
* @param callback will give the result if the security provisioning succeeds or fails for some reasons.
*
+ * @throws ESInvalidParameterException If callback is null.
* @throws ESBadRequestException If RemoteEnrollee device not created prior to this call.
*
* @see SecurityProvStatusCb
* @param devProp a data structure storing the above information to be delivered
* @param callback will give the result if the provisioning succeeds or fails
*
+ * @throws ESInvalidParameterException If callback is null.
* @throws ESBadRequestException If RemoteEnrollee device not created prior to this call.
*
* @see DeviceProp
* @param cloudProp a data structure storing the above information to be delivered
* @param callback will give the result if the provisioning succeeds or fails
*
+ * @throws ESInvalidParameterException If callback is null.
* @throws ESBadRequestException If RemoteEnrollee device not created prior to this call.
*
* @see CloudProp
void provisionCloudProperties(const CloudProp& cloudProp,
const CloudPropProvStatusCb callback);
+ /**
+ * Provision Cloud information to Enrollee, which includes Auth code, auth provider,
+ * Cloud interface server URL, and etc.
+ * Note that, this API is skipping finding Enrollee in a given network. Instead, an OCResource
+ * given as a first parameter will be considered to the Enrollee for cloud provisioning.
+ *
+ * @param resource an OCResource corresponding to a target Enrollee for cloud provisioning
+ * @param cloudProp a data structure storing the above information to be delivered
+ * @param callback will give the result if the provisioning succeeds or fails
+ *
+ * @throws ESInvalidParameterException If callback is null.
+ * @throws ESBadRequestException If RemoteEnrollee device not created prior to this call.
+ *
+ * @see CloudProp
+ * @see CloudPropProvStatusCb
+ */
+ void provisionCloudProperties(const std::shared_ptr< OC::OCResource > resource,
+ const CloudProp& cloudProp,
+ const CloudPropProvStatusCb callback);
+
private:
RemoteEnrollee(const std::shared_ptr< OC::OCResource > resource);
OIC_LOG_V (DEBUG, EASYSETUP_TAG, "HOST: %s", resource->host().c_str());
OIC_LOG_V (DEBUG, EASYSETUP_TAG, "URI: %s", resource->uri().c_str());
OIC_LOG_V (DEBUG, EASYSETUP_TAG, "SID: %s", resource->sid().c_str());
+ OIC_LOG_V (DEBUG, EASYSETUP_TAG, "CONNECTIVITY: %d", resource->connectivityType());
return std::shared_ptr< RemoteEnrollee > (new RemoteEnrollee(resource));
}
}
void RemoteEnrollee::provisionCloudProperties(const CloudProp& cloudProp,
const CloudPropProvStatusCb callback)
{
+ OIC_LOG(DEBUG, ES_REMOTE_ENROLLEE_TAG, "provisionCloudProperties w/o OCResource IN");
+
+ provisionCloudProperties(NULL, cloudProp, callback);
+
+ OIC_LOG(DEBUG, ES_REMOTE_ENROLLEE_TAG, "provisionCloudProperties w/o OCResource OUT");
+ }
+
+ void RemoteEnrollee::provisionCloudProperties(const std::shared_ptr< OC::OCResource > resource,
+ const CloudProp& cloudProp,
+ const CloudPropProvStatusCb callback)
+ {
OIC_LOG(DEBUG, ES_REMOTE_ENROLLEE_TAG, "provisionCloudProperties IN");
if(!callback)
throw ESBadRequestException ("Invalid Cloud Provisiong Info.");
}
- try
+ if(resource)
{
- initCloudResource();
+ if(resource->getResourceTypes().at(0) != OC_RSRVD_ES_RES_TYPE_PROV ||
+ resource->connectivityType() & CT_ADAPTER_TCP)
+ {
+ OIC_LOG (ERROR, ES_REMOTE_ENROLLEE_TAG, "Given resource is not valid due to wrong rt or conntype");
+ throw ESInvalidParameterException("A given OCResource is wrong");
+ }
+
+ auto interfaces = resource->getResourceInterfaces();
+ bool isFound = false;
+ for(auto interface : interfaces)
+ {
+ if(interface.compare(BATCH_INTERFACE) == 0)
+ {
+ OIC_LOG (DEBUG, ES_REMOTE_ENROLLEE_TAG, "RemoteEnrollee object is succeessfully created");
+ OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_TAG, "HOST: %s", resource->host().c_str());
+ OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_TAG, "URI: %s", resource->uri().c_str());
+ OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_TAG, "SID: %s", resource->sid().c_str());
+ OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_TAG, "CONNECTIVITY: %d", resource->connectivityType());
+ isFound = true;
+ }
+ }
+
+ if(!isFound)
+ {
+ throw ESInvalidParameterException("A given OCResource has no batch interface");
+ }
}
+ try
+ {
+ if(resource == NULL)
+ {
+ initCloudResource();
+ }
+ else
+ {
+ OIC_LOG(DEBUG, ES_REMOTE_ENROLLEE_TAG, "Skip to find a provisioning resource");
+ m_ocResource = resource;
+ m_cloudResource = std::make_shared<CloudResource>(m_ocResource);
+ }
+ }
catch (const std::exception& e)
{
OIC_LOG_V(ERROR, ES_REMOTE_ENROLLEE_TAG,