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>
Thu, 24 Nov 2016 04:10:10 +0000 (04:10 +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>
(cherry picked from commit 531eb849bb6cd36510ecd83194268a1f304e85a9)
Reviewed-on: https://gerrit.iotivity.org/gerrit/14665

resource/csdk/security/provisioning/src/ownershiptransfermanager.c

index 499ac30..5a06faf 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;