Address RI Code review comments
authorSakthivel Samidurai <sakthivel.samidurai@intel.com>
Mon, 23 Mar 2015 18:13:04 +0000 (11:13 -0700)
committerSashi Penta <sashi.kumar.penta@intel.com>
Tue, 24 Mar 2015 17:43:47 +0000 (17:43 +0000)
Remove duplicate code to convert qualityOfService to
CAMessageType.

Change-Id: Icfc7365587cd4306d619544acfa9e6e70bea5d8e
Signed-off-by: Sakthivel Samidurai <sakthivel.samidurai@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/537
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Erich Keane <erich.keane@intel.com>
Reviewed-by: Sashi Penta <sashi.kumar.penta@intel.com>
resource/csdk/stack/include/internal/ocstackinternal.h
resource/csdk/stack/src/ocserverrequest.c

index 5f0e2b1..a95a424 100644 (file)
@@ -201,6 +201,16 @@ OCStackResult CAResultToOCResult(CAResult_t caResult);
 // This is done automatically during the OCInit process (via the call to OCInitCoAP),
 // so ensure that this call is done after that.
 const char* OCGetServerInstanceIDString(void);
+
+/**
+ * Map OCQualityOfService to CAMessageType
+ *
+ * @param OCQualityOfService - Input qos.
+ *
+ * Returns CA message type for a given qos.
+ */
+CAMessageType_t qualityOfServiceToMessageType(OCQualityOfService qos);
+
 #ifdef WITH_PRESENCE
 //TODO: should the following function be public?
 OCStackResult OCChangeResourceProperty(OCResourceProperty * inputProperty,
index 56ab124..6c74095 100644 (file)
@@ -302,7 +302,6 @@ OCStackResult HandleSingleResponse(OCEntityHandlerResponse * ehResponse)
     responseEndpoint.addressInfo      = serverRequest->addressInfo;
     responseEndpoint.connectivityType = serverRequest->connectivityType;
     responseEndpoint.isSecured        = serverRequest->secured;
-
     // Copy the info
     switch (ehResponse->ehResult)
     {
@@ -328,27 +327,8 @@ OCStackResult HandleSingleResponse(OCEntityHandlerResponse * ehResponse)
             responseInfo.result = CA_BAD_REQ;
             break;
     }
-
-    switch (serverRequest->qos)
-    {
-        case OC_LOW_QOS:
-            responseInfo.info.type = CA_MSG_NONCONFIRM;
-            break;
-        case OC_MEDIUM_QOS:
-            responseInfo.info.type = CA_MSG_NONCONFIRM;
-            break;
-        case OC_HIGH_QOS:
-            responseInfo.info.type = CA_MSG_CONFIRM;
-            break;
-        case OC_NA_QOS:
-            responseInfo.info.type = CA_MSG_NONCONFIRM;
-            break;
-        default:
-            responseInfo.info.type = CA_MSG_NONCONFIRM;
-            break;
-    }
-
-    responseInfo.info.token = (CAToken_t)OCCalloc(1, CA_MAX_TOKEN_LEN+1);
+    responseInfo.info.type = qualityOfServiceToMessageType(serverRequest->qos);
+    responseInfo.info.token = (CAToken_t) OCCalloc(1, CA_MAX_TOKEN_LEN + 1);
     if (!responseInfo.info.token)
     {
         OC_LOG(FATAL, TAG, "Response Info Token is NULL");