コード例 #1
0
ファイル: threadingsample.cpp プロジェクト: kartben/iotivity
 FooResource(std::string uri): m_isFoo(true), m_barCount (0),
                                 m_uri(uri), m_resourceType("core.foo")
 {
     m_rep.setUri(m_uri);
     m_rep.setValue("isFoo", m_isFoo);
     m_rep.setValue("barCount", m_barCount);
 }
コード例 #2
0
    OCRepresentation parseRDResponseCallback(OCClientResponse* clientResponse)
    {
        if (nullptr == clientResponse || nullptr == clientResponse->payload ||
                    PAYLOAD_TYPE_RD != clientResponse->payload->type)
        {
            return OCRepresentation();
        }

        MessageContainer oc;
        oc.setPayload(clientResponse->payload);

        std::vector<OCRepresentation>::const_iterator it = oc.representations().begin();
        if (it == oc.representations().end())
        {
            return OCRepresentation();
        }

        // first one is considered the root, everything else is considered a child of this one.
        OCRepresentation root = *it;
        root.setDevAddr(clientResponse->devAddr);
        root.setUri(clientResponse->resourceUri);
        ++it;

        std::for_each(it, oc.representations().end(),
                [&root](const OCRepresentation& repItr)
                {root.addChild(repItr);});
        return root;

    }
コード例 #3
0
ファイル: lightserver.cpp プロジェクト: EmuxEvans/iotivity
    /// Constructor
    LightResource()
        :m_power(""), m_lightUri("/a/light") {
        // Initialize representation
        m_lightRep.setUri(m_lightUri);

        m_lightRep.setValue("power", m_power);
    }
コード例 #4
0
ファイル: fanserver.cpp プロジェクト: santais/iotivity
    /// Constructor
    FanResource() :
        m_speed(10), m_fanUri("/a/fan"), m_resourceHandle(0)
    {
        // Initialize representation
        m_fanRep.setUri(m_fanUri);

        m_fanRep.setValue("speed", m_speed);
    }
コード例 #5
0
ファイル: fanserver.cpp プロジェクト: MCherifiOSS/iotivity
        /// Constructor
        FanResource(): m_name("John's fan"), m_state(false), m_power(0), m_fanUri("/a/fan")
        {
            // Initialize representation
            m_fanRep.setUri(m_fanUri);

            m_fanRep.setValue("state", m_state);
            m_fanRep.setValue("power", m_power);
            m_fanRep.setValue("name", m_name);
        }
コード例 #6
0
ファイル: simpleserver.cpp プロジェクト: Frank-KunLi/iotivity
    /// 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);
    }
コード例 #7
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));
}
コード例 #8
0
ファイル: roomserver.cpp プロジェクト: iotk/iochibity-cxx
    /// Constructor
    RoomResource(): m_roomName("John's Room"), m_roomHandle(nullptr), m_lightState(false),
                    m_lightColor(0),m_lightHandle(nullptr),  m_fanState(false), m_fanSpeed(0),
                    m_fanHandle(nullptr)
    {
        m_roomUri = "/a/room"; // URI of the resource
        m_roomTypes.push_back("core.room"); // resource type name. In this case, it is light
        m_roomInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.
        m_roomInterfaces.push_back(BATCH_INTERFACE); // resource interface.
        m_roomInterfaces.push_back(LINK_INTERFACE); // resource interface.
        m_roomRep.setValue("name", m_roomName);
        m_roomRep.setUri(m_roomUri);
        m_roomRep.setResourceTypes(m_roomTypes);
        m_roomRep.setResourceInterfaces(m_roomInterfaces);


        m_lightUri = "/a/light"; // URI of the resource
        m_lightTypes.push_back("core.light"); // resource type name. In this case, it is light
        m_lightInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.

        m_lightRep.setUri(m_lightUri);
        m_lightRep.setResourceTypes(m_lightTypes);
        m_lightRep.setResourceInterfaces(m_lightInterfaces);
        m_lightRep.setValue("state", m_lightState);
        m_lightRep.setValue("color", m_lightColor);

        m_fanUri = "/a/fan"; // URI of the resource
        m_fanTypes.push_back("core.fan"); // resource type name. In this case, it is light
        m_fanInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.

        m_fanRep.setUri(m_fanUri);
        m_fanRep.setResourceTypes(m_fanTypes);
        m_fanRep.setResourceInterfaces(m_fanInterfaces);
        m_fanRep.setValue("state", m_fanState);
        m_fanRep.setValue("speed", m_fanSpeed);

    }
コード例 #9
0
    OCRepresentation parseGetSetCallback(OCClientResponse* clientResponse)
    {
        if(clientResponse->payload == nullptr ||
                (
                    clientResponse->payload->type != PAYLOAD_TYPE_DEVICE &&
                    clientResponse->payload->type != PAYLOAD_TYPE_PLATFORM &&
                    clientResponse->payload->type != PAYLOAD_TYPE_REPRESENTATION
                )
          )
        {
            //OCPayloadDestroy(clientResponse->payload);
            return OCRepresentation();
        }

        MessageContainer oc;
        oc.setPayload(clientResponse->payload);
        //OCPayloadDestroy(clientResponse->payload);

        std::vector<OCRepresentation>::const_iterator it = oc.representations().begin();
        if(it == oc.representations().end())
        {
            return OCRepresentation();
        }

        // first one is considered the root, everything else is considered a child of this one.
        OCRepresentation root = *it;
        root.setDevAddr(clientResponse->devAddr);
        root.setUri(clientResponse->resourceUri);
        ++it;

        std::for_each(it, oc.representations().end(),
                [&root](const OCRepresentation& repItr)
                {root.addChild(repItr);});
        return root;

    }
コード例 #10
0
 FooResource(): m_isFoo(true), m_barCount (0)
 {
     m_rep.setUri("/q/foo");
     m_rep.setValue("isFoo", m_isFoo);
     m_rep.setValue("barCount", m_barCount);
 }