Since BLE transport has gatt server and client.
there are two sender and receiver
such as notifyCharacteristic / writeCharacteristic in BLE transport.
(while other transport has only one sender and receiver.)
thur, message has to be sent by message type which whether
it is a request or response message.
Change-Id: I7f77d86c13115138082b72a6371ce5bd49f1f0c6
Signed-off-by: jihwan.seo <jihwan.seo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/9255
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Jaehong Jo <jaehong.jo@samsung.com>
Reviewed-by: Jon A. Cruz <jon@joncruz.org>
#endif
/**
- * IP address Length
+ * IP address Length.
*/
#define CA_IPADDR_SIZE 16
#define CA_RAJABBERID_SIZE 256
/**
- * Mac address length for BT port
+ * Mac address length for BT port.
*/
#define CA_MACADDR_SIZE 18
/**
- * Max header options data length
+ * Max header options data length.
*/
#define CA_MAX_HEADER_OPTION_DATA_LENGTH 20
/**
-* Max token length
+* Max token length.
*/
#define CA_MAX_TOKEN_LEN (8)
/**
- * Max URI length
+ * Max URI length.
*/
#ifdef ARDUINO
#define CA_MAX_URI_LENGTH 128 /* maximum size of URI for embedded platforms*/
#endif
/**
- * Max PDU length supported
+ * Max PDU length supported.
*/
#ifdef ARDUINO
#define COAP_MAX_PDU_SIZE 320 /* maximum size of a CoAP PDU for embedded platforms*/
#endif
/**
- *Maximum length of the remoteEndpoint identity
+ *Maximum length of the remoteEndpoint identity.
*/
#define CA_MAX_ENDPOINT_IDENTITY_LEN (32)
/**
- * option types - the highest option number 63
+ * option types - the highest option number 63.
*/
#define CA_OPTION_IF_MATCH 1
#define CA_OPTION_ETAG 4
#define CA_OPTION_LOCATION_QUERY 20
/**
- * Payload information from resource model
+ * Payload information from resource model.
*/
typedef uint8_t *CAPayload_t;
typedef char *CAURI_t;
/**
- * Token information for mapping the request and responses by resource model
+ * Token information for mapping the request and responses by resource model.
*/
typedef char *CAToken_t;
/*
- * Socket types and error definitions
+ * Socket types and error definitions.
*/
#ifdef HAVE_WINSOCK2_H
# define OC_SOCKET_ERROR SOCKET_ERROR
#define CA_SCOPE_MASK 0xf // mask scope bits above
/**
- * @enum CANetworkStatus_t
* Information about the network status.
*/
typedef enum
} CANetworkStatus_t;
/*
- * remoteEndpoint identity
+ * remoteEndpoint identity.
*/
typedef struct
{
} CARemoteId_t;
/**
- * @enum CAMessageType_t
- * Message Type for Base source code
+ * Message Type for Base source code.
*/
typedef enum
{
} CAMessageType_t;
/**
- * @enum CAMethod_t
- * Allowed method to be used by resource model
+ * Allowed method to be used by resource model.
*/
typedef enum
{
} CAMethod_t;
/**
- * block size
+ * block size.
* it depends on defined size in libCoAP.
*/
typedef enum
} CABlockSize_t;
/**
- * Endpoint information for connectivities
+ * Endpoint information for connectivities.
* Must be identical to OCDevAddr.
*/
typedef struct
} CAEndpoint_t;
/**
- * Endpoint information for secure messages
+ * Endpoint information for secure messages.
*/
typedef struct
{
} CASecureEndpoint_t;
/**
- * @enum CAResult_t
- * Enums for CA return values
+ * Enums for CA return values.
*/
typedef enum
{
} CAResult_t;
/**
- * @enum CAResponseResult_t
- * Enums for CA Response values
+ * Enums for CA Response values.
*/
typedef enum
{
} CAResponseResult_t;
/**
- * @enum CATransportProtocolID_t
- * Transport Protocol IDs for additional options
+ * Data type whether the data is Request Message or Response Message.
+ * if there is some failure before send data on network.
+ * Type will be set as error type for error callback.
+ */
+typedef enum
+{
+ CA_REQUEST_DATA = 1,
+ CA_RESPONSE_DATA,
+ CA_ERROR_DATA,
+ CA_RESPONSE_FOR_RES
+} CADataType_t;
+
+/**
+ * Transport Protocol IDs for additional options.
*/
typedef enum
{
} CATransportProtocolID_t;
/**
- * @enum CAAdapterState_t
* Adapter State to indicate the network changed notifications.
*/
typedef enum
} CAPayloadFormat_t;
/**
- * Header options structure to be filled
+ * Header options structure to be filled.
*
* This structure is used to hold header information.
*/
} CAHeaderOption_t;
/**
- * Base Information received
+ * Base Information received.
*
- * This structure is used to hold request & response base information
+ * This structure is used to hold request & response base information.
*/
typedef struct
{
CAPayloadFormat_t acceptFormat; /**< accept format for the response payload */
CAURI_t resourceUri; /**< Resource URI information **/
CARemoteId_t identity; /**< endpoint identity */
+ CADataType_t dataType; /**< data type */
} CAInfo_t;
/**
- * Request Information to be sent
+ * Request Information to be sent.
*
- * This structure is used to hold request information
+ * This structure is used to hold request information.
*/
typedef struct
{
} CARequestInfo_t;
/**
- * Response information received
+ * Response information received.
*
- * This structure is used to hold response information
+ * This structure is used to hold response information.
*/
typedef struct
{
/**
* Error information from CA
- * contains error code and message information
+ * contains error code and message information.
*
- * This structure holds error information
+ * This structure holds error information.
*/
typedef struct
{
} CAErrorInfo_t;
/**
- * Hold global variables for CA layer (also used by RI layer)
+ * Hold global variables for CA layer. (also used by RI layer)
*/
typedef struct
{
} CAHistory_t;
/**
- * Hold interface index for keeping track of comings and goings
+ * Hold interface index for keeping track of comings and goings.
*/
typedef struct
{
* reference uri and connectivity type) to which the unicast data has to be sent.
* @param[in] data Data which required to be sent.
* @param[in] dataLen Size of data to be sent.
+ * @param[in] dataType Data type which is REQUEST or RESPONSE.
* @return The number of bytes sent on the network. Return value equal to -1 indicates error.
*/
typedef int32_t (*CAAdapterSendUnicastData)(const CAEndpoint_t *endpoint,
- const void *data, uint32_t dataLen);
+ const void *data, uint32_t dataLen,
+ CADataType_t dataType);
/**
* Sends Multicast data to the endpoint using the adapter connectivity.
* @param[in] endpoint Remote Endpoint information (like ipaddress , port,
* @param[in] data Data which required to be sent.
* @param[in] dataLen Size of data to be sent.
+ * @param[in] dataType Data type which is REQUEST or RESPONSE.
* @return The number of bytes sent on the network. Return value equal to -1 indicates error.
*/
typedef int32_t (*CAAdapterSendMulticastData)(const CAEndpoint_t *endpoint,
- const void *data, uint32_t dataLen);
+ const void *data, uint32_t dataLen,
+ CADataType_t dataType);
/**
* Get Network Information.
* connectivity type) to which the unicast data has to be sent.
* @param[in] data Data to be sent.
* @param[in] dataLength Size of data to be sent.
+ * @param[in] dataType Data type which is REQUEST or RESPONSE.
* @return The number of bytes sent on the network. Returns -1 on error.
*
*/
int32_t CASendEDRUnicastData(const CAEndpoint_t *endpoint, const void *data,
- uint32_t dataLength);
+ uint32_t dataLength, CADataType_t dataType);
/**
* Sends multicast data to all discovered bluetooth OIC devices using the adapter.
* @param[in] endpoint Remote Endpoint information (like ipaddress, port, and connectivity.
* @param[in] data Data which needs to be sent to all discovered bluetooth OIC device.
* @param[in] dataLength Length of data in bytes.
+ * @param[in] dataType Data type which is REQUEST or RESPONSE.
* @return Number of bytes sent on the network. Returns -1 on error.
*/
int32_t CASendEDRMulticastData(const CAEndpoint_t *endpoint, const void *data,
- uint32_t dataLength);
+ uint32_t dataLength, CADataType_t dataType);
/**
* Get EDR Connectivity network information.
* @param[in] endpoint endpoint information where the data has to be sent.
* @param[in] data data that needs to be sent.
* @param[in] length length of the data that needs to be sent.
+ * @param[in] dataType Data type which is REQUEST or RESPONSE.
* @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
*/
-CAResult_t CASendUnicastData(const CAEndpoint_t *endpoint, const void *data, uint32_t length);
+CAResult_t CASendUnicastData(const CAEndpoint_t *endpoint, const void *data,
+ uint32_t length, CADataType_t dataType);
/**
* Sends multicast data to all endpoints in the network.
* @param[in] endpoint endpoint information where the data has to be sent.
* @param[in] data data that needs to be sent.
* @param[in] length length of the data that needs to be sent.
+ * @param[in] dataType Data type which is REQUEST or RESPONSE.
* @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
*/
-CAResult_t CASendMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t length);
+CAResult_t CASendMulticastData(const CAEndpoint_t *endpoint, const void *data,
+ uint32_t length, CADataType_t dataType);
/**
* Start listening servers to receive search requests from clients.
* which the unicast data has to be sent.
* @param[in] data Data which is required to be sent.
* @param[in] dataLen Size of data to be sent.
+ * @param[in] dataType Data type which is REQUEST or RESPONSE.
* @note dataLen must be > 0.
* @return The number of bytes sent on the network, or -1 upon error.
*/
int32_t CASendIPUnicastData(const CAEndpoint_t *endpoint, const void *data,
- uint32_t dataLen);
+ uint32_t dataLen, CADataType_t dataType);
/**
* Send Multicast data to the endpoint using the IP connectivity.
* port)
* @param[in] data Data which is required to be sent.
* @param[in] dataLen Size of data to be sent.
+ * @param[in] dataType Data type which is REQUEST or RESPONSE.
* @note dataLen must be > 0.
* @return The number of bytes sent on the network, or -1 upon error.
*/
-int32_t CASendIPMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t dataLen);
+int32_t CASendIPMulticastData(const CAEndpoint_t *endpoint, const void *data,
+ uint32_t dataLen, CADataType_t dataType);
/**
* Get IP Connectivity network information.
SEND_TYPE_UNICAST
} CASendDataType_t;
-typedef enum
-{
- CA_REQUEST_DATA = 1,
- CA_RESPONSE_DATA = 2,
- CA_ERROR_DATA = 3,
-} CADataType_t;
-
typedef struct
{
CASendDataType_t type;
* @param[in] endpoint Remote Endpoint information.\r
* @param[in] data data to be sent.\r
* @param[in] dataLen Size of data to be sent.\r
+ * @param[in] dataType Data type which is REQUEST or RESPONSE.\r
* @return number of bytes sent on the network. Return value equal to -1 indicates error.\r
* @remark dataLen must be > 0.\r
*/\r
int32_t CASendNFCUnicastData(const CAEndpoint_t *endpoint, const void *data,\r
- uint32_t dataLen);\r
+ uint32_t dataLen, CADataType_t dataType);\r
\r
/**\r
* Send Multicast data to the endpoint using the NFC connectivity.\r
* @param[in] endpoint Remote Endpoint information.\r
* @param[in] data Data which is required to be sent.\r
* @param[in] dataLen Size of data to be sent.\r
+ @param[in] dataType Data type which is REQUEST or RESPONSE.\r
* @return number of bytes sent on the network. Return value equal to -1 indicates error.\r
* @remark dataLen must be > 0.\r
*/\r
-int32_t CASendNFCMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t dataLen);\r
+int32_t CASendNFCMulticastData(const CAEndpoint_t *endpoint, const void *data,\r
+ uint32_t dataLen, CADataType_t dataType);\r
\r
/**\r
* Get NFC Connectivity network information\r
* the unicast data has to be sent.
* @param[in] data Data which is required to be sent.
* @param[in] dataLen Size of data to be sent.
+ * @param[in] dataType Data type which is REQUEST or RESPONSE.
* @note dataLen must be > 0.
* @return The number of bytes sent on the network, or -1 upon error.
*/
int32_t CASendRAUnicastData(const CAEndpoint_t *endpoint, const void *data,
- uint32_t dataLen);
+ uint32_t dataLen, CADataType_t dataType);
/**
* Get RA Connectivity network information.
* These functions are not applicable to Remote Access adapter.
*/
int32_t CASendRAMulticastData(const CAEndpoint_t *endpoint,
- const void *data, uint32_t dataLen);
+ const void *data, uint32_t dataLen, CADataType_t dataType);
/**
* Start listening server for receiving search requests.
/** retransmission data send method type. **/
typedef CAResult_t (*CADataSendMethod_t)(const CAEndpoint_t *endpoint,
const void *pdu,
- uint32_t size);
+ uint32_t size,
+ CADataType_t dataType);
/** retransmission timeout callback type. **/
typedef void (*CATimeoutCallback_t)(const CAEndpoint_t *endpoint,
* process the retransmission data.
* @param[in] context context for retransmission.
* @param[in] endpoint endpoint information.
+ * @param[in] dataType Data type which is REQUEST or RESPONSE.
* @param[in] pdu sent pdu binary data.
* @param[in] size sent pdu binary data size.
* @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
*/
-CAResult_t CARetransmissionSentData(CARetransmission_t* context,
- const CAEndpoint_t* endpoint,
- const void* pdu, uint32_t size);
+CAResult_t CARetransmissionSentData(CARetransmission_t *context,
+ const CAEndpoint_t *endpoint,
+ CADataType_t dataType,
+ const void *pdu, uint32_t size);
/**
* Pass the received pdu data. if received pdu is ACK data for the retransmission CON data,
* which the unicast data has to be sent.
* @param[in] data Data which is required to be sent.
* @param[in] dataLen Size of data to be sent.
+ * @param[in] dataType Data type which is REQUEST or RESPONSE.
* @note dataLen must be > 0.
* @return The number of bytes sent on the network, or -1 upon error.
*/
int32_t CASendTCPUnicastData(const CAEndpoint_t *endpoint,
- const void *data, uint32_t dataLen);
+ const void *data, uint32_t dataLen,
+ CADataType_t dataType);
/**
* Send Multicast data to the endpoint using the TCP connectivity.
* port)
* @param[in] data Data which is required to be sent.
* @param[in] dataLen Size of data to be sent.
+ * @param[in] dataType Data type which is REQUEST or RESPONSE.
* @note dataLen must be > 0.
* @return The number of bytes sent on the network, or -1 upon error.
*/
int32_t CASendTCPMulticastData(const CAEndpoint_t *endpoint,
- const void *data, uint32_t dataLen);
+ const void *data, uint32_t dataLen,
+ CADataType_t dataType);
/**
* Get TCP Connectivity network information.
}
int32_t CASendEDRUnicastData(const CAEndpoint_t *remoteEndpoint, const void *data,
- uint32_t dataLength)
+ uint32_t dataLength, CADataType_t dataType)
{
// Input validation
VERIFY_NON_NULL_RET(remoteEndpoint, TAG, "Remote endpoint is null", -1);
VERIFY_NON_NULL_RET(data, TAG, "Data is null", -1);
+ (void)dataType;
if (0 == dataLength)
{
return sentLength;
}
-int32_t CASendEDRMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t dataLength)
+int32_t CASendEDRMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t dataLength,
+ CADataType_t dataType)
{
OIC_LOG(DEBUG, TAG, "IN - CASendEDRMulticastData");
+ (void)dataType;
// Input validation
VERIFY_NON_NULL_RET(data, TAG, "Data is null", -1);
*/
static int32_t CASendLEUnicastData(const CAEndpoint_t *endpoint,
const void *data,
- uint32_t dataLen);
+ uint32_t dataLen,
+ CADataType_t dataType);
/**
* Send multicast data to the endpoint using the LE connectivity.
*/
static int32_t CASendLEMulticastData(const CAEndpoint_t *endpoint,
const void *data,
- uint32_t dataLen);
+ uint32_t dataLen,
+ CADataType_t dataType);
/**
* Get LE Connectivity network information.
static int32_t CASendLEUnicastData(const CAEndpoint_t *endpoint,
const void *data,
- uint32_t dataLen)
+ uint32_t dataLen,
+ CADataType_t dataType)
{
- OIC_LOG(DEBUG, CALEADAPTER_TAG, "IN - CASendLEUnicastData");
+ OIC_LOG_V(DEBUG, CALEADAPTER_TAG, "IN - CASendLEUnicastData : type(%d)", dataType);
//Input validation
VERIFY_NON_NULL_RET(endpoint, CALEADAPTER_TAG, "Remote endpoint is null", -1);
}
ca_mutex_lock(g_bleIsServerMutex);
- if (ADAPTER_SERVER == g_adapterType || ADAPTER_BOTH_CLIENT_SERVER == g_adapterType)
+ if (ADAPTER_SERVER == g_adapterType ||
+ (ADAPTER_BOTH_CLIENT_SERVER == g_adapterType && CA_RESPONSE_DATA == dataType))
{
result = CALEAdapterServerSendData(endpoint, data, dataLen);
if (CA_STATUS_OK != result)
}
}
- if (ADAPTER_CLIENT == g_adapterType || ADAPTER_BOTH_CLIENT_SERVER == g_adapterType)
+ if (ADAPTER_CLIENT == g_adapterType ||
+ (ADAPTER_BOTH_CLIENT_SERVER == g_adapterType && CA_REQUEST_DATA == dataType) ||
+ (ADAPTER_BOTH_CLIENT_SERVER == g_adapterType && CA_RESPONSE_FOR_RES == dataType))
{
result = CALEAdapterClientSendData(endpoint, data, dataLen);
if (CA_STATUS_OK != result)
static int32_t CASendLEMulticastData(const CAEndpoint_t *endpoint,
const void *data,
- uint32_t dataLen)
+ uint32_t dataLen,
+ CADataType_t dataType)
{
OIC_LOG(DEBUG, CALEADAPTER_TAG, "IN - CASendLEMulticastData");
}
ca_mutex_lock(g_bleIsServerMutex);
- if (ADAPTER_SERVER == g_adapterType || ADAPTER_BOTH_CLIENT_SERVER == g_adapterType)
+ if (ADAPTER_SERVER == g_adapterType ||
+ (ADAPTER_BOTH_CLIENT_SERVER == g_adapterType && CA_RESPONSE_DATA == dataType))
{
result = CALEAdapterServerSendData(NULL, data, dataLen);
if (CA_STATUS_OK != result)
}
}
- if (ADAPTER_CLIENT == g_adapterType || ADAPTER_BOTH_CLIENT_SERVER == g_adapterType)
+ if (ADAPTER_CLIENT == g_adapterType ||
+ (ADAPTER_BOTH_CLIENT_SERVER == g_adapterType && CA_REQUEST_DATA == dataType) ||
+ (ADAPTER_BOTH_CLIENT_SERVER == g_adapterType && CA_RESPONSE_FOR_RES == dataType))
{
result = CALEAdapterClientSendData(NULL, data, dataLen);
if (CA_STATUS_OK != result)
return CA_STATUS_NOT_INITIALIZED;
}
- if (responseInfo && responseInfo->isMulticast &&
+ if (!responseInfo || !object)
+ {
+ return CA_STATUS_INVALID_PARAM;
+ }
+
+ if (responseInfo->isMulticast &&
(object->adapter == CA_DEFAULT_ADAPTER || object->adapter == CA_ALL_ADAPTERS))
{
- return CASendMessageMultiAdapter(object, responseInfo, CA_RESPONSE_DATA);
+ return CASendMessageMultiAdapter(object, responseInfo, responseInfo->info.dataType);
}
else
{
- return CADetachSendMessage(object, responseInfo, CA_RESPONSE_DATA);
+ return CADetachSendMessage(object, responseInfo, responseInfo->info.dataType);
}
}
return CA_MEMORY_ALLOC_FAILED;
}
-CAResult_t CASendUnicastData(const CAEndpoint_t *endpoint, const void *data, uint32_t length)
+CAResult_t CASendUnicastData(const CAEndpoint_t *endpoint, const void *data, uint32_t length,
+ CADataType_t dataType)
{
if (endpoint == NULL)
{
if (NULL != g_adapterHandler[index].sendData)
{
OIC_LOG(DEBUG, TAG, "unicast message to adapter");
- sentDataLen = g_adapterHandler[index].sendData(endpoint, data, length);
+ sentDataLen = g_adapterHandler[index].sendData(endpoint, data, length, dataType);
}
if (sentDataLen != (int32_t)length)
return CA_STATUS_OK;
}
-CAResult_t CASendMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t length)
+CAResult_t CASendMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t length,
+ CADataType_t dataType)
{
u_arraylist_t *list = CAGetSelectedNetworkList();
if (!list)
return CA_MEMORY_ALLOC_FAILED;
}
memcpy(payload, data, length);
- sentDataLen = g_adapterHandler[index].sendDataToAll(endpoint, payload, length);
+ sentDataLen = g_adapterHandler[index].sendDataToAll(endpoint, payload, length, dataType);
OICFree(payload);
}
OIC_LOG(DEBUG, TAG, "pdu to send :");
OIC_LOG_BUFFER(DEBUG, TAG, (uint8_t*)pdu->hdr, pdu->length);
- res = CASendMulticastData(data->remoteEndpoint, pdu->hdr, pdu->length);
+ res = CASendMulticastData(data->remoteEndpoint, pdu->hdr, pdu->length, data->dataType);
if (CA_STATUS_OK != res)
{
OIC_LOG_V(ERROR, TAG, "send failed:%d", res);
#endif // WITH_BWT
CALogPDUInfo(pdu, data->remoteEndpoint);
- res = CASendUnicastData(data->remoteEndpoint, pdu->hdr, pdu->length);
+ OIC_LOG_V(INFO, TAG, "CASendUnicastData type : %d", data->dataType);
+ res = CASendUnicastData(data->remoteEndpoint, pdu->hdr, pdu->length, data->dataType);
if (CA_STATUS_OK != res)
{
OIC_LOG_V(ERROR, TAG, "send failed:%d", res);
#endif
{
// for retransmission
- res = CARetransmissionSentData(&g_retransmissionContext, data->remoteEndpoint,
+ res = CARetransmissionSentData(&g_retransmissionContext,
+ data->remoteEndpoint,
+ data->dataType,
pdu->hdr, pdu->length);
if ((CA_STATUS_OK != res) && (CA_NOT_SUPPORTED != res))
{
cadata->type = request->isMulticast ? SEND_TYPE_MULTICAST : SEND_TYPE_UNICAST;
cadata->requestInfo = request;
}
- else if (CA_RESPONSE_DATA == dataType)
+ else if (CA_RESPONSE_DATA == dataType || CA_RESPONSE_FOR_RES == dataType)
{
// clone response info
CAResponseInfo_t *response = CACloneResponseInfo((CAResponseInfo_t *)sendData);
#endif
uint8_t triedCount; /**< retransmission count */
uint16_t messageId; /**< coap PDU message id */
+ CADataType_t dataType; /**< data Type (Request/Response) */
CAEndpoint_t *endpoint; /**< remote endpoint */
void *pdu; /**< coap PDU */
uint32_t size; /**< coap PDU size */
{
OIC_LOG_V(DEBUG, TAG, "retransmission CON data!!, msgid=%d",
retData->messageId);
- context->dataSendMethod(retData->endpoint, retData->pdu, retData->size);
+ context->dataSendMethod(retData->endpoint, retData->pdu,
+ retData->size, retData->dataType);
}
// #3. increase the retransmission count and update timestamp.
CAResult_t CARetransmissionSentData(CARetransmission_t *context,
const CAEndpoint_t *endpoint,
+ CADataType_t dataType,
const void *pdu, uint32_t size)
{
if (NULL == context || NULL == endpoint || NULL == pdu)
retData->endpoint = remoteEndpoint;
retData->pdu = pduData;
retData->size = size;
+ retData->dataType = dataType;
#ifndef SINGLE_THREAD
// mutex lock
ca_mutex_lock(context->threadMutex);
}
int32_t CASendIPUnicastData(const CAEndpoint_t *endpoint,
- const void *data, uint32_t dataLength)
+ const void *data, uint32_t dataLength,
+ CADataType_t dataType)
{
+ (void)dataType;
return CAQueueIPData(false, endpoint, data, dataLength);
}
-int32_t CASendIPMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t dataLength)
+int32_t CASendIPMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t dataLength,
+ CADataType_t dataType)
{
+ (void)dataType;
return CAQueueIPData(true, endpoint, data, dataLength);
}
}
-int32_t CASendNFCUnicastData(const CAEndpoint_t *endpoint, const void *data, uint32_t dataLength)
+int32_t CASendNFCUnicastData(const CAEndpoint_t *endpoint, const void *data, uint32_t dataLength,
+ CADataType_t dataType)
{
+ (void)dataType;
return CAQueueNFCData(endpoint, data, dataLength);
}
-int32_t CASendNFCMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t dataLength)
+int32_t CASendNFCMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t dataLength,
+ CADataType_t dataType)
{
+ (void)dataType;
return CAQueueNFCData(endpoint, data, dataLength);
}
}
int32_t CASendRAUnicastData(const CAEndpoint_t *remoteEndpoint, const void *data,
- uint32_t dataLength)
+ uint32_t dataLength, CADataType_t dataType)
{
+ SET_BUT_NOT_USED(dataType);
+
if (!remoteEndpoint || !data)
{
OIC_LOG(ERROR, RA_ADAPTER_TAG, "Invalid parameter!");
}
int32_t CASendRAMulticastData(const CAEndpoint_t *endpoint,
- const void *data, uint32_t dataLength)
+ const void *data, uint32_t dataLength,
+ CADataType_t dataType)
{
OIC_LOG(INFO, RA_ADAPTER_TAG, "RA adapter does not support sending multicast data");
SET_BUT_NOT_USED(endpoint);
SET_BUT_NOT_USED(data);
SET_BUT_NOT_USED(dataLength);
+ SET_BUT_NOT_USED(dataType);
return 0;
}
}
int32_t CASendRAUnicastData(const CAEndpoint_t *remoteEndpoint, const void *data,
- uint32_t dataLength)
+ uint32_t dataLength, CADataType_t dataType)
{
+ (void)dataType;
if (!remoteEndpoint || !data)
{
OIC_LOG(ERROR, RA_ADAPTER_TAG, "Invalid parameter!");
}
int32_t CASendRAMulticastData(const CAEndpoint_t *endpoint,
- const void *data, uint32_t dataLength)
+ const void *data, uint32_t dataLength,
+ CADataType_t dataType)
{
OIC_LOG(INFO, RA_ADAPTER_TAG, "RA adapter does not support sending multicast data");
return 0;
}
int32_t CASendTCPUnicastData(const CAEndpoint_t *endpoint,
- const void *data, uint32_t dataLength)
+ const void *data, uint32_t dataLength,
+ CADataType_t dataType)
{
OIC_LOG(DEBUG, TAG, "IN");
+ (void)dataType;
#ifndef SINGLE_THREAD
return CAQueueTCPData(false, endpoint, data, dataLength);
#else
}
int32_t CASendTCPMulticastData(const CAEndpoint_t *endpoint,
- const void *data, uint32_t dataLength)
+ const void *data, uint32_t dataLength,
+ CADataType_t dataType)
{
+ (void)dataType;
return CAQueueTCPData(true, endpoint, data, dataLength);
}
responseData.type = CA_MSG_RESET;
responseData.messageId = 1;
responseData.payload = (CAPayload_t)malloc(sizeof("response payload"));
+ responseData.dataType = CA_RESPONSE_DATA;
EXPECT_TRUE(responseData.payload != NULL);
responseData.type = CA_MSG_NONCONFIRM;
responseData.messageId = 1;
responseData.payload = (CAPayload_t)malloc(sizeof("response payload"));
+ responseData.dataType = CA_RESPONSE_DATA;
EXPECT_TRUE(responseData.payload != NULL);
if(!responseData.payload)
responseData.type = CA_MSG_NONCONFIRM;
responseData.messageId = 1;
responseData.payload = (CAPayload_t)malloc(sizeof("response payload"));
+ responseData.dataType = CA_RESPONSE_DATA;
EXPECT_TRUE(responseData.payload != NULL);
if(!responseData.payload)
OCStackResult SendDirectStackResponse(const CAEndpoint_t* endPoint, const uint16_t coapID,
const CAResponseResult_t responseResult, const CAMessageType_t type,
const uint8_t numOptions, const CAHeaderOption_t *options,
- CAToken_t token, uint8_t tokenLength, const char *resourceUri);
+ CAToken_t token, uint8_t tokenLength, const char *resourceUri,
+ CADataType_t dataType);
#ifdef WITH_PRESENCE
if(responseInfo->info.type == CA_MSG_CONFIRM)
{
SendDirectStackResponse(endPoint, responseInfo->info.messageId, CA_EMPTY,
- CA_MSG_ACKNOWLEDGE, 0, NULL, NULL, 0, NULL);
+ CA_MSG_ACKNOWLEDGE, 0, NULL, NULL, 0, NULL, CA_RESPONSE_FOR_RES);
}
OCPayloadDestroy(response.payload);
{
OIC_LOG(INFO, TAG, "Received a message without callbacks. Sending RESET");
SendDirectStackResponse(endPoint, responseInfo->info.messageId, CA_EMPTY,
- CA_MSG_RESET, 0, NULL, NULL, 0, NULL);
+ CA_MSG_RESET, 0, NULL, NULL, 0, NULL, CA_RESPONSE_FOR_RES);
}
}
OCStackResult SendDirectStackResponse(const CAEndpoint_t* endPoint, const uint16_t coapID,
const CAResponseResult_t responseResult, const CAMessageType_t type,
const uint8_t numOptions, const CAHeaderOption_t *options,
- CAToken_t token, uint8_t tokenLength, const char *resourceUri)
+ CAToken_t token, uint8_t tokenLength, const char *resourceUri,
+ CADataType_t dataType)
{
OIC_LOG(DEBUG, TAG, "Entering SendDirectStackResponse");
CAResponseInfo_t respInfo = {
respInfo.info.type = type;
respInfo.info.resourceUri = OICStrdup (resourceUri);
respInfo.info.acceptFormat = CA_FORMAT_UNDEFINED;
+ respInfo.info.dataType = dataType;
#if defined (ROUTING_GATEWAY) || defined (ROUTING_EP)
// Add the destination to route option from the endpoint->routeData.
SendDirectStackResponse(endPoint, requestInfo->info.messageId, CA_BAD_REQ,
requestInfo->info.type, requestInfo->info.numOptions,
requestInfo->info.options, requestInfo->info.token,
- requestInfo->info.tokenLength, requestInfo->info.resourceUri);
+ requestInfo->info.tokenLength, requestInfo->info.resourceUri,
+ CA_RESPONSE_DATA);
OICFree(serverRequest.payload);
return;
}
SendDirectStackResponse(endPoint, requestInfo->info.messageId, CA_INTERNAL_SERVER_ERROR,
requestInfo->info.type, requestInfo->info.numOptions,
requestInfo->info.options, requestInfo->info.token,
- requestInfo->info.tokenLength, requestInfo->info.resourceUri);
+ requestInfo->info.tokenLength, requestInfo->info.resourceUri,
+ CA_RESPONSE_DATA);
OICFree(serverRequest.payload);
return;
}
SendDirectStackResponse(endPoint, requestInfo->info.messageId, CA_BAD_OPT,
requestInfo->info.type, requestInfo->info.numOptions,
requestInfo->info.options, requestInfo->info.token,
- requestInfo->info.tokenLength, requestInfo->info.resourceUri);
+ requestInfo->info.tokenLength, requestInfo->info.resourceUri,
+ CA_RESPONSE_DATA);
OICFree(serverRequest.payload);
OICFree(serverRequest.requestToken);
return;
if (requestInfo->info.type == CA_MSG_CONFIRM)
{
SendDirectStackResponse(endPoint, requestInfo->info.messageId, CA_EMPTY,
- CA_MSG_ACKNOWLEDGE,0, NULL, NULL, 0, NULL);
+ CA_MSG_ACKNOWLEDGE,0, NULL, NULL, 0, NULL,
+ CA_RESPONSE_DATA);
}
}
else if(!OCResultToSuccess(requestResult))
SendDirectStackResponse(endPoint, requestInfo->info.messageId, stackResponse,
requestInfo->info.type, requestInfo->info.numOptions,
requestInfo->info.options, requestInfo->info.token,
- requestInfo->info.tokenLength, requestInfo->info.resourceUri);
+ requestInfo->info.tokenLength, requestInfo->info.resourceUri,
+ CA_RESPONSE_DATA);
}
// requestToken is fed to HandleStackRequests, which then goes to AddServerRequest.
// The token is copied in there, and is thus still owned by this function.
SendDirectStackResponse(endPoint, requestInfo->info.messageId, result, requestInfo->info.type,
requestInfo->info.numOptions, requestInfo->info.options,
requestInfo->info.token, requestInfo->info.tokenLength,
- requestInfo->info.resourceUri);
+ requestInfo->info.resourceUri, CA_RESPONSE_DATA);
return OC_STACK_OK;
}
SendDirectStackResponse(endPoint, requestInfo->info.messageId, CA_CHANGED, requestInfo->info.type,
requestInfo->info.numOptions, requestInfo->info.options,
requestInfo->info.token, requestInfo->info.tokenLength,
- requestInfo->info.resourceUri);
+ requestInfo->info.resourceUri, CA_RESPONSE_DATA);
return OC_STACK_OK;
}