<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/java"/>
- <classpathentry exported="true" kind="lib" path="E:/Projects/Mixed_backup/master_22_aug/android/android_api/base/build/intermediates/bundles/release/classes.jar"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="output" path="bin/classes"/>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>SampleServer</name>
+ <name>REClient</name>
<comment></comment>
<projects>
</projects>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
-
+
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="Discover Resource" />
-
-
+
<ListView
android:id="@+id/groupaApiList"
android:layout_width="match_parent"
- android:layout_height="300dp"
+ android:layout_height="300dp"
android:layout_below="@id/button1">
</ListView>
-
+
<EditText
android:id="@+id/EditText"
android:layout_width="fill_parent"
android:layout_alignParentLeft="true"
android:layout_below="@+id/groupaApiList"
android:layout_marginTop="15dp"
- android:ems="10"
+ android:ems="10"
android:editable="false" >
<requestFocus />
</EditText>
-
-
+
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<resources>
- <string name="app_name">RESampleClient</string>
+ <string name="app_name">REClient</string>
<string name="hello_world">Hello world!</string>
<string name="action_settings">Settings</string>
Vector<String> resourceInterfaces = foundResource.getInterFaces();
logMessage = "URI : " + resourceURI + "\n";
- logMessage = logMessage + "Host : " + hostAddress + "\n";
+ logMessage += "Host : " + hostAddress + "\n";
for (int i = 0; i < resourceTypes.size(); i++) {
- logMessage = logMessage + "resourceType : "
- + resourceTypes.get(i) + "\n";
+ logMessage += "resourceType : " + resourceTypes.get(i) + "\n";
}
for (int i = 0; i < resourceInterfaces.size(); i++) {
- logMessage = logMessage + "resourceInterfaces : "
+ logMessage += "resourceInterfaces : "
+ resourceInterfaces.get(i) + "\n";
}
- logMessage = logMessage + "isObservable : " + isObservableflag
- + "\n";
+ logMessage += "isObservable : " + isObservableflag + "\n";
ContainerClientActivity.this.runOnUiThread(new Runnable() {
public void run() {
apisList = new ArrayList<String>();
// adding the item to list that will be displayed on the UI.
- apisList.add("Resource Client API's");
+ apisList.add("Resource Client");
apisList.add("Discover Container Resource");
apis = new ArrayAdapter<String>(activityObj,
android.R.layout.simple_list_item_1, apisList);
import org.iotivity.ResourceEncapsulation.client.RCSAddress;
import org.iotivity.ResourceEncapsulation.client.RCSDiscoveryManager;
import org.iotivity.ResourceEncapsulation.client.RCSDiscoveryManager.IDiscoverResourceListener;
+import org.iotivity.ResourceEncapsulation.client.RCSRemoteResourceObject.IGetRemoteAttributeListener;
+import org.iotivity.ResourceEncapsulation.client.RCSRemoteResourceObject.ISetRemoteAttributeListener;
import org.iotivity.ResourceEncapsulation.client.RCSRemoteResourceObject.IStateChangedCallbackListener;
import org.iotivity.ResourceEncapsulation.client.RCSRemoteResourceObject.ICacheUpdateListener;
-import org.iotivity.ResourceEncapsulation.client.RCSRemoteResourceObject.IRemoteAttributeListener;
import org.iotivity.ResourceEncapsulation.client.RCSRemoteResourceObject.CacheState;
import org.iotivity.ResourceEncapsulation.client.RCSRemoteResourceObject.ResourceState;
import org.iotivity.ResourceEncapsulation.client.RCSRemoteResourceObject;
*/
public class ResourceClient {
- private static final String LOG_TAG = "[RESample] Client";
- private static Message msg;
- public String logMessage;
+ private static final String LOG_TAG = "[RESample] Client";
+ private static Message msg;
+ public String logMessage;
- private final RCSDiscoveryManager discoveyManagerObj;
- public RCSRemoteResourceObject remoteResourceObj;
+ private final RCSDiscoveryManager discoveyManagerObj;
+ public RCSRemoteResourceObject remoteResourceObj;
- private static ResourceClientActivity resourcClientActivityObj = null;
- private final DiscoverResourceListener discoverResourceListener;
- private final StateChangedListener stateChangedListener;
- private final CacheUpdateListener cacheUpdateListener;
- private final RemoteAttributeListener remoteAttributeListener;
- static boolean monitoringState = false;
- static boolean cachingState = false;
+ private static ResourceClientActivity resourcClientActivityObj = null;
+ private final DiscoverResourceListener discoverResourceListener;
+ private final StateChangedListener stateChangedListener;
+ private final CacheUpdateListener cacheUpdateListener;
+ private final RemoteAttributeGetListener remoteAttributeGetListener;
+ private final RemoteAttributeSetListener remoteAttributeSetListener;
+ static boolean monitoringState = false;
+ static boolean cachingState = false;
// constructor
public ResourceClient() {
discoverResourceListener = new DiscoverResourceListener();
stateChangedListener = new StateChangedListener();
cacheUpdateListener = new CacheUpdateListener();
- remoteAttributeListener = new RemoteAttributeListener();
+ remoteAttributeGetListener = new RemoteAttributeGetListener();
+ remoteAttributeSetListener = new RemoteAttributeSetListener();
discoveyManagerObj
.setDiscoverResourceListener(discoverResourceListener);
Vector<String> resourceTypes = foundResource.getTypes();
Vector<String> resourceInterfaces = foundResource.getInterFaces();
remoteResourceObj = foundResource;
+ cachingState = false;
+ monitoringState = false;
msg = Message.obtain();
msg.what = 0;
resourcClientActivityObj.getHandler().sendMessage(msg);
logMessage = "URI : " + resourceURI + "\n";
- logMessage = logMessage + "Host : " + hostAddress + "\n";
+ logMessage += "Host : " + hostAddress + "\n";
for (int i = 0; i < resourceTypes.size(); i++) {
- logMessage = logMessage + "resourceType : "
- + resourceTypes.get(i) + "\n";
+ logMessage += "resourceType : " + resourceTypes.get(i) + "\n";
}
for (int i = 0; i < resourceInterfaces.size(); i++) {
- logMessage = logMessage + "resourceInterfaces : "
+ logMessage += "resourceInterfaces : "
+ resourceInterfaces.get(i) + "\n";
}
- logMessage = logMessage + "isObservable : " + isObservableflag
- + "\n";
+ logMessage += "isObservable : " + isObservableflag + "\n";
ResourceClientActivity.setMessageLog(logMessage);
msg = Message.obtain();
case LOST_SIGNAL:
Log.i(LOG_TAG, "Current Resource State : LOST_SIGNAL");
logMessage = "Current Resource State : LOST_SIGNAL\n";
- logMessage = logMessage
- + "Start the server and press discover resource button"
+ logMessage += "Start the server and press discover resource button"
+ "\n";
break;
msg.what = 1;
resourcClientActivityObj.getHandler().sendMessage(msg);
}
-
}
/**
/**
* Listener for receiving the resource attributes as a result of
- * getRemoteAttributes() and setRemoteAttributes() API
+ * getRemoteAttributes() API
*/
- private class RemoteAttributeListener implements IRemoteAttributeListener {
+ private class RemoteAttributeGetListener implements
+ IGetRemoteAttributeListener {
@Override
public void onRemoteAttributesGetCallback(
RCSResourceAttributes attributes) {
}
};
+ /**
+ * Listener for receiving the resource attributes as a result of
+ * setRemoteAttributes() API
+ */
+ private class RemoteAttributeSetListener implements
+ ISetRemoteAttributeListener {
+ @Override
+ public void onRemoteAttributesSetCallback(
+ RCSResourceAttributes attributes) {
+
+ Log.i(LOG_TAG, "onRemoteAttributesSetCallback invoked");
+ printAttributes(attributes);
+ }
+ };
+
// Discover Resource
public void disocverResources() {
Log.d(LOG_TAG, "discover resources entry");
try {
remoteResourceObj
- .setRemoteAttributesListener(remoteAttributeListener);
+ .setGetRemoteAttributesListener(remoteAttributeGetListener);
- if (null != remoteAttributeListener) {
+ if (null != remoteAttributeGetListener) {
remoteResourceObj.getRemoteAttributes();
}
} catch (Exception e) {
try {
remoteResourceObj
- .setRemoteAttributesListener(remoteAttributeListener);
+ .setSetRemoteAttributesListener(remoteAttributeSetListener);
- if (null != remoteAttributeListener) {
+ if (null != remoteAttributeSetListener) {
RCSResourceAttributes attr = new RCSResourceAttributes();
attr.setValueInt("Temperature", value);
remoteResourceObj.setRemoteAttributes(attr);
return;
}
logMessage = "Key : " + key + "\n";
- logMessage = logMessage + "Value : " + attribute + "\n";
+ logMessage += "Value : " + attribute + "\n";
ResourceClientActivity.setMessageLog(logMessage);
msg = Message.obtain();
msg.what = 1;
EditText temperatureValue = (EditText) dialog
.findViewById(R.id.attributeValue);
String value = temperatureValue.getText().toString();
- if (value.equalsIgnoreCase("")) {
- String toastmessage = "Please enter the Temperature Value";
- displayToastMessage(toastmessage);
- } else {
+
+ try {
+ int intValue = Integer.parseInt(value);
+ resourceClientObj.setRemoteAttributes(intValue);
dialog.dismiss();
- int val = Integer.parseInt(value);
- resourceClientObj.setRemoteAttributes(val);
+
+ } catch (NumberFormatException e) {
+ String toastmessage = "Please enter the Integer Value";
+ displayToastMessage(toastmessage);
}
}
});
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
- <classpathentry exported="true" kind="lib" path="E:/Projects/Mixed_backup/master_22_aug/android/android_api/base/build/intermediates/bundles/release/classes.jar"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="output" path="bin/classes"/>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>SampleResourceClientApp</name>
+ <name>REServer</name>
<comment></comment>
<projects>
</projects>
<application
android:allowBackup="true"
- android:icon="@drawable/ic_launcher"
+ android:icon="@drawable/iot"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<container>
+<container>
<bundle>
<id>oic.bundle.discomfortIndexSensor</id>
<path>data/data/com.example.sampleresourceserver/files/libSoftSensorBundle.so</path>
<resources>
<resourceInfo>
<name>DiscomfortIndexSensor1</name>
- <resourceType>oic.softsensor</resourceType>
+ <resourceType>oic.softsensor</resourceType>
<outputs>
<output>
<name>discomfortIndex</name>
<name>humidity</name>
<type>double</type>
</input>
- <input>
+ <input>
<name>temperature</name>
<type>double</type>
</input>
</inputs>
- </resourceInfo>
+ </resourceInfo>
</resources>
</bundle>
</container>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
-
+
<Button
android:id="@+id/startContainer"
android:layout_width="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="Start Container" />
-
-
+
<ListView
android:id="@+id/containerApiList"
android:layout_width="match_parent"
- android:layout_height="300dp"
+ android:layout_height="300dp"
android:layout_below="@id/startContainer">
</ListView>
-
+
<EditText
android:id="@+id/log"
android:layout_width="fill_parent"
android:layout_alignParentLeft="true"
android:layout_below="@+id/containerApiList"
android:layout_marginTop="15dp"
- android:ems="10"
+ android:ems="10"
android:editable="false" >
<requestFocus />
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="Stop Container" />
-
+
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<resources>
- <string name="app_name">SampleResourceServer</string>
+ <string name="app_name">REServer</string>
<string name="hello_world">Hello world!</string>
<string name="action_settings">Settings</string>
apisList = new ArrayList<String>();
// adding the item to list that will be displayed on the UI.
- apisList.add("Server Builder APIs");
- apisList.add("Resource Container APIs");
+ apisList.add("Server Builder");
+ apisList.add("Resource Container");
apis = new ArrayAdapter<String>(activityObj,
android.R.layout.simple_list_item_1, apisList);
list.setAdapter(apis);
import org.iotivity.ResourceEncapsulation.server.RCSBundleInfo;
import org.iotivity.ResourceEncapsulation.server.RCSResourceContainer;
+import android.content.Context;
import android.os.Message;
/**
}
// Start Container
- public void startContainer() {
+ public void startContainer(String sdCardPath) {
startBundleFlag = true;
- String configFile = "/data/data/"
- + resourceContainerActivityInstance.getPackageName()
- + "/files/ResourceContainerConfig.xml";
+ String configFile = sdCardPath + "/ResourceContainerConfig.xml";
+
if (!isStarted) {
for (int i = 0; i < 2; i++) {
containerInstance.startContainer(configFile);
List<String> bundleResources = containerInstance
.listBundleResources("oic.bundle.discomfortIndexSensor");
- Iterator it = bundleResources.iterator();
+ Iterator<String> it = bundleResources.iterator();
logMessage = "";
if (0 == bundleResources.size()) {
public void listBundles() {
List<RCSBundleInfo> bundleList = containerInstance.listBundles();
- Iterator it = bundleList.iterator();
+ Iterator<RCSBundleInfo> it = bundleList.iterator();
logMessage = "";
logMessage = logMessage + "size of bundleList : " + bundleList.size()
+ "\n";
private Button startContainer;
private Button stopContainer;
private static EditText logs;
+ private static String sdCardPath;
@Override
protected void onCreate(Bundle savedInstanceState) {
stopContainer.setEnabled(false);
logs = (EditText) findViewById(R.id.log);
+ sdCardPath = this.getFilesDir().getPath();
// adding the item to list that will be displayed on the UI.
containerApiList.add("1. List Bundles");
containerApiList.add("2. List bundle resources");
@Override
public void onClick(View v) {
- resourceContainerInstance.startContainer();
+ resourceContainerInstance.startContainer(sdCardPath);
startContainer.setEnabled(false);
stopContainer.setEnabled(true);
try {
rcsResourceObject = builderObject.build();
+ rcsResourceObject
+ .setSetRequestHandlerPolicy(SetRequestHandlerPolicy.ACCEPTANCE);
} catch (RCSException e) {
e.printStackTrace();
}
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
-OIC_SRC_DIR := ../../../../..
+OIC_SRC_DIR := ../../../..
LOCAL_MODULE := re-jni
LOCAL_C_INCLUDES := $(LOCAL_PATH)/jniutil/inc \
{
switch (result)
{
- case 1:
+ case 0:
return OCEntityHandlerResult::OC_EH_OK;
- case 2:
+ case 1:
return OCEntityHandlerResult::OC_EH_ERROR;
- case 3:
+ case 2:
return OCEntityHandlerResult::OC_EH_RESOURCE_CREATED;
- case 4:
+ case 3:
return OCEntityHandlerResult::OC_EH_RESOURCE_DELETED;
- case 5:
+ case 4:
return OCEntityHandlerResult::OC_EH_SLOW;
- case 6:
+ case 5:
return OCEntityHandlerResult::OC_EH_FORBIDDEN;
- case 7:
+ case 6:
return OCEntityHandlerResult::OC_EH_RESOURCE_NOT_FOUND;
}
return OCEntityHandlerResult::OC_EH_ERROR;
{
switch (policy)
{
- case 1:
+ case 0:
return RCSResourceObject::AutoNotifyPolicy::NEVER;
- case 2:
+ case 1:
return RCSResourceObject::AutoNotifyPolicy::ALWAYS;
- case 3:
+ case 2:
return RCSResourceObject::AutoNotifyPolicy::UPDATED;
}
}
{
switch (policy)
{
- case 1:
+ case 0:
return RCSResourceObject::SetRequestHandlerPolicy::NEVER;
- case 2:
+ case 1:
return RCSResourceObject::SetRequestHandlerPolicy::ACCEPTANCE;
}
}
{
onResFoundListener->discoverResourceCallback(resource);
};
- if ( 0 == jTypeofDiscovery )
+ if ( 1 == jTypeofDiscovery )
{
RCSDiscoveryManager::getInstance()->discoverResourceByType(RCSAddress::multicast(), relativeUri,
resourceType, discoverCallback);
LOGI("NativeInterface_discoverResource multicast");
}
- else if ( 1 == jTypeofDiscovery)
+ else if ( 0 == jTypeofDiscovery)
{
RCSDiscoveryManager::getInstance()->discoverResourceByType(RCSAddress::unicast(address),
relativeUri, resourceType, discoverCallback );
(JNIEnv *env, jobject interfaceClass, jobject jResourceAttributesListener)
{
LOGD("RCSRemoteResourceObject_nativeGetRemoteAttributes");
+ if (!jResourceAttributesListener)
+ {
+ LOGE("RCSRemoteResourceObject_nativeGetRemoteAttributes: listener is NULL");
+ throwRCSException(env, "Invalid parameter");
+ return;
+ }
JniRCSRemoteResourceObject *resource = JniRCSRemoteResourceObject::getJniRCSRemoteResourceObject(
env, interfaceClass);
if (!resource) return;
jobject jResourceAttributesListener)
{
LOGD("RCSRemoteResourceObject_nativeSetRemoteAttributes");
+ if (!jResourceAttributesListener)
+ {
+ LOGE("RCSRemoteResourceObject_nativeSetRemoteAttributes: listener is NULL");
+ throwRCSException(env, "Invalid parameter");
+ return;
+ }
JniRCSRemoteResourceObject *resource = JniRCSRemoteResourceObject::getJniRCSRemoteResourceObject(
env, interfaceClass);
if (!resource) return;
return;
}
- jmethodID midL = env->GetMethodID(clsL, "onRemoteAttributesGetCallback",
+ jmethodID midL = env->GetMethodID(clsL, "onRemoteAttributesSetCallback",
"(Lorg/iotivity/ResourceEncapsulation/common/RCSResourceAttributes;)V");
if (!midL)
*
******************************************************************/
/**
- * @file RCSAddress.java
- *
- * @brief This file provides a class for a set of APIs relating to resource address and the
- * the type of discovery request for a resource of interest.
- *
+ * @file
+ * This file provides a class for a set of APIs relating to resource address and the
+ * the type of discovery request for a resource of interest.
*/
package org.iotivity.ResourceEncapsulation.client;
*
******************************************************************/
/**
- * @file RCSDiscoveryManager.java
- *
- * @brief This file provides a class for a set of APIs relating to discovery of a particular
- * resource in the network
- *
+ * @file
+ * This file provides a class for a set of APIs relating to discovery of a particular
+ * resource in the network
*/
package org.iotivity.ResourceEncapsulation.client;
* @param address
* A RCSAddress object
*
- * {@link RCSAddress}
- *
+ * @throws RCSException
+ * {@link RCSAddress}
*/
public void discoverResource(RCSAddress address) throws RCSException {
* @param relativeURI
* The relative uri of resource to be searched
*
- * {@link RCSAddress}
- *
+ * @throws RCSException
+ * {@link RCSAddress}
*/
public void discoverResource(RCSAddress address, String relativeURI)
throws RCSException {
* @param resourceType
* Ressource Type
*
- * {@link RCSAddress}
- *
+ * @throws RCSException
+ * {@link RCSAddress}
*/
public void discoverResourceByType(RCSAddress address, String resourceType)
throws RCSException {
* @param resourceType
* Ressource Type
*
- * {@link RCSAddress}
- *
+ * @throws RCSException
+ * {@link RCSAddress}
*/
public void discoverResourceByType(RCSAddress address, String relativeURI,
String resourceType) throws RCSException {
this.discoverResource(addr, typeOfDiscovery.ordinal(), relativeURI,
resourceType, m_discoverListener);
}
-
}
*
******************************************************************/
/**
- * @file RCSRemoteResourceObject.java
- *
- * @brief This file provides a class which provides a set of native functions and API's
- * of resource client, provided to the developers.
+ * @file
+ * This file provides a class which provides a set of native functions and API's
+ * of resource client, provided to the developers.
*/
package org.iotivity.ResourceEncapsulation.client;
* API.
*
* {@link RCSDiscoveryManager}
- *
*/
public class RCSRemoteResourceObject {
private IStateChangedCallbackListener m_stateChangedListener;
private ICacheUpdateListener m_cacheUpdateListener;
- private IRemoteAttributeListener m_remoteAttributeListener;
+ private IGetRemoteAttributeListener m_getremoteAttributeListener;
+ private ISetRemoteAttributeListener m_setremoteAttributeListener;
private long m_nativeHandle;
private String LOG_TAG = this.getClass()
.getSimpleName();
private native String nativeGetCachedAttribute(String key);
private native void nativeGetRemoteAttributes(
- IRemoteAttributeListener listener);
+ IGetRemoteAttributeListener listener);
private native void nativeSetRemoteAttributes(
- RCSResourceAttributes attributes, IRemoteAttributeListener listener);
+ RCSResourceAttributes attributes,
+ ISetRemoteAttributeListener listener);
private native String nativeGetUri();
*/
public enum ResourceState {
- NONE, /** < Monitoring is not started. */
- REQUESTED, /**
- * < Monitoring is started and checking state is in progress.
- * This is the default state after startMonitoring.
- */
- ALIVE, /** < The resource is alive. */
- LOST_SIGNAL, /** < Failed to reach the resource. */
+ NONE, /* < Monitoring is not started. */
+ REQUESTED, /*
+ * < Monitoring is started and checking state is in progress.
+ * This is the default state after startMonitoring.
+ */
+ ALIVE, /* < The resource is alive. */
+ LOST_SIGNAL, /* < Failed to reach the resource. */
DESTROYED;
- /** < The resource is deleted. */
+ /* < The resource is deleted. */
- /**
+ /*
* Utility API for integer to enum conversion.
*/
public static ResourceState getResourceState(int ordinal) {
return ResourceState.values()[2];
else if (ordinal == 3)
return ResourceState.values()[3];
+ else if (ordinal == 4)
+ return ResourceState.values()[4];
return null;
}
*/
public enum CacheState {
- NONE, /** < Caching is not started. */
- UNREADY, /**
- * < Caching is started, but the data is not ready yet. This is
- * the default state after startCaching.
- */
- READY, /** < The data is ready. */
+ NONE, /* < Caching is not started. */
+ UNREADY, /*
+ * < Caching is started, but the data is not ready yet. This is
+ * the default state after startCaching.
+ */
+ READY, /* < The data is ready. */
LOST_SIGNAL;
- /** < Failed to reach the resource. */
+ /* < Failed to reach the resource. */
- /**
+ /*
* Utility API for int to enum conversion.
*/
public static CacheState getCacheState(int ordinal) {
- CacheState result = CacheState.values()[0];
-
- if (ordinal == 1)
- result = CacheState.values()[1];
+ if (ordinal == 0)
+ return CacheState.values()[0];
+ else if (ordinal == 1)
+ return CacheState.values()[1];
else if (ordinal == 2)
- result = CacheState.values()[2];
+ return CacheState.values()[2];
else if (ordinal == 3)
- result = CacheState.values()[3];
+ return CacheState.values()[3];
- return result;
+ return null;
}
}
/**
* Provides interface for receiving the callback for the getRemoteAttributes
- * and setRemoteAttributes requested actions.
+ * requested action.
*/
- public interface IRemoteAttributeListener {
+ public interface IGetRemoteAttributeListener {
/**
* This callback method is called when a asynchronous response for the
- * getRemoteAttributes request or setRemoteAttributes request is
- * received.
+ * getRemoteAttributes request is received.
*
* @param attributes
* It is the updated resource attributes value received from
}
/**
+ * Provides interface for receiving the callback for the setRemoteAttributes
+ * requested action.
+ */
+ public interface ISetRemoteAttributeListener {
+
+ /**
+ * This callback method is called when a asynchronous response for the
+ * setRemoteAttributes request is received.
+ *
+ * @param attributes
+ * It is the updated resource attributes value received from
+ * the remote resource.
+ *
+ * {@link RCSResourceAttributes}
+ */
+ public void onRemoteAttributesSetCallback(
+ RCSResourceAttributes attributes);
+
+ }
+
+ /**
* Provides interface for receiving the callback for the startMonitoring
* This callback is received on remote resource state change.
*/
/**
* Set listener for receiving asynchronous response for resource attributes
- * SET and GET request.
+ * GET request.
*
* @param listener
- * IRemoteAttributeListener to receive asynchronous response for
- * resource attributes SET and GET request.
+ * IGetRemoteAttributeListener to receive asynchronous response
+ * for resource attributes SET and GET request.
*/
- public void setRemoteAttributesListener(IRemoteAttributeListener listener) {
- m_remoteAttributeListener = listener;
+ public void setGetRemoteAttributesListener(
+ IGetRemoteAttributeListener listener) {
+ m_getremoteAttributeListener = listener;
+ }
+
+ /**
+ * Set listener for receiving asynchronous response for resource attributes
+ * SET request.
+ *
+ * @param listener
+ * IGetRemoteAttributeListener to receive asynchronous response
+ * for resource attributes SET and GET request.
+ */
+ public void setSetRemoteAttributesListener(
+ ISetRemoteAttributeListener listener) {
+ m_setremoteAttributeListener = listener;
}
/**
*
* {@link IStateChangedCallbackListener} {@link ResourceState}
* {@link #isMonitoring()} {@link #stopMonitoring()}
- *
*/
public void startMonitoring() throws RCSException {
*
* {@link RCSResourceAttributes} {@link #isCachedAvailable()}
* {@link #startCaching()}
- *
*/
public RCSResourceAttributes getCachedAttributes() throws RCSException {
*
* {@link RCSResourceAttributes} {@link #isCachedAvailable()}
* {@link #startCaching()}
- *
*/
public String getCachedAttribute(String key) throws RCSException {
* attributes to the caller in the RemoteAttributesReceivedCallback.
*
* <p>
- * IRemoteAttributeListener should be set to get the attributes
+ * IGetRemoteAttributeListener should be set to get the attributes
*
- * {@link IRemoteAttributeListener}
+ * @throws RCSException
+ * {@link IGetRemoteAttributeListener}
*/
public void getRemoteAttributes() throws RCSException {
Log.i(LOG_TAG, "getRemoteAttributes called");
- this.nativeGetRemoteAttributes(m_remoteAttributeListener);
+ this.nativeGetRemoteAttributes(m_getremoteAttributeListener);
}
/**
* Attribute value to set for the remote resource.
*
* <p>
- * IRemoteAttributeListener should be set to call this API
+ * ISetRemoteAttributeListener should be set to call this API
*
- * {@link IRemoteAttributeListener}
+ * @throws RCSException
+ * {@link ISetRemoteAttributeListener}
*/
public void setRemoteAttributes(RCSResourceAttributes attributes)
throws RCSException {
Log.i(LOG_TAG, "getRemoteAttributes called");
- this.nativeSetRemoteAttributes(attributes, m_remoteAttributeListener);
+ this.nativeSetRemoteAttributes(attributes, m_setremoteAttributeListener);
}
/**
*
******************************************************************/
/**
- * @file RCSException.java
- *
- * @brief This file provides RCSException class for RE layer
- *
+ * @file
+ *This file provides RCSException class for RE layer
*/
package org.iotivity.ResourceEncapsulation.common;
*
******************************************************************/
/**
- * @file RCSResourceAttributes.java
- *
- * @brief This file provides a class which represents the attributes for a resource.
+ * @file
+ * This file provides a class which represents the attributes for a resource.
*/
package org.iotivity.ResourceEncapsulation.common;
* RCSResourceAttributes represents the attributes for a resource.
*
* An attribute value can be one of various types : integer, double, boolean,
- * String<br/>
+ * String.
*
* <p>
* If developer on client side wants to get the RCSResourceAttributes for the
* - Key of the element.
*
* @return int - integer value of key provided.
- *
*/
public int getValueInt(String key) {
Integer value = 0;
* - Key of the element.
*
* @return boolean - boolean value of key provided.
- *
*/
public double getValueDouble(String key) {
double value = 0;
* - Key of the element.
*
* @return boolean - boolean value of key provided.
- *
*/
public boolean getValueBool(String key) {
Boolean value = false;
* - Key of the element.
*
* @return String - String value of key provided.
- *
*/
public String getValueString(String key) {
String value = "";
* @param value
* - integer value of key to be set.
*
+ * @throws RCSException
*/
public void setValueInt(String key, int value) throws RCSException {
try {
* @param value
* - double value of key to be set.
*
+ * @throws RCSException
*/
public void setValueDouble(String key, double value) throws RCSException {
try {
* @param value
* - integer value of key to be set.
*
+ * @throws RCSException
*/
public void setValueBool(String key, boolean value) throws RCSException {
try {
* @param value
* - integer value of key to be set.
*
+ * @throws RCSException
*/
public void setValueString(String key, String value) throws RCSException {
try {
*
******************************************************************/
/**
- * @file Builder.java
- *
- * This file contains Builder class which provides the easy creation of Resource.
- *
+ * @file
+ * This file contains Builder class which provides the easy creation of Resource.
*/
package org.iotivity.ResourceEncapsulation.server;
* Resource type value to be set
* @param resourceInterface
* Interface value to be set
- *
*/
public Builder(String resourceURI, String resourceType,
String resourceInterface) {
*
* @param isDiscoverable
* Whether to be discovered or not
- *
*/
public void setDiscoverable(boolean isDiscoverable) {
m_discovervableFlag = isDiscoverable;
*
* @param isObservable
* Whether to be observed or not
- *
*/
public void setObservable(boolean isObservable) {
m_observableFlag = isObservable;
* Observable as needed. [optional] - Set the attributes for the
* resource. [optional] - At last call the build() method to
* create the resource.
- *
*/
public RCSResourceObject build() throws RCSException {
return this.nativeBuild(m_resourceUri, m_resourceType,
*
******************************************************************/
/**
- * @file RCSBundleInfo.java
- *
- * This file contains RCSBundleInfo class, which provides APIs related to Bundle information.
- *
+ * @file
+ * This file contains RCSBundleInfo class, which provides APIs related to Bundle information.
*/
package org.iotivity.ResourceEncapsulation.server;
* API for getting the Id of the bundle
*
* @return string - Id of the bundle
- *
*/
public String getID() {
return this.nativeGetID();
* API for getting the path of the bundle
*
* @return path - path of the bundle
- *
*/
public String getPath() {
return this.nativeGetPath();
* API for setting the Activator name for the bundle
*
* @return string - Name of the activator
- *
*/
public String getActivatorName() {
return nativeGetActivatorName();
* API for getting the library path for the bundle
*
* @return string - Library path in string form
- *
*/
public String getLibraryPath() {
return nativeGetLibraryPath();
* API for getting the version of the bundle
*
* @return string - version of the bundle
- *
*/
public String getVersion() {
return nativeGetVersion();
*
* @param id
* - Id of the bundle in string form
- *
*/
public void setID(String id) {
this.nativeSetID(id);
*
* @param path
* - path of the bundle in string form
- *
*/
public void setPath(String path) {
this.nativeSetPath(path);
/**
* API for setting the Activator name for the bundle
*
- * @param activator
+ * @param activatorName
* - Activator name in string form
- *
*/
public void setActivatorName(String activatorName) {
this.nativeSetActivatorName(activatorName);
/**
* API for setting the library path for the bundle
*
- * @param libpath
+ * @param libraryPath
* - Library path in string form
- *
*/
public void setLibraryPath(String libraryPath) {
this.nativeSetLibraryPath(libraryPath);
*
* @param version
* - version of the bundle in string form
- *
*/
public void setVersion(String version) {
this.nativeSetVersion(version);
*
******************************************************************/
/**
- * @file RCSGetResponse.java
- *
- * This file contains the class for creating a Get response
- * for the received Get request.
+ * @file
+ * This file contains the class for creating a Get response
+ * for the received Get request.
*
*/
* @return RCSGetResponse
*
* {@link EntityHandlerResult}
- *
*/
public static RCSGetResponse create(EntityHandlerResult result,
int errorCode) {
* @return RCSGetResponse
*
* {@link RCSResourceAttributes}
- *
*/
public static RCSGetResponse create(RCSResourceAttributes attributes) {
return new RCSGetResponse(attributes);
this.m_errorCode = errorCode;
}
- @SuppressWarnings("unused")
private int getTypeOfGetResponse() {
return m_typeOfGetResponse;
}
- @SuppressWarnings("unused")
private int getResult() {
return m_handlerResult;
}
- @SuppressWarnings("unused")
private int getErrorCode() {
return m_errorCode;
}
- @SuppressWarnings("unused")
private RCSResourceAttributes getAttributes() {
return m_attributes;
}
*
******************************************************************/
/**
- * @file RCSRequest.java
- *
- * This file provides RCSRequest class which will describes the request.
- *
+ * @file
+ * This file provides RCSRequest class which will describes the request.
*/
package org.iotivity.ResourceEncapsulation.server;
*
******************************************************************/
/**
- * @file RCSResourceContainer.java
- *
- * This file contains the Resource Container APIs
- *
+ * @file
+ * This file contains the Resource Container APIs
*/
package org.iotivity.ResourceEncapsulation.server;
/**
* API for getting the list of all bundles in the container
*
- * @return list<RCSBundleInfo> -List of BundleInfo objects each associated
- * with a bundle
+ * @return list -List of BundleInfo objects each associated with a bundle
*
* {@link RCSBundleInfo}
*/
* @param bundleId
* - Id of the Bundle
*
- * @return List<String> All the bundle resources
+ * @return List All the bundle resources
*/
public List<String> listBundleResources(String bundleId) {
return this.nativeListBundleResources(bundleId);
-/******************************************************************
+/* *****************************************************************
*
* Copyright 2015 Samsung Electronics All Rights Reserved.
*
*
******************************************************************/
/**
- * @file RCSResourceObject.java
- *
- * This file contains the resource object APIs provided to the developers.
- * RCSResourceObject is a part of the server builder module.
- *
+ * @file
+ * This file contains the resource object APIs provided to the developers.
+ * RCSResourceObject is a part of the server builder module.
*/
package org.iotivity.ResourceEncapsulation.server;
* {@link RCSResourceObject}
*/
public enum AutoNotifyPolicy {
- NEVER, /** < Never notify. */
- ALWAYS, /** < Always notify. */
+ NEVER, /* < Never notify. */
+ ALWAYS, /* < Always notify. */
UPDATED;
- /** < When attributes are changed, notify. */
+ /* < When attributes are changed, notify. */
- /**
+ /*
* Utility API for integer to enum conversion.
*/
public static AutoNotifyPolicy getAutoNotifyPolicy(int ordinal) {
public enum SetRequestHandlerPolicy {
- NEVER, /**
- * < Server ignore when server is received set-request of
- * attributes of the new key.
- */
+ NEVER, /*
+ * < Server ignore when server is received set-request of
+ * attributes of the new key.
+ */
ACCEPTANCE;
- /**
+ /*
* < Server creates attributes of the new key When server is received
* set-request of attributes of the new key.
*/
- /**
+ /*
* Utility API for integer to enum conversion.
*/
public static SetRequestHandlerPolicy getSetRequestHandlerPolicy(
* The thread-safety for attributes is taken care internally.
*/
public void setAttribute(String key, int value) {
- Log.e(LOG_TAG, "setAttribute (integer) called");
+ Log.i(LOG_TAG, "setAttribute (integer) called");
this.nativeSetAttributeInteger(key, value);
}
* The thread-safety for attributes is taken care internally.
*/
public void setAttribute(String key, double value) {
- Log.e(LOG_TAG, "setAttribute (float) called");
+ Log.i(LOG_TAG, "setAttribute (float) called");
this.nativeSetAttributeDouble(key, value);
}
* The thread-safety for attributes is taken care internally.
*/
public void setAttribute(String key, boolean value) {
- Log.e(LOG_TAG, "setAttribute (double) called ");
+ Log.i(LOG_TAG, "setAttribute (double) called ");
this.nativeSetAttributeBool(key, value);
}
* The thread-safety for attributes is taken care internally.
*/
public void setAttribute(String key, String value) {
- Log.e(LOG_TAG, "setAttribute (String) called ");
+ Log.i(LOG_TAG, "setAttribute (String) called ");
this.nativeSetAttributeString(key, value);
}
* The thread-safety for attributes is taken care internally.
*/
public String getAttributeValue(String key) {
- Log.e(LOG_TAG, "getAttributeValue called");
+ Log.i(LOG_TAG, "getAttributeValue called");
return this.nativeGetAttributeValue(key);
}
* The thread-safety for attributes is taken care internally.
*/
public boolean removeAttribute(String key) {
- Log.e(LOG_TAG, "removeAttribute called");
+ Log.i(LOG_TAG, "removeAttribute called");
return this.nativeRemoveAttribute(key);
}
* The thread-safety for attributes is taken care internally.
*/
public boolean containsAttribute(String key) {
- Log.e(LOG_TAG, "containsAttribute called");
+ Log.i(LOG_TAG, "containsAttribute called");
return this.nativeContainsAttribute(key);
}
* {@link RCSResourceAttributes}
*/
public RCSResourceAttributes getAttributes() {
- Log.e(LOG_TAG, "getAttributes called");
+ Log.i(LOG_TAG, "getAttributes called");
return this.nativeGetAttributes();
}
* @return true if observable otherwise false
*/
public boolean isObservable() {
- Log.e(LOG_TAG, "isObservable called");
+ Log.i(LOG_TAG, "isObservable called");
return this.nativeIsObservable();
}
* @return true if discoverable else false
*/
public boolean isDiscoverable() {
- Log.e(LOG_TAG, "isDiscoverable called");
+ Log.i(LOG_TAG, "isDiscoverable called");
return this.nativeIsDiscoverable();
}
* listener call setGetRequestListener() API
*
* {@link RCSGetResponse} {@link #setGetRequestListener(IGetRequestHandler)}
- *
*/
public void setGetRequestHandler() {
if (null == m_getRequestListener) {
- Log.e(LOG_TAG, "getRequestListener is not set");
+ Log.i(LOG_TAG, "getRequestListener is not set");
return;
} else {
this.nativeSetGetRequestHandler(m_getRequestListener);
* listener call setSetRequestListener() API
*
* {@link RCSSetResponse} {@link #setSetRequestListener(ISetRequestHandler)}
- *
*/
public void setSetRequestHandler() {
if (null == m_setRequestListener) {
- Log.e(LOG_TAG, "setRequestListener is not set");
+ Log.i(LOG_TAG, "setRequestListener is not set");
return;
} else {
this.nativeSetSetRequestHandler(m_setRequestListener);
*/
public void addAttributeUpdatedListener(String key) {
if (null == m_attributeUpdatedListener) {
- Log.e(LOG_TAG, "addAttributeUpdatedListener is not set");
+ Log.i(LOG_TAG, "addAttributeUpdatedListener is not set");
return;
} else {
this.nativeAddAttributeUpdatedListener(key,
* attributes value
*/
public void notifyObservers() {
- Log.e(LOG_TAG, "notifyObservers called");
+ Log.i(LOG_TAG, "notifyObservers called");
this.nativeNotify();
}
* policy to be set
*
* {@link AutoNotifyPolicy}
- *
*/
public void setAutoNotifyPolicy(AutoNotifyPolicy policy) {
- Log.e(LOG_TAG, "setAutoNotifyPolicy called");
+ Log.i(LOG_TAG, "setAutoNotifyPolicy called");
this.nativeSetAutoNotifyPolicy(policy.ordinal());
}
/**
* API for getting auto notify policy
*
- * @return AntoNotify policy
+ * @return AutoNotifyPolicy
*
* {@link AutoNotifyPolicy}
- *
*/
public AutoNotifyPolicy getAutoNotifyPolicy() {
- Log.e(LOG_TAG, "getAutoNotifyPolicy called");
+ Log.i(LOG_TAG, "getAutoNotifyPolicy called");
return AutoNotifyPolicy.getAutoNotifyPolicy(this
.nativeGetAutoNotifyPolicy());
}
* policy to be set
*
* {@link SetRequestHandlerPolicy}
- *
*/
public void setSetRequestHandlerPolicy(SetRequestHandlerPolicy policy) {
- Log.e(LOG_TAG, "setSetRequestHandlerPolicy called");
+ Log.i(LOG_TAG, "setSetRequestHandlerPolicy called");
this.nativeSetSetRequestHandlerPolicy(policy.ordinal());
}
/**
* API for getting the SetRequestHandler Policy.
*
- * @return Property of setRequesthandler
+ * @return SetRequestHandlerPolicy
*
* {@link SetRequestHandlerPolicy}
- *
*/
public SetRequestHandlerPolicy getSetRequestHandlerPolicy() {
- Log.e(LOG_TAG, "getSetRequestHandlerPolicy called");
+ Log.i(LOG_TAG, "getSetRequestHandlerPolicy called");
return SetRequestHandlerPolicy.getSetRequestHandlerPolicy(this
.nativeGetSetRequestHandlerPolicy());
}
*
******************************************************************/
/**
- * @file RCSSetResponse.java
- *
- * This file contains the class for creating a Set response
- * for the received Set request.
- *
+ * @file
+ * This file contains the class for creating a Set response
+ * for the received Set request.
*/
package org.iotivity.ResourceEncapsulation.server;
import org.iotivity.ResourceEncapsulation.common.RCSResourceAttributes;
import org.iotivity.ResourceEncapsulation.utils.EntityHandlerResult;
+import org.iotivity.ResourceEncapsulation.server.RCSResourceObject;
/**
* This class provides methods to create the response for a received set
*
* <p>
* DEFAULT : Follow SetRequestHandlerPolicy of the RCSResourceObject.
- *
- * @return RCSSetResponse
- *
- * {@link SetRequestHandlerPolicy}
*/
public static RCSSetResponse defaultAction() {
return new RCSSetResponse(DEFAULT_RESPONSE);
m_errorCode = errorCode;
}
- @SuppressWarnings("unused")
private int getTypeOfGetResponse() {
return m_typeOfSetResponse;
}
- @SuppressWarnings("unused")
private int getResult() {
return m_handlerResult;
}
- @SuppressWarnings("unused")
private int getErrorCode() {
return m_errorCode;
}
- @SuppressWarnings("unused")
private RCSResourceAttributes getAttributes() {
return m_attributes;
}
*
******************************************************************/
/**
- * @file DiscoveryType.java
- *
- * @brief This file provides a Enum to handle unicast or multicast discovery.
- *
- *@link RCSAddress
+ * @file
+ * This file provides a Enum to handle unicast or multicast discovery.
+ * @link RCSAddress
*/
package org.iotivity.ResourceEncapsulation.utils;
+import org.iotivity.ResourceEncapsulation.client.RCSAddress;
+
/**
* This Enum discovery codes for different discovery types.
*
*/
public enum DiscoveryType {
- UNICAST, /** < Unicast type discovery. */
+ UNICAST, /* < Unicast type discovery. */
MULTICAST;
- /** < Multicast type discovery. */
+ /* < Multicast type discovery. */
- /**
- * Utility API for int to enum conversion.
+ /*
+ * Utility API for integer to enum conversion.
*/
public static DiscoveryType getDiscoveryType(int ordinal) {
*
******************************************************************/
/**
- * @file EntityHandlerResult.java
- *
- * @brief This file provides EntityHandlerResult Enum & utility function.
- *
+ * @file
+ * This file provides EntityHandlerResult Enum & utility function.
*/
package org.iotivity.ResourceEncapsulation.utils;
+import org.iotivity.ResourceEncapsulation.server.*;
+
/**
* Represents the EntityHandlerResult, that application can send for a Get or a
* Set request.