From: DoHyun Pyun Date: Mon, 10 Jun 2019 05:17:01 +0000 (+0900) Subject: Add the public API to get the remote client's MTU value X-Git-Tag: submit/tizen/20190611.064259^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0f458ee418460abae973a5a29e4c1b59b5baeec9;p=platform%2Fcore%2Fapi%2Fbluetooth.git Add the public API to get the remote client's MTU value Change-Id: I40f0a927245488913a525aea03a53ff42e9877d6 Signed-off-by: DoHyun Pyun --- diff --git a/include/bluetooth.h b/include/bluetooth.h index 917b902..2bdfb0a 100644 --- a/include/bluetooth.h +++ b/include/bluetooth.h @@ -5243,6 +5243,24 @@ int bt_gatt_server_foreach_services(bt_gatt_server_h server, bt_gatt_foreach_cb callback, void *user_data); +/** + * @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 diff --git a/src/bluetooth-gatt.c b/src/bluetooth-gatt.c index 8cadcd5..350e510 100644 --- a/src/bluetooth-gatt.c +++ b/src/bluetooth-gatt.c @@ -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) { diff --git a/test/bt_unit_test.c b/test/bt_unit_test.c index 45b462a..852773c 100644 --- a/test/bt_unit_test.c +++ b/test/bt_unit_test.c @@ -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; diff --git a/test/bt_unit_test.h b/test/bt_unit_test.h index 404f347..58ebf9a 100644 --- a/test/bt_unit_test.h +++ b/test/bt_unit_test.h @@ -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,