[IOT-1538] Add support for Protocol-Independent ID
authorDan Mihai <Daniel.Mihai@microsoft.com>
Fri, 13 Jan 2017 00:52:43 +0000 (16:52 -0800)
committerMike Fenelon <mike.fenelon@microsoft.com>
Tue, 17 Jan 2017 22:26:44 +0000 (22:26 +0000)
Per OCF Core CR 64: add support for a protocol-independent ID of a
device, in /oic/d, for use with de-duping information discovered via
more than one protocol (OCF, AllJoyn, UPnP, WS-Discovery, etc.). The
other protocols already carry a UUID for this purpose.

Change-Id: I2c6f5f2a29d09b2a120d450708360bcd61c08b3c
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
Signed-off-by: Dan Mihai <Daniel.Mihai@microsoft.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/14261
Reviewed-by: George Nash <george.nash@intel.com>
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Mike Fenelon <mike.fenelon@microsoft.com>
22 files changed:
cloud/samples/client/airconditioner/aircon_controlee.cpp
cloud/samples/client/thin_light/thin_room_light.cpp
plugins/samples/linux/IotivityandZigbeeServer.c
resource/csdk/include/octypes.h
resource/csdk/stack/samples/linux/SimpleClientServer/ocserver.cpp
resource/csdk/stack/samples/tizen/SimpleClientServer/ocserver.cpp
resource/examples/devicediscoveryserver.cpp
resource/examples/fridgeserver.cpp
resource/examples/garageserver.cpp
resource/examples/lightserver.cpp
resource/examples/mediaserver.cpp
resource/examples/presenceserver.cpp
resource/examples/roomserver.cpp
resource/examples/simpleserver.cpp
resource/examples/simpleserverHQ.cpp
resource/unittests/OCPlatformTest.cpp
resource/unittests/OCRepresentationEncodingTest.cpp
service/simulator/examples/server/simulator_server.cpp
service/simulator/inc/simulator_manager.h
service/simulator/java/jni/simulator_manager_jni.cpp
service/simulator/java/sdk/src/org/oic/simulator/SimulatorManager.java
service/simulator/src/simulator_manager.cpp

index 201f89e..a18f1fd 100644 (file)
@@ -528,6 +528,15 @@ OCStackResult SetDeviceInfo()
         return result;
     }
 
+    result = OCPlatform::setPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_PROTOCOL_INDEPENDENT_ID,
+                                          "d7d2b492-83ac-4783-9dcc-b1b54587ebed");
+
+    if (result != OC_STACK_OK)
+    {
+        cout << "Failed to set piid" << endl;
+        return result;
+    }
+
     return OC_STACK_OK;
 }
 
index 9927362..d8df6d0 100644 (file)
@@ -475,6 +475,8 @@ OCStackResult SetDeviceInfo()
     }
 
     VERIFY_SUCCESS(OCSetPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_DEVICE_NAME, "Living Room Light"));
+    VERIFY_SUCCESS(OCSetPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_PROTOCOL_INDEPENDENT_ID,
+                                      "91debd4b-c875-47e1-9e1d-b1cd32baeb01"));
 
     cout << "Device information published successfully." << endl;
     return OC_STACK_OK;
index da7a793..0abd561 100644 (file)
@@ -155,6 +155,9 @@ OCStackResult SetDeviceInfo()
     VERIFY_SUCCESS(OCSetPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_DATA_MODEL_VERSION,
                                       "IoTivity/Zigbee Data Model Version"));
 
+    VERIFY_SUCCESS(OCSetPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_PROTOCOL_INDEPENDENT_ID,
+                                      "4ea65ac9-59a3-4eb8-8d77-76c3ee72c250"));
+
     OIC_LOG(INFO, TAG, "Device information initialized successfully.");
     return OC_STACK_OK;
 
index d02a569..481db4c 100755 (executable)
@@ -306,6 +306,10 @@ extern "C" {
 
 /** Device Data Model version.*/
 #define OC_DATA_MODEL_VERSION           "res.1.1.0,sh.1.1.0"
+
+/** Protocol-Independent ID.*/
+#define OC_RSRVD_PROTOCOL_INDEPENDENT_ID "piid"
+
 /**
  *  These provide backward compatibility - their use is deprecated.
  */
index 0e53bdc..2e8f9fe 100644 (file)
@@ -90,6 +90,7 @@ const char *manufacturerName = "myName";
 const char *operatingSystemVersion = "myOS";
 const char *hardwareVersion = "myHardwareVersion";
 const char *platformID = "0A3E0D6F-DBF5-404E-8719-D6880042463A";
+const char *protocolIndependentID = "6ef9211d-2d5c-401e-8e5d-4b3af48a054f";
 const char *manufacturerLink = "https://www.iotivity.org";
 const char *modelNumber = "myModelNumber";
 const char *platformVersion = "myPlatformVersion";
@@ -1006,6 +1007,8 @@ OCStackResult SetDeviceInfo()
     VERIFY_SUCCESS(OCSetPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_SPEC_VERSION, specVersion));
     VERIFY_SUCCESS(OCSetPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_DATA_MODEL_VERSION,
                                       dataModelVersions));
+    VERIFY_SUCCESS(OCSetPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_PROTOCOL_INDEPENDENT_ID,
+                                      protocolIndependentID));
 
     OIC_LOG(INFO, TAG, "Device information initialized successfully.");
     return OC_STACK_OK;
@@ -1189,7 +1192,7 @@ int main(int argc, char* argv[])
         OIC_LOG(INFO, TAG, "Device Registration failed!");
         exit (EXIT_FAILURE);
     }
-  
+
     /*
      * Declare and create the example resource: Light
      */
index ae36f7a..387e27a 100644 (file)
@@ -80,6 +80,7 @@ const char *manufacturerName = "myName";
 const char *operatingSystemVersion = "myOS";
 const char *hardwareVersion = "myHardwareVersion";
 const char *platformID = "0A3E0D6F-DBF5-404E-8719-D6880042463A";
+const char *protocolIndependentID = "45a908e9-c06c-4935-b2dd-4195da863a11";
 const char *manufacturerLink = "https://www.iotivity.org";
 const char *modelNumber = "myModelNumber";
 const char *platformVersion = "myPlatformVersion";
@@ -932,6 +933,8 @@ OCStackResult SetDeviceInfo()
     VERIFY_SUCCESS(OCSetPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_SPEC_VERSION, specVersion));
     VERIFY_SUCCESS(OCSetPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_DATA_MODEL_VERSION,
                                       dataModelVersions));
+    VERIFY_SUCCESS(OCSetPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_PROTOCOL_INDEPENDENT_ID,
+                                      protocolIndependentID));
 
     OIC_LOG(INFO, TAG, "Device information initialized successfully.");
     return OC_STACK_OK;
index 7bb24a2..6923172 100644 (file)
@@ -50,6 +50,7 @@ std::string  systemTime = "2016-01-15T11.01";
 std::string  deviceName = "Bill's Battlestar";
 std::string  specVersion = "core.1.1.0";
 std::vector<std::string> dataModelVersions = {"res.1.1.0", "sh.1.1.0"};
+std::string  protocolIndependentID = "4cae60c1-48cb-47dc-882e-dedec114f45c";
 
 // Device type
 std::string  deviceType = "oic.d.tv";
@@ -138,6 +139,14 @@ OCStackResult SetDeviceInfo()
         return result;
     }
 
+    result = OCPlatform::setPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_PROTOCOL_INDEPENDENT_ID,
+                                          protocolIndependentID);
+    if (result != OC_STACK_OK)
+    {
+        std::cout << "Failed to set piid" << std::endl;
+        return result;
+    }
+
     return OC_STACK_OK;
 }
 
index d1622b0..9ab20d7 100644 (file)
@@ -63,6 +63,7 @@ std::string  systemTime = "2016-01-15T11.01";
 std::string  deviceName = "IoTivity Fridge Server";
 std::string  specVersion = "core.1.1.0";
 std::vector<std::string> dataModelVersions = {"res.1.1.0"};
+std::string  protocolIndependentID = "054718eb-b1e7-4e9e-9892-30e718a6a8f3";
 
 // OCPlatformInfo Contains all the platform info to be stored
 OCPlatformInfo platformInfo;
@@ -552,6 +553,14 @@ OCStackResult SetDeviceInfo()
         return result;
     }
 
+    result = OCPlatform::setPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_PROTOCOL_INDEPENDENT_ID,
+                                          protocolIndependentID);
+    if (result != OC_STACK_OK)
+    {
+        std::cout << "Failed to set piid" << std::endl;
+        return result;
+    }
+
     return OC_STACK_OK;
 }
 
index ab4072d..f333d45 100644 (file)
@@ -52,6 +52,7 @@ std::string  systemTime = "2016-01-15T11.01";
 std::string  deviceName = "IoTivity Garage Server";
 std::string  specVersion = "core.1.1.0";
 std::vector<std::string> dataModelVersions = {"res.1.1.0"};
+std::string  protocolIndependentID = "1cbab786-ca5f-4eb9-89b2-e90eb4820145";
 
 // OCPlatformInfo Contains all the platform info to be stored
 OCPlatformInfo platformInfo;
@@ -328,6 +329,14 @@ OCStackResult SetDeviceInfo()
         return result;
     }
 
+    result = OCPlatform::setPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_PROTOCOL_INDEPENDENT_ID,
+                                          protocolIndependentID);
+    if (result != OC_STACK_OK)
+    {
+        cout << "Failed to set piid" << endl;
+        return result;
+    }
+
     return OC_STACK_OK;
 }
 
@@ -358,6 +367,7 @@ int main(int /*argc*/, char** /*argv[1]*/)
     }
 
     result = SetDeviceInfo();
+
     if (result != OC_STACK_OK)
     {
         std::cout << "Device Registration failed\n";
index 55188e9..2baf79f 100644 (file)
@@ -63,6 +63,7 @@ std::string  systemTime = "2016-01-15T11.01";
 std::string  deviceName = "IoTivity Light Server";
 std::string  specVersion = "core.1.1.0";
 std::vector<std::string> dataModelVersions = {"res.1.1.0"};
+std::string  protocolIndependentID = "b0ed9259-ec95-4ac6-8f62-241d0da02683";
 
 // OCPlatformInfo Contains all the platform info to be stored
 OCPlatformInfo platformInfo;
@@ -375,6 +376,14 @@ OCStackResult SetDeviceInfo()
         return result;
     }
 
+    result = OCPlatform::setPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_PROTOCOL_INDEPENDENT_ID,
+                                          protocolIndependentID);
+    if (result != OC_STACK_OK)
+    {
+        cout << "Failed to set piid" << endl;
+        return result;
+    }
+
     return OC_STACK_OK;
 }
 
index 18f353c..457349b 100644 (file)
@@ -421,6 +421,14 @@ OCStackResult SetDeviceInfo()
         return result;
     }
 
+    result = OCPlatform::setPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_PROTOCOL_INDEPENDENT_ID,
+                                          "9f9752ed-b4ab-4662-af22-7e541bbee2fb");
+    if (result != OC_STACK_OK)
+    {
+        cout << "Failed to set piid" << endl;
+        return result;
+    }
+
     return OC_STACK_OK;
 }
 
index 2ed2359..da1d937 100644 (file)
@@ -63,6 +63,7 @@ std::string  systemTime = "2016-01-15T11.01";
 std::string  deviceName = "IoTivity Presence Server";
 std::string  specVersion = "core.1.1.0";
 std::vector<std::string> dataModelVersions = {"res.1.1.0"};
+std::string  protocolIndependentID = "41a75d38-83c3-4b83-a794-f2174990b30b";
 
 // OCPlatformInfo Contains all the platform info to be stored
 OCPlatformInfo platformInfo;
@@ -286,6 +287,14 @@ OCStackResult SetDeviceInfo()
         return result;
     }
 
+    result = OCPlatform::setPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_PROTOCOL_INDEPENDENT_ID,
+                                          protocolIndependentID);
+    if (result != OC_STACK_OK)
+    {
+        cout << "Failed to set piid" << endl;
+        return result;
+    }
+
     return OC_STACK_OK;
 }
 
@@ -316,6 +325,7 @@ int main()
     }
 
     result = SetDeviceInfo();
+
     if (result != OC_STACK_OK)
     {
         std::cout << "Device Registration failed\n";
index 07e8f51..8295401 100644 (file)
@@ -60,6 +60,7 @@ std::string  systemTime = "2016-01-15T11.01";
 std::string  deviceName = "IoTivity Room Server";
 std::string  specVersion = "core.1.1.0";
 std::vector<std::string> dataModelVersions = {"res.1.1.0"};
+std::string  protocolIndependentID = "ac1b42a7-0518-448f-9b11-bfe328837bbf";
 
 // OCPlatformInfo Contains all the platform info to be stored
 OCPlatformInfo platformInfo;
@@ -618,6 +619,14 @@ OCStackResult SetDeviceInfo()
         return result;
     }
 
+    result = OCPlatform::setPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_PROTOCOL_INDEPENDENT_ID,
+                                          protocolIndependentID);
+    if (result != OC_STACK_OK)
+    {
+        cout << "Failed to set piid" << endl;
+        return result;
+    }
+
     return OC_STACK_OK;
 }
 
index 04c7649..6185e3d 100644 (file)
@@ -69,6 +69,7 @@ std::string  deviceName = "IoTivity Simple Server";
 std::string  deviceType = "oic.wk.tv";
 std::string  specVersion = "core.1.1.0";
 std::vector<std::string> dataModelVersions = {"res.1.1.0", "sh.1.1.0"};
+std::string  protocolIndependentID = "fa008167-3bbf-4c9d-8604-c9bcb96cb712";
 
 // OCPlatformInfo Contains all the platform info to be stored
 OCPlatformInfo platformInfo;
@@ -573,6 +574,14 @@ OCStackResult SetDeviceInfo()
         return result;
     }
 
+    result = OCPlatform::setPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_PROTOCOL_INDEPENDENT_ID,
+                                          protocolIndependentID);
+    if (result != OC_STACK_OK)
+    {
+        cout << "Failed to set piid" << endl;
+        return result;
+    }
+
     return OC_STACK_OK;
 }
 
@@ -678,6 +687,7 @@ int main(int argc, char* argv[])
     }
 
     result = SetDeviceInfo();
+
     if (result != OC_STACK_OK)
     {
         std::cout << "Device Registration failed\n";
index e4db483..013dbd9 100644 (file)
@@ -65,6 +65,7 @@ std::string  systemTime = "2016-01-15T11.01";
 std::string  deviceName = "IoTivity Simple Server HQ";
 std::string  specVersion = "core.1.1.0";
 std::vector<std::string> dataModelVersions = {"res.1.1.0"};
+std::string  protocolIndependentID = "88b3584f-d7bc-4e56-9210-0e8b305202c3";
 
 // OCPlatformInfo Contains all the platform info to be stored
 OCPlatformInfo platformInfo;
@@ -500,6 +501,14 @@ OCStackResult SetDeviceInfo()
         return result;
     }
 
+    result = OCPlatform::setPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_PROTOCOL_INDEPENDENT_ID,
+                                          protocolIndependentID);
+    if (result != OC_STACK_OK)
+    {
+        cout << "Failed to set piid" << endl;
+        return result;
+    }
+
     return OC_STACK_OK;
 }
 
@@ -558,6 +567,7 @@ int main(int argc, char* argv[])
     }
 
     result = SetDeviceInfo();
+
     if (result != OC_STACK_OK)
     {
         std::cout << "Device Registration failed\n";
index 05c497d..5a26944 100644 (file)
@@ -802,12 +802,15 @@ namespace OCPlatformTest
         OCDeviceInfo deviceInfo;
         DuplicateString(&deviceInfo.deviceName, "myDeviceName");
         deviceInfo.types = NULL;
-        OCResourcePayloadAddStringLL(&deviceInfo.types, "oic.wk.d");
+        OCResourcePayloadAddStringLL(&deviceInfo.types, OC_RSRVD_RESOURCE_TYPE_DEVICE);
         OCResourcePayloadAddStringLL(&deviceInfo.types, "oic.d.tv");
         DuplicateString(&deviceInfo.specVersion, "mySpecVersion");
         deviceInfo.dataModelVersions = nullptr;
         OCResourcePayloadAddStringLL(&deviceInfo.dataModelVersions, "myDataModelVersions");
         EXPECT_EQ(OC_STACK_OK, OCPlatform::registerDeviceInfo(deviceInfo));
+        EXPECT_EQ(OC_STACK_OK, OCPlatform::setPropertyValue(
+            PAYLOAD_TYPE_DEVICE, OC_RSRVD_PROTOCOL_INDEPENDENT_ID,
+            "bda0e016-fe64-41dc-871e-c7e94cc143b9"));
         EXPECT_NO_THROW(DeleteDeviceInfo(deviceInfo));
     }
 
@@ -829,6 +832,8 @@ namespace OCPlatformTest
         dmv.push_back("myDataModelVersions");
         EXPECT_EQ(OC_STACK_OK, OCPlatform::setPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_DATA_MODEL_VERSION,
             dmv));
+        EXPECT_EQ(OC_STACK_OK, OCPlatform::setPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_PROTOCOL_INDEPENDENT_ID,
+            "99a74220-73d3-426f-8397-3c06d586a865"));
         OCResourceHandle handle = OCGetResourceHandleAtUri(OC_RSRVD_DEVICE_URI);
         ASSERT_TRUE(NULL != handle);
         EXPECT_EQ(OC_STACK_OK, OCBindResourceTypeToResource(handle, "oic.wk.tv"));
index ba5b29f..f2e2df5 100644 (file)
@@ -64,6 +64,7 @@ namespace OCRepresentationEncodingTest
     TEST(DeviceDiscoveryEncoding, Normal)
     {
         sid1 = OCGetServerInstanceIDString();
+        static const char piid1[] = "e987b8f5-527a-454e-98c1-1eef2e5f1cf5";
         const char devicename1[] = "device name";
         OCRepPayload *device = OCRepPayloadCreate();
         EXPECT_TRUE(device);
@@ -72,6 +73,7 @@ namespace OCRepresentationEncodingTest
         EXPECT_TRUE(OCRepPayloadSetPropString(device, OC_RSRVD_DEVICE_ID, sid1));
         EXPECT_TRUE(OCRepPayloadSetPropString(device, OC_RSRVD_DEVICE_NAME, devicename1));
         EXPECT_TRUE(OCRepPayloadSetPropString(device, OC_RSRVD_SPEC_VERSION, OC_SPEC_VERSION));
+        EXPECT_TRUE(OCRepPayloadSetPropString(device, OC_RSRVD_PROTOCOL_INDEPENDENT_ID, piid1));
         EXPECT_TRUE(OCRepPayloadSetPropString(device, "x.org.iotivity.newproperty", "value"));
 
         size_t dim[MAX_REP_ARRAY_DEPTH] = {1, 0, 0};
@@ -94,6 +96,9 @@ namespace OCRepresentationEncodingTest
         EXPECT_TRUE(OCRepPayloadGetPropString(parsedRep, OC_RSRVD_DEVICE_ID, &value));
         EXPECT_STREQ(sid1, value);
         OICFree(value);
+        EXPECT_TRUE(OCRepPayloadGetPropString(parsedRep, OC_RSRVD_PROTOCOL_INDEPENDENT_ID, &value));
+        EXPECT_STREQ(piid1, value);
+        OICFree(value);
         EXPECT_TRUE(OCRepPayloadGetPropString(parsedRep, OC_RSRVD_DEVICE_NAME, &value));
         EXPECT_STREQ(devicename1, value);
         OICFree(value);
@@ -108,7 +113,7 @@ namespace OCRepresentationEncodingTest
         EXPECT_STREQ(OC_DATA_MODEL_VERSION, dmv[0]);
         OICFree(dmv[0]);
         OICFree(dmv);
-        EXPECT_STREQ("oic.wk.d", parsedRep->types->value);
+        EXPECT_STREQ(OC_RSRVD_RESOURCE_TYPE_DEVICE, parsedRep->types->value);
         EXPECT_STREQ("oic.d.tv", parsedRep->types->next->value);
         EXPECT_EQ(device->base.type, parsedRep->base.type);
 
@@ -133,6 +138,7 @@ namespace OCRepresentationEncodingTest
         EXPECT_TRUE(OCRepPayloadAddResourceType(device, "oic.d.tv"));
         EXPECT_TRUE(OCRepPayloadSetPropString(device, OC_RSRVD_DEVICE_NAME, devicename1));
         EXPECT_TRUE(OCRepPayloadSetPropString(device, OC_RSRVD_DEVICE_ID, sid1));
+        EXPECT_TRUE(OCRepPayloadSetPropString(device, OC_RSRVD_PROTOCOL_INDEPENDENT_ID, piid1));
         EXPECT_TRUE(OCRepPayloadSetPropString(device, OC_RSRVD_SPEC_VERSION, OC_SPEC_VERSION));
         size_t dim1[MAX_REP_ARRAY_DEPTH] = {2, 0, 0};
         char **dt1 = (char **)OICMalloc(sizeof(char *) * 2);
index a02c24d..576cc33 100644 (file)
@@ -398,7 +398,8 @@ void setDeviceInfo()
 {
     try
     {
-        SimulatorManager::getInstance()->setDeviceInfo("IoTivity Simulator Linux Sample");
+        SimulatorManager::getInstance()->setDeviceInfo("IoTivity Simulator Linux Sample",
+                                                       "c49f7cba-3b3d-490b-9d3f-d4f17a3dad26");
         std::cout << "Setting Device Info is successful" << std::endl;
     }
     catch (InvalidArgsException &e)
index 2ebb10a..53d22c9 100644 (file)
@@ -162,6 +162,16 @@ class SimulatorManager
         void setDeviceInfo(const std::string &deviceName);
 
         /**
+         * API for registering device information with stack.
+         *
+         * @param deviceName - Device name to be registered.
+         * @param protocolIndependentID - Protocol-independent UUID to be registered.
+         *
+         * NOTE: API throws @InvalidArgsException and @SimulatorException on error.
+         */
+        void setDeviceInfo(const std::string &deviceName, const std::string &protocolIndependentID);
+
+        /**
          * API for getting platform information from remote device.
          * Received platform information will be notified through the callback set using
          * @callback parameter.
index a5b135e..b5f8b07 100644 (file)
@@ -328,6 +328,28 @@ Java_org_oic_simulator_SimulatorManager_nativeSetDeviceInfo
 }
 
 JNIEXPORT void JNICALL
+Java_org_oic_simulator_SimulatorManager_nativeSetDeviceInfo2
+(JNIEnv *env, jobject /*object*/, jstring jDeviceName, jstring jProtocolIndependentID)
+{
+    VALIDATE_INPUT(env, !jDeviceName, "Device name is null!")
+
+    try
+    {
+        JniString jniDeviceName(env, jDeviceName);
+        JniString jniProtocolIndependentID(env, jProtocolIndependentID);
+        SimulatorManager::getInstance()->setDeviceInfo(jniDeviceName.get(), jniProtocolIndependentID.get());
+    }
+    catch (InvalidArgsException &e)
+    {
+        ThrowInvalidArgsException(env, e.code(), e.what());
+    }
+    catch (SimulatorException &e)
+    {
+        ThrowSimulatorException(env, e.code(), e.what());
+    }
+}
+
+JNIEXPORT void JNICALL
 Java_org_oic_simulator_SimulatorManager_nativeFindDevices
 (JNIEnv *env, jobject /*object*/, jstring jHostUri, jobject jListener)
 {
index ed20a9c..a3351d5 100644 (file)
@@ -153,6 +153,8 @@ public class SimulatorManager {
     /**
      * API to set the device information.
      *
+     * @deprecated Use setDeviceInfo2 instead.
+     *
      * @param deviceInfo
      *            Device information.
      *
@@ -167,6 +169,24 @@ public class SimulatorManager {
     }
 
     /**
+     * API to set the device information.
+     *
+     * @param deviceInfo
+     *            Device information.
+     * @param protocolIndependentID
+     *            Protocol-independent UUID of the device.
+     *
+     * @throws InvalidArgsException
+     *             Thrown if the input parameter is empty.
+     * @throws SimulatorException
+     *             Thrown for other errors.
+     */
+    public static void setDeviceInfo2(String deviceInfo, String protocolIndependentID)
+            throws InvalidArgsException, SimulatorException {
+        nativeSetDeviceInfo2(deviceInfo, protocolIndependentID);
+    }
+
+    /**
      * API to search for devices on the given host in the network.
      *
      * @param hostUri
@@ -248,6 +268,8 @@ public class SimulatorManager {
             FindResourceListener listener);
 
     private static native void nativeSetDeviceInfo(String deviceInfo);
+    private static native void nativeSetDeviceInfo2(String deviceInfo,
+            String protocolIndependentID);
 
     private static native void nativeFindDevices(String hostUri,
             DeviceListener listener);
index 2f0fb29..789fd39 100644 (file)
@@ -184,6 +184,19 @@ void SimulatorManager::setDeviceInfo(const std::string &deviceName)
                      ocDeviceInfo);
 }
 
+void SimulatorManager::setDeviceInfo(const std::string &deviceName, const std::string &protocolIndependentID)
+{
+    setDeviceInfo(deviceName);
+
+    typedef OCStackResult (*SetPropertyValue)(OCPayloadType, const std::string&,
+                                              const std::string&);
+
+    invokeocplatform(static_cast<SetPropertyValue>(OC::OCPlatform::setPropertyValue),
+                     PAYLOAD_TYPE_DEVICE,
+                     OC_RSRVD_PROTOCOL_INDEPENDENT_ID,
+                     protocolIndependentID.c_str());
+}
+
 void SimulatorManager::getPlatformInfo(const std::string &host, PlatformInfoCallback callback)
 {
     VALIDATE_CALLBACK(callback)