Esempio n. 1
0
/*
* Class:     org_iotivity_base_OcRepresentation
* Method:    getResourceInterfaces
* Signature: ()Ljava/util/List;
*/
JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcRepresentation_getResourceInterfaces
(JNIEnv *env, jobject thiz)
{
    LOGD("OcRepresentation_getResourceInterfaces");
    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
    if (!rep) return nullptr;

    std::vector<std::string> resourceInterfaces = rep->getResourceInterfaces();
    return JniUtils::convertStrVectorToJavaStrList(env, resourceInterfaces);
}
Esempio n. 2
0
void putClientRepresentation(std::shared_ptr<OCResource> resource, string &key, int value)
{
	if(resource)
	{
		OCRepresentation rep;
		std::cout << "Putting representation..."<<std::endl;
		rep.setValue(key, value);
		resource->put(rep, QueryParamsMap(), &onPut);
	}
}
Esempio n. 3
0
    /// Constructor
    LightResource()
        :m_name("John's light"), m_state(false), m_power(0), m_lightUri("/a/light"),
                m_resourceHandle(nullptr) {
        // Initialize representation
        m_lightRep.setUri(m_lightUri);

        m_lightRep.setValue("state", m_state);
        m_lightRep.setValue("power", m_power);
        m_lightRep.setValue("name", m_name);
    }
Esempio n. 4
0
        OCRepresentation get()
        {
            cout << "resource get\n";
            m_Rep.setValue("temperature", m_temp);
            m_Rep.setValue("humidity", m_humid);

            cout << "resource get : done\n";

            return m_Rep;
        }
Esempio 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 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);
            }
        }
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);
    }
}
Esempio n. 8
0
/*
* Class:     org_iotivity_base_OcRepresentation
* Method:    addChild
* Signature: (Lorg/iotivity/base/OcRepresentation;)V
*/
JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_addChild
(JNIEnv *env, jobject thiz, jobject jOcRepresentation)
{
    LOGD("OcRepresentation_addChild");
    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
    if (!rep) return;

    OCRepresentation *child = JniOcRepresentation::getOCRepresentationPtr(env, jOcRepresentation);
    if (!child) return;

    rep->addChild(*child);
}
Esempio n. 9
0
    // Note that resourceName, resource, and getId are all bound via the std::bind mechanism.
    // it is possible to attach ANY arbitrary data to do whatever you would like here.  It may,
    // however be a better fit to wrap each call in an object so a fuller context (and additional
    // requests) can be easily made inside of a simple context
    void getResponse(const std::string& resourceName, const HeaderOptions& headerOptions,
                const OCRepresentation rep, const int eCode, OCResource::Ptr resource, int getId)
    {
        std::cout << "Got a response from get from the " << resourceName << std::endl;
        std::cout << "Get ID is "<<getId<<" and resource URI is " << resource->uri() << std::endl;

        printHeaderOptions(headerOptions);

        std::cout << "The Attribute Data is: "<<std::endl;

        switch(getId)
        {
            case 0:
                {
                    // Get on device
                    std::string name;
                    rep.getValue("device_name", name);
                    std::cout << "Name of device: "<< name << std::endl;
                    break;
                }
            case 1:
                {
                    bool isOn = false;
                    rep.getValue("on",isOn);
                    std::cout<<"The fridge light is "<< ((isOn)?"":"not ") <<"on"<<std::endl;
                }
                break;
            case 2:
            case 3:
                {
                    bool isOpen = false;
                    std::string side;
                    rep.getValue("open", isOpen);
                    rep.getValue("side", side);
                    std::cout << "Door is "<<isOpen<<" and is on the "<<side<<std::endl;
                }
                break;
            case 4:
                {
                    // Get on random resource called.
                    std::string name;
                    rep.getValue("device_name", name);
                    std::cout << "Name of fridge: "<< name << std::endl;
                    break;
                }
        }
        ++m_callbackCount;

        if(m_callbackCount == m_callsMade)
        {
            m_cv.notify_all();
        }
    }
Esempio n. 10
0
/*
* Class:     org_iotivity_base_OcRepresentation
* Method:    getChildrenArray
* Signature: ()[Lorg/iotivity/base/OcRepresentation;
*/
JNIEXPORT jobjectArray JNICALL Java_org_iotivity_base_OcRepresentation_getChildrenArray
(JNIEnv *env, jobject thiz)
{
    LOGD("OcRepresentation_getChildrenArray");
    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
    if (!rep)
    {
        return nullptr;
    }

    return JniUtils::convertRepresentationVectorToJavaArray(env, rep->getChildren());
}
Esempio n. 11
0
/*
* Class:     org_iotivity_base_OcRepresentation
* Method:    clearChildren
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_clearChildren
(JNIEnv *env, jobject thiz)
{
    LOGD("OcRepresentation_clearChildren");
    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
    if (!rep)
    {
        return;
    }

    rep->clearChildren();
}
Esempio n. 12
0
/*
* Class:     org_iotivity_base_OcRepresentation
* Method:    isEmpty
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcRepresentation_isEmpty
(JNIEnv *env, jobject thiz)
{
    LOGD("OcRepresentation_isEmpty");
    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
    if (!rep)
    {
        return false;
    }

    return static_cast<jboolean>(rep->empty());
}
Esempio n. 13
0
/*
* Class:     org_iotivity_base_OcRepresentation
* Method:    size
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_iotivity_base_OcRepresentation_size
(JNIEnv *env, jobject thiz)
{
    LOGD("OcRepresentation_size");
    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
    if (!rep)
    {
        return -1;
    }

    return static_cast<jint>(rep->numberOfAttributes());
}
Esempio n. 14
0
void allBulbOff()
{
    OCRepresentation rep;

    rep.setValue("DoAction", std::string("AllBulbOff"));

    if (g_resource)
    {
        g_resource->post("a.collection", GROUP_INTERFACE, rep, QueryParamsMap(),
                &onPost);
    }
}
void onPut(const OCRepresentation& rep , const int eCode)
{
    if(eCode == SUCCESS_RESPONSE)
    {
        std::cout << "PUT request was successful" << std::endl;

        AttributeMap attributeMap = rep.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;
        }

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

        for(auto oit = children.begin() ; oit != children.end() ; ++oit)
        {
            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;
            }
        }

        if(OBSERVE_TYPE_TO_USE == ObserveType::Observe)
            std::cout << std::endl << "Observe is used." << std::endl << std::endl;
        else if(OBSERVE_TYPE_TO_USE == ObserveType::ObserveAll)
            std::cout << std::endl << "ObserveAll is used." << std::endl << std::endl;

        QueryParamsMap test;

        g_curResource->observe(ObserveType::Observe , test , &onObserve);

    }
    else
    {
        std::cout << "onPut Response error: " << eCode << std::endl;
        std::exit(-1);
    }
}
void WANIpConnection::setConnectionType(string newConnectionType)
{
    unique_lock<mutex> wanIpLock(m_mutex);
    OCRepresentation rep;
    rep.setValue("uri", m_resource->uri());
    rep.setValue("type", newConnectionType);
    m_setConnectionTypeInfoCB = bind(&WANIpConnection::onSetConnectionType, this, _1, _2, _3);
    m_resource->post(rep, QueryParamsMap(), m_setConnectionTypeInfoCB);
    if (m_cv.wait_for(wanIpLock, chrono::seconds(MAX_WAIT_TIME_FOR_BLOCKING_CALL)) == cv_status::timeout)
    {
        cerr << "Remote device failed to respond to the request." << endl;
    }
}
Esempio n. 17
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;
	}
}
Esempio n. 18
0
/*
* Class:     org_iotivity_base_OcRepresentation
* Method:    setUri
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setUri
(JNIEnv *env, jobject thiz, jstring jUri)
{
    LOGD("OcRepresentation_setUri");
    if (!jUri)
    {
        ThrowOcException(OC_STACK_INVALID_PARAM, "uri cannot be null");
        return;
    }
    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
    if (!rep) return;

    rep->setUri(env->GetStringUTFChars(jUri, nullptr));
}
        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;
            }
        }
Esempio n. 20
0
/*
* Class:     org_iotivity_base_OcRepresentation
* Method:    setValueDouble
* Signature: (Ljava/lang/String;D)V
*/
JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueDouble
(JNIEnv *env, jobject thiz, jstring jKey, jdouble jValue)
{
    LOGD("OcRepresentation_setValueDouble");
    if (!jKey)
    {
        ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");
        return;
    }
    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
    if (!rep) return;

    std::string str = env->GetStringUTFChars(jKey, nullptr);
    rep->setValue(str, static_cast<double>(jValue));
}
Esempio n. 21
0
void allBulbOn()
{
    OCRepresentation rep;

    rep.setValue("DoAction", std::string("AllBulbOn"));

    if (g_resource)
    {
        OCStackResult res = g_resource->post("a.collection", GROUP_INTERFACE,
            rep, QueryParamsMap(), &onPost);

        if( res != OC_STACK_OK )
            cout << "failed" << endl;
    }
}
Esempio n. 22
0
    void setFanRepresentation(OCRepresentation& rep)
    {
        bool tempState = false;
        int tempSpeed = 0;

        // If both entries exist
        if(rep.getValue("state", tempState) && rep.getValue("speed", tempSpeed))
        {
            m_fanState = tempState;
            m_fanSpeed = tempSpeed;

            cout << "\t\t\t\t" << "state: " << m_fanState << endl;
            cout << "\t\t\t\t" << "speed: " << m_fanSpeed << endl;
        }
    }
Esempio n. 23
0
/*
* Class:     org_iotivity_base_OcRepresentation
* Method:    isNull
* Signature: (Ljava/lang/String;)Z
*/
JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcRepresentation_isNull
(JNIEnv *env, jobject thiz, jstring jAttributeKey)
{
    LOGD("OcRepresentation_isNull");
    if (!jAttributeKey)
    {
        ThrowOcException(OC_STACK_INVALID_PARAM, "attributeKey cannot be null");
        return false;
    }
    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
    if (!rep) return false;

    std::string attributeKey = env->GetStringUTFChars(jAttributeKey, nullptr);
    return static_cast<jboolean>(rep->isNULL(attributeKey));
}
Esempio n. 24
0
void TemphumidResource::setResourceRepresentation(OCRepresentation &rep)
{
    int tempHumid = 0;
    int tempTemp = 0;

    rep.getValue("humidity", tempTemp);
    rep.getValue("temperature", tempHumid);

    m_humid = tempHumid;
    m_temp = tempTemp;

    cout << "\t\t\t" << "Received representation: " << endl;
    cout << "\t\t\t\t" << "temp: " << m_humid << endl;
    cout << "\t\t\t\t" << "humid: " << m_temp << endl;
}
Esempio n. 25
0
JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcRepresentation_hasAttribute
(JNIEnv *env, jobject thiz, jstring jstr)
{
    LOGD("OcRepresentation_hasAttribute");
    if (!jstr)
    {
        ThrowOcException(OC_STACK_INVALID_PARAM, "attributeKey cannot be null");
        return false;
    }
    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
    if (!rep) return false;

    std::string str = env->GetStringUTFChars(jstr, nullptr);
    return rep->hasAttribute(str);
}
Esempio n. 26
0
    void setLightRepresentation(OCRepresentation& rep)
    {
        bool tempState = false;
        int tempColor = 0;

        // If both entries exist
        if(rep.getValue("state", tempState) && rep.getValue("color", tempColor))
        {
            m_lightState = tempState;
            m_lightColor= tempColor;

            cout << "\t\t\t\t" << "state: " << m_lightState << endl;
            cout << "\t\t\t\t" << "color: " << m_lightColor << endl;
        }
    }
Esempio n. 27
0
void Resource::put(std::string data)
{
    QueryParamsMap params;
    OCRepresentation rep;
    rep.setValue(Config::m_key, data);

    static double lat = 52.165;
    static double lon = -2.21;
    lat += 0.01;
    lon += 0.01;

    rep.setValue("lat", lat);
    rep.setValue("lon", lon);
    m_resourceHandle->put(rep, params, m_PUTCallback);
}
void onPost(const HeaderOptions& /*headerOptions*/,
        const OCRepresentation& rep, const int eCode)
{
    try
    {
        if(eCode == OC_STACK_OK || eCode == OC_STACK_RESOURCE_CREATED)
        {
            std::cout << "POST request was successful" << std::endl;

            if(rep.hasAttribute("createduri"))
            {
                std::cout << "\tUri of the created resource: "
                    << rep.getValue<std::string>("createduri") << std::endl;
            }
            else
            {
                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;
            }

            OCRepresentation rep2;

            std::cout << "Posting light representation..."<<std::endl;

            mylight.m_state = true;
            mylight.m_power = 55;

            rep2.setValue("state", mylight.m_state);
            rep2.setValue("power", mylight.m_power);

            curResource->post(rep2, QueryParamsMap(), &onPost2);
        }
        else
        {
            std::cout << "onPost Response error: " << eCode << std::endl;
            std::exit(-1);
        }
    }
    catch(std::exception& e)
    {
        std::cout << "Exception: " << e.what() << " in onPost" << std::endl;
    }
}
Esempio n. 29
0
void onPost(const HeaderOptions& headerOptions, const OCRepresentation& rep,
        const int eCode)
{
    printf("\nonPost\n");

    if (rep.hasAttribute("ActionSet"))
    {
        std::string plainText;

        if (rep.getValue("ActionSet", plainText))
        {
            ActionSet *actionset = groupMgr->getActionSetfromString(plainText);
            if (actionset != NULL)
            {
                cout << endl << "\tACTIONSET NAME :: "
                        << actionset->actionsetName << endl;
                for (auto actIter = actionset->listOfAction.begin();
                        actIter != actionset->listOfAction.end(); ++actIter)
                {
                    cout << "\t\tTARGET :: " << (*actIter)->target << endl;

                    for (auto capaIter = (*actIter)->listOfCapability.begin();
                            capaIter != (*actIter)->listOfCapability.end();
                            ++capaIter)
                    {
                        cout << "\t\t\t" << (*capaIter)->capability << " :: "
                                << (*capaIter)->status << endl;
                    }
                }
            }
            delete actionset;
        }

        // printf( "\tPlain Text :: %s\n", plainText.c_str() );
    }
    else if (rep.hasAttribute("DoAction"))
    {
        std::string plainText;
        if (rep.getValue("DoAction", plainText))
        {
            cout << "\t" << plainText << endl;
        }
    }
    else
    {

    }
}
Esempio n. 30
0
OCStackResult GroupManager::cancelActionSet(std::shared_ptr< OCResource > resource,
        std::string actionsetName, PostCallback cb)
{
    if (resource != NULL)
    {
        OCRepresentation rep;

        rep.setValue("CancelAction", actionsetName);
        return resource->post(resource->getResourceTypes().front(), GROUP_INTERFACE, rep,
                QueryParamsMap(), cb);
    }
    else
    {
        return OC_STACK_ERROR;
    }
}