Fixed a merge of OcConnectivityType and OcConnectivityFlags
authorTim Kourt <tim.a.kourt@intel.com>
Thu, 30 Jul 2015 16:22:31 +0000 (09:22 -0700)
committerErich Keane <erich.keane@intel.com>
Thu, 30 Jul 2015 18:45:11 +0000 (18:45 +0000)
throughout the android stack

A small Android API change was introduced as part of the merge: all discovery
calls now take a Set of OcConnectivtyTypes instead of a single enum.

In addition, it fixes a setHeaderOptions bug.

Change-Id: Ib269e39a0168055b4a1f46353cbd620fbff1dbad
Signed-off-by: Tim Kourt <tim.a.kourt@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1992
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Joseph Morrow <joseph.l.morrow@intel.com>
Reviewed-by: Erich Keane <erich.keane@intel.com>
16 files changed:
android/android_api/base/jni/JniOcPlatform.cpp
android/android_api/base/jni/JniUtils.cpp
android/android_api/base/jni/JniUtils.h
android/android_api/base/src/androidTest/java/org/iotivity/base/OcRepresentationTest.java
android/android_api/base/src/androidTest/java/org/iotivity/base/SmokeTest.java
android/android_api/base/src/main/java/org/iotivity/base/OcConnectivityFlags.java [deleted file]
android/android_api/base/src/main/java/org/iotivity/base/OcConnectivityType.java
android/android_api/base/src/main/java/org/iotivity/base/OcPlatform.java
android/android_api/base/src/main/java/org/iotivity/base/OcRepresentation.java
android/android_api/base/src/main/java/org/iotivity/base/OcResource.java
android/android_api/base/src/main/java/org/iotivity/ca/CaWiFiInterface.java [deleted file]
android/examples/fridgeclient/src/main/java/org/iotivity/base/examples/fridgeclient/FridgeClient.java
android/examples/fridgeclient/src/main/java/org/iotivity/base/examples/fridgeclient/StringConstants.java
android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/DeviceResource.java
android/examples/guiclient/src/main/java/org/iotivity/guiclient/OcWorker.java
android/examples/simpleclient/src/main/java/org/iotivity/base/examples/simpleclient/SimpleClient.java

index 4860e85..c8a619e 100644 (file)
@@ -578,7 +578,7 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_findResource0
         OCStackResult result = OCPlatform::findResource(
             host,
             resourceUri,
-            JniUtils::getConnectivityType(env, static_cast<int>(jConnectivityType)),
+            static_cast<OCConnectivityType>(jConnectivityType),
             findCallback);
 
         if (OC_STACK_OK != result)
@@ -630,7 +630,7 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_findResource1
         OCStackResult result = OCPlatform::findResource(
             host,
             resourceUri,
-            JniUtils::getConnectivityType(env, static_cast<int>(jConnectivityType)),
+            static_cast<OCConnectivityType>(jConnectivityType),
             findCallback,
             JniUtils::getQOS(env, static_cast<int>(jQoS)));
 
@@ -683,7 +683,7 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_getDeviceInfo0
         OCStackResult result = OCPlatform::getDeviceInfo(
             host,
             resourceUri,
-            JniUtils::getConnectivityType(env, static_cast<int>(jConnectivityType)),
+            static_cast<OCConnectivityType>(jConnectivityType),
             findDeviceCallback);
 
         if (OC_STACK_OK != result)
@@ -734,7 +734,7 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_getDeviceInfo1
         OCStackResult result = OCPlatform::getDeviceInfo(
             host,
             resourceUri,
-            JniUtils::getConnectivityType(env, static_cast<int>(jConnectivityType)),
+            static_cast<OCConnectivityType>(jConnectivityType),
             findDeviceCallback,
             JniUtils::getQOS(env, static_cast<int>(jQoS)));
 
@@ -786,7 +786,7 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_getPlatformInfo0
         OCStackResult result = OCPlatform::getPlatformInfo(
             host,
             resourceUri,
-            JniUtils::getConnectivityType(env, static_cast<int>(jConnectivityType)),
+            static_cast<OCConnectivityType>(jConnectivityType),
             findPlatformCallback);
 
         if (OC_STACK_OK != result)
@@ -837,7 +837,7 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_getPlatformInfo1
         OCStackResult result = OCPlatform::getPlatformInfo(
             host,
             resourceUri,
-            JniUtils::getConnectivityType(env, static_cast<int>(jConnectivityType)),
+            static_cast<OCConnectivityType>(jConnectivityType),
             findDeviceCallback,
             JniUtils::getQOS(env, static_cast<int>(jQoS)));
 
@@ -869,15 +869,13 @@ JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_registerResource0
     }
     JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, jResource);
     if (!resource) return nullptr;
-    LOGD("OcPlatform_registerResource1");
+
     OCResourceHandle resourceHandle;
     try
     {
-        LOGD("OcPlatform_registerResource2");
         OCStackResult result = OCPlatform::registerResource(
             resourceHandle,
             resource->getOCResource());
-        LOGD("OcPlatform_registerResource3");
 
         if (OC_STACK_OK != result)
         {
@@ -890,11 +888,10 @@ JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_registerResource0
         ThrowOcException(OC_STACK_ERROR, e.reason().c_str());
         return nullptr;
     }
-    LOGD("OcPlatform_registerResource4");
     JniOcResourceHandle* jniHandle = new JniOcResourceHandle(resourceHandle);
     jlong handle = reinterpret_cast<jlong>(jniHandle);
     jobject jResourceHandle = env->NewObject(g_cls_OcResourceHandle, g_mid_OcResourceHandle_N_ctor, handle);
-    LOGD("OcPlatform_registerResource5");
+
     if (!jResourceHandle)
     {
         LOGE("Failed to create OcResourceHandle");
@@ -1583,7 +1580,7 @@ JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_subscribePresence0
         OCStackResult result = OCPlatform::subscribePresence(
             presenceHandle,
             host,
-            JniUtils::getConnectivityType(env, static_cast<int>(jConnectivityType)),
+            static_cast<OCConnectivityType>(jConnectivityType),
             subscribeCallback);
 
         if (OC_STACK_OK != result)
@@ -1650,7 +1647,7 @@ JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_subscribePresence1
             presenceHandle,
             host,
             resourceType,
-            JniUtils::getConnectivityType(env, static_cast<int>(jConnectivityType)),
+            static_cast<OCConnectivityType>(jConnectivityType),
             subscribeCallback);
 
         if (OC_STACK_OK != result)
@@ -1758,7 +1755,7 @@ jboolean jIsObservable, jobjectArray jResourceTypeArray, jobjectArray jInterface
     std::shared_ptr<OCResource> resource = OCPlatform::constructResourceObject(
         host,
         uri,
-        JniUtils::getConnectivityType(env, static_cast<int>(jConnectivityType)),
+        static_cast<OCConnectivityType>(jConnectivityType),
         static_cast<bool>(jIsObservable),
         resourceTypes,
         interfaces);
index 38d22a3..e26a82c 100644 (file)
@@ -57,16 +57,13 @@ void JniUtils::convertJavaHeaderOptionsArrToVector(JNIEnv *env, jobjectArray jHe
     OC::HeaderOptions &headerOptions)
 {
     if (!jHeaderOptions) return;
-
     jsize len = env->GetArrayLength(jHeaderOptions);
     for (jsize i = 0; i < len; ++i)
     {
         jobject header = env->GetObjectArrayElement(jHeaderOptions, i);
-        if (!header) nullptr;
+        if (!header) return;
         jint jId = env->CallIntMethod(header, g_mid_OcHeaderOption_get_id);
         jstring jData = (jstring)env->CallObjectMethod(header, g_mid_OcHeaderOption_get_data);
-        if (jData) return;
-
         OC::HeaderOption::OCHeaderOption hopt(
             static_cast<int>(jId),
             env->GetStringUTFChars(jData, NULL));
index 0d9d1a7..70e8054 100644 (file)
@@ -124,23 +124,6 @@ public:
         };
     }
 
-    static OCConnectivityType getConnectivityType(JNIEnv *env, int type)
-    {
-        switch (type) {
-        case 0:
-            return OCConnectivityType::CT_DEFAULT;
-        case 1:
-            return OCConnectivityType::CT_ADAPTER_IP;
-        case 2:
-            return OCConnectivityType::CT_ADAPTER_RFCOMM_BTEDR;
-        case 3:
-            return OCConnectivityType::CT_ADAPTER_GATT_BTLE;
-        default:
-            ThrowOcException(OC_STACK_INVALID_PARAM, "Unexpected connectivity type");
-            return OCConnectivityType::CT_DEFAULT;
-        };
-    }
-
     static std::string stackResultToStr(const int result)
     {
         switch (result)
index 27191df..cbed2d5 100644 (file)
@@ -76,22 +76,6 @@ public class OcRepresentationTest extends InstrumentationTestCase {
         assertEquals(expected, actual);
     }
 
-    public void testJSONRepresentation() throws OcException {
-        OcRepresentation representation = new OcRepresentation();
-        String key = "key";
-        int value = 75;
-
-        String emptyJson1 = representation.getJSONRepresentation();
-        representation.setValue(key, value);
-        String intValue1 = representation.getJSONRepresentation();
-        representation.remove(key);
-        String emptyJson2 = representation.getJSONRepresentation();
-        assertEquals(emptyJson1, emptyJson2);
-        representation.setValue(key, value);
-        String intValue2 = representation.getJSONRepresentation();
-        assertEquals(intValue1, intValue2);
-    }
-
     public void testResourceTypesGetSet() {
         OcRepresentation representation = new OcRepresentation();
 
index d8356bc..eb981b5 100644 (file)
@@ -78,8 +78,10 @@ public class SmokeTest extends InstrumentationTestCase {
                     public void onResourceFound(OcResource resource) {
                         Log.i(TAG, "Host: " + resource.getHost());
                         Log.i(TAG, "Server ID: " + resource.getServerId());
-                        Log.i(TAG, "Connectivity Type: " + resource.getConnectivityType());
-                        Log.i(TAG, "Connectivity Type: " + resource.getConnectivityFlags());
+                        Log.i(TAG, "Connectivity Types: ");
+                        for (OcConnectivityType connectivityType : resource.getConnectivityTypeSet()) {
+                            Log.i(TAG, " " + connectivityType);
+                        }
                         signal.countDown();
                     }
                 };
@@ -97,7 +99,7 @@ public class SmokeTest extends InstrumentationTestCase {
             //client
             OcPlatform.findResource("",
                     OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
-                    OcConnectivityType.CT_DEFAULT,
+                    EnumSet.of(OcConnectivityType.CT_DEFAULT),
                     resourceFoundListener);
 
             //wait for onResourceFound event
@@ -139,7 +141,7 @@ public class SmokeTest extends InstrumentationTestCase {
 //                            //client
 //                            OcPresenceHandle presenceHandle = OcPlatform.subscribePresence(
 //                                    resource.getHost(),
-//                                    OcConnectivityType.CT_DEFAULT,
+//                                    EnumSet.of(OcConnectivityType.CT_DEFAULT),
 //                                    presenceListener
 //                            );
 //
@@ -163,13 +165,13 @@ public class SmokeTest extends InstrumentationTestCase {
 //                    resourceType,
 //                    OcPlatform.DEFAULT_INTERFACE,
 //                    entityHandler,
-//                    EnumSet.of(ResourceProperty.DISCOVERABLE)
+//                    EnumSet.of(ResourceProperty.DISCOVERABLE, ResourceProperty.OBSERVABLE)
 //            );
 //
 //            //client
 //            OcPlatform.findResource("",
 //                    OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
-//                    OcConnectivityType.CT_DEFAULT,
+//                    EnumSet.of(OcConnectivityType.CT_DEFAULT),
 //                    resourceFoundListener);
 //
 //            //server
@@ -224,12 +226,11 @@ public class SmokeTest extends InstrumentationTestCase {
                 if (ex instanceof OcException) {
                     OcException ocEx = (OcException) ex;
                     ErrorCode errCode = ocEx.getErrorCode();
-                    if(ErrorCode.NO_RESOURCE != errCode){
+                    if (ErrorCode.NO_RESOURCE != errCode) {
                         Log.e(TAG, ocEx.getMessage());
                         assertTrue(false);
                     }
-                }
-                else{
+                } else {
                     Log.e(TAG, ex.getMessage());
                     assertTrue(false);
                 }
@@ -321,7 +322,7 @@ public class SmokeTest extends InstrumentationTestCase {
             //client
             OcPlatform.findResource(null,
                     OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
-                    OcConnectivityType.CT_DEFAULT,
+                    EnumSet.of(OcConnectivityType.CT_DEFAULT),
                     resourceFoundListener);
 
             //wait for onResourceFound event
@@ -371,12 +372,11 @@ public class SmokeTest extends InstrumentationTestCase {
                 if (ex instanceof OcException) {
                     OcException ocEx = (OcException) ex;
                     ErrorCode errCode = ocEx.getErrorCode();
-                    if(ErrorCode.NO_RESOURCE != errCode){
+                    if (ErrorCode.NO_RESOURCE != errCode) {
                         Log.e(TAG, ocEx.getMessage());
                         assertTrue(false);
                     }
-                }
-                else{
+                } else {
                     Log.e(TAG, ex.getMessage());
                     assertTrue(false);
                 }
@@ -413,12 +413,11 @@ public class SmokeTest extends InstrumentationTestCase {
                                             if (ex instanceof OcException) {
                                                 OcException ocEx = (OcException) ex;
                                                 ErrorCode errCode = ocEx.getErrorCode();
-                                                if(ErrorCode.NO_RESOURCE != errCode){
+                                                if (ErrorCode.NO_RESOURCE != errCode) {
                                                     Log.e(TAG, ocEx.getMessage());
                                                     assertTrue(false);
                                                 }
-                                            }
-                                            else{
+                                            } else {
                                                 Log.e(TAG, ex.getMessage());
                                                 assertTrue(false);
                                             }
@@ -496,7 +495,7 @@ public class SmokeTest extends InstrumentationTestCase {
             //client
             OcPlatform.findResource("",
                     OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
-                    OcConnectivityType.CT_DEFAULT,
+                    EnumSet.of(OcConnectivityType.CT_DEFAULT),
                     resourceFoundListener);
 
             //wait for onResourceFound event
@@ -546,12 +545,11 @@ public class SmokeTest extends InstrumentationTestCase {
                 if (ex instanceof OcException) {
                     OcException ocEx = (OcException) ex;
                     ErrorCode errCode = ocEx.getErrorCode();
-                    if(ErrorCode.NO_RESOURCE != errCode){
+                    if (ErrorCode.NO_RESOURCE != errCode) {
                         Log.e(TAG, ocEx.getMessage());
                         assertTrue(false);
                     }
-                }
-                else{
+                } else {
                     Log.e(TAG, ex.getMessage());
                     assertTrue(false);
                 }
@@ -588,12 +586,11 @@ public class SmokeTest extends InstrumentationTestCase {
                                             if (ex instanceof OcException) {
                                                 OcException ocEx = (OcException) ex;
                                                 ErrorCode errCode = ocEx.getErrorCode();
-                                                if(ErrorCode.NO_RESOURCE != errCode){
+                                                if (ErrorCode.NO_RESOURCE != errCode) {
                                                     Log.e(TAG, ocEx.getMessage());
                                                     assertTrue(false);
                                                 }
-                                            }
-                                            else{
+                                            } else {
                                                 Log.e(TAG, ex.getMessage());
                                                 assertTrue(false);
                                             }
@@ -674,7 +671,7 @@ public class SmokeTest extends InstrumentationTestCase {
             //client
             OcPlatform.findResource("",
                     OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
-                    OcConnectivityType.CT_DEFAULT,
+                    EnumSet.of(OcConnectivityType.CT_DEFAULT),
                     resourceFoundListener);
 
             //wait for onResourceFound event
@@ -710,12 +707,11 @@ public class SmokeTest extends InstrumentationTestCase {
                 if (ex instanceof OcException) {
                     OcException ocEx = (OcException) ex;
                     ErrorCode errCode = ocEx.getErrorCode();
-                    if(ErrorCode.NO_RESOURCE != errCode){
+                    if (ErrorCode.NO_RESOURCE != errCode) {
                         Log.e(TAG, ocEx.getMessage());
                         assertTrue(false);
                     }
-                }
-                else{
+                } else {
                     Log.e(TAG, ex.getMessage());
                     assertTrue(false);
                 }
@@ -784,7 +780,7 @@ public class SmokeTest extends InstrumentationTestCase {
             //client
             OcPlatform.findResource("",
                     OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
-                    OcConnectivityType.CT_DEFAULT,
+                    EnumSet.of(OcConnectivityType.CT_DEFAULT),
                     resourceFoundListener);
 
             //wait for onResourceFound event
@@ -962,7 +958,7 @@ public class SmokeTest extends InstrumentationTestCase {
             //client
             OcPlatform.findResource("",
                     OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
-                    OcConnectivityType.CT_DEFAULT,
+                    EnumSet.of(OcConnectivityType.CT_DEFAULT),
                     resourceFoundListener);
 
             //wait for onResourceFound event
@@ -1024,7 +1020,7 @@ public class SmokeTest extends InstrumentationTestCase {
             OcPlatform.getPlatformInfo(
                     "",
                     OcPlatform.MULTICAST_PREFIX + "/oic/p",
-                    OcConnectivityType.CT_DEFAULT,
+                    EnumSet.of(OcConnectivityType.CT_DEFAULT),
                     platformFoundListener);
 
             //wait for onPlatformFound event
@@ -1035,62 +1031,50 @@ public class SmokeTest extends InstrumentationTestCase {
         }
     }
 
-//    public void testRegisterDeviceInfoGetDeviceInfo() throws InterruptedException {
-//        final String resourceType = "unit.test.resource" + new Date().getTime();
-//        final CountDownLatch signal = new CountDownLatch(1);
-//
-//        OcPlatform.OnDeviceFoundListener deviceFoundListener = new OcPlatform.OnDeviceFoundListener() {
-//            @Override
-//            public void onDeviceFound(OcRepresentation ocRepresentation) {
-//                try {
-//                    Log.i(TAG, "Device Name: " + ocRepresentation.getValue("n"));
-//                } catch (OcException e) {
-//                    Log.e(TAG, e.toString());
-//                    assertTrue(false);
-//                }
-//                boolean hasDeviceNameAtr = ocRepresentation.hasAttribute("n");
-//                assertTrue(hasDeviceNameAtr);
-//                boolean hasNonExistingAtr = ocRepresentation.hasAttribute("NonExisting");
-//                assertFalse(hasNonExistingAtr);
-//                Log.i(TAG, "URI: " + ocRepresentation.getUri());
-//                signal.countDown();
-//            }
-//        };
-//
-//        OcDeviceInfo devInfo = new OcDeviceInfo();
-//
-//        devInfo.setContentType("myContentType");
-//        devInfo.setDateOfManufacture("myDateOfManufacture");
-//        devInfo.setDeviceName("myDeviceName");
-//        devInfo.setDeviceUuid("myDeviceUUID");
-//        devInfo.setFirmwareVersion("myFirmwareVersion");
-//        devInfo.setHostName("myHostName");
-//        devInfo.setManufacturerName("myManufacturerNa");
-//        devInfo.setManufacturerUrl("myManufacturerUrl");
-//        devInfo.setModelNumber("myModelNumber");
-//        devInfo.setPlatformVersion("myPlatformVersion");
-//        devInfo.setSupportUrl("mySupportUrl");
-//        devInfo.setVersion("myVersion");
-//
-//        try {
-//            //server
-//            OcPlatform.registerDeviceInfo(devInfo);
-//
-//            //client
-//            OcPlatform.getDeviceInfo(
-//                    "",
-//                      OcPlatform.MULTICAST_PREFIX + DEVICE_URI,
-//                    OcConnectivityType.CT_DEFAULT,
-//                    deviceFoundListener);
-//
-//            //wait for onDeviceFound event
-//            assertTrue(signal.await(60, TimeUnit.SECONDS));
-//
-//        } catch (OcException e) {
-//            Log.e(TAG, e.getMessage());
-//            assertTrue(false);
-//        }
-//    }
+    public void testRegisterDeviceInfoGetDeviceInfo() throws InterruptedException {
+        final String resourceType = "unit.test.resource" + new Date().getTime();
+        final CountDownLatch signal = new CountDownLatch(1);
+
+        OcPlatform.OnDeviceFoundListener deviceFoundListener = new OcPlatform.OnDeviceFoundListener() {
+            @Override
+            public void onDeviceFound(OcRepresentation ocRepresentation) {
+                try {
+                    Log.i(TAG, "Device Name: " + ocRepresentation.getValue("n"));
+                } catch (OcException e) {
+                    Log.e(TAG, e.toString());
+                    assertTrue(false);
+                }
+                boolean hasDeviceNameAtr = ocRepresentation.hasAttribute("n");
+                assertTrue(hasDeviceNameAtr);
+                boolean hasNonExistingAtr = ocRepresentation.hasAttribute("NonExisting");
+                assertFalse(hasNonExistingAtr);
+                Log.i(TAG, "URI: " + ocRepresentation.getUri());
+                signal.countDown();
+            }
+        };
+
+        OcDeviceInfo devInfo = new OcDeviceInfo();
+        devInfo.setDeviceName("myDeviceName");
+
+        try {
+            //server
+            OcPlatform.registerDeviceInfo(devInfo);
+
+            //client
+            OcPlatform.getDeviceInfo(
+                    "",
+                    OcPlatform.MULTICAST_PREFIX + OcPlatform.DEVICE_URI,
+                    EnumSet.of(OcConnectivityType.CT_DEFAULT),
+                    deviceFoundListener);
+
+            //wait for onDeviceFound event
+            assertTrue(signal.await(60, TimeUnit.SECONDS));
+
+        } catch (OcException e) {
+            Log.e(TAG, e.getMessage());
+            assertTrue(false);
+        }
+    }
 
     public void testBindUnbindResources() throws InterruptedException {
         final String resourceType = "unit.test.resource" + new Date().getTime();
@@ -1180,7 +1164,7 @@ public class SmokeTest extends InstrumentationTestCase {
             //client
             OcPlatform.findResource("",
                     OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
-                    OcConnectivityType.CT_DEFAULT,
+                    EnumSet.of(OcConnectivityType.CT_DEFAULT),
                     resourceFoundListener1);
 
             //wait for onResourceFound event to find 3 registered resources
@@ -1193,7 +1177,7 @@ public class SmokeTest extends InstrumentationTestCase {
             //client
             OcPlatform.findResource("",
                     OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
-                    OcConnectivityType.CT_DEFAULT,
+                    EnumSet.of(OcConnectivityType.CT_DEFAULT),
                     resourceFoundListener3);
 
             //wait for onResourceFound event to find 1 collection resources
@@ -1205,7 +1189,7 @@ public class SmokeTest extends InstrumentationTestCase {
             //client
             OcPlatform.findResource("",
                     OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
-                    OcConnectivityType.CT_DEFAULT,
+                    EnumSet.of(OcConnectivityType.CT_DEFAULT),
                     resourceFoundListener2);
 
             //wait for onResourceFound event to find 2 resources
@@ -1217,7 +1201,7 @@ public class SmokeTest extends InstrumentationTestCase {
             //client
             OcPlatform.findResource("",
                     OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
-                    OcConnectivityType.CT_DEFAULT,
+                    EnumSet.of(OcConnectivityType.CT_DEFAULT),
                     resourceFoundListener4);
 
             //wait for onResourceFound event to find 3 registered resources
@@ -1232,7 +1216,7 @@ public class SmokeTest extends InstrumentationTestCase {
             //client
             OcPlatform.findResource("",
                     OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
-                    OcConnectivityType.CT_DEFAULT,
+                    EnumSet.of(OcConnectivityType.CT_DEFAULT),
                     resourceFoundListener6);
 
             //wait for onResourceFound event to find 1 collection resources
@@ -1243,7 +1227,7 @@ public class SmokeTest extends InstrumentationTestCase {
             //client
             OcPlatform.findResource("",
                     OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
-                    OcConnectivityType.CT_DEFAULT,
+                    EnumSet.of(OcConnectivityType.CT_DEFAULT),
                     resourceFoundListener5);
 
             //wait for onResourceFound event to find 1 collection resources
@@ -1327,12 +1311,12 @@ public class SmokeTest extends InstrumentationTestCase {
             //client
             OcPlatform.findResource("",
                     OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType1,
-                    OcConnectivityType.CT_DEFAULT,
+                    EnumSet.of(OcConnectivityType.CT_DEFAULT),
                     resourceFoundListener);
 
             OcPlatform.findResource("",
                     OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType2,
-                    OcConnectivityType.CT_DEFAULT,
+                    EnumSet.of(OcConnectivityType.CT_DEFAULT),
                     resourceFoundListener);
 
             //wait for onResourceFound event
@@ -1376,7 +1360,7 @@ public class SmokeTest extends InstrumentationTestCase {
                             OcResource resourceProxy = OcPlatform.constructResourceObject(
                                     resource.getHost(),
                                     resource.getUri(),
-                                    OcConnectivityType.CT_DEFAULT,
+                                    EnumSet.of(OcConnectivityType.CT_DEFAULT),
                                     resource.isObservable(),
                                     resource.getResourceTypes(),
                                     resource.getResourceInterfaces());
@@ -1406,7 +1390,7 @@ public class SmokeTest extends InstrumentationTestCase {
             //client
             OcPlatform.findResource("",
                     OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
-                    OcConnectivityType.CT_DEFAULT,
+                    EnumSet.of(OcConnectivityType.CT_DEFAULT),
                     resourceFoundListener);
 
             //wait for onResourceFound event
@@ -1433,7 +1417,7 @@ public class SmokeTest extends InstrumentationTestCase {
             //client
             OcPlatform.findResource("",
                     OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
-                    OcConnectivityType.CT_DEFAULT,
+                    EnumSet.of(OcConnectivityType.CT_DEFAULT),
                     resourceFoundListener);
 
             //wait for onResourceFound event
@@ -1605,7 +1589,7 @@ public class SmokeTest extends InstrumentationTestCase {
             //client
             OcPlatform.findResource("",
                     OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
-                    OcConnectivityType.CT_DEFAULT,
+                    EnumSet.of(OcConnectivityType.CT_DEFAULT),
                     resourceFoundListener);
 
             //wait for onResourceFound event
diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcConnectivityFlags.java b/android/android_api/base/src/main/java/org/iotivity/base/OcConnectivityFlags.java
deleted file mode 100644 (file)
index a4b4920..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- */
-
-package org.iotivity.base;
-
-import java.security.InvalidParameterException;
-public enum OcConnectivityFlags {
-    OC_DEFAULT_FLAGS (0),
-    // Insecure transport is the default (subject to change)
-    OC_FLAG_SECURE     (1 << 4), // secure the transport path
-
-    // IPv4 & IPv6 autoselection is the default
-    OC_IP_USE_V6       (1 << 5), // IP adapter only
-    OC_IP_USE_V4       (1 << 6), // IP adapter only
-
-    // Link-Local multicast is the default multicast scope for IPv6.
-    // These are placed here to correspond to the IPv6 address bits.
-    OC_SCOPE_INTERFACE (0x1), // IPv6 Interface-Local scope (loopback)
-    OC_SCOPE_LINK      (0x2), // IPv6 Link-Local scope (default)
-    OC_SCOPE_REALM     (0x3), // IPv6 Realm-Local scope
-    OC_SCOPE_ADMIN     (0x4), // IPv6 Admin-Local scope
-    OC_SCOPE_SITE      (0x5), // IPv6 Site-Local scope
-    OC_SCOPE_ORG       (0x8), // IPv6 Organization-Local scope
-    OC_SCOPE_GLOBAL    (0xE), // IPv6 Global scope
-    ;
-    private int value;
-
-    private OcConnectivityFlags(int value) {
-        this.value = value;
-    }
-
-    public int getValue() {
-        return this.value;
-    }
-
-    public static OcConnectivityFlags get(int val) {
-        for (OcConnectivityType v : OcConnectivityType.values()) {
-            for (OcConnectivityFlags f : OcConnectivityFlags.values()) {
-                int value = v.getValue() + f.getValue();
-                if (value == val)
-                    return f;
-            }
-        }
-        throw new InvalidParameterException("Unexpected OcConnectivityFlags value:" + val);
-    }
-}
\ No newline at end of file
index 512f2ba..7d42144 100644 (file)
 package org.iotivity.base;
 
 import java.security.InvalidParameterException;
+import java.util.EnumSet;
 
 public enum OcConnectivityType {
-    CT_DEFAULT (0),
-    CT_ADAPTER_IP (1 << 16),
-    CT_ADAPTER_GATT_BTLE (1 << 17),
+    /** use when defaults are ok. */
+    CT_DEFAULT              (0),
+
+    /** IPv4 and IPv6, including 6LoWPAN.*/
+    CT_ADAPTER_IP           (1 << 16),
+
+    /** GATT over Bluetooth LE.*/
+    CT_ADAPTER_GATT_BTLE    (1 << 17),
+
+    /** RFCOMM over Bluetooth EDR.*/
     CT_ADAPTER_RFCOMM_BTEDR (1 << 18),
+
+    /** Remote Access over XMPP.*/
+    CT_ADAPTER_REMOTE_ACCESS(1 << 19),
+
+    /** Insecure transport is the default (subject to change).*/
+
+    /** secure the transport path.*/
+    CT_FLAG_SECURE          (1 << 4),
+
+    /** IPv4 & IPv6 autoselection is the default.*/
+
+    /** IP adapter only.*/
+    CT_IP_USE_V6            (1 << 5),
+
+    /** IP adapter only.*/
+    CT_IP_USE_V4            (1 << 6),
+
+    /** Link-Local multicast is the default multicast scope for IPv6.
+     * These are placed here to correspond to the IPv6 address bits.*/
+
+    /** IPv6 Interface-Local scope(loopback).*/
+    CT_SCOPE_INTERFACE      (0x1),
+
+    /** IPv6 Link-Local scope (default).*/
+    CT_SCOPE_LINK           (0x2),
+
+    /** IPv6 Realm-Local scope.*/
+    CT_SCOPE_REALM          (0x3),
+
+    /** IPv6 Admin-Local scope.*/
+    CT_SCOPE_ADMIN          (0x4),
+
+    /** IPv6 Site-Local scope.*/
+    CT_SCOPE_SITE           (0x5),
+
+    /** IPv6 Organization-Local scope.*/
+    CT_SCOPE_ORG            (0x8),
+
+    /** IPv6 Global scope.*/
+    CT_SCOPE_GLOBAL         (0xE),
     ;
 
     private int value;
@@ -41,15 +89,23 @@ public enum OcConnectivityType {
         return this.value;
     }
 
-    public static OcConnectivityType get(int val) {
-        // val is a combination of OcConnectivityType and OcConnectivityFlags
-        for (OcConnectivityType v : OcConnectivityType.values()) {
-            for (OcConnectivityFlags f : OcConnectivityFlags.values()) {
-                int value = v.getValue() + f.getValue();
-                if (value == val)
-                    return v;
+    public static EnumSet<OcConnectivityType> convertToEnumSet(int value) {
+        EnumSet<OcConnectivityType> typeSet = null;
+
+        for (OcConnectivityType v : values()) {
+            if (0 != (value & v.getValue())) {
+                if (null == typeSet) {
+                    typeSet = EnumSet.of(v);
+                } else {
+                    typeSet.add(v);
+                }
             }
         }
-        throw new InvalidParameterException("Unexpected OcConnectivityType value:" + val);
+
+        if (null == typeSet || typeSet.isEmpty()) {
+            throw new InvalidParameterException("Unexpected OcConnectivityType value:" + value);
+        }
+
+        return typeSet;
     }
 }
index 9c54d7d..d042e9e 100644 (file)
@@ -227,13 +227,21 @@ public final class OcPlatform {
     public static void findResource(
             String host,
             String resourceUri,
-            OcConnectivityType connectivityType,
+            EnumSet<OcConnectivityType> connectivityTypeSet,
             OnResourceFoundListener onResourceFoundListener) throws OcException {
         OcPlatform.initCheck();
+
+        int connTypeInt = 0;
+
+        for (OcConnectivityType connType : OcConnectivityType.values()) {
+            if (connectivityTypeSet.contains(connType))
+                connTypeInt |= connType.getValue();
+        }
+
         OcPlatform.findResource0(
                 host,
                 resourceUri,
-                connectivityType.getValue(),
+                connTypeInt,
                 onResourceFoundListener
         );
     }
@@ -260,13 +268,21 @@ public final class OcPlatform {
     public static void findResource(
             String host,
             String resourceUri,
-            OcConnectivityType connectivityType,
+            EnumSet<OcConnectivityType> connectivityTypeSet,
             OnResourceFoundListener onResourceFoundListener,
             QualityOfService qualityOfService) throws OcException {
         OcPlatform.initCheck();
+
+        int connTypeInt = 0;
+
+        for (OcConnectivityType connType : OcConnectivityType.values()) {
+            if (connectivityTypeSet.contains(connType))
+                connTypeInt |= connType.getValue();
+        }
+
         OcPlatform.findResource1(host,
                 resourceUri,
-                connectivityType.getValue(),
+                connTypeInt,
                 onResourceFoundListener,
                 qualityOfService.getValue()
         );
@@ -292,13 +308,19 @@ public final class OcPlatform {
     public static void getDeviceInfo(
             String host,
             String deviceUri,
-            OcConnectivityType connectivityType,
+            EnumSet<OcConnectivityType> connectivityTypeSet,
             OnDeviceFoundListener onDeviceFoundListener) throws OcException {
         OcPlatform.initCheck();
+        int connTypeInt = 0;
+
+        for (OcConnectivityType connType : OcConnectivityType.values()) {
+            if (connectivityTypeSet.contains(connType))
+                connTypeInt |= connType.getValue();
+        }
         OcPlatform.getDeviceInfo0(
                 host,
                 deviceUri,
-                connectivityType.getValue(),
+                connTypeInt,
                 onDeviceFoundListener
         );
     }
@@ -323,14 +345,20 @@ public final class OcPlatform {
     public static void getDeviceInfo(
             String host,
             String deviceUri,
-            OcConnectivityType connectivityType,
+            EnumSet<OcConnectivityType> connectivityTypeSet,
             OnDeviceFoundListener onDeviceFoundListener,
             QualityOfService qualityOfService) throws OcException {
         OcPlatform.initCheck();
+        int connTypeInt = 0;
+
+        for (OcConnectivityType connType : OcConnectivityType.values()) {
+            if (connectivityTypeSet.contains(connType))
+                connTypeInt |= connType.getValue();
+        }
         OcPlatform.getDeviceInfo1(
                 host,
                 deviceUri,
-                connectivityType.getValue(),
+                connTypeInt,
                 onDeviceFoundListener,
                 qualityOfService.getValue()
         );
@@ -346,10 +374,10 @@ public final class OcPlatform {
     /**
      * API for Platform Discovery
      *
-     * @param host                  Host IP Address. If null or empty, Multicast is performed.
-     * @param platformUri           Uri containing address to the platform
-     * @param connectivityType      a type of connectivity indicating the interface. Example: IPV4,
-     *                              IPV6, ALL
+     * @param host                    Host IP Address. If null or empty, Multicast is performed.
+     * @param platformUri             Uri containing address to the platform
+     * @param connectivityType        a type of connectivity indicating the interface. Example: IPV4,
+     *                                IPV6, ALL
      * @param onPlatformFoundListener Handles events, success states and failure states.
      * @throws OcException
      */
@@ -357,13 +385,19 @@ public final class OcPlatform {
     public static void getPlatformInfo(
             String host,
             String platformUri,
-            OcConnectivityType connectivityType,
+            EnumSet<OcConnectivityType> connectivityTypeSet,
             OnPlatformFoundListener onPlatformFoundListener) throws OcException {
         OcPlatform.initCheck();
+        int connTypeInt = 0;
+
+        for (OcConnectivityType connType : OcConnectivityType.values()) {
+            if (connectivityTypeSet.contains(connType))
+                connTypeInt |= connType.getValue();
+        }
         OcPlatform.getPlatformInfo0(
                 host,
                 platformUri,
-                connectivityType.getValue(),
+                connTypeInt,
                 onPlatformFoundListener
         );
     }
@@ -377,26 +411,32 @@ public final class OcPlatform {
     /**
      * API for Platform Discovery
      *
-     * @param host                  Host IP Address. If null or empty, Multicast is performed.
-     * @param platformUri           Uri containing address to the platform
-     * @param connectivityType      a type of connectivity indicating the interface. Example: IPV4,
-     *                              IPV6, ALL
+     * @param host                    Host IP Address. If null or empty, Multicast is performed.
+     * @param platformUri             Uri containing address to the platform
+     * @param connectivityType        a type of connectivity indicating the interface. Example: IPV4,
+     *                                IPV6, ALL
      * @param onPlatformFoundListener Handles events, success states and failure states.
-     * @param qualityOfService      the quality of communication
+     * @param qualityOfService        the quality of communication
      * @throws OcException
      */
 
     public static void getPlatformInfo(
             String host,
             String platformUri,
-            OcConnectivityType connectivityType,
+            EnumSet<OcConnectivityType> connectivityTypeSet,
             OnPlatformFoundListener onPlatformFoundListener,
             QualityOfService qualityOfService) throws OcException {
         OcPlatform.initCheck();
+        int connTypeInt = 0;
+
+        for (OcConnectivityType connType : OcConnectivityType.values()) {
+            if (connectivityTypeSet.contains(connType))
+                connTypeInt |= connType.getValue();
+        }
         OcPlatform.getPlatformInfo1(
                 host,
                 platformUri,
-                connectivityType.getValue(),
+                connTypeInt,
                 onPlatformFoundListener,
                 qualityOfService.getValue()
         );
@@ -481,7 +521,7 @@ public final class OcPlatform {
 
     private static native void registerDeviceInfo0(
             String deviceName
-            ) throws OcException;
+    ) throws OcException;
 
     /**
      * Register Platform Info
@@ -688,12 +728,18 @@ public final class OcPlatform {
      */
     public static OcPresenceHandle subscribePresence(
             String host,
-            OcConnectivityType connectivityType,
+            EnumSet<OcConnectivityType> connectivityTypeSet,
             OnPresenceListener onPresenceListener) throws OcException {
         OcPlatform.initCheck();
+        int connTypeInt = 0;
+
+        for (OcConnectivityType connType : OcConnectivityType.values()) {
+            if (connectivityTypeSet.contains(connType))
+                connTypeInt |= connType.getValue();
+        }
         return OcPlatform.subscribePresence0(
                 host,
-                connectivityType.getValue(),
+                connTypeInt,
                 onPresenceListener
         );
     }
@@ -719,13 +765,19 @@ public final class OcPlatform {
     public static OcPresenceHandle subscribePresence(
             String host,
             String resourceType,
-            OcConnectivityType connectivityType,
+            EnumSet<OcConnectivityType> connectivityTypeSet,
             OnPresenceListener onPresenceListener) throws OcException {
         OcPlatform.initCheck();
+        int connTypeInt = 0;
+
+        for (OcConnectivityType connType : OcConnectivityType.values()) {
+            if (connectivityTypeSet.contains(connType))
+                connTypeInt |= connType.getValue();
+        }
         return OcPlatform.subscribePresence1(
                 host,
                 resourceType,
-                connectivityType.getValue(),
+                connTypeInt,
                 onPresenceListener);
     }
 
@@ -777,15 +829,21 @@ public final class OcPlatform {
     public static OcResource constructResourceObject(
             String host,
             String uri,
-            OcConnectivityType connectivityType,
+            EnumSet<OcConnectivityType> connectivityTypeSet,
             boolean isObservable,
             List<String> resourceTypeList,
             List<String> interfaceList) throws OcException {
         OcPlatform.initCheck();
+        int connTypeInt = 0;
+
+        for (OcConnectivityType connType : OcConnectivityType.values()) {
+            if (connectivityTypeSet.contains(connType))
+                connTypeInt |= connType.getValue();
+        }
         return OcPlatform.constructResourceObject0(
                 host,
                 uri,
-                connectivityType.getValue(),
+                connTypeInt,
                 isObservable,
                 resourceTypeList.toArray(new String[resourceTypeList.size()]),
                 interfaceList.toArray(new String[interfaceList.size()])
index 8dca1cc..eba1001 100644 (file)
@@ -265,8 +265,6 @@ public class OcRepresentation {
         }
     }
 
-    public native String getJSONRepresentation();
-
     public native void addChild(OcRepresentation representation);
 
     public native void clearChildren();
index 2393549..92e38e6 100644 (file)
@@ -22,6 +22,7 @@
 
 package org.iotivity.base;
 
+import java.util.EnumSet;
 import java.util.List;
 import java.util.Map;
 
@@ -460,10 +461,10 @@ public class OcResource {
     /**
      * Method to get the connectivity type of this resource
      *
-     * @return OcConnectivityType connectivity type
+     * @return EnumSet<OcConnectivityType></OcConnectivityType> connectivity type set
      */
-    public OcConnectivityType getConnectivityType() {
-        return OcConnectivityType.get(
+    public EnumSet<OcConnectivityType> getConnectivityTypeSet() {
+        return OcConnectivityType.convertToEnumSet(
                 this.getConnectivityTypeN()
         );
     }
@@ -471,18 +472,6 @@ public class OcResource {
     private native int getConnectivityTypeN();
 
     /**
-     * Method to get the connectivity flags of this resource
-     *
-     * @return OcConnectivityFlags connectivity type
-     */
-    public OcConnectivityFlags getConnectivityFlags() {
-        OcConnectivityType connType = this.getConnectivityType();
-        int connTypeN = this.getConnectivityTypeN();
-        int flag = connTypeN - connType.getValue();
-        return OcConnectivityFlags.get(flag);
-    }
-
-    /**
      * Method to provide ability to check if this resource is observable or not
      *
      * @return true indicates resource is observable; false indicates resource is not observable
diff --git a/android/android_api/base/src/main/java/org/iotivity/ca/CaWiFiInterface.java b/android/android_api/base/src/main/java/org/iotivity/ca/CaWiFiInterface.java
deleted file mode 100644 (file)
index 9ec6eb8..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- */
-
-package org.iotivity.ca;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.net.ConnectivityManager;
-import android.net.NetworkInfo;
-import android.net.wifi.WifiManager;
-
-public class CaWiFiInterface {
-
-    private static Context mContext;
-
-    private CaWiFiInterface(Context context) {
-        mContext = context;
-        registerWiFiStateReceiver();
-    }
-
-    private void registerWiFiStateReceiver() {
-        IntentFilter intentFilter = new IntentFilter();
-        intentFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
-        intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
-
-        mContext.registerReceiver(mReceiver, intentFilter);
-    }
-
-    private static BroadcastReceiver mReceiver = new BroadcastReceiver() {
-
-        @Override
-        public void onReceive(Context context, Intent intent) {
-            if (intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE,
-                    WifiManager.WIFI_STATE_UNKNOWN) == WifiManager.WIFI_STATE_DISABLED) {
-                CAWiFiStateDisabled();
-            } else if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
-                ConnectivityManager manager = (ConnectivityManager)
-                        mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
-                NetworkInfo nwInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
-
-                if (nwInfo.isConnected()) {
-                    CAWiFiStateEnabled();
-                }
-            }
-        }
-    };
-
-    private native static void CAWiFiStateEnabled();
-
-    private native static void CAWiFiStateDisabled();
-}
\ No newline at end of file
index 5d0913b..b2109e8 100644 (file)
@@ -49,6 +49,7 @@ import org.iotivity.base.PlatformConfig;
 import org.iotivity.base.QualityOfService;
 import org.iotivity.base.ServiceType;
 
+import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
@@ -88,7 +89,7 @@ public class FridgeClient extends Activity implements
         OcPlatform.Configure(cfg);
         try {
             OcPlatform.findResource("", OcPlatform.WELL_KNOWN_QUERY + "?rt=" + "intel.fridge",
-                    OcConnectivityType.CT_DEFAULT, this);
+                    EnumSet.of(OcConnectivityType.CT_DEFAULT), this);
         } catch (OcException e) {
             logMessage(TAG + " init Error. " + e.getMessage());
             Log.e(TAG, e.getMessage());
@@ -195,23 +196,23 @@ public class FridgeClient extends Activity implements
         lightTypes.add("intel.fridge.light");
         try {
             OcResource light = OcPlatform.constructResourceObject(ocResource.getHost(),
-                    StringConstants.LIGHT, OcConnectivityType.CT_DEFAULT, false, lightTypes, ifaces);
+                    StringConstants.LIGHT, EnumSet.of(OcConnectivityType.CT_DEFAULT), false, lightTypes, ifaces);
 
             List<String> doorTypes = new LinkedList<>();
             doorTypes.add("intel.fridge.door");
             OcResource leftDoor = OcPlatform.constructResourceObject(ocResource.getHost(),
-                    StringConstants.LEFT_DOOR, OcConnectivityType.CT_DEFAULT, false, doorTypes, ifaces);
+                    StringConstants.LEFT_DOOR, EnumSet.of(OcConnectivityType.CT_DEFAULT), false, doorTypes, ifaces);
 
             OcResource rightDoor = OcPlatform.constructResourceObject(ocResource.getHost(),
-                    StringConstants.RIGHT_DOOR, OcConnectivityType.CT_DEFAULT, false, doorTypes, ifaces);
+                    StringConstants.RIGHT_DOOR, EnumSet.of(OcConnectivityType.CT_DEFAULT), false, doorTypes, ifaces);
 
             OcResource randomDoor = OcPlatform.constructResourceObject(ocResource.getHost(),
-                    StringConstants.RANDOM_DOOR, OcConnectivityType.CT_DEFAULT, false, doorTypes, ifaces);
+                    StringConstants.RANDOM_DOOR, EnumSet.of(OcConnectivityType.CT_DEFAULT), false, doorTypes, ifaces);
 
             List<OcHeaderOption> headerOptions = new LinkedList<>();
             OcHeaderOption apiVersion = new OcHeaderOption(StringConstants.API_VERSION_KEY,
                     StringConstants.API_VERSION);
-            OcHeaderOption clientToken = new OcHeaderOption(StringConstants.CLIENT_VERSION_KEY,
+            OcHeaderOption clientToken = new OcHeaderOption(StringConstants.CLIENT_TOKEN_KEY,
                     StringConstants.CLIENT_TOKEN);
             headerOptions.add(apiVersion);
             headerOptions.add(clientToken);
index 1fd690f..4c2f197 100644 (file)
@@ -26,7 +26,7 @@ public interface StringConstants {
 
     public static final int WAIT_TIME = 1000;
     public static final int API_VERSION_KEY = 2048;
-    public static final int CLIENT_VERSION_KEY = 3000;
+    public static final int CLIENT_TOKEN_KEY = 3000;
 
     public static final boolean ENABLE_PRINTING = true; // change to false to disable printing
                                                         // of messages on the console and the screen
index fd00402..9868f32 100644 (file)
@@ -131,6 +131,7 @@ public class DeviceResource extends Resource implements IMessageLogger {
                     logMessage(TAG + " Client Token: " + clientToken);
                 }
             }
+
             if (clientAPIVersion.equals(StringConstants.API_VERSION) &&
                     clientToken.equals(StringConstants.CLIENT_TOKEN)) {
                 List<OcHeaderOption> serverHeaderOptions = new LinkedList<>();
@@ -157,10 +158,6 @@ public class DeviceResource extends Resource implements IMessageLogger {
                                 response.setErrorCode(StringConstants.OK);
                                 response.setResponseResult(EntityHandlerResult.OK);
                                 break;
-                            case POST:
-                                response.setResponseResult(EntityHandlerResult.ERROR);
-                                OcPlatform.sendResponse(response);
-                                break;
                         }
                         result = EntityHandlerResult.OK;
                     }
index f8b5d51..cb049a6 100644 (file)
@@ -35,6 +35,7 @@ import org.iotivity.base.QualityOfService;
 import org.iotivity.base.ServiceType;
 
 import java.util.ArrayList;
+import java.util.EnumSet;
 import java.util.List;
 
 import static org.iotivity.guiclient.OcProtocolStrings.COAP_CORE;
@@ -503,7 +504,7 @@ public class OcWorker extends Thread
                 Log.d(TAG, String.format("discoverResources(): Calling OcPlatform.findResource(%s)", s));
                 OcPlatform.findResource("",
                         OcPlatform.WELL_KNOWN_QUERY + "?rt=" + s,
-                        OcConnectivityType.CT_DEFAULT,
+                        EnumSet.of(OcConnectivityType.CT_DEFAULT),
                         this);
             }
         } catch (OcException e) {
index 90c287b..d20794e 100644 (file)
@@ -55,6 +55,7 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.List;
 
@@ -99,7 +100,7 @@ public class SimpleClient extends Activity implements OcPlatform.OnResourceFound
              * find all resources
              */
             OcPlatform.findResource("", OcPlatform.WELL_KNOWN_QUERY + "?rt=" + "core.light",
-                    OcConnectivityType.CT_DEFAULT, this);
+                    EnumSet.of(OcConnectivityType.CT_DEFAULT), this);
         } catch (OcException e) {
             logMessage(TAG + "findResource error: " + e.getMessage());
             Log.e(TAG, e.getMessage());