diff options
author | Kausik Sinnaswamy <kausik@broadcom.com> | 2012-03-06 13:07:54 -0800 |
---|---|---|
committer | Matthew Xie <mattx@google.com> | 2012-07-14 11:19:11 -0700 |
commit | e2f1686eb6870338e070714a75bb5c7266440faf (patch) | |
tree | f548a9daef06cfed2a16b978076e2ff48fc4447f /btif/src | |
parent | 6244405bed75853e51324d1f7c90548ba15321b5 (diff) | |
download | external_bluetooth_bluedroid-e2f1686eb6870338e070714a75bb5c7266440faf.zip external_bluetooth_bluedroid-e2f1686eb6870338e070714a75bb5c7266440faf.tar.gz external_bluetooth_bluedroid-e2f1686eb6870338e070714a75bb5c7266440faf.tar.bz2 |
Merged the Passkey request callback and the passkey reply APIs into the SSP API and callback respectively
Change-Id: I356e2bea421377e68b8702404a989634f2445efa
Diffstat (limited to 'btif/src')
-rw-r--r-- | btif/src/bluetooth.c | 16 | ||||
-rw-r--r-- | btif/src/btif_dm.c | 63 |
2 files changed, 40 insertions, 39 deletions
diff --git a/btif/src/bluetooth.c b/btif/src/bluetooth.c index 766f685..c323c70 100644 --- a/btif/src/bluetooth.c +++ b/btif/src/bluetooth.c @@ -280,23 +280,14 @@ static int pin_reply(const bt_bdaddr_t *bd_addr, uint8_t accept, return btif_dm_pin_reply(bd_addr, accept, pin_len, pin_code); } -static int passkey_reply(const bt_bdaddr_t *bd_addr, uint8_t accept, - uint32_t passkey) +static int ssp_reply(const bt_bdaddr_t *bd_addr, bt_ssp_variant_t variant, + uint8_t accept, uint32_t passkey) { /* sanity check */ if (interface_ready() == FALSE) return BT_STATUS_NOT_READY; - return btif_dm_passkey_reply(bd_addr, accept, passkey); -} - -static int ssp_reply(const bt_bdaddr_t *bd_addr, uint8_t accept) -{ - /* sanity check */ - if (interface_ready() == FALSE) - return BT_STATUS_NOT_READY; - - return btif_dm_ssp_reply(bd_addr, accept); + return btif_dm_ssp_reply(bd_addr, variant, accept, passkey); } static const void* get_profile_interface (const char *profile_id) @@ -332,7 +323,6 @@ static const bt_interface_t bluetoothInterface = { remove_bond, cancel_bond, pin_reply, - passkey_reply, ssp_reply, get_profile_interface }; diff --git a/btif/src/btif_dm.c b/btif/src/btif_dm.c index ddd187a..750bb76 100644 --- a/btif/src/btif_dm.c +++ b/btif/src/btif_dm.c @@ -299,23 +299,44 @@ static void btif_dm_ssp_cfm_req_evt(tBTA_DM_SP_CFM_REQ *p_ssp_cfm_req) if (p_ssp_cfm_req->just_works) { BTIF_TRACE_EVENT1("%s: Auto-accept JustWorks pairing", __FUNCTION__); - btif_dm_ssp_reply(&bd_addr, TRUE); + btif_dm_ssp_reply(&bd_addr, BT_SSP_VARIANT_CONSENT, TRUE, 0); return; } cod = devclass2uint(p_ssp_cfm_req->dev_class); - if ( cod == 0) { + if ( cod == 0) { LOGD("cod is 0, set as unclassified"); cod = COD_UNCLASSIFIED; } - /* TODO: pairing variant? */ + /* TODO: pairing variant passkey_entry? */ CHECK_CALL_CBACK(bt_hal_cbacks, ssp_request_cb, &bd_addr, &bd_name, - cod, BT_SSP_VARIANT_CONSENT, + cod, BT_SSP_VARIANT_PASSKEY_CONFIRMATION, p_ssp_cfm_req->num_val); } +static void btif_dm_ssp_key_notif_evt(tBTA_DM_SP_KEY_NOTIF *p_ssp_key_notif) +{ + bt_bdaddr_t bd_addr; + bt_bdname_t bd_name; + UINT32 cod; + + BTIF_TRACE_DEBUG1("%s", __FUNCTION__); + bdcpy(bd_addr.address, p_ssp_key_notif->bd_addr); + memcpy(bd_name.name, p_ssp_key_notif->bd_name, BD_NAME_LEN); + + cod = devclass2uint(p_ssp_key_notif->dev_class); + + if ( cod == 0) { + LOGD("cod is 0, set as unclassified"); + cod = COD_UNCLASSIFIED; + } + + CHECK_CALL_CBACK(bt_hal_cbacks, ssp_request_cb, &bd_addr, &bd_name, + cod, BT_SSP_VARIANT_PASSKEY_NOTIFICATION, + p_ssp_key_notif->passkey); +} /******************************************************************************* ** ** Function btif_dm_auth_cmpl_evt @@ -690,13 +711,14 @@ static void btif_dm_upstreams_evt(UINT16 event, char* p_param) case BTA_DM_SP_CFM_REQ_EVT: btif_dm_ssp_cfm_req_evt(&p_data->cfm_req); break; - + case BTA_DM_SP_KEY_NOTIF_EVT: + btif_dm_ssp_key_notif_evt(&p_data->key_notif); + break; case BTA_DM_AUTHORIZE_EVT: case BTA_DM_LINK_DOWN_EVT: case BTA_DM_SIG_STRENGTH_EVT: case BTA_DM_BUSY_LEVEL_EVT: case BTA_DM_BOND_CANCEL_CMPL_EVT: - case BTA_DM_SP_KEY_NOTIF_EVT: case BTA_DM_SP_RMT_OOB_EVT: case BTA_DM_SP_KEYPRESS_EVT: case BTA_DM_ROLE_CHG_EVT: @@ -1021,40 +1043,29 @@ bt_status_t btif_dm_pin_reply( const bt_bdaddr_t *bd_addr, uint8_t accept, return BT_STATUS_SUCCESS; } - /******************************************************************************* ** -** Function btif_dm_passkey_reply +** Function btif_dm_ssp_reply ** -** Description BT SSP passkey reply +** Description BT SSP Reply - Just Works, Numeric Comparison & Passkey Entry ** ** Returns bt_status_t ** *******************************************************************************/ -bt_status_t btif_dm_passkey_reply(const bt_bdaddr_t *bd_addr, - uint8_t accept, uint32_t passkey) +bt_status_t btif_dm_ssp_reply(const bt_bdaddr_t *bd_addr, + bt_ssp_variant_t variant, uint8_t accept, + uint32_t passkey) +{ + if (variant == BT_SSP_VARIANT_PASSKEY_ENTRY) { /* This is not implemented in the stack. - ** For devices with display, this is not needed + * For devices with display, this is not needed */ BTIF_TRACE_WARNING1("%s: Not implemented", __FUNCTION__); - return BT_STATUS_FAIL; } - -/******************************************************************************* -** -** Function btif_dm_ssp_reply -** -** Description BT SSP Reply - Just Works & Numeric Comparison -** -** Returns bt_status_t -** -*******************************************************************************/ - -bt_status_t btif_dm_ssp_reply(const bt_bdaddr_t *bd_addr, uint8_t accept) -{ + /* BT_SSP_VARIANT_CONSENT & BT_SSP_VARIANT_PASSKEY_CONFIRMATION supported */ BTIF_TRACE_EVENT2("%s: accept=%d", __FUNCTION__, accept); BTA_DmConfirm( (UINT8 *)bd_addr->address, accept); if (!accept) |