From: Kim Kibum Date: Sun, 29 Apr 2012 07:58:20 +0000 (+0900) Subject: upload tizen1.0 source X-Git-Tag: 2.0_alpha~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5eb955f7834189fd0573107fd15f0c2ced128d96;hp=19be7961c92801ca303b33772875e3c21fb60a22;p=framework%2Fapi%2Fbluetooth.git upload tizen1.0 source --- diff --git a/CMakeLists.txt b/CMakeLists.txt index bebbb55..0cfe898 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,7 @@ SET(INC_DIR include) INCLUDE_DIRECTORIES(${INC_DIR}) SET(dependents "dlog glib-2.0 capi-base-common bluetooth-api") +SET(pc_dependents "capi-base-common") INCLUDE(FindPkgConfig) pkg_check_modules(${fw_name} REQUIRED ${dependents}) @@ -50,9 +51,8 @@ INSTALL( ) SET(PC_NAME ${fw_name}) -SET(PC_REQUIRED ${dependents}) +SET(PC_REQUIRED ${pc_dependents}) SET(PC_LDFLAGS -l${fw_name}) -SET(PC_CFLAGS -I\${includedir}/network) CONFIGURE_FILE( capi-network-bluetooth.pc.in diff --git a/capi-network-bluetooth.pc.in b/capi-network-bluetooth.pc.in index fd41dbb..097a2d1 100644 --- a/capi-network-bluetooth.pc.in +++ b/capi-network-bluetooth.pc.in @@ -1,4 +1,3 @@ - # Package Information for pkg-config prefix=@PREFIX@ @@ -11,5 +10,5 @@ Description: @PACKAGE_DESCRIPTION@ Version: @VERSION@ Requires: @PC_REQUIRED@ Libs: -L${libdir} @PC_LDFLAGS@ -Cflags: -I${includedir} @PC_CFLAGS@ +Cflags: -I${includedir} diff --git a/debian/changelog b/debian/changelog index 07e84a6..277f508 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,40 @@ +capi-network-bluetooth (0.1.2-1) unstable; urgency=low + + * Fix the DTS testcase + * Git: api/bluetooth + * Tag: capi-network-bluetooth_0.1.2-1 + + -- DoHyun Pyun Thu, 12 Apr 2012 15:48:47 +0900 + +capi-network-bluetooth (0.1.1-1) unstable; urgency=low + + * Fix the crash in DTS test + * Git: api/bluetooth + * Tag: capi-network-bluetooth_0.1.1-1 + + -- DoHyun Pyun Thu, 29 Mar 2012 14:45:08 +0900 + +capi-network-bluetooth (0.1.0-14) unstable; urgency=low + + * Initialize the pointer to NULL after free + * Git: api/bluetooth + * Tag: capi-network-bluetooth_0.1.0-14 + + -- DoHyun Pyun Wed, 21 Mar 2012 17:15:59 +0900 + +capi-network-bluetooth (0.1.0-13) unstable; urgency=low + + * Correct dependent package + * Git: api/bluetooth + * Tag: capi-network-bluetooth_0.1.0-13 + + -- ByungWoo Lee Thu, 15 Mar 2012 13:13:36 +0900 + capi-network-bluetooth (0.1.0-12) unstable; urgency=low * Convert internal symbol to static - * Git: slp/api/bluetooth - * Tag: capi-network-bluetooth_0.1.0-12 + * Git: api/bluetooth + * Tag: capi-network-bluetooth_0.1.0-12 -- ByungWoo Lee Mon, 20 Feb 2012 15:50:45 +0900 @@ -10,7 +42,7 @@ capi-network-bluetooth (0.1.0-11) unstable; urgency=low * Add versioning of library * Git: api/bluetooth - * Tag: capi-network-bluetooth_0.1.0-11 + * Tag: capi-network-bluetooth_0.1.0-11 -- ByungWoo Lee Tue, 14 Feb 2012 17:09:56 +0900 @@ -18,7 +50,7 @@ capi-network-bluetooth (0.1.0-10) unstable; urgency=low * Correct typos * Git: api/bluetooth - * Tag: capi-network-bluetooth_0.1.0-10 + * Tag: capi-network-bluetooth_0.1.0-10 -- ByungWoo Lee Fri, 03 Feb 2012 09:43:46 +0900 @@ -32,7 +64,7 @@ capi-network-bluetooth (0.1.0-9) unstable; urgency=low capi-network-bluetooth (0.0.1-1) unstable; urgency=low - * Initial release. + * Initial release. * Git: api/bluetooth * Tag: capi-network-bluetooth_0.0.1-1 diff --git a/debian/control b/debian/control index 3cffddf..7299ecb 100644 --- a/debian/control +++ b/debian/control @@ -6,12 +6,12 @@ Build-Depends: debhelper (>= 5), dlog-dev, capi-base-common-dev, libglib2.0-dev, Package: capi-network-bluetooth Architecture: any -Depends: ${shilbs:Depends}, ${misc:Depends} +Depends: ${shlibs:Depends}, ${misc:Depends} Description: A Network Bluetooth library in Tizen Native API Package: capi-network-bluetooth-dev Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, capi-network-bluetooth (= ${Source-Version}), dlog-dev, capi-base-common-dev, libglib2.0-dev, libbluetooth-frwk-dev +Depends: ${shlibs:Depends}, ${misc:Depends}, capi-network-bluetooth (= ${Source-Version}), capi-base-common-dev Description: A Network Bluetooth library in Tizen Native API (DEV) Package: capi-network-bluetooth-dbg diff --git a/include/bluetooth.h b/include/bluetooth.h index 3950e99..60d828e 100644 --- a/include/bluetooth.h +++ b/include/bluetooth.h @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - + #ifndef __TIZEN_NETWORK_BLUETOOTH_H__ #define __TIZEN_NETWORK_BLUETOOTH_H__ @@ -253,12 +253,12 @@ typedef enum BT_MINOR_DEVICE_CLASS_HEATH_PULSE_OXIMETER = 0x14, /**< Pulse oximeter minor device class of health */ BT_MINOR_DEVICE_CLASS_HEATH_HEART_PULSE_RATE_MONITOR = 0x18, /**< Heart/Pulse rate monitor minor device class of health */ BT_MINOR_DEVICE_CLASS_HEATH_DATA_DISPLAY = 0x1C, /**< Health data display minor device class of health */ - BT_MINOR_DEVICE_CLASS_HEATH_STEP_COUNTER = 0x20, /**< Step counter minor device class of health */ - BT_MINOR_DEVICE_CLASS_HEATH_BODY_COMPOSITION_ANALYZER = 0x24, /**< Body composition analyzer minor device class of health */ - BT_MINOR_DEVICE_CLASS_HEATH_PEAK_FLOW_MONITOR = 0x28, /**< Peak flow monitor minor device class of health */ - BT_MINOR_DEVICE_CLASS_HEATH_MEDICATION_MONITOR = 0x2C, /**< Medication monitor minor device class of health */ - BT_MINOR_DEVICE_CLASS_HEATH_KNEE_PROSTHESIS = 0x30, /**< Knee prosthesis minor device class of health */ - BT_MINOR_DEVICE_CLASS_HEATH_ANKLE_PROSTHESIS = 0x34, /**< Ankle prosthesis minor device class of health */ + BT_MINOR_DEVICE_CLASS_HEATH_STEP_COUNTER = 0x20, /**< Step counter minor device class of health */ + BT_MINOR_DEVICE_CLASS_HEATH_BODY_COMPOSITION_ANALYZER = 0x24, /**< Body composition analyzer minor device class of health */ + BT_MINOR_DEVICE_CLASS_HEATH_PEAK_FLOW_MONITOR = 0x28, /**< Peak flow monitor minor device class of health */ + BT_MINOR_DEVICE_CLASS_HEATH_MEDICATION_MONITOR = 0x2C, /**< Medication monitor minor device class of health */ + BT_MINOR_DEVICE_CLASS_HEATH_KNEE_PROSTHESIS = 0x30, /**< Knee prosthesis minor device class of health */ + BT_MINOR_DEVICE_CLASS_HEATH_ANKLE_PROSTHESIS = 0x34, /**< Ankle prosthesis minor device class of health */ } bt_minor_device_class_e; /** @@ -278,7 +278,7 @@ typedef struct { bt_major_device_class_e major_device_class; /**< Major device class. */ bt_minor_device_class_e minor_device_class; /**< Minor device class. */ - int major_service_class_mask; /**< Major service class mask. + int major_service_class_mask; /**< Major service class mask. This value can be a combination of #bt_major_service_class_e like #BT_MAJOR_SERVICE_CLASS_RENDERING | #BT_MAJOR_SERVICE_CLASS_AUDIO */ } bt_class_s; @@ -311,7 +311,7 @@ typedef struct char* remote_name; /**< The name of remote device */ bt_class_s bt_class; /**< The Bluetooth classes */ char** service_uuid; /**< The UUID list of service */ - int service_count; /**< The number of services */ + int service_count; /**< The number of services */ bool is_bonded; /**< The bonding state */ bool is_connected; /**< The connection state */ bool is_authorized; /**< The authorization state */ @@ -322,7 +322,7 @@ typedef struct * @brief Service Discovery Protocol (SDP) data structure. * * @details This protocol is used for discovering available services or pear device, - * and finding one to connect with. + * and finding one to connect with. * * @see bt_device_service_searched_cb() */ @@ -371,7 +371,7 @@ typedef struct /** * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE - * @brief Called when the Bluetooth adapter state changes. + * @brief Called when the Bluetooth adapter state changes. * @param[in] result The result of the adapter state changing * @param[in] adapter_state The adapter state to be changed * @param[in] user_data The user data passed from the callback registration function @@ -379,13 +379,13 @@ typedef struct * @see bt_adapter_enable() * @see bt_adapter_disable() * @see bt_adapter_set_state_changed_cb() - * @see bt_adapter_unset_state_changed_cb() + * @see bt_adapter_unset_state_changed_cb() */ typedef void (*bt_adapter_state_changed_cb)(int result, bt_adapter_state_e adapter_state, void *user_data); /** * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE - * @brief Called when adapter name changes. + * @brief Called when adapter name changes. * @param[in] device_name The name of the Bluetooth device to be changed * @param[in] user_data The user data passed from the callback registration function * @pre This function will be invoked when the name of Bluetooth adapter changes @@ -398,14 +398,14 @@ typedef void (*bt_adapter_name_changed_cb)(char *device_name, void *user_data); /** * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE - * @brief Called when the visibility mode changes. + * @brief Called when the visibility mode changes. * @param[in] result The result of the visibility mode changing * @param[in] visibility_mode The visibility mode to be changed * @param[in] user_data The user data passed from the callback registration function - * + * * @pre This function will be invoked when the visibility of Bluetooth adapter changes * if you register this callback using bt_adapter_set_visibility_mode_changed_cb(). - * + * * @see bt_adapter_set_visibility() * @see bt_adapter_set_visibility_mode_changed_cb() * @see bt_adapter_unset_visibility_mode_changed_cb() @@ -415,26 +415,26 @@ typedef void (*bt_adapter_visibility_mode_changed_cb) /** * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE - * @brief Called when the state of device discovery changes. + * @brief Called when the state of device discovery changes. * - * @remarks If \a discovery_state is #BT_ADAPTER_DEVICE_DISCOVERY_FOUND, + * @remarks If \a discovery_state is #BT_ADAPTER_DEVICE_DISCOVERY_FOUND, * then you can get some information, such as remote device address, remote device name, rssi, and bonding state. * * @param[in] result The result of the device discovery * @param[in] discovery_state The discovery state to be changed * @param[in] device_info The information of the discovered device \n - * If \a discovery_state is #BT_ADAPTER_DEVICE_DISCOVERY_STARTED or + * If \a discovery_state is #BT_ADAPTER_DEVICE_DISCOVERY_STARTED or * #BT_ADAPTER_DEVICE_DISCOVERY_FINISHED, then \a device_info is NULL. * @param[in] user_data The user data passed from the callback registration function - * - * @pre Either bt_adapter_start_device_discovery() or bt_adapter_stop_device_discovery() will invoke this function + * + * @pre Either bt_adapter_start_device_discovery() or bt_adapter_stop_device_discovery() will invoke this function * if you register this callback using bt_adapter_set_device_discovery_state_changed_cb(). * - * @see bt_adapter_start_device_discovery() + * @see bt_adapter_start_device_discovery() * @see bt_adapter_stop_device_discovery() * @see bt_adapter_set_device_discovery_state_changed_cb() * @see bt_adapter_unset_device_discovery_state_changed_cb() - * + * */ typedef void (*bt_adapter_device_discovery_state_changed_cb) (int result, bt_adapter_device_discovery_state_e discovery_state, bt_adapter_device_discovery_info_s *discovery_info, void *user_data); @@ -445,12 +445,12 @@ typedef void (*bt_adapter_device_discovery_state_changed_cb) * * @param[in] device_info The bonded device information * @param[in] user_data The user data passed from the foreach function - * @return @c true to continue with the next iteration of the loop, + * @return @c true to continue with the next iteration of the loop, * \n @c false to break out of the loop. * @pre bt_adapter_foreach_bonded_device() will invoke this function. - * + * * @see bt_adapter_foreach_bonded_device() - * + * */ typedef bool (*bt_adapter_bonded_device_cb)(bt_device_info_s* device_info, void *user_data); @@ -458,7 +458,7 @@ typedef bool (*bt_adapter_bonded_device_cb)(bt_device_info_s* device_info, void * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE * @brief Called when the process of creating bond finishes. * @remarks If the remote user does not respond within 60 seconds, a time out will happen with #BT_ERROR_TIMED_OUT result code.\n - * If bt_device_cancel_bonding() is called and it returns #BT_ERROR_NONE, then this callback function will be called + * If bt_device_cancel_bonding() is called and it returns #BT_ERROR_NONE, then this callback function will be called * with #BT_ERROR_CANCELLED result. \n * If creating a bond succeeds but service search fails, then this callback will be called with #BT_ERROR_SERVICE_SEARCH_FAILED. * In this case, you should try service search again by bt_device_start_service_search() to get the supported service list. @@ -466,11 +466,11 @@ typedef bool (*bt_adapter_bonded_device_cb)(bt_device_info_s* device_info, void * @param[in] result The result of the bonding device * @param[in] device_info The device information which you creates bond with * @param[in] user_data The user data passed from the callback registration function - * - * @pre Either bt_device_create_bond() will invoke this function + * + * @pre Either bt_device_create_bond() will invoke this function * if you register this callback using bt_device_set_bond_created_cb(). * - * @see bt_device_create_bond() + * @see bt_device_create_bond() * @see bt_device_cancel_bonding() * @see bt_device_set_bond_created_cb() * @see bt_device_unset_bond_created_cb() @@ -479,13 +479,13 @@ typedef void (*bt_device_bond_created_cb)(int result, bt_device_info_s *device_i /** * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE - * @brief Called when the bond destroys. + * @brief Called when the bond destroys. * @param[in] result The result that a bond is destroyed * @param[in] remote_address The address of the remote Bluetooth device to destroy bond with * @param[in] user_data The user data passed from the callback registration function * @pre bt_device_destroy_bond() will invoke this function * if you register this callback using bt_device_set_bond_destroyed_cb(). - * + * * @see bt_device_destroy_bond() * @see bt_device_set_bond_destroyed_cb() * @see bt_device_unset_bond_destroyed_cb() @@ -494,14 +494,14 @@ typedef void (*bt_device_bond_destroyed_cb)(int result, char *remote_address, vo /** * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE - * @brief Called when the authorization of device changes. + * @brief Called when the authorization of device changes. * @param[in] authorization The authorization of device * @param[in] remote_address The address of the remote Bluetooth device which is (un)authorized * @param[in] user_data The user data passed from the callback registration function * @pre bt_device_set_authorization() will invoke this function if you register this callback using bt_device_set_authorization_changed_cb(). * * @see bt_device_set_authorization() - * @see #bt_device_set_authorization_changed_cb() + * @see #bt_device_set_authorization_changed_cb() * @see #bt_device_unset_authorization_changed_cb() */ typedef void (*bt_device_authorization_changed_cb) @@ -509,14 +509,14 @@ typedef void (*bt_device_authorization_changed_cb) /** * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE - * @brief Called when the process of service search finishes. - * @remark If bt_device_cancel_service_search() is called and it returns #BT_ERROR_NONE, + * @brief Called when the process of service search finishes. + * @remark If bt_device_cancel_service_search() is called and it returns #BT_ERROR_NONE, * then this callback function will be called with #BT_ERROR_CANCELLED result. * * @param[in] result The result of the service searching * @param[in] sdp_info The structure of service lists found on a device * @param[in] user_data The user data passed from the callback registration function - * @pre Either bt_device_start_service_search() will invoke this function + * @pre Either bt_device_start_service_search() will invoke this function * if you register this callback using bt_device_set_service_searched_cb(). * * @see bt_device_start_service_search() @@ -527,15 +527,15 @@ typedef void (*bt_device_authorization_changed_cb) */ typedef void (*bt_device_service_searched_cb)(int result, bt_device_sdp_info_s *sdp_info, void *user_data); -/** +/** * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE - * @brief Called when you receive data. + * @brief Called when you receive data. * * @param[in] data The received data from the remote device * @param[in] user_data The user data passed from the callback registration function * * @pre When the connected remote Bluetooth device invokes bt_socket_send_data(), - * this function will be invoked if you register this function using bt_socket_set_data_received_cb(). + * this function will be invoked if you register this function using bt_socket_set_data_received_cb(). * * @see bt_socket_set_data_received_cb() * @see bt_socket_unset_data_received_cb() @@ -552,7 +552,7 @@ typedef void (*bt_socket_data_received_cb)(bt_socket_received_data_s *data, void * @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_listen_and_accept_rfcomm() or bt_socket_connect_rfcomm() will invoke this function + * @pre Either bt_socket_listen_and_accept_rfcomm() or bt_socket_connect_rfcomm() will invoke this function * if you register this callback using bt_socket_set_connection_state_changed_cb(). \n * If the remote Bluetooth device is connected when bt_socket_destroy_rfcomm() is called, then bt_socket_connection_state_changed_cb() will be invoked. * @@ -585,7 +585,7 @@ int bt_initialize(void); * @ingroup CAPI_NETWORK_BLUETOOTH_MODULE * @brief Releases all resources of the Bluetooth API. * - * @remarks This function must be called if Bluetooth API is no longer needed. + * @remarks This function must be called if Bluetooth API is no longer needed. * * @return 0 on success, otherwise a negative error value. * @retval #BT_ERROR_NONE Successful @@ -603,7 +603,7 @@ int bt_deinitialize(void); * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE * @brief Enables the local Bluetooth adapter, asynchronously. * - * @details This function enables Bluetooth protocol stack and hardware. + * @details This function enables Bluetooth protocol stack and hardware. * * @return 0 on success, otherwise a negative error value. * @retval #BT_ERROR_NONE Successful @@ -618,7 +618,7 @@ int bt_deinitialize(void); * @see bt_adapter_get_state() * @see bt_adapter_disable() * @see bt_adapter_set_state_changed_cb() - * @see bt_adapter_unset_state_changed_cb() + * @see bt_adapter_unset_state_changed_cb() * @see bt_adapter_state_changed_cb() * */ @@ -626,9 +626,9 @@ int bt_adapter_enable(void); /** * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE - * @brief Disables the local Bluetooth adapter, asynchronously. + * @brief Disables the local Bluetooth adapter, asynchronously. * - * @details This function disables Bluetooth protocol stack and hardware. + * @details This function disables Bluetooth protocol stack and hardware. * * @remarks You should disable Bluetooth adapter to switch off Bluetooth chip, which is helpful for saving power. * @@ -663,7 +663,7 @@ int bt_adapter_disable(void); * * @pre Bluetooth service must be initialized with bt_initialize(). * - * @see bt_initialize() + * @see bt_initialize() * @see bt_adapter_enable() * @see bt_adapter_disable() */ @@ -680,13 +680,13 @@ int bt_adapter_get_state(bt_adapter_state_e *adapter_state); * @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_INVALID_PARAMETER Invalid parameter * @retval #BT_ERROR_NOT_ENABLED Not enabled * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory - * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_OPERATION_FAILED Operation failed * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). * @see bt_adapter_enable() - * @see bt_adapter_get_name() + * @see bt_adapter_get_name() */ int bt_adapter_get_address(char **local_address); @@ -694,7 +694,7 @@ int bt_adapter_get_address(char **local_address); * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE * @brief Gets the name of local Bluetooth adapter. * - * @details Use this function to get the friendly name associated with Bluetooth + * @details Use this function to get the friendly name associated with Bluetooth * device, retrieved by the remote Bluetooth devices. * * @remarks The @a local_name must be released with free() by you. @@ -707,21 +707,21 @@ int bt_adapter_get_address(char **local_address); * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter * @retval #BT_ERROR_NOT_ENABLED Not enabled * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory - * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_OPERATION_FAILED Operation failed * * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). - * - * @see bt_adapter_enable() - * @see bt_adapter_set_name() + * + * @see bt_adapter_enable() + * @see bt_adapter_set_name() */ int bt_adapter_get_name(char **local_name); /** * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE - * @brief Sets the name of local Bluetooth adapter. + * @brief Sets the name of local Bluetooth adapter. * * @param[in] local_name The name of the Bluetooth device. \n - * The maximum length is 248 characters. + * The maximum length is 248 characters. * * @return 0 on success, otherwise a negative error value. * @retval #BT_ERROR_NONE Successful @@ -732,12 +732,12 @@ int bt_adapter_get_name(char **local_name); * * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). * @post bt_adapter_name_changed_cb() will be invoked if this function returns #BT_ERROR_NONE. - * + * * @see bt_adapter_enable() * @see bt_adapter_get_name() * @see bt_adapter_name_changed_cb() * @see bt_adapter_set_name_changed_cb() - * @see bt_adapter_unset_name_changed_cb() + * @see bt_adapter_unset_name_changed_cb() */ int bt_adapter_set_name(const char *local_name); @@ -754,23 +754,23 @@ int bt_adapter_set_name(const char *local_name); * @retval #BT_ERROR_NOT_ENABLED Not enabled * @retval #BT_ERROR_OPERATION_FAILED Operation failed * - * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). * - * @see bt_adapter_enable() + * @see bt_adapter_enable() * @see bt_adapter_set_visibility() */ int bt_adapter_get_visibility(bt_adapter_visibility_mode_e *mode); /** * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE - * @brief Sets the visibility mode. + * @brief Sets the visibility mode. * - * @remarks #BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE will change to #BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE + * @remarks #BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE will change to #BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE * after the given @a timeout_sec goes. * * @param[in] discoverable_mode The Bluetooth discoverable mode to set * @param[in] timeout_sec The discoverable time duration (in seconds) - * @a timeout_sec is used only for #BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE mode. + * @a timeout_sec is used only for #BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE mode. * * @return 0 on success, otherwise a negative error value. * @retval #BT_ERROR_NONE Successful @@ -779,22 +779,22 @@ int bt_adapter_get_visibility(bt_adapter_visibility_mode_e *mode); * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter * @retval #BT_ERROR_OPERATION_FAILED Operation failed * - * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). - * @post bt_adapter_visibility_mode_changed_cb() will be invoked if this function returns #BT_ERROR_NONE. + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). + * @post bt_adapter_visibility_mode_changed_cb() will be invoked if this function returns #BT_ERROR_NONE. * * @see bt_adapter_enable() * @see bt_adapter_get_visibility() * @see bt_adapter_visibility_mode_changed_cb() * @see bt_adapter_set_visibility_mode_changed_cb() - * @see bt_adapter_unset_visibility_mode_changed_cb() + * @see bt_adapter_unset_visibility_mode_changed_cb() */ int bt_adapter_set_visibility(bt_adapter_visibility_mode_e discoverable_mode, int timeout_sec); /** * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE - * @brief Starts the device discovery, asynchronously. + * @brief Starts the device discovery, asynchronously. * - * @details If a device is discovered, bt_adapter_device_discovery_state_changed_cb() will be invoked + * @details If a device is discovered, bt_adapter_device_discovery_state_changed_cb() will be invoked * with #BT_ADAPTER_DEVICE_DISCOVERY_FOUND, and then bt_adapter_device_discovery_state_changed_cb() * will be called with #BT_ADAPTER_DEVICE_DISCOVERY_FINISHED in case of the completion or cancellation of the discovery. * @@ -805,10 +805,10 @@ int bt_adapter_set_visibility(bt_adapter_visibility_mode_e discoverable_mode, in * @retval #BT_ERROR_NONE Successful * @retval #BT_ERROR_NOT_INITIALIZED Not initialized * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_NOW_IN_PROGRESS Operation is now in progress + * @retval #BT_ERROR_NOW_IN_PROGRESS Operation is now in progress * @retval #BT_ERROR_OPERATION_FAILED Operation failed * - * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). * @post This function invokes bt_adapter_device_discovery_state_changed_cb(). * * @see bt_adapter_enable() @@ -816,15 +816,15 @@ int bt_adapter_set_visibility(bt_adapter_visibility_mode_e discoverable_mode, in * @see bt_adapter_stop_device_discovery() * @see bt_adapter_device_discovery_state_changed_cb() * @see bt_adapter_set_device_discovery_state_changed_cb() - * @see bt_adapter_unset_device_discovery_state_changed_cb() + * @see bt_adapter_unset_device_discovery_state_changed_cb() */ int bt_adapter_start_device_discovery(void); /** * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE - * @brief Stops the device discovery, asynchronously. - * @remarks The device discovery process will take 10 ~ 20 seconds to get all the devices in vicinity. - * + * @brief Stops the device discovery, asynchronously. + * @remarks The device discovery process will take 10 ~ 20 seconds to get all the devices in vicinity. + * * @return 0 on success, otherwise a negative error value. * @retval #BT_ERROR_NONE Successful * @retval #BT_ERROR_NOT_INITIALIZED Not initialized @@ -832,10 +832,10 @@ int bt_adapter_start_device_discovery(void); * @retval #BT_ERROR_NOT_IN_PROGRESS Operation is not in progress * @retval #BT_ERROR_OPERATION_FAILED Operation failed * - * @pre The device discovery must be in progress with bt_adapter_start_device_discovery(). + * @pre The device discovery must be in progress with bt_adapter_start_device_discovery(). * @post This function invokes bt_adapter_device_discovery_state_changed_cb(). * - * @see bt_adapter_is_discovering() + * @see bt_adapter_is_discovering() * @see bt_adapter_start_device_discovery() * @see bt_adapter_set_device_discovery_state_changed_cb() * @see bt_adapter_unset_device_discovery_state_changed_cb() @@ -847,8 +847,8 @@ int bt_adapter_stop_device_discovery(void); * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE * @brief Checks for the device discovery is in progress or not. * - * @remarks If Bluetooth discovery is in progress, other operations are not allowed and - * you have to either stop the discovery operation, or wait for it to be finished, + * @remarks If Bluetooth discovery is in progress, other operations are not allowed and + * you have to either stop the discovery operation, or wait for it to be finished, * before performing other operations. * @param[out] is_discovering The discovering status: (@c true = in progress , @c false = not in progress ) @@ -860,8 +860,8 @@ int bt_adapter_stop_device_discovery(void); * @retval #BT_ERROR_NOT_ENABLED Not enabled * @retval #BT_ERROR_OPERATION_FAILED Operation failed * - * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). - * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). + * * @see bt_adapter_enable() * @see bt_adapter_start_device_discovery() * @see bt_adapter_stop_device_discovery() @@ -870,8 +870,8 @@ int bt_adapter_is_discovering(bool* is_discovering); /** * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE - * @brief Retrieves the device information of all bonded devices. - * + * @brief Retrieves the device information of all bonded devices. + * * @param [in] callback The callback function to invoke * @param [in] user_data The user data passed from the foreach function * @@ -879,11 +879,11 @@ int bt_adapter_is_discovering(bool* is_discovering); * @retval #BT_ERROR_NONE Successful * @retval #BT_ERROR_NOT_INITIALIZED Not initialized * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory * @retval #BT_ERROR_NOT_ENABLED Not enabled * @retval #BT_ERROR_OPERATION_FAILED Operation failed * - * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). * @post This function invokes bt_adapter_bonded_device_cb(). * * @see bt_adapter_bonded_device_cb() @@ -903,7 +903,7 @@ int bt_adapter_foreach_bonded_device(bt_adapter_bonded_device_cb callback, void * @retval #BT_ERROR_NOT_INITIALIZED Not initialized * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter * - * @pre The Bluetooth service must be initialized with bt_initialize(). + * @pre The Bluetooth service must be initialized with bt_initialize(). * @post bt_adapter_state_changed_cb() will be invoked. * * @see bt_initialize() @@ -921,7 +921,7 @@ int bt_adapter_set_state_changed_cb(bt_adapter_state_changed_cb callback, void * * @retval #BT_ERROR_NONE Successful * @retval #BT_ERROR_NOT_INITIALIZED Not initialized * - * @pre The Bluetooth service must be initialized with bt_initialize(). + * @pre The Bluetooth service must be initialized with bt_initialize(). * * @see bt_initialize() * @see bt_adapter_set_state_changed_cb() @@ -940,10 +940,10 @@ int bt_adapter_unset_state_changed_cb(void); * @retval #BT_ERROR_NOT_INITIALIZED Not initialized * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter * - * @pre The Bluetooth service must be initialized with bt_initialize(). + * @pre The Bluetooth service must be initialized with bt_initialize(). * @post bt_adapter_name_changed_cb() will be invoked. * - * @see bt_initialize() + * @see bt_initialize() * @see bt_adapter_name_changed_cb() * @see bt_adapter_unset_name_changed_cb() */ @@ -976,10 +976,10 @@ int bt_adapter_unset_name_changed_cb(void); * @retval #BT_ERROR_NOT_INITIALIZED Not initialized * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter * - * @pre The Bluetooth service must be initialized with bt_initialize(). + * @pre The Bluetooth service must be initialized with bt_initialize(). * @post bt_adapter_visibility_mode_changed_cb() will be invoked. * - * @see bt_initialize() + * @see bt_initialize() * @see bt_adapter_visibility_mode_changed_cb() * @see bt_adapter_unset_visibility_mode_changed_cb() */ @@ -993,9 +993,9 @@ int bt_adapter_set_visibility_mode_changed_cb(bt_adapter_visibility_mode_changed * @retval #BT_ERROR_NONE Successful * @retval #BT_ERROR_NOT_INITIALIZED Not initialized * - * @pre The Bluetooth service must be initialized with bt_initialize(). + * @pre The Bluetooth service must be initialized with bt_initialize(). * - * @see bt_initialize() + * @see bt_initialize() * @see bt_adapter_set_visibility_mode_changed_cb() */ int bt_adapter_unset_visibility_mode_changed_cb(void); @@ -1012,13 +1012,13 @@ int bt_adapter_unset_visibility_mode_changed_cb(void); * @retval #BT_ERROR_NOT_INITIALIZED Not initialized * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter * - * @pre The Bluetooth service must be initialized with bt_initialize(). + * @pre The Bluetooth service must be initialized with bt_initialize(). * @post bt_adapter_device_discovery_state_changed_cb() will be invoked. * - * @see bt_initialize() + * @see bt_initialize() * @see bt_adapter_device_discovery_state_changed_cb() * @see bt_adapter_set_device_discovery_state_changed_cb() - * @see bt_adapter_unset_device_discovery_state_changed_cb() + * @see bt_adapter_unset_device_discovery_state_changed_cb() */ int bt_adapter_set_device_discovery_state_changed_cb(bt_adapter_device_discovery_state_changed_cb callback, void *user_data); @@ -1032,15 +1032,15 @@ int bt_adapter_set_device_discovery_state_changed_cb(bt_adapter_device_discovery * * @pre The Bluetooth service must be initialized with bt_initialize(). * - * @see bt_initialize() - * @see bt_adapter_set_device_discovery_state_changed_cb() + * @see bt_initialize() + * @see bt_adapter_set_device_discovery_state_changed_cb() */ int bt_adapter_unset_device_discovery_state_changed_cb(void); /** * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE - * @brief Creates a bond with a remote Bluetooth device, asynchronously. + * @brief Creates a bond with a remote Bluetooth device, asynchronously. * * @remarks A bond can be destroyed by bt_device_destroy_bond().\n * The bonding request can be cancelled by bt_device_cancel_bonding(). @@ -1065,34 +1065,34 @@ int bt_adapter_unset_device_discovery_state_changed_cb(void); * @see bt_device_cancel_bonding() * @see bt_device_destroy_bond() * @see bt_device_set_bond_created_cb() - * @see bt_device_unset_bond_created_cb() + * @see bt_device_unset_bond_created_cb() */ int bt_device_create_bond(const char *remote_address); /** * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE - * @brief Cancels the bonding process. + * @brief Cancels the bonding process. * - * @remakrs Use this function when the remote Bluetooth device is not responding to the + * @remakrs Use this function when the remote Bluetooth device is not responding to the * bond request or you wish to cancel the bonding request. - * + * * @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_NOT_IN_PROGRESS Operation not in progress - * @pre The creating a bond must be in progress by bt_device_create_bond(). + * @pre The creating a bond must be in progress by bt_device_create_bond(). * * @see bt_device_create_bond() - * @see bt_device_bond_created_cb() + * @see bt_device_bond_created_cb() * @see bt_device_set_bond_created_cb() - * @see bt_device_unset_bond_created_cb() + * @see bt_device_unset_bond_created_cb() */ int bt_device_cancel_bonding(void); /** * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE - * @brief Destroys the bond, asynchronously. + * @brief Destroys the bond, asynchronously. * * @param[in] remote_address The address of the remote Bluetooth device to remove bonding * @@ -1106,20 +1106,20 @@ int bt_device_cancel_bonding(void); * @retval #BT_ERROR_OPERATION_FAILED Operation failed * * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). - * @pre The bond with the remote device must be created with bt_device_create_bond(). + * @pre The bond with the remote device must be created with bt_device_create_bond(). * @post This function invokes bt_device_bond_destroyed_cb(). * * @see bt_adapter_enable() * @see bt_device_create_bond() * @see bt_device_bond_destroyed_cb() * @see bt_device_set_bond_destroyed_cb() - * @see bt_device_unset_bond_destroyed_cb() + * @see bt_device_unset_bond_destroyed_cb() */ int bt_device_destroy_bond(const char *remote_address); /** * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE - * @brief Sets an alias for the bonded device. + * @brief Sets an alias for the bonded device. * * @param[in] remote_address The address of the remote Bluetooth device * @param[in] alias The alias of the remote Bluetooth device @@ -1128,50 +1128,50 @@ int bt_device_destroy_bond(const char *remote_address); * @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_REMOTE_DEVICE_NOT_BONDED Remote device not bonded + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_BONDED Remote device not bonded * @retval #BT_ERROR_OPERATION_FAILED Operation failed * * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). - * @pre The bond with the remote device must be created with bt_device_create_bond(). + * @pre The bond with the remote device must be created with bt_device_create_bond(). * * @see bt_adapter_enable() - * @see bt_device_create_bond() + * @see bt_device_create_bond() */ int bt_device_set_alias(const char *remote_address, const char *alias); /** * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE - * @brief Sets the authorization of a bonded device, asynchronously. + * @brief Sets the authorization of a bonded device, asynchronously. * * @remarks Once a device is authorized, you don't need to receive a confirmation. - * + * * @param[in] remote_address The address of the remote Bluetooth device to authorize * @param[in] authorization The Bluetooth authorization state - * + * * @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_REMOTE_DEVICE_NOT_BONDED Remote device not bonded + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_BONDED Remote device not bonded * @retval #BT_ERROR_OPERATION_FAILED Operation failed * * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). - * @pre The bond with the remote device must be created with bt_device_create_bond(). + * @pre The bond with the remote device must be created with bt_device_create_bond(). * @post bt_device_authorization_changed_cb() will be invoked. * * @see bt_adapter_enable() - * @see bt_device_create_bond() + * @see bt_device_create_bond() * @see bt_device_authorization_changed_cb() * @see bt_device_set_authorization_changed_cb() - * @see bt_device_unset_authorization_changed_cb() + * @see bt_device_unset_authorization_changed_cb() */ int bt_device_set_authorization(const char *remote_address, bt_device_authorization_e authorization_state); /** * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE - * @brief Starts the search for services supported by the specified device, asynchronously. + * @brief Starts the search for services supported by the specified device, asynchronously. * * @remarks If creating a bond succeeds, which means bt_device_bond_created_cb() is called with result #BT_ERROR_NONE, * then you don't need to run this function.\n @@ -1187,20 +1187,20 @@ int bt_device_set_authorization(const char *remote_address, bt_device_authorizat * @retval #BT_ERROR_NOT_ENABLED Not enabled * @retval #BT_ERROR_REMOTE_DEVICE_NOT_BONDED Remote device not bonded * @retval #BT_ERROR_SERVICE_SEARCH_FAILED Service search failed - * + * * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). - * @pre The remote device must be discoverable with bt_adapter_start_device_discovery(). - * @pre The bond with the remote device must be created with bt_device_create_bond(). + * @pre The remote device must be discoverable with bt_adapter_start_device_discovery(). + * @pre The bond with the remote device must be created with bt_device_create_bond(). * @post This function invokes bt_device_service_searched_cb(). * * @see bt_adapter_enable() * @see bt_adapter_start_device_discovery() - * @see bt_device_create_bond() + * @see bt_device_create_bond() * @see bt_device_bond_created_cb() * @see bt_device_service_searched_cb() * @see bt_device_cancel_service_search() * @see bt_device_set_service_searched_cb() - * @see bt_device_unset_service_searched_cb() + * @see bt_device_unset_service_searched_cb() */ int bt_device_start_service_search(const char *remote_address); @@ -1212,16 +1212,16 @@ int bt_device_start_service_search(const char *remote_address); * @retval #BT_ERROR_NONE Successful * @retval #BT_ERROR_NOT_INITIALIZED Not initialized * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_REMOTE_DEVICE_NOT_BONDED Remote device not bonded + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_BONDED Remote device not bonded * @retval #BT_ERROR_NOT_IN_PROGRESS Operation not in progress * @retval #BT_ERROR_OPERATION_FAILED Operation failed * - * @pre The service search must be in progress by bt_device_start_service_search(). + * @pre The service search must be in progress by bt_device_start_service_search(). * * @see bt_device_start_service_search() - * @see bt_device_service_searched_cb() + * @see bt_device_service_searched_cb() * @see bt_device_set_service_searched_cb() - * @see bt_device_unset_service_searched_cb() + * @see bt_device_unset_service_searched_cb() */ int bt_device_cancel_service_search(void); @@ -1234,8 +1234,8 @@ int bt_device_cancel_service_search(void); * @retval #BT_ERROR_NONE Successful * @retval #BT_ERROR_NOT_INITIALIZED Not initialized * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @pre The Bluetooth service must be initialized with bt_initialize(). - * @post bt_device_bond_created_cb() will be invoked. + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post bt_device_bond_created_cb() will be invoked. * @see bt_initialize() * @see bt_device_bond_created_cb() * @see bt_device_unset_bond_created_cb() @@ -1248,8 +1248,8 @@ int bt_device_set_bond_created_cb(bt_device_bond_created_cb callback, void *user * @return 0 on success, otherwise a negative error value. * @retval #BT_ERROR_NONE Successful * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @pre The Bluetooth service must be initialized with bt_initialize(). - * @see bt_initialize() + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @see bt_initialize() * @see bt_device_set_bond_created_cb() */ int bt_device_unset_bond_created_cb(void); @@ -1263,9 +1263,9 @@ int bt_device_unset_bond_created_cb(void); * @retval #BT_ERROR_NONE Successful * @retval #BT_ERROR_NOT_INITIALIZED Not initialized * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @pre The Bluetooth service must be initialized with bt_initialize(). - * @post bt_device_bond_destroyed_cb() will be invoked. - * @see bt_initialize() + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post bt_device_bond_destroyed_cb() will be invoked. + * @see bt_initialize() * @see bt_device_bond_destroyed_cb() * @see bt_device_unset_bond_destroyed_cb() */ @@ -1277,8 +1277,8 @@ int bt_device_set_bond_destroyed_cb(bt_device_bond_destroyed_cb callback, void * * @return 0 on success, otherwise a negative error value. * @retval #BT_ERROR_NONE Successful * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @pre The Bluetooth service must be initialized with bt_initialize(). - * @see bt_initialize() + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @see bt_initialize() * @see bt_device_set_bond_destroyed_cb() */ int bt_device_unset_bond_destroyed_cb(void); @@ -1292,11 +1292,11 @@ int bt_device_unset_bond_destroyed_cb(void); * @retval #BT_ERROR_NONE Successful * @retval #BT_ERROR_NOT_INITIALIZED Not initialized * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @pre The Bluetooth service must be initialized with bt_initialize(). - * @post bt_device_authorization_changed_cb() will be invoked. - * @see bt_initialize() + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post bt_device_authorization_changed_cb() will be invoked. + * @see bt_initialize() * @see bt_device_authorization_changed_cb() - * @see bt_device_set_authorization_changed_cb() + * @see bt_device_set_authorization_changed_cb() * @see bt_device_unset_authorization_changed_cb() */ int bt_device_set_authorization_changed_cb(bt_device_authorization_changed_cb callback, void *user_data); @@ -1307,8 +1307,8 @@ int bt_device_set_authorization_changed_cb(bt_device_authorization_changed_cb ca * @return 0 on success, otherwise a negative error value. * @retval #BT_ERROR_NONE Successful * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @pre The Bluetooth service must be initialized with bt_initialize(). - * @see bt_initialize() + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @see bt_initialize() * @see bt_device_set_authorization_changed_cb() */ int bt_device_unset_authorization_changed_cb(void); @@ -1322,9 +1322,9 @@ int bt_device_unset_authorization_changed_cb(void); * @retval #BT_ERROR_NONE Successful * @retval #BT_ERROR_NOT_INITIALIZED Not initialized * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @pre The Bluetooth service must be initialized with bt_initialize(). - * @post bt_device_service_searched_cb() will be invoked. - * @see bt_initialize() + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post bt_device_service_searched_cb() will be invoked. + * @see bt_initialize() * @see bt_device_service_searched_cb() * @see bt_device_unset_service_searched_cb() */ @@ -1336,15 +1336,15 @@ int bt_device_set_service_searched_cb(bt_device_service_searched_cb callback, vo * @return 0 on success, otherwise a negative error value. * @retval #BT_ERROR_NONE Successful * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @pre The Bluetooth service must be initialized with bt_initialize(). - * @see bt_initialize() + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @see bt_initialize() * @see bt_device_set_service_searched_cb() */ int bt_device_unset_service_searched_cb(void); /** * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE - * @brief Registers a rfcomm socket with a specific UUID. + * @brief Registers a rfcomm socket with a specific UUID. * * @remarks A socket can be destroyed by bt_socket_destroy_rfcomm(). * @@ -1357,9 +1357,9 @@ int bt_device_unset_service_searched_cb(void); * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter * @retval #BT_ERROR_NOT_ENABLED Not enabled * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). * - * @see bt_adapter_enable() + * @see bt_adapter_enable() * @see bt_socket_listen_and_accept_rfcomm() * @see bt_socket_destroy_rfcomm() */ @@ -1377,7 +1377,7 @@ int bt_socket_create_rfcomm(const char* port_uuid, int *socket_fd); * @retval #BT_ERROR_NOT_ENABLED Not enabled * @retval #BT_ERROR_OPERATION_FAILED Operation failed * - * @pre The socket must be created with bt_socket_create_rfcomm(). + * @pre The socket must be created with bt_socket_create_rfcomm(). * @post If callback function bt_socket_connection_state_changed_cb() is set and the remote Bluetooth device is connected, * then bt_socket_connection_state_changed_cb() will be called. * @@ -1390,7 +1390,7 @@ int bt_socket_destroy_rfcomm(int socket_fd); /** * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE - * @brief Starts listening on passed rfcomm socket and accepts connection requests, asynchronously. + * @brief Starts listening on passed rfcomm socket and accepts connection requests, asynchronously. * * @param[in] socket_fd The socket file descriptor on which start to listen * @param[in] max_pending_connections The maximum number of pending connections @@ -1398,25 +1398,25 @@ int bt_socket_destroy_rfcomm(int socket_fd); * @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_NOT_ENABLED Not enabled * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_OPERATION_FAILED Operation failed * - * @pre The socket must be created with bt_socket_create_rfcomm(). + * @pre The socket must be created with bt_socket_create_rfcomm(). * @post This function invokes bt_socket_connection_state_changed_cb(). * * @see bt_socket_create_rfcomm() * @see bt_socket_connection_state_changed_cb() * @see bt_socket_set_connection_state_changed_cb() - * @see bt_socket_unset_connection_state_changed_cb() + * @see bt_socket_unset_connection_state_changed_cb() */ int bt_socket_listen_and_accept_rfcomm(int socket_fd, int max_pending_connections); /** * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE - * @brief Connects to a specific RFCOMM based service on a remote Bluetooth device UUID, asynchronously. + * @brief Connects to a specific RFCOMM based service on a remote Bluetooth device UUID, asynchronously. * - * @remarks A connection can be disconnected by bt_socket_disconnect_rfcomm(). + * @remarks A connection can be disconnected by bt_socket_disconnect_rfcomm(). * * @param[in] remote_address The address of the remote Bluetooth device * @param[in] remote_port_uuid The UUID of service provided by the remote Bluetooth device @@ -1431,9 +1431,9 @@ int bt_socket_listen_and_accept_rfcomm(int socket_fd, int max_pending_connection * * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). * @pre The remote device must be discoverable with bt_adapter_start_device_discovery(). - * @pre The bond with the remote device must be created with bt_device_create_bond(). + * @pre The bond with the remote device must be created with bt_device_create_bond(). * @post This function invokes bt_socket_connection_state_changed_cb(). - * + * * @see bt_adapter_enable() * @see bt_device_create_bond() * @see bt_adapter_start_device_discovery() @@ -1441,48 +1441,48 @@ int bt_socket_listen_and_accept_rfcomm(int socket_fd, int max_pending_connection * @see bt_socket_disconnect_rfcomm() * @see bt_socket_connection_state_changed_cb() * @see bt_socket_set_connection_state_changed_cb() - * @see bt_socket_unset_connection_state_changed_cb() + * @see bt_socket_unset_connection_state_changed_cb() */ int bt_socket_connect_rfcomm(const char *remote_address, const char* remote_port_uuid); /** * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE - * @brief Disconnects the RFCOMM connection with the given socket file descriptor. + * @brief Disconnects the RFCOMM connection with the given socket file descriptor. * @remarks Because this is a synchronous function, bt_socket_connection_state_changed_cb() won't be called - * even though a connection is disconnected successfully. + * even though a connection is disconnected successfully. * * @param[in] socket_fd The socket file descriptor to close * * @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_NOT_ENABLED Not enabled * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter * - * @pre The connection must be established with bt_socket_connect_rfcomm(). - * + * @pre The connection must be established with bt_socket_connect_rfcomm(). + * * @see bt_socket_connect_rfcomm() */ int bt_socket_disconnect_rfcomm(int socket_fd); /** * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE - * @brief Sends data to the connected device. + * @brief Sends data to the connected device. * - * @param[in] socket_fd The connected socket + * @param[in] socket_fd The connected socket * @param[in] data The data to be sent * @param[in] length The length of data to be sent * * @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_NOT_ENABLED Not enabled * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter * @retval #BT_ERROR_OPERATION_FAILED Operation failed * - * @pre The connection must be established with either bt_socket_connect_rfcomm() or bt_socket_listen_and_accept_rfcomm(). + * @pre The connection must be established with either bt_socket_connect_rfcomm() or bt_socket_listen_and_accept_rfcomm(). * - * @see bt_socket_connect_rfcomm() + * @see bt_socket_connect_rfcomm() * @see bt_socket_listen_and_accept_rfcomm() */ int bt_socket_send_data(int socket_fd, const char* data, int length); @@ -1496,11 +1496,11 @@ int bt_socket_send_data(int socket_fd, const char* data, int length); * @retval #BT_ERROR_NONE Successful * @retval #BT_ERROR_NOT_INITIALIZED Not initialized * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @pre The Bluetooth service must be initialized with bt_initialize(). + * @pre The Bluetooth service must be initialized with bt_initialize(). * @post bt_socket_data_received_cb() will be invoked. * @see bt_initialize() * @see bt_socket_data_received_cb() - * @see bt_socket_set_data_received_cb() + * @see bt_socket_set_data_received_cb() * @see bt_socket_unset_data_received_cb() */ int bt_socket_set_data_received_cb(bt_socket_data_received_cb callback, void *user_data); @@ -1511,7 +1511,7 @@ int bt_socket_set_data_received_cb(bt_socket_data_received_cb callback, void *us * @return 0 on success, otherwise a negative error value. * @retval #BT_ERROR_NONE Successful * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @pre The Bluetooth service must be initialized with bt_initialize(). + * @pre The Bluetooth service must be initialized with bt_initialize(). * @see bt_initialize() * @see bt_socket_data_received_cb() * @see bt_socket_set_data_received_cb() @@ -1527,9 +1527,9 @@ int bt_socket_unset_data_received_cb(void); * @retval #BT_ERROR_NONE Successful * @retval #BT_ERROR_NOT_INITIALIZED Not initialized * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @pre The Bluetooth service must be initialized with bt_initialize(). + * @pre The Bluetooth service must be initialized with bt_initialize(). * @post bt_socket_connection_state_changed_cb() will be invoked. - * @see bt_initialize() + * @see bt_initialize() * @see bt_socket_connection_state_changed_cb() * @see bt_socket_unset_connection_state_changed_cb() */ @@ -1541,8 +1541,8 @@ int bt_socket_set_connection_state_changed_cb(bt_socket_connection_state_changed * @return 0 on success, otherwise a negative error value. * @retval #BT_ERROR_NONE Successful * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @pre The Bluetooth service must be initialized with bt_initialize(). - * @see bt_initialize() + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @see bt_initialize() * @see bt_socket_connection_state_changed_cb() * @see bt_socket_set_connection_state_changed_cb() */ diff --git a/packaging/capi-network-bluetooth.spec b/packaging/capi-network-bluetooth.spec index 0fcef6a..3a5f868 100644 --- a/packaging/capi-network-bluetooth.spec +++ b/packaging/capi-network-bluetooth.spec @@ -1,6 +1,6 @@ Name: capi-network-bluetooth Summary: Network Bluetooth Framework -Version: 0.1.0 +Version: 0.1.2 Release: 1 Group: TO_BE/FILLED_IN License: Apache-2.0 @@ -13,7 +13,8 @@ BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(bluetooth-api) -BuildRequires: capi-base-common +BuildRequires: pkgconfig(capi-base-common) + BuildRequires: cmake @@ -32,9 +33,8 @@ Network Bluetooth Framework (DEV). %setup -q %build -FULLVER=%{version} -MAJORVER=`echo ${FULLVER} | cut -d '.' -f 1` -cmake . -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=${FULLVER} -DMAJORVER=${MAJORVER} +MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` +cmake . -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER} make %{?jobs:-j%jobs} @@ -48,8 +48,10 @@ rm -rf %{buildroot} %postun -p /sbin/ldconfig %files -/usr/lib/*.so* +%{_libdir}/libcapi-network-bluetooth.so.* %files devel -/usr/include/* -/usr/lib/pkgconfig/capi-network-bluetooth.pc +%{_includedir}/network/bluetooth.h +%{_libdir}/pkgconfig/capi-network-bluetooth.pc +%{_libdir}/libcapi-network-bluetooth.so + diff --git a/src/bluetooth.c b/src/bluetooth.c index edee953..04e5a11 100644 --- a/src/bluetooth.c +++ b/src/bluetooth.c @@ -14,7 +14,6 @@ * limitations under the License. */ - #include #include #include @@ -32,10 +31,7 @@ #define LOG_TAG "TIZEN_N_BLUETOOTH" static bool is_initialized = false; -static bool is_creating_bond = false; -static bt_device_info_s* bonded_device = NULL; -static bt_event_sig_event_slot_s bt_event_slot_container[] = -{ +static bt_event_sig_event_slot_s bt_event_slot_container[] = { {BT_EVENT_STATE_CHANGED, NULL, NULL}, {BT_EVENT_NAME_CHANGED, NULL, NULL}, {BT_EVENT_VISIBILITY_MODE_CHANGED, NULL, NULL}, @@ -48,8 +44,7 @@ static bt_event_sig_event_slot_s bt_event_slot_container[] = {BT_EVENT_CONNECTION_STATE_CHANGED, NULL, NULL}, }; - -/* +/* * Internal Macros */ #define BT_CHECK_INIT_STATUS() \ @@ -66,7 +61,7 @@ static bt_event_sig_event_slot_s bt_event_slot_container[] = return BT_ERROR_INVALID_PARAMETER; \ } -/* +/* * Internal Functions */ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *user_data); @@ -77,22 +72,16 @@ static void __bt_convert_lower_to_upper(char* origin); static bt_adapter_visibility_mode_e __bt_get_bt_adapter_visibility_mode_e(bluetooth_discoverable_mode_t mode); static int __bt_get_bt_device_sdp_info_s(bt_device_sdp_info_s **dest, bt_sdp_info_t *source); static void __bt_free_bt_device_sdp_info_s(bt_device_sdp_info_s *sdp_info); -static int __bt_get_bt_adapter_device_discovery_info_s - (bt_adapter_device_discovery_info_s **discovery_info, bluetooth_device_info_t *source_info); +static int __bt_get_bt_adapter_device_discovery_info_s(bt_adapter_device_discovery_info_s **discovery_info, bluetooth_device_info_t *source_info); static void __bt_free_bt_adapter_device_discovery_info_s(bt_adapter_device_discovery_info_s *discovery_info); -static int __bt_copy_service_list(bt_device_info_s *bonded_device_info, bt_device_sdp_info_s *sdp_info); - - /* * Public Functions */ int bt_initialize(void) { - if( is_initialized != true ) - { - if( bluetooth_register_callback(&__bt_event_proxy, NULL) != BLUETOOTH_ERROR_NONE ) - { + if (is_initialized != true) { + if (bluetooth_register_callback(&__bt_event_proxy, NULL) != BLUETOOTH_ERROR_NONE) { LOGE("[%s] OPERATION_FAILED(0x%08x)", __FUNCTION__, BT_ERROR_OPERATION_FAILED); return BT_ERROR_OPERATION_FAILED; } @@ -105,25 +94,22 @@ int bt_initialize(void) int bt_deinitialize(void) { BT_CHECK_INIT_STATUS(); - if( bluetooth_unregister_callback() != BLUETOOTH_ERROR_NONE ) - { + if (bluetooth_unregister_callback() != BLUETOOTH_ERROR_NONE) { LOGE("[%s] OPERATION_FAILED(0x%08x)", __FUNCTION__, BT_ERROR_OPERATION_FAILED); return BT_ERROR_OPERATION_FAILED; } - is_initialized = false; + is_initialized = false; return BT_ERROR_NONE; } - int bt_adapter_enable(void) { int error_code = BT_ERROR_NONE; - + BT_CHECK_INIT_STATUS(); error_code = _bt_get_error_code( bluetooth_enable_adapter() ); - if( error_code != BT_ERROR_NONE ) - { + if (error_code != BT_ERROR_NONE) { LOGE("[%s] %s(0x%08x)", __FUNCTION__, _bt_convert_error_to_string(error_code), error_code); } return error_code; @@ -135,11 +121,10 @@ int bt_adapter_disable(void) BT_CHECK_INIT_STATUS(); error_code = _bt_get_error_code( bluetooth_disable_adapter() ); - if( error_code != BT_ERROR_NONE ) - { + if (error_code != BT_ERROR_NONE) { LOGE("[%s] %s(0x%08x)", __FUNCTION__, _bt_convert_error_to_string(error_code), error_code); } - return error_code; + return error_code; } int bt_adapter_get_state(bt_adapter_state_e *adapter_state) @@ -160,18 +145,16 @@ int bt_adapter_get_address(char **address) BT_CHECK_INPUT_PARAMETER(address); error_code = _bt_get_error_code( bluetooth_get_local_address(&loc_address) ); - if( error_code != BT_ERROR_NONE ) - { + if (error_code != BT_ERROR_NONE) { LOGE("[%s] %s(0x%08x)", __FUNCTION__, _bt_convert_error_to_string(error_code), error_code); - return error_code; + return error_code; } error_code = _bt_convert_address_to_string(address, &loc_address); - if( error_code != BT_ERROR_NONE ) - { + if (error_code != BT_ERROR_NONE) { LOGE("[%s] %s(0x%08x)", __FUNCTION__, _bt_convert_error_to_string(error_code), error_code); - return error_code; - } + return error_code; + } return BT_ERROR_NONE; } @@ -185,19 +168,17 @@ int bt_adapter_get_name(char** name) BT_CHECK_INPUT_PARAMETER(name); ret = _bt_get_error_code( bluetooth_get_local_name(&loc_name) ); - if( ret != BT_ERROR_NONE ) - { + if (ret != BT_ERROR_NONE) { LOGE("[%s] %s(0x%08x)", __FUNCTION__, _bt_convert_error_to_string(ret), ret); return ret; } *name = strdup(loc_name.name); - if( *name == NULL ) - { - LOGE("[%s] OUT_OF_MEMORY(0x%08x)", __FUNCTION__, BT_ERROR_OUT_OF_MEMORY); + if (*name == NULL) { + LOGE("[%s] OUT_OF_MEMORY(0x%08x)", __FUNCTION__, BT_ERROR_OUT_OF_MEMORY); return BT_ERROR_OUT_OF_MEMORY; } - + return BT_ERROR_NONE; } @@ -213,8 +194,7 @@ int bt_adapter_set_name(const char* name) loc_name.name[BLUETOOTH_DEVICE_NAME_LENGTH_MAX] = '\0'; ret = _bt_get_error_code( bluetooth_set_local_name(&loc_name) ); - if( ret != BT_ERROR_NONE ) - { + if (ret != BT_ERROR_NONE) { LOGE("[%s] %s(0x%08x)", __FUNCTION__, _bt_convert_error_to_string(ret), ret); } @@ -230,14 +210,13 @@ int bt_adapter_get_visibility(bt_adapter_visibility_mode_e *mode) BT_CHECK_INPUT_PARAMETER(mode); ret = _bt_get_error_code( bluetooth_get_discoverable_mode(&discoverable_mode) ); - if( ret != BT_ERROR_NONE ) - { - LOGE("[%s] %s(0x%08x)", __FUNCTION__, _bt_convert_error_to_string(ret), ret); + if (ret != BT_ERROR_NONE) { + LOGE("[%s] %s(0x%08x)", __FUNCTION__, _bt_convert_error_to_string(ret), ret); return ret; } - + *mode = __bt_get_bt_adapter_visibility_mode_e(discoverable_mode); - return BT_ERROR_NONE; + return BT_ERROR_NONE; } int bt_adapter_set_visibility(bt_adapter_visibility_mode_e visibility_mode, int timeout_sec) @@ -246,10 +225,9 @@ int bt_adapter_set_visibility(bt_adapter_visibility_mode_e visibility_mode, int int error_code = BT_ERROR_NONE; BT_CHECK_INIT_STATUS(); - switch(visibility_mode) - { + switch (visibility_mode) { case BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE : - discoverable_mode = BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE; + discoverable_mode = BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE; break; case BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE : discoverable_mode = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE; @@ -263,14 +241,13 @@ int bt_adapter_set_visibility(bt_adapter_visibility_mode_e visibility_mode, int LOGE("[%s] INVALID_PARAMETER(0x%08x)", __FUNCTION__, BT_ERROR_INVALID_PARAMETER); return BT_ERROR_INVALID_PARAMETER; } - + error_code = _bt_get_error_code( bluetooth_set_discoverable_mode(discoverable_mode, timeout_sec) ); - if( error_code != BT_ERROR_NONE ) - { + if (error_code != BT_ERROR_NONE) { LOGE("[%s] %s(0x%08x)", __FUNCTION__, _bt_convert_error_to_string(error_code), error_code); } - - return error_code; + + return error_code; } int bt_device_create_bond(const char* device_address) @@ -283,26 +260,24 @@ int bt_device_create_bond(const char* device_address) _bt_convert_address_to_hex(&addr_hex, device_address); error_code = _bt_get_error_code( bluetooth_bond_device(&addr_hex) ); - if( error_code != BT_ERROR_NONE ) - { + if (error_code != BT_ERROR_NONE) { LOGE("[%s] %s(0x%08x)", __FUNCTION__, _bt_convert_error_to_string(error_code), error_code); } - - return error_code; + + return error_code; } int bt_device_cancel_bonding(void) { int error_code = BT_ERROR_NONE; - + BT_CHECK_INIT_STATUS(); error_code = _bt_get_error_code( bluetooth_cancel_bonding() ); - if( error_code != BT_ERROR_NONE ) - { + if (error_code != BT_ERROR_NONE) { LOGE("[%s] %s(0x%08x)", __FUNCTION__, _bt_convert_error_to_string(error_code), error_code); } - - return error_code; + + return error_code; } int bt_device_destroy_bond(const char *device_address) @@ -315,19 +290,18 @@ int bt_device_destroy_bond(const char *device_address) _bt_convert_address_to_hex(&addr_hex, device_address); error_code = _bt_get_error_code( bluetooth_unbond_device(&addr_hex) ); - if( error_code != BT_ERROR_NONE ) - { + if (error_code != BT_ERROR_NONE) { LOGE("[%s] %s(0x%08x)", __FUNCTION__, _bt_convert_error_to_string(error_code), error_code); } - return error_code; + return error_code; } int bt_adapter_foreach_bonded_device(bt_adapter_bonded_device_cb foreach_cb, void *user_data) { GPtrArray* dev_list = NULL; bt_device_info_s* dev_info = NULL; - bluetooth_device_info_t* ptr = NULL; + bluetooth_device_info_t* ptr = NULL; int ret = BT_ERROR_NONE; int i = 0; @@ -335,50 +309,41 @@ int bt_adapter_foreach_bonded_device(bt_adapter_bonded_device_cb foreach_cb, voi BT_CHECK_INPUT_PARAMETER(foreach_cb); dev_list = g_ptr_array_new(); - if( dev_list == NULL ) - { + if (dev_list == NULL) { LOGE("[%s] OUT_OF_MEMORY(0x%08x)", __FUNCTION__, BT_ERROR_OUT_OF_MEMORY); - return BT_ERROR_OUT_OF_MEMORY; + return BT_ERROR_OUT_OF_MEMORY; } ret = _bt_get_error_code( bluetooth_get_bonded_device_list(&dev_list) ); - if(ret != BT_ERROR_NONE) - { + if (ret != BT_ERROR_NONE) { LOGE("[%s] %s(0x%08x) : Failed to get bonded device list", __FUNCTION__, _bt_convert_error_to_string(ret), ret); return ret; } - for(i=0; ilen; i++) - { + for (i = 0; i < dev_list->len; i++) { ptr = g_ptr_array_index(dev_list, i); - if( ptr != NULL ) - { + if (ptr != NULL) { ret = _bt_get_bt_device_info_s(&dev_info, (bluetooth_device_info_t*)ptr); - if( ret != BT_ERROR_NONE ) - { + if (ret != BT_ERROR_NONE) { LOGE("[%s] %s(0x%08x) : Failed to get device info", __FUNCTION__, _bt_convert_error_to_string(ret), ret); break; } - if( !foreach_cb(dev_info, user_data) ) - { + if (!foreach_cb(dev_info, user_data)) { _bt_free_bt_device_info_s(dev_info); - break; - } + break; + } _bt_free_bt_device_info_s(dev_info); - } - else - { + } else { LOGE("[%s] OPERATION_FAILED(0x%08x)", __FUNCTION__, BT_ERROR_OPERATION_FAILED); ret = BT_ERROR_OPERATION_FAILED; break; } - } + } - if(dev_list != NULL ) - { + if (dev_list != NULL) { g_ptr_array_free(dev_list, TRUE); - } + } return ret; } @@ -392,13 +357,12 @@ int bt_device_set_alias(const char* device_address, const char* alias) BT_CHECK_INPUT_PARAMETER(device_address); BT_CHECK_INPUT_PARAMETER(alias); - _bt_convert_address_to_hex(&addr_hex, device_address); + _bt_convert_address_to_hex(&addr_hex, device_address); error_code = _bt_get_error_code( bluetooth_set_alias(&addr_hex, alias) ); - if( error_code != BT_ERROR_NONE ) - { + if (error_code != BT_ERROR_NONE) { LOGE("[%s] %s(0x%08x)", __FUNCTION__, _bt_convert_error_to_string(error_code), error_code); } - return error_code; + return error_code; } int bt_device_set_authorization(const char *device_address, bt_device_authorization_e authorization) @@ -410,16 +374,15 @@ int bt_device_set_authorization(const char *device_address, bt_device_authorizat BT_CHECK_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(device_address); - _bt_convert_address_to_hex(&addr_hex, device_address); + _bt_convert_address_to_hex(&addr_hex, device_address); if( authorization == BT_DEVICE_AUTHORIZED ) trusted = TRUE; error_code = _bt_get_error_code( bluetooth_authorize_device(&addr_hex, trusted) ); - if( error_code != BT_ERROR_NONE ) - { + if (error_code != BT_ERROR_NONE) { LOGE("[%s] %s(0x%08x)", __FUNCTION__, _bt_convert_error_to_string(error_code), error_code); } - return error_code; + return error_code; } int bt_device_start_service_search(const char * device_address) @@ -432,13 +395,12 @@ int bt_device_start_service_search(const char * device_address) _bt_convert_address_to_hex(&addr_hex, device_address); ret = _bt_get_error_code( bluetooth_search_service(&addr_hex) ); - + // In service search, BT_ERROR_SERVICE_SEARCH_FAILED is returned instead of BT_ERROR_OPERATION_FAILED. if( ret == BT_ERROR_OPERATION_FAILED ) ret = BT_ERROR_SERVICE_SEARCH_FAILED; - if( ret != BT_ERROR_NONE ) - { + if (ret != BT_ERROR_NONE) { LOGE("[%s] %s(0x%08x)", __FUNCTION__, _bt_convert_error_to_string(ret), ret); } return ret; @@ -446,35 +408,31 @@ int bt_device_start_service_search(const char * device_address) int bt_device_cancel_service_search(void) { - int ret = 0; - + int ret = 0; + BT_CHECK_INIT_STATUS(); ret = _bt_get_error_code( bluetooth_cancel_service_search() ); - if( ret != BT_ERROR_NONE ) - { + if (ret != BT_ERROR_NONE) { LOGE("[%s] %s(0x%08x)", __FUNCTION__, _bt_convert_error_to_string(ret), ret); } - return ret; + return ret; } int bt_socket_create_rfcomm(const char* uuid, int *socket_fd) { int ret = 0; - + BT_CHECK_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(uuid); BT_CHECK_INPUT_PARAMETER(socket_fd); ret = bluetooth_rfcomm_create_socket(uuid); - if( ret < 0 ) - { + if (ret < 0) { ret = _bt_get_error_code(ret); LOGE("[%s] %s(0x%08x)", __FUNCTION__, _bt_convert_error_to_string(ret), ret); return ret; - } - else - { + } else { *socket_fd = ret; return BT_ERROR_NONE; } @@ -483,14 +441,13 @@ int bt_socket_create_rfcomm(const char* uuid, int *socket_fd) int bt_socket_destroy_rfcomm(int socket_fd) { int error_code = BT_ERROR_NONE; - + BT_CHECK_INIT_STATUS(); error_code = _bt_get_error_code( bluetooth_rfcomm_remove_socket(socket_fd, 0) ); - if( error_code != BT_ERROR_NONE ) - { + if (error_code != BT_ERROR_NONE) { LOGE("[%s] %s(0x%08x)", __FUNCTION__, _bt_convert_error_to_string(error_code), error_code); } - + return error_code; } @@ -500,12 +457,11 @@ int bt_socket_listen_and_accept_rfcomm(int socket_fd, int max_pending_connection BT_CHECK_INIT_STATUS(); ret = _bt_get_error_code( bluetooth_rfcomm_listen_and_accept(socket_fd,max_pending_connection) ); - if( ret != BT_ERROR_NONE ) - { + if (ret != BT_ERROR_NONE) { LOGE("[%s] %s(0x%08x)", __FUNCTION__, _bt_convert_error_to_string(ret), ret); } - return ret; + return ret; } int bt_socket_connect_rfcomm(const char* remote_address, const char* remote_port_uuid) @@ -517,15 +473,14 @@ int bt_socket_connect_rfcomm(const char* remote_address, const char* remote_port BT_CHECK_INPUT_PARAMETER(remote_address); BT_CHECK_INPUT_PARAMETER(remote_port_uuid); - _bt_convert_address_to_hex(&addr_hex, remote_address); + _bt_convert_address_to_hex(&addr_hex, remote_address); error_code = _bt_get_error_code( bluetooth_rfcomm_connect(&addr_hex, remote_port_uuid) ); - if( error_code != BT_ERROR_NONE ) - { + if (error_code != BT_ERROR_NONE) { LOGE("[%s] %s(0x%08x)", __FUNCTION__, _bt_convert_error_to_string(error_code), error_code); } - return error_code; + return error_code; } int bt_socket_disconnect_rfcomm(int socket_fd) @@ -535,12 +490,11 @@ int bt_socket_disconnect_rfcomm(int socket_fd) BT_CHECK_INIT_STATUS(); ret = _bt_get_error_code( bluetooth_rfcomm_disconnect(socket_fd) ); - if( ret != BT_ERROR_NONE ) - { + if (ret != BT_ERROR_NONE) { LOGE("[%s] %s(0x%08x)", __FUNCTION__, _bt_convert_error_to_string(ret), ret); } - return ret; + return ret; } int bt_socket_send_data(int socket_fd, const char* data, int length) @@ -549,170 +503,158 @@ int bt_socket_send_data(int socket_fd, const char* data, int length) BT_CHECK_INIT_STATUS(); ret = bluetooth_rfcomm_write(socket_fd, data, length); - if( ret == BLUETOOTH_ERROR_NOT_IN_OPERATION ) - { + if (ret == BLUETOOTH_ERROR_NOT_IN_OPERATION) { LOGE("[%s] OPERATION_FAILED(0x%08x)", __FUNCTION__, BT_ERROR_OPERATION_FAILED); return BT_ERROR_OPERATION_FAILED; } ret = _bt_get_error_code(ret); - if( ret != BT_ERROR_NONE ) - { + if (ret != BT_ERROR_NONE) { LOGE("[%s] %s(0x%08x)", __FUNCTION__, _bt_convert_error_to_string(ret), ret); } - return ret; + return ret; } int bt_adapter_set_state_changed_cb(bt_adapter_state_changed_cb callback, void* user_data) { int ret = BT_ERROR_NONE; - + BT_CHECK_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(callback); __bt_set_cb(BT_EVENT_STATE_CHANGED, callback, user_data); - if( ret != BT_ERROR_NONE ) - { + if (ret != BT_ERROR_NONE) { LOGE("[%s] %s(0x%08x)", __FUNCTION__, _bt_convert_error_to_string(ret), ret); } - + return ret; } int bt_adapter_set_name_changed_cb(bt_adapter_name_changed_cb callback, void* user_data) { int ret = BT_ERROR_NONE; - + BT_CHECK_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(callback); __bt_set_cb(BT_EVENT_NAME_CHANGED, callback, user_data); - if( ret != BT_ERROR_NONE ) - { + if (ret != BT_ERROR_NONE) { LOGE("[%s] %s(0x%08x)", __FUNCTION__, _bt_convert_error_to_string(ret), ret); } - + return ret; } int bt_adapter_set_visibility_mode_changed_cb(bt_adapter_visibility_mode_changed_cb callback, void* user_data) { int ret = BT_ERROR_NONE; - + BT_CHECK_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(callback); __bt_set_cb(BT_EVENT_VISIBILITY_MODE_CHANGED, callback, user_data); - if( ret != BT_ERROR_NONE ) - { + if (ret != BT_ERROR_NONE) { LOGE("[%s] %s(0x%08x)", __FUNCTION__, _bt_convert_error_to_string(ret), ret); } - + return ret; } int bt_adapter_set_device_discovery_state_changed_cb(bt_adapter_device_discovery_state_changed_cb callback, void* user_data) { int ret = BT_ERROR_NONE; - + BT_CHECK_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(callback); __bt_set_cb(BT_EVENT_DEVICE_DISCOVERY_STATE_CHANGED, callback, user_data); - if( ret != BT_ERROR_NONE ) - { + if (ret != BT_ERROR_NONE) { LOGE("[%s] %s(0x%08x)", __FUNCTION__, _bt_convert_error_to_string(ret), ret); } - + return ret; } int bt_device_set_bond_created_cb(bt_device_bond_created_cb callback, void* user_data) { int ret = BT_ERROR_NONE; - + BT_CHECK_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(callback); __bt_set_cb(BT_EVENT_BOND_CREATED, callback, user_data); - if( ret != BT_ERROR_NONE ) - { + if (ret != BT_ERROR_NONE) { LOGE("[%s] %s(0x%08x)", __FUNCTION__, _bt_convert_error_to_string(ret), ret); } - + return ret; } int bt_device_set_bond_destroyed_cb(bt_device_bond_destroyed_cb callback, void* user_data) { int ret = BT_ERROR_NONE; - + BT_CHECK_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(callback); __bt_set_cb(BT_EVENT_BOND_DESTROYED, callback, user_data); - if( ret != BT_ERROR_NONE ) - { + if (ret != BT_ERROR_NONE) { LOGE("[%s] %s(0x%08x)", __FUNCTION__, _bt_convert_error_to_string(ret), ret); } - + return ret; } int bt_device_set_authorization_changed_cb(bt_device_authorization_changed_cb callback, void* user_data) { int ret = BT_ERROR_NONE; - + BT_CHECK_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(callback); __bt_set_cb(BT_EVENT_AUTHORIZATION_CHANGED, callback, user_data); - if( ret != BT_ERROR_NONE ) - { + if (ret != BT_ERROR_NONE) { LOGE("[%s] %s(0x%08x)", __FUNCTION__, _bt_convert_error_to_string(ret), ret); } - + return ret; } int bt_device_set_service_searched_cb(bt_device_service_searched_cb callback, void* user_data) { int ret = BT_ERROR_NONE; - + BT_CHECK_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(callback); __bt_set_cb(BT_EVENT_SERVICE_SEARCHED, callback, user_data); - if( ret != BT_ERROR_NONE ) - { + if (ret != BT_ERROR_NONE) { LOGE("[%s] %s(0x%08x)", __FUNCTION__, _bt_convert_error_to_string(ret), ret); } - + return ret; } int bt_socket_set_data_received_cb(bt_socket_data_received_cb callback, void* user_data) { int ret = BT_ERROR_NONE; - + BT_CHECK_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(callback); __bt_set_cb(BT_EVENT_DATA_RECEIVED, callback, user_data); - if( ret != BT_ERROR_NONE ) - { + if (ret != BT_ERROR_NONE) { LOGE("[%s] %s(0x%08x)", __FUNCTION__, _bt_convert_error_to_string(ret), ret); } - + return ret; -} +} int bt_socket_set_connection_state_changed_cb(bt_socket_connection_state_changed_cb callback, void* user_data) { int ret = BT_ERROR_NONE; - + BT_CHECK_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(callback); __bt_set_cb(BT_EVENT_CONNECTION_STATE_CHANGED, callback, user_data); - if( ret != BT_ERROR_NONE ) - { + if (ret != BT_ERROR_NONE) { LOGE("[%s] %s(0x%08x)", __FUNCTION__, _bt_convert_error_to_string(ret), ret); } - + return ret; -} +} int bt_adapter_unset_state_changed_cb(void) { @@ -775,26 +717,25 @@ int bt_socket_unset_data_received_cb(void) BT_CHECK_INIT_STATUS(); __bt_unset_cb(BT_EVENT_DATA_RECEIVED); return BT_ERROR_NONE; -} +} int bt_socket_unset_connection_state_changed_cb(void) { BT_CHECK_INIT_STATUS(); __bt_unset_cb(BT_EVENT_CONNECTION_STATE_CHANGED); return BT_ERROR_NONE; -} +} int bt_adapter_start_device_discovery(void) { int error_code = BT_ERROR_NONE; - + BT_CHECK_INIT_STATUS(); error_code = _bt_get_error_code( bluetooth_start_discovery(0, 0, BLUETOOTH_DEVICE_MAJOR_MASK_MISC) ); - if( error_code != BT_ERROR_NONE ) - { + if (error_code != BT_ERROR_NONE) { LOGE("[%s] %s(0x%08x)", __FUNCTION__, _bt_convert_error_to_string(error_code), error_code); } - return error_code; + return error_code; } int bt_adapter_stop_device_discovery(void) @@ -803,36 +744,30 @@ int bt_adapter_stop_device_discovery(void) BT_CHECK_INIT_STATUS(); error_code = _bt_get_error_code( bluetooth_cancel_discovery() ); - if( error_code != BT_ERROR_NONE ) - { + if (error_code != BT_ERROR_NONE) { LOGE("[%s] %s(0x%08x)", __FUNCTION__, _bt_convert_error_to_string(error_code), error_code); } - return error_code; + return error_code; } int bt_adapter_is_discovering(bool* is_discovering) { int ret = 0; - + BT_CHECK_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(is_discovering); ret = bluetooth_is_discovering(); - if(ret >= BLUETOOTH_ERROR_BASE) - { + if (ret >= BLUETOOTH_ERROR_BASE) { *is_discovering = (ret == 1)?true:false; return BT_ERROR_NONE; - } - else - { + } else { ret = _bt_get_error_code(ret); LOGE("[%s] %s(0x%08x)", __FUNCTION__, _bt_convert_error_to_string(ret), ret); return ret; } } - - /* * Internal Functions */ @@ -844,20 +779,18 @@ static void __bt_set_cb(int events, void* callback, void* user_data) static void __bt_unset_cb(int events) { - if( bt_event_slot_container[events].callback != NULL ) - { + if (bt_event_slot_container[events].callback != NULL) { bt_event_slot_container[events].callback = NULL; bt_event_slot_container[events].user_data = NULL; } } - + int _bt_get_error_code(int origin_error) { - switch(origin_error) - { + switch (origin_error) { case BLUETOOTH_ERROR_NONE: return BT_ERROR_NONE; - case BLUETOOTH_ERROR_INVALID_DATA: + case BLUETOOTH_ERROR_INVALID_DATA: case BLUETOOTH_ERROR_INVALID_PARAM: case BLUETOOTH_ERROR_NOT_CONNECTED: case BLUETOOTH_ERROR_NOT_SUPPORT: @@ -867,36 +800,36 @@ int _bt_get_error_code(int origin_error) return BT_ERROR_OUT_OF_MEMORY; case BLUETOOTH_ERROR_TIMEOUT: return BT_ERROR_TIMED_OUT; - case BLUETOOTH_ERROR_DEVICE_NOT_ENABLED: + case BLUETOOTH_ERROR_DEVICE_NOT_ENABLED: return BT_ERROR_NOT_ENABLED; - case BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED: + case BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED: return BT_ERROR_ALREADY_DONE; - case BLUETOOTH_ERROR_NOT_PAIRED: + case BLUETOOTH_ERROR_NOT_PAIRED: return BT_ERROR_REMOTE_DEVICE_NOT_BONDED; - case BLUETOOTH_ERROR_NOT_IN_OPERATION: + case BLUETOOTH_ERROR_NOT_IN_OPERATION: return BT_ERROR_NOT_IN_PROGRESS; case BLUETOOTH_ERROR_IN_PROGRESS: return BT_ERROR_NOW_IN_PROGRESS; - case BLUETOOTH_ERROR_DEVICE_BUSY: + case BLUETOOTH_ERROR_DEVICE_BUSY: return BT_ERROR_RESOURCE_BUSY; - case BLUETOOTH_ERROR_CANCEL: - case BLUETOOTH_ERROR_CANCEL_BY_USER: + case BLUETOOTH_ERROR_CANCEL: + case BLUETOOTH_ERROR_CANCEL_BY_USER: return BT_ERROR_CANCELLED; - case BLUETOOTH_ERROR_AUTHENTICATION_FAILED: + case BLUETOOTH_ERROR_AUTHENTICATION_FAILED: return BT_ERROR_AUTH_FAILED; case BLUETOOTH_ERROR_HOST_DOWN: return BT_ERROR_REMOTE_DEVICE_NOT_FOUND; - case BLUETOOTH_ERROR_SERVICE_SEARCH_ERROR: + case BLUETOOTH_ERROR_SERVICE_SEARCH_ERROR: return BT_ERROR_SERVICE_SEARCH_FAILED; case BLUETOOTH_ERROR_SERVICE_NOT_FOUND: - case BLUETOOTH_ERROR_PARING_FAILED: - case BLUETOOTH_ERROR_MAX_CONNECTION: - case BLUETOOTH_ERROR_ALREADY_CONNECT: - case BLUETOOTH_ERROR_NO_RESOURCES: - case BLUETOOTH_ERROR_REGISTRATION_FAILED: - case BLUETOOTH_ERROR_CONNECTION_BUSY: - case BLUETOOTH_ERROR_MAX_CLIENT: - case BLUETOOTH_ERROR_INVALID_CALLBACK: + case BLUETOOTH_ERROR_PARING_FAILED: + case BLUETOOTH_ERROR_MAX_CONNECTION: + case BLUETOOTH_ERROR_ALREADY_CONNECT: + case BLUETOOTH_ERROR_NO_RESOURCES: + case BLUETOOTH_ERROR_REGISTRATION_FAILED: + case BLUETOOTH_ERROR_CONNECTION_BUSY: + case BLUETOOTH_ERROR_MAX_CLIENT: + case BLUETOOTH_ERROR_INVALID_CALLBACK: case BLUETOOTH_ERROR_NOT_FOUND: case BLUETOOTH_ERROR_INTERNAL: case BLUETOOTH_ERROR_CONNECTION_ERROR: @@ -910,52 +843,42 @@ int _bt_get_error_code(int origin_error) int _bt_get_bt_device_info_s(bt_device_info_s** dest_dev, bluetooth_device_info_t* source_dev) { int i = 0; - + BT_CHECK_INPUT_PARAMETER(source_dev); *dest_dev = (bt_device_info_s *)malloc(sizeof(bt_device_info_s)); - if(*dest_dev == NULL) - { + if (*dest_dev == NULL) { return BT_ERROR_OUT_OF_MEMORY; } - - if( strlen(source_dev->device_name.name) > 0 ) - { + + if (strlen(source_dev->device_name.name) > 0) { (*dest_dev)->remote_name = strdup(source_dev->device_name.name); - } - else - { + } else { (*dest_dev)->remote_name = NULL; } _bt_convert_address_to_string(&((*dest_dev)->remote_address), &(source_dev->device_address)); (*dest_dev)->bt_class.major_device_class = source_dev->device_class.major_class; - (*dest_dev)->bt_class.minor_device_class = source_dev->device_class.minor_class; - (*dest_dev)->bt_class.major_service_class_mask = source_dev->device_class.service_class; - if(source_dev->service_index > 0) - { + (*dest_dev)->bt_class.minor_device_class = source_dev->device_class.minor_class; + (*dest_dev)->bt_class.major_service_class_mask = source_dev->device_class.service_class; + if (source_dev->service_index > 0) { (*dest_dev)->service_uuid = (char**)malloc(sizeof(char*) * source_dev->service_index); - if( (*dest_dev)->service_uuid != NULL ) - { - for(i=0; iservice_index; i++) - { + if ((*dest_dev)->service_uuid != NULL) { + for (i = 0; i < source_dev->service_index; i++) { (*dest_dev)->service_uuid[i] = strdup(source_dev->uuids[i]); - if( (*dest_dev)->service_uuid[i] != NULL ) - { + if ((*dest_dev)->service_uuid[i] != NULL) { __bt_convert_lower_to_upper((*dest_dev)->service_uuid[i]); - } - } + } + } } - } - else - { + } else { (*dest_dev)->service_uuid = NULL; } (*dest_dev)->service_count = source_dev->service_index; - (*dest_dev)->is_bonded = (bool)source_dev->paired; - (*dest_dev)->is_connected = (bool)source_dev->connected; - (*dest_dev)->is_authorized = (bool)source_dev->trust; + (*dest_dev)->is_bonded = (bool)source_dev->paired; + (*dest_dev)->is_connected = (bool)source_dev->connected; + (*dest_dev)->is_authorized = (bool)source_dev->trust; return BT_ERROR_NONE; } @@ -963,7 +886,7 @@ int _bt_get_bt_device_info_s(bt_device_info_s** dest_dev, bluetooth_device_info_ void _bt_free_bt_device_info_s(bt_device_info_s* device_info) { int i = 0; - + if(device_info == NULL) return; @@ -973,10 +896,8 @@ void _bt_free_bt_device_info_s(bt_device_info_s* device_info) if(device_info->remote_address != NULL) free(device_info->remote_address); - if( device_info->service_uuid != NULL ) - { - for(i=0; iservice_count; i++) - { + if (device_info->service_uuid != NULL) { + for (i = 0; i < device_info->service_count; i++) { if( device_info->service_uuid[i] != NULL ) free(device_info->service_uuid[i]); } @@ -991,16 +912,12 @@ int _bt_convert_address_to_string(char** addr_str, bluetooth_device_address_t* a { char address[18] = {0,}; - snprintf(address, 18, "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", \ - addr_hex->addr[0],addr_hex->addr[1],addr_hex->addr[2],addr_hex->addr[3],addr_hex->addr[4],addr_hex->addr[5]); + snprintf(address, 18, "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", addr_hex->addr[0], addr_hex->addr[1], addr_hex->addr[2], addr_hex->addr[3], addr_hex->addr[4], addr_hex->addr[5]); *addr_str = strdup(address); - if(*addr_str != NULL) - { + if (*addr_str != NULL) { return BT_ERROR_NONE; - } - else - { + } else { return BT_ERROR_OUT_OF_MEMORY; } } @@ -1011,13 +928,11 @@ void _bt_convert_address_to_hex(bluetooth_device_address_t* addr_hex, const char unsigned int addr[BLUETOOTH_ADDRESS_LENGTH] = {0,}; i = sscanf(addr_str, "%X:%X:%X:%X:%X:%X", &addr[0], &addr[1], &addr[2], &addr[3], &addr[4], &addr[5]); - if(i != BLUETOOTH_ADDRESS_LENGTH) - { + if (i != BLUETOOTH_ADDRESS_LENGTH) { LOGI("[%s] Invalid format string - %s", __FUNCTION__, addr_str); } - for(i=0; iaddr[i] = (unsigned char)addr[i]; } } @@ -1025,42 +940,34 @@ void _bt_convert_address_to_hex(bluetooth_device_address_t* addr_hex, const char static int __bt_get_bt_device_sdp_info_s(bt_device_sdp_info_s** dest, bt_sdp_info_t* source) { int i = 0; - + *dest = (bt_device_sdp_info_s *)malloc(sizeof(bt_device_sdp_info_s)); - if( *dest == NULL ) - { + if (*dest == NULL) { return BT_ERROR_OUT_OF_MEMORY; } - if( _bt_convert_address_to_string( &((*dest)->remote_address), &(source->device_addr) ) != BT_ERROR_NONE ) - { + if (_bt_convert_address_to_string(&((*dest)->remote_address), &(source->device_addr)) != BT_ERROR_NONE) { __bt_free_bt_device_sdp_info_s(*dest); return BT_ERROR_OUT_OF_MEMORY; } - - if(source->service_index > 0) - { + + if (source->service_index > 0) { (*dest)->service_uuid = (char**)malloc(sizeof(char*) * source->service_index); - if( (*dest)->service_uuid == NULL ) - { + if ((*dest)->service_uuid == NULL) { __bt_free_bt_device_sdp_info_s(*dest); return BT_ERROR_OUT_OF_MEMORY; } - - for(i=0; iservice_index; i++) - { + + for (i = 0; i < source->service_index; i++) { (*dest)->service_uuid[i] = strdup(source->uuids[i]); - if( (*dest)->service_uuid[i] == NULL ) - { + if ((*dest)->service_uuid[i] == NULL) { __bt_free_bt_device_sdp_info_s(*dest); return BT_ERROR_OUT_OF_MEMORY; } - __bt_convert_lower_to_upper((*dest)->service_uuid[i]); - } - } - else - { - (*dest)->service_uuid = NULL; + __bt_convert_lower_to_upper((*dest)->service_uuid[i]); + } + } else { + (*dest)->service_uuid = NULL; } (*dest)->service_count = source->service_index; @@ -1070,17 +977,15 @@ static int __bt_get_bt_device_sdp_info_s(bt_device_sdp_info_s** dest, bt_sdp_inf static void __bt_free_bt_device_sdp_info_s(bt_device_sdp_info_s* sdp_info) { int i = 0; - + if(sdp_info == NULL) return; if(sdp_info->remote_address != NULL) free(sdp_info->remote_address); - if( sdp_info->service_uuid != NULL ) - { - for(i=0; iservice_count; i++) - { + if (sdp_info->service_uuid != NULL) { + for (i = 0; i < sdp_info->service_count; i++) { if( sdp_info->service_uuid[i] != NULL ) free( sdp_info->service_uuid[i] ); } @@ -1093,8 +998,7 @@ static void __bt_free_bt_device_sdp_info_s(bt_device_sdp_info_s* sdp_info) static bt_adapter_visibility_mode_e __bt_get_bt_adapter_visibility_mode_e(bluetooth_discoverable_mode_t mode) { - switch(mode) - { + switch (mode) { case BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE: return BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE; case BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE: @@ -1104,7 +1008,6 @@ static bt_adapter_visibility_mode_e __bt_get_bt_adapter_visibility_mode_e(blueto } } - static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void* user_data) { bluetooth_rfcomm_connection_t* connection_ind = NULL; @@ -1112,65 +1015,26 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void* us bt_socket_connection_s rfcomm_connection; bt_device_sdp_info_s* sdp_info = NULL; bt_adapter_device_discovery_info_s* discovery_info = NULL; + bt_device_info_s *bonded_device = NULL; char* device_addr = NULL; int error_code = BT_ERROR_NONE; int event_index = -1; event_index = __bt_get_cb_index(event); - if( event_index == -1 || bt_event_slot_container[event_index].callback == NULL ) - { - if( event_index == BT_EVENT_BOND_CREATED ) - _bt_free_bt_device_info_s(bonded_device); + if (event_index == -1 || bt_event_slot_container[event_index].callback == NULL) { return; } - - /* - * BLUETOOTH_EVENT_SERVICE_SEARCHED is converted BLUETOOTH_EVENT_BONDING_FINISHED - * immediately after BLUETOOTH_EVENT_BONDING_FINISHED - */ - if( event == BLUETOOTH_EVENT_BONDING_FINISHED ) - { - if( param->result == BLUETOOTH_ERROR_NONE ) - { - is_creating_bond = true; - } - error_code = param->result; - _bt_get_bt_device_info_s(&bonded_device, (bluetooth_device_info_t *)(param->param_data)); - } - else if( is_creating_bond == true && event == BLUETOOTH_EVENT_SERVICE_SEARCHED ) - { - is_creating_bond = false; - event = BLUETOOTH_EVENT_BONDING_FINISHED; - - if( param->result == BLUETOOTH_ERROR_NONE && - __bt_get_bt_device_sdp_info_s(&sdp_info, (bt_sdp_info_t*)(param->param_data)) == BT_ERROR_NONE ) - { - error_code = BLUETOOTH_ERROR_NONE; - if( __bt_copy_service_list(bonded_device, sdp_info) != BT_ERROR_NONE ) - { - error_code = BT_ERROR_SERVICE_SEARCH_FAILED; - } - __bt_free_bt_device_sdp_info_s(sdp_info); - } - else - { - error_code = BT_ERROR_SERVICE_SEARCH_FAILED; - } - } - switch(event) - { + switch (event) { case BLUETOOTH_EVENT_ENABLED: LOGI("[%s] bt_adapter_state_changed_cb() will be called with BT_ADAPTER_ENABLED", __FUNCTION__); ((bt_adapter_state_changed_cb)bt_event_slot_container[event_index].callback) - (_bt_get_error_code(param->result), BT_ADAPTER_ENABLED, - bt_event_slot_container[event_index].user_data); - break; + (_bt_get_error_code(param->result), BT_ADAPTER_ENABLED, bt_event_slot_container[event_index].user_data); + break; case BLUETOOTH_EVENT_DISABLED: LOGI("[%s] bt_adapter_state_changed_cb() will be called with BT_ADAPTER_DISABLED", __FUNCTION__); ((bt_adapter_state_changed_cb)bt_event_slot_container[event_index].callback) - (_bt_get_error_code(param->result), BT_ADAPTER_DISABLED, - bt_event_slot_container[event_index].user_data); + (_bt_get_error_code(param->result), BT_ADAPTER_DISABLED, bt_event_slot_container[event_index].user_data); break; case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED: LOGI("[%s] bt_adapter_name_changed_cb() will be called", __FUNCTION__); @@ -1178,70 +1042,50 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void* us ((char*)(param->param_data), bt_event_slot_container[event_index].user_data); break; case BLUETOOTH_EVENT_DISCOVERABLE_MODE_CHANGED: - LOGI("[%s] bt_adapter_visibility_mode_changed_cb() will be called", __FUNCTION__); + LOGI("[%s] bt_adapter_visibility_mode_changed_cb() will be called", __FUNCTION__); ((bt_adapter_visibility_mode_changed_cb)bt_event_slot_container[event_index].callback) - (_bt_get_error_code(param->result), - __bt_get_bt_adapter_visibility_mode_e(*(bt_adapter_visibility_mode_e*)(param->param_data)), - bt_event_slot_container[event_index].user_data); + (_bt_get_error_code(param->result), __bt_get_bt_adapter_visibility_mode_e(*(bt_adapter_visibility_mode_e *)(param->param_data)), bt_event_slot_container[event_index].user_data); break; case BLUETOOTH_EVENT_DISCOVERY_STARTED: LOGI("[%s] bt_adapter_device_discovery_state_changed_cb() will be called with BT_ADAPTER_DEVICE_DISCOVERY_STARTED", __FUNCTION__); ((bt_adapter_device_discovery_state_changed_cb)bt_event_slot_container[event_index].callback) - (_bt_get_error_code(param->result), - BT_ADAPTER_DEVICE_DISCOVERY_STARTED, NULL, bt_event_slot_container[event_index].user_data); + (_bt_get_error_code(param->result), BT_ADAPTER_DEVICE_DISCOVERY_STARTED, NULL, bt_event_slot_container[event_index].user_data); break; - case BLUETOOTH_EVENT_DISCOVERY_FINISHED: + case BLUETOOTH_EVENT_DISCOVERY_FINISHED: LOGI("[%s] bt_adapter_device_discovery_state_changed_cb() will be called with BT_ADAPTER_DEVICE_DISCOVERY_FINISHED", __FUNCTION__); ((bt_adapter_device_discovery_state_changed_cb)bt_event_slot_container[event_index].callback) - (_bt_get_error_code(param->result), BT_ADAPTER_DEVICE_DISCOVERY_FINISHED, - NULL, bt_event_slot_container[event_index].user_data); + (_bt_get_error_code(param->result), BT_ADAPTER_DEVICE_DISCOVERY_FINISHED, NULL, bt_event_slot_container[event_index].user_data); break; - case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED: + case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED: LOGI("[%s] bt_adapter_device_discovery_state_changed_cb() will be called with BT_ADAPTER_DEVICE_DISCOVERY_FOUND", __FUNCTION__); - if( __bt_get_bt_adapter_device_discovery_info_s(&discovery_info, (bluetooth_device_info_t *)(param->param_data)) == BT_ERROR_NONE ) - { + if( __bt_get_bt_adapter_device_discovery_info_s(&discovery_info, (bluetooth_device_info_t *)(param->param_data)) == BT_ERROR_NONE ) { ((bt_adapter_device_discovery_state_changed_cb)bt_event_slot_container[event_index].callback) - (_bt_get_error_code(param->result), BT_ADAPTER_DEVICE_DISCOVERY_FOUND, - discovery_info, bt_event_slot_container[event_index].user_data); - __bt_free_bt_adapter_device_discovery_info_s(discovery_info); - } - else - { + (_bt_get_error_code(param->result), BT_ADAPTER_DEVICE_DISCOVERY_FOUND, discovery_info, bt_event_slot_container[event_index].user_data); + __bt_free_bt_adapter_device_discovery_info_s(discovery_info); + } else { ((bt_adapter_device_discovery_state_changed_cb)bt_event_slot_container[event_index].callback) - (_bt_get_error_code(param->result), BT_ADAPTER_DEVICE_DISCOVERY_FOUND, - NULL, bt_event_slot_container[event_index].user_data); - } - break; - case BLUETOOTH_EVENT_BONDING_FINISHED: - if( is_creating_bond == false ) - { - LOGI("[%s] bt_device_bond_created_cb() will be called", __FUNCTION__); - if( error_code != BT_ERROR_SERVICE_SEARCH_FAILED ) - { - // In other case, BLUETOOTH_ERROR_ACCESS_DENIED will be changed to BT_ERROR_OPERATION_FAILED - if(error_code == BLUETOOTH_ERROR_ACCESS_DENIED) - error_code = BT_ERROR_AUTH_REJECTED; - else - error_code = _bt_get_error_code(error_code); - } - ((bt_device_bond_created_cb)bt_event_slot_container[event_index].callback) - (error_code, bonded_device, bt_event_slot_container[event_index].user_data); - _bt_free_bt_device_info_s(bonded_device); + (_bt_get_error_code(param->result), BT_ADAPTER_DEVICE_DISCOVERY_FOUND, NULL, bt_event_slot_container[event_index].user_data); } - else - LOGI("[%s] After finishing service search, bt_device_bond_created_cb() will be called", __FUNCTION__); - break; + break; + case BLUETOOTH_EVENT_BONDING_FINISHED: + LOGI("[%s] bt_device_bond_created_cb() will be called", __FUNCTION__); + _bt_get_bt_device_info_s(&bonded_device, (bluetooth_device_info_t *)(param->param_data)); + + ((bt_device_bond_created_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), bonded_device, bt_event_slot_container[event_index].user_data); + _bt_free_bt_device_info_s(bonded_device); + bonded_device = NULL; + break; case BLUETOOTH_EVENT_BONDED_DEVICE_REMOVED: - LOGI("[%s] bt_device_bond_destroyed_cb() will be called", __FUNCTION__); + LOGI("[%s] bt_device_bond_destroyed_cb() will be called", __FUNCTION__); _bt_convert_address_to_string(&device_addr, (bluetooth_device_address_t *)(param->param_data)); ((bt_device_bond_destroyed_cb)bt_event_slot_container[event_index].callback) - (_bt_get_error_code(param->result), device_addr, - bt_event_slot_container[event_index].user_data); + (_bt_get_error_code(param->result), device_addr, bt_event_slot_container[event_index].user_data); if(device_addr != NULL) free(device_addr); device_addr = NULL; - break; - case BLUETOOTH_EVENT_DEVICE_AUTHORIZED: + break; + case BLUETOOTH_EVENT_DEVICE_AUTHORIZED: LOGI("[%s] bt_device_authorization_changed_cb() will be called with BT_DEVICE_AUTHORIZED", __FUNCTION__); _bt_convert_address_to_string(&device_addr, (bluetooth_device_address_t *)(param->param_data)); ((bt_device_authorization_changed_cb)bt_event_slot_container[event_index].callback) @@ -1250,7 +1094,7 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void* us free(device_addr); device_addr = NULL; break; - case BLUETOOTH_EVENT_DEVICE_UNAUTHORIZED: + case BLUETOOTH_EVENT_DEVICE_UNAUTHORIZED: LOGI("[%s] bt_device_authorization_changed_cb() will be called with BT_DEVICE_UNAUTHORIZED", __FUNCTION__); _bt_convert_address_to_string(&device_addr, (bluetooth_device_address_t *)(param->param_data)); ((bt_device_authorization_changed_cb)bt_event_slot_container[event_index].callback) @@ -1269,19 +1113,19 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void* us ((bt_device_service_searched_cb)bt_event_slot_container[event_index].callback) (error_code, sdp_info, bt_event_slot_container[event_index].user_data); __bt_free_bt_device_sdp_info_s(sdp_info); - break; + break; case BLUETOOTH_EVENT_RFCOMM_DATA_RECEIVED: LOGI("[%s] bt_socket_data_received_cb() will be called", __FUNCTION__); ((bt_socket_data_received_cb)bt_event_slot_container[event_index].callback) ((bt_socket_received_data_s*)(param->param_data), bt_event_slot_container[event_index].user_data); - break; - case BLUETOOTH_EVENT_RFCOMM_CONNECTED: + break; + case BLUETOOTH_EVENT_RFCOMM_CONNECTED: LOGI("[%s] bt_socket_connection_state_changed_cb() will be called with BT_SOCKET_CONNECTED", __FUNCTION__); // In other case, BLUETOOTH_ERROR_INVALID_PARAM will be changed to BT_ERROR_INVALID_PARAM if(param->result == BLUETOOTH_ERROR_INVALID_PARAM) error_code = BT_ERROR_OPERATION_FAILED; else - error_code = _bt_get_error_code(param->result); + error_code = _bt_get_error_code(param->result); connection_ind = (bluetooth_rfcomm_connection_t*)(param->param_data); rfcomm_connection.socket_fd = connection_ind->socket_fd; @@ -1291,61 +1135,51 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void* us ((bt_socket_connection_state_changed_cb)bt_event_slot_container[event_index].callback) (error_code, BT_SOCKET_CONNECTED, &rfcomm_connection, bt_event_slot_container[event_index].user_data); - if( rfcomm_connection.remote_address != NULL ) - { + if( rfcomm_connection.remote_address != NULL ) { free(rfcomm_connection.remote_address); rfcomm_connection.remote_address = NULL; } - break; - case BLUETOOTH_EVENT_RFCOMM_DISCONNECTED: + break; + case BLUETOOTH_EVENT_RFCOMM_DISCONNECTED: LOGI("[%s] bt_socket_connection_state_changed_cb() will be called with BT_SOCKET_DISCONNECTED", __FUNCTION__); disconnection_ind = (bluetooth_rfcomm_disconnection_t*)(param->param_data); rfcomm_connection.socket_fd = disconnection_ind->socket_fd; rfcomm_connection.local_role = BT_SOCKET_UNKNOWN; _bt_convert_address_to_string(&(rfcomm_connection.remote_address), &(disconnection_ind->device_addr)); ((bt_socket_connection_state_changed_cb)bt_event_slot_container[event_index].callback) - (_bt_get_error_code(param->result), BT_SOCKET_DISCONNECTED, - &rfcomm_connection, bt_event_slot_container[event_index].user_data); + (_bt_get_error_code(param->result), BT_SOCKET_DISCONNECTED, &rfcomm_connection, bt_event_slot_container[event_index].user_data); - if( rfcomm_connection.remote_address != NULL ) - { + if( rfcomm_connection.remote_address != NULL ) { free(rfcomm_connection.remote_address); rfcomm_connection.remote_address = NULL; } - break; + break; } } - -static int __bt_get_bt_adapter_device_discovery_info_s -(bt_adapter_device_discovery_info_s** discovery_info, bluetooth_device_info_t* source_info) -{ +static int __bt_get_bt_adapter_device_discovery_info_s(bt_adapter_device_discovery_info_s **discovery_info, bluetooth_device_info_t *source_info) { BT_CHECK_INPUT_PARAMETER(source_info); *discovery_info = (bt_adapter_device_discovery_info_s *)malloc(sizeof(bt_adapter_device_discovery_info_s)); - if(*discovery_info == NULL) - { + if (*discovery_info == NULL) { return BT_ERROR_OUT_OF_MEMORY; } - - if( strlen(source_info->device_name.name) > 0 ) - { + + if (strlen(source_info->device_name.name) > 0) { (*discovery_info)->remote_name = strdup(source_info->device_name.name); - } - else - { + } else { (*discovery_info)->remote_name = NULL; } _bt_convert_address_to_string(&((*discovery_info)->remote_address), &(source_info->device_address)); (*discovery_info)->bt_class.major_device_class = source_info->device_class.major_class; - (*discovery_info)->bt_class.minor_device_class = source_info->device_class.minor_class; - (*discovery_info)->bt_class.major_service_class_mask = source_info->device_class.service_class; + (*discovery_info)->bt_class.minor_device_class = source_info->device_class.minor_class; + (*discovery_info)->bt_class.major_service_class_mask = source_info->device_class.service_class; - (*discovery_info)->rssi = (bool)source_info->rssi; - (*discovery_info)->is_bonded = (bool)source_info->paired; + (*discovery_info)->rssi = (bool)source_info->rssi; + (*discovery_info)->is_bonded = (bool)source_info->paired; return BT_ERROR_NONE; } @@ -1354,7 +1188,7 @@ static void __bt_free_bt_adapter_device_discovery_info_s(bt_adapter_device_disco { if(discovery_info == NULL) return; - + if(discovery_info->remote_name != NULL) free(discovery_info->remote_name); @@ -1367,8 +1201,7 @@ static void __bt_free_bt_adapter_device_discovery_info_s(bt_adapter_device_disco static int __bt_get_cb_index(int event) { - switch(event) - { + switch (event) { case BLUETOOTH_EVENT_ENABLED: case BLUETOOTH_EVENT_DISABLED: return BT_EVENT_STATE_CHANGED; @@ -1377,64 +1210,31 @@ static int __bt_get_cb_index(int event) case BLUETOOTH_EVENT_DISCOVERABLE_MODE_CHANGED: return BT_EVENT_VISIBILITY_MODE_CHANGED; case BLUETOOTH_EVENT_DISCOVERY_STARTED: - case BLUETOOTH_EVENT_DISCOVERY_FINISHED: - case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED: + case BLUETOOTH_EVENT_DISCOVERY_FINISHED: + case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED: return BT_EVENT_DEVICE_DISCOVERY_STATE_CHANGED; - case BLUETOOTH_EVENT_BONDING_FINISHED: + case BLUETOOTH_EVENT_BONDING_FINISHED: return BT_EVENT_BOND_CREATED; - case BLUETOOTH_EVENT_BONDED_DEVICE_REMOVED: + case BLUETOOTH_EVENT_BONDED_DEVICE_REMOVED: return BT_EVENT_BOND_DESTROYED; - case BLUETOOTH_EVENT_DEVICE_AUTHORIZED: - case BLUETOOTH_EVENT_DEVICE_UNAUTHORIZED: + case BLUETOOTH_EVENT_DEVICE_AUTHORIZED: + case BLUETOOTH_EVENT_DEVICE_UNAUTHORIZED: return BT_EVENT_AUTHORIZATION_CHANGED; case BLUETOOTH_EVENT_SERVICE_SEARCHED: - if( is_creating_bond == true ) - return BT_EVENT_BOND_CREATED; - else - return BT_EVENT_SERVICE_SEARCHED; - case BLUETOOTH_EVENT_RFCOMM_DATA_RECEIVED: + return BT_EVENT_SERVICE_SEARCHED; + case BLUETOOTH_EVENT_RFCOMM_DATA_RECEIVED: return BT_EVENT_DATA_RECEIVED; - case BLUETOOTH_EVENT_RFCOMM_CONNECTED: - case BLUETOOTH_EVENT_RFCOMM_DISCONNECTED: + case BLUETOOTH_EVENT_RFCOMM_CONNECTED: + case BLUETOOTH_EVENT_RFCOMM_DISCONNECTED: return BT_EVENT_CONNECTION_STATE_CHANGED; default: return -1; } } -static int __bt_copy_service_list(bt_device_info_s* bonded_device_info, bt_device_sdp_info_s* sdp_info) -{ - int i = 0; - - BT_CHECK_INPUT_PARAMETER(bonded_device_info); - BT_CHECK_INPUT_PARAMETER(sdp_info); - - if(sdp_info->service_count > 0) - { - bonded_device_info->service_uuid = (char**)malloc(sizeof(char*) * sdp_info->service_count); - if( bonded_device_info->service_uuid == NULL ) - { - return BT_ERROR_OUT_OF_MEMORY; - } - - for(i=0; iservice_count; i++) - { - bonded_device_info->service_uuid[i] = strdup(sdp_info->service_uuid[i]); - } - } - else - { - bonded_device_info->service_uuid = NULL; - } - bonded_device_info->service_count = sdp_info->service_count; - - return BT_ERROR_NONE; -} - char* _bt_convert_error_to_string(int error) { - switch(error) - { + switch (error) { case BT_ERROR_CANCELLED: return "CANCELLED"; case BT_ERROR_INVALID_PARAMETER: @@ -1477,10 +1277,8 @@ static void __bt_convert_lower_to_upper(char* origin) int length = strlen(origin); int i = 0; - for(i=0; i