Fix for issue of NM ResourceHosting android sample not working. 92/1092/2
authorHarish Kumara Marappa <h.marappa@samsung.com>
Fri, 22 May 2015 09:58:14 +0000 (15:28 +0530)
committerUze Choi <uzchoi@samsung.com>
Wed, 27 May 2015 10:18:21 +0000 (10:18 +0000)
Error code type changed from OCStackResult to int in
ISubscribePresenceListener::onPresenceCallback.

Change-Id: If0cc7684ca8cd1932a721bf56ca23c13fa98421f
Signed-off-by: Harish Kumara Marappa <h.marappa@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1092
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
Reviewed-by: kwon doil <doil.kwon@samsung.com>
Reviewed-by: RadhaBhavani <radha.p@samsung.com>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
service/notification-manager/SampleApp/android/ResourceHostingSampleApp/src/com/example/resourcehostingsampleapp/ResourceHosting.java
service/notification-manager/SampleApp/android/SampleConsumer/src/com/example/sample/consumer/SampleConsumer.java
service/notification-manager/SampleApp/android/SampleProviderApp/src/com/example/sample/provider/SampleProvider.java
service/things-manager/sdk/java/src/org/iotivity/service/tm/ISubscribePresenceListener.java
service/things-manager/sdk/java/src/org/iotivity/service/tm/ThingsManagerCallback.java

index 6dd340d..53576c2 100644 (file)
@@ -25,7 +25,12 @@ import java.net.NetworkInterface;
 import java.net.SocketException;
 import java.util.Enumeration;
 
+import org.iotivity.base.ModeType;
+import org.iotivity.base.OcPlatform;
 import org.iotivity.base.OcResourceHandle;
+import org.iotivity.base.PlatformConfig;
+import org.iotivity.base.QualityOfService;
+import org.iotivity.base.ServiceType;
 
 import android.app.Activity;
 import android.os.Bundle;
@@ -66,6 +71,15 @@ public class ResourceHosting extends Activity implements OnClickListener
             findViewById(R.id.btnStartHosting).setOnClickListener(this);
             findViewById(R.id.btnStopHosting).setOnClickListener(this);
             findViewById(R.id.btLogClear).setOnClickListener(this);
+
+            PlatformConfig platformConfigObj;
+
+            platformConfigObj = new PlatformConfig(this,ServiceType.IN_PROC,
+                    ModeType.CLIENT_SERVER, "0.0.0.0", 0, QualityOfService.LOW);
+
+            Log.i(TAG, "Before Calling Configure of ocPlatform");
+            OcPlatform.Configure(platformConfigObj);
+            Log.i(TAG, "Configuration done Successfully");
         }
 
         /**
@@ -261,14 +275,15 @@ public class ResourceHosting extends Activity implements OnClickListener
          */
         public native int ResourceHostingTerminate();
 
-        static
-        {
-               System.loadLibrary("gnustl_shared");
-               System.loadLibrary("oc_logger");
-               System.loadLibrary("connectivity_abstraction");
-            System.loadLibrary("octbstack");
-            System.loadLibrary("oc");
-            System.loadLibrary("ocstack-jni");
-            System.loadLibrary("NotificationManager");
-        }
+    static
+    {
+        System.loadLibrary("gnustl_shared");
+        System.loadLibrary("oc_logger");
+        System.loadLibrary("connectivity_abstraction");
+        System.loadLibrary("ca-interface");
+        System.loadLibrary("octbstack");
+        System.loadLibrary("oc");
+        System.loadLibrary("ocstack-jni");
+        System.loadLibrary("NotificationManager");
+    }
 }
index bf1cf5a..b24ab35 100644 (file)
@@ -165,7 +165,7 @@ public class SampleConsumer extends Activity implements View.OnClickListener,
         public void initOICStack()
         {
             PlatformConfig cfg = new PlatformConfig(this,ServiceType.IN_PROC,
-                                                    ModeType.CLIENT, "0.0.0.0", 0, QualityOfService.HIGH);
+                                                    ModeType.CLIENT, "0.0.0.0", 0, QualityOfService.LOW);
             OcPlatform.Configure(cfg);
             current_log_result += "Created Platform...\n";
             tv_current_log_result.setText(current_log_result);
@@ -175,7 +175,7 @@ public class SampleConsumer extends Activity implements View.OnClickListener,
 
         public void findResourceCandidate()
         {
-            nmfindResource("", "coap://224.0.1.187/oc/core?rt=Resource.Hosting");
+            nmfindResource("", "/oc/core?rt=Resource.Hosting");
             current_log_result += "Finding Resource... \n";
             tv_current_log_result.setText(current_log_result);
         }
@@ -344,12 +344,12 @@ public class SampleConsumer extends Activity implements View.OnClickListener,
                     break;
                 case R.id.btn_delete:
                     tv_select_method_type.setText(DELETE);
-                               try {
-                                       startDelete(curResource);
-                               } catch (OcException e) {
-                                       // TODO Auto-generated catch block
-                                       e.printStackTrace();
-                               }
+                try {
+                    startDelete(curResource);
+                } catch (OcException e) {
+                    // TODO Auto-generated catch block
+                    e.printStackTrace();
+                }
                     btn_delete.setClickable(false);
                     break;
                 case R.id.btn_clean:
@@ -561,27 +561,27 @@ public class SampleConsumer extends Activity implements View.OnClickListener,
             btn_delete.setClickable(true);
         }
 
-               @Override
-               public void onPutFailed(Throwable arg0) {
-                       // TODO Auto-generated method stub
-                       
-               }
-
-               @Override
-               public void onObserveFailed(Throwable arg0) {
-                       // TODO Auto-generated method stub
-                       
-               }
-
-               @Override
-               public void onDeleteFailed(Throwable arg0) {
-                       // TODO Auto-generated method stub
-                       
-               }
-
-               @Override
-               public void onGetFailed(Throwable arg0) {
-                       // TODO Auto-generated method stub
-                       
-               }
+        @Override
+        public void onPutFailed(Throwable arg0) {
+            // TODO Auto-generated method stub
+
+        }
+
+        @Override
+        public void onObserveFailed(Throwable arg0) {
+            // TODO Auto-generated method stub
+
+        }
+
+        @Override
+        public void onDeleteFailed(Throwable arg0) {
+            // TODO Auto-generated method stub
+
+        }
+
+        @Override
+        public void onGetFailed(Throwable arg0) {
+            // TODO Auto-generated method stub
+
+        }
 }
index 66572b8..26bd9b5 100644 (file)
@@ -79,7 +79,6 @@ public class SampleProvider extends Activity implements OnClickListener,
             findViewById(R.id.btnHumidityDown).setOnClickListener(this);
             findViewById(R.id.btnLogClear).setOnClickListener(this);
 
-
             isExecutePresence = false;
         }
 
@@ -88,7 +87,8 @@ public class SampleProvider extends Activity implements OnClickListener,
             // create platform config
             PlatformConfig cfg = new PlatformConfig(this,ServiceType.IN_PROC,
                                                     ModeType.SERVER, "0.0.0.0", // bind to all available interfaces
-                                                    0, QualityOfService.HIGH);
+                                                    0, QualityOfService.LOW);
+
             OcPlatform.Configure(cfg);
 
             try
index 8e2cca4..a1e2541 100644 (file)
@@ -38,5 +38,5 @@ public interface ISubscribePresenceListener {
      * @param result
      *            error code.
      */
-    public void onPresenceCallback(String resource, OCStackResult result);
+    public void onPresenceCallback(String resource, int result);
 }
index 667ae9f..36456dc 100644 (file)
@@ -400,15 +400,15 @@ class ThingsManagerCallback {
      *
      * @param resource
      *            URI of resource.
-     * @param result
+     * @param errorValue
      *            error code.
      *
      */
-    public void onPresenceCallback(String resource, OCStackResult result) {
+    public void onPresenceCallback(String resource, int errorValue) {
         if (null != presenceListener) {
             Log.i("ThingsManagerCallback : onPresenceCallback",
                     "Received Callback from JNI");
-            presenceListener.onPresenceCallback(resource, result);
+            presenceListener.onPresenceCallback(resource, errorValue);
         }
     }