Replace tizen BLE internal APIs with public 37/176637/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:09 +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: I451a6519edfaa792862819d59693500ff46b50ce
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 b373665dadef07e8bbbc25680c27af2545238ff4..4a608ce55de77479343c03327d229ad303315d5f 100644 (file)
@@ -130,6 +130,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 017319096a43f28713895c25b2d0fefcd70bb0d6..49384b4dd7b251d7918417ffe96eea10da80d989 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 63724290c5521b9572ccc78636e0e40f267cc4d8..e967513bc79f99c78bb47920690724fee6388fda 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 9f2a527910528b0071196056ebbe72d0b3a7a144..5c4ef44e41dc4a23c3959e8c8ee4cc367a05e14d 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 ae755bd30c68b4bdb03364073cc7dc0538c03056..feae2255a0d6bdf62c5d303ab2bae5530fe9d216 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 f310885a68b3fcb93b89253e9943da27a5236297..e8687facaf698ff213d055f0175c352f600ed49c 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 9aa398b76a2c68ae5e25c6b43448900698e9db05..46c914c8d3f521a10e8bea6e7e333f2d62e85bb5 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 cc6f2084cf678d4f2a2de2f9dfa4f4031bc57566..6a52aedbd064451d52809d59fe6cefc0dd0e5fd9 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;
index e831d56fcd3e9db8aec78d5b5de440b306179d0f..df46ccc715f5fc5a21cb59bb5857a81f20b37bcf 100644 (file)
@@ -20,8 +20,6 @@
 
 #include <bluetooth.h>
 #include <bluetooth_type.h>
-#include <bluetooth_internal.h>
-
 #include "camanagerleinterface.h"
 #include "cacommon.h"
 #include "camessagehandler.h"