diff options
author | Jerzy Kasenberg <jerzy.kasenberg@tieto.com> | 2013-11-08 13:48:30 +0100 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2013-11-08 15:13:06 +0200 |
commit | fcd2812197783c3524ff9a0544ac93894b9c443f (patch) | |
tree | ae4d1208dbba01ec6ed47a7eed329f44b95f84a8 /android/client | |
parent | 72c31efadf139132ea7f4c70b2e0d023afee3b72 (diff) | |
download | bluez-fcd2812197783c3524ff9a0544ac93894b9c443f.tar.gz |
android/client: Add ssp key confirmation helper
This patch adds handling of ssp_request_cb that prints prompt
asking user if pass key matches. User does not need to type:
bluetooth ssp_reply address BT_SSP_VARIANT_PASSKEY_CONFIRMATION 1 key
Diffstat (limited to 'android/client')
-rw-r--r-- | android/client/if-bt.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/android/client/if-bt.c b/android/client/if-bt.c index 0a580e11f..10ae12510 100644 --- a/android/client/if-bt.c +++ b/android/client/if-bt.c @@ -239,10 +239,26 @@ static void pin_request_cb(bt_bdaddr_t *remote_bd_addr, bt_bdname_t *bd_name, terminal_prompt_for("Enter pin: ", pin_request_answer); } +/* Variables to store information from ssp_request_cb used for ssp_reply */ +static bt_bdaddr_t ssp_request_addr; +static bt_ssp_variant_t ssp_request_variant; +static uint32_t ssp_request_pask_key; + +/* Called when user hit enter on prompt for confirmation */ +static void ssp_request_yes_no_answer(char *reply) +{ + int accept = *reply == 0 || *reply == 'y' || *reply == 'Y'; + + if_bluetooth->ssp_reply(&ssp_request_addr, ssp_request_variant, accept, + ssp_request_pask_key); +} + static void ssp_request_cb(bt_bdaddr_t *remote_bd_addr, bt_bdname_t *bd_name, uint32_t cod, bt_ssp_variant_t pairing_variant, uint32_t pass_key) { + static char prompt[50]; + /* Store for command completion */ bt_bdaddr_t2str(remote_bd_addr, last_remote_addr); last_ssp_variant = pairing_variant; @@ -250,6 +266,16 @@ static void ssp_request_cb(bt_bdaddr_t *remote_bd_addr, bt_bdname_t *bd_name, haltest_info("%s: remote_bd_addr=%s bd_name=%s cod=%06x pairing_variant=%s pass_key=%d\n", __func__, last_remote_addr, bd_name->name, cod, bt_ssp_variant_t2str(pairing_variant), pass_key); + + if (pairing_variant == BT_SSP_VARIANT_PASSKEY_CONFIRMATION) { + sprintf(prompt, "Does other device show %d [Y/n] ?", pass_key); + + ssp_request_addr = *remote_bd_addr; + ssp_request_variant = pairing_variant; + ssp_request_pask_key = pass_key; + + terminal_prompt_for(prompt, ssp_request_yes_no_answer); + } } static void bond_state_changed_cb(bt_status_t status, |