From: DoHyun Pyun Date: Mon, 7 Nov 2016 00:40:12 +0000 (+0900) Subject: Add internal APIs for the application's pairing procedure X-Git-Tag: accepted/tizen/ivi/20161108.001300~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2a514b0cccf7ae66e08bfe844131d6f08bd8c5bd;p=platform%2Fcore%2Fapi%2Fbluetooth.git Add internal APIs for the application's pairing procedure Change-Id: I2f394c569713a310a91c7651a1ff1371ecb62994 Signed-off-by: DoHyun Pyun --- diff --git a/include/bluetooth_private.h b/include/bluetooth_private.h index 92cdf2c..c6cdba1 100644 --- a/include/bluetooth_private.h +++ b/include/bluetooth_private.h @@ -599,17 +599,6 @@ do { \ } while (0) /** - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE - * @brief Enumerations of the authentication event types. - * - */ -typedef enum { - BT_AUTH_KEYBOARD_PASSKEY_DISPLAY = 0, /**< PIN display event to user for entering PIN in keyboard */ - BT_AUTH_PIN_REQUEST, /**< Legacy PIN or PASSKEY request event */ - BT_AUTH_PASSKEY_CONFIRM_REQUEST, /**< PASSKEY confirmation event to match PASSKEY in remote device */ -} bt_authentication_type_info_e; - -/** * @internal * @brief Check the initialzating status */ @@ -892,76 +881,6 @@ int bt_device_le_set_data_length_change_cb( _bt_le_set_data_length_changed_cb callback, void *user_data); /** - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE - * @brief Called when remote device requests authentication. - * @param[in] result - * @param[in] auth_type - * typedef enum { - * BT_AUTH_KEYBOARD_PASSKEY_DISPLAY = 0, : PIN display event to user for entering PIN in keyboard - * BT_AUTH_PIN_REQUEST, : Legacy PIN or PASSKEY request event - * BT_AUTH_PASSKEY_CONFIRM_REQUEST, : PASSKEY confirmation event to match PASSKEY in remote device - * } bt_authentication_type_info_e; - * @param[in] device_name Name of the remote device - * @param[in] remote_addr Remote BD address - * @param[in] pass_key PASSKEY string - * PASSKEY string is valid only if authentication types are following - * a/ BT_AUTH_KEYBOARD_PASSKEY_DISPLAY - * b/ BT_AUTH_PASSKEY_CONFIRM_REQUEST - * pass_key string will be invalid if authentication event is of type BT_AUTH_PIN_REQUEST - * as this event indicates that user MUST enter PIN or PASSKEY and perform authentication. - * - * Upon receiving BT_AUTH_KEYBOARD_PASSKEY_DISPLAY event, user should enter PASSKEY in keyboard - * Application can also call bt_device_cancel_bonding() Upon receiving BT_AUTH_KEYBOARD_PASSKEY_DISPLAY - * event which will fail the on-going pairing with remote device. - * @param[in] user_data The user data passed from the callback registration function - * @see bt_adapter_set_authentication_req_cb() - */ -typedef void (*bt_adapter_authentication_req_cb)(int result, bt_authentication_type_info_e auth_type, - char *device_name, char *remote_addr, - char *pass_key, void *user_data); - -int bt_adapter_set_authentication_req_cb(bt_adapter_authentication_req_cb callback, void *user_data); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE - * @brief Unregisters a callback function that will be invoked when remote device requests authentication. - * @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 by bt_initialize(). - * @see bt_initialize() - * @see bt_adapter_set_authentication_req_cb() - */ -int bt_adapter_unset_authentication_req_cb(void); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE - * @brief API to reply with PIN or PASSKEY with authentication type - TRUE or FALSE. - * @remarks This function can be called by application when remote device requests PIN or PASSKEY from - * local adapter. - * @param[in] passkey The passkey to be provided by application when remote devices requests for it. - * @param[in] authentication_reply This indicates whether application wants to accept or cancel the on-going pairing - * @pre This function can only be called when application receieves authentication event (BT_AUTH_PIN_REQUEST) - * from remote device. - * @see bt_adapter_set_authentication_req_cb() - */ -int bt_passkey_reply(char *passkey, bool authentication_reply); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE - * @brief API to reply to the PASSKEY confirmation for on-going pairing with remote device. - * @remarks This function can be called by application, when local adapter wants PASSKEY confirmation from user. - * @param[in] confirmation_reply This indicates whether application wants to accepts or cancels the on-going pairing - * confirmation_reply : TRUE will indicate that Application has confirmed the PASSKEY - * confirmation_reply : FALSE will indicate that Application has failed to confirm the PASSKEY. In this situation - * the pairing will be failed. - * @pre This function can only be called when application receives authentication event (BT_AUTH_PASSKEY_CONFIRM_REQUEST) - * from remote device. - * @see bt_adapter_set_authentication_req_cb() - */ -int bt_passkey_confirmation_reply(bool confirmation_reply); - -/** * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE * @brief Sends the custom event data. * @since_tizen 3.0 diff --git a/include/mobile/bluetooth_internal.h b/include/mobile/bluetooth_internal.h index e0289e3..7171b75 100644 --- a/include/mobile/bluetooth_internal.h +++ b/include/mobile/bluetooth_internal.h @@ -233,6 +233,62 @@ int bt_adapter_get_local_info(char **chipset, char **firmware, char **stack_vers int bt_adapter_set_visibility(bt_adapter_visibility_mode_e discoverable_mode, int duration); /** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Registers a callback function that will be invoked when remote device requests authentication. + * @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 by bt_initialize(). + * @param[in] callback callback function to be set when a request is received. + * @param[in] user_data data from application which will be provided in callback. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @see bt_initialize() + * @see bt_adapter_set_authentication_req_cb() + */ +int bt_adapter_set_authentication_req_cb(bt_adapter_authentication_req_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Unregisters a callback function that will be invoked when remote device requests authentication. + * @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 by bt_initialize(). + * @see bt_initialize() + * @see bt_adapter_set_authentication_req_cb() + */ +int bt_adapter_unset_authentication_req_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief API to reply with PIN or PASSKEY with authentication type - TRUE or FALSE. + * @remarks This function can be called by application when remote device requests PIN or PASSKEY from + * local adapter. + * @param[in] passkey The passkey to be provided by application when remote devices requests for it. + * @param[in] authentication_reply This indicates whether application wants to accept or cancel the on-going pairing + * @pre This function can only be called when application receieves authentication event (BT_AUTH_PIN_REQUEST) + * from remote device. + * @see bt_adapter_set_authentication_req_cb() + */ +int bt_adapter_passkey_reply(char *passkey, bool authentication_reply); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief API to reply to the PASSKEY confirmation for on-going pairing with remote device. + * @remarks This function can be called by application, when local adapter wants PASSKEY confirmation from user. + * @param[in] confirmation_reply This indicates whether application wants to accepts or cancels the on-going pairing + * confirmation_reply : TRUE will indicate that Application has confirmed the PASSKEY + * confirmation_reply : FALSE will indicate that Application has failed to confirm the PASSKEY. In this situation + * the pairing will be failed. + * @pre This function can only be called when application receives authentication event (BT_AUTH_PASSKEY_CONFIRM_REQUEST) + * from remote device. + * @see bt_adapter_set_authentication_req_cb() + */ +int bt_adapter_passkey_confirmation_reply(bool confirmation_reply); + +/** * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE * @brief Registers a callback function to be invoked when the connectable state changes. diff --git a/include/mobile/bluetooth_type_internal.h b/include/mobile/bluetooth_type_internal.h index 8260262..65f57a1 100644 --- a/include/mobile/bluetooth_type_internal.h +++ b/include/mobile/bluetooth_type_internal.h @@ -395,6 +395,18 @@ typedef enum { } bt_restricted_profile_t; /** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Enumerations of the authentication event types. + * @since_tizen 3.0 + * + */ +typedef enum { + BT_AUTH_KEYBOARD_PASSKEY_DISPLAY = 0, /**< PIN display event to user for entering PIN in keyboard */ + BT_AUTH_PIN_REQUEST, /**< Legacy PIN or PASSKEY request event */ + BT_AUTH_PASSKEY_CONFIRM_REQUEST, /**< PASSKEY confirmation event to match PASSKEY in remote device */ +} bt_authentication_type_info_e; + +/** * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE * @brief Called when Trusted Profiles is changed. * @since_tizen 3.0 @@ -456,6 +468,37 @@ typedef void (*bt_ipsp_connection_state_changed_cb) /** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Called when remote device requests authentication. + * @since_tizen 3.0 + * @param[in] result + * @param[in] auth_type + * typedef enum { + * BT_AUTH_KEYBOARD_PASSKEY_DISPLAY = 0, : PIN display event to user for entering PIN in keyboard + * BT_AUTH_PIN_REQUEST, : Legacy PIN or PASSKEY request event + * BT_AUTH_PASSKEY_CONFIRM_REQUEST, : PASSKEY confirmation event to match PASSKEY in remote device + * } bt_authentication_type_info_e; + * @param[in] device_name Name of the remote device + * @param[in] remote_addr Remote BD address + * @param[in] pass_key PASSKEY string + * PASSKEY string is valid only if authentication types are following + * a/ BT_AUTH_KEYBOARD_PASSKEY_DISPLAY + * b/ BT_AUTH_PASSKEY_CONFIRM_REQUEST + * pass_key string will be invalid if authentication event is of type BT_AUTH_PIN_REQUEST + * as this event indicates that user MUST enter PIN or PASSKEY and perform authentication. + * + * Upon receiving BT_AUTH_KEYBOARD_PASSKEY_DISPLAY event, user should enter PASSKEY in keyboard + * Application can also call bt_device_cancel_bonding() Upon receiving BT_AUTH_KEYBOARD_PASSKEY_DISPLAY + * event which will fail the on-going pairing with remote device. + * @param[in] user_data The user data passed from the callback registration function + * @see bt_adapter_set_authentication_req_cb() + */ +typedef void (*bt_adapter_authentication_req_cb)(int result, bt_authentication_type_info_e auth_type, + char *device_name, char *remote_addr, + char *pass_key, void *user_data); + +/** * @} */ diff --git a/include/tv/bluetooth_internal.h b/include/tv/bluetooth_internal.h index 2e68a03..495e089 100644 --- a/include/tv/bluetooth_internal.h +++ b/include/tv/bluetooth_internal.h @@ -233,6 +233,62 @@ int bt_adapter_get_local_info(char **chipset, char **firmware, char **stack_vers int bt_adapter_set_visibility(bt_adapter_visibility_mode_e discoverable_mode, int duration); /** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Registers a callback function that will be invoked when remote device requests authentication. + * @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 by bt_initialize(). + * @param[in] callback callback function to be set when a request is received. + * @param[in] user_data data from application which will be provided in callback. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @see bt_initialize() + * @see bt_adapter_set_authentication_req_cb() + */ +int bt_adapter_set_authentication_req_cb(bt_adapter_authentication_req_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Unregisters a callback function that will be invoked when remote device requests authentication. + * @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 by bt_initialize(). + * @see bt_initialize() + * @see bt_adapter_set_authentication_req_cb() + */ +int bt_adapter_unset_authentication_req_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief API to reply with PIN or PASSKEY with authentication type - TRUE or FALSE. + * @remarks This function can be called by application when remote device requests PIN or PASSKEY from + * local adapter. + * @param[in] passkey The passkey to be provided by application when remote devices requests for it. + * @param[in] authentication_reply This indicates whether application wants to accept or cancel the on-going pairing + * @pre This function can only be called when application receieves authentication event (BT_AUTH_PIN_REQUEST) + * from remote device. + * @see bt_adapter_set_authentication_req_cb() + */ +int bt_adapter_passkey_reply(char *passkey, bool authentication_reply); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief API to reply to the PASSKEY confirmation for on-going pairing with remote device. + * @remarks This function can be called by application, when local adapter wants PASSKEY confirmation from user. + * @param[in] confirmation_reply This indicates whether application wants to accepts or cancels the on-going pairing + * confirmation_reply : TRUE will indicate that Application has confirmed the PASSKEY + * confirmation_reply : FALSE will indicate that Application has failed to confirm the PASSKEY. In this situation + * the pairing will be failed. + * @pre This function can only be called when application receives authentication event (BT_AUTH_PASSKEY_CONFIRM_REQUEST) + * from remote device. + * @see bt_adapter_set_authentication_req_cb() + */ +int bt_adapter_passkey_confirmation_reply(bool confirmation_reply); + +/** * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE * @brief Registers a callback function to be invoked when the connectable state changes. diff --git a/include/tv/bluetooth_type_internal.h b/include/tv/bluetooth_type_internal.h index 8260262..33ae41e 100644 --- a/include/tv/bluetooth_type_internal.h +++ b/include/tv/bluetooth_type_internal.h @@ -395,6 +395,18 @@ typedef enum { } bt_restricted_profile_t; /** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Enumerations of the authentication event types. + * @since_tizen 3.0 + * + */ +typedef enum { + BT_AUTH_KEYBOARD_PASSKEY_DISPLAY = 0, /**< PIN display event to user for entering PIN in keyboard */ + BT_AUTH_PIN_REQUEST, /**< Legacy PIN or PASSKEY request event */ + BT_AUTH_PASSKEY_CONFIRM_REQUEST, /**< PASSKEY confirmation event to match PASSKEY in remote device */ +} bt_authentication_type_info_e; + +/** * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE * @brief Called when Trusted Profiles is changed. * @since_tizen 3.0 @@ -454,6 +466,36 @@ typedef void (*bt_ipsp_init_state_changed_cb) typedef void (*bt_ipsp_connection_state_changed_cb) (int result, bool connected, const char *remote_address, const char *iface_name, void *user_data); +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Called when remote device requests authentication. + * @since_tizen 3.0 + * @param[in] result + * @param[in] auth_type + * typedef enum { + * BT_AUTH_KEYBOARD_PASSKEY_DISPLAY = 0, : PIN display event to user for entering PIN in keyboard + * BT_AUTH_PIN_REQUEST, : Legacy PIN or PASSKEY request event + * BT_AUTH_PASSKEY_CONFIRM_REQUEST, : PASSKEY confirmation event to match PASSKEY in remote device + * } bt_authentication_type_info_e; + * @param[in] device_name Name of the remote device + * @param[in] remote_addr Remote BD address + * @param[in] pass_key PASSKEY string + * PASSKEY string is valid only if authentication types are following + * a/ BT_AUTH_KEYBOARD_PASSKEY_DISPLAY + * b/ BT_AUTH_PASSKEY_CONFIRM_REQUEST + * pass_key string will be invalid if authentication event is of type BT_AUTH_PIN_REQUEST + * as this event indicates that user MUST enter PIN or PASSKEY and perform authentication. + * + * Upon receiving BT_AUTH_KEYBOARD_PASSKEY_DISPLAY event, user should enter PASSKEY in keyboard + * Application can also call bt_device_cancel_bonding() Upon receiving BT_AUTH_KEYBOARD_PASSKEY_DISPLAY + * event which will fail the on-going pairing with remote device. + * @param[in] user_data The user data passed from the callback registration function + * @see bt_adapter_set_authentication_req_cb() + */ +typedef void (*bt_adapter_authentication_req_cb)(int result, bt_authentication_type_info_e auth_type, + char *device_name, char *remote_addr, + char *pass_key, void *user_data); /** * @} diff --git a/include/wearable/bluetooth_internal.h b/include/wearable/bluetooth_internal.h index b4378bf..7d98a0f 100644 --- a/include/wearable/bluetooth_internal.h +++ b/include/wearable/bluetooth_internal.h @@ -233,6 +233,62 @@ int bt_adapter_get_local_info(char **chipset, char **firmware, char **stack_vers int bt_adapter_set_visibility(bt_adapter_visibility_mode_e discoverable_mode, int duration); /** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Registers a callback function that will be invoked when remote device requests authentication. + * @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 by bt_initialize(). + * @param[in] callback callback function to be set when a request is received. + * @param[in] user_data data from application which will be provided in callback. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @see bt_initialize() + * @see bt_adapter_set_authentication_req_cb() + */ +int bt_adapter_set_authentication_req_cb(bt_adapter_authentication_req_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Unregisters a callback function that will be invoked when remote device requests authentication. + * @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 by bt_initialize(). + * @see bt_initialize() + * @see bt_adapter_set_authentication_req_cb() + */ +int bt_adapter_unset_authentication_req_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief API to reply with PIN or PASSKEY with authentication type - TRUE or FALSE. + * @remarks This function can be called by application when remote device requests PIN or PASSKEY from + * local adapter. + * @param[in] passkey The passkey to be provided by application when remote devices requests for it. + * @param[in] authentication_reply This indicates whether application wants to accept or cancel the on-going pairing + * @pre This function can only be called when application receieves authentication event (BT_AUTH_PIN_REQUEST) + * from remote device. + * @see bt_adapter_set_authentication_req_cb() + */ +int bt_adapter_passkey_reply(char *passkey, bool authentication_reply); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief API to reply to the PASSKEY confirmation for on-going pairing with remote device. + * @remarks This function can be called by application, when local adapter wants PASSKEY confirmation from user. + * @param[in] confirmation_reply This indicates whether application wants to accepts or cancels the on-going pairing + * confirmation_reply : TRUE will indicate that Application has confirmed the PASSKEY + * confirmation_reply : FALSE will indicate that Application has failed to confirm the PASSKEY. In this situation + * the pairing will be failed. + * @pre This function can only be called when application receives authentication event (BT_AUTH_PASSKEY_CONFIRM_REQUEST) + * from remote device. + * @see bt_adapter_set_authentication_req_cb() + */ +int bt_adapter_passkey_confirmation_reply(bool confirmation_reply); + +/** * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE * @brief Registers a callback function to be invoked when the connectable state changes. diff --git a/include/wearable/bluetooth_type_internal.h b/include/wearable/bluetooth_type_internal.h index 9dce714..04abcc0 100644 --- a/include/wearable/bluetooth_type_internal.h +++ b/include/wearable/bluetooth_type_internal.h @@ -412,6 +412,18 @@ typedef enum { } bt_restricted_profile_t; /** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Enumerations of the authentication event types. + * @since_tizen 3.0 + * + */ +typedef enum { + BT_AUTH_KEYBOARD_PASSKEY_DISPLAY = 0, /**< PIN display event to user for entering PIN in keyboard */ + BT_AUTH_PIN_REQUEST, /**< Legacy PIN or PASSKEY request event */ + BT_AUTH_PASSKEY_CONFIRM_REQUEST, /**< PASSKEY confirmation event to match PASSKEY in remote device */ +} bt_authentication_type_info_e; + +/** * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE * @brief Called when Trusted Profiles is changed. * @since_tizen 3.0 @@ -467,6 +479,37 @@ typedef void (*bt_ipsp_connection_state_changed_cb) (int result, bool connected, const char *remote_address, const char *iface_name, void *user_data); /** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Called when remote device requests authentication. + * @since_tizen 3.0 + * @param[in] result + * @param[in] auth_type + * typedef enum { + * BT_AUTH_KEYBOARD_PASSKEY_DISPLAY = 0, : PIN display event to user for entering PIN in keyboard + * BT_AUTH_PIN_REQUEST, : Legacy PIN or PASSKEY request event + * BT_AUTH_PASSKEY_CONFIRM_REQUEST, : PASSKEY confirmation event to match PASSKEY in remote device + * } bt_authentication_type_info_e; + * @param[in] device_name Name of the remote device + * @param[in] remote_addr Remote BD address + * @param[in] pass_key PASSKEY string + * PASSKEY string is valid only if authentication types are following + * a/ BT_AUTH_KEYBOARD_PASSKEY_DISPLAY + * b/ BT_AUTH_PASSKEY_CONFIRM_REQUEST + * pass_key string will be invalid if authentication event is of type BT_AUTH_PIN_REQUEST + * as this event indicates that user MUST enter PIN or PASSKEY and perform authentication. + * + * Upon receiving BT_AUTH_KEYBOARD_PASSKEY_DISPLAY event, user should enter PASSKEY in keyboard + * Application can also call bt_device_cancel_bonding() Upon receiving BT_AUTH_KEYBOARD_PASSKEY_DISPLAY + * event which will fail the on-going pairing with remote device. + * @param[in] user_data The user data passed from the callback registration function + * @see bt_adapter_set_authentication_req_cb() + */ +typedef void (*bt_adapter_authentication_req_cb)(int result, bt_authentication_type_info_e auth_type, + char *device_name, char *remote_addr, + char *pass_key, void *user_data); + +/** * @} */ diff --git a/src/bluetooth-adapter.c b/src/bluetooth-adapter.c index c62fc9b..f46e1d2 100644 --- a/src/bluetooth-adapter.c +++ b/src/bluetooth-adapter.c @@ -3808,3 +3808,28 @@ int bt_adapter_unset_authentication_req_cb(void) return BT_ERROR_NONE; } /* LCOV_EXCL_STOP */ + +int bt_adapter_passkey_reply(char *passkey, bool authentication_reply) +{ + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(passkey); + int error_code = BT_ERROR_NONE; + error_code = _bt_get_error_code(bluetooth_passkey_reply(passkey, authentication_reply)); + if (error_code != BT_ERROR_NONE) + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + + return error_code; +} + +int bt_adapter_passkey_confirmation_reply(bool confirmation_reply) +{ + BT_CHECK_INIT_STATUS(); + + int error_code = BT_ERROR_NONE; + error_code = _bt_get_error_code(bluetooth_passkey_confirmation_reply(confirmation_reply)); + if (error_code != BT_ERROR_NONE) + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + + return error_code; +} +/* LCOV_EXCL_STOP */ diff --git a/src/bluetooth-device.c b/src/bluetooth-device.c index 6962ea8..315f836 100644 --- a/src/bluetooth-device.c +++ b/src/bluetooth-device.c @@ -691,30 +691,6 @@ int bt_device_get_service_mask_from_uuid_list(char **uuids, } /* LCOV_EXCL_START */ -int bt_passkey_reply(char *passkey, bool authentication_reply) -{ - BT_CHECK_INIT_STATUS(); - BT_CHECK_INPUT_PARAMETER(passkey); - int error_code = BT_ERROR_NONE; - error_code = _bt_get_error_code(bluetooth_passkey_reply(passkey, authentication_reply)); - if (error_code != BT_ERROR_NONE) - BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); - - return error_code; -} - -int bt_passkey_confirmation_reply(bool confirmation_reply) -{ - BT_CHECK_INIT_STATUS(); - - int error_code = BT_ERROR_NONE; - error_code = _bt_get_error_code(bluetooth_passkey_confirmation_reply(confirmation_reply)); - if (error_code != BT_ERROR_NONE) - BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); - - return error_code; -} - int bt_device_set_pin_code(const char *remote_address, const char *pin_code) { int error_code = BT_ERROR_NONE; diff --git a/test/bt_unit_test.c b/test/bt_unit_test.c index 5a88368..dfda703 100644 --- a/test/bt_unit_test.c +++ b/test/bt_unit_test.c @@ -256,13 +256,13 @@ tc_table_t tc_adapter[] = { , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_AUTHENTICATION_REQUSET_CB}, {"bt_adapter_unset_authentication_req_cb" , BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_AUTHENTICATION_REQUSET_CB}, - {"bt_passkey_reply(passkey, TRUE)" + {"bt_adapter_passkey_reply(passkey, TRUE)" , BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_REPLY_ACCEPT}, - {"bt_passkey_reply(passkey, FALSE)" + {"bt_adapter_passkey_reply(passkey, FALSE)" , BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_REPLY_CANCEL}, - {"bt_passkey_confirmation_reply(TRUE)" + {"bt_adapter_passkey_confirmation_reply(TRUE)" , BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_CONFIRMATION_REPLY_ACCEPT}, - {"bt_passkey_confirmation_reply(FALSE)" + {"bt_adapter_passkey_confirmation_reply(FALSE)" , BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_CONFIRMATION_REPLY_REJECT}, {"Select this menu to set parameters and then select the function again." , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, @@ -4723,45 +4723,45 @@ int test_input_callback(void *data) case BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_REPLY_ACCEPT: { char *passkey = NULL; - TC_PRT("bt_passkey_reply: Authenticate Logitech Mouse: reply = Accept"); + TC_PRT("bt_adapter_passkey_reply: Authenticate Logitech Mouse: reply = Accept"); passkey = g_strdup("0000"); /* Passkey - "0000" for mouse */ - ret = bt_passkey_reply(passkey, TRUE); + ret = bt_adapter_passkey_reply(passkey, TRUE); if (ret < BT_ERROR_NONE) TC_PRT("failed with [0x%04x]", ret); else - TC_PRT("bt_passkey_reply: accept authentication result = %d", ret); + TC_PRT("bt_adapter_passkey_reply: accept authentication result = %d", ret); g_free(passkey); break; } case BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_REPLY_CANCEL: { char *passkey = NULL; - TC_PRT("bt_passkey_reply: cancel authentication reply"); + TC_PRT("bt_adapter_passkey_reply: cancel authentication reply"); passkey = g_strdup("0000"); /* Passkey - "0000" */ - ret = bt_passkey_reply(passkey, FALSE); + ret = bt_adapter_passkey_reply(passkey, FALSE); if (ret < BT_ERROR_NONE) TC_PRT("failed with [0x%04x]", ret); else - TC_PRT("bt_passkey_reply: Logitech Mouse cancel authentication result = %d", ret); + TC_PRT("bt_adapter_passkey_reply: Logitech Mouse cancel authentication result = %d", ret); g_free(passkey); break; } case BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_CONFIRMATION_REPLY_ACCEPT: { - ret = bt_passkey_confirmation_reply(TRUE); + ret = bt_adapter_passkey_confirmation_reply(TRUE); if (ret < BT_ERROR_NONE) TC_PRT("failed with [0x%04x]", ret); else - TC_PRT("bt_passkey_confirmation_reply accept, result = %d", ret); + TC_PRT("bt_adapter_passkey_confirmation_reply accept, result = %d", ret); break; } case BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_CONFIRMATION_REPLY_REJECT: { - ret = bt_passkey_confirmation_reply(FALSE); + ret = bt_adapter_passkey_confirmation_reply(FALSE); if (ret < BT_ERROR_NONE) TC_PRT("failed with [0x%04x]", ret); else - TC_PRT("bt_passkey_confirmation_reply reject, result = %d", ret); + TC_PRT("bt_adapter_passkey_confirmation_reply reject, result = %d", ret); break; } case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: