[Easy Setup] Adding logs for OTM failure reason 29/22429/6
authorAbhishek Pandey <abhi.siso@samsung.com>
Tue, 12 Sep 2017 07:10:32 +0000 (12:40 +0530)
committerAshok Babu Channa <ashok.channa@samsung.com>
Fri, 15 Sep 2017 06:18:41 +0000 (06:18 +0000)
IOT-2703: https://jira.iotivity.org/browse/IOT-2703
[Easy Setup] Adding Ownership transfer failure reason logs

- Mapped failure due to Timeout to ESResult::ES_COMMUNICATION_ERROR.
- Added error logs for developers to know failure reason.
- Optimized for loop with a break when matching resource is found.

Signed-off-by: Abhishek Pandey <abhi.siso@samsung.com>
Change-Id: I0e1e0fce5834acc625347198497a9e420b54909c

service/easy-setup/mediator/richsdk/src/EnrolleeSecurity.cpp

index 956fa1b..a27c3a7 100644 (file)
@@ -542,8 +542,29 @@ namespace OIC
                                 res = ESResult::ES_AUTHENTICATION_FAILURE_WITH_WRONG_PIN;
                             }
                         }
+                        else if(OC_STACK_COMM_ERROR == result->at(i).res)
+                        {
+                            OIC_LOG(ERROR, ENROLEE_SECURITY_TAG,
+                                "OwnershipTransfer is failed with OC_STACK_COMM_ERROR");
+                            res = ESResult::ES_COMMUNICATION_ERROR;
+                        }
+                        else if(OC_STACK_TIMEOUT == result->at(i).res)
+                        {
+                            OIC_LOG(ERROR, ENROLEE_SECURITY_TAG,
+                                "OwnershipTransfer is failed with OC_STACK_TIMEOUT");
+                            res = ESResult::ES_COMMUNICATION_ERROR;
+                        }
+                        else if(OC_STACK_GATEWAY_TIMEOUT == result->at(i).res)
+                        {
+                            OIC_LOG(ERROR, ENROLEE_SECURITY_TAG,
+                                "OwnershipTransfer is failed with OC_STACK_GATEWAY_TIMEOUT");
+                            res = ESResult::ES_COMMUNICATION_ERROR;
+                        }
+
+                        break;
                     }
                 }
+
                 OIC_LOG_V(ERROR, ENROLEE_SECURITY_TAG, "OwnershipTransfer is failed with ESResult(%d)", res);
 
                 otmResult = false;
@@ -570,6 +591,8 @@ namespace OIC
                             OIC_LOG_V(ERROR, ENROLEE_SECURITY_TAG, "OwnershipTransfer is failed with code(%d)", hasError);
                             otmResult = false;
                         }
+
+                        break;
                     }
                 }
             }