Replace tizen BLE internal APIs with public 33/176633/1
authorVeeraj Khokale <veeraj.sk@samsung.com>
Thu, 12 Apr 2018 11:07:33 +0000 (16:37 +0530)
committerAmit KS <amit.s12@samsung.com>
Fri, 20 Apr 2018 09:37:06 +0000 (15:07 +0530)
Tizen 4.0 build fails in case BLE internal API's are used,
therefore replace them with public API's. All changes are
made under the preprocess define TIZEN_4

https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/pull/282
(cherry picked from commit d66f237dc92c15a515332d0416f769d8e856bfe9)

Change-Id: I2cd45780dbc29d83fbf7f69e758245cde0fe7f2a
Signed-off-by: Veeraj Khokale <veeraj.sk@samsung.com>
Signed-off-by: Amit KS <amit.s12@samsung.com>
build_common/SConscript
resource/csdk/connectivity/src/bt_edr_adapter/tizen/caedrclient.c
resource/csdk/connectivity/src/bt_le_adapter/tizen/caleclient.h
resource/csdk/connectivity/src/bt_le_adapter/tizen/calenwmonitor.c
resource/csdk/connectivity/src/bt_le_adapter/tizen/calenwmonitor_vd.c
resource/csdk/connectivity/src/bt_le_adapter/tizen/caleserver.h
resource/csdk/connectivity/src/bt_le_adapter/tizen/caleserver_mcd.c
resource/csdk/connectivity/src/bt_le_adapter/tizen/caleserver_vd.c
resource/csdk/connectivity/util/src/camanager/bt_le_manager/tizen/caleconnectionmanager.c

index e16a27d..95268aa 100644 (file)
@@ -131,6 +131,7 @@ help_vars.Add(EnumVariable('WITH_UPSTREAM_LIBCOAP', 'Use latest stable version o
 help_vars.Add(EnumVariable('BLE_CUSTOM_ADV', 'Build with CUSTOM Advertisement', 'False', allowed_values=('True', 'False')))
 help_vars.Add(EnumVariable('BLE_DIVISION', 'BLE Build with division code', 'OFF', allowed_values=('OFF', 'MCD', 'VD')))
 help_vars.Add(EnumVariable('BLE_TIZEN_30', 'Build with tizen 3.0 BLE api', 'False', allowed_values=('True', 'False')))
+help_vars.Add(EnumVariable('TIZEN_4', 'Build with tizen 4.0 api', 'False', allowed_values=('True', 'False')))
 help_vars.Add(PathVariable('TIZENRT_OS_DIR', 'Absolute Path to TizenRT OS directory', None, PathVariable.PathAccept))
 help_vars.Add(EnumVariable('PLATFORM_TLS', 'Use platform tls instead of local mbedtls', '0', allowed_values=('0', '1')))
 help_vars.Add(EnumVariable('OIC_SUPPORT_TIZEN_TRACE', 'Tizen Trace(T-trace) api availability', 'False', allowed_values=('True', 'False')))
index 0173190..49384b4 100644 (file)
@@ -27,8 +27,6 @@
 
 #include <string.h>
 #include <bluetooth.h>
-#include <bluetooth_internal.h>
-
 #include "caedrinterface.h"
 #include "octhread.h"
 #include "caedrendpoint.h"
index 6372429..e967513 100644 (file)
@@ -33,9 +33,6 @@
 
 #include <bluetooth.h>
 #include <bluetooth_type.h>
-#include <bluetooth_type_internal.h>
-#include <bluetooth_internal.h>
-
 #include "cacommon.h"
 #include "caadapterutils.h"
 #include "caleutil.h"
index 9f2a527..5c4ef44 100644 (file)
@@ -30,7 +30,6 @@
 #include <netinet/in.h>
 
 #include <bluetooth.h>
-#include <bluetooth_internal.h>
 #include <bluetooth_type.h>
 
 #include "octhread.h"
index ae755bd..feae225 100644 (file)
@@ -30,7 +30,6 @@
 #include <netinet/in.h>
 
 #include <bluetooth.h>
-#include <bluetooth_internal.h>
 #include <bluetooth_type.h>
 
 #include "octhread.h"
index f310885..e8687fa 100644 (file)
@@ -33,7 +33,6 @@
 
 #include <bluetooth.h>
 #include <bluetooth_type.h>
-#include <bluetooth_internal.h>
 #ifdef BLE_MCD
 #include <bluetooth_product.h>
 #endif
index 9aa398b..46c914c 100644 (file)
@@ -27,6 +27,9 @@
 #include "oic_string.h"
 #include "oic_malloc.h"
 #include "caleutil.h"
+#ifndef TIZEN_4
+#include <bluetooth_internal.h>
+#endif
 
 /**
  * Logging tag for module name
@@ -1103,14 +1106,44 @@ uint16_t CALEServerGetMtuSize(const char* address)
     OIC_LOG(DEBUG, TAG, "IN");
     VERIFY_NON_NULL_RET(address, TAG, "address is null", CA_DEFAULT_BLE_MTU_SIZE);
 
-    unsigned int mtu;
-    int ret = bt_device_get_att_mtu(address, &mtu);
+    unsigned int mtu = CA_DEFAULT_BLE_MTU_SIZE;
+    int ret = 0;
+
+#ifdef TIZEN_4
+    bt_gatt_client_h client = NULL;
+    ret = bt_gatt_client_create(address, &client);
+    if (0 != ret)
+    {
+        OIC_LOG_V(ERROR, TAG,
+                  "bt_gatt_client_create failed with return [%s]", CALEGetErrorMsg(ret));
+        return CA_DEFAULT_BLE_MTU_SIZE;
+    }
+
+    ret = bt_gatt_client_get_att_mtu(client, &mtu);
+    if (0 != ret)
+    {
+        OIC_LOG_V(ERROR, TAG,
+                  "bt_gatt_client_get_att_mtu failed with return [%s]", CALEGetErrorMsg(ret));
+        return CA_DEFAULT_BLE_MTU_SIZE;
+    }
+
+    ret = bt_gatt_client_destroy(client);
+    if (0 != ret)
+    {
+        OIC_LOG_V(ERROR, TAG,
+                  "bt_gatt_client_destroy failed with return [%s]", CALEGetErrorMsg(ret));
+        return CA_DEFAULT_BLE_MTU_SIZE;
+    }
+#else
+    ret = bt_device_get_att_mtu(address, &mtu);
     if (0 != ret)
     {
         OIC_LOG_V(ERROR, TAG,
                   "bt_device_get_att_mtu failed with return [%s]", CALEGetErrorMsg(ret));
         return CA_DEFAULT_BLE_MTU_SIZE;
     }
+#endif // TIZEN_4
+
     OIC_LOG_V(INFO, TAG, "mtu size(including header) from bt_device_get_att_mtu is %d", mtu);
     OIC_LOG(DEBUG, TAG, "OUT");
     return mtu - CA_BLE_MTU_HEADER_SIZE;
index cc6f208..6a52aed 100755 (executable)
 #include "oic_malloc.h"
 #include "caleutil.h"
 #include "caadapterutils.h"
+#include <glib.h>
+#ifndef TIZEN_4
+#include <bluetooth_internal.h>
+#endif
 
 /**
  * Logging tag for module name
@@ -1036,14 +1040,44 @@ uint16_t CALEServerGetMtuSize(const char* address)
     OIC_LOG(DEBUG, TAG, "IN");
     VERIFY_NON_NULL_RET(address, TAG, "address is null", CA_DEFAULT_BLE_MTU_SIZE);
 
-    unsigned int mtu;
-    int ret = bt_device_get_att_mtu(address, &mtu);
+    unsigned int mtu = CA_DEFAULT_BLE_MTU_SIZE;
+    int ret = 0;
+
+#ifdef TIZEN_4
+    bt_gatt_client_h client = NULL;
+    ret = bt_gatt_client_create(address, &client);
+    if (0 != ret)
+    {
+        OIC_LOG_V(ERROR, TAG,
+                  "bt_gatt_client_create failed with return [%s]", CALEGetErrorMsg(ret));
+        return CA_DEFAULT_BLE_MTU_SIZE;
+    }
+
+    ret = bt_gatt_client_get_att_mtu(client, &mtu);
+    if (0 != ret)
+    {
+        OIC_LOG_V(ERROR, TAG,
+                  "bt_gatt_client_get_att_mtu failed with return [%s]", CALEGetErrorMsg(ret));
+        return CA_DEFAULT_BLE_MTU_SIZE;
+    }
+
+    ret = bt_gatt_client_destroy(client);
+    if (0 != ret)
+    {
+        OIC_LOG_V(ERROR, TAG,
+                  "bt_gatt_client_destroy failed with return [%s]", CALEGetErrorMsg(ret));
+        return CA_DEFAULT_BLE_MTU_SIZE;
+    }
+#else
+    ret = bt_device_get_att_mtu(address, &mtu);
     if (0 != ret)
     {
         OIC_LOG_V(ERROR, TAG,
                   "bt_device_get_att_mtu failed with return [%s]", CALEGetErrorMsg(ret));
         return CA_DEFAULT_BLE_MTU_SIZE;
     }
+#endif // TIZEN_4
+
     OIC_LOG_V(INFO, TAG, "mtu size(including header) from bt_device_get_att_mtu is %d", mtu);
     OIC_LOG(DEBUG, TAG, "OUT");
     return mtu - CA_BLE_MTU_HEADER_SIZE;