Bluetooth: Add support for fixed passkeys

Add a new bt_passkey_set() API that can be used to set a fixed passkey
to be used for pairing. The new API also requires a new Kconfig option
to be enabled first (CONFIG_BT_FIXED_PASSKEY).

Fixes #8350

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
Johan Hedberg 2018-07-30 20:29:40 +03:00 committed by Johan Hedberg
commit c446c8267b
4 changed files with 113 additions and 44 deletions

View file

@ -382,6 +382,28 @@ struct bt_conn_cb {
*/
void bt_conn_cb_register(struct bt_conn_cb *cb);
/** @def BT_PASSKEY_INVALID
*
* Special passkey value that can be used to disable a previously
* set fixed passkey.
*/
#define BT_PASSKEY_INVALID 0xffffffff
/** @brief Set a fixed passkey to be used for pairing.
*
* This API is only available when the CONFIG_BT_FIXED_PASSKEY
* configuration option has been enabled.
*
* Sets a fixed passkey to be used for pairing. If set, the
* pairing_confim() callback will be called for all incoming pairings.
*
* @param passkey A valid passkey (0 - 999999) or BT_PASSKEY_INVALID
* to disable a previously set fixed passkey.
*
* @return 0 on success or a negative error code on failure.
*/
int bt_passkey_set(unsigned int passkey);
/** Authenticated pairing callback structure */
struct bt_conn_auth_cb {
/** @brief Display a passkey to the user.