Immediately bounce back SYMM packet when initiator.
On first establishment of the LLCP link, if we are
the initiator, we waited the full LTO before sending
the SYMM to the target. This will prevent the target
from communicating with us for 750ms! Old Android
implementations only connected LLCP on touch, but
newer ones will immediately connect LLCP.
To solve this, bounce the SYMM back immediately, to allow
the target to start sending as soon as it wants to.
Change-Id: I2fb09599798527f2e6f908b8ba362e0061120be2
diff --git a/src/phFriNfc_Llcp.c b/src/phFriNfc_Llcp.c
index 8138cd3..ca2836a 100644
--- a/src/phFriNfc_Llcp.c
+++ b/src/phFriNfc_Llcp.c
@@ -702,7 +702,8 @@
static void phFriNfc_Llcp_ResetLTO( phFriNfc_Llcp_t *Llcp )
{
- uint32_t nDuration;
+ uint32_t nDuration = 0;
+ uint8_t bIsReset = 0;
/* Stop timer */
phOsalNfc_Timer_Stop(Llcp->hSymmTimer);
@@ -720,6 +721,7 @@
else if (Llcp->state != PHFRINFC_LLCP_STATE_DEACTIVATION &&
Llcp->state != PHFRINFC_LLCP_STATE_RESET_INIT)
{
+ bIsReset = 1;
/* Not yet in OPERATION state, perform first reset */
if (Llcp->eRole == phFriNfc_LlcpMac_ePeerTypeInitiator)
{
@@ -740,11 +742,22 @@
}
else
{
- /* Must answer before the local announced LTO */
- /* NOTE: to ensure the answer is completely sent before LTO, the
- timer is triggered _before_ LTO expiration */
- /* TODO: make sure time scope is enough, and avoid use of magic number */
- nDuration = (Llcp->sLocalParams.lto * 10) / 2;
+ if (bIsReset)
+ {
+ /* Immediately bounce SYMM back - it'll take
+ * a while for the host to come up with something,
+ * and maybe the remote is faster.
+ */
+ nDuration = 1;
+ }
+ else
+ {
+ /* Must answer before the local announced LTO */
+ /* NOTE: to ensure the answer is completely sent before LTO, the
+ timer is triggered _before_ LTO expiration */
+ /* TODO: make sure time scope is enough, and avoid use of magic number */
+ nDuration = (Llcp->sLocalParams.lto * 10) / 2;
+ }
}
LLCP_DEBUG("Starting LLCP timer with duration %d", nDuration);