* 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.
* @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.
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
{
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
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");
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;
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");
}
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);
}
}
+ 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;