Fixed bug for device status management in OTM.
authorChul Lee <chuls.lee@samsung.com>
Wed, 23 Nov 2016 08:33:10 +0000 (17:33 +0900)
committerRandeep Singh <randeep.s@samsung.com>
Wed, 23 Nov 2016 10:47:38 +0000 (10:47 +0000)
[Bug]
  1. Perform the OTM.
  2. Remove the device using OCRemoveDevice or OCRemoveDeviceWithUuid
  3. Initialize the server to unowned status.
  3. Perform the OTM again w/ same server.
     [Actual Result] Device UUID removed from PDM DB.
     [Expected result] Device UUID should be set to initial status.

Change-Id: Ie662ca6eeedfb5a98db4d97e020b61fbf331cb0e
Signed-off-by: Chul Lee <chuls.lee@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/14643
Reviewed-by: Uze Choi <uzchoi@samsung.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Jihun Ha <jihun.ha@samsung.com>
Reviewed-by: Randeep Singh <randeep.s@samsung.com>
resource/csdk/security/provisioning/src/ownershiptransfermanager.c

index 499ac304ffed5f8b18abf14366fcd2755e2b372e..5a06faf22d047b2cb0baecca0c3c476e76d55f9f 100644 (file)
@@ -1736,12 +1736,11 @@ static OCStackResult StartOwnershipTransfer(void* ctx, OCProvisionDev_t* selecte
         if(PDM_DEVICE_STALE == state)
         {
             OIC_LOG(INFO, TAG, "Detected duplicated UUID in stale status, "
-                               "this UUID will be removed from PDM");
-
-            res = PDMDeleteDevice(&selectedDevice->doxm->deviceID);
+                               "device status will revert back to initial status.");
+            res = PDMSetDeviceState(&selectedDevice->doxm->deviceID, PDM_DEVICE_INIT);
             if(OC_STACK_OK != res)
             {
-                OIC_LOG(ERROR, TAG, "Internal error in PDMDeleteDevice");
+                OIC_LOG(ERROR, TAG, "Internal error in PDMSetDeviceState");
                 OICFree(strUuid);
                 SetResult(otmCtx, res);
                 return res;