Ejemplo n.º 1
0
/* Callback Function to be called by the platform
   when response arrives from the BootStrap Server */
void onBootStrapCallback(const HeaderOptions &headerOptions, const OCRepresentation &rep,
                         const int eCode)
{
    dlog_print(DLOG_INFO, LOG_TAG, "#### onBootStrap entry");

    if (SUCCESS_RESPONSE != eCode)
    {
        dlog_print(DLOG_INFO, LOG_TAG, "#### onBootStrap -- onGET Response error: %d", eCode);
        return ;
    }

    dlog_print(DLOG_INFO, LOG_TAG, "#### onBootStrap -- GET request was successful");
    dlog_print(DLOG_INFO, LOG_TAG, "#### onBootStrap -- Resource URI: %s", rep.getUri().c_str());

    logMessage = "----------------------------<br>";
    logMessage += "GET request was successful<br>";
    logMessage += "URI : " + rep.getUri() + "<br>";

    defaultRegion = rep.getValue< std::string >("r");
    defaultSystemTime = rep.getValue< std::string >("st");
    defaultCurrency = rep.getValue< std::string >("c");
    defaultLocation = rep.getValue< std::string >("loc");

    logMessage += "Location : " + defaultLocation + "<br>";
    logMessage += "SystemTime : " + defaultSystemTime + "<br>";
    logMessage += "currency : " + defaultCurrency + "<br>";
    logMessage += "Region : " + defaultRegion + "<br>";

    dlog_print(DLOG_INFO, LOG_TAG, "  %s", logMessage.c_str());

    //Call updateLog in the thread safe mode
    ecore_main_loop_thread_safe_call_sync(updateLog, &logMessage);

}
Ejemplo n.º 2
0
        void RemoteEnrolleeResource::triggerNetworkConnectionCb(
                const HeaderOptions& /*headerOptions*/, const OCRepresentation& rep,
                const int eCode)
        {
            OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "checkProvInformationCb : %s, eCode = %d",
                    rep.getUri().c_str(),
                    eCode);

            if (eCode != 0)
            {
                OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG,
                        "triggerNetworkConnectionCb : Trigger action failed ");
                std::shared_ptr< ProvisioningStatus > provStatus = std::make_shared<
                        ProvisioningStatus >(ESResult::ES_ERROR, ESState::ES_PROVISIONING_ERROR);
                m_provStatusCb(provStatus);
                return;
            }
            else
            {
                OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG,
                        "triggerNetworkConnectionCb : Provisioning is success ");
                std::shared_ptr< ProvisioningStatus > provStatus = std::make_shared<
                        ProvisioningStatus >(ESResult::ES_OK, ESState::ES_PROVISIONING_SUCCESS);
                m_provStatusCb(provStatus);
                return;
            }
        }
Ejemplo n.º 3
0
// callback handler on GET request
void onBootstrap(const HeaderOptions& /*headerOptions*/, const OCRepresentation& rep, const int eCode)
{
    pthread_mutex_lock(&mutex_lock);
    isWaiting = 0;
    pthread_mutex_unlock(&mutex_lock);

    if (eCode != SUCCESS_RESPONSE)
    {
        std::cout << "onGET Response error: " << eCode << std::endl;
        return ;
    }

    std::cout << "\n\nGET request was successful" << std::endl;
    std::cout << "\tResource URI: " << rep.getUri() << std::endl;

    defaultDeviceName = rep.getValue< std::string >("n");
    defaultLocation = rep.getValue< std::string >("loc");
    defaultLocationName = rep.getValue< std::string >("locn");
    defaultRegion = rep.getValue< std::string >("r");
    defaultCurrency = rep.getValue< std::string >("c");

    std::cout << "\tDeviceName : " << defaultDeviceName << std::endl;
    std::cout << "\tLocation : " << defaultLocation << std::endl;
    std::cout << "\tLocationName : " << defaultLocationName << std::endl;
    std::cout << "\tCurrency : " << defaultCurrency << std::endl;
    std::cout << "\tRegion : " << defaultRegion << std::endl;

}
Ejemplo n.º 4
0
// Callback handler on GET request
void onGet(const HeaderOptions &headerOptions, const OCRepresentation &rep, const int eCode)
{
    (void)headerOptions;
    try
    {
        if (eCode == OC_STACK_OK)
        {
            std::cout << "GET request was successful" << std::endl;
            std::cout << "Resource URI: " << rep.getUri() << std::endl;

            std::cout << "Payload: " << rep.getPayload() << std::endl;

            rep.getValue("on-off", mylight.m_on_off);
            rep.getValue("dim", mylight.m_dim);
            rep.getValue("color", mylight.m_color);

            std::cout << "\ton-off: " << mylight.m_on_off << std::endl;
            std::cout << "\tcolor: " << mylight.m_color << std::endl;
            std::cout << "\tdim: " << mylight.m_dim << std::endl;

            putLightRepresentation(curResource);
        }
        else
        {
            std::cout << "onGET Response error: " << eCode << std::endl;
        }
    }
    catch (std::exception &e)
    {
        std::cout << "Exception: " << e.what() << " in onGet" << std::endl;
    }
}
Ejemplo n.º 5
0
/*
* Class:     org_iotivity_base_OcRepresentation
* Method:    getUri
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcRepresentation_getUri
(JNIEnv *env, jobject thiz)
{
    LOGD("OcRepresentation_getUri");
    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
    if (!rep) return nullptr;

    std::string uri(rep->getUri());
    return env->NewStringUTF(uri.c_str());
}
void onObserve(const HeaderOptions &headerOption , const OCRepresentation& rep , const int& eCode, const int& sequenceNumber)
{
	std::cout << "onObserve" << std::endl;
//    if(eCode == SUCCESS_RESPONSE)
	if(eCode <= OC_STACK_RESOURCE_DELETED)
    {

        AttributeMap attributeMap = rep.getAttributeMap();

        for(auto it = attributeMap.begin() ; it != attributeMap.end() ; ++it)
        {
            if(attributeMap.find(it->first) == attributeMap.end())
            {
                return;
            }
        }

        if(rep.getUri().empty())
        {
        	cout << "uri is null\n";
            return;
        }

        std::cout << std::endl;
        std::cout << "========================================================" << std::endl;
        std::cout << "Receive OBSERVE RESULT:" << std::endl;
        std::cout << "\tSequenceNumber: " << sequenceNumber << std::endl;
        for(auto it = attributeMap.begin() ; it != attributeMap.end() ; ++it)
        {
            std::cout << "\tAttribute name: " << it->first << " value: ";
            for(auto valueItr = it->second.begin() ; valueItr != it->second.end() ; ++valueItr)
            {
                std::cout << "\t" << *valueItr << " ";
            }

            std::cout << std::endl;
        }

        if(observe_count() > 30)
        {
            std::cout << "Cancelling Observe..." << std::endl;
            OCStackResult result = g_curResource->cancelObserve();

            std::cout << "Cancel result: " << result << std::endl;
            sleep(10);
            std::cout << "DONE" << std::endl;
            std::exit(0);
        }
    }
    else
    {
        std::cout << "onObserve Response error: " << eCode << std::endl;
        std::exit(-1);
    }
}
Ejemplo n.º 7
0
        void RemoteEnrolleeResource::getProvStatusResponse(const HeaderOptions& /*headerOptions*/,
                const OCRepresentation& rep, const int eCode)
        {
            OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "getProvStatusResponse : %s, eCode = %d",
                    rep.getUri().c_str(),
                    eCode);

            if (eCode != 0)
            {
                OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG,
                        "getProvStatusResponse : Provisioning is failed ");
                std::shared_ptr< ProvisioningStatus > provStatus = std::make_shared<
                        ProvisioningStatus >(ESResult::ES_ERROR, ESState::ES_PROVISIONING_ERROR);
                m_provStatusCb(provStatus);
                return;
            }

            int ps = -1;

            rep.getValue(OC_RSRVD_ES_PS, ps);

            OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "getProvStatusResponse : ps - %d",
                    ps);

            if (ps == ES_PS_NEED_PROVISIONING) //Indicates the need for provisioning
            {
                OCRepresentation provisioningRepresentation;

                provisioningRepresentation.setValue(OC_RSRVD_ES_TNN,
                std::string(m_ProvConfig.provData.WIFI.ssid));
                provisioningRepresentation.setValue(OC_RSRVD_ES_CD,
                std::string(m_ProvConfig.provData.WIFI.pwd));

                OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "getProvStatusResponse : ssid - %s",
                        m_ProvConfig.provData.WIFI.ssid);
                OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "getProvStatusResponse : pwd - %s",
                        m_ProvConfig.provData.WIFI.pwd);

                m_ocResource->post(provisioningRepresentation, QueryParamsMap(),
                        std::function<
                                void(const HeaderOptions& headerOptions,
                                        const OCRepresentation& rep, const int eCode) >(
                        std::bind(&RemoteEnrolleeResource::checkProvInformationCb, this,
                        std::placeholders::_1, std::placeholders::_2,
                        std::placeholders::_3)));
            }
            else if (ps == ES_PS_PROVISIONING_COMPLETED) //Indicates that provisioning is completed
            {
                OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG,
                        "getProvStatusResponse : Provisioning is successful");
                std::shared_ptr< ProvisioningStatus > provStatus = std::make_shared<
                        ProvisioningStatus >(ESResult::ES_OK, ESState::ES_PROVISIONED_ALREADY);
                m_provStatusCb(provStatus);
            }
        }
Ejemplo n.º 8
0
void onReboot(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode)
{
    pthread_mutex_lock(&mutex_lock);
    isWaiting = 0;
    pthread_mutex_unlock(&mutex_lock);

    if (eCode != SUCCESS_RESPONSE)
    {
        return ;
    }

    std::cout << "\tResource URI: " << rep.getUri() << std::endl;
    std::cout << "\t\tReboot:" << rep.getValue< std::string >("value") << std::endl;
}
Ejemplo n.º 9
0
void onGet(const HeaderOptions& /*headerOptions*/, const OCRepresentation& rep, const int eCode)
{
	try
	{
		if(eCode == OC_STACK_OK)
		{
			dlog_print(DLOG_INFO, LOG_TAG,  "GET request was successful %s", rep.getUri().c_str());
			std::cout << "Attributes : " << rep.numberOfAttributes() << std::endl;
			typedef std::map<std::string, int>::iterator it_type;
			for(it_type iterator = intprops.begin(); iterator != intprops.end(); iterator++) {
				std::cout << "Key  : " << iterator->first << " Value = "<<rep[iterator->first]<<std::endl;
				iterator->second = rep[iterator->first];
			}
			typedef std::map<std::string, double>::iterator itd_type;
			for(itd_type iterator = doubleprops.begin(); iterator != doubleprops.end(); iterator++) {
				std::cout << "Key  : " << iterator->first << " Value = "<<rep[iterator->first]<<std::endl;
				iterator->second = rep[iterator->first];
			}

			rvidata r;
			r.lt = rep["leftTemperature"];
			r.rt = rep["rightTemperature"];
			r.lhs = rep["leftSeatHeat"];
			r.rhs = rep["rightSeatHeat"];
			r.fs = rep["fanSpeed"];
			r.fd = rep["fanDown"];
			r.fr = rep["fanRight"];
			r.fu = rep["fanUp"];
			r.fac = rep["fanAC"];
			r.fa = rep["fanAuto"];
			r.fr = rep["fanRecirc"];
			r.dm = rep["defrostMax"];
			r.df = rep["defrostFront"];
			r.dr = rep["defrostRear"];

			send_message(&r);



		}
		else
		{
			dlog_print(DLOG_INFO, LOG_TAG,  "GET request was UNsuccessful");
		}
	}
	catch(std::exception& e)
	{
		std::cout << "Exception: " << e.what() << " in onPut" << std::endl;
	}
}
Ejemplo n.º 10
0
        void RemoteEnrolleeResource::checkProvInformationCb(const HeaderOptions& /*headerOptions*/,
                const OCRepresentation& rep, const int eCode)
        {
            OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "checkProvInformationCb : %s, eCode = %d",
                    rep.getUri().c_str(),
                    eCode);

            if (eCode != 0)
            {
                OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG,
                        "checkProvInformationCb : Provisioning is failed ");
                std::shared_ptr< ProvisioningStatus > provStatus = std::make_shared<
                        ProvisioningStatus >(ESResult::ES_ERROR, ESState::ES_PROVISIONING_ERROR);
                m_provStatusCb(provStatus);
                return;
            }

            int ps = -1;

            rep.getValue(OC_RSRVD_ES_PS, ps);

            OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "checkProvInformationCb : ps - %d", ps);

            //Provisioning status check
            if (ps == ES_PS_PROVISIONING_COMPLETED)
            {
                OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG,
                        "checkProvInformationCb : Provisioning is success. "
                        "Now trigger network connection ");

                #ifdef REMOTE_ARDUINO_ENROLEE
                 std::shared_ptr< ProvisioningStatus > provStatus = std::make_shared<
                        ProvisioningStatus >(ESResult::ES_OK, ESState::ES_PROVISIONING_SUCCESS);
                m_provStatusCb(provStatus);
                #endif

                triggerNetworkConnection();
                return;
            }
            else
            {
                OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG,
                        "checkProvInformationCb : Provisioning is failed ");
                std::shared_ptr< ProvisioningStatus > provStatus = std::make_shared<
                        ProvisioningStatus >(ESResult::ES_ERROR, ESState::ES_PROVISIONING_ERROR);
                m_provStatusCb(provStatus);
                return;
            }
        }
// callback handler on GET request
void onGet(const HeaderOptions &headerOption , const OCRepresentation& rep , const int eCode)
{
    if(eCode == SUCCESS_RESPONSE)
    {
        std::cout << "GET request was successful" << std::endl;

        AttributeMap attributeMap = rep.getAttributeMap();

        std::cout << "Resource URI: " << rep.getUri() << std::endl;

        for(auto it = attributeMap.begin() ; it != attributeMap.end() ; ++it)
        {
            std::cout << "\tAttribute name: " << it->first << " value: ";
            for(auto valueItr = it->second.begin() ; valueItr != it->second.end() ; ++valueItr)
            {
                std::cout << "\t" << *valueItr << " ";
            }

            std::cout << std::endl;
        }

        std::vector< OCRepresentation > children = rep.getChildren();

        for(auto oit = children.begin() ; oit != children.end() ; ++oit)
        {
            std::cout << "Child Resource URI: " << oit->getUri() << std::endl;

            attributeMap = oit->getAttributeMap();

            for(auto it = attributeMap.begin() ; it != attributeMap.end() ; ++it)
            {
                std::cout << "\tAttribute name: " << it->first << " value: ";
                for(auto valueItr = it->second.begin() ; valueItr != it->second.end() ; ++valueItr)
                {
                    std::cout << "\t" << *valueItr << " ";
                }

                std::cout << std::endl;
            }
        }
    }
    else
    {
        std::cout << "onGET Response error: " << eCode << std::endl;
        std::exit(-1);
    }
}
Ejemplo n.º 12
0
void GroupManager::onGetForPresence(const HeaderOptions& headerOptions,
        const OCRepresentation& rep, const int eCode, CollectionPresenceCallback callback)
{
    if (eCode == OC_STACK_OK)
    {
        std::cout << "GET request was successful" << std::endl;
        std::cout << "Resource URI: " << rep.getUri() << std::endl;

        checkCollectionRepresentation(rep, callback);

    }
    else
    {
        std::cout << "onGET Response error: " << eCode << std::endl;
        callback("", OC_STACK_ERROR);
    }
}
Ejemplo n.º 13
0
// Callback handler on GET request
void onGet(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode)
{
    if(eCode == SUCCESS_RESPONSE)
    {
        std::cout << "GET request was successful" << std::endl;
        std::cout << "Resource URI: " << rep.getUri() << std::endl;

        printRepresentation(rep);

        putLightRepresentation(curResource);
    }
    else
    {
        std::cout << "onGET Response error: " << eCode << std::endl;
        std::exit(-1);
    }
}
Ejemplo n.º 14
0
void SensorResource::onGet(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode)
{
	try {
		if(eCode == OC_STACK_OK) {
			std::cout << "Resource URI: " << rep.getUri() << std::endl;

			if (rep.hasAttribute("fanstate")) {
				std::string state = rep.getValue<std::string>("fanstate");
				m_fanState = (state == "on" ? true:false);
				std::cout << "\tfanstate: " << m_fanState << std::endl;
			}
		}
		else {
			std::cout << "onGET Response error: " << eCode << std::endl;
		}
	}
	catch(std::exception& e) {
		std::cout << "Exception: " << e.what() << " in onGet" << std::endl;
	}
}
Ejemplo n.º 15
0
void onLightGet(const HeaderOptions &headerOptions, const OCRepresentation &rep, const int eCode)
{
    if (eCode == OC_STACK_OK)
    {
        std::cout << "GET Light request was successful" << std::endl;
        std::cout << "Resource URI: " << rep.getUri() << std::endl;

        rep.getValue("state", mylight.m_state);
        rep.getValue("power", mylight.m_power);
        rep.getValue("name", mylight.m_name);

        std::cout << "\tstate: " << mylight.m_state << std::endl;
        std::cout << "\tpower: " << mylight.m_power << std::endl;
        std::cout << "\tname: " << mylight.m_name << std::endl;
    }
    else
    {
        std::cout << "onGET Response error: " << eCode << std::endl;
        std::exit(-1);
    }
}
Ejemplo n.º 16
0
void onGet(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode)
{
    pthread_mutex_lock(&mutex_lock);
    isWaiting = 0;
    pthread_mutex_unlock(&mutex_lock);

    if (eCode != SUCCESS_RESPONSE)
    {
        return ;
    }

    std::cout << "\tResource URI: " << rep.getUri() << std::endl;

    if (rep.hasAttribute("loc"))
        std::cout << "\t\tLocation:" << rep.getValue< std::string >("loc") << std::endl;
    if (rep.hasAttribute("st"))
        std::cout << "\t\tSystemTime:" << rep.getValue< std::string >("st") << std::endl;
    if (rep.hasAttribute("c"))
        std::cout << "\t\tCurrency:" << rep.getValue< std::string >("c") << std::endl;
    if (rep.hasAttribute("r"))
        std::cout << "\t\tRegion:" << rep.getValue< std::string >("r") << std::endl;
}
Ejemplo n.º 17
0
// Callback handler on GET request
void onGet(const HeaderOptions& /*headerOptions*/, const OCRepresentation& rep, const int eCode)
{
    if(eCode == SUCCESS_RESPONSE)
    {
        std::cout << "GET request was successful" << std::endl;
        std::cout << "Resource URI: " << rep.getUri() << std::endl;

        rep.getValue("state", mylight.m_state);
        rep.getValue("power", mylight.m_power);
        rep.getValue("name", mylight.m_name);

        std::cout << "\tstate: " << mylight.m_state << std::endl;
        std::cout << "\tpower: " << mylight.m_power << std::endl;
        std::cout << "\tname: " << mylight.m_name << std::endl;
        sleep(1);
        putLightRepresentation(curResource);
    }
    else
    {
        std::cout << "onGET Response error: " << eCode << std::endl;
        std::exit(-1);
    }
}
Ejemplo n.º 18
0
void GroupManager::checkCollectionRepresentation(const OCRepresentation& rep,
        CollectionPresenceCallback callback)
{
    std::cout << "\tResource URI: " << rep.getUri() << std::endl;

    std::vector< OCRepresentation > children = rep.getChildren();
    if(children.size() == 0 )
    {
        callback("", OC_STACK_ERROR);
        return;
    }

    for (auto oit = children.begin(); oit != children.end(); ++oit)
    {
        if(oit->getUri().find("coap://") == std::string::npos)
        {
            std::cout << "The resource with a URI " << oit->getUri() << " is not a remote resource."
                << " Thus, we ignore to send a request for presence check to the resource.\n";

            continue;
        }

        std::vector< std::string > hostAddressVector = str_split(oit->getUri(), '/');
        std::string hostAddress = "";
        for (unsigned int i = 0; i < hostAddressVector.size(); ++i)
        {
            if (i < 3)
            {
                hostAddress.append(hostAddressVector.at(i));
                if (i != 2)
                {
                    hostAddress.append("/");
                }
            }
        }

        std::vector< std::string > resourceTypes = oit->getResourceTypes();
        // for (unsigned int i = 0; i < resourceTypes.size(); ++i)
        // {
        //     std::cout << "\t\t\tresourcetype :" << resourceTypes.at(i) << std::endl;
        // }

        // std::string resourceType = "core.";
        // resourceType.append(str_split(oit->getUri(), '/').at(4));
        // std::cout << "\t\tconvertRT : " << resourceType << std::endl;
        // std::cout << "\t\tresource type front : " << resourceTypes.front() << endl;
        // std::cout << "\t\thost : " << hostAddress << std::endl;
        OCPlatform::OCPresenceHandle presenceHandle;
        OCStackResult result = OC_STACK_ERROR;

        try
        {
            result = OCPlatform::subscribePresence(presenceHandle, hostAddress,
                    // resourceType,
                    resourceTypes.front(),
                    OC_ETHERNET,
                    std::function<
                            void(OCStackResult result, const unsigned int nonce,
                                    const std::string& hostAddress) >(
                            std::bind(&GroupManager::collectionPresenceHandler, this,
                                    std::placeholders::_1, std::placeholders::_2,
                                    std::placeholders::_3, hostAddress, oit->getUri())));

            result = OCPlatform::subscribePresence(presenceHandle, hostAddress,
                    // resourceType,
                    resourceTypes.front(),
                    OC_WIFI,
                    std::function<
                            void(OCStackResult result, const unsigned int nonce,
                                    const std::string& hostAddress) >(
                            std::bind(&GroupManager::collectionPresenceHandler, this,
                                    std::placeholders::_1, std::placeholders::_2,
                                    std::placeholders::_3, hostAddress, oit->getUri())));
        }catch(OCException& e)
        {
            std::cout<< "Exception in subscribePresence: "<< e.what() << std::endl;
        }

        if (result == OC_STACK_OK)
        {
            presenceCallbacks.insert(std::make_pair(oit->getUri(), callback));
        }
        else
        {
            callback("", OC_STACK_ERROR);
        }
    }
}
Ejemplo n.º 19
0
    void ThingsMaintenance::onGetChildInfoForUpdate(const HeaderOptions& headerOptions,
            const OCRepresentation& rep, const int eCode, std::string mnt)
    {
        if (eCode != OC_STACK_OK)
        {
            std::cout << "onGet Response error: " << eCode << std::endl;
            getCallback(mnt)(headerOptions, rep, eCode);
            return ;
        }

        std::cout << "GET request was successful" << std::endl;

        std::cout << "\tResource URI: " << rep.getUri() << std::endl;

        std::vector < OCRepresentation > children = rep.getChildren();
        for (auto oit = children.begin(); oit != children.end(); ++oit)
        {
            std::cout << "\t\tChild Resource URI: " << oit->getUri() << std::endl;
        }

        // Get information by using maintenance name(mnt)
        std::shared_ptr < OCResource > resource = getResource(mnt);
        std::string actionstring = mnt;
        std::string uri = getUriByMaintenanceName(mnt);
        std::string attrKey = mnt;

        if (uri == "")
            return;

        if (resource)
        {
            // In this nest, we create a new action set of which name is the dignostics name.
            // Required information consists of a host address, URI, attribute key, and
            // attribute value.
            ActionSet *newActionSet = new ActionSet();
            newActionSet->actionsetName = mnt;

            for (auto oit = children.begin(); oit != children.end(); ++oit)
            {
                Action *newAction = new Action();

                // oit->getUri() includes a host address as well as URI.
                // We should split these to each other and only use the host address to create
                // a child resource's URI. Note that the collection resource and its child
                // resource are located in same host.
                newAction->target = getHostFromURI(oit->getUri()) + uri;

                Capability *newCapability = new Capability();
                newCapability->capability = attrKey;
                newCapability->status = getUpdateVal(mnt);

                newAction->listOfCapability.push_back(newCapability);
                newActionSet->listOfAction.push_back(newAction);
            }

            // Request to create a new action set by using the above actionSet
            g_groupmanager->addActionSet(resource, newActionSet,
                    std::function<
                            void(const HeaderOptions& headerOptions,
                                    const OCRepresentation& rep, const int eCode) >(
                            std::bind(&ThingsMaintenance::onCreateActionSet, this,
                                    std::placeholders::_1, std::placeholders::_2,
                                    std::placeholders::_3, mnt)));

            delete(newActionSet);

        }
    }