ARYGON readers could now poll using PN532 hardware feature.
This commit is contained in:
parent
332eed3596
commit
2766cd8822
1 changed files with 41 additions and 6 deletions
|
@ -46,9 +46,11 @@
|
||||||
#define SERIAL_STRING "COM"
|
#define SERIAL_STRING "COM"
|
||||||
#define snprintf _snprintf
|
#define snprintf _snprintf
|
||||||
#define strdup _strdup
|
#define strdup _strdup
|
||||||
|
#define delay_ms( X ) Sleep( X )
|
||||||
#else
|
#else
|
||||||
// unistd.h is needed for usleep() fct.
|
// unistd.h is needed for usleep() fct.
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#define delay_ms( X ) usleep( X * 1000 )
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
// MacOS
|
// MacOS
|
||||||
|
@ -245,6 +247,39 @@ bool arygon_transceive(const nfc_device_spec_t nds, const byte_t* pbtTx, const s
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf(" RX: ");
|
||||||
|
print_hex(abtRxBuf,szRxBufLen);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const byte_t pn53x_ack_frame[] = { 0x00,0x00,0xff,0x00,0xff,0x00 };
|
||||||
|
const byte_t pn53x_nack_frame[] = { 0x00,0x00,0xff,0xff,0x00,0x00 };
|
||||||
|
if(szRxBufLen >= sizeof(pn53x_ack_frame)) {
|
||||||
|
|
||||||
|
// Check if PN53x reply ACK
|
||||||
|
if(0!=memcmp(pn53x_ack_frame, abtRxBuf, sizeof(pn53x_ack_frame))) {
|
||||||
|
DBG("%s", "PN53x doesn't respond ACK frame.");
|
||||||
|
if (0==memcmp(pn53x_nack_frame, abtRxBuf, sizeof(pn53x_nack_frame))) {
|
||||||
|
ERR("%s", "PN53x reply NACK frame.");
|
||||||
|
// FIXME Handle NACK frame i.e. resend frame, PN53x doesn't received it correctly
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
szRxBufLen -= sizeof(pn53x_ack_frame);
|
||||||
|
if(szRxBufLen) {
|
||||||
|
memmove(abtRxBuf, abtRxBuf+sizeof(pn53x_ack_frame), szRxBufLen);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(szRxBufLen == 0) {
|
||||||
|
// There was no more data than ACK frame, we need to wait next frame
|
||||||
|
DBG("%s", "There was no more data than ACK frame, we need to wait next frame");
|
||||||
|
while (!uart_receive((serial_port)nds,abtRxBuf,&szRxBufLen)) {
|
||||||
|
delay_ms(10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf(" RX: ");
|
printf(" RX: ");
|
||||||
print_hex(abtRxBuf,szRxBufLen);
|
print_hex(abtRxBuf,szRxBufLen);
|
||||||
|
@ -253,12 +288,12 @@ bool arygon_transceive(const nfc_device_spec_t nds, const byte_t* pbtTx, const s
|
||||||
// When the answer should be ignored, just return a successful result
|
// When the answer should be ignored, just return a successful result
|
||||||
if(pbtRx == NULL || pszRxLen == NULL) return true;
|
if(pbtRx == NULL || pszRxLen == NULL) return true;
|
||||||
|
|
||||||
// Only succeed when the result is at least 00 00 ff 00 ff 00 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 < 15) return false;
|
if(szRxBufLen < 9) 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 - 15;
|
*pszRxLen = szRxBufLen - 9;
|
||||||
memcpy(pbtRx, abtRxBuf+13, *pszRxLen);
|
memcpy(pbtRx, abtRxBuf+7, *pszRxLen);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue