diff options
author | Sunil Jogi <sunil.jogi@nxp.com> | 2012-02-09 13:39:23 -0800 |
---|---|---|
committer | Martijn Coenen <maco@google.com> | 2012-04-17 10:56:56 -0700 |
commit | c0da27e8f303bf459797f90f9f2e67c552ae8c27 (patch) | |
tree | 7741461c2a0bf5740153d36aa4369c833827e152 | |
parent | c3a87316a08d782d8b336d2d9663b47a4ec37d21 (diff) | |
download | external_libnfc-nxp-c0da27e8f303bf459797f90f9f2e67c552ae8c27.zip external_libnfc-nxp-c0da27e8f303bf459797f90f9f2e67c552ae8c27.tar.gz external_libnfc-nxp-c0da27e8f303bf459797f90f9f2e67c552ae8c27.tar.bz2 |
Added addr field in response of Jewel command
Most of the Jewel command response includes the address which is sent
as part of command. The response of Jewel command was missing address
field. This patch fix that problem by adding the missing addr field.
Bug: 5341397
Change-Id: Icba0b37dd9987bc34c3490fa12ebda51ac25ad1e
-rw-r--r-- | src/phHal4Nfc_Reader.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/phHal4Nfc_Reader.c b/src/phHal4Nfc_Reader.c index f27bb09..f5c9130 100644 --- a/src/phHal4Nfc_Reader.c +++ b/src/phHal4Nfc_Reader.c @@ -53,6 +53,20 @@ phHal4Nfc_Hal4Ctxt_t *gpHal4Ctxt; +/* Jewel Commands */ +#define PH_HAL4NFC_JEWEL_READALL 0x00 +#define PH_HAL4NFC_JEWEL_READ1 0x01 +#define PH_HAL4NFC_JEWEL_READ4 0x02 +#define PH_HAL4NFC_JEWEL_READ8 0x03 +#define PH_HAL4NFC_JEWEL_WRITE1E 0x53 +#define PH_HAL4NFC_JEWEL_WRITE4E 0x54 +#define PH_HAL4NFC_JEWEL_WRITE8E 0x55 +#define PH_HAL4NFC_JEWEL_WRITE1NE 0x1A +#define PH_HAL4NFC_JEWEL_WRITE4NE 0x1B +#define PH_HAL4NFC_JEWEL_WRITE8NE 0x1C +#define PH_HAL4NFC_JEWEL_RID 0x78 +#define PH_HAL4NFC_JEWEL_READSEG 0x10 + /* --------------------Structures and enumerations --------------------------*/ static void phHal4Nfc_Iso_3A_Transceive( @@ -535,6 +549,24 @@ NFCSTATUS phHal4Nfc_Transceive( Hal4Ctxt->psTrcvCtxtInfo-> XchangeInfo.params.tag_info.cmd_type = (uint8_t)psTransceiveInfo->cmd.JewelCmd; + + /* If Jewel command with address then save the address */ + if (psTransceiveInfo->cmd.JewelCmd == phHal_eJewel_Raw) + { + if ((psTransceiveInfo->sSendData.buffer[0] == PH_HAL4NFC_JEWEL_READ1) || + (psTransceiveInfo->sSendData.buffer[0] == PH_HAL4NFC_JEWEL_READ4) || + (psTransceiveInfo->sSendData.buffer[0] == PH_HAL4NFC_JEWEL_READ8) || + (psTransceiveInfo->sSendData.buffer[0] == PH_HAL4NFC_JEWEL_WRITE1E) || + (psTransceiveInfo->sSendData.buffer[0] == PH_HAL4NFC_JEWEL_WRITE4E) || + (psTransceiveInfo->sSendData.buffer[0] == PH_HAL4NFC_JEWEL_WRITE8E) || + (psTransceiveInfo->sSendData.buffer[0] == PH_HAL4NFC_JEWEL_WRITE1NE) || + (psTransceiveInfo->sSendData.buffer[0] == PH_HAL4NFC_JEWEL_WRITE4NE) || + (psTransceiveInfo->sSendData.buffer[0] == PH_HAL4NFC_JEWEL_WRITE8NE)) + { + Hal4Ctxt->psTrcvCtxtInfo->XchangeInfo.params.tag_info.addr = + psTransceiveInfo->sSendData.buffer[1]; + } + } break; case phHal_eISO14443_BPrime_PICC: RetStatus = PHNFCSTVAL(CID_NFC_HAL , @@ -1319,6 +1351,8 @@ void phHal4Nfc_TransceiveComplete( { /*Copy status code*/ NFCSTATUS TrcvStatus = ((phNfc_sCompletionInfo_t *)pInfo)->status; + uint32_t i; + /*Update next state*/ Hal4Ctxt->Hal4NextState = (eHal4StateTransaction == Hal4Ctxt->Hal4NextState?eHal4StateInvalid:Hal4Ctxt->Hal4NextState); @@ -1338,6 +1372,35 @@ void phHal4Nfc_TransceiveComplete( } else if(TrcvStatus == NFCSTATUS_SUCCESS) { + /* If jewel command response include address then restore the address + in the received response */ + if (Hal4Ctxt->sTgtConnectInfo.psConnectedDevice->RemDevType == phHal_eJewel_PICC) + { + if (Hal4Ctxt->psTrcvCtxtInfo->XchangeInfo.params.tag_info.cmd_type == phHal_eJewel_Raw) + { + if ((Hal4Ctxt->psTrcvCtxtInfo->XchangeInfo.tx_buffer[0] == PH_HAL4NFC_JEWEL_READ1) || + (Hal4Ctxt->psTrcvCtxtInfo->XchangeInfo.tx_buffer[0] == PH_HAL4NFC_JEWEL_READ4) || + (Hal4Ctxt->psTrcvCtxtInfo->XchangeInfo.tx_buffer[0] == PH_HAL4NFC_JEWEL_READ8) || + (Hal4Ctxt->psTrcvCtxtInfo->XchangeInfo.tx_buffer[0] == PH_HAL4NFC_JEWEL_WRITE1E) || + (Hal4Ctxt->psTrcvCtxtInfo->XchangeInfo.tx_buffer[0] == PH_HAL4NFC_JEWEL_WRITE4E) || + (Hal4Ctxt->psTrcvCtxtInfo->XchangeInfo.tx_buffer[0] == PH_HAL4NFC_JEWEL_WRITE8E) || + (Hal4Ctxt->psTrcvCtxtInfo->XchangeInfo.tx_buffer[0] == PH_HAL4NFC_JEWEL_WRITE1NE) || + (Hal4Ctxt->psTrcvCtxtInfo->XchangeInfo.tx_buffer[0] == PH_HAL4NFC_JEWEL_WRITE4NE) || + (Hal4Ctxt->psTrcvCtxtInfo->XchangeInfo.tx_buffer[0] == PH_HAL4NFC_JEWEL_WRITE8NE)) + { + /* Add address field in response */ + for (i = 0; i < ((phNfc_sTransactionInfo_t *)pInfo)->length; i++) + { + ((phNfc_sTransactionInfo_t *)pInfo)->buffer[i + 1] = + ((phNfc_sTransactionInfo_t *)pInfo)->buffer[i]; + } + ((phNfc_sTransactionInfo_t *)pInfo)->buffer[0] = + Hal4Ctxt->psTrcvCtxtInfo->XchangeInfo.params.tag_info.addr; + ((phNfc_sTransactionInfo_t *)pInfo)->length++; + } + } + } + /*Check if recvdata buffer given by upper layer is big enough to receive all response bytes.If it is not big enough ,copy number of bytes requested by upper layer to the buffer.Remaining |