[ACR-1694] Add new APIs for L2CAP LE CoC functionality 25/273625/6 accepted/tizen/unified/20220502.003743 submit/tizen/20220428.025526 submit/tizen/20220429.071758
authorWootak Jung <wootak.jung@samsung.com>
Sun, 10 Apr 2022 23:47:16 +0000 (08:47 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Wed, 27 Apr 2022 04:50:01 +0000 (13:50 +0900)
- add new feature:
tizen.org/feature/network.bluetooth.le.coc

Change-Id: I193513b0524daeac8e8c538f8226285ccc07a895

doc/bluetooth_doc.h
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-socket.c

index 9fb2f01..30d039c 100644 (file)
  * Please refer Bluetooth Tutorial if you want to get more detailed usages and information of this api.
  */
 
+/**
+ * @defgroup CAPI_NETWORK_BLUETOOTH_L2CAP_SOCKET_MODULE Bluetooth L2CAP Socket
+ * @brief Bluetooth L2CAP Socket API provides functions for managing connections to other devices and exchanging data.
+ * @ingroup CAPI_NETWORK_BLUETOOTH_MODULE
+ *
+ * @section CAPI_NETWORK_BLUETOOTH_L2CAP_SOCKET_MODULE_HEADER Required Header
+ *  \#include <bluetooth.h>
+ *
+ * @section CAPI_NETWORK_BLUETOOTH_L2CAP_SOCKET_MODULE_OVERVIEW Overview
+ * This set of functions is used for exchanging data between two bluetooth
+ * devices, our device can have both roles as server (service provider) and client
+ * (service user).
+ * Depending on the role, there is difference in creating a connection.
+ * After that, processes of exchanging data and disconnection are same.
+ *
+ * To start communication, you should first register for #bt_socket_set_l2cap_channel_connection_state_changed_cb()
+ * and #bt_socket_set_data_received_cb().
+ * Next step depends on the role of your application.\n
+ * If you want to be \b server \b role, application should create socket
+ * (#bt_socket_create_l2cap_channel()), and start listening and accepting incoming connections
+ * (#bt_socket_listen_and_accept_l2cap_channel()).
+ * If you want to connect to specific device and use it's services (\a client \a role),
+ * you have to start connection with #bt_socket_connect_l2cap_channel() and wait for connection.\n
+ * After connection has been established (information is passed to your program with
+ * #bt_socket_l2cap_channel_connection_state_changed_cb() function call), you can exchange data by
+ * calling #bt_socket_send_data_l2cap_channel(). \n
+ * If you receive data from remote device, #bt_socket_data_received_cb() functions will be called.
+ * When you finish exchanging data, you should disconnect connection
+ * with #bt_socket_disconnect_l2cap_channel() and unregister callback functions (with using
+ * #bt_socket_unset_data_received_cb(), #bt_socket_unset_l2cap_channel_connection_state_changed_cb()).
+ *
+ * @section CAPI_NETWORK_BLUETOOTH_L2CAP_SOCKET_MODULE_FEATURE Related Features
+ * This API is related with the following features:\n
+ *  - %http://tizen.org/feature/network.bluetooth.le.coc\n
+ *
+ * It is recommended to design feature related codes in your application for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE,thereby controlling the procedure of your application.\n
+ *
+ * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
+ *
+ * More details on featuring your application can be found from <a href="https://docs.tizen.org/application/tizen-studio/native-tools/manifest-text-editor#feature-element"><b>Feature Element</b>.</a>
+ *
+ * @section CAPI_NETWORK_BLUETOOTH_L2CAP_SOCKET_MODULE_ASYNCHRONOUS_OPERATIONS Asynchronous Operations
+ * <div><table class="doxtable" >
+ *     <tr>
+ *        <th><b>FUNCTION</b></th>
+ *        <th><b>CALLBACK</b></th>
+ *        <th><b>DESCRIPTION</b></th>
+ *     </tr>
+ *     <tr>
+ *        <td>bt_socket_listen_and_accept_l2cap_channel()<br>
+ *            bt_socket_connect_l2cap_channel()</td>
+ *        <td>bt_socket_l2cap_channel_connection_state_changed_cb()</td>
+ *        <td>Used to connect a device. </td>
+ *     </tr>
+ *</table></div>
+ *
+ * @section CAPI_NETWORK_BLUETOOTH_L2CAP_SOCKET_MODULE_CALLBACK_OPERATIONS Callback(Event) Operations
+ * <div><table class="doxtable" >
+ *     <tr>
+ *        <th><b>REGISTER</b></th>
+ *        <th><b>UNREGISTER</b></th>
+ *        <th><b>CALLBACK</b></th>
+ *        <th><b>DESCRIPTION</b></th>
+ *     </tr>
+ *     <tr>
+ *        <td>bt_socket_set_data_received_cb()</td>
+ *        <td>bt_socket_unset_data_received_cb()</td>
+ *        <td>bt_socket_data_received_cb()</td>
+ *        <td>Used to be notified of received data. </td>
+ *     </tr>
+ *     <tr>
+ *        <td>bt_socket_set_l2cap_channel_connection_state_changed_cb()</td>
+ *        <td>bt_socket_unset_l2cap_channel_connection_state_changed_cb()</td>
+ *        <td>bt_socket_l2cap_channel_connection_state_changed_cb()</td>
+ *        <td>Used to be notified when the state of connection changes. </td>
+ *     </tr>
+ *</table></div>
+ *
+ *<BR>
+ * Please refer Bluetooth Tutorial if you want to get more detailed usages and information of this api.
+ */
 
 /**
  * @defgroup CAPI_NETWORK_BLUETOOTH_OPP_MODULE Bluetooth OPP
index a7489c6..d1e06b7 100644 (file)
@@ -6081,7 +6081,360 @@ int bt_adapter_le_is_2m_phy_supported(bool *is_supported);
  */
 int bt_adapter_le_is_coded_phy_supported(bool *is_supported);
 
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_L2CAP_SOCKET_MODULE
+ * @brief Registers a L2CAP Connection-oriented Channel (CoC) server socket with a specific protocol/service multiplexer (PSM) value.
+ * @details If 0 is passed, the system will assign a dynamic PSM value when bt_socket_listen_and_accept_l2cap_channel()
+ * is called. This @a psm value can be read from the bt_socket_get_l2cap_psm().
+ * @since_tizen 7.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/bluetooth
+ *
+ * @remarks A socket can be destroyed by bt_socket_destroy_l2cap_channel().
+ *
+ * @param[in] psm The dynamic PSM value to start server
+ * @param[out] socket_fd The file descriptor of socket to listen
+ * @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_ENABLED  Not enabled
+ * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
+ * @retval #BT_ERROR_PERMISSION_DENIED  Permission denied
+ * @retval #BT_ERROR_NOT_SUPPORTED  Not supported
+ *
+ * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED.
+ *
+ * @see bt_socket_listen_and_accept_l2cap_channel()
+ * @see bt_socket_destroy_l2cap_channel()
+ */
+int bt_socket_create_l2cap_channel(int psm, int *socket_fd);
+
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_L2CAP_SOCKET_MODULE
+ * @brief Removes the L2CAP Connection-oriented Channel (CoC) server socket which was created using bt_socket_create_l2cap_channel().
+ * @since_tizen 7.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/bluetooth
+ * @remarks If callback function bt_socket_l2cap_channel_connection_state_changed_cb() is set and the remote Bluetooth device is connected,
+ * then bt_socket_l2cap_channel_connection_state_changed_cb() will be called when this function is finished successfully.
+ *
+ * @param[in] socket_fd The file descriptor of socket (which was created using bt_socket_create_l2cap_channel()) to destroy
+ * @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_ENABLED  Not enabled
+ * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
+ * @retval #BT_ERROR_PERMISSION_DENIED  Permission denied
+ * @retval #BT_ERROR_NOT_SUPPORTED  Not supported
+ *
+ * @pre The socket must be created with bt_socket_create_l2cap_channel().
+ * @post If callback function bt_socket_l2cap_channel_connection_state_changed_cb() is set and the remote Bluetooth device is connected,
+ * then bt_socket_l2cap_channel_connection_state_changed_cb() will be called.
+ * @see bt_socket_create_l2cap_channel()
+ * @see bt_socket_l2cap_channel_connection_state_changed_cb()
+ * @see bt_socket_set_l2cap_channel_connection_state_changed_cb()
+ * @see bt_socket_unset_l2cap_channel_connection_state_changed_cb()
+ */
+int bt_socket_destroy_l2cap_channel(int socket_fd);
+
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_L2CAP_SOCKET_MODULE
+ * @brief Starts listening on passed L2CAP_LE socket and accepts connection requests.
+ * @details Pop-up is shown automatically when a L2CAP CoC connection is requested.
+ * bt_socket_l2cap_channel_connection_state_changed_cb() will be called with
+ * #BT_SOCKET_CONNECTED if the user click "yes" and connection is finished successfully.
+ * @since_tizen 7.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/bluetooth
+ * @param[in] socket_fd The file descriptor of socket on which start to listen
+ * @param[in] max_pending_connections The maximum number of pending connections
+ * @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_ENABLED  Not enabled
+ * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
+ * @retval #BT_ERROR_PERMISSION_DENIED  Permission denied
+ * @retval #BT_ERROR_NOT_SUPPORTED  Not supported
+ *
+ * @pre The socket must be created with bt_socket_create_l2cap_channel().
+ * @post If callback function bt_socket_l2cap_channel_connection_state_changed_cb() is set,
+ * then bt_socket_l2cap_channel_connection_state_changed_cb() will be called when the remote Bluetooth device is connected.
+ * @see bt_socket_create_l2cap_channel()
+ * @see bt_socket_l2cap_channel_connection_state_changed_cb()
+ * @see bt_socket_set_l2cap_channel_connection_state_changed_cb()
+ * @see bt_socket_unset_l2cap_channel_connection_state_changed_cb()
+ */
+int bt_socket_listen_and_accept_l2cap_channel(int socket_fd,
+                                               int max_pending_connections);
+
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_L2CAP_SOCKET_MODULE
+ * @brief Gets the assigned PSM for the listening L2CAP Connection-oriented Channel (CoC) server socket.
+ * @details It is used to get the system assigned PSM value especially when bt_socket_create_l2cap_channel()
+ * is called with @a psm value 0.
+ * @since_tizen 7.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/bluetooth
+ *
+ * @param[in] socket_fd The file descriptor of connected socket which was received using bt_socket_l2cap_channel_connection_state_changed_cb()
+ * @param[out] psm The assigned dynamic PSM value for the listening L2CAP CoC server socket
+ *
+ * @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_ENABLED  Not enabled
+ * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
+ * @retval #BT_ERROR_PERMISSION_DENIED  Permission denied
+ * @retval #BT_ERROR_NOT_SUPPORTED  Not supported
+ *
+ * @pre The bt_socket_listen_and_accept_l2cap_channel() must be called.
+ *
+ * @see bt_socket_create_l2cap_channel()
+ * @see bt_socket_listen_and_accept_l2cap_channel()
+ */
+int bt_socket_get_l2cap_psm(int socket_fd, int *psm);
+
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_L2CAP_SOCKET_MODULE
+ * @brief Connects to a specific L2CAP CoC socket on a remote Bluetooth device PSM, asynchronously.
+ * @since_tizen 7.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/bluetooth
+ *
+ * @remarks A connection can be disconnected by bt_socket_disconnect_l2cap_channel().
+ *
+ * @param[in] remote_address The address of the remote Bluetooth device
+ * @param[in] psm The dynamic PSM of a remote Bluetooth device
+ *
+ * @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_ENABLED  Not enabled
+ * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
+ * @retval #BT_ERROR_PERMISSION_DENIED  Permission denied
+ * @retval #BT_ERROR_NOT_SUPPORTED  Not supported
+ *
+ * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED.
+ * @pre The remote device must be scannable with bt_adapter_le_start_scan().
+ * @post This function invokes bt_socket_l2cap_channel_connection_state_changed_cb().
+ *
+ * @see bt_adapter_le_start_scan()
+ * @see bt_socket_disconnect_l2cap_channel()
+ * @see bt_socket_l2cap_channel_connection_state_changed_cb()
+ * @see bt_socket_set_l2cap_channel_connection_state_changed_cb()
+ * @see bt_socket_unset_l2cap_channel_connection_state_changed_cb()
+ */
+int bt_socket_connect_l2cap_channel(const char *remote_address, int psm);
+
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_L2CAP_SOCKET_MODULE
+ * @brief Disconnects the L2CAP CoC connection with the given file descriptor of connected socket.
+ * @since_tizen 7.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/bluetooth
+ * @param[in] socket_fd  The file descriptor of socket to close which was received using bt_socket_l2cap_channel_connection_state_changed_cb().
+ * @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_ENABLED  Not enabled
+ * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
+ * @retval #BT_ERROR_PERMISSION_DENIED  Permission denied
+ * @retval #BT_ERROR_NOT_SUPPORTED  Not supported
+ *
+ * @pre The connection must be established.
+ *
+ * @see bt_socket_l2cap_channel_connection_state_changed_cb()
+ * @see bt_socket_set_l2cap_channel_connection_state_changed_cb()
+ * @see bt_socket_unset_l2cap_channel_connection_state_changed_cb()
+ */
+int bt_socket_disconnect_l2cap_channel(int socket_fd);
+
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_L2CAP_SOCKET_MODULE
+ * @brief Sends data to the connected device.
+ * @since_tizen 7.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/bluetooth
+ * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
+ *
+ * @param[in] socket_fd The file descriptor of connected socket which was received using bt_socket_l2cap_channel_connection_state_changed_cb()
+ * @param[in] data The data to be sent
+ * @param[in] length The length of data to be sent
+ *
+ * @return the number of bytes written (zero indicates nothing was written).
+ * @retval On error, -1 is returned, and errno is set appropriately. See write 2 man page.
+ * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
+ * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #BT_ERROR_NOT_ENABLED  Not enabled
+ * @exception BT_ERROR_PERMISSION_DENIED  Permission denied
+ * @exception BT_ERROR_AGAIN  Resource temporarily unavailable
+ * @retval #BT_ERROR_NOT_SUPPORTED   Not supported
+ *
+ * @pre The connection must be established.
+ *
+ * @see bt_socket_l2cap_channel_connection_state_changed_cb()
+ * @see bt_socket_set_l2cap_channel_connection_state_changed_cb()
+ * @see bt_socket_unset_l2cap_channel_connection_state_changed_cb()
+ */
+int bt_socket_send_data_l2cap_channel(int socket_fd, const char *data, int length);
 
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_L2CAP_SOCKET_MODULE
+ * @brief  Registers a callback function that will be invoked when a L2CAP CoC connection is requested.
+ * @since_tizen 7.0
+ * @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_socket_connection_requested_cb() will be invoked.
+ * @see bt_initialize()
+ * @see bt_socket_unset_l2cap_channel_connection_requested_cb()
+ */
+int bt_socket_set_l2cap_channel_connection_requested_cb(
+                                               bt_socket_connection_requested_cb callback, void *user_data);
+
+/**
+ * @ingroup  CAPI_NETWORK_BLUETOOTH_L2CAP_SOCKET_MODULE
+ * @brief Unregisters the L2CAP CoC connection requested callback.
+ * @since_tizen 7.0
+ * @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_socket_set_l2cap_channel_connection_requested_cb()
+ * @see  bt_socket_connection_requested_cb()
+ */
+int bt_socket_unset_l2cap_channel_connection_requested_cb(void);
+
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_L2CAP_SOCKET_MODULE
+ * @brief  Registers a callback function that will be invoked when the connection state changes.
+ * @since_tizen 7.0
+ * @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_socket_l2cap_channel_connection_state_changed_cb() will be invoked.
+ * @see bt_initialize()
+ * @see bt_socket_l2cap_channel_connection_state_changed_cb()
+ * @see bt_socket_unset_l2cap_channel_connection_state_changed_cb()
+ */
+int bt_socket_set_l2cap_channel_connection_state_changed_cb(
+                                       bt_socket_l2cap_channel_connection_state_changed_cb callback, void *user_data);
+
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_L2CAP_SOCKET_MODULE
+ * @brief Unregisters the L2CAP CoC connection state changed callback.
+ * @since_tizen 7.0
+ * @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_socket_l2cap_channel_connection_state_changed_cb()
+ * @see bt_socket_set_l2cap_channel_connection_state_changed_cb()
+ */
+int bt_socket_unset_l2cap_channel_connection_state_changed_cb(void);
+
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_L2CAP_SOCKET_MODULE
+ * @brief Starts listening on passed L2CAP Connection-oriented Channel (CoC) socket.
+ * @since_tizen 7.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/bluetooth
+ * @details bt_socket_l2cap_channel_connection_requested_cb() will be called when a L2CAP CoC connection is requested.
+ *
+ * @param[in] socket_fd  The file descriptor socket on which start to listen
+ * @param[in] max_pending_connections  The number of pending connections
+ *
+ * @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_ENABLED  Not enabled
+ * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
+ * @retval #BT_ERROR_PERMISSION_DENIED  Permission denied
+ * @retval #BT_ERROR_NOT_SUPPORTED  Not supported
+ *
+ * @pre The socket must be created with bt_socket_create_l2cap_channel().
+ * @post This function invokes bt_socket_l2cap_channel_connection_state_changed_cb().
+ *
+ * @see bt_socket_create_l2cap_channel()
+ * @see bt_socket_set_l2cap_channel_connection_requested_cb()
+ * @see bt_socket_unset_l2cap_channel_connection_requested_cb()
+ * @see bt_socket_l2cap_channel_connection_requested_cb()
+ */
+int bt_socket_listen_l2cap_channel(int socket_fd, int max_pending_connections);
+
+/**
+ * @ingroup  CAPI_NETWORK_BLUETOOTH_L2CAP_SOCKET_MODULE
+ * @brief  Accepts a connection request.
+ * @since_tizen 7.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/bluetooth
+ * @param[in] requested_socket_fd  The file descriptor of socket on which a connection is requested
+ * @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_ENABLED  Not enabled
+ * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
+ * @retval #BT_ERROR_PERMISSION_DENIED  Permission denied
+ * @retval #BT_ERROR_NOT_SUPPORTED  Not supported
+ *
+ * @pre The connection is requested by bt_socket_l2cap_channel_connection_requested_cb().
+ * @see bt_socket_create_l2cap_channel()
+ * @see bt_socket_l2cap_channel_connection_requested_cb()
+ * @see bt_socket_listen_l2cap_channel()
+ * @see bt_socket_reject_l2cap_channel()
+*/
+int bt_socket_accept_l2cap_channel(int requested_socket_fd);
+
+/**
+ * @ingroup  CAPI_NETWORK_BLUETOOTH_L2CAP_SOCKET_MODULE
+ * @brief  Rejects a connection request.
+ * @since_tizen 7.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/bluetooth
+ * @param[in] socket_fd  The file descriptor of socket on which a connection is requested
+ * @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_ENABLED  Not enabled
+ * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
+ * @retval #BT_ERROR_PERMISSION_DENIED  Permission denied
+ * @retval #BT_ERROR_NOT_SUPPORTED  Not supported
+ *
+ * @pre The connection is requested by bt_socket_l2cap_channel_connection_requested_cb().
+ * @see bt_socket_create_l2cap_channel()
+ * @see bt_socket_l2cap_channel_connection_requested_cb()
+ * @see bt_socket_listen_l2cap_channel()
+ * @see bt_socket_accept_l2cap_channel()
+ */
+int bt_socket_reject_l2cap_channel(int socket_fd);
 
 #ifdef __cplusplus
 }
index a2a18e0..cd3e823 100644 (file)
@@ -5443,87 +5443,6 @@ int bt_mesh_model_get_publication(bt_mesh_model_h model,
                        void *user_data);
 
 /**
- * @internal
- * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE
- * @brief Starts listening on passed L2CAP Connection-oriented Channel (CoC) socket.
- * @since_tizen 7.0
- * @privlevel platform
- * @privilege %http://tizen.org/privilege/bluetooth.admin
- * @details bt_socket_l2cap_channel_connection_requested_cb() will be called when a L2CAP CoC connection is requested.
- *
- * @param[in] socket_fd  The file descriptor socket on which start to listen
- * @param[in] max_pending_connections  The number of pending connections
- *
- * @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_ENABLED  Not enabled
- * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
- * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
- * @retval #BT_ERROR_PERMISSION_DENIED  Permission denied
- * @retval #BT_ERROR_NOT_SUPPORTED  Not supported
- *
- * @pre The socket must be created with bt_socket_create_l2cap_channel().
- * @post This function invokes bt_socket_l2cap_channel_connection_state_changed_cb().
- *
- * @see bt_socket_create_l2cap_channel()
- * @see bt_socket_set_l2cap_channel_connection_requested_cb()
- * @see bt_socket_unset_l2cap_channel_connection_requested_cb()
- * @see bt_socket_l2cap_channel_connection_requested_cb()
- */
-int bt_socket_listen_l2cap_channel(int socket_fd, int max_pending_connections);
-
-/**
- * @internal
- * @ingroup  CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE
- * @brief  Accepts a connection request.
- * @since_tizen 7.0
- * @privlevel platform
- * @privilege %http://tizen.org/privilege/bluetooth.admin
- * @param[in] requested_socket_fd  The file descriptor of socket on which a connection is requested
- * @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_ENABLED  Not enabled
- * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
- * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
- * @retval #BT_ERROR_PERMISSION_DENIED  Permission denied
- * @retval #BT_ERROR_NOT_SUPPORTED  Not supported
- *
- * @pre The connection is requested by bt_socket_l2cap_channel_connection_requested_cb().
- * @see bt_socket_create_l2cap_channel()
- * @see bt_socket_l2cap_channel_connection_requested_cb()
- * @see bt_socket_listen_l2cap_channel()
- * @see bt_socket_reject_l2cap_channel()
-*/
-int bt_socket_accept_l2cap_channel(int requested_socket_fd);
-
-/**
- * @internal
- * @ingroup  CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE
- * @brief  Rejects a connection request.
- * @since_tizen 7.0
- * @privlevel platform
- * @privilege %http://tizen.org/privilege/bluetooth.admin
- * @param[in] socket_fd  The file descriptor of socket on which a connection is requested
- * @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_ENABLED  Not enabled
- * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
- * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
- * @retval #BT_ERROR_PERMISSION_DENIED  Permission denied
- * @retval #BT_ERROR_NOT_SUPPORTED  Not supported
- *
- * @pre The connection is requested by bt_socket_l2cap_channel_connection_requested_cb().
- * @see bt_socket_create_l2cap_channel()
- * @see bt_socket_l2cap_channel_connection_requested_cb()
- * @see bt_socket_listen_l2cap_channel()
- * @see bt_socket_accept_l2cap_channel()
- */
-int bt_socket_reject_l2cap_channel(int socket_fd);
-
-/**
  * @}
  */
 
index 840b3d7..e19f0b1 100644 (file)
@@ -615,6 +615,7 @@ typedef enum {
        BT_FEATURE_COMMON = BT_FEATURE_BASE,
        BT_FEATURE_LE,
        BT_FEATURE_LE_5_0,
+       BT_FEATURE_LE_COC,
        BT_FEATURE_IPSP,
        BT_FEATURE_MESH,
        BT_FEATURE_AUDIO_CALL,
@@ -1308,278 +1309,6 @@ extern tizen_profile_t profile;
 
 #define TIZEN_FEATURE_ENABLE_LEGACY_GATT_CLIENT                TIZEN_PROFILE_MOBILE
 
-/**
- * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE
- * @brief Registers a L2CAP Connection-oriented Channel (CoC) server socket
- * with a specific protocol/service multiplexer (PSM) value. If 0 is passed,
- * the system will assign a dynamic psm value when bt_socket_listen_and_accept_l2cap_channel()
- * is called. This psm value can be read from the bt_socket_get_l2cap_psm().
- * @since_tizen 7.0
- * @privlevel public
- * @privilege %http://tizen.org/privilege/bluetooth
- *
- * @remarks A socket can be destroyed by bt_socket_destroy_l2cap_channel().
- *
- * @param[in] psm The dynamic psm value to start server
- * @param[out] socket_fd The file descriptor of socket to listen
- * @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_ENABLED  Not enabled
- * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
- * @retval #BT_ERROR_PERMISSION_DENIED  Permission denied
- * @retval #BT_ERROR_NOT_SUPPORTED  Not supported
- *
- * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED.
- *
- * @see bt_socket_listen_and_accept_l2cap_channel()
- * @see bt_socket_destroy_l2cap_channel()
- */
-int bt_socket_create_l2cap_channel(int psm, int *socket_fd);
-
-/**
- * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE
- * @brief Removes the L2CAP Connection-oriented Channel (CoC) server socket which was created using bt_socket_create_l2cap_channel().
- * @since_tizen 7.0
- * @privlevel public
- * @privilege %http://tizen.org/privilege/bluetooth
- * @remarks If callback function bt_socket_l2cap_channel_connection_state_changed_cb() is set and the remote Bluetooth device is connected, \n
- * then bt_socket_l2cap_channel_connection_state_changed_cb() will be called when this function is finished successfully.
- *
- * @param[in] socket_fd The file descriptor of socket (which was created using bt_socket_create_l2cap_channel()) to destroy
- * @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_ENABLED  Not enabled
- * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
- * @retval #BT_ERROR_PERMISSION_DENIED  Permission denied
- * @retval #BT_ERROR_NOT_SUPPORTED  Not supported
- *
- * @pre The socket must be created with bt_socket_create_l2cap_channel().
- * @post If callback function bt_socket_l2cap_channel_connection_state_changed_cb() is set and the remote Bluetooth device is connected,
- * then bt_socket_l2cap_channel_connection_state_changed_cb() will be called.
- * @see bt_socket_create_l2cap_channel()
- * @see bt_socket_l2cap_channel_connection_state_changed_cb()
- * @see bt_socket_set_l2cap_channel_connection_state_changed_cb()
- * @see bt_socket_unset_l2cap_channel_connection_state_changed_cb()
- */
-int bt_socket_destroy_l2cap_channel(int socket_fd);
-
-/**
- * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE
- * @brief Starts listening on passed L2CAP_LE socket and accepts connection requests.
- * @details Pop-up is shown automatically when a L2CAP CoC connection is requested. \n
- * bt_socket_l2cap_channel_connection_state_changed_cb() will be called with \n
- * #BT_SOCKET_CONNECTED if you click "yes" and connection is finished successfully.
- * @since_tizen 7.0
- * @privlevel public
- * @privilege %http://tizen.org/privilege/bluetooth
- * @param[in] socket_fd The file descriptor of socket on which start to listen
- * @param[in] max_pending_connections The maximum number of pending connections
- * @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_ENABLED  Not enabled
- * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
- * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
- * @retval #BT_ERROR_PERMISSION_DENIED  Permission denied
- * @retval #BT_ERROR_NOT_SUPPORTED  Not supported
- *
- * @pre The socket must be created with bt_socket_create_l2cap_channel().
- * @post If callback function bt_socket_l2cap_channel_connection_state_changed_cb() is set,
- * then bt_socket_l2cap_channel_connection_state_changed_cb() will be called when the remote Bluetooth device is connected.
- * @see bt_socket_create_l2cap_channel()
- * @see bt_socket_l2cap_channel_connection_state_changed_cb()
- * @see bt_socket_set_l2cap_channel_connection_state_changed_cb()
- * @see bt_socket_unset_l2cap_channel_connection_state_changed_cb()
- */
-int bt_socket_listen_and_accept_l2cap_channel(int socket_fd,
-                                               int max_pending_connections);
-
-/**
- * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE
- * @brief Get the assigned PSM for the listening L2CAP Connection-oriented Channel (CoC) server socket.
- * @details It is used to get the system assigned PSM value especially when bt_socket_create_l2cap_channel()
- * is called with psm value 0.
- * @since_tizen 7.0
- * @privlevel public
- * @privilege %http://tizen.org/privilege/bluetooth
- *
- * @param[in] socket_fd The file descriptor of connected socket which was received using bt_socket_l2cap_channel_connection_state_changed_cb()
- * @param[out] psm The assigned dynamic PSM value for the listening L2CAP CoC server socket
- *
- * @return 0 on success, otherwise a negative error value.
- * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
- * @retval #BT_ERROR_NOT_SUPPORTED   Not supported
- * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
- *
- * @pre The bt_socket_listen_and_accept_l2cap_channel() must be called.
- *
- * @see bt_socket_create_l2cap_channel()
- * @see bt_socket_listen_and_accept_l2cap_channel()
- */
-int bt_socket_get_l2cap_psm(int socket_fd, int *psm);
-
-/**
- * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE
- * @brief Connects to a specific L2CAP CoC socket on a remote Bluetooth device PSM, asynchronously.
- * @since_tizen 7.0
- * @privlevel public
- * @privilege %http://tizen.org/privilege/bluetooth
- *
- * @remarks A connection can be disconnected by bt_socket_disconnect_l2cap_channel().
- *
- * @param[in] remote_address The address of the remote Bluetooth device
- * @param[in] psm The dynamic psm of a remote Bluetooth device
- *
- * @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_ENABLED  Not enabled
- * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
- * @retval #BT_ERROR_PERMISSION_DENIED  Permission denied
- * @retval #BT_ERROR_NOT_SUPPORTED  Not supported
- *
- * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED.
- * @pre The remote device must be scannable with bt_adapter_le_start_scan().
- * @post This function invokes bt_socket_l2cap_channel_connection_state_changed_cb().
- *
- * @see bt_adapter_le_start_scan()
- * @see bt_socket_disconnect_l2cap_channel()
- * @see bt_socket_l2cap_channel_connection_state_changed_cb()
- * @see bt_socket_set_l2cap_channel_connection_state_changed_cb()
- * @see bt_socket_unset_l2cap_channel_connection_state_changed_cb()
- */
-int bt_socket_connect_l2cap_channel(const char *remote_address, int psm);
-
-/**
- * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE
- * @brief Disconnects the L2CAP CoC connection with the given file descriptor of connected socket.
- * @since_tizen 7.0
- * @privlevel public
- * @privilege %http://tizen.org/privilege/bluetooth
- * @param[in] socket_fd  The file descriptor of socket to close which was received using bt_socket_l2cap_channel_connection_state_changed_cb().
- * @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_ENABLED  Not enabled
- * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
- * @retval #BT_ERROR_PERMISSION_DENIED  Permission denied
- * @retval #BT_ERROR_NOT_SUPPORTED  Not supported
- *
- * @pre The connection must be established.
- *
- * @see bt_socket_l2cap_channel_connection_state_changed_cb()
- * @see bt_socket_set_l2cap_channel_connection_state_changed_cb()
- * @see bt_socket_unset_l2cap_channel_connection_state_changed_cb()
- */
-int bt_socket_disconnect_l2cap_channel(int socket_fd);
-
-/**
- * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE
- * @brief Sends data to the connected device.
- * @since_tizen 7.0
- * @privlevel public
- * @privilege %http://tizen.org/privilege/bluetooth
- * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
- *
- * @param[in] socket_fd The file descriptor of connected socket which was received using bt_socket_l2cap_channel_connection_state_changed_cb()
- * @param[in] data The data to be sent
- * @param[in] length The length of data to be sent
- *
- * @return the number of bytes written (zero indicates nothing was written).
- * @retval On error, -1 is returned, and errno is set appropriately. See write 2 man page.
- * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
- * @retval #BT_ERROR_NOT_SUPPORTED   Not supported
- * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
- * @exception BT_ERROR_PERMISSION_DENIED  Permission denied
- * @exception BT_ERROR_AGAIN  Resource temporarily unavailable
- *
- * @pre The connection must be established.
- *
- * @see bt_socket_l2cap_channel_connection_state_changed_cb()
- * @see bt_socket_set_l2cap_channel_connection_state_changed_cb()
- * @see bt_socket_unset_l2cap_channel_connection_state_changed_cb()
- */
-int bt_socket_send_data_l2cap_channel(int socket_fd, const char *data, int length);
-
-/**
- * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE
- * @brief  Registers a callback function that will be invoked when a L2CAP CoC connection is requested.
- * @since_tizen 7.0
- * @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_socket_connection_requested_cb() will be invoked.
- * @see bt_initialize()
- * @see bt_socket_unset_l2cap_channel_connection_requested_cb()
- */
-int bt_socket_set_l2cap_channel_connection_requested_cb(
-                                               bt_socket_connection_requested_cb callback, void *user_data);
-
-/**
- * @ingroup  CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE
- * @brief  Unregisters the callback function.
- * @since_tizen 7.0
- * @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_socket_set_l2cap_channel_connection_requested_cb()
- * @see  bt_socket_connection_requested_cb()
- */
-int bt_socket_unset_l2cap_channel_connection_requested_cb(void);
-
-/**
- * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE
- * @brief  Registers a callback function that will be invoked when the connection state changes.
- * @since_tizen 7.0
- * @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_socket_l2cap_channel_connection_state_changed_cb() will be invoked.
- * @see bt_initialize()
- * @see bt_socket_l2cap_channel_connection_state_changed_cb()
- * @see bt_socket_unset_l2cap_channel_connection_state_changed_cb()
- */
-int bt_socket_set_l2cap_channel_connection_state_changed_cb(
-                                       bt_socket_l2cap_channel_connection_state_changed_cb callback, void *user_data);
-
-/**
- * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE
- * @brief      Unregisters the callback function.
- * @since_tizen 7.0
- * @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_socket_l2cap_channel_connection_state_changed_cb()
- * @see bt_socket_set_l2cap_channel_connection_state_changed_cb()
- */
-int bt_socket_unset_l2cap_channel_connection_state_changed_cb(void);
-
 #ifdef __cplusplus
 }
 #endif
index 5d4da97..a62418a 100644 (file)
@@ -2156,6 +2156,40 @@ typedef enum {
  */
 typedef void *bt_scan_filter_h;
 
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE
+ * @brief L2CAP CoC connection data used for exchanging data between Bluetooth devices.
+ * @since_tizen 7.0
+ *
+ * @see bt_socket_l2cap_channel_connection_state_changed_cb()
+ */
+typedef struct {
+       int socket_fd;  /**< The file descriptor of connected socket */
+       int server_fd;  /**< The file descriptor of the server socket or -1 for client connection */
+       bt_socket_role_e local_role;    /**< The local device role in this connection */
+       char *remote_address;   /**< The remote device address */
+       int psm;        /**< The psm of the connected socket */
+} bt_socket_l2cap_le_connection_s;
+
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE
+ * @brief  Called when the l2cap channel socket connection state changes.
+ * @since_tizen 7.0
+ *
+ * @param[in] result The result of connection state changing
+ * @param[in] connection_state The connection state
+ * @param[in] connection The connection information which is established or disconnected
+ * @param[in] user_data The user data passed from the callback registration function
+ * @pre Either bt_socket_connect_l2cap_channel() will invoke this function.
+ * In addition, bt_socket_l2cap_channel_connection_state_changed_cb() will be invoked when the socket connection state is changed.
+ * @see bt_socket_listen_and_accept_l2cap_channel()
+ * @see bt_socket_connect_l2cap_channel()
+ * @see bt_socket_set_l2cap_channel_connection_state_changed_cb()
+ * @see bt_socket_unset_l2cap_channel_connection_state_changed_cb()
+ */
+typedef void (*bt_socket_l2cap_channel_connection_state_changed_cb)
+       (int result, bt_socket_connection_state_e connection_state, bt_socket_l2cap_le_connection_s *connection, void *user_data);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index 254bd0f..d55a748 100644 (file)
@@ -1687,40 +1687,6 @@ typedef bool (*bt_mesh_network_group_info_cb)
                (int result, bt_mesh_network_h network, int total,
                        bt_mesh_group_h group, void *user_data);
 
-/**
- * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE
- * @brief L2CAP CoC connection data used for exchanging data between Bluetooth devices.
- * @since_tizen 7.0
- *
- * @see bt_socket_l2cap_channel_connection_state_changed_cb()
- */
-typedef struct {
-       int socket_fd;  /**< The file descriptor of connected socket */
-       int server_fd;  /**< The file descriptor of the server socket or -1 for client connection */
-       bt_socket_role_e local_role;    /**< The local device role in this connection */
-       char *remote_address;   /**< The remote device address */
-       int psm;        /**< The psm of the connected socket */
-} bt_socket_l2cap_le_connection_s;
-
-/**
- * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE
- * @brief  Called when the l2cap channel socket connection state changes.
- * @since_tizen 7.0
- *
- * @param[in] result The result of connection state changing
- * @param[in] connection_state The connection state
- * @param[in] connection The connection information which is established or disconnected
- * @param[in] user_data The user data passed from the callback registration function
- * @pre Either bt_socket_connect_l2cap_channel() will invoke this function.
- * In addition, bt_socket_l2cap_channel_connection_state_changed_cb() will be invoked when the socket connection state is changed.
- * @see bt_socket_listen_and_accept_l2cap_channel()
- * @see bt_socket_connect_l2cap_channel()
- * @see bt_socket_set_l2cap_channel_connection_state_changed_cb()
- * @see bt_socket_unset_l2cap_channel_connection_state_changed_cb()
- */
-typedef void (*bt_socket_l2cap_channel_connection_state_changed_cb)
-       (int result, bt_socket_connection_state_e connection_state, bt_socket_l2cap_le_connection_s *connection, void *user_data);
-
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index da623f9..bdbcdaf 100644 (file)
@@ -312,6 +312,7 @@ static bt_feature_table_t feature_table[] = {
        {"tizen.org/feature/network.bluetooth", FALSE, FALSE},                  /* BT_FEATURE_COMMON */
        {"tizen.org/feature/network.bluetooth.le", FALSE, FALSE},               /* BT_FEATURE_LE */
        {"tizen.org/feature/network.bluetooth.le.5_0", FALSE, FALSE},           /* BT_FEATURE_LE_5_0 */
+       {"tizen.org/feature/network.bluetooth.le.coc", FALSE, FALSE},           /* BT_FEATURE_LE_COC */
        {"tizen.org/feature/network.bluetooth.le.ipsp", FALSE, FALSE},          /* BT_FEATURE_IPSP */
        {"tizen.org/feature/network.bluetooth.le.mesh", TRUE, TRUE},            /* BT_FEATURE_MESH */
        {"tizen.org/feature/network.bluetooth.audio.call", FALSE, FALSE},       /* BT_FEATURE_AUDIO_CALL */
index 26bf4fd..3f7bb46 100644 (file)
@@ -316,7 +316,7 @@ int bt_socket_create_l2cap_channel(int psm, int *socket_fd)
 {
        int ret = 0;
 
-       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON);
+       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_LE_COC);
        BT_CHECK_INIT_STATUS();
        BT_CHECK_INPUT_PARAMETER(socket_fd);
 
@@ -335,7 +335,7 @@ int bt_socket_destroy_l2cap_channel(int socket_fd)
 {
        int error_code = BT_ERROR_NONE;
 
-       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON);
+       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_LE_COC);
        BT_CHECK_INIT_STATUS();
        error_code = _bt_get_error_code(bluetooth_l2cap_le_remove_socket(socket_fd));
        if (error_code != BT_ERROR_NONE) {
@@ -349,7 +349,7 @@ int bt_socket_destroy_l2cap_channel(int socket_fd)
 /* LCOV_EXCL_START */
 int bt_socket_is_psm_used(int psm, bool *used)
 {
-       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON);
+       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_LE_COC);
        BT_CHECK_INIT_STATUS();
        BT_CHECK_INPUT_PARAMETER(used);
 
@@ -363,7 +363,7 @@ int bt_socket_listen_and_accept_l2cap_channel(int socket_fd,
 {
        int error_code = BT_ERROR_NONE;
 
-       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON);
+       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_LE_COC);
        BT_CHECK_INIT_STATUS();
        error_code = _bt_get_error_code(bluetooth_l2cap_le_listen_and_accept(socket_fd, max_pending_connections));
        if (error_code != BT_ERROR_NONE) {
@@ -379,7 +379,7 @@ int bt_socket_listen_l2cap_channel(int socket_fd, int max_pending_connections)
 {
        int error_code = BT_ERROR_NONE;
 
-       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON);
+       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_LE_COC);
        BT_CHECK_INIT_STATUS();
 
        error_code = _bt_get_error_code(bluetooth_l2cap_le_listen(socket_fd, max_pending_connections));
@@ -395,7 +395,7 @@ int bt_socket_accept_l2cap_channel(int socket_fd)
 {
        int error_code = BT_ERROR_NONE;
 
-       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON);
+       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_LE_COC);
        BT_CHECK_INIT_STATUS();
 
        error_code = _bt_get_error_code(bluetooth_l2cap_le_accept_connection(socket_fd));
@@ -411,7 +411,7 @@ int bt_socket_reject_l2cap_channel(int socket_fd)
 {
        int error_code = BT_ERROR_NONE;
 
-       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON);
+       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_LE_COC);
        BT_CHECK_INIT_STATUS();
 
        error_code = _bt_get_error_code(bluetooth_l2cap_le_reject_connection(socket_fd));
@@ -429,7 +429,7 @@ int bt_socket_connect_l2cap_channel(const char *remote_address, int psm)
        bluetooth_device_address_t addr_hex = { {0,} };
        int error_code = BT_ERROR_NONE;
 
-       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON);
+       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_LE_COC);
        BT_CHECK_INIT_STATUS(); /* LCOV_EXCL_START */
        BT_CHECK_INPUT_PARAMETER(remote_address);
 
@@ -448,7 +448,7 @@ int bt_socket_disconnect_l2cap_channel(int socket_fd)
 {
        int error_code = BT_ERROR_NONE;
 
-       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON);
+       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_LE_COC);
        BT_CHECK_INIT_STATUS(); /* LCOV_EXCL_START */
 
        error_code = _bt_get_error_code(bluetooth_l2cap_le_disconnect(socket_fd));
@@ -465,7 +465,7 @@ int bt_socket_send_data_l2cap_channel(int socket_fd, const char *data,
 {
        int ret = 0;
 
-       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON);
+       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_LE_COC);
        BT_CHECK_INIT_STATUS(); /* LCOV_EXCL_START */
        BT_CHECK_INPUT_PARAMETER(data);
 
@@ -497,7 +497,7 @@ int bt_socket_get_l2cap_psm(int socket_fd, int *psm)
 {
        int ret = 0;
 
-       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON);
+       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_LE_COC);
        BT_CHECK_INIT_STATUS(); /* LCOV_EXCL_START */
 
        ret = bluetooth_l2cap_le_get_psm(socket_fd, psm);
@@ -512,7 +512,7 @@ int bt_socket_get_l2cap_psm(int socket_fd, int *psm)
 int bt_socket_set_l2cap_channel_connection_state_changed_cb(
                                                bt_socket_l2cap_channel_connection_state_changed_cb callback, void *user_data)
 {
-       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON);
+       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_LE_COC);
        BT_CHECK_INIT_STATUS();
        BT_CHECK_INPUT_PARAMETER(callback);
        _bt_set_cb(BT_EVENT_L2CAP_CHANNEL_CONNECTION_STATE_CHANGED, callback, user_data);
@@ -521,7 +521,7 @@ int bt_socket_set_l2cap_channel_connection_state_changed_cb(
 
 int bt_socket_unset_l2cap_channel_connection_state_changed_cb(void)
 {
-       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON);
+       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_LE_COC);
        BT_CHECK_INIT_STATUS();
        _bt_unset_cb(BT_EVENT_L2CAP_CHANNEL_CONNECTION_STATE_CHANGED);
        return BT_ERROR_NONE;
@@ -530,7 +530,7 @@ int bt_socket_unset_l2cap_channel_connection_state_changed_cb(void)
 int bt_socket_set_l2cap_channel_connection_requested_cb(
                                        bt_socket_connection_requested_cb callback, void *user_data)
 {
-       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON);
+       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_LE_COC);
        BT_CHECK_INIT_STATUS();
        BT_CHECK_INPUT_PARAMETER(callback);
        _bt_set_cb(BT_EVENT_L2CAP_CHANNEL_CONNECTION_REQUESTED, callback, user_data);
@@ -539,7 +539,7 @@ int bt_socket_set_l2cap_channel_connection_requested_cb(
 
 int bt_socket_unset_l2cap_channel_connection_requested_cb(void)
 {
-       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON);
+       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_LE_COC);
        BT_CHECK_INIT_STATUS();
        _bt_unset_cb(BT_EVENT_L2CAP_CHANNEL_CONNECTION_REQUESTED);
        return BT_ERROR_NONE;