/// 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); }
/* * Class: org_iotivity_base_OcRepresentation * Method: setResourceTypeArray * Signature: ([Ljava/lang/String;)V */ JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setResourceTypeArray (JNIEnv *env, jobject thiz, jobjectArray jResourceTypeArray) { LOGD("OcRepresentation_setResourceTypeArray"); if (!jResourceTypeArray) { ThrowOcException(OC_STACK_INVALID_PARAM, "resourceTypeList cannot be null"); return; } OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); if (!rep) return; std::vector<std::string> resourceTypes; JniUtils::convertJavaStrArrToStrVector(env, jResourceTypeArray, resourceTypes); rep->setResourceTypes(resourceTypes); }