Always ACK on transmission.
New issue Summary: Make sending ACK on message transmission skipable. Owner: rtartiere@il4p.fr Cc: rtartiere@il4p.fr Status: New I guess that for performance reasons, some advance users would prefer to skip sending the non-mandatory ACK on data transmission. They may also perform a quicker check of the ACK returned by the chip after sending the command and before receiving the response (not sure about this one). It will probably be a ./configure option disabled by default that allows some "shortcuts" to perform NFC hacking.
This commit is contained in:
parent
f4bc39bf41
commit
57b775bae2
3 changed files with 24 additions and 0 deletions
|
@ -199,6 +199,8 @@ bool arygon_transceive(nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTx
|
||||||
byte_t abtRxBuf[BUFFER_LENGTH];
|
byte_t abtRxBuf[BUFFER_LENGTH];
|
||||||
size_t szRxBufLen = BUFFER_LENGTH;
|
size_t szRxBufLen = BUFFER_LENGTH;
|
||||||
size_t szPos;
|
size_t szPos;
|
||||||
|
// TODO: Move this one level up for libnfc-1.6
|
||||||
|
uint8_t ack_frame[] = { 0x00, 0x00, 0xff, 0x00, 0xff, 0x00 };
|
||||||
|
|
||||||
// Packet length = data length (len) + checksum (1) + end of stream marker (1)
|
// Packet length = data length (len) + checksum (1) + end of stream marker (1)
|
||||||
abtTxBuf[4] = szTxLen;
|
abtTxBuf[4] = szTxLen;
|
||||||
|
@ -254,6 +256,14 @@ bool arygon_transceive(nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTx
|
||||||
// Only succeed when the result is at least 00 00 FF xx Fx Dx xx .. .. .. xx 00 (x = variable)
|
// Only succeed when the result is at least 00 00 FF xx Fx Dx xx .. .. .. xx 00 (x = variable)
|
||||||
if(szRxBufLen < 9) return false;
|
if(szRxBufLen < 9) return false;
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
PRINT_HEX("TX", ack_frame, 6);
|
||||||
|
#endif
|
||||||
|
if (!uart_send((serial_port)pnd->nds, ack_frame, 6)) {
|
||||||
|
ERR("%s", "Unable to transmit data. (TX)");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Remove the preceding and appending bytes 00 00 ff 00 ff 00 00 00 FF xx Fx .. .. .. xx 00 (x = variable)
|
// Remove the preceding and appending bytes 00 00 ff 00 ff 00 00 00 FF xx Fx .. .. .. xx 00 (x = variable)
|
||||||
*pszRxLen = szRxBufLen - 9;
|
*pszRxLen = szRxBufLen - 9;
|
||||||
memcpy(pbtRx, abtRxBuf+7, *pszRxLen);
|
memcpy(pbtRx, abtRxBuf+7, *pszRxLen);
|
||||||
|
|
|
@ -181,6 +181,8 @@ bool pn532_uart_transceive(nfc_device_t* pnd, const byte_t* pbtTx, const size_t
|
||||||
byte_t abtRxBuf[BUFFER_LENGTH];
|
byte_t abtRxBuf[BUFFER_LENGTH];
|
||||||
size_t szRxBufLen = BUFFER_LENGTH;
|
size_t szRxBufLen = BUFFER_LENGTH;
|
||||||
size_t szPos;
|
size_t szPos;
|
||||||
|
// TODO: Move this one level up for libnfc-1.6
|
||||||
|
uint8_t ack_frame[] = { 0x00, 0x00, 0xff, 0x00, 0xff, 0x00 };
|
||||||
|
|
||||||
// Packet length = data length (len) + checksum (1) + end of stream marker (1)
|
// Packet length = data length (len) + checksum (1) + end of stream marker (1)
|
||||||
abtTxBuf[3] = szTxLen;
|
abtTxBuf[3] = szTxLen;
|
||||||
|
@ -236,6 +238,14 @@ bool pn532_uart_transceive(nfc_device_t* pnd, const byte_t* pbtTx, const size_t
|
||||||
// Only succeed when the result is at least 00 00 FF xx Fx Dx xx .. .. .. xx 00 (x = variable)
|
// Only succeed when the result is at least 00 00 FF xx Fx Dx xx .. .. .. xx 00 (x = variable)
|
||||||
if(szRxBufLen < 9) return false;
|
if(szRxBufLen < 9) return false;
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
PRINT_HEX("TX", ack_frame,6);
|
||||||
|
#endif
|
||||||
|
if (!uart_send((serial_port)pnd->nds,ack_frame,6)) {
|
||||||
|
ERR("%s", "Unable to transmit data. (TX)");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Remove the preceding and appending bytes 00 00 ff 00 ff 00 00 00 FF xx Fx .. .. .. xx 00 (x = variable)
|
// Remove the preceding and appending bytes 00 00 ff 00 ff 00 00 00 FF xx Fx .. .. .. xx 00 (x = variable)
|
||||||
*pszRxLen = szRxBufLen - 9;
|
*pszRxLen = szRxBufLen - 9;
|
||||||
memcpy(pbtRx, abtRxBuf+7, *pszRxLen);
|
memcpy(pbtRx, abtRxBuf+7, *pszRxLen);
|
||||||
|
|
|
@ -243,6 +243,7 @@ bool pn53x_usb_transceive(nfc_device_t* pnd, const byte_t* pbtTx, const size_t s
|
||||||
byte_t abtTx[BUFFER_LENGTH] = { 0x00, 0x00, 0xff }; // Every packet must start with "00 00 ff"
|
byte_t abtTx[BUFFER_LENGTH] = { 0x00, 0x00, 0xff }; // Every packet must start with "00 00 ff"
|
||||||
byte_t abtRx[BUFFER_LENGTH];
|
byte_t abtRx[BUFFER_LENGTH];
|
||||||
usb_spec_t* pus = (usb_spec_t*)pnd->nds;
|
usb_spec_t* pus = (usb_spec_t*)pnd->nds;
|
||||||
|
// TODO: Move this one level up for libnfc-1.6
|
||||||
uint8_t ack_frame[] = { 0x00, 0x00, 0xff, 0x00, 0xff, 0x00 };
|
uint8_t ack_frame[] = { 0x00, 0x00, 0xff, 0x00, 0xff, 0x00 };
|
||||||
|
|
||||||
// Packet length = data length (len) + checksum (1) + end of stream marker (1)
|
// Packet length = data length (len) + checksum (1) + end of stream marker (1)
|
||||||
|
@ -298,6 +299,9 @@ bool pn53x_usb_transceive(nfc_device_t* pnd, const byte_t* pbtTx, const size_t s
|
||||||
PRINT_HEX("RX", abtRx,ret);
|
PRINT_HEX("RX", abtRx,ret);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
PRINT_HEX("TX", ack_frame,6);
|
||||||
|
#endif
|
||||||
usb_bulk_write(pus->pudh, pus->uiEndPointOut, (char *)ack_frame, 6, USB_TIMEOUT);
|
usb_bulk_write(pus->pudh, pus->uiEndPointOut, (char *)ack_frame, 6, USB_TIMEOUT);
|
||||||
|
|
||||||
// When the answer should be ignored, just return a succesful result
|
// When the answer should be ignored, just return a succesful result
|
||||||
|
|
Loading…
Reference in a new issue