summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKush <kush.agrawal@samsung.com>2020-01-22 18:50:46 +0530
committerDoHyun Pyun <dh79.pyun@samsung.com>2020-01-30 10:54:17 +0900
commitbc8c98b075bd33aa1fb42a9f6c7058887100195d (patch)
tree0846b82f7fb3ec6df75777c7e0e4e4d70edbb804
parent962ac894c7957698134f9ccf953637849a034191 (diff)
downloadiotivity-bc8c98b075bd33aa1fb42a9f6c7058887100195d.tar.gz
iotivity-bc8c98b075bd33aa1fb42a9f6c7058887100195d.tar.bz2
iotivity-bc8c98b075bd33aa1fb42a9f6c7058887100195d.zip
CONPRO-1551 Adding support for LE bi directional request.
Issue : Currently Tizen LE Server only supports sending response and LE Client supports sending request and response for response. But in some scenarios if server tries to send request using same BLE connection, then that is not possible. Solution: This patch will allow LE server to send Request using same BLE connection https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/pull/654 (cherry-picked from af41fb6485fdb0bb02bfd92e6e4993a0b1596a36) Change-Id: Ie2a0bb3add5e56565d0059ac2d42dfd68336c958 Signed-off-by: Kush <kush.agrawal@samsung.com> Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
-rwxr-xr-xresource/csdk/connectivity/api/cacommon.h4
-rw-r--r--resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c33
2 files changed, 34 insertions, 3 deletions
diff --git a/resource/csdk/connectivity/api/cacommon.h b/resource/csdk/connectivity/api/cacommon.h
index 002794cb4..d1e53f75f 100755
--- a/resource/csdk/connectivity/api/cacommon.h
+++ b/resource/csdk/connectivity/api/cacommon.h
@@ -403,7 +403,9 @@ typedef enum
CA_RESPONSE_DATA,
CA_ERROR_DATA,
CA_RESPONSE_FOR_RES,
- CA_NETWORK_COMMAND
+ CA_NETWORK_COMMAND,
+ CA_REQUEST_DATA_SERVER_INIT,
+ CA_RESPONSE_DATA_CLIENT_INIT
} CADataType_t;
typedef enum
diff --git a/resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c b/resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c
index d3245f0b5..4d9bf62cf 100644
--- a/resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c
+++ b/resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c
@@ -117,6 +117,11 @@ static char g_localBLEAddress[18] = { 0 };
*/
static CABLEAdapter_t g_adapterType = ADAPTER_EMPTY;
+/**
+ * Variable to define current adapter type.
+ */
+static CABLEAdapter_t g_currentDeviceRole = ADAPTER_EMPTY;
+
#ifdef __WITH_DTLS__
static CADataType_t g_dataType = CA_REQUEST_DATA;
#endif
@@ -2772,9 +2777,18 @@ static int32_t CASendLEUnicastData(const CAEndpoint_t *endpoint,
OIC_LOG(ERROR, CALEADAPTER_TAG, "g_adapterType is Empty");
}
+ if(dataType == CA_REQUEST_DATA && g_currentDeviceRole == ADAPTER_SERVER){
+ OIC_LOG(DEBUG, CALEADAPTER_TAG, "Request Message from server" );
+ dataType = CA_REQUEST_DATA_SERVER_INIT;
+ } else if (dataType == CA_RESPONSE_DATA && g_currentDeviceRole == ADAPTER_CLIENT) {
+ OIC_LOG(DEBUG, CALEADAPTER_TAG, "Response Message from client" );
+ dataType = CA_RESPONSE_DATA_CLIENT_INIT;
+ }
+
oc_mutex_lock(g_bleIsServerMutex);
if (ADAPTER_SERVER == g_adapterType ||
- (ADAPTER_BOTH_CLIENT_SERVER == g_adapterType && CA_RESPONSE_DATA == dataType))
+ (ADAPTER_BOTH_CLIENT_SERVER == g_adapterType && CA_RESPONSE_DATA == dataType) ||
+ (ADAPTER_BOTH_CLIENT_SERVER == g_adapterType && CA_REQUEST_DATA_SERVER_INIT== dataType))
{
#ifdef __WITH_DTLS__
if (endpoint && endpoint->flags & CA_SECURE)
@@ -2802,6 +2816,13 @@ static int32_t CASendLEUnicastData(const CAEndpoint_t *endpoint,
#else
result = CALEAdapterServerSendData(endpoint, data, dataLen);
#endif
+
+ if(g_currentDeviceRole == ADAPTER_EMPTY)
+ {
+ OIC_LOG(INFO, CALEADAPTER_TAG, "Setting current device role as server" );
+ g_currentDeviceRole = ADAPTER_SERVER;
+ }
+
if (CA_STATUS_OK != result)
{
oc_mutex_unlock(g_bleIsServerMutex);
@@ -2816,7 +2837,8 @@ static int32_t CASendLEUnicastData(const CAEndpoint_t *endpoint,
}
else 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))
+ (ADAPTER_BOTH_CLIENT_SERVER == g_adapterType && CA_RESPONSE_FOR_RES == dataType) ||
+ (ADAPTER_BOTH_CLIENT_SERVER == g_adapterType && CA_RESPONSE_DATA_CLIENT_INIT== dataType))
{
#ifdef __WITH_DTLS__
if (endpoint && endpoint->flags & CA_SECURE)
@@ -2844,6 +2866,13 @@ static int32_t CASendLEUnicastData(const CAEndpoint_t *endpoint,
#else
result = CALEAdapterClientSendData(endpoint, data, dataLen);
#endif
+
+ if(g_currentDeviceRole == ADAPTER_EMPTY)
+ {
+ OIC_LOG(INFO, CALEADAPTER_TAG, "Setting current device role as client" );
+ g_currentDeviceRole = ADAPTER_CLIENT;
+ }
+
if (CA_STATUS_OK != result)
{
oc_mutex_unlock(g_bleIsServerMutex);