Publish GATT MTU Exchange APIs to Native public API 82/119882/13
authorDoHyun Pyun <dh79.pyun@samsung.com>
Mon, 20 Mar 2017 10:57:05 +0000 (19:57 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Wed, 5 Apr 2017 23:24:31 +0000 (08:24 +0900)
Change-Id: Id1a134752e8c383a5d307ecffd89c48b5b803b19
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
include/bluetooth.h
include/bluetooth_internal.h
include/bluetooth_private.h
include/bluetooth_type.h
include/bluetooth_type_internal.h
src/bluetooth-common.c
src/bluetooth-device.c
src/bluetooth-gatt.c
test/bt_unit_test.c
test/bt_unit_test.h

index c00934951171f6445d98d49a17ea0e4905b65841..cfd257a2eb0d50154a748d283a009863009a2750 100644 (file)
@@ -4815,6 +4815,87 @@ int bt_gatt_client_read_value(bt_gatt_h gatt_handle,
 int bt_gatt_client_write_value(bt_gatt_h gatt_handle,
                bt_gatt_client_request_completed_cb callback, void *user_data);
 
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE
+ * @brief Requests a change of the ATT MTU value.
+ * @since_tizen 4.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/bluetooth
+ *
+ * @param[in] client The created GATT client's handle
+ * @param[in] mtu The new MTU value
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #BT_ERROR_NONE  Successful
+ * @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
+ * @retval #BT_ERROR_PERMISSION_DENIED  Permission denied
+ * @retval #BT_ERROR_NOT_SUPPORTED  Not supported
+ * @see bt_gatt_client_set_att_mtu_changed_cb()
+ */
+int bt_gatt_client_request_att_mtu_change(bt_gatt_client_h client, unsigned int mtu);
+
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE
+ * @brief Gets the ATT MTU value set for a connection.
+ * @since_tizen 4.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/bluetooth
+ *
+ * @param[in] client The created GATT client's handle
+ * @param[ot] 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_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
+ * @retval #BT_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #BT_ERROR_NOT_SUPPORTED     Not supported
+ */
+int bt_gatt_client_get_att_mtu(bt_gatt_client_h client, unsigned int *mtu);
+
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE
+ * @brief  Registers a callback function to be invoked when the ATT MTU is changed.
+ * @since_tizen 4.0
+ * @param[in] client The created GATT client's handle
+ * @param[in] callback The callback function to register
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #BT_ERROR_NONE  Successful
+ * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
+ * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #BT_ERROR_NOT_SUPPORTED  Not supported
+ *
+ * @pre The Bluetooth service must be initialized with bt_initialize().
+ * @post bt_device_connection_state_changed_cb() will be invoked.
+ * @see bt_initialize()
+ * @see bt_gatt_client_request_att_mtu_change()
+ * @see bt_gatt_client_unset_att_mtu_changed_cb()
+ */
+int bt_gatt_client_set_att_mtu_changed_cb(bt_gatt_client_h client, bt_gatt_client_att_mtu_changed_cb callback, void *user_data);
+
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE
+ * @brief Unregisters the callback function to be invoked when the ATT MTU is changed.
+ * @since_tizen 4.0
+ * @param[in] client The created GATT client's handle
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #BT_ERROR_NONE  Successful
+ * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
+ * @retval #BT_ERROR_NOT_SUPPORTED  Not supported
+ *
+ * @pre The Bluetooth service must be initialized with bt_initialize().
+ * @see bt_initialize()
+ * @see bt_gatt_client_request_att_mtu_change()
+ * @see bt_gatt_client_set_att_mtu_changed_cb()
+ */
+int bt_gatt_client_unset_att_mtu_changed_cb(bt_gatt_client_h client);
+
 /**
  * @ingroup  CAPI_NETWORK_BLUETOOTH_GATT_MODULE
  * @brief  Registers a callback function to be invoked when the characteristic value is changed on the remote device.
index 977746d57f950e1987008c071f0f8a31af5f205f..eebc80f911d443569f2d86a075af50e3ac6a178c 100644 (file)
@@ -947,6 +947,7 @@ int bt_device_set_trusted_profile_cb(bt_device_trusted_profiles_cb callback, voi
 int bt_device_unset_trusted_profile_cb(void);
 
 /**
+ * @deprecated Deprecated since 4.0. Use bt_gatt_client_request_att_mtu_change instead.
  * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
  * @brief Request to change ATT MTU value
  * @since_tizen 3.0
@@ -965,9 +966,10 @@ int bt_device_unset_trusted_profile_cb(void);
  * @retval #BT_ERROR_PERMISSION_DENIED  Permission denied
  * @retval #BT_ERROR_NOT_SUPPORTED  Not supported
  */
-int bt_device_request_att_mtu(const char *remote_address, unsigned int mtu);
+int bt_device_request_att_mtu(const char *remote_address, unsigned int mtu) TIZEN_DEPRECATED_API;
 
 /**
+ * @deprecated Deprecated since 4.0. Use bt_gatt_client_get_att_mtu instead.
  * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
  * @brief Gets the ATT MTU value set for a connection
  * @since_tizen 3.0
@@ -986,9 +988,10 @@ int bt_device_request_att_mtu(const char *remote_address, unsigned int mtu);
  * @retval #BT_ERROR_PERMISSION_DENIED Permission denied
  * @retval #BT_ERROR_NOT_SUPPORTED     Not supported
  */
-int bt_device_get_att_mtu(const char *remote_address, unsigned int *mtu);
+int bt_device_get_att_mtu(const char *remote_address, unsigned int *mtu) TIZEN_DEPRECATED_API;
 
 /**
+ * @deprecated Deprecated since 4.0. Use bt_gatt_client_set_att_mtu_changed_cb instead.
  * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
  * @brief  Registers a callback function to be invoked when the ATT MTU is changed.
  * @since_tizen 3.0
@@ -1005,9 +1008,10 @@ int bt_device_get_att_mtu(const char *remote_address, unsigned int *mtu);
  * @see bt_initialize()
  * @see bt_device_unset_att_mtu_changed_cb()
  */
-int bt_device_set_att_mtu_changed_cb(bt_device_att_mtu_changed_cb callback, void *user_data);
+int bt_device_set_att_mtu_changed_cb(bt_device_att_mtu_changed_cb callback, void *user_data) TIZEN_DEPRECATED_API;
 
 /**
+ * @deprecated Deprecated since 4.0. Use bt_gatt_client_unset_att_mtu_changed_cb instead.
  * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
  * @brief      Unregisters the callback function to be invoked when the ATT MTU is changed.
  * @since_tizen 3.0
@@ -1020,7 +1024,7 @@ int bt_device_set_att_mtu_changed_cb(bt_device_att_mtu_changed_cb callback, void
  * @see bt_initialize()
  * @see bt_device_set_att_mtu_changed_cb()
  */
-int bt_device_unset_att_mtu_changed_cb(void);
+int bt_device_unset_att_mtu_changed_cb(void) TIZEN_DEPRECATED_API;
 
 /**
  * @internal
index 5e911f8cbfc5ffd202a8e8b66194c88a3a97fa89..6d32366563bdd27098dd81f3fc6d3037f1eb9dd5 100644 (file)
@@ -311,8 +311,10 @@ typedef struct {
        bool services_discovered;
        bool connected;
 
+       bt_gatt_client_att_mtu_changed_cb att_mtu_changed_cb;
        bt_gatt_client_service_changed_cb service_changed_cb;
        void *service_changed_user_data;
+       void *att_mtu_changed_user_data;
 } bt_gatt_client_s;
 
 typedef struct {
index a89e68df26b0139f05dbf7c6f38a764933e5ab78..2c4f4c169d75d98b813d687276c11aba391b794d 100644 (file)
@@ -1825,6 +1825,38 @@ typedef void (*bt_gatt_characteristic_descriptor_discovered_cb) (int result,
 typedef bool (*bt_gatt_foreach_cb) (int total, int index, bt_gatt_h gatt_handle,
                                    void *user_data);
 
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE
+ * @brief Attribute protocol MTU change information structure.
+ * @since_tizen 4.0
+ *
+ * @see bt_gatt_client_att_mtu_changed_cb()
+ */
+typedef struct {
+       char *remote_address;   /**< The address of remote device */
+       unsigned int mtu;               /**< MTU value */
+       unsigned int status;            /**< Request status*/
+} bt_gatt_client_att_mtu_info_s;
+
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE
+ * @brief Called when the ATT MTU value is changed.
+ * @since_tizen 4.0
+ *
+ * @remarks The @a mtu_info must not be freed by application.
+ *                @a mtu_info can be used only inside the callback.
+ *                If it's needed outside, make a copy.
+ *
+ * @param[in] client The handle of a GATT client which is associated with a remote device
+ * @param[in] mtu_info The MTU information
+ * @param[in] user_data The user data passed from the callback registration function
+ * @see bt_gatt_client_set_connection_state_changed_cb()
+ * @see bt_gatt_client_unset_connection_state_changed_cb()
+ */
+typedef void (*bt_gatt_client_att_mtu_changed_cb)(bt_gatt_client_h client,
+               const bt_gatt_client_att_mtu_info_s *mtu_info,
+               void *user_data);
+
 /**
  * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE
  * @brief  Called when the client request(e.g. read / write) has been completed
index 11960bb9ec146af36b36d86fa2653a85f7bf072f..48055536386fc5ff08d51e16925dfb12461efc1a 100644 (file)
@@ -644,6 +644,7 @@ typedef void (*bt_device_trusted_profiles_cb)
        (int result, char *remote_address, int trusted_profile, bool supported, bool trusted, void *user_data);
 
 /**
+ * @deprecated Deprecated since 4.0. Use bt_gatt_client_att_mtu_info_s instead.
  * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
  * @brief Attribute protocol MTU change information structure.
  * @since_tizen 3.0
@@ -657,6 +658,7 @@ typedef struct {
 } bt_device_att_mtu_info_s;
 
 /**
+ * @deprecated Deprecated since 4.0. Use bt_gatt_client_att_mtu_changed_cb instead.
  * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
  * @brief  Called when the connection state is changed.
  * @since_tizen 3.0
index 7d1b12e7de525aba2593ac2eb1acd0309696b51c..8815a9037f31b3b6e98b23f4c805e57f31969f4c 100644 (file)
@@ -733,9 +733,9 @@ static void __bt_free_bt_device_sdp_info_s(bt_device_sdp_info_s *sdp_info)
        sdp_info = NULL;
 }
 
-static int __bt_get_bt_device_att_mtu_info_s(bt_device_att_mtu_info_s **dest, bluetooth_le_att_mtu_info_t *source)
+static int __bt_get_bt_gatt_client_att_mtu_info_s(bt_gatt_client_att_mtu_info_s **dest, bluetooth_le_att_mtu_info_t *source)
 {
-       *dest = (bt_device_att_mtu_info_s *)g_malloc0(sizeof(bt_device_att_mtu_info_s));
+       *dest = (bt_gatt_client_att_mtu_info_s *)g_malloc0(sizeof(bt_gatt_client_att_mtu_info_s));
        if (*dest == NULL)
                return BT_ERROR_OUT_OF_MEMORY;
 
@@ -1048,6 +1048,7 @@ static bool __bt_need_to_handle(int event)
        case BLUETOOTH_EVENT_GATT_SERVER_READ_REQUESTED:
        case BLUETOOTH_EVENT_GATT_SERVER_NOTIFICATION_COMPLETED:
        case BLUETOOTH_EVENT_GATT_CLIENT_SERVICE_CHANGED:
+       case BLUETOOTH_EVENT_GATT_ATT_MTU_CHANGED:
        case BLUETOOTH_EVENT_TDS_TRANSPORT_DATA_RECEIVED:
        case BLUETOOTH_EVENT_TDS_ACTIVATION_RESULT:
        case BLUETOOTH_EVENT_TDS_CONTROL_POINT_ENABLED:
@@ -2438,12 +2439,24 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us
                 bt_event_slot_container[event_index].user_data);
                break;
        case BLUETOOTH_EVENT_GATT_ATT_MTU_CHANGED: {
-               bt_device_att_mtu_info_s *mtu_info = NULL;
+               bt_gatt_client_att_mtu_info_s *mtu_info = NULL;
+               bt_gatt_client_s *client = NULL;
 
                BT_INFO("BLUETOOTH_EVENT_GATT_ATT_MTU_CHANGED");
-               __bt_get_bt_device_att_mtu_info_s(&mtu_info, (bluetooth_le_att_mtu_info_t *)(param->param_data));
-               ((bt_device_att_mtu_changed_cb)bt_event_slot_container[event_index].callback)
-                (_bt_get_error_code(param->result), mtu_info, bt_event_slot_container[event_index].user_data);
+               __bt_get_bt_gatt_client_att_mtu_info_s(&mtu_info, (bluetooth_le_att_mtu_info_t *)(param->param_data));
+
+               client = _bt_gatt_get_client(mtu_info->remote_address);
+
+               if (client && client->connected && client->att_mtu_changed_cb)
+                       client->att_mtu_changed_cb(client,
+                                       (const bt_gatt_client_att_mtu_info_s *)mtu_info,
+                                       client->att_mtu_changed_user_data);
+
+               if (bt_event_slot_container[event_index].callback)
+                       ((bt_device_att_mtu_changed_cb)bt_event_slot_container[event_index].callback)
+                        (_bt_get_error_code(param->result), (bt_device_att_mtu_info_s *)mtu_info,
+                        bt_event_slot_container[event_index].user_data);
+
                break;
        }
        case BLUETOOTH_EVENT_LE_DATA_LENGTH_CHANGED:
index 94fc70023f22fba9edcb53a105ba083e39eb4271..974eb55051b3af508a57698905205d042f7c26ec 100644 (file)
@@ -401,7 +401,7 @@ int bt_device_unset_att_mtu_changed_cb(void)
 {
        BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON);
        BT_CHECK_INIT_STATUS();
-       _bt_unset_cb(BT_EVENT_DEVICE_CONNECTION_STATUS);
+       _bt_unset_cb(BT_EVENT_GATT_ATT_MTU_CHANGE_STATUS);
        return BT_ERROR_NONE;
 }
 
index 18631921e1630dcb1d411e6c3d16ccfc4813853f..7d51c4bab98b21aeb78e3c5fce2593e4a1b743da 100644 (file)
@@ -3246,3 +3246,86 @@ int bt_gatt_client_unset_service_changed_cb(bt_gatt_client_h client)
 
        return BT_ERROR_NONE;
 }
+
+int bt_gatt_client_request_att_mtu_change(bt_gatt_client_h client, unsigned int mtu)
+{
+       int ret;
+       bluetooth_device_address_t addr_hex = { {0,} };
+       bt_gatt_client_s *client_s = (bt_gatt_client_s *)client;
+
+       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON);
+       BT_CHECK_INIT_STATUS();
+       BT_CHECK_INPUT_PARAMETER(client);
+
+       _bt_convert_address_to_hex(&addr_hex, client_s->remote_address);
+
+       ret = _bt_get_error_code(bluetooth_request_att_mtu(&addr_hex, mtu));
+       if (BT_ERROR_NONE != ret)
+               BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
+
+       return ret;
+}
+
+int bt_gatt_client_get_att_mtu(bt_gatt_client_h client, unsigned int *mtu)
+{
+       bluetooth_device_address_t addr_hex = { {0,} };
+       int ret;
+       unsigned int mtu_value = 0;
+       bt_gatt_client_s *client_s = (bt_gatt_client_s *)client;
+
+       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON);
+       BT_CHECK_INIT_STATUS();
+       BT_CHECK_INPUT_PARAMETER(client);
+
+       _bt_convert_address_to_hex(&addr_hex, client_s->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_client_set_att_mtu_changed_cb(bt_gatt_client_h client, bt_gatt_client_att_mtu_changed_cb callback, void *user_data)
+{
+       bt_gatt_client_s *client_s = (bt_gatt_client_s *)client;
+
+       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON);
+       BT_CHECK_INIT_STATUS();
+       BT_CHECK_INPUT_PARAMETER(callback);
+       BT_CHECK_INPUT_PARAMETER(client);
+
+       if (client_s->att_mtu_changed_cb) {
+               BT_INFO("Already registered");
+               client_s->att_mtu_changed_cb = callback;
+               client_s->att_mtu_changed_user_data = user_data;
+               return BT_ERROR_NONE;
+       }
+
+       BT_INFO("MTU Changed callback registered");
+       client_s->att_mtu_changed_cb = callback;
+       client_s->att_mtu_changed_user_data = user_data;
+
+       return BT_ERROR_NONE;
+}
+
+int bt_gatt_client_unset_att_mtu_changed_cb(bt_gatt_client_h client)
+{
+       bt_gatt_client_s *client_s = (bt_gatt_client_s *)client;
+
+       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON);
+       BT_CHECK_INIT_STATUS();
+       BT_CHECK_INPUT_PARAMETER(client);
+
+       BT_INFO("MTU Changed callback unregistered [%s]", client_s->remote_address);
+       client_s->service_changed_cb = NULL;
+       client_s->service_changed_user_data = NULL;
+
+       return BT_ERROR_NONE;
+}
index 273f9f80ba6aa02bc3934c56f9c5bb1ae09415d5..a8f0c0ebd185618074012d1759825b2b25bfa4ff 100644 (file)
@@ -580,10 +580,18 @@ tc_table_t tc_gatt[] = {
                , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_UNSET_CHAR_VALUE_CHANGED_CB},
        {"bt_gatt_client_foreach_services"
                , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_FOREACH_SERVICES},
+       {"bt_gatt_client_request_att_mtu_change"
+               , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_REQUEST_ATT_MTU},
+       {"bt_gatt_client_get_att_mtu"
+                               , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_GET_ATT_MTU},
        {"bt_gatt_client_set_service_changed_cb"
                , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_SET_SERVICE_CHANGED_CB},
        {"bt_gatt_client_unset_service_changed_cb"
                , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_UNSET_SERVICE_CHANGED_CB},
+       {"bt_gatt_client_set_att_mtu_changed_cb"
+               , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_SET_ATT_MTU_CHANGED_CB},
+       {"bt_gatt_client_unset_att_mtu_changed_cb"
+               , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_UNSET_ATT_MTU_CHANGED_CB},
        {"bt_gatt_server_initialize"
                , BT_UNIT_TEST_FUNCTION_GATT_SERVER_INITIALIZE},
        {"bt_gatt_server_deinitilaize"
@@ -2169,6 +2177,28 @@ void __bt_gatt_client_service_changed_cb(bt_gatt_client_h c,
        g_free(addr);
 }
 
+void __bt_gatt_client_att_mtu_changed_cb(bt_gatt_client_h c, const bt_gatt_client_att_mtu_info_s *mtu_info, void *user_data)
+{
+       char *addr = NULL;
+       int ret;
+
+       TC_PRT("__bt_gatt_client_att_mtu_changed_cb");
+
+       ret = bt_gatt_client_get_remote_address(client, &addr);
+       if (ret != BT_ERROR_NONE) {
+               TC_PRT("Cannot get remote address");
+               return;
+       }
+
+       if (mtu_info) {
+               TC_PRT("status [%d]", mtu_info->status);
+               TC_PRT("address [%s]", mtu_info->remote_address);
+               TC_PRT("MTU [%d]", mtu_info->mtu);
+       }
+
+       g_free(addr);
+}
+
 int __bt_gatt_client_set_value(char *type, char *value, bt_gatt_h h)
 {
        int ret;
@@ -3944,6 +3974,34 @@ int test_set_params(int test_id, char *param)
 
                        break;
                }
+               case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_REQUEST_ATT_MTU: {
+                       if (param_index == 0) {
+                               g_test_param.param_count = 1;
+                               g_test_param.params = g_malloc0(sizeof(char*) * g_test_param.param_count);
+                               param_type = "int(1, 2, 10, ...., 512)";
+                       }
+
+                       if (param_index > 0) {
+                               g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1);
+                               strncpy(g_test_param.params[param_index - 1], param, strlen(param));
+                       }
+
+                       if (param_index == g_test_param.param_count) {
+                               need_to_set_params = false;
+#ifdef ARCH64
+                               test_input_callback((void *)(uintptr_t)test_id);
+#else
+                               test_input_callback((void *)test_id);
+#endif
+                               param_index = 0;
+                               return 0;
+                       }
+
+                       TC_PRT("Input param(%d) : %s", param_index + 1, param_type);
+                       param_index++;
+
+                       break;
+               }
                case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_SET_CHAR_VALUE_CHANGED_CB: {
                        if (param_index == 0) {
                                g_test_param.param_count = 2;
@@ -6697,6 +6755,25 @@ int test_input_callback(void *data)
                                TC_PRT("bt_gatt_client_foreach_services_by_uuid is failed");
                        break;
                }
+               case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_REQUEST_ATT_MTU: {
+                       unsigned int mtu = 512; /* MAX MTU Value */
+
+                       if (g_test_param.param_count > 0) {
+                               mtu = atoi(g_test_param.params[0]);
+
+                               __bt_free_test_param(&g_test_param);
+                       }
+
+                       ret = bt_gatt_client_request_att_mtu_change(client, mtu);
+                       TC_PRT("returns %s\n", __bt_get_error_message(ret));
+                       break;
+               }
+               case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_GET_ATT_MTU: {
+                       unsigned int mtu = 0;
+                       ret = bt_gatt_client_get_att_mtu(client, &mtu);
+                       TC_PRT("returns %s, MTU %d\n", __bt_get_error_message(ret), mtu);
+                       break;
+               }
                case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_SET_SERVICE_CHANGED_CB: {
                        ret = bt_gatt_client_set_service_changed_cb(client,
                                        __bt_gatt_client_service_changed_cb, NULL);
@@ -6710,6 +6787,16 @@ int test_input_callback(void *data)
                                TC_PRT("bt_gatt_client_unset_service_changed_cb is failed");
                        break;
                }
+               case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_SET_ATT_MTU_CHANGED_CB: {
+                       ret = bt_gatt_client_set_att_mtu_changed_cb(client, __bt_gatt_client_att_mtu_changed_cb, NULL);
+                       TC_PRT("returns %s\n", __bt_get_error_message(ret));
+                       break;
+               }
+               case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_UNSET_ATT_MTU_CHANGED_CB: {
+                       ret = bt_gatt_client_unset_att_mtu_changed_cb(client);
+                       TC_PRT("returns %s\n", __bt_get_error_message(ret));
+                       break;
+               }
                case BT_UNIT_TEST_FUNCTION_GATT_SERVER_INITIALIZE: {
 
                        ret = bt_gatt_server_initialize();
index f5b210a13b6cf933d89c3647d62a88d9b4ec298c..3457df7cb906446d0a23190890104a5472977f18 100644 (file)
@@ -231,8 +231,12 @@ typedef enum {
        BT_UNIT_TEST_FUNCTION_GATT_CLIENT_SET_CHAR_VALUE_CHANGED_CB,
        BT_UNIT_TEST_FUNCTION_GATT_CLIENT_UNSET_CHAR_VALUE_CHANGED_CB,
        BT_UNIT_TEST_FUNCTION_GATT_CLIENT_FOREACH_SERVICES,
+       BT_UNIT_TEST_FUNCTION_GATT_CLIENT_REQUEST_ATT_MTU,
+       BT_UNIT_TEST_FUNCTION_GATT_CLIENT_GET_ATT_MTU,
        BT_UNIT_TEST_FUNCTION_GATT_CLIENT_SET_SERVICE_CHANGED_CB,
        BT_UNIT_TEST_FUNCTION_GATT_CLIENT_UNSET_SERVICE_CHANGED_CB,
+       BT_UNIT_TEST_FUNCTION_GATT_CLIENT_SET_ATT_MTU_CHANGED_CB,
+       BT_UNIT_TEST_FUNCTION_GATT_CLIENT_UNSET_ATT_MTU_CHANGED_CB,
        BT_UNIT_TEST_FUNCTION_GATT_SERVER_INITIALIZE,
        BT_UNIT_TEST_FUNCTION_GATT_SERVER_DEINITIALIZE,
        BT_UNIT_TEST_FUNCTION_GATT_SERVER_UNREGISTER_ALL_SERVICES,