summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartijn Coenen <maco@google.com>2013-02-28 13:48:39 -0800
committerMartijn Coenen <maco@google.com>2013-02-28 13:52:55 -0800
commit65e86fce1fe9e3f9aff98861c5e1e9d9ba6df9d5 (patch)
tree128c65cc864002045bfc14f3b2d31a6a27ea2728
parent54222dd9925b48b9d124a1f73302866cb5256788 (diff)
downloadlibnfc-nxp-65e86fce1fe9e3f9aff98861c5e1e9d9ba6df9d5.tar.gz
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
-rw-r--r--src/phFriNfc_Llcp.c25
1 files changed, 19 insertions, 6 deletions
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_LinkStatus_CB( void *pCon
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 @@ static void phFriNfc_Llcp_ResetLTO( phFriNfc_Llcp_t *Llcp )
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 @@ static void phFriNfc_Llcp_ResetLTO( phFriNfc_Llcp_t *Llcp )
}
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);