Massive code clean up: (Fixes Issue 161)
- Remove typedef from internal structs - Remove _t suffix from types - Fix tests using connstrings
This commit is contained in:
parent
55daa29a7c
commit
c718fafee7
47 changed files with 546 additions and 533 deletions
|
|
@ -61,18 +61,20 @@ char *serial_ports_device_radix[] = { "ttyUSB", "ttyS", NULL };
|
|||
// Work-around to claim uart interface using the c_iflag (software input processing) from the termios struct
|
||||
# define CCLAIMED 0x80000000
|
||||
|
||||
typedef struct {
|
||||
struct serial_port_unix{
|
||||
int fd; // Serial port file descriptor
|
||||
struct termios termios_backup; // Terminal info before using the port
|
||||
struct termios termios_new; // Terminal info during the transaction
|
||||
} serial_port_unix;
|
||||
};
|
||||
|
||||
// TODO: #define UART_FD( X ) (((struct serial_port_unix *) X)->fd)
|
||||
|
||||
void uart_close_ext (const serial_port sp, const bool restore_termios);
|
||||
|
||||
serial_port
|
||||
uart_open (const char *pcPortName)
|
||||
{
|
||||
serial_port_unix *sp = malloc (sizeof (serial_port_unix));
|
||||
struct serial_port_unix *sp = malloc (sizeof (struct serial_port_unix));
|
||||
|
||||
if (sp == 0)
|
||||
return INVALID_SERIAL_PORT;
|
||||
|
|
@ -114,12 +116,12 @@ void
|
|||
uart_flush_input (serial_port sp)
|
||||
{
|
||||
// This line seems to produce absolutely no effect on my system (GNU/Linux 2.6.35)
|
||||
tcflush (((serial_port_unix *) sp)->fd, TCIFLUSH);
|
||||
tcflush (((struct serial_port_unix *) sp)->fd, TCIFLUSH);
|
||||
// So, I wrote this byte-eater
|
||||
// Retrieve the count of the incoming bytes
|
||||
int available_bytes_count = 0;
|
||||
int res;
|
||||
res = ioctl (((serial_port_unix *) sp)->fd, FIONREAD, &available_bytes_count);
|
||||
res = ioctl (((struct serial_port_unix *) sp)->fd, FIONREAD, &available_bytes_count);
|
||||
if (res != 0) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -128,7 +130,7 @@ uart_flush_input (serial_port sp)
|
|||
}
|
||||
char* rx = malloc (available_bytes_count);
|
||||
// There is something available, read the data
|
||||
res = read (((serial_port_unix *) sp)->fd, rx, available_bytes_count);
|
||||
res = read (((struct serial_port_unix *) sp)->fd, rx, available_bytes_count);
|
||||
log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "%d bytes have eatten.", available_bytes_count);
|
||||
free (rx);
|
||||
}
|
||||
|
|
@ -137,7 +139,7 @@ void
|
|||
uart_set_speed (serial_port sp, const uint32_t uiPortSpeed)
|
||||
{
|
||||
log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "Serial port speed requested to be set to %d bauds.", uiPortSpeed);
|
||||
serial_port_unix *spu = (serial_port_unix *) sp;
|
||||
struct serial_port_unix *spu = (struct serial_port_unix *) sp;
|
||||
|
||||
// Portability note: on some systems, B9600 != 9600 so we have to do
|
||||
// uint32_t <=> speed_t associations by hand.
|
||||
|
|
@ -190,7 +192,7 @@ uint32_t
|
|||
uart_get_speed (serial_port sp)
|
||||
{
|
||||
uint32_t uiPortSpeed = 0;
|
||||
const serial_port_unix *spu = (serial_port_unix *) sp;
|
||||
const struct serial_port_unix *spu = (struct serial_port_unix *) sp;
|
||||
switch (cfgetispeed (&spu->termios_new)) {
|
||||
case B9600:
|
||||
uiPortSpeed = 9600;
|
||||
|
|
@ -229,10 +231,10 @@ uart_get_speed (serial_port sp)
|
|||
void
|
||||
uart_close_ext (const serial_port sp, const bool restore_termios)
|
||||
{
|
||||
if (((serial_port_unix *) sp)->fd >= 0) {
|
||||
if (((struct serial_port_unix *) sp)->fd >= 0) {
|
||||
if (restore_termios)
|
||||
tcsetattr (((serial_port_unix *) sp)->fd, TCSANOW, &((serial_port_unix *) sp)->termios_backup);
|
||||
close (((serial_port_unix *) sp)->fd);
|
||||
tcsetattr (((struct serial_port_unix *) sp)->fd, TCSANOW, &((struct serial_port_unix *) sp)->termios_backup);
|
||||
close (((struct serial_port_unix *) sp)->fd);
|
||||
}
|
||||
free (sp);
|
||||
}
|
||||
|
|
@ -261,7 +263,7 @@ uart_receive (serial_port sp, byte_t * pbtRx, const size_t szRx, void * abort_p,
|
|||
select:
|
||||
// Reset file descriptor
|
||||
FD_ZERO (&rfds);
|
||||
FD_SET (((serial_port_unix *) sp)->fd, &rfds);
|
||||
FD_SET (((struct serial_port_unix *) sp)->fd, &rfds);
|
||||
|
||||
if (iAbortFd) {
|
||||
FD_SET (iAbortFd, &rfds);
|
||||
|
|
@ -277,7 +279,7 @@ select:
|
|||
timeout = &fixed_timeout;
|
||||
}
|
||||
|
||||
res = select (MAX(((serial_port_unix *) sp)->fd, iAbortFd) + 1, &rfds, NULL, NULL, timeout);
|
||||
res = select (MAX(((struct serial_port_unix *) sp)->fd, iAbortFd) + 1, &rfds, NULL, NULL, timeout);
|
||||
|
||||
if ((res < 0) && (EINTR == errno)) {
|
||||
// The system call was interupted by a signal and a signal handler was
|
||||
|
|
@ -304,12 +306,12 @@ select:
|
|||
}
|
||||
|
||||
// Retrieve the count of the incoming bytes
|
||||
res = ioctl (((serial_port_unix *) sp)->fd, FIONREAD, &available_bytes_count);
|
||||
res = ioctl (((struct serial_port_unix *) sp)->fd, FIONREAD, &available_bytes_count);
|
||||
if (res != 0) {
|
||||
return ECOMIO;
|
||||
}
|
||||
// There is something available, read the data
|
||||
res = read (((serial_port_unix *) sp)->fd, pbtRx + received_bytes_count, MIN(available_bytes_count, (expected_bytes_count - received_bytes_count)));
|
||||
res = read (((struct serial_port_unix *) sp)->fd, pbtRx + received_bytes_count, MIN(available_bytes_count, (expected_bytes_count - received_bytes_count)));
|
||||
// Stop if the OS has some troubles reading the data
|
||||
if (res <= 0) {
|
||||
return ECOMIO;
|
||||
|
|
@ -331,7 +333,7 @@ uart_send (serial_port sp, const byte_t * pbtTx, const size_t szTx, struct timev
|
|||
{
|
||||
(void) timeout;
|
||||
LOG_HEX ("TX", pbtTx, szTx);
|
||||
if ((int) szTx == write (((serial_port_unix *) sp)->fd, pbtTx, szTx))
|
||||
if ((int) szTx == write (((struct serial_port_unix *) sp)->fd, pbtTx, szTx))
|
||||
return 0;
|
||||
else
|
||||
return ECOMIO;
|
||||
|
|
|
|||
|
|
@ -31,17 +31,17 @@
|
|||
#include "contrib/windows.h"
|
||||
#define delay_ms( X ) Sleep( X )
|
||||
|
||||
typedef struct {
|
||||
struct serial_port_windows {
|
||||
HANDLE hPort; // Serial port handle
|
||||
DCB dcb; // Device control settings
|
||||
COMMTIMEOUTS ct; // Serial port time-out configuration
|
||||
} serial_port_windows;
|
||||
};
|
||||
|
||||
serial_port
|
||||
uart_open (const char *pcPortName)
|
||||
{
|
||||
char acPortName[255];
|
||||
serial_port_windows *sp = malloc (sizeof (serial_port_windows));
|
||||
struct serial_port_windows *sp = malloc (sizeof (struct serial_port_windows));
|
||||
|
||||
// Copy the input "com?" to "\\.\COM?" format
|
||||
sprintf (acPortName, "\\\\.\\%s", pcPortName);
|
||||
|
|
@ -85,8 +85,8 @@ uart_open (const char *pcPortName)
|
|||
void
|
||||
uart_close (const serial_port sp)
|
||||
{
|
||||
if (((serial_port_windows *) sp)->hPort != INVALID_HANDLE_VALUE) {
|
||||
CloseHandle (((serial_port_windows *) sp)->hPort);
|
||||
if (((struct serial_port_windows *) sp)->hPort != INVALID_HANDLE_VALUE) {
|
||||
CloseHandle (((struct serial_port_windows *) sp)->hPort);
|
||||
}
|
||||
free (sp);
|
||||
}
|
||||
|
|
@ -94,13 +94,13 @@ uart_close (const serial_port sp)
|
|||
void
|
||||
uart_flush_input (const serial_port sp)
|
||||
{
|
||||
PurgeComm(((serial_port_windows *) sp)->hPort, PURGE_RXABORT | PURGE_RXCLEAR);
|
||||
PurgeComm(((struct serial_port_windows *) sp)->hPort, PURGE_RXABORT | PURGE_RXCLEAR);
|
||||
}
|
||||
|
||||
void
|
||||
uart_set_speed (serial_port sp, const uint32_t uiPortSpeed)
|
||||
{
|
||||
serial_port_windows *spw;
|
||||
struct serial_port_windows *spw;
|
||||
|
||||
log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "Serial port speed requested to be set to %d bauds.", uiPortSpeed);
|
||||
// Set port speed (Input and Output)
|
||||
|
|
@ -117,7 +117,7 @@ uart_set_speed (serial_port sp, const uint32_t uiPortSpeed)
|
|||
log_put (LOG_CATEGORY, NFC_PRIORITY_ERROR, "Unable to set serial port speed to %d bauds. Speed value must be one of these constants: 9600 (default), 19200, 38400, 57600, 115200, 230400 or 460800.", uiPortSpeed);
|
||||
return;
|
||||
};
|
||||
spw = (serial_port_windows *) sp;
|
||||
spw = (struct serial_port_windows *) sp;
|
||||
|
||||
// Set baud rate
|
||||
spw->dcb.BaudRate = uiPortSpeed;
|
||||
|
|
@ -131,7 +131,7 @@ uart_set_speed (serial_port sp, const uint32_t uiPortSpeed)
|
|||
uint32_t
|
||||
uart_get_speed (const serial_port sp)
|
||||
{
|
||||
const serial_port_windows *spw = (serial_port_windows *) sp;
|
||||
const struct serial_port_windows *spw = (struct serial_port_windows *) sp;
|
||||
if (!GetCommState (spw->hPort, (serial_port) & spw->dcb))
|
||||
return spw->dcb.BaudRate;
|
||||
|
||||
|
|
@ -155,7 +155,7 @@ uart_receive (serial_port sp, byte_t * pbtRx, const size_t szRx, void * abort_p,
|
|||
timeouts.WriteTotalTimeoutMultiplier = 0;
|
||||
timeouts.WriteTotalTimeoutConstant = timeout_ms;
|
||||
|
||||
if (!SetCommTimeouts (((serial_port_windows *) sp)->hPort, &timeouts)) {
|
||||
if (!SetCommTimeouts (((struct serial_port_windows *) sp)->hPort, &timeouts)) {
|
||||
log_put (LOG_CATEGORY, NFC_PRIORITY_ERROR, "Unable to apply new timeout settings.");
|
||||
return ECOMIO;
|
||||
}
|
||||
|
|
@ -166,7 +166,7 @@ uart_receive (serial_port sp, byte_t * pbtRx, const size_t szRx, void * abort_p,
|
|||
volatile bool * abort_flag_p = (volatile bool *)abort_p;
|
||||
do {
|
||||
log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "ReadFile");
|
||||
res = ReadFile (((serial_port_windows *) sp)->hPort, pbtRx + dwTotalBytesReceived,
|
||||
res = ReadFile (((struct serial_port_windows *) sp)->hPort, pbtRx + dwTotalBytesReceived,
|
||||
dwBytesToGet,
|
||||
&dwBytesReceived, NULL);
|
||||
|
||||
|
|
@ -205,13 +205,13 @@ uart_send (serial_port sp, const byte_t * pbtTx, const size_t szTx, struct timev
|
|||
timeouts.WriteTotalTimeoutMultiplier = 0;
|
||||
timeouts.WriteTotalTimeoutConstant = timeout ? ((timeout->tv_sec * 1000) + (timeout->tv_usec / 1000)) : 0;
|
||||
|
||||
if (!SetCommTimeouts (((serial_port_windows *) sp)->hPort, &timeouts)) {
|
||||
if (!SetCommTimeouts (((struct serial_port_windows *) sp)->hPort, &timeouts)) {
|
||||
log_put (LOG_CATEGORY, NFC_PRIORITY_ERROR, "Unable to apply new timeout settings.");
|
||||
return ECOMIO;
|
||||
}
|
||||
|
||||
LOG_HEX ("TX", pbtTx, szTx);
|
||||
if (!WriteFile (((serial_port_windows *) sp)->hPort, pbtTx, szTx, &dwTxLen, NULL)) {
|
||||
if (!WriteFile (((struct serial_port_windows *) sp)->hPort, pbtTx, szTx, &dwTxLen, NULL)) {
|
||||
return ECOMIO;
|
||||
}
|
||||
if (!dwTxLen)
|
||||
|
|
|
|||
|
|
@ -51,15 +51,15 @@ const byte_t pn53x_nack_frame[] = { 0x00, 0x00, 0xff, 0xff, 0x00, 0x00 };
|
|||
static const byte_t pn53x_error_frame[] = { 0x00, 0x00, 0xff, 0x01, 0xff, 0x7f, 0x81, 0x00 };
|
||||
|
||||
/* prototypes */
|
||||
bool pn53x_reset_settings (nfc_device_t * pnd);
|
||||
bool pn53x_writeback_register (nfc_device_t * pnd);
|
||||
bool pn53x_reset_settings (nfc_device * pnd);
|
||||
bool pn53x_writeback_register (nfc_device * pnd);
|
||||
|
||||
nfc_modulation_t pn53x_ptt_to_nm (const pn53x_target_type_t ptt);
|
||||
pn53x_modulation_t pn53x_nm_to_pm (const nfc_modulation_t nm);
|
||||
pn53x_target_type_t pn53x_nm_to_ptt (const nfc_modulation_t nm);
|
||||
nfc_modulation pn53x_ptt_to_nm (const pn53x_target_type ptt);
|
||||
pn53x_modulation pn53x_nm_to_pm (const nfc_modulation nm);
|
||||
pn53x_target_type pn53x_nm_to_ptt (const nfc_modulation nm);
|
||||
|
||||
bool
|
||||
pn53x_init(nfc_device_t * pnd)
|
||||
pn53x_init(nfc_device * pnd)
|
||||
{
|
||||
// GetFirmwareVersion command is used to set PN53x chips type (PN531, PN532 or PN533)
|
||||
char abtFirmwareText[22];
|
||||
|
|
@ -89,7 +89,7 @@ pn53x_init(nfc_device_t * pnd)
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_reset_settings(nfc_device_t * pnd)
|
||||
pn53x_reset_settings(nfc_device * pnd)
|
||||
{
|
||||
// Reset the ending transmission bits register, it is unknown what the last tranmission used there
|
||||
CHIP_DATA (pnd)->ui8TxBits = 0;
|
||||
|
|
@ -100,7 +100,7 @@ pn53x_reset_settings(nfc_device_t * pnd)
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_transceive (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx, size_t *pszRx, struct timeval *timeout)
|
||||
pn53x_transceive (nfc_device * pnd, const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx, size_t *pszRx, struct timeval *timeout)
|
||||
{
|
||||
if (CHIP_DATA (pnd)->wb_trigged) {
|
||||
if (!pn53x_writeback_register (pnd)) {
|
||||
|
|
@ -190,7 +190,7 @@ pn53x_transceive (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx, b
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_set_parameters (nfc_device_t * pnd, const uint8_t ui8Parameter, const bool bEnable)
|
||||
pn53x_set_parameters (nfc_device * pnd, const uint8_t ui8Parameter, const bool bEnable)
|
||||
{
|
||||
uint8_t ui8Value = (bEnable) ? (CHIP_DATA (pnd)->ui8Parameters | ui8Parameter) : (CHIP_DATA (pnd)->ui8Parameters & ~(ui8Parameter));
|
||||
if (ui8Value != CHIP_DATA (pnd)->ui8Parameters) {
|
||||
|
|
@ -200,7 +200,7 @@ pn53x_set_parameters (nfc_device_t * pnd, const uint8_t ui8Parameter, const bool
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_set_tx_bits (nfc_device_t * pnd, const uint8_t ui8Bits)
|
||||
pn53x_set_tx_bits (nfc_device * pnd, const uint8_t ui8Bits)
|
||||
{
|
||||
// Test if we need to update the transmission bits register setting
|
||||
if (CHIP_DATA (pnd)->ui8TxBits != ui8Bits) {
|
||||
|
|
@ -318,8 +318,8 @@ pn53x_unwrap_frame (const byte_t * pbtFrame, const size_t szFrameBits, byte_t *
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_decode_target_data (const byte_t * pbtRawData, size_t szRawData, pn53x_type type, nfc_modulation_type_t nmt,
|
||||
nfc_target_info_t * pnti)
|
||||
pn53x_decode_target_data (const byte_t * pbtRawData, size_t szRawData, pn53x_type type, nfc_modulationype nmt,
|
||||
nfc_target_info * pnti)
|
||||
{
|
||||
uint8_t szAttribRes;
|
||||
|
||||
|
|
@ -462,7 +462,7 @@ pn53x_decode_target_data (const byte_t * pbtRawData, size_t szRawData, pn53x_typ
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_ReadRegister (nfc_device_t * pnd, uint16_t ui16RegisterAddress, uint8_t * ui8Value)
|
||||
pn53x_ReadRegister (nfc_device * pnd, uint16_t ui16RegisterAddress, uint8_t * ui8Value)
|
||||
{
|
||||
byte_t abtCmd[] = { ReadRegister, ui16RegisterAddress >> 8, ui16RegisterAddress & 0xff };
|
||||
byte_t abtRegValue[2];
|
||||
|
|
@ -481,13 +481,13 @@ pn53x_ReadRegister (nfc_device_t * pnd, uint16_t ui16RegisterAddress, uint8_t *
|
|||
return true;
|
||||
}
|
||||
|
||||
bool pn53x_read_register (nfc_device_t * pnd, uint16_t ui16RegisterAddress, uint8_t * ui8Value)
|
||||
bool pn53x_read_register (nfc_device * pnd, uint16_t ui16RegisterAddress, uint8_t * ui8Value)
|
||||
{
|
||||
return pn53x_ReadRegister (pnd, ui16RegisterAddress, ui8Value);
|
||||
}
|
||||
|
||||
bool
|
||||
pn53x_WriteRegister (nfc_device_t * pnd, const uint16_t ui16RegisterAddress, const uint8_t ui8Value)
|
||||
pn53x_WriteRegister (nfc_device * pnd, const uint16_t ui16RegisterAddress, const uint8_t ui8Value)
|
||||
{
|
||||
byte_t abtCmd[] = { WriteRegister, ui16RegisterAddress >> 8, ui16RegisterAddress & 0xff, ui8Value };
|
||||
PNREG_TRACE (ui16RegisterAddress);
|
||||
|
|
@ -495,7 +495,7 @@ pn53x_WriteRegister (nfc_device_t * pnd, const uint16_t ui16RegisterAddress, con
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_write_register (nfc_device_t * pnd, const uint16_t ui16RegisterAddress, const uint8_t ui8SymbolMask, const uint8_t ui8Value)
|
||||
pn53x_write_register (nfc_device * pnd, const uint16_t ui16RegisterAddress, const uint8_t ui8SymbolMask, const uint8_t ui8Value)
|
||||
{
|
||||
if ((ui16RegisterAddress < PN53X_CACHE_REGISTER_MIN_ADDRESS) || (ui16RegisterAddress > PN53X_CACHE_REGISTER_MAX_ADDRESS)) {
|
||||
// Direct write
|
||||
|
|
@ -521,7 +521,7 @@ pn53x_write_register (nfc_device_t * pnd, const uint16_t ui16RegisterAddress, co
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_writeback_register (nfc_device_t * pnd)
|
||||
pn53x_writeback_register (nfc_device * pnd)
|
||||
{
|
||||
// TODO Check at each step (ReadRegister, WriteRegister) if we didn't exceed max supported frame length
|
||||
BUFFER_INIT (abtReadRegisterCmd, PN53x_EXTENDED_FRAME__DATA_MAX_LEN);
|
||||
|
|
@ -589,7 +589,7 @@ pn53x_writeback_register (nfc_device_t * pnd)
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_get_firmware_version (nfc_device_t * pnd, char abtFirmwareText[22])
|
||||
pn53x_get_firmware_version (nfc_device * pnd, char abtFirmwareText[22])
|
||||
{
|
||||
const byte_t abtCmd[] = { GetFirmwareVersion };
|
||||
byte_t abtFw[4];
|
||||
|
|
@ -640,7 +640,7 @@ pn53x_get_firmware_version (nfc_device_t * pnd, char abtFirmwareText[22])
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_configure (nfc_device_t * pnd, const nfc_device_option_t ndo, const bool bEnable)
|
||||
pn53x_configure (nfc_device * pnd, const nfc_device_option ndo, const bool bEnable)
|
||||
{
|
||||
byte_t btValue;
|
||||
switch (ndo) {
|
||||
|
|
@ -777,7 +777,7 @@ pn53x_configure (nfc_device_t * pnd, const nfc_device_option_t ndo, const bool b
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_idle (nfc_device_t *pnd)
|
||||
pn53x_idle (nfc_device *pnd)
|
||||
{
|
||||
switch (CHIP_DATA (pnd)->operating_mode) {
|
||||
case TARGET:
|
||||
|
|
@ -825,7 +825,7 @@ pn53x_idle (nfc_device_t *pnd)
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_check_communication (nfc_device_t *pnd)
|
||||
pn53x_check_communication (nfc_device *pnd)
|
||||
{
|
||||
const byte_t abtCmd[] = { Diagnose, 0x00, 'l', 'i', 'b', 'n', 'f', 'c' };
|
||||
const byte_t abtExpectedRx[] = { 0x00, 'l', 'i', 'b', 'n', 'f', 'c' };
|
||||
|
|
@ -843,7 +843,7 @@ pn53x_check_communication (nfc_device_t *pnd)
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_initiator_init (nfc_device_t * pnd)
|
||||
pn53x_initiator_init (nfc_device * pnd)
|
||||
{
|
||||
pn53x_reset_settings(pnd);
|
||||
|
||||
|
|
@ -856,10 +856,10 @@ pn53x_initiator_init (nfc_device_t * pnd)
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_initiator_select_passive_target_ext (nfc_device_t * pnd,
|
||||
const nfc_modulation_t nm,
|
||||
pn53x_initiator_select_passive_target_ext (nfc_device * pnd,
|
||||
const nfc_modulation nm,
|
||||
const byte_t * pbtInitData, const size_t szInitData,
|
||||
nfc_target_t * pnt,
|
||||
nfc_target * pnt,
|
||||
struct timeval* timeout)
|
||||
{
|
||||
byte_t abtTargetsData[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
|
||||
|
|
@ -941,7 +941,7 @@ pn53x_initiator_select_passive_target_ext (nfc_device_t * pnd,
|
|||
return true;
|
||||
} // else:
|
||||
|
||||
const pn53x_modulation_t pm = pn53x_nm_to_pm(nm);
|
||||
const pn53x_modulation pm = pn53x_nm_to_pm(nm);
|
||||
if (PM_UNDEFINED == pm) {
|
||||
pnd->iLastError = EINVALARG;
|
||||
return false;
|
||||
|
|
@ -966,25 +966,25 @@ pn53x_initiator_select_passive_target_ext (nfc_device_t * pnd,
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_initiator_select_passive_target (nfc_device_t * pnd,
|
||||
const nfc_modulation_t nm,
|
||||
pn53x_initiator_select_passive_target (nfc_device * pnd,
|
||||
const nfc_modulation nm,
|
||||
const byte_t * pbtInitData, const size_t szInitData,
|
||||
nfc_target_t * pnt)
|
||||
nfc_target * pnt)
|
||||
{
|
||||
return pn53x_initiator_select_passive_target_ext (pnd, nm, pbtInitData, szInitData, pnt, NULL);
|
||||
}
|
||||
|
||||
bool
|
||||
pn53x_initiator_poll_target (nfc_device_t * pnd,
|
||||
const nfc_modulation_t * pnmModulations, const size_t szModulations,
|
||||
pn53x_initiator_poll_target (nfc_device * pnd,
|
||||
const nfc_modulation * pnmModulations, const size_t szModulations,
|
||||
const uint8_t uiPollNr, const uint8_t uiPeriod,
|
||||
nfc_target_t * pnt)
|
||||
nfc_target * pnt)
|
||||
{
|
||||
if (CHIP_DATA(pnd)->type == PN532) {
|
||||
size_t szTargetTypes = 0;
|
||||
pn53x_target_type_t apttTargetTypes[32];
|
||||
pn53x_target_type apttTargetTypes[32];
|
||||
for (size_t n=0; n<szModulations; n++) {
|
||||
const pn53x_target_type_t ptt = pn53x_nm_to_ptt(pnmModulations[n]);
|
||||
const pn53x_target_type ptt = pn53x_nm_to_ptt(pnmModulations[n]);
|
||||
if (PTT_UNDEFINED == ptt) {
|
||||
pnd->iLastError = EINVALARG;
|
||||
return false;
|
||||
|
|
@ -998,7 +998,7 @@ pn53x_initiator_poll_target (nfc_device_t * pnd,
|
|||
szTargetTypes++;
|
||||
}
|
||||
size_t szTargetFound = 0;
|
||||
nfc_target_t ntTargets[2];
|
||||
nfc_target ntTargets[2];
|
||||
if (!pn53x_InAutoPoll (pnd, apttTargetTypes, szTargetTypes, uiPollNr, uiPeriod, ntTargets, &szTargetFound))
|
||||
return false;
|
||||
switch (szTargetFound) {
|
||||
|
|
@ -1042,10 +1042,10 @@ pn53x_initiator_poll_target (nfc_device_t * pnd,
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_initiator_select_dep_target(nfc_device_t * pnd,
|
||||
const nfc_dep_mode_t ndm, const nfc_baud_rate_t nbr,
|
||||
const nfc_dep_info_t * pndiInitiator,
|
||||
nfc_target_t * pnt)
|
||||
pn53x_initiator_select_dep_target(nfc_device * pnd,
|
||||
const nfc_dep_mode ndm, const nfc_baud_rate nbr,
|
||||
const nfc_dep_info * pndiInitiator,
|
||||
nfc_target * pnt)
|
||||
{
|
||||
const byte_t abtPassiveInitiatorData[] = { 0x00, 0xff, 0xff, 0x00, 0x00 }; // Only for 212/424 kpbs: First 4 bytes shall be set like this according to NFCIP-1, last byte is TSN (Time Slot Number)
|
||||
const byte_t * pbtPassiveInitiatorData = NULL;
|
||||
|
|
@ -1070,7 +1070,7 @@ pn53x_initiator_select_dep_target(nfc_device_t * pnd,
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_initiator_transceive_bits (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTxBits,
|
||||
pn53x_initiator_transceive_bits (nfc_device * pnd, const byte_t * pbtTx, const size_t szTxBits,
|
||||
const byte_t * pbtTxPar, byte_t * pbtRx, size_t * pszRxBits, byte_t * pbtRxPar)
|
||||
{
|
||||
size_t szFrameBits = 0;
|
||||
|
|
@ -1134,7 +1134,7 @@ pn53x_initiator_transceive_bits (nfc_device_t * pnd, const byte_t * pbtTx, const
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_initiator_transceive_bytes (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx,
|
||||
pn53x_initiator_transceive_bytes (nfc_device * pnd, const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx,
|
||||
size_t * pszRx, struct timeval *timeout)
|
||||
{
|
||||
size_t szExtraTxLen;
|
||||
|
|
@ -1180,7 +1180,7 @@ pn53x_initiator_transceive_bytes (nfc_device_t * pnd, const byte_t * pbtTx, cons
|
|||
return true;
|
||||
}
|
||||
|
||||
void __pn53x_init_timer(nfc_device_t * pnd, const uint32_t max_cycles)
|
||||
void __pn53x_init_timer(nfc_device * pnd, const uint32_t max_cycles)
|
||||
{
|
||||
// The prescaler will dictate what will be the precision and
|
||||
// the largest delay to measure before saturation. Some examples:
|
||||
|
|
@ -1201,7 +1201,7 @@ void __pn53x_init_timer(nfc_device_t * pnd, const uint32_t max_cycles)
|
|||
pn53x_write_register (pnd, PN53X_REG_CIU_TReloadVal_lo, 0xFF, reloadval & 0xFF);
|
||||
}
|
||||
|
||||
uint32_t __pn53x_get_timer(nfc_device_t * pnd, const uint8_t last_cmd_byte)
|
||||
uint32_t __pn53x_get_timer(nfc_device * pnd, const uint8_t last_cmd_byte)
|
||||
{
|
||||
uint8_t parity;
|
||||
uint8_t counter_hi, counter_lo;
|
||||
|
|
@ -1262,7 +1262,7 @@ uint32_t __pn53x_get_timer(nfc_device_t * pnd, const uint8_t last_cmd_byte)
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_initiator_transceive_bits_timed (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTxBits,
|
||||
pn53x_initiator_transceive_bits_timed (nfc_device * pnd, const byte_t * pbtTx, const size_t szTxBits,
|
||||
const byte_t * pbtTxPar, byte_t * pbtRx, size_t * pszRxBits, byte_t * pbtRxPar, uint32_t * cycles)
|
||||
{
|
||||
// TODO Do something with these bytes...
|
||||
|
|
@ -1364,7 +1364,7 @@ pn53x_initiator_transceive_bits_timed (nfc_device_t * pnd, const byte_t * pbtTx,
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_initiator_transceive_bytes_timed (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx,
|
||||
pn53x_initiator_transceive_bytes_timed (nfc_device * pnd, const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx,
|
||||
size_t * pszRx, uint32_t * cycles)
|
||||
{
|
||||
uint16_t i;
|
||||
|
|
@ -1467,7 +1467,7 @@ pn53x_initiator_transceive_bytes_timed (nfc_device_t * pnd, const byte_t * pbtTx
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_initiator_deselect_target (nfc_device_t * pnd)
|
||||
pn53x_initiator_deselect_target (nfc_device * pnd)
|
||||
{
|
||||
return (pn53x_InDeselect (pnd, 0)); // 0 mean deselect all selected targets
|
||||
}
|
||||
|
|
@ -1475,13 +1475,13 @@ pn53x_initiator_deselect_target (nfc_device_t * pnd)
|
|||
#define SAK_ISO14443_4_COMPLIANT 0x20
|
||||
#define SAK_ISO18092_COMPLIANT 0x40
|
||||
bool
|
||||
pn53x_target_init (nfc_device_t * pnd, nfc_target_t * pnt, byte_t * pbtRx, size_t * pszRx)
|
||||
pn53x_target_init (nfc_device * pnd, nfc_target * pnt, byte_t * pbtRx, size_t * pszRx)
|
||||
{
|
||||
pn53x_reset_settings(pnd);
|
||||
|
||||
CHIP_DATA (pnd)->operating_mode = TARGET;
|
||||
|
||||
pn53x_target_mode_t ptm = PTM_NORMAL;
|
||||
pn53x_target_mode ptm = PTM_NORMAL;
|
||||
|
||||
switch (pnt->nm.nmt) {
|
||||
case NMT_ISO14443A:
|
||||
|
|
@ -1631,11 +1631,11 @@ pn53x_target_init (nfc_device_t * pnd, nfc_target_t * pnt, byte_t * pbtRx, size_
|
|||
return false;
|
||||
}
|
||||
|
||||
nfc_modulation_t nm = {
|
||||
nfc_modulation nm = {
|
||||
.nmt = NMT_DEP, // Silent compilation warnings
|
||||
.nbr = NBR_UNDEFINED
|
||||
};
|
||||
nfc_dep_mode_t ndm = NDM_UNDEFINED;
|
||||
nfc_dep_mode ndm = NDM_UNDEFINED;
|
||||
// Decode activated "mode"
|
||||
switch(btActivatedMode & 0x70) { // Baud rate
|
||||
case 0x00: // 106kbps
|
||||
|
|
@ -1681,8 +1681,8 @@ pn53x_target_init (nfc_device_t * pnd, nfc_target_t * pnt, byte_t * pbtRx, size_
|
|||
if (CHIP_DATA (pnd)->current_target) {
|
||||
free (CHIP_DATA (pnd)->current_target);
|
||||
}
|
||||
CHIP_DATA (pnd)->current_target = malloc (sizeof(nfc_target_t));
|
||||
memcpy (CHIP_DATA (pnd)->current_target, pnt, sizeof(nfc_target_t));
|
||||
CHIP_DATA (pnd)->current_target = malloc (sizeof(nfc_target));
|
||||
memcpy (CHIP_DATA (pnd)->current_target, pnt, sizeof(nfc_target));
|
||||
|
||||
if (ptm & PTM_ISO14443_4_PICC_ONLY) {
|
||||
// When PN532 is in PICC target mode, it automatically reply to RATS so
|
||||
|
|
@ -1696,7 +1696,7 @@ pn53x_target_init (nfc_device_t * pnd, nfc_target_t * pnt, byte_t * pbtRx, size_
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_target_receive_bits (nfc_device_t * pnd, byte_t * pbtRx, size_t * pszRxBits, byte_t * pbtRxPar)
|
||||
pn53x_target_receive_bits (nfc_device * pnd, byte_t * pbtRx, size_t * pszRxBits, byte_t * pbtRxPar)
|
||||
{
|
||||
byte_t abtCmd[] = { TgGetInitiatorCommand };
|
||||
|
||||
|
|
@ -1731,7 +1731,7 @@ pn53x_target_receive_bits (nfc_device_t * pnd, byte_t * pbtRx, size_t * pszRxBit
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_target_receive_bytes (nfc_device_t * pnd, byte_t * pbtRx, size_t * pszRx, struct timeval *timeout)
|
||||
pn53x_target_receive_bytes (nfc_device * pnd, byte_t * pbtRx, size_t * pszRx, struct timeval *timeout)
|
||||
{
|
||||
byte_t abtCmd[1];
|
||||
|
||||
|
|
@ -1780,7 +1780,7 @@ pn53x_target_receive_bytes (nfc_device_t * pnd, byte_t * pbtRx, size_t * pszRx,
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_target_send_bits (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTxBits, const byte_t * pbtTxPar)
|
||||
pn53x_target_send_bits (nfc_device * pnd, const byte_t * pbtTx, const size_t szTxBits, const byte_t * pbtTxPar)
|
||||
{
|
||||
size_t szFrameBits = 0;
|
||||
size_t szFrameBytes = 0;
|
||||
|
|
@ -1818,7 +1818,7 @@ pn53x_target_send_bits (nfc_device_t * pnd, const byte_t * pbtTx, const size_t s
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_target_send_bytes (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx, struct timeval *timeout)
|
||||
pn53x_target_send_bytes (nfc_device * pnd, const byte_t * pbtTx, const size_t szTx, struct timeval *timeout)
|
||||
{
|
||||
byte_t abtCmd[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
|
||||
|
||||
|
|
@ -1917,7 +1917,7 @@ static struct sErrorMessage {
|
|||
};
|
||||
|
||||
const char *
|
||||
pn53x_strerror (const nfc_device_t * pnd)
|
||||
pn53x_strerror (const nfc_device * pnd)
|
||||
{
|
||||
const char *pcRes = "Unknown error";
|
||||
size_t i;
|
||||
|
|
@ -1933,14 +1933,14 @@ pn53x_strerror (const nfc_device_t * pnd)
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_RFConfiguration__RF_field (nfc_device_t * pnd, bool bEnable)
|
||||
pn53x_RFConfiguration__RF_field (nfc_device * pnd, bool bEnable)
|
||||
{
|
||||
byte_t abtCmd[] = { RFConfiguration, RFCI_FIELD, (bEnable) ? 0x01 : 0x00 };
|
||||
return pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
bool
|
||||
pn53x_RFConfiguration__Various_timings (nfc_device_t * pnd, const uint8_t fATR_RES_Timeout, const uint8_t fRetryTimeout)
|
||||
pn53x_RFConfiguration__Various_timings (nfc_device * pnd, const uint8_t fATR_RES_Timeout, const uint8_t fRetryTimeout)
|
||||
{
|
||||
byte_t abtCmd[] = {
|
||||
RFConfiguration,
|
||||
|
|
@ -1953,7 +1953,7 @@ pn53x_RFConfiguration__Various_timings (nfc_device_t * pnd, const uint8_t fATR_R
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_RFConfiguration__MaxRtyCOM (nfc_device_t * pnd, const uint8_t MaxRtyCOM)
|
||||
pn53x_RFConfiguration__MaxRtyCOM (nfc_device * pnd, const uint8_t MaxRtyCOM)
|
||||
{
|
||||
byte_t abtCmd[] = {
|
||||
RFConfiguration,
|
||||
|
|
@ -1964,7 +1964,7 @@ pn53x_RFConfiguration__MaxRtyCOM (nfc_device_t * pnd, const uint8_t MaxRtyCOM)
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_RFConfiguration__MaxRetries (nfc_device_t * pnd, const uint8_t MxRtyATR, const uint8_t MxRtyPSL, const uint8_t MxRtyPassiveActivation)
|
||||
pn53x_RFConfiguration__MaxRetries (nfc_device * pnd, const uint8_t MxRtyATR, const uint8_t MxRtyPSL, const uint8_t MxRtyPassiveActivation)
|
||||
{
|
||||
// Retry format: 0x00 means only 1 try, 0xff means infinite
|
||||
byte_t abtCmd[] = {
|
||||
|
|
@ -1978,7 +1978,7 @@ pn53x_RFConfiguration__MaxRetries (nfc_device_t * pnd, const uint8_t MxRtyATR, c
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_SetParameters (nfc_device_t * pnd, const uint8_t ui8Value)
|
||||
pn53x_SetParameters (nfc_device * pnd, const uint8_t ui8Value)
|
||||
{
|
||||
byte_t abtCmd[] = { SetParameters, ui8Value };
|
||||
|
||||
|
|
@ -1991,7 +1991,7 @@ pn53x_SetParameters (nfc_device_t * pnd, const uint8_t ui8Value)
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_SAMConfiguration (nfc_device_t * pnd, const pn532_sam_mode ui8Mode, struct timeval *timeout)
|
||||
pn53x_SAMConfiguration (nfc_device * pnd, const pn532_sam_mode ui8Mode, struct timeval *timeout)
|
||||
{
|
||||
byte_t abtCmd[] = { SAMConfiguration, ui8Mode, 0x00, 0x00 };
|
||||
size_t szCmd = sizeof(abtCmd);
|
||||
|
|
@ -2020,7 +2020,7 @@ pn53x_SAMConfiguration (nfc_device_t * pnd, const pn532_sam_mode ui8Mode, struct
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_PowerDown (nfc_device_t * pnd)
|
||||
pn53x_PowerDown (nfc_device * pnd)
|
||||
{
|
||||
byte_t abtCmd[] = { PowerDown, 0xf0 };
|
||||
return (pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, NULL));
|
||||
|
|
@ -2030,7 +2030,7 @@ pn53x_PowerDown (nfc_device_t * pnd)
|
|||
* @brief C wrapper to InListPassiveTarget command
|
||||
* @return true if command is successfully sent
|
||||
*
|
||||
* @param pnd nfc_device_t struct pointer that represent currently used device
|
||||
* @param pnd nfc_device struct pointer that represent currently used device
|
||||
* @param pmInitModulation Desired modulation
|
||||
* @param pbtInitiatorData Optional initiator data used for Felica, ISO14443B, Topaz Polling or for ISO14443A selecting a specific UID
|
||||
* @param szInitiatorData Length of initiator data \a pbtInitiatorData
|
||||
|
|
@ -2041,8 +2041,8 @@ pn53x_PowerDown (nfc_device_t * pnd)
|
|||
* @note To decode theses TargetData[n], there is @fn pn53x_decode_target_data
|
||||
*/
|
||||
bool
|
||||
pn53x_InListPassiveTarget (nfc_device_t * pnd,
|
||||
const pn53x_modulation_t pmInitModulation, const byte_t szMaxTargets,
|
||||
pn53x_InListPassiveTarget (nfc_device * pnd,
|
||||
const pn53x_modulation pmInitModulation, const byte_t szMaxTargets,
|
||||
const byte_t * pbtInitiatorData, const size_t szInitiatorData,
|
||||
byte_t * pbtTargetsData, size_t * pszTargetsData,
|
||||
struct timeval* timeout)
|
||||
|
|
@ -2094,7 +2094,7 @@ pn53x_InListPassiveTarget (nfc_device_t * pnd,
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_InDeselect (nfc_device_t * pnd, const uint8_t ui8Target)
|
||||
pn53x_InDeselect (nfc_device * pnd, const uint8_t ui8Target)
|
||||
{
|
||||
if (CHIP_DATA(pnd)->type == RCS360) {
|
||||
// We should do act here *only* if a target was previously selected
|
||||
|
|
@ -2116,7 +2116,7 @@ pn53x_InDeselect (nfc_device_t * pnd, const uint8_t ui8Target)
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_InRelease (nfc_device_t * pnd, const uint8_t ui8Target)
|
||||
pn53x_InRelease (nfc_device * pnd, const uint8_t ui8Target)
|
||||
{
|
||||
if (CHIP_DATA(pnd)->type == RCS360) {
|
||||
// We should do act here *only* if a target was previously selected
|
||||
|
|
@ -2138,9 +2138,9 @@ pn53x_InRelease (nfc_device_t * pnd, const uint8_t ui8Target)
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_InAutoPoll (nfc_device_t * pnd,
|
||||
const pn53x_target_type_t * ppttTargetTypes, const size_t szTargetTypes,
|
||||
const byte_t btPollNr, const byte_t btPeriod, nfc_target_t * pntTargets, size_t * pszTargetFound)
|
||||
pn53x_InAutoPoll (nfc_device * pnd,
|
||||
const pn53x_target_type * ppttTargetTypes, const size_t szTargetTypes,
|
||||
const byte_t btPollNr, const byte_t btPeriod, nfc_target * pntTargets, size_t * pszTargetFound)
|
||||
{
|
||||
if (CHIP_DATA(pnd)->type != PN532) {
|
||||
// This function is not supported by pn531 neither pn533
|
||||
|
|
@ -2168,7 +2168,7 @@ pn53x_InAutoPoll (nfc_device_t * pnd,
|
|||
byte_t *pbt = abtRx + 1;
|
||||
/* 1st target */
|
||||
// Target type
|
||||
pn53x_target_type_t ptt = *(pbt++);
|
||||
pn53x_target_type ptt = *(pbt++);
|
||||
pntTargets[0].nm = pn53x_ptt_to_nm(ptt);
|
||||
// AutoPollTargetData length
|
||||
ln = *(pbt++);
|
||||
|
|
@ -2197,16 +2197,16 @@ pn53x_InAutoPoll (nfc_device_t * pnd,
|
|||
* @param pbtNFCID3i NFCID3 of the initiator
|
||||
* @param pbtGBi General Bytes of the initiator
|
||||
* @param szGBi count of General Bytes
|
||||
* @param[out] pnt \a nfc_target_t which will be filled by this function
|
||||
* @param[out] pnt \a nfc_target which will be filled by this function
|
||||
*/
|
||||
bool
|
||||
pn53x_InJumpForDEP (nfc_device_t * pnd,
|
||||
const nfc_dep_mode_t ndm,
|
||||
const nfc_baud_rate_t nbr,
|
||||
pn53x_InJumpForDEP (nfc_device * pnd,
|
||||
const nfc_dep_mode ndm,
|
||||
const nfc_baud_rate nbr,
|
||||
const byte_t * pbtPassiveInitiatorData,
|
||||
const byte_t * pbtNFCID3i,
|
||||
const byte_t * pbtGBi, const size_t szGBi,
|
||||
nfc_target_t * pnt)
|
||||
nfc_target * pnt)
|
||||
{
|
||||
// Max frame size = 1 (Command) + 1 (ActPass) + 1 (Baud rate) + 1 (Next) + 5 (PassiveInitiatorData) + 10 (NFCID3) + 48 (General bytes) = 67 bytes
|
||||
byte_t abtCmd[67] = { InJumpForDEP, (ndm == NDM_ACTIVE) ? 0x01 : 0x00 };
|
||||
|
|
@ -2294,7 +2294,7 @@ pn53x_InJumpForDEP (nfc_device_t * pnd,
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_TgInitAsTarget (nfc_device_t * pnd, pn53x_target_mode_t ptm,
|
||||
pn53x_TgInitAsTarget (nfc_device * pnd, pn53x_target_mode ptm,
|
||||
const byte_t * pbtMifareParams,
|
||||
const byte_t * pbtTkt, size_t szTkt,
|
||||
const byte_t * pbtFeliCaParams,
|
||||
|
|
@ -2365,7 +2365,7 @@ pn53x_TgInitAsTarget (nfc_device_t * pnd, pn53x_target_mode_t ptm,
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_check_ack_frame (nfc_device_t * pnd, const byte_t * pbtRxFrame, const size_t szRxFrameLen)
|
||||
pn53x_check_ack_frame (nfc_device * pnd, const byte_t * pbtRxFrame, const size_t szRxFrameLen)
|
||||
{
|
||||
if (szRxFrameLen >= sizeof (pn53x_ack_frame)) {
|
||||
if (0 == memcmp (pbtRxFrame, pn53x_ack_frame, sizeof (pn53x_ack_frame))) {
|
||||
|
|
@ -2379,7 +2379,7 @@ pn53x_check_ack_frame (nfc_device_t * pnd, const byte_t * pbtRxFrame, const size
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_check_error_frame (nfc_device_t * pnd, const byte_t * pbtRxFrame, const size_t szRxFrameLen)
|
||||
pn53x_check_error_frame (nfc_device * pnd, const byte_t * pbtRxFrame, const size_t szRxFrameLen)
|
||||
{
|
||||
if (szRxFrameLen >= sizeof (pn53x_error_frame)) {
|
||||
if (0 == memcmp (pbtRxFrame, pn53x_error_frame, sizeof (pn53x_error_frame))) {
|
||||
|
|
@ -2453,8 +2453,8 @@ pn53x_build_frame (byte_t * pbtFrame, size_t * pszFrame, const byte_t * pbtData,
|
|||
}
|
||||
return true;
|
||||
}
|
||||
pn53x_modulation_t
|
||||
pn53x_nm_to_pm(const nfc_modulation_t nm)
|
||||
pn53x_modulation
|
||||
pn53x_nm_to_pm(const nfc_modulation nm)
|
||||
{
|
||||
switch(nm.nmt) {
|
||||
case NMT_ISO14443A:
|
||||
|
|
@ -2511,8 +2511,8 @@ pn53x_nm_to_pm(const nfc_modulation_t nm)
|
|||
return PM_UNDEFINED;
|
||||
}
|
||||
|
||||
nfc_modulation_t
|
||||
pn53x_ptt_to_nm( const pn53x_target_type_t ptt )
|
||||
nfc_modulation
|
||||
pn53x_ptt_to_nm( const pn53x_target_type ptt )
|
||||
{
|
||||
switch (ptt) {
|
||||
case PTT_GENERIC_PASSIVE_106:
|
||||
|
|
@ -2524,44 +2524,44 @@ pn53x_ptt_to_nm( const pn53x_target_type_t ptt )
|
|||
|
||||
case PTT_MIFARE:
|
||||
case PTT_ISO14443_4A_106:
|
||||
return (const nfc_modulation_t){ .nmt = NMT_ISO14443A, .nbr = NBR_106 };
|
||||
return (const nfc_modulation){ .nmt = NMT_ISO14443A, .nbr = NBR_106 };
|
||||
break;
|
||||
|
||||
case PTT_ISO14443_4B_106:
|
||||
case PTT_ISO14443_4B_TCL_106:
|
||||
return (const nfc_modulation_t){ .nmt = NMT_ISO14443B, .nbr = NBR_106 };
|
||||
return (const nfc_modulation){ .nmt = NMT_ISO14443B, .nbr = NBR_106 };
|
||||
break;
|
||||
|
||||
case PTT_JEWEL_106:
|
||||
return (const nfc_modulation_t){ .nmt = NMT_JEWEL, .nbr = NBR_106 };
|
||||
return (const nfc_modulation){ .nmt = NMT_JEWEL, .nbr = NBR_106 };
|
||||
break;
|
||||
|
||||
case PTT_FELICA_212:
|
||||
return (const nfc_modulation_t){ .nmt = NMT_FELICA, .nbr = NBR_212 };
|
||||
return (const nfc_modulation){ .nmt = NMT_FELICA, .nbr = NBR_212 };
|
||||
break;
|
||||
case PTT_FELICA_424:
|
||||
return (const nfc_modulation_t){ .nmt = NMT_FELICA, .nbr = NBR_424 };
|
||||
return (const nfc_modulation){ .nmt = NMT_FELICA, .nbr = NBR_424 };
|
||||
break;
|
||||
|
||||
case PTT_DEP_PASSIVE_106:
|
||||
case PTT_DEP_ACTIVE_106:
|
||||
return (const nfc_modulation_t){ .nmt = NMT_DEP, .nbr = NBR_106 };
|
||||
return (const nfc_modulation){ .nmt = NMT_DEP, .nbr = NBR_106 };
|
||||
break;
|
||||
case PTT_DEP_PASSIVE_212:
|
||||
case PTT_DEP_ACTIVE_212:
|
||||
return (const nfc_modulation_t){ .nmt = NMT_DEP, .nbr = NBR_212 };
|
||||
return (const nfc_modulation){ .nmt = NMT_DEP, .nbr = NBR_212 };
|
||||
break;
|
||||
case PTT_DEP_PASSIVE_424:
|
||||
case PTT_DEP_ACTIVE_424:
|
||||
return (const nfc_modulation_t){ .nmt = NMT_DEP, .nbr = NBR_424 };
|
||||
return (const nfc_modulation){ .nmt = NMT_DEP, .nbr = NBR_424 };
|
||||
break;
|
||||
}
|
||||
// We should never be here, this line silent compilation warning
|
||||
return (const nfc_modulation_t){ .nmt = NMT_ISO14443A, .nbr = NBR_106 };
|
||||
return (const nfc_modulation){ .nmt = NMT_ISO14443A, .nbr = NBR_106 };
|
||||
}
|
||||
|
||||
pn53x_target_type_t
|
||||
pn53x_nm_to_ptt(const nfc_modulation_t nm)
|
||||
pn53x_target_type
|
||||
pn53x_nm_to_ptt(const nfc_modulation nm)
|
||||
{
|
||||
switch(nm.nmt) {
|
||||
case NMT_ISO14443A:
|
||||
|
|
@ -2614,7 +2614,7 @@ pn53x_nm_to_ptt(const nfc_modulation_t nm)
|
|||
}
|
||||
|
||||
void
|
||||
pn53x_data_new (nfc_device_t * pnd, const struct pn53x_io* io)
|
||||
pn53x_data_new (nfc_device * pnd, const struct pn53x_io* io)
|
||||
{
|
||||
pnd->chip_data = malloc(sizeof(struct pn53x_data));
|
||||
|
||||
|
|
@ -2640,7 +2640,7 @@ pn53x_data_new (nfc_device_t * pnd, const struct pn53x_io* io)
|
|||
}
|
||||
|
||||
void
|
||||
pn53x_data_free (nfc_device_t * pnd)
|
||||
pn53x_data_free (nfc_device * pnd)
|
||||
{
|
||||
if (CHIP_DATA (pnd)->current_target) {
|
||||
free (CHIP_DATA (pnd)->current_target);
|
||||
|
|
|
|||
|
|
@ -127,8 +127,8 @@ typedef enum {
|
|||
} pn53x_operating_mode;
|
||||
|
||||
struct pn53x_io {
|
||||
bool (*send)(nfc_device_t * pnd, const byte_t * pbtData, const size_t szData, struct timeval *timeout);
|
||||
int (*receive)(nfc_device_t * pnd, byte_t * pbtData, const size_t szDataLen, struct timeval *timeout);
|
||||
bool (*send)(nfc_device * pnd, const byte_t * pbtData, const size_t szData, struct timeval *timeout);
|
||||
int (*receive)(nfc_device * pnd, byte_t * pbtData, const size_t szDataLen, struct timeval *timeout);
|
||||
};
|
||||
|
||||
/* defines */
|
||||
|
|
@ -143,7 +143,7 @@ struct pn53x_data {
|
|||
/** Current operating mode */
|
||||
pn53x_operating_mode operating_mode;
|
||||
/** Current emulated target */
|
||||
nfc_target_t* current_target;
|
||||
nfc_target* current_target;
|
||||
/** PN53x I/O functions stored in struct */
|
||||
const struct pn53x_io * io;
|
||||
/** Register cache for REG_CIU_BIT_FRAMING, SYMBOL_TX_LAST_BITS: The last TX bits setting, we need to reset this if it does not apply anymore */
|
||||
|
|
@ -165,7 +165,7 @@ struct pn53x_data {
|
|||
#define CHIP_DATA(pnd) ((struct pn53x_data*)(pnd->chip_data))
|
||||
|
||||
/**
|
||||
* @enum pn53x_modulation_t
|
||||
* @enum pn53x_modulation
|
||||
* @brief NFC modulation
|
||||
*/
|
||||
typedef enum {
|
||||
|
|
@ -187,10 +187,10 @@ typedef enum {
|
|||
PM_ISO14443B_424 = 0x07,
|
||||
/** ISO14443-B http://en.wikipedia.org/wiki/ISO/IEC_14443 (Not supported by PN531 nor PN532) */
|
||||
PM_ISO14443B_847 = 0x08,
|
||||
} pn53x_modulation_t;
|
||||
} pn53x_modulation;
|
||||
|
||||
/**
|
||||
* @enum pn53x_target_type_t
|
||||
* @enum pn53x_target_type
|
||||
* @brief NFC target type enumeration
|
||||
*/
|
||||
typedef enum {
|
||||
|
|
@ -228,7 +228,7 @@ typedef enum {
|
|||
PTT_DEP_ACTIVE_212 = 0x81,
|
||||
/** DEP active 424 kbps */
|
||||
PTT_DEP_ACTIVE_424 = 0x82,
|
||||
} pn53x_target_type_t;
|
||||
} pn53x_target_type;
|
||||
|
||||
typedef enum {
|
||||
PSM_NORMAL = 0x01,
|
||||
|
|
@ -238,7 +238,7 @@ typedef enum {
|
|||
} pn532_sam_mode;
|
||||
|
||||
/**
|
||||
* @enum pn53x_target_mode_t
|
||||
* @enum pn53x_target_mode
|
||||
* @brief PN53x target mode enumeration
|
||||
*/
|
||||
typedef enum {
|
||||
|
|
@ -250,86 +250,86 @@ typedef enum {
|
|||
PTM_DEP_ONLY = 0x02,
|
||||
/** Configure the PN532 to accept to be initialized only as ISO/IEC14443-4 PICC */
|
||||
PTM_ISO14443_4_PICC_ONLY = 0x04
|
||||
} pn53x_target_mode_t;
|
||||
} pn53x_target_mode;
|
||||
|
||||
extern const byte_t pn53x_ack_frame[6];
|
||||
extern const byte_t pn53x_nack_frame[6];
|
||||
|
||||
bool pn53x_init(nfc_device_t * pnd);
|
||||
bool pn53x_transceive (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx, size_t *pszRx, struct timeval *timeout);
|
||||
bool pn53x_init(nfc_device * pnd);
|
||||
bool pn53x_transceive (nfc_device * pnd, const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx, size_t *pszRx, struct timeval *timeout);
|
||||
|
||||
bool pn53x_set_parameters (nfc_device_t * pnd, const uint8_t ui8Value, const bool bEnable);
|
||||
bool pn53x_set_tx_bits (nfc_device_t * pnd, const uint8_t ui8Bits);
|
||||
bool pn53x_set_parameters (nfc_device * pnd, const uint8_t ui8Value, const bool bEnable);
|
||||
bool pn53x_set_tx_bits (nfc_device * pnd, const uint8_t ui8Bits);
|
||||
bool pn53x_wrap_frame (const byte_t * pbtTx, const size_t szTxBits, const byte_t * pbtTxPar, byte_t * pbtFrame,
|
||||
size_t * pszFrameBits);
|
||||
bool pn53x_unwrap_frame (const byte_t * pbtFrame, const size_t szFrameBits, byte_t * pbtRx, size_t * pszRxBits,
|
||||
byte_t * pbtRxPar);
|
||||
bool pn53x_decode_target_data (const byte_t * pbtRawData, size_t szRawData,
|
||||
pn53x_type chip_type, nfc_modulation_type_t nmt,
|
||||
nfc_target_info_t * pnti);
|
||||
bool pn53x_read_register (nfc_device_t * pnd, uint16_t ui16Reg, uint8_t * ui8Value);
|
||||
bool pn53x_write_register (nfc_device_t * pnd, uint16_t ui16Reg, uint8_t ui8SymbolMask, uint8_t ui8Value);
|
||||
bool pn53x_get_firmware_version (nfc_device_t * pnd, char abtFirmwareText[22]);
|
||||
bool pn53x_configure (nfc_device_t * pnd, const nfc_device_option_t ndo, const bool bEnable);
|
||||
bool pn53x_check_communication (nfc_device_t *pnd);
|
||||
bool pn53x_idle (nfc_device_t * pnd);
|
||||
pn53x_type chip_type, nfc_modulationype nmt,
|
||||
nfc_target_info * pnti);
|
||||
bool pn53x_read_register (nfc_device * pnd, uint16_t ui16Reg, uint8_t * ui8Value);
|
||||
bool pn53x_write_register (nfc_device * pnd, uint16_t ui16Reg, uint8_t ui8SymbolMask, uint8_t ui8Value);
|
||||
bool pn53x_get_firmware_version (nfc_device * pnd, char abtFirmwareText[22]);
|
||||
bool pn53x_configure (nfc_device * pnd, const nfc_device_option ndo, const bool bEnable);
|
||||
bool pn53x_check_communication (nfc_device *pnd);
|
||||
bool pn53x_idle (nfc_device * pnd);
|
||||
|
||||
// NFC device as Initiator functions
|
||||
bool pn53x_initiator_init (nfc_device_t * pnd);
|
||||
bool pn53x_initiator_select_passive_target (nfc_device_t * pnd,
|
||||
const nfc_modulation_t nm,
|
||||
bool pn53x_initiator_init (nfc_device * pnd);
|
||||
bool pn53x_initiator_select_passive_target (nfc_device * pnd,
|
||||
const nfc_modulation nm,
|
||||
const byte_t * pbtInitData, const size_t szInitData,
|
||||
nfc_target_t * pnt);
|
||||
bool pn53x_initiator_poll_target (nfc_device_t * pnd,
|
||||
const nfc_modulation_t * pnmModulations, const size_t szModulations,
|
||||
nfc_target * pnt);
|
||||
bool pn53x_initiator_poll_target (nfc_device * pnd,
|
||||
const nfc_modulation * pnmModulations, const size_t szModulations,
|
||||
const uint8_t uiPollNr, const uint8_t uiPeriod,
|
||||
nfc_target_t * pnt);
|
||||
bool pn53x_initiator_select_dep_target (nfc_device_t * pnd,
|
||||
const nfc_dep_mode_t ndm, const nfc_baud_rate_t nbr,
|
||||
const nfc_dep_info_t * pndiInitiator,
|
||||
nfc_target_t * pnt);
|
||||
bool pn53x_initiator_transceive_bits (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTxBits,
|
||||
nfc_target * pnt);
|
||||
bool pn53x_initiator_select_dep_target (nfc_device * pnd,
|
||||
const nfc_dep_mode ndm, const nfc_baud_rate nbr,
|
||||
const nfc_dep_info * pndiInitiator,
|
||||
nfc_target * pnt);
|
||||
bool pn53x_initiator_transceive_bits (nfc_device * pnd, const byte_t * pbtTx, const size_t szTxBits,
|
||||
const byte_t * pbtTxPar, byte_t * pbtRx, size_t * pszRxBits,
|
||||
byte_t * pbtRxPar);
|
||||
bool pn53x_initiator_transceive_bytes (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx,
|
||||
bool pn53x_initiator_transceive_bytes (nfc_device * pnd, const byte_t * pbtTx, const size_t szTx,
|
||||
byte_t * pbtRx, size_t * pszRx, struct timeval *timeout);
|
||||
bool pn53x_initiator_transceive_bits_timed (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTxBits,
|
||||
bool pn53x_initiator_transceive_bits_timed (nfc_device * pnd, const byte_t * pbtTx, const size_t szTxBits,
|
||||
const byte_t * pbtTxPar, byte_t * pbtRx, size_t * pszRxBits,
|
||||
byte_t * pbtRxPar, uint32_t * cycles);
|
||||
bool pn53x_initiator_transceive_bytes_timed (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx,
|
||||
bool pn53x_initiator_transceive_bytes_timed (nfc_device * pnd, const byte_t * pbtTx, const size_t szTx,
|
||||
byte_t * pbtRx, size_t * pszRx, uint32_t * cycles);
|
||||
bool pn53x_initiator_deselect_target (nfc_device_t * pnd);
|
||||
bool pn53x_initiator_deselect_target (nfc_device * pnd);
|
||||
|
||||
// NFC device as Target functions
|
||||
bool pn53x_target_init (nfc_device_t * pnd, nfc_target_t * pnt, byte_t * pbtRx, size_t * pszRx);
|
||||
bool pn53x_target_receive_bits (nfc_device_t * pnd, byte_t * pbtRx, size_t * pszRxBits, byte_t * pbtRxPar);
|
||||
bool pn53x_target_receive_bytes (nfc_device_t * pnd, byte_t * pbtRx, size_t * pszRx, struct timeval *timeout);
|
||||
bool pn53x_target_send_bits (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTxBits, const byte_t * pbtTxPar);
|
||||
bool pn53x_target_send_bytes (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx, struct timeval *timeout);
|
||||
bool pn53x_target_init (nfc_device * pnd, nfc_target * pnt, byte_t * pbtRx, size_t * pszRx);
|
||||
bool pn53x_target_receive_bits (nfc_device * pnd, byte_t * pbtRx, size_t * pszRxBits, byte_t * pbtRxPar);
|
||||
bool pn53x_target_receive_bytes (nfc_device * pnd, byte_t * pbtRx, size_t * pszRx, struct timeval *timeout);
|
||||
bool pn53x_target_send_bits (nfc_device * pnd, const byte_t * pbtTx, const size_t szTxBits, const byte_t * pbtTxPar);
|
||||
bool pn53x_target_send_bytes (nfc_device * pnd, const byte_t * pbtTx, const size_t szTx, struct timeval *timeout);
|
||||
|
||||
// Error handling functions
|
||||
const char *pn53x_strerror (const nfc_device_t * pnd);
|
||||
const char *pn53x_strerror (const nfc_device * pnd);
|
||||
|
||||
// C wrappers for PN53x commands
|
||||
bool pn53x_SetParameters (nfc_device_t * pnd, const uint8_t ui8Value);
|
||||
bool pn53x_SAMConfiguration (nfc_device_t * pnd, const pn532_sam_mode mode, struct timeval *timeout);
|
||||
bool pn53x_PowerDown (nfc_device_t * pnd);
|
||||
bool pn53x_InListPassiveTarget (nfc_device_t * pnd, const pn53x_modulation_t pmInitModulation,
|
||||
bool pn53x_SetParameters (nfc_device * pnd, const uint8_t ui8Value);
|
||||
bool pn53x_SAMConfiguration (nfc_device * pnd, const pn532_sam_mode mode, struct timeval *timeout);
|
||||
bool pn53x_PowerDown (nfc_device * pnd);
|
||||
bool pn53x_InListPassiveTarget (nfc_device * pnd, const pn53x_modulation pmInitModulation,
|
||||
const byte_t szMaxTargets, const byte_t * pbtInitiatorData,
|
||||
const size_t szInitiatorDataLen, byte_t * pbtTargetsData, size_t * pszTargetsData,
|
||||
struct timeval *timeout);
|
||||
bool pn53x_InDeselect (nfc_device_t * pnd, const uint8_t ui8Target);
|
||||
bool pn53x_InRelease (nfc_device_t * pnd, const uint8_t ui8Target);
|
||||
bool pn53x_InAutoPoll (nfc_device_t * pnd, const pn53x_target_type_t * ppttTargetTypes, const size_t szTargetTypes,
|
||||
const byte_t btPollNr, const byte_t btPeriod, nfc_target_t * pntTargets,
|
||||
bool pn53x_InDeselect (nfc_device * pnd, const uint8_t ui8Target);
|
||||
bool pn53x_InRelease (nfc_device * pnd, const uint8_t ui8Target);
|
||||
bool pn53x_InAutoPoll (nfc_device * pnd, const pn53x_target_type * ppttTargetTypes, const size_t szTargetTypes,
|
||||
const byte_t btPollNr, const byte_t btPeriod, nfc_target * pntTargets,
|
||||
size_t * pszTargetFound);
|
||||
bool pn53x_InJumpForDEP (nfc_device_t * pnd,
|
||||
const nfc_dep_mode_t ndm, const nfc_baud_rate_t nbr,
|
||||
bool pn53x_InJumpForDEP (nfc_device * pnd,
|
||||
const nfc_dep_mode ndm, const nfc_baud_rate nbr,
|
||||
const byte_t * pbtPassiveInitiatorData,
|
||||
const byte_t * pbtNFCID3i,
|
||||
const byte_t * pbtGB, const size_t szGB,
|
||||
nfc_target_t * pnt);
|
||||
bool pn53x_TgInitAsTarget (nfc_device_t * pnd, pn53x_target_mode_t ptm,
|
||||
nfc_target * pnt);
|
||||
bool pn53x_TgInitAsTarget (nfc_device * pnd, pn53x_target_mode ptm,
|
||||
const byte_t * pbtMifareParams,
|
||||
const byte_t * pbtTkt, size_t szTkt,
|
||||
const byte_t * pbtFeliCaParams,
|
||||
|
|
@ -337,17 +337,17 @@ bool pn53x_TgInitAsTarget (nfc_device_t * pnd, pn53x_target_mode_t ptm,
|
|||
byte_t * pbtRx, size_t * pszRx, byte_t * pbtModeByte);
|
||||
|
||||
// RFConfiguration
|
||||
bool pn53x_RFConfiguration__RF_field (nfc_device_t * pnd, bool bEnable);
|
||||
bool pn53x_RFConfiguration__Various_timings (nfc_device_t * pnd, const uint8_t fATR_RES_Timeout, const uint8_t fRetryTimeout);
|
||||
bool pn53x_RFConfiguration__MaxRtyCOM (nfc_device_t * pnd, const uint8_t MaxRtyCOM);
|
||||
bool pn53x_RFConfiguration__MaxRetries (nfc_device_t * pnd, const uint8_t MxRtyATR, const uint8_t MxRtyPSL, const uint8_t MxRtyPassiveActivation);
|
||||
bool pn53x_RFConfiguration__RF_field (nfc_device * pnd, bool bEnable);
|
||||
bool pn53x_RFConfiguration__Various_timings (nfc_device * pnd, const uint8_t fATR_RES_Timeout, const uint8_t fRetryTimeout);
|
||||
bool pn53x_RFConfiguration__MaxRtyCOM (nfc_device * pnd, const uint8_t MaxRtyCOM);
|
||||
bool pn53x_RFConfiguration__MaxRetries (nfc_device * pnd, const uint8_t MxRtyATR, const uint8_t MxRtyPSL, const uint8_t MxRtyPassiveActivation);
|
||||
|
||||
// Misc
|
||||
bool pn53x_check_ack_frame (nfc_device_t * pnd, const byte_t * pbtRxFrame, const size_t szRxFrameLen);
|
||||
bool pn53x_check_error_frame (nfc_device_t * pnd, const byte_t * pbtRxFrame, const size_t szRxFrameLen);
|
||||
bool pn53x_check_ack_frame (nfc_device * pnd, const byte_t * pbtRxFrame, const size_t szRxFrameLen);
|
||||
bool pn53x_check_error_frame (nfc_device * pnd, const byte_t * pbtRxFrame, const size_t szRxFrameLen);
|
||||
bool pn53x_build_frame (byte_t * pbtFrame, size_t * pszFrame, const byte_t * pbtData, const size_t szData);
|
||||
|
||||
void pn53x_data_new (nfc_device_t * pnd, const struct pn53x_io* io);
|
||||
void pn53x_data_free (nfc_device_t * pnd);
|
||||
void pn53x_data_new (nfc_device * pnd, const struct pn53x_io* io);
|
||||
void pn53x_data_free (nfc_device * pnd);
|
||||
|
||||
#endif // __NFC_CHIPS_PN53X_H__
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@
|
|||
|
||||
const struct pn53x_io acr122_io;
|
||||
|
||||
char *acr122_firmware (nfc_device_t *pnd);
|
||||
char *acr122_firmware (nfc_device *pnd);
|
||||
|
||||
const char *supported_devices[] = {
|
||||
"ACS ACR122", // ACR122U & Touchatag, last version
|
||||
|
|
@ -239,7 +239,7 @@ acr122_connstring_decode (const nfc_connstring connstring, struct acr122_descrip
|
|||
return 3;
|
||||
}
|
||||
|
||||
nfc_device_t *
|
||||
nfc_device *
|
||||
acr122_connect (const nfc_connstring connstring)
|
||||
{
|
||||
struct acr122_descriptor ndd;
|
||||
|
|
@ -251,7 +251,7 @@ acr122_connect (const nfc_connstring connstring)
|
|||
// FIXME: acr122_connect() does not take care about bus index
|
||||
|
||||
char *pcFirmware;
|
||||
nfc_device_t *pnd = nfc_device_new ();
|
||||
nfc_device *pnd = nfc_device_new ();
|
||||
pnd->driver_data = malloc (sizeof (struct acr122_data));
|
||||
|
||||
// Alloc and init chip's data
|
||||
|
|
@ -300,7 +300,7 @@ error:
|
|||
}
|
||||
|
||||
void
|
||||
acr122_disconnect (nfc_device_t * pnd)
|
||||
acr122_disconnect (nfc_device * pnd)
|
||||
{
|
||||
SCardDisconnect (DRIVER_DATA (pnd)->hCard, SCARD_LEAVE_CARD);
|
||||
acr122_free_scardcontext ();
|
||||
|
|
@ -310,7 +310,7 @@ acr122_disconnect (nfc_device_t * pnd)
|
|||
}
|
||||
|
||||
bool
|
||||
acr122_send (nfc_device_t * pnd, const byte_t * pbtData, const size_t szData, struct timeval *timeout)
|
||||
acr122_send (nfc_device * pnd, const byte_t * pbtData, const size_t szData, struct timeval *timeout)
|
||||
{
|
||||
// FIXME: timeout is not handled
|
||||
(void) timeout;
|
||||
|
|
@ -381,7 +381,7 @@ acr122_send (nfc_device_t * pnd, const byte_t * pbtData, const size_t szData, st
|
|||
}
|
||||
|
||||
int
|
||||
acr122_receive (nfc_device_t * pnd, byte_t * pbtData, const size_t szData, struct timeval *timeout)
|
||||
acr122_receive (nfc_device * pnd, byte_t * pbtData, const size_t szData, struct timeval *timeout)
|
||||
{
|
||||
// FIXME: timeout is not handled
|
||||
(void) timeout;
|
||||
|
|
@ -422,7 +422,7 @@ acr122_receive (nfc_device_t * pnd, byte_t * pbtData, const size_t szData, struc
|
|||
}
|
||||
|
||||
char *
|
||||
acr122_firmware (nfc_device_t *pnd)
|
||||
acr122_firmware (nfc_device *pnd)
|
||||
{
|
||||
byte_t abtGetFw[5] = { 0xFF, 0x00, 0x48, 0x00, 0x00 };
|
||||
uint32_t uiResult;
|
||||
|
|
@ -445,7 +445,7 @@ acr122_firmware (nfc_device_t *pnd)
|
|||
|
||||
#if 0
|
||||
bool
|
||||
acr122_led_red (nfc_device_t *pnd, bool bOn)
|
||||
acr122_led_red (nfc_device *pnd, bool bOn)
|
||||
{
|
||||
byte_t abtLed[9] = { 0xFF, 0x00, 0x40, 0x05, 0x04, 0x00, 0x00, 0x00, 0x00 };
|
||||
byte_t abtBuf[2];
|
||||
|
|
|
|||
|
|
@ -29,10 +29,10 @@
|
|||
bool acr122_probe (nfc_connstring connstrings[], size_t connstrings_len, size_t * pszDeviceFound);
|
||||
|
||||
// Functions used by developer to handle connection to this device
|
||||
nfc_device_t *acr122_connect (const nfc_connstring connstring);
|
||||
bool acr122_send (nfc_device_t * pnd, const byte_t * pbtData, const size_t szData, struct timeval *timeout);
|
||||
int acr122_receive (nfc_device_t * pnd, byte_t * pbtData, const size_t szData, struct timeval *timeout);
|
||||
void acr122_disconnect (nfc_device_t * pnd);
|
||||
nfc_device *acr122_connect (const nfc_connstring connstring);
|
||||
bool acr122_send (nfc_device * pnd, const byte_t * pbtData, const size_t szData, struct timeval *timeout);
|
||||
int acr122_receive (nfc_device * pnd, byte_t * pbtData, const size_t szData, struct timeval *timeout);
|
||||
void acr122_disconnect (nfc_device * pnd);
|
||||
|
||||
extern const struct nfc_driver_t acr122_driver;
|
||||
|
||||
|
|
|
|||
|
|
@ -88,8 +88,8 @@ static const byte_t arygon_error_none[] = "FF000000\x0d\x0a";
|
|||
static const byte_t arygon_error_incomplete_command[] = "FF0C0000\x0d\x0a";
|
||||
static const byte_t arygon_error_unknown_mode[] = "FF060000\x0d\x0a";
|
||||
|
||||
bool arygon_reset_tama (nfc_device_t * pnd);
|
||||
void arygon_firmware (nfc_device_t * pnd, char * str);
|
||||
bool arygon_reset_tama (nfc_device * pnd);
|
||||
void arygon_firmware (nfc_device * pnd, char * str);
|
||||
|
||||
bool
|
||||
arygon_probe (nfc_connstring connstrings[], size_t connstrings_len, size_t * pszDeviceFound)
|
||||
|
|
@ -120,7 +120,7 @@ arygon_probe (nfc_connstring connstrings[], size_t connstrings_len, size_t * psz
|
|||
uart_flush_input (sp);
|
||||
uart_set_speed (sp, ARYGON_DEFAULT_SPEED);
|
||||
|
||||
nfc_device_t *pnd = nfc_device_new ();
|
||||
nfc_device *pnd = nfc_device_new ();
|
||||
pnd->driver = &arygon_driver;
|
||||
pnd->driver_data = malloc(sizeof(struct arygon_data));
|
||||
DRIVER_DATA (pnd)->port = sp;
|
||||
|
|
@ -215,7 +215,7 @@ arygon_connstring_decode (const nfc_connstring connstring, struct arygon_descrip
|
|||
return 3;
|
||||
}
|
||||
|
||||
nfc_device_t *
|
||||
nfc_device *
|
||||
arygon_connect (const nfc_connstring connstring)
|
||||
{
|
||||
struct arygon_descriptor ndd;
|
||||
|
|
@ -228,7 +228,7 @@ arygon_connect (const nfc_connstring connstring)
|
|||
ndd.speed = ARYGON_DEFAULT_SPEED;
|
||||
}
|
||||
serial_port sp;
|
||||
nfc_device_t *pnd = NULL;
|
||||
nfc_device *pnd = NULL;
|
||||
|
||||
log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "Attempt to connect to: %s at %d bauds.", ndd.port, ndd.speed);
|
||||
sp = uart_open (ndd.port);
|
||||
|
|
@ -286,7 +286,7 @@ arygon_connect (const nfc_connstring connstring)
|
|||
}
|
||||
|
||||
void
|
||||
arygon_disconnect (nfc_device_t * pnd)
|
||||
arygon_disconnect (nfc_device * pnd)
|
||||
{
|
||||
// Release UART port
|
||||
uart_close (DRIVER_DATA (pnd)->port);
|
||||
|
|
@ -304,7 +304,7 @@ arygon_disconnect (nfc_device_t * pnd)
|
|||
#define ARYGON_TX_BUFFER_LEN (PN53x_NORMAL_FRAME__DATA_MAX_LEN + PN53x_NORMAL_FRAME__OVERHEAD + 1)
|
||||
#define ARYGON_RX_BUFFER_LEN (PN53x_EXTENDED_FRAME__DATA_MAX_LEN + PN53x_EXTENDED_FRAME__OVERHEAD)
|
||||
bool
|
||||
arygon_tama_send (nfc_device_t * pnd, const byte_t * pbtData, const size_t szData, struct timeval *timeout)
|
||||
arygon_tama_send (nfc_device * pnd, const byte_t * pbtData, const size_t szData, struct timeval *timeout)
|
||||
{
|
||||
// Before sending anything, we need to discard from any junk bytes
|
||||
uart_flush_input (DRIVER_DATA(pnd)->port);
|
||||
|
|
@ -354,7 +354,7 @@ arygon_tama_send (nfc_device_t * pnd, const byte_t * pbtData, const size_t szDat
|
|||
}
|
||||
|
||||
int
|
||||
arygon_abort (nfc_device_t *pnd)
|
||||
arygon_abort (nfc_device *pnd)
|
||||
{
|
||||
// Send a valid TAMA packet to wakup the PN53x (we will not have an answer, according to Arygon manual)
|
||||
byte_t dummy[] = { 0x32, 0x00, 0x00, 0xff, 0x09, 0xf7, 0xd4, 0x00, 0x00, 0x6c, 0x69, 0x62, 0x6e, 0x66, 0x63, 0xbe, 0x00 };
|
||||
|
|
@ -366,7 +366,7 @@ arygon_abort (nfc_device_t *pnd)
|
|||
}
|
||||
|
||||
int
|
||||
arygon_tama_receive (nfc_device_t * pnd, byte_t * pbtData, const size_t szDataLen, struct timeval *timeout)
|
||||
arygon_tama_receive (nfc_device * pnd, byte_t * pbtData, const size_t szDataLen, struct timeval *timeout)
|
||||
{
|
||||
byte_t abtRxBuf[5];
|
||||
size_t len;
|
||||
|
|
@ -484,7 +484,7 @@ arygon_tama_receive (nfc_device_t * pnd, byte_t * pbtData, const size_t szDataLe
|
|||
}
|
||||
|
||||
void
|
||||
arygon_firmware (nfc_device_t * pnd, char * str)
|
||||
arygon_firmware (nfc_device * pnd, char * str)
|
||||
{
|
||||
const byte_t arygon_firmware_version_cmd[] = { DEV_ARYGON_PROTOCOL_ARYGON_ASCII, 'a', 'v' };
|
||||
byte_t abtRx[16];
|
||||
|
|
@ -512,7 +512,7 @@ arygon_firmware (nfc_device_t * pnd, char * str)
|
|||
}
|
||||
|
||||
bool
|
||||
arygon_reset_tama (nfc_device_t * pnd)
|
||||
arygon_reset_tama (nfc_device * pnd)
|
||||
{
|
||||
const byte_t arygon_reset_tama_cmd[] = { DEV_ARYGON_PROTOCOL_ARYGON_ASCII, 'a', 'r' };
|
||||
byte_t abtRx[10]; // Attempted response is 10 bytes long
|
||||
|
|
@ -541,7 +541,7 @@ arygon_reset_tama (nfc_device_t * pnd)
|
|||
}
|
||||
|
||||
bool
|
||||
arygon_abort_command (nfc_device_t * pnd)
|
||||
arygon_abort_command (nfc_device * pnd)
|
||||
{
|
||||
if (pnd) {
|
||||
#ifndef WIN32
|
||||
|
|
|
|||
|
|
@ -32,11 +32,11 @@
|
|||
|
||||
bool arygon_probe (nfc_connstring connstrings[], size_t connstrings_len, size_t * pszDeviceFound);
|
||||
|
||||
nfc_device_t *arygon_connect (const nfc_connstring connstring);
|
||||
void arygon_disconnect (nfc_device_t * pnd);
|
||||
nfc_device *arygon_connect (const nfc_connstring connstring);
|
||||
void arygon_disconnect (nfc_device * pnd);
|
||||
|
||||
bool arygon_tama_send (nfc_device_t * pnd, const byte_t * pbtData, const size_t szData, struct timeval *timeout);
|
||||
int arygon_tama_receive (nfc_device_t * pnd, byte_t * pbtData, const size_t szDat, struct timeval *timeouta);
|
||||
bool arygon_tama_send (nfc_device * pnd, const byte_t * pbtData, const size_t szData, struct timeval *timeout);
|
||||
int arygon_tama_receive (nfc_device * pnd, byte_t * pbtData, const size_t szDat, struct timeval *timeouta);
|
||||
|
||||
extern const struct nfc_driver_t arygon_driver;
|
||||
|
||||
|
|
|
|||
|
|
@ -48,8 +48,8 @@
|
|||
#define PN532_UART_DRIVER_NAME "pn532_uart"
|
||||
#define LOG_CATEGORY "libnfc.driver.pn532_uart"
|
||||
|
||||
int pn532_uart_ack (nfc_device_t * pnd);
|
||||
int pn532_uart_wakeup (nfc_device_t * pnd);
|
||||
int pn532_uart_ack (nfc_device * pnd);
|
||||
int pn532_uart_wakeup (nfc_device * pnd);
|
||||
|
||||
const struct pn53x_io pn532_uart_io;
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ pn532_uart_probe (nfc_connstring connstrings[], size_t connstrings_len, size_t *
|
|||
// Serial port claimed but we need to check if a PN532_UART is connected.
|
||||
uart_set_speed (sp, PN532_UART_DEFAULT_SPEED);
|
||||
|
||||
nfc_device_t *pnd = nfc_device_new ();
|
||||
nfc_device *pnd = nfc_device_new ();
|
||||
pnd->driver = &pn532_uart_driver;
|
||||
pnd->driver_data = malloc(sizeof(struct pn532_uart_data));
|
||||
DRIVER_DATA (pnd)->port = sp;
|
||||
|
|
@ -196,7 +196,7 @@ pn532_connstring_decode (const nfc_connstring connstring, struct pn532_uart_desc
|
|||
return 3;
|
||||
}
|
||||
|
||||
nfc_device_t *
|
||||
nfc_device *
|
||||
pn532_uart_connect (const nfc_connstring connstring)
|
||||
{
|
||||
struct pn532_uart_descriptor ndd;
|
||||
|
|
@ -209,7 +209,7 @@ pn532_uart_connect (const nfc_connstring connstring)
|
|||
ndd.speed = PN532_UART_DEFAULT_SPEED;
|
||||
}
|
||||
serial_port sp;
|
||||
nfc_device_t *pnd = NULL;
|
||||
nfc_device *pnd = NULL;
|
||||
|
||||
log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "Attempt to connect to: %s at %d bauds.", ndd.port, ndd.speed);
|
||||
sp = uart_open (ndd.port);
|
||||
|
|
@ -262,7 +262,7 @@ pn532_uart_connect (const nfc_connstring connstring)
|
|||
}
|
||||
|
||||
void
|
||||
pn532_uart_disconnect (nfc_device_t * pnd)
|
||||
pn532_uart_disconnect (nfc_device * pnd)
|
||||
{
|
||||
// Release UART port
|
||||
uart_close (DRIVER_DATA(pnd)->port);
|
||||
|
|
@ -278,7 +278,7 @@ pn532_uart_disconnect (nfc_device_t * pnd)
|
|||
}
|
||||
|
||||
int
|
||||
pn532_uart_wakeup (nfc_device_t * pnd)
|
||||
pn532_uart_wakeup (nfc_device * pnd)
|
||||
{
|
||||
/* High Speed Unit (HSU) wake up consist to send 0x55 and wait a "long" delay for PN532 being wakeup. */
|
||||
const byte_t pn532_wakeup_preamble[] = { 0x55, 0x55, 0x00, 0x00, 0x00 };
|
||||
|
|
@ -289,7 +289,7 @@ pn532_uart_wakeup (nfc_device_t * pnd)
|
|||
|
||||
#define PN532_BUFFER_LEN (PN53x_EXTENDED_FRAME__DATA_MAX_LEN + PN53x_EXTENDED_FRAME__OVERHEAD)
|
||||
bool
|
||||
pn532_uart_send (nfc_device_t * pnd, const byte_t * pbtData, const size_t szData, struct timeval *timeout)
|
||||
pn532_uart_send (nfc_device * pnd, const byte_t * pbtData, const size_t szData, struct timeval *timeout)
|
||||
{
|
||||
// Before sending anything, we need to discard from any junk bytes
|
||||
uart_flush_input (DRIVER_DATA(pnd)->port);
|
||||
|
|
@ -352,7 +352,7 @@ pn532_uart_send (nfc_device_t * pnd, const byte_t * pbtData, const size_t szData
|
|||
}
|
||||
|
||||
int
|
||||
pn532_uart_receive (nfc_device_t * pnd, byte_t * pbtData, const size_t szDataLen, struct timeval *timeout)
|
||||
pn532_uart_receive (nfc_device * pnd, byte_t * pbtData, const size_t szDataLen, struct timeval *timeout)
|
||||
{
|
||||
byte_t abtRxBuf[5];
|
||||
size_t len;
|
||||
|
|
@ -476,7 +476,7 @@ pn532_uart_receive (nfc_device_t * pnd, byte_t * pbtData, const size_t szDataLen
|
|||
}
|
||||
|
||||
int
|
||||
pn532_uart_ack (nfc_device_t * pnd)
|
||||
pn532_uart_ack (nfc_device * pnd)
|
||||
{
|
||||
if (POWERDOWN == CHIP_DATA(pnd)->power_mode) {
|
||||
if (-1 == pn532_uart_wakeup(pnd)) {
|
||||
|
|
@ -487,7 +487,7 @@ pn532_uart_ack (nfc_device_t * pnd)
|
|||
}
|
||||
|
||||
bool
|
||||
pn532_uart_abort_command (nfc_device_t * pnd)
|
||||
pn532_uart_abort_command (nfc_device * pnd)
|
||||
{
|
||||
if (pnd) {
|
||||
#ifndef WIN32
|
||||
|
|
|
|||
|
|
@ -31,10 +31,10 @@
|
|||
|
||||
bool pn532_uart_probe (nfc_connstring connstrings[], size_t connstrings_len, size_t * pszDeviceFound);
|
||||
|
||||
nfc_device_t *pn532_uart_connect (const nfc_connstring connstring);
|
||||
void pn532_uart_disconnect (nfc_device_t * pnd);
|
||||
bool pn532_uart_send (nfc_device_t * pnd, const byte_t * pbtData, const size_t szData, struct timeval *timeout);
|
||||
int pn532_uart_receive (nfc_device_t * pnd, byte_t * pbtData, const size_t szData, struct timeval *timeout);
|
||||
nfc_device *pn532_uart_connect (const nfc_connstring connstring);
|
||||
void pn532_uart_disconnect (nfc_device * pnd);
|
||||
bool pn532_uart_send (nfc_device * pnd, const byte_t * pbtData, const size_t szData, struct timeval *timeout);
|
||||
int pn532_uart_receive (nfc_device * pnd, byte_t * pbtData, const size_t szData, struct timeval *timeout);
|
||||
|
||||
extern const struct nfc_driver_t pn532_uart_driver;
|
||||
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ struct pn53x_usb_data {
|
|||
|
||||
const struct pn53x_io pn53x_usb_io;
|
||||
bool pn53x_usb_get_usb_device_name (struct usb_device *dev, usb_dev_handle *udev, char *buffer, size_t len);
|
||||
bool pn53x_usb_init (nfc_device_t *pnd);
|
||||
bool pn53x_usb_init (nfc_device *pnd);
|
||||
|
||||
int
|
||||
pn53x_usb_bulk_read (struct pn53x_usb_data *data, byte_t abtRx[], const size_t szRx, struct timeval *timeout)
|
||||
|
|
@ -190,7 +190,7 @@ pn53x_usb_get_device_model (uint16_t vendor_id, uint16_t product_id)
|
|||
return UNKNOWN;
|
||||
}
|
||||
|
||||
int pn53x_usb_ack (nfc_device_t * pnd);
|
||||
int pn53x_usb_ack (nfc_device * pnd);
|
||||
|
||||
// Find transfer endpoints for bulk transfers
|
||||
void
|
||||
|
|
@ -378,7 +378,7 @@ pn53x_usb_get_usb_device_name (struct usb_device *dev, usb_dev_handle *udev, cha
|
|||
return false;
|
||||
}
|
||||
|
||||
nfc_device_t *
|
||||
nfc_device *
|
||||
pn53x_usb_connect (const nfc_connstring connstring)
|
||||
{
|
||||
struct pn53x_usb_descriptor desc;
|
||||
|
|
@ -388,7 +388,7 @@ pn53x_usb_connect (const nfc_connstring connstring)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
nfc_device_t *pnd = NULL;
|
||||
nfc_device *pnd = NULL;
|
||||
struct pn53x_usb_data data = {
|
||||
.pudh = NULL,
|
||||
.uiEndPointIn = 0,
|
||||
|
|
@ -492,7 +492,7 @@ error:
|
|||
}
|
||||
|
||||
void
|
||||
pn53x_usb_disconnect (nfc_device_t * pnd)
|
||||
pn53x_usb_disconnect (nfc_device * pnd)
|
||||
{
|
||||
pn53x_usb_ack (pnd);
|
||||
|
||||
|
|
@ -519,7 +519,7 @@ pn53x_usb_disconnect (nfc_device_t * pnd)
|
|||
#define PN53X_USB_BUFFER_LEN (PN53x_EXTENDED_FRAME__DATA_MAX_LEN + PN53x_EXTENDED_FRAME__OVERHEAD)
|
||||
|
||||
bool
|
||||
pn53x_usb_send (nfc_device_t * pnd, const byte_t * pbtData, const size_t szData, struct timeval *timeout)
|
||||
pn53x_usb_send (nfc_device * pnd, const byte_t * pbtData, const size_t szData, struct timeval *timeout)
|
||||
{
|
||||
byte_t abtFrame[PN53X_USB_BUFFER_LEN] = { 0x00, 0x00, 0xff }; // Every packet must start with "00 00 ff"
|
||||
size_t szFrame = 0;
|
||||
|
|
@ -565,7 +565,7 @@ pn53x_usb_send (nfc_device_t * pnd, const byte_t * pbtData, const size_t szData,
|
|||
}
|
||||
|
||||
int
|
||||
pn53x_usb_receive (nfc_device_t * pnd, byte_t * pbtData, const size_t szDataLen, struct timeval *timeout)
|
||||
pn53x_usb_receive (nfc_device * pnd, byte_t * pbtData, const size_t szDataLen, struct timeval *timeout)
|
||||
{
|
||||
size_t len;
|
||||
off_t offset = 0;
|
||||
|
|
@ -715,13 +715,13 @@ read:
|
|||
}
|
||||
|
||||
int
|
||||
pn53x_usb_ack (nfc_device_t * pnd)
|
||||
pn53x_usb_ack (nfc_device * pnd)
|
||||
{
|
||||
return pn53x_usb_bulk_write (DRIVER_DATA (pnd), (byte_t *) pn53x_ack_frame, sizeof (pn53x_ack_frame), NULL);
|
||||
}
|
||||
|
||||
bool
|
||||
pn53x_usb_init (nfc_device_t *pnd)
|
||||
pn53x_usb_init (nfc_device *pnd)
|
||||
{
|
||||
// Sometimes PN53x USB doesn't reply ACK one the first frame, so we need to send a dummy one...
|
||||
//pn53x_check_communication (pnd); // Sony RC-S360 doesn't support this command for now so let's use a get_firmware_version instead:
|
||||
|
|
@ -778,7 +778,7 @@ On ASK LoGO hardware:
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_usb_configure (nfc_device_t * pnd, const nfc_device_option_t ndo, const bool bEnable)
|
||||
pn53x_usb_configure (nfc_device * pnd, const nfc_device_option ndo, const bool bEnable)
|
||||
{
|
||||
if (!pn53x_configure (pnd, ndo, bEnable))
|
||||
return false;
|
||||
|
|
@ -806,7 +806,7 @@ pn53x_usb_configure (nfc_device_t * pnd, const nfc_device_option_t ndo, const bo
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_usb_abort_command (nfc_device_t * pnd)
|
||||
pn53x_usb_abort_command (nfc_device * pnd)
|
||||
{
|
||||
DRIVER_DATA (pnd)->abort_flag = true;
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -30,10 +30,10 @@
|
|||
# include <nfc/nfc-types.h>
|
||||
|
||||
bool pn53x_usb_probe (nfc_connstring connstrings[], size_t connstrings_len, size_t * pszDeviceFound);
|
||||
nfc_device_t *pn53x_usb_connect (const nfc_connstring connstring);
|
||||
bool pn53x_usb_send (nfc_device_t * pnd, const byte_t * pbtData, const size_t szData, struct timeval *timeout);
|
||||
int pn53x_usb_receive (nfc_device_t * pnd, byte_t * pbtData, const size_t szData, struct timeval *timeout);
|
||||
void pn53x_usb_disconnect (nfc_device_t * pnd);
|
||||
nfc_device *pn53x_usb_connect (const nfc_connstring connstring);
|
||||
bool pn53x_usb_send (nfc_device * pnd, const byte_t * pbtData, const size_t szData, struct timeval *timeout);
|
||||
int pn53x_usb_receive (nfc_device * pnd, byte_t * pbtData, const size_t szData, struct timeval *timeout);
|
||||
void pn53x_usb_disconnect (nfc_device * pnd);
|
||||
|
||||
extern const struct nfc_driver_t pn53x_usb_driver;
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
/**
|
||||
* @file nfc-device.c
|
||||
* @brief Provide internal function to manipulate nfc_device_t type
|
||||
* @brief Provide internal function to manipulate nfc_device type
|
||||
*/
|
||||
|
||||
/* vim:set et sw=2 ts=2: */
|
||||
|
|
@ -32,10 +32,10 @@
|
|||
|
||||
#include "nfc-internal.h"
|
||||
|
||||
nfc_device_t *
|
||||
nfc_device *
|
||||
nfc_device_new (void)
|
||||
{
|
||||
nfc_device_t *res = malloc (sizeof (*res));
|
||||
nfc_device *res = malloc (sizeof (*res));
|
||||
|
||||
if (!res) {
|
||||
err (EXIT_FAILURE, "nfc_device_new: malloc");
|
||||
|
|
@ -57,7 +57,7 @@ nfc_device_new (void)
|
|||
}
|
||||
|
||||
void
|
||||
nfc_device_free (nfc_device_t *nfc_device)
|
||||
nfc_device_free (nfc_device *nfc_device)
|
||||
{
|
||||
if (nfc_device) {
|
||||
free (nfc_device->driver_data);
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
#include "iso7816.h"
|
||||
|
||||
int
|
||||
nfc_emulate_target (nfc_device_t* pnd, struct nfc_emulator *emulator)
|
||||
nfc_emulate_target (nfc_device* pnd, struct nfc_emulator *emulator)
|
||||
{
|
||||
byte_t abtRx[ISO7816_SHORT_R_APDU_MAX_LEN];
|
||||
size_t szRx = sizeof(abtRx);
|
||||
|
|
|
|||
|
|
@ -23,10 +23,9 @@
|
|||
*/
|
||||
|
||||
#include <nfc/nfc.h>
|
||||
#include <nfc/nfc-emulation.h>
|
||||
|
||||
void
|
||||
prepare_initiator_data (const nfc_modulation_t nm, byte_t **ppbtInitiatorData, size_t * pszInitiatorData)
|
||||
prepare_initiator_data (const nfc_modulation nm, byte_t **ppbtInitiatorData, size_t * pszInitiatorData)
|
||||
{
|
||||
switch (nm.nmt) {
|
||||
case NMT_ISO14443B: {
|
||||
|
|
|
|||
|
|
@ -127,37 +127,37 @@
|
|||
struct nfc_driver_t {
|
||||
const char *name;
|
||||
bool (*probe)(nfc_connstring connstrings[], size_t connstrings_len, size_t * pszDeviceFound);
|
||||
nfc_device_t * (*connect) (const nfc_connstring connstring);
|
||||
void (*disconnect) (nfc_device_t * pnd);
|
||||
const char *(*strerror) (const nfc_device_t * pnd);
|
||||
nfc_device * (*connect) (const nfc_connstring connstring);
|
||||
void (*disconnect) (nfc_device * pnd);
|
||||
const char *(*strerror) (const nfc_device * pnd);
|
||||
|
||||
bool (*initiator_init) (nfc_device_t * pnd);
|
||||
bool (*initiator_select_passive_target) (nfc_device_t * pnd, const nfc_modulation_t nm, const byte_t * pbtInitData, const size_t szInitData, nfc_target_t * pnt);
|
||||
bool (*initiator_poll_target) (nfc_device_t * pnd, const nfc_modulation_t * pnmModulations, const size_t szModulations, const uint8_t uiPollNr, const uint8_t btPeriod, nfc_target_t * pnt);
|
||||
bool (*initiator_select_dep_target) (nfc_device_t * pnd, const nfc_dep_mode_t ndm, const nfc_baud_rate_t nbr, const nfc_dep_info_t * pndiInitiator, nfc_target_t * pnt);
|
||||
bool (*initiator_deselect_target) (nfc_device_t * pnd);
|
||||
bool (*initiator_transceive_bytes) (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx, size_t * pszRx, struct timeval *timeout);
|
||||
bool (*initiator_transceive_bits) (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTxBits, const byte_t * pbtTxPar, byte_t * pbtRx, size_t * pszRxBits, byte_t * pbtRxPar);
|
||||
bool (*initiator_transceive_bytes_timed) (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx, size_t * pszRx, uint32_t * cycles);
|
||||
bool (*initiator_transceive_bits_timed) (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTxBits, const byte_t * pbtTxPar, byte_t * pbtRx, size_t * pszRxBits, byte_t * pbtRxPar, uint32_t * cycles);
|
||||
bool (*initiator_init) (nfc_device * pnd);
|
||||
bool (*initiator_select_passive_target) (nfc_device * pnd, const nfc_modulation nm, const byte_t * pbtInitData, const size_t szInitData, nfc_target * pnt);
|
||||
bool (*initiator_poll_target) (nfc_device * pnd, const nfc_modulation * pnmModulations, const size_t szModulations, const uint8_t uiPollNr, const uint8_t btPeriod, nfc_target * pnt);
|
||||
bool (*initiator_select_dep_target) (nfc_device * pnd, const nfc_dep_mode ndm, const nfc_baud_rate nbr, const nfc_dep_info * pndiInitiator, nfc_target * pnt);
|
||||
bool (*initiator_deselect_target) (nfc_device * pnd);
|
||||
bool (*initiator_transceive_bytes) (nfc_device * pnd, const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx, size_t * pszRx, struct timeval *timeout);
|
||||
bool (*initiator_transceive_bits) (nfc_device * pnd, const byte_t * pbtTx, const size_t szTxBits, const byte_t * pbtTxPar, byte_t * pbtRx, size_t * pszRxBits, byte_t * pbtRxPar);
|
||||
bool (*initiator_transceive_bytes_timed) (nfc_device * pnd, const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx, size_t * pszRx, uint32_t * cycles);
|
||||
bool (*initiator_transceive_bits_timed) (nfc_device * pnd, const byte_t * pbtTx, const size_t szTxBits, const byte_t * pbtTxPar, byte_t * pbtRx, size_t * pszRxBits, byte_t * pbtRxPar, uint32_t * cycles);
|
||||
|
||||
bool (*target_init) (nfc_device_t * pnd, nfc_target_t * pnt, byte_t * pbtRx, size_t * pszRx);
|
||||
bool (*target_send_bytes) (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx, struct timeval *timeout);
|
||||
bool (*target_receive_bytes) (nfc_device_t * pnd, byte_t * pbtRx, size_t * pszRx, struct timeval *timeout);
|
||||
bool (*target_send_bits) (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTxBits, const byte_t * pbtTxPar);
|
||||
bool (*target_receive_bits) (nfc_device_t * pnd, byte_t * pbtRx, size_t * pszRxBits, byte_t * pbtRxPar);
|
||||
bool (*target_init) (nfc_device * pnd, nfc_target * pnt, byte_t * pbtRx, size_t * pszRx);
|
||||
bool (*target_send_bytes) (nfc_device * pnd, const byte_t * pbtTx, const size_t szTx, struct timeval *timeout);
|
||||
bool (*target_receive_bytes) (nfc_device * pnd, byte_t * pbtRx, size_t * pszRx, struct timeval *timeout);
|
||||
bool (*target_send_bits) (nfc_device * pnd, const byte_t * pbtTx, const size_t szTxBits, const byte_t * pbtTxPar);
|
||||
bool (*target_receive_bits) (nfc_device * pnd, byte_t * pbtRx, size_t * pszRxBits, byte_t * pbtRxPar);
|
||||
|
||||
bool (*configure) (nfc_device_t * pnd, const nfc_device_option_t ndo, const bool bEnable);
|
||||
bool (*configure) (nfc_device * pnd, const nfc_device_option ndo, const bool bEnable);
|
||||
|
||||
bool (*abort_command) (nfc_device_t * pnd);
|
||||
bool (*idle) (nfc_device_t * pnd);
|
||||
bool (*abort_command) (nfc_device * pnd);
|
||||
bool (*idle) (nfc_device * pnd);
|
||||
};
|
||||
|
||||
nfc_device_t *nfc_device_new (void);
|
||||
void nfc_device_free (nfc_device_t *nfc_device);
|
||||
nfc_device *nfc_device_new (void);
|
||||
void nfc_device_free (nfc_device *nfc_device);
|
||||
|
||||
void iso14443_cascade_uid (const byte_t abtUID[], const size_t szUID, byte_t * pbtCascadedUID, size_t * pszCascadedUID);
|
||||
|
||||
void prepare_initiator_data (const nfc_modulation_t nm, byte_t **ppbtInitiatorData, size_t * pszInitiatorData);
|
||||
void prepare_initiator_data (const nfc_modulation nm, byte_t **ppbtInitiatorData, size_t * pszInitiatorData);
|
||||
|
||||
#endif // __NFC_INTERNAL_H__
|
||||
|
|
|
|||
120
libnfc/nfc.c
120
libnfc/nfc.c
|
|
@ -98,24 +98,24 @@ nfc_get_default_device (nfc_connstring *connstring)
|
|||
/**
|
||||
* @brief Connect to a NFC device
|
||||
* @param connstring The device connection string if specific device is wanted, \c NULL otherwise
|
||||
* @return Returns pointer to a \a nfc_device_t struct if successfull; otherwise returns \c NULL value.
|
||||
* @return Returns pointer to a \a nfc_device struct if successfull; otherwise returns \c NULL value.
|
||||
*
|
||||
* If \e connstring is \c NULL, the \a nfc_get_default_device() function is used.
|
||||
*
|
||||
* If \e connstring is set, this function will try to claim the right device using information provided by \e connstring.
|
||||
*
|
||||
* When it has successfully claimed a NFC device, memory is allocated to save the device information.
|
||||
* It will return a pointer to a \a nfc_device_t struct.
|
||||
* It will return a pointer to a \a nfc_device struct.
|
||||
* This pointer should be supplied by every next functions of libnfc that should perform an action with this device.
|
||||
*
|
||||
* @note Depending on the desired operation mode, the device needs to be configured by using nfc_initiator_init() or nfc_target_init(),
|
||||
* optionally followed by manual tuning of the parameters if the default parameters are not suiting your goals.
|
||||
*/
|
||||
nfc_device_t *
|
||||
nfc_device *
|
||||
nfc_connect (const nfc_connstring connstring)
|
||||
{
|
||||
log_init ();
|
||||
nfc_device_t *pnd = NULL;
|
||||
nfc_device *pnd = NULL;
|
||||
|
||||
nfc_connstring ncs;
|
||||
if (connstring == NULL) {
|
||||
|
|
@ -158,12 +158,12 @@ nfc_connect (const nfc_connstring connstring)
|
|||
|
||||
/**
|
||||
* @brief Disconnect from a NFC device
|
||||
* @param pnd \a nfc_device_t struct pointer that represent currently used device
|
||||
* @param pnd \a nfc_device struct pointer that represent currently used device
|
||||
*
|
||||
* Initiator's selected tag is disconnected and the device, including allocated \a nfc_device_t struct, is released.
|
||||
* Initiator's selected tag is disconnected and the device, including allocated \a nfc_device struct, is released.
|
||||
*/
|
||||
void
|
||||
nfc_disconnect (nfc_device_t * pnd)
|
||||
nfc_disconnect (nfc_device * pnd)
|
||||
{
|
||||
if (pnd) {
|
||||
// Go in idle mode
|
||||
|
|
@ -206,8 +206,8 @@ nfc_list_devices (nfc_connstring connstrings[] , size_t szDevices, size_t * pszD
|
|||
/**
|
||||
* @brief Configure advanced NFC device settings
|
||||
* @return Returns \c true if action was successfully performed; otherwise returns \c false.
|
||||
* @param pnd \a nfc_device_t struct pointer that represent currently used device
|
||||
* @param ndo \a nfc_device_option_t struct that contains option to set to device
|
||||
* @param pnd \a nfc_device struct pointer that represent currently used device
|
||||
* @param ndo \a nfc_device_option struct that contains option to set to device
|
||||
* @param bEnable boolean to activate/disactivate the option
|
||||
*
|
||||
* Configures parameters and registers that control for example timing,
|
||||
|
|
@ -216,7 +216,7 @@ nfc_list_devices (nfc_connstring connstrings[] , size_t szDevices, size_t * pszD
|
|||
* accept).
|
||||
*/
|
||||
bool
|
||||
nfc_configure (nfc_device_t * pnd, const nfc_device_option_t ndo, const bool bEnable)
|
||||
nfc_configure (nfc_device * pnd, const nfc_device_option ndo, const bool bEnable)
|
||||
{
|
||||
HAL (configure, pnd, ndo, bEnable);
|
||||
}
|
||||
|
|
@ -224,7 +224,7 @@ nfc_configure (nfc_device_t * pnd, const nfc_device_option_t ndo, const bool bEn
|
|||
/**
|
||||
* @brief Initialize NFC device as initiator (reader)
|
||||
* @return Returns \c true if action was successfully performed; otherwise returns \c false.
|
||||
* @param pnd \a nfc_device_t struct pointer that represent currently used device
|
||||
* @param pnd \a nfc_device struct pointer that represent currently used device
|
||||
*
|
||||
* The NFC device is configured to function as RFID reader.
|
||||
* After initialization it can be used to communicate to passive RFID tags and active NFC devices.
|
||||
|
|
@ -242,7 +242,7 @@ nfc_configure (nfc_device_t * pnd, const nfc_device_option_t ndo, const bool bEn
|
|||
* - RF field is shortly dropped (if it was enabled) then activated again
|
||||
*/
|
||||
bool
|
||||
nfc_initiator_init (nfc_device_t * pnd)
|
||||
nfc_initiator_init (nfc_device * pnd)
|
||||
{
|
||||
// Drop the field for a while
|
||||
if (!nfc_configure (pnd, NDO_ACTIVATE_FIELD, false))
|
||||
|
|
@ -287,7 +287,7 @@ nfc_initiator_init (nfc_device_t * pnd)
|
|||
* @brief Select a passive or emulated tag
|
||||
* @return Returns \c true if action was successfully performed; otherwise returns \c false.
|
||||
*
|
||||
* @param pnd \a nfc_device_t struct pointer that represent currently used device
|
||||
* @param pnd \a nfc_device struct pointer that represent currently used device
|
||||
* @param nm desired modulation
|
||||
* @param pbtInitData optional initiator data used for Felica, ISO14443B, Topaz polling or to select a specific UID in ISO14443A.
|
||||
* @param szInitData length of initiator data \a pbtInitData.
|
||||
|
|
@ -296,7 +296,7 @@ nfc_initiator_init (nfc_device_t * pnd)
|
|||
* - for an ISO/IEC 14443 type B modulation, pbbInitData contains Application Family Identifier (AFI) (see ISO/IEC 14443-3);
|
||||
* - for a FeliCa modulation, pbbInitData contains polling payload (see ISO/IEC 18092 11.2.2.5).
|
||||
*
|
||||
* @param[out] pnt \a nfc_target_t struct pointer which will filled if available
|
||||
* @param[out] pnt \a nfc_target struct pointer which will filled if available
|
||||
*
|
||||
* The NFC device will try to find one available passive tag or emulated tag.
|
||||
*
|
||||
|
|
@ -304,10 +304,10 @@ nfc_initiator_init (nfc_device_t * pnd)
|
|||
* the initial modulation and speed (106, 212 or 424 kbps) should be supplied.
|
||||
*/
|
||||
bool
|
||||
nfc_initiator_select_passive_target (nfc_device_t * pnd,
|
||||
const nfc_modulation_t nm,
|
||||
nfc_initiator_select_passive_target (nfc_device * pnd,
|
||||
const nfc_modulation nm,
|
||||
const byte_t * pbtInitData, const size_t szInitData,
|
||||
nfc_target_t * pnt)
|
||||
nfc_target * pnt)
|
||||
{
|
||||
byte_t abtInit[MAX(12, szInitData)];
|
||||
size_t szInit;
|
||||
|
|
@ -330,9 +330,9 @@ nfc_initiator_select_passive_target (nfc_device_t * pnd,
|
|||
* @brief List passive or emulated tags
|
||||
* @return Returns \c true if action was successfully performed; otherwise returns \c false.
|
||||
*
|
||||
* @param pnd \a nfc_device_t struct pointer that represent currently used device
|
||||
* @param pnd \a nfc_device struct pointer that represent currently used device
|
||||
* @param nm desired modulation
|
||||
* @param[out] ant array of \a nfc_target_t that will be filled with targets info
|
||||
* @param[out] ant array of \a nfc_target that will be filled with targets info
|
||||
* @param szTargets size of \a ant (will be the max targets listed)
|
||||
* @param[out] pszTargetFound pointer where target found counter will be stored
|
||||
*
|
||||
|
|
@ -344,11 +344,11 @@ nfc_initiator_select_passive_target (nfc_device_t * pnd,
|
|||
* should be supplied.
|
||||
*/
|
||||
bool
|
||||
nfc_initiator_list_passive_targets (nfc_device_t * pnd,
|
||||
const nfc_modulation_t nm,
|
||||
nfc_target_t ant[], const size_t szTargets, size_t * pszTargetFound)
|
||||
nfc_initiator_list_passive_targets (nfc_device * pnd,
|
||||
const nfc_modulation nm,
|
||||
nfc_target ant[], const size_t szTargets, size_t * pszTargetFound)
|
||||
{
|
||||
nfc_target_t nt;
|
||||
nfc_target nt;
|
||||
size_t szTargetFound = 0;
|
||||
byte_t *pbtInitData = NULL;
|
||||
size_t szInitDataLen = 0;
|
||||
|
|
@ -371,14 +371,14 @@ nfc_initiator_list_passive_targets (nfc_device_t * pnd,
|
|||
bool seen = false;
|
||||
// Check if we've already seen this tag
|
||||
for (i = 0; i < szTargetFound; i++) {
|
||||
if (memcmp(&(ant[i]), &nt, sizeof (nfc_target_t)) == 0) {
|
||||
if (memcmp(&(ant[i]), &nt, sizeof (nfc_target)) == 0) {
|
||||
seen = true;
|
||||
}
|
||||
}
|
||||
if (seen) {
|
||||
break;
|
||||
}
|
||||
memcpy (&(ant[szTargetFound]), &nt, sizeof (nfc_target_t));
|
||||
memcpy (&(ant[szTargetFound]), &nt, sizeof (nfc_target));
|
||||
szTargetFound++;
|
||||
// deselect has no effect on FeliCa and Jewel cards so we'll stop after one...
|
||||
// ISO/IEC 14443 B' cards are polled at 100% probability so it's not possible to detect correctly two cards at the same time
|
||||
|
|
@ -395,20 +395,20 @@ nfc_initiator_list_passive_targets (nfc_device_t * pnd,
|
|||
* @brief Polling for NFC targets
|
||||
* @return Returns \c true if action was successfully performed; otherwise returns \c false.
|
||||
*
|
||||
* @param pnd \a nfc_device_t struct pointer that represent currently used device
|
||||
* @param pnd \a nfc_device struct pointer that represent currently used device
|
||||
* @param ppttTargetTypes array of desired target types
|
||||
* @param szTargetTypes \e ppttTargetTypes count
|
||||
* @param uiPollNr specifies the number of polling (0x01 – 0xFE: 1 up to 254 polling, 0xFF: Endless polling)
|
||||
* @note one polling is a polling for each desired target type
|
||||
* @param uiPeriod indicates the polling period in units of 150 ms (0x01 – 0x0F: 150ms – 2.25s)
|
||||
* @note e.g. if uiPeriod=10, it will poll each desired target type during 1.5s
|
||||
* @param[out] pnt pointer on \a nfc_target_t (over)writable struct
|
||||
* @param[out] pnt pointer on \a nfc_target (over)writable struct
|
||||
*/
|
||||
bool
|
||||
nfc_initiator_poll_target (nfc_device_t * pnd,
|
||||
const nfc_modulation_t * pnmModulations, const size_t szModulations,
|
||||
nfc_initiator_poll_target (nfc_device * pnd,
|
||||
const nfc_modulation * pnmModulations, const size_t szModulations,
|
||||
const uint8_t uiPollNr, const uint8_t uiPeriod,
|
||||
nfc_target_t * pnt)
|
||||
nfc_target * pnt)
|
||||
{
|
||||
HAL (initiator_poll_target, pnd, pnmModulations, szModulations, uiPollNr, uiPeriod, pnt);
|
||||
}
|
||||
|
|
@ -418,21 +418,21 @@ nfc_initiator_poll_target (nfc_device_t * pnd,
|
|||
* @brief Select a target and request active or passive mode for D.E.P. (Data Exchange Protocol)
|
||||
* @return Returns \c true if action was successfully performed; otherwise returns \c false.
|
||||
*
|
||||
* @param pnd \a nfc_device_t struct pointer that represent currently used device
|
||||
* @param pnd \a nfc_device struct pointer that represent currently used device
|
||||
* @param ndm desired D.E.P. mode (\a NDM_ACTIVE or \a NDM_PASSIVE for active, respectively passive mode)
|
||||
* @param ndiInitiator pointer \a nfc_dep_info_t struct that contains \e NFCID3 and \e General \e Bytes to set to the initiator device (optionnal, can be \e NULL)
|
||||
* @param[out] pnt is a \a nfc_target_t struct pointer where target information will be put.
|
||||
* @param ndiInitiator pointer \a nfc_dep_info struct that contains \e NFCID3 and \e General \e Bytes to set to the initiator device (optionnal, can be \e NULL)
|
||||
* @param[out] pnt is a \a nfc_target struct pointer where target information will be put.
|
||||
*
|
||||
* The NFC device will try to find an available D.E.P. target. The standards
|
||||
* (ISO18092 and ECMA-340) describe the modulation that can be used for reader
|
||||
* to passive communications.
|
||||
*
|
||||
* @note \a nfc_dep_info_t will be returned when the target was acquired successfully.
|
||||
* @note \a nfc_dep_info will be returned when the target was acquired successfully.
|
||||
*/
|
||||
bool
|
||||
nfc_initiator_select_dep_target (nfc_device_t * pnd,
|
||||
const nfc_dep_mode_t ndm, const nfc_baud_rate_t nbr,
|
||||
const nfc_dep_info_t * pndiInitiator, nfc_target_t * pnt)
|
||||
nfc_initiator_select_dep_target (nfc_device * pnd,
|
||||
const nfc_dep_mode ndm, const nfc_baud_rate nbr,
|
||||
const nfc_dep_info * pndiInitiator, nfc_target * pnt)
|
||||
{
|
||||
HAL (initiator_select_dep_target, pnd, ndm, nbr, pndiInitiator, pnt);
|
||||
}
|
||||
|
|
@ -440,7 +440,7 @@ nfc_initiator_select_dep_target (nfc_device_t * pnd,
|
|||
/**
|
||||
* @brief Deselect a selected passive or emulated tag
|
||||
* @return Returns \c true if action was successfully performed; otherwise returns \c false.
|
||||
* @param pnd \a nfc_device_t struct pointer that represents currently used device
|
||||
* @param pnd \a nfc_device struct pointer that represents currently used device
|
||||
*
|
||||
* After selecting and communicating with a passive tag, this function could be
|
||||
* used to deactivate and release the tag. This is very useful when there are
|
||||
|
|
@ -450,7 +450,7 @@ nfc_initiator_select_dep_target (nfc_device_t * pnd,
|
|||
* the next tag until the correct tag is found.
|
||||
*/
|
||||
bool
|
||||
nfc_initiator_deselect_target (nfc_device_t * pnd)
|
||||
nfc_initiator_deselect_target (nfc_device * pnd)
|
||||
{
|
||||
HAL (initiator_deselect_target, pnd);
|
||||
}
|
||||
|
|
@ -479,7 +479,7 @@ nfc_initiator_deselect_target (nfc_device_t * pnd)
|
|||
* @warning The configuration option \a NDO_HANDLE_PARITY must be set to \c true (the default value).
|
||||
*/
|
||||
bool
|
||||
nfc_initiator_transceive_bytes (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx,
|
||||
nfc_initiator_transceive_bytes (nfc_device * pnd, const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx,
|
||||
size_t * pszRx, struct timeval *timeout)
|
||||
{
|
||||
HAL (initiator_transceive_bytes, pnd, pbtTx, szTx, pbtRx, pszRx, timeout)
|
||||
|
|
@ -521,7 +521,7 @@ nfc_initiator_transceive_bytes (nfc_device_t * pnd, const byte_t * pbtTx, const
|
|||
* CRC bytes. Using this feature you are able to simulate these frames.
|
||||
*/
|
||||
bool
|
||||
nfc_initiator_transceive_bits (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTxBits, const byte_t * pbtTxPar,
|
||||
nfc_initiator_transceive_bits (nfc_device * pnd, const byte_t * pbtTx, const size_t szTxBits, const byte_t * pbtTxPar,
|
||||
byte_t * pbtRx, size_t * pszRxBits, byte_t * pbtRxPar)
|
||||
{
|
||||
HAL (initiator_transceive_bits, pnd, pbtTx, szTxBits, pbtTxPar, pbtRx, pszRxBits, pbtRxPar);
|
||||
|
|
@ -548,7 +548,7 @@ nfc_initiator_transceive_bits (nfc_device_t * pnd, const byte_t * pbtTx, const s
|
|||
* @warning The configuration option \a NDO_HANDLE_PARITY must be set to \c true (the default value).
|
||||
*/
|
||||
bool
|
||||
nfc_initiator_transceive_bytes_timed (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx,
|
||||
nfc_initiator_transceive_bytes_timed (nfc_device * pnd, const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx,
|
||||
size_t * pszRx, uint32_t * cycles)
|
||||
{
|
||||
HAL (initiator_transceive_bytes_timed, pnd, pbtTx, szTx, pbtRx, pszRx, cycles)
|
||||
|
|
@ -576,7 +576,7 @@ nfc_initiator_transceive_bytes_timed (nfc_device_t * pnd, const byte_t * pbtTx,
|
|||
* @warning The configuration option \a NDO_HANDLE_PARITY must be set to \c true (the default value).
|
||||
*/
|
||||
bool
|
||||
nfc_initiator_transceive_bits_timed (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTxBits, const byte_t * pbtTxPar,
|
||||
nfc_initiator_transceive_bits_timed (nfc_device * pnd, const byte_t * pbtTx, const size_t szTxBits, const byte_t * pbtTxPar,
|
||||
byte_t * pbtRx, size_t * pszRxBits, byte_t * pbtRxPar, uint32_t * cycles)
|
||||
{
|
||||
HAL (initiator_transceive_bits_timed, pnd, pbtTx, szTxBits, pbtTxPar, pbtRx, pszRxBits, pbtRxPar, cycles);
|
||||
|
|
@ -586,9 +586,9 @@ nfc_initiator_transceive_bits_timed (nfc_device_t * pnd, const byte_t * pbtTx, c
|
|||
* @brief Initialize NFC device as an emulated tag
|
||||
* @return Returns \c true if action was successfully performed; otherwise returns \c false.
|
||||
*
|
||||
* @param pnd \a nfc_device_t struct pointer that represent currently used device
|
||||
* @param pnd \a nfc_device struct pointer that represent currently used device
|
||||
* @param ntm target mode restriction that you want to emulate (eg. NTM_PASSIVE_ONLY)
|
||||
* @param pnt pointer to \a nfc_target_t struct that represents the wanted emulated target
|
||||
* @param pnt pointer to \a nfc_target struct that represents the wanted emulated target
|
||||
*
|
||||
* @note \a pnt can be updated by this function: if you set NBR_UNDEFINED
|
||||
* and/or NDM_UNDEFINED (ie. for DEP mode), these fields will be updated.
|
||||
|
|
@ -613,7 +613,7 @@ nfc_initiator_transceive_bits_timed (nfc_device_t * pnd, const byte_t * pbtTx, c
|
|||
* receive functions can be used.
|
||||
*/
|
||||
bool
|
||||
nfc_target_init (nfc_device_t * pnd, nfc_target_t * pnt, byte_t * pbtRx, size_t * pszRx)
|
||||
nfc_target_init (nfc_device * pnd, nfc_target * pnt, byte_t * pbtRx, size_t * pszRx)
|
||||
{
|
||||
// Disallow invalid frame
|
||||
if (!nfc_configure (pnd, NDO_ACCEPT_INVALID_FRAMES, false))
|
||||
|
|
@ -646,14 +646,14 @@ nfc_target_init (nfc_device_t * pnd, nfc_target_t * pnt, byte_t * pbtRx, size_t
|
|||
* @brief Turn NFC device in idle mode
|
||||
* @return Returns \c true if action was successfully performed; otherwise returns \c false.
|
||||
*
|
||||
* @param pnd \a nfc_device_t struct pointer that represent currently used device
|
||||
* @param pnd \a nfc_device struct pointer that represent currently used device
|
||||
*
|
||||
* This function switch the device in idle mode.
|
||||
* In initiator mode, the RF field is turned off and the device is set to low power mode (if avaible);
|
||||
* In target mode, the emulation is stoped (no target available from external initiator) and the device is set to low power mode (if avaible).
|
||||
*/
|
||||
bool
|
||||
nfc_idle (nfc_device_t * pnd)
|
||||
nfc_idle (nfc_device * pnd)
|
||||
{
|
||||
HAL (idle, pnd);
|
||||
}
|
||||
|
|
@ -662,7 +662,7 @@ nfc_idle (nfc_device_t * pnd)
|
|||
* @brief Abort current running command
|
||||
* @return Returns \c true if action was successfully performed; otherwise returns \c false.
|
||||
*
|
||||
* @param pnd \a nfc_device_t struct pointer that represent currently used device
|
||||
* @param pnd \a nfc_device struct pointer that represent currently used device
|
||||
*
|
||||
* Some commands (ie. nfc_target_init()) are blocking functions and will return only in particular conditions (ie. external initiator request).
|
||||
* This function attempt to abort the current running command.
|
||||
|
|
@ -670,7 +670,7 @@ nfc_idle (nfc_device_t * pnd)
|
|||
* @note The blocking function (ie. nfc_target_init()) will failed with DEABORT error.
|
||||
*/
|
||||
bool
|
||||
nfc_abort_command (nfc_device_t * pnd)
|
||||
nfc_abort_command (nfc_device * pnd)
|
||||
{
|
||||
HAL (abort_command, pnd);
|
||||
}
|
||||
|
|
@ -679,7 +679,7 @@ nfc_abort_command (nfc_device_t * pnd)
|
|||
* @brief Send bytes and APDU frames
|
||||
* @return Returns \c true if action was successfully performed; otherwise returns \c false.
|
||||
*
|
||||
* @param pnd \a nfc_device_t struct pointer that represent currently used device
|
||||
* @param pnd \a nfc_device struct pointer that represent currently used device
|
||||
* @param pbtTx pointer to Tx buffer
|
||||
* @param szTx size of Tx buffer
|
||||
* @param timeout timeval struct pointer (NULL means infinite)
|
||||
|
|
@ -691,7 +691,7 @@ nfc_abort_command (nfc_device_t * pnd)
|
|||
* If timeout is a null pointer, the function blocks indefinitely (until an error is raised or function is completed).
|
||||
*/
|
||||
bool
|
||||
nfc_target_send_bytes (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx, struct timeval *timeout)
|
||||
nfc_target_send_bytes (nfc_device * pnd, const byte_t * pbtTx, const size_t szTx, struct timeval *timeout)
|
||||
{
|
||||
HAL (target_send_bytes, pnd, pbtTx, szTx, timeout);
|
||||
}
|
||||
|
|
@ -700,7 +700,7 @@ nfc_target_send_bytes (nfc_device_t * pnd, const byte_t * pbtTx, const size_t sz
|
|||
* @brief Receive bytes and APDU frames
|
||||
* @return Returns \c true if action was successfully performed; otherwise returns \c false.
|
||||
*
|
||||
* @param pnd \a nfc_device_t struct pointer that represent currently used device
|
||||
* @param pnd \a nfc_device struct pointer that represent currently used device
|
||||
* @param[out] pbtRx pointer to Rx buffer
|
||||
* @param[out] pszRx received byte count
|
||||
* @param timeout timeval struct pointer (NULL means infinite)
|
||||
|
|
@ -711,7 +711,7 @@ nfc_target_send_bytes (nfc_device_t * pnd, const byte_t * pbtTx, const size_t sz
|
|||
* If timeout is a null pointer, the function blocks indefinitely (until an error is raised or function is completed).
|
||||
*/
|
||||
bool
|
||||
nfc_target_receive_bytes (nfc_device_t * pnd, byte_t * pbtRx, size_t * pszRx, struct timeval *timeout)
|
||||
nfc_target_receive_bytes (nfc_device * pnd, byte_t * pbtRx, size_t * pszRx, struct timeval *timeout)
|
||||
{
|
||||
HAL (target_receive_bytes, pnd, pbtRx, pszRx, timeout);
|
||||
}
|
||||
|
|
@ -724,7 +724,7 @@ nfc_target_receive_bytes (nfc_device_t * pnd, byte_t * pbtRx, size_t * pszRx, st
|
|||
* using the specified NFC device (configured as \e target).
|
||||
*/
|
||||
bool
|
||||
nfc_target_send_bits (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTxBits, const byte_t * pbtTxPar)
|
||||
nfc_target_send_bits (nfc_device * pnd, const byte_t * pbtTx, const size_t szTxBits, const byte_t * pbtTxPar)
|
||||
{
|
||||
HAL (target_send_bits, pnd, pbtTx, szTxBits, pbtTxPar);
|
||||
}
|
||||
|
|
@ -741,7 +741,7 @@ nfc_target_send_bits (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szT
|
|||
* frames.
|
||||
*/
|
||||
bool
|
||||
nfc_target_receive_bits (nfc_device_t * pnd, byte_t * pbtRx, size_t * pszRxBits, byte_t * pbtRxPar)
|
||||
nfc_target_receive_bits (nfc_device * pnd, byte_t * pbtRx, size_t * pszRxBits, byte_t * pbtRxPar)
|
||||
{
|
||||
HAL (target_receive_bits, pnd, pbtRx, pszRxBits, pbtRxPar);
|
||||
}
|
||||
|
|
@ -751,7 +751,7 @@ nfc_target_receive_bits (nfc_device_t * pnd, byte_t * pbtRx, size_t * pszRxBits,
|
|||
* @return Returns a string
|
||||
*/
|
||||
const char *
|
||||
nfc_strerror (const nfc_device_t * pnd)
|
||||
nfc_strerror (const nfc_device * pnd)
|
||||
{
|
||||
return pnd->driver->strerror (pnd);
|
||||
}
|
||||
|
|
@ -761,7 +761,7 @@ nfc_strerror (const nfc_device_t * pnd)
|
|||
* @return Returns 0 upon success
|
||||
*/
|
||||
int
|
||||
nfc_strerror_r (const nfc_device_t * pnd, char *pcStrErrBuf, size_t szBufLen)
|
||||
nfc_strerror_r (const nfc_device * pnd, char *pcStrErrBuf, size_t szBufLen)
|
||||
{
|
||||
return (snprintf (pcStrErrBuf, szBufLen, "%s", nfc_strerror (pnd)) < 0) ? -1 : 0;
|
||||
}
|
||||
|
|
@ -770,7 +770,7 @@ nfc_strerror_r (const nfc_device_t * pnd, char *pcStrErrBuf, size_t szBufLen)
|
|||
* @brief Display the PCD error a-la perror
|
||||
*/
|
||||
void
|
||||
nfc_perror (const nfc_device_t * pnd, const char *pcString)
|
||||
nfc_perror (const nfc_device * pnd, const char *pcString)
|
||||
{
|
||||
fprintf (stderr, "%s: %s\n", pcString, nfc_strerror (pnd));
|
||||
}
|
||||
|
|
@ -782,7 +782,7 @@ nfc_perror (const nfc_device_t * pnd, const char *pcString)
|
|||
* @return Returns a string with the device name
|
||||
*/
|
||||
const char *
|
||||
nfc_device_name (nfc_device_t * pnd)
|
||||
nfc_device_name (nfc_device * pnd)
|
||||
{
|
||||
return pnd->acName;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue