modified some flag to set Blockwise tranfer
authorjihwan.seo <jihwan.seo@samsung.com>
Fri, 31 Jul 2015 02:30:06 +0000 (11:30 +0900)
committerErich Keane <erich.keane@intel.com>
Wed, 5 Aug 2015 16:44:15 +0000 (16:44 +0000)
- unnecessary parameter was removed (payload, payloadSize)
- to add some flag related to enable BWT as per platform

Change-Id: I1606732073ba519a7655c430e0ef8bdc31a004d0
Signed-off-by: jihwan.seo <jihwan.seo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/2014
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Erich Keane <erich.keane@intel.com>
resource/csdk/connectivity/inc/caprotocolmessage.h
resource/csdk/connectivity/src/camessagehandler.c
resource/csdk/connectivity/src/caprotocolmessage.c

index 4110506..d97af0d 100644 (file)
@@ -53,9 +53,10 @@ typedef uint32_t code_t;
  * generates pdu structure from the given information.
  * @param[in]   code                 code of the pdu packet.
  * @param[in]   info                 pdu information.
+ * @param[in]   endpoint             endpoint information.
  * @return  generated pdu.
  */
-coap_pdu_t *CAGeneratePDU(uint32_t code, const CAInfo_t *info);
+coap_pdu_t *CAGeneratePDU(uint32_t code, const CAInfo_t *info, const CAEndpoint_t *endpoint);
 
 /**
  * extracts request information from received pdu.
@@ -86,11 +87,11 @@ CAResult_t CAGetErrorInfoFromPDU(const coap_pdu_t *pdu, CAErrorInfo_t *errorInfo
  * @param[in]   code                 request or response code.
  * @param[out]  options              options for the request and response.
  * @param[in]   info                 information to create pdu.
- * @param[in]   payload              payload for the request or response consumed.
+ * @param[in]   endpoint             endpoint information.
  * @return  generated pdu.
  */
 coap_pdu_t *CAGeneratePDUImpl(code_t code, coap_list_t *options, const CAInfo_t *info,
-                              const uint8_t *payload, size_t payloadSize);
+                              const CAEndpoint_t *endpoint);
 
 /**
  * parse the URI and creates the options.
index f596167..38b185d 100644 (file)
@@ -413,14 +413,14 @@ static CAResult_t CAProcessSendData(const CAData_t *data)
             OIC_LOG(DEBUG, TAG, "requestInfo is available..");
 
             info = &data->requestInfo->info;
-            pdu = CAGeneratePDU(data->requestInfo->method, info);
+            pdu = CAGeneratePDU(data->requestInfo->method, info, data->remoteEndpoint);
         }
         else if (NULL != data->responseInfo)
         {
             OIC_LOG(DEBUG, TAG, "responseInfo is available..");
 
             info = &data->responseInfo->info;
-            pdu = CAGeneratePDU(data->responseInfo->result, info);
+            pdu = CAGeneratePDU(data->responseInfo->result, info, data->remoteEndpoint);
         }
         else
         {
@@ -487,7 +487,7 @@ static CAResult_t CAProcessSendData(const CAData_t *data)
             OIC_LOG(DEBUG, TAG, "requestInfo is available..");
 
             info = &data->requestInfo->info;
-            pdu = CAGeneratePDU(CA_GET, info);
+            pdu = CAGeneratePDU(CA_GET, info, data->remoteEndpoint);
             if (NULL != pdu)
             {
 #ifdef WITH_BWT
index 2236c24..d6a48b7 100644 (file)
@@ -119,7 +119,7 @@ CAResult_t CAGetErrorInfoFromPDU(const coap_pdu_t *pdu, CAErrorInfo_t *errorInfo
     return ret;
 }
 
-coap_pdu_t *CAGeneratePDU(uint32_t code, const CAInfo_t *info)
+coap_pdu_t *CAGeneratePDU(uint32_t code, const CAInfo_t *info, const CAEndpoint_t *endpoint)
 {
     OIC_LOG(DEBUG, TAG, "IN");
 
@@ -130,7 +130,7 @@ coap_pdu_t *CAGeneratePDU(uint32_t code, const CAInfo_t *info)
     if (CA_MSG_RESET == info->type || (CA_EMPTY == code && CA_MSG_ACKNOWLEDGE == info->type))
     {
         OIC_LOG(DEBUG, TAG, "code is empty");
-        if (!(pdu = CAGeneratePDUImpl((code_t) code, NULL, info, NULL, 0)))
+        if (!(pdu = CAGeneratePDUImpl((code_t) code, NULL, info, endpoint)))
         {
             OIC_LOG(ERROR, TAG, "pdu NULL");
             return NULL;
@@ -187,7 +187,8 @@ coap_pdu_t *CAGeneratePDU(uint32_t code, const CAInfo_t *info)
             coap_delete_list(optlist);
             return NULL;
         }
-        pdu = CAGeneratePDUImpl((code_t) code, optlist, info, info->payload, info->payloadSize);
+
+        pdu = CAGeneratePDUImpl((code_t) code, optlist, info, endpoint);
         if (NULL == pdu)
         {
             OIC_LOG(ERROR, TAG, "pdu NULL");
@@ -238,7 +239,7 @@ coap_pdu_t *CAParsePDU(const char *data, uint32_t length, uint32_t *outCode)
 }
 
 coap_pdu_t *CAGeneratePDUImpl(code_t code, coap_list_t *options, const CAInfo_t *info,
-                              const uint8_t *payload, size_t payloadSize)
+                              const CAEndpoint_t *endpoint)
 {
     OIC_LOG(DEBUG, TAG, "IN");
     VERIFY_NON_NULL_RET(info, TAG, "info is NULL", NULL);
@@ -296,15 +297,19 @@ coap_pdu_t *CAGeneratePDUImpl(code_t code, coap_list_t *options, const CAInfo_t
         }
     }
 
+    bool enabledPayload = false;
 #ifndef WITH_BWT
-    if (NULL != payload)
+    enabledPayload = true;
+#endif
+
+    if (enabledPayload || CA_ADAPTER_GATT_BTLE == endpoint->adapter)
     {
-        coap_add_data(pdu, payloadSize, (const unsigned char *) payload);
+        if (NULL != info->payload)
+        {
+            OIC_LOG(DEBUG, TAG, "payload is added");
+            coap_add_data(pdu, info->payloadSize, (const unsigned char *) info->payload);
+        }
     }
-#else
-    (void)payload;
-    (void)payloadSize;
-#endif
 
     OIC_LOG(DEBUG, TAG, "OUT");
     return pdu;