summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/bt_target.h4
-rw-r--r--stack/btm/btm_int.h5
-rw-r--r--stack/btm/btm_sec.c46
3 files changed, 53 insertions, 2 deletions
diff --git a/include/bt_target.h b/include/bt_target.h
index 16605c6df..f712d2c1a 100644
--- a/include/bt_target.h
+++ b/include/bt_target.h
@@ -132,6 +132,10 @@
#define BTA_AV_RET_TOUT 15
#endif
+#ifndef PORCHE_PAIRING_CONFLICT
+#define PORCHE_PAIRING_CONFLICT TRUE
+#endif
+
#ifndef BTA_AV_CO_CP_SCMS_T
#define BTA_AV_CO_CP_SCMS_T FALSE
#endif
diff --git a/stack/btm/btm_int.h b/stack/btm/btm_int.h
index 7f3eff645..65f0895d7 100644
--- a/stack/btm/btm_int.h
+++ b/stack/btm/btm_int.h
@@ -853,6 +853,11 @@ typedef struct
BOOLEAN security_mode_changed; /* mode changed during bonding */
BOOLEAN pin_type_changed; /* pin type changed during bonding */
BOOLEAN sec_req_pending; /* TRUE if a request is pending */
+// btla-specific ++
+#ifdef PORCHE_PAIRING_CONFLICT
+ UINT8 pin_code_len_saved; /* for legacy devices */
+#endif
+// btla-specific --
UINT8 pin_code_len; /* for legacy devices */
PIN_CODE pin_code; /* for legacy devices */
diff --git a/stack/btm/btm_sec.c b/stack/btm/btm_sec.c
index c8b1de708..68e9a8e4d 100644
--- a/stack/btm/btm_sec.c
+++ b/stack/btm/btm_sec.c
@@ -953,6 +953,13 @@ void BTM_PINCodeReply (BD_ADDR bd_addr, UINT8 res, UINT8 pin_len, UINT8 *p_pin,
btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_AUTH_COMPLETE);
btm_cb.acl_disc_reason = HCI_SUCCESS;
+#ifdef PORCHE_PAIRING_CONFLICT
+ BTM_TRACE_EVENT("BTM_PINCodeReply(): Saving pin_len: %d btm_cb.pin_code_len: %d", pin_len, btm_cb.pin_code_len);
+ /* if this was not pre-fetched, save the PIN */
+ if (btm_cb.pin_code_len == 0)
+ memcpy (btm_cb.pin_code, p_pin, pin_len);
+ btm_cb.pin_code_len_saved = pin_len;
+#endif
btsnd_hcic_pin_code_req_reply (bd_addr, pin_len, p_pin);
}
@@ -5183,6 +5190,10 @@ void btm_sec_pin_code_request (UINT8 *p_bda)
tBTM_SEC_DEV_REC *p_dev_rec;
tBTM_CB *p_cb = &btm_cb;
+#ifdef PORCHE_PAIRING_CONFLICT
+ UINT8 default_pin_code_len = 4;
+ PIN_CODE default_pin_code = {0x30, 0x30, 0x30, 0x30};
+#endif
BTM_TRACE_EVENT ("btm_sec_pin_code_request() State: %s, BDA:%04x%08x",
btm_pair_state_descr(btm_cb.pairing_state),
(p_bda[0]<<8)+p_bda[1], (p_bda[2]<<24)+(p_bda[3]<<16)+(p_bda[4]<<8)+p_bda[5] );
@@ -5192,15 +5203,41 @@ void btm_sec_pin_code_request (UINT8 *p_bda)
if ( (memcmp (p_bda, btm_cb.pairing_bda, BD_ADDR_LEN) == 0) &&
(btm_cb.pairing_state == BTM_PAIR_STATE_WAIT_AUTH_COMPLETE) )
{
- btsnd_hcic_pin_code_neg_reply (p_bda);
- return;
+ /* fake this out - porshe carkit issue - */
+// btm_cb.pairing_state = BTM_PAIR_STATE_IDLE;
+ if(! btm_cb.pin_code_len_saved)
+ {
+ btsnd_hcic_pin_code_neg_reply (p_bda);
+ return;
+ }
+ else
+ {
+ btsnd_hcic_pin_code_req_reply (p_bda, btm_cb.pin_code_len_saved, p_cb->pin_code);
+ return;
+ }
}
else if ((btm_cb.pairing_state != BTM_PAIR_STATE_WAIT_PIN_REQ)
|| memcmp (p_bda, btm_cb.pairing_bda, BD_ADDR_LEN) != 0)
{
BTM_TRACE_WARNING ("btm_sec_pin_code_request() rejected - state: %s",
btm_pair_state_descr(btm_cb.pairing_state));
+
+#ifdef PORCHE_PAIRING_CONFLICT
+ /* reply pin code again due to counter in_rand when local initiates pairing */
+ BTM_TRACE_EVENT ("btm_sec_pin_code_request from remote dev. for local initiated pairing");
+ if(! btm_cb.pin_code_len_saved)
+ {
+ btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_AUTH_COMPLETE);
+ btsnd_hcic_pin_code_req_reply (p_bda, default_pin_code_len, default_pin_code);
+ }
+ else
+ {
+ btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_AUTH_COMPLETE);
+ btsnd_hcic_pin_code_req_reply (p_bda, btm_cb.pin_code_len_saved, p_cb->pin_code);
+ }
+#else
btsnd_hcic_pin_code_neg_reply (p_bda);
+#endif
return;
}
}
@@ -5237,6 +5274,10 @@ void btm_sec_pin_code_request (UINT8 *p_bda)
BTM_TRACE_EVENT ("btm_sec_pin_code_request bonding sending reply");
btsnd_hcic_pin_code_req_reply (p_bda, btm_cb.pin_code_len, p_cb->pin_code);
+#ifdef PORCHE_PAIRING_CONFLICT
+ btm_cb.pin_code_len_saved = btm_cb.pin_code_len;
+#endif
+
/* Mark that we forwarded received from the user PIN code */
btm_cb.pin_code_len = 0;
@@ -5267,6 +5308,7 @@ void btm_sec_pin_code_request (UINT8 *p_bda)
/* Notify upper layer of PIN request and start expiration timer */
else
{
+ btm_cb.pin_code_len_saved = 0;
btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_LOCAL_PIN);
/* Pin code request can not come at the same time as connection request */
memcpy (p_cb->connecting_bda, p_bda, BD_ADDR_LEN);