Add the public API to get the remote client's MTU value 17/207617/4 accepted/tizen/unified/20190612.111707 submit/tizen/20190611.064259
authorDoHyun Pyun <dh79.pyun@samsung.com>
Mon, 10 Jun 2019 05:17:01 +0000 (14:17 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Mon, 10 Jun 2019 23:39:59 +0000 (08:39 +0900)
Change-Id: I40f0a927245488913a525aea03a53ff42e9877d6
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
include/bluetooth.h
src/bluetooth-gatt.c
test/bt_unit_test.c
test/bt_unit_test.h

index 917b902..2bdfb0a 100644 (file)
@@ -5244,6 +5244,24 @@ int bt_gatt_server_foreach_services(bt_gatt_server_h server,
 
 
 /**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE
+ * @brief Gets the ATT MTU value set for a connection.
+ * @since_tizen 5.5
+ *
+ * @param[in] remote_address The address of the remote Bluetooth device
+ * @param[out] mtu The MTU value set for a connection
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #BT_ERROR_NONE  Successful
+ * @retval #BT_ERROR_NOT_SUPPORTED     Not supported
+ * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
+ * @retval #BT_ERROR_NOT_ENABLED  Not enabled
+ * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
+ */
+int bt_gatt_server_get_device_mtu(const char *remote_address, unsigned int *mtu);
+
+/**
  * @WEARABLE_ONLY
  * @ingroup CAPI_NETWORK_BLUETOOTH_PBAP_MODULE
  * @brief Initializes the Bluetooth PBAP Client.
index 8cadcd5..350e510 100644 (file)
@@ -3286,6 +3286,31 @@ int bt_gatt_server_get_service(bt_gatt_server_h server, const char *uuid,
        return ret;
 }
 
+int bt_gatt_server_get_device_mtu(const char *remote_address, unsigned int *mtu)
+{
+       bluetooth_device_address_t addr_hex = { {0,} };
+       int ret;
+       unsigned int mtu_value = 0;
+
+       BT_CHECK_GATT_SERVER_SUPPORT();
+       BT_CHECK_INIT_STATUS();
+       BT_CHECK_INPUT_PARAMETER(remote_address);
+
+       _bt_convert_address_to_hex(&addr_hex, remote_address);
+
+       ret = _bt_get_error_code(bluetooth_get_att_mtu(&addr_hex, &mtu_value));
+
+       if (ret != BT_ERROR_NONE) {
+               BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
+               return ret;
+       }
+
+       *mtu = mtu_value;
+
+       return ret;
+
+}
+
 int bt_gatt_server_foreach_services(bt_gatt_server_h server,
                bt_gatt_foreach_cb callback, void *user_data)
 {
index 45b462a..852773c 100644 (file)
@@ -610,6 +610,8 @@ tc_table_t tc_gatt[] = {
                , BT_UNIT_TEST_FUNCTION_GATT_SERVER_UNREGISTER_ALL_SERVICES},
        {"bt_gatt_server_foreach_services"
                , BT_UNIT_TEST_FUNCTION_GATT_SERVER_FOREACH_SERVICES},
+       {"bt_gatt_server_get_device_mtu"
+               , BT_UNIT_TEST_FUNCTION_GATT_SERVER_GET_DEVICE_MTU},
        {"Register Battery Service"
                , BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_BATTERY_SVC},
        {"Change Battery Level"
@@ -6846,6 +6848,12 @@ int test_input_callback(void *data)
                        TC_PRT("bt_gatt_server_foreach_services: %s\n", __bt_get_error_message(ret));
                        break;
                }
+               case BT_UNIT_TEST_FUNCTION_GATT_SERVER_GET_DEVICE_MTU: {
+                       unsigned int mtu = 0;
+                       ret = bt_gatt_server_get_device_mtu(remote_addr, &mtu);
+                       TC_PRT("returns %s, MTU %d\n", __bt_get_error_message(ret), mtu);
+                       break;
+               }
                case BT_UNIT_TEST_FUNCTION_ANCS_PAIR: {
                        bt_device_connection_link_type_e link_type = BT_DEVICE_CONNECTION_LINK_LE;
 
index 404f347..58ebf9a 100644 (file)
@@ -256,6 +256,7 @@ typedef enum {
        BT_UNIT_TEST_FUNCTION_GATT_SERVER_DEINITIALIZE,
        BT_UNIT_TEST_FUNCTION_GATT_SERVER_UNREGISTER_ALL_SERVICES,
        BT_UNIT_TEST_FUNCTION_GATT_SERVER_FOREACH_SERVICES,
+       BT_UNIT_TEST_FUNCTION_GATT_SERVER_GET_DEVICE_MTU,
        BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_BATTERY_SVC,
        BT_UNIT_TEST_FUNCTION_GATT_SERVER_CHANGE_BATTERY_LEVEL,
        BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_HEART_RATE_SVC,