Fix SMP pairing request issue on LE
The cause of the failure:
- the master device sent the three keys to slave, but slave only receive
two and got the link drop before the third key is received.
- the slave device treats it as pairing failure due to the key missing.
SMP should wait for all keys been sent to controller before dropping the link.
Implement L2CAP fix channel tx_complete callback for this reason,
and it has been applied on the channel 6 (SMP).
Channel 7 (BR_SMP channel) was not keeping track of total_tx_unacked
number and closed the link too early. Added check in the
smp_br_key_distribution() and the ACL data tracking there before
posting SMP_BR_AUTH_CMPL_EVT.
Original author: Chaojing Sun <cjsun@broadcom.com>
Change-Id: If48a4c5e28b1d177f14ff089e8dfa3ace41eba83
diff --git a/stack/smp/smp_act.c b/stack/smp/smp_act.c
index 150ffe6..f4e81dc 100644
--- a/stack/smp/smp_act.c
+++ b/stack/smp/smp_act.c
@@ -907,8 +907,13 @@
if (!p_cb->local_i_key && !p_cb->local_r_key)
{
/* state check to prevent re-entrance */
- if (p_cb->smp_over_br)
- smp_br_state_machine_event(p_cb, SMP_BR_AUTH_CMPL_EVT, &reason);
+ if (smp_get_br_state() == SMP_BR_STATE_BOND_PENDING)
+ {
+ if (p_cb->total_tx_unacked == 0)
+ smp_br_state_machine_event(p_cb, SMP_BR_AUTH_CMPL_EVT, &reason);
+ else
+ p_cb->wait_for_authorization_complete = TRUE;
+ }
}
}
@@ -2077,8 +2082,12 @@
void smp_br_pairing_complete(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
{
SMP_TRACE_DEBUG("%s", __func__);
- /* process the pairing complete */
- smp_proc_pairing_cmpl(p_cb);
+
+ if (p_cb->total_tx_unacked == 0)
+ {
+ /* process the pairing complete */
+ smp_proc_pairing_cmpl(p_cb);
+ }
}
#endif