From: Wootak Jung Date: Tue, 27 Feb 2024 04:41:27 +0000 (+0900) Subject: Add new L2CAP socket API to get the maximum buffer size X-Git-Tag: accepted/tizen/7.0/unified/20240330.125439^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=90373b5502d2142cc9dc8716521cb70ac5ec7c0d;p=platform%2Fcore%2Fapi%2Fbluetooth.git Add new L2CAP socket API to get the maximum buffer size Change-Id: I07346e76772c3d8379f2eb713bb55996fa1d3bba Signed-off-by: Wootak Jung --- diff --git a/include/bluetooth_internal.h b/include/bluetooth_internal.h index 2856a1c..095ba31 100644 --- a/include/bluetooth_internal.h +++ b/include/bluetooth_internal.h @@ -5645,6 +5645,22 @@ int bt_adapter_le_add_advertising_custom_name(bt_advertiser_h advertiser, int bt_adapter_le_remove_advertising_custom_name(bt_advertiser_h advertiser, bt_adapter_le_packet_type_e pkt_type); +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_L2CAP_SOCKET_MODULE + * @brief Gets the maximum buffer size. + * + * @param[out] size The maximum size of buffer + * + * @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 + * + * @see bt_socket_send_data_l2cap_channel() + */ +int bt_socket_get_l2cap_max_buffer_size(int *size); + /** * @} */ diff --git a/src/bluetooth-socket.c b/src/bluetooth-socket.c index 3f7bb46..02050d9 100644 --- a/src/bluetooth-socket.c +++ b/src/bluetooth-socket.c @@ -509,6 +509,21 @@ int bt_socket_get_l2cap_psm(int socket_fd, int *psm) return ret; /* LCOV_EXCL_STOP */ } +int bt_socket_get_l2cap_max_buffer_size(int *size) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_LE_COC); + BT_CHECK_INIT_STATUS(); /* LCOV_EXCL_START */ + BT_CHECK_INPUT_PARAMETER(size); + + error_code = bluetooth_l2cap_le_get_max_buffer_size(size); + if (error_code != BT_ERROR_NONE) + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + + return error_code; /* LCOV_EXCL_STOP */ +} + int bt_socket_set_l2cap_channel_connection_state_changed_cb( bt_socket_l2cap_channel_connection_state_changed_cb callback, void *user_data) { diff --git a/tests/test/bt_unit_test.c b/tests/test/bt_unit_test.c index 2846b98..be008bc 100644 --- a/tests/test/bt_unit_test.c +++ b/tests/test/bt_unit_test.c @@ -509,6 +509,8 @@ tc_table_t tc_socket[] = { , BT_UNIT_TEST_FUNCTION_SOCKET_SEND_DATA_L2CAP_CHANNEL}, {"bt_socket_get_l2cap_psm" , BT_UNIT_TEST_FUNCTION_SOCKET_GET_L2CAP_PSM}, + {"bt_socket_get_l2cap_max_buffer_size" + , BT_UNIT_TEST_FUNCTION_SOCKET_GET_L2CAP_MAX_BUFFER_SIZE}, {"bt_socket_set_l2cap_channel_connection_requested_cb" , BT_UNIT_TEST_FUNCTION_SOCKET_SET_L2CAP_CHANNEL_CONNECTION_REQUESTED_CB}, {"bt_socket_unset_l2cap_channel_connection_requested_cb" @@ -6421,6 +6423,15 @@ int test_input_callback(void *data) } break; } + case BT_UNIT_TEST_FUNCTION_SOCKET_GET_L2CAP_MAX_BUFFER_SIZE: { + int size; + ret = bt_socket_get_l2cap_max_buffer_size(&size); + if (ret != BT_ERROR_NONE) + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + else + TC_PRT("max buffer size: %d(0x%x)", size, size); + break; + } case BT_UNIT_TEST_FUNCTION_SOCKET_SET_L2CAP_CHANNEL_CONNECTION_REQUESTED_CB: ret = bt_socket_set_l2cap_channel_connection_requested_cb( __bt_socket_connection_requested_cb, NULL); diff --git a/tests/test/bt_unit_test.h b/tests/test/bt_unit_test.h index 34f936a..4dc6871 100644 --- a/tests/test/bt_unit_test.h +++ b/tests/test/bt_unit_test.h @@ -212,6 +212,7 @@ typedef enum { BT_UNIT_TEST_FUNCTION_SOCKET_DISCONNECT_L2CAP_CHANNEL, BT_UNIT_TEST_FUNCTION_SOCKET_SEND_DATA_L2CAP_CHANNEL, BT_UNIT_TEST_FUNCTION_SOCKET_GET_L2CAP_PSM, + BT_UNIT_TEST_FUNCTION_SOCKET_GET_L2CAP_MAX_BUFFER_SIZE, BT_UNIT_TEST_FUNCTION_SOCKET_SET_L2CAP_CHANNEL_CONNECTION_REQUESTED_CB, BT_UNIT_TEST_FUNCTION_SOCKET_UNSET_L2CAP_CHANNEL_CONNECTION_REQUESTED_CB, BT_UNIT_TEST_FUNCTION_SOCKET_SET_L2CAP_CHANNEL_CONNECTION_STATE_CHANGED_CB,