Change byte_t type to uint8_t (Fixes Issue 147)

This commit is contained in:
Audrey Diacre 2011-11-24 10:54:42 +00:00
parent ce846931bc
commit 784a2f86a2
43 changed files with 442 additions and 444 deletions

View file

@ -49,8 +49,8 @@ void uart_flush_input (const serial_port sp);
void uart_set_speed (serial_port sp, const uint32_t uiPortSpeed);
uint32_t uart_get_speed (const serial_port sp);
int uart_receive (serial_port sp, byte_t * pbtRx, const size_t szRx, void * abort_p, struct timeval *timeout);
int uart_send (serial_port sp, const byte_t * pbtTx, const size_t szTx, struct timeval *timeout);
int uart_receive (serial_port sp, uint8_t * pbtRx, const size_t szRx, void * abort_p, struct timeval *timeout);
int uart_send (serial_port sp, const uint8_t * pbtTx, const size_t szTx, struct timeval *timeout);
char **uart_list_ports (void);

View file

@ -249,7 +249,7 @@ uart_close (const serial_port sp)
* @return 0 on success, otherwise driver error code
*/
int
uart_receive (serial_port sp, byte_t * pbtRx, const size_t szRx, void * abort_p, struct timeval *timeout)
uart_receive (serial_port sp, uint8_t * pbtRx, const size_t szRx, void * abort_p, struct timeval *timeout)
{
int iAbortFd = abort_p ? *((int*)abort_p) : 0;
int received_bytes_count = 0;
@ -327,7 +327,7 @@ select:
* @return 0 on success, otherwise a driver error is returned
*/
int
uart_send (serial_port sp, const byte_t * pbtTx, const size_t szTx, struct timeval *timeout)
uart_send (serial_port sp, const uint8_t * pbtTx, const size_t szTx, struct timeval *timeout)
{
(void) timeout;
LOG_HEX ("TX", pbtTx, szTx);

View file

@ -139,7 +139,7 @@ uart_get_speed (const serial_port sp)
}
int
uart_receive (serial_port sp, byte_t * pbtRx, const size_t szRx, void * abort_p, struct timeval *timeout)
uart_receive (serial_port sp, uint8_t * pbtRx, const size_t szRx, void * abort_p, struct timeval *timeout)
{
DWORD dwBytesToGet = (DWORD)szRx;
DWORD dwBytesReceived = 0;
@ -194,7 +194,7 @@ uart_receive (serial_port sp, byte_t * pbtRx, const size_t szRx, void * abort_p,
}
int
uart_send (serial_port sp, const byte_t * pbtTx, const size_t szTx, struct timeval *timeout)
uart_send (serial_port sp, const uint8_t * pbtTx, const size_t szTx, struct timeval *timeout)
{
DWORD dwTxLen = 0;

View file

@ -46,9 +46,9 @@
#define LOG_CATEGORY "libnfc.chip.pn53x"
const byte_t pn53x_ack_frame[] = { 0x00, 0x00, 0xff, 0x00, 0xff, 0x00 };
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 };
const uint8_t pn53x_ack_frame[] = { 0x00, 0x00, 0xff, 0x00, 0xff, 0x00 };
const uint8_t pn53x_nack_frame[] = { 0x00, 0x00, 0xff, 0xff, 0x00, 0x00 };
static const uint8_t pn53x_error_frame[] = { 0x00, 0x00, 0xff, 0x01, 0xff, 0x7f, 0x81, 0x00 };
/* prototypes */
bool pn53x_reset_settings (nfc_device * pnd);
@ -100,7 +100,7 @@ pn53x_reset_settings(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)
pn53x_transceive (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTx, uint8_t * pbtRx, size_t *pszRx, struct timeval *timeout)
{
if (CHIP_DATA (pnd)->wb_trigged) {
if (!pn53x_writeback_register (pnd)) {
@ -112,7 +112,7 @@ pn53x_transceive (nfc_device * pnd, const byte_t * pbtTx, const size_t szTx, byt
if (timeout)
log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "Timeout values: %li s, %li us", timeout->tv_sec, timeout->tv_usec);
byte_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
uint8_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
size_t szRx = sizeof(abtRx);
// Check if receiving buffers are available, if not, replace them
@ -215,11 +215,11 @@ 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)
pn53x_wrap_frame (const uint8_t * pbtTx, const size_t szTxBits, const uint8_t * pbtTxPar,
uint8_t * pbtFrame, size_t * pszFrameBits)
{
byte_t btFrame;
byte_t btData;
uint8_t btFrame;
uint8_t btData;
uint32_t uiBitPos;
uint32_t uiDataPos = 0;
size_t szBitsLeft = szTxBits;
@ -271,14 +271,14 @@ pn53x_wrap_frame (const byte_t * pbtTx, const size_t szTxBits, const byte_t * pb
}
bool
pn53x_unwrap_frame (const byte_t * pbtFrame, const size_t szFrameBits, byte_t * pbtRx, size_t * pszRxBits,
byte_t * pbtRxPar)
pn53x_unwrap_frame (const uint8_t * pbtFrame, const size_t szFrameBits, uint8_t * pbtRx, size_t * pszRxBits,
uint8_t * pbtRxPar)
{
byte_t btFrame;
byte_t btData;
uint8_t btFrame;
uint8_t btData;
uint8_t uiBitPos;
uint32_t uiDataPos = 0;
byte_t *pbtFramePos = (byte_t *) pbtFrame;
uint8_t *pbtFramePos = (uint8_t *) pbtFrame;
size_t szBitsLeft = szFrameBits;
// Make sure we should frame at least something
@ -318,7 +318,7 @@ 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_modulationype nmt,
pn53x_decode_target_data (const uint8_t * pbtRawData, size_t szRawData, pn53x_type type, nfc_modulationype nmt,
nfc_target_info * pnti)
{
uint8_t szAttribRes;
@ -464,8 +464,8 @@ pn53x_decode_target_data (const byte_t * pbtRawData, size_t szRawData, pn53x_typ
bool
pn53x_ReadRegister (nfc_device * pnd, uint16_t ui16RegisterAddress, uint8_t * ui8Value)
{
byte_t abtCmd[] = { ReadRegister, ui16RegisterAddress >> 8, ui16RegisterAddress & 0xff };
byte_t abtRegValue[2];
uint8_t abtCmd[] = { ReadRegister, ui16RegisterAddress >> 8, ui16RegisterAddress & 0xff };
uint8_t abtRegValue[2];
size_t szRegValue = sizeof (abtRegValue);
PNREG_TRACE (ui16RegisterAddress);
@ -489,7 +489,7 @@ bool pn53x_read_register (nfc_device * pnd, uint16_t ui16RegisterAddress, uint8_
bool
pn53x_WriteRegister (nfc_device * pnd, const uint16_t ui16RegisterAddress, const uint8_t ui8Value)
{
byte_t abtCmd[] = { WriteRegister, ui16RegisterAddress >> 8, ui16RegisterAddress & 0xff, ui8Value };
uint8_t abtCmd[] = { WriteRegister, ui16RegisterAddress >> 8, ui16RegisterAddress & 0xff, ui8Value };
PNREG_TRACE (ui16RegisterAddress);
return pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, NULL);
}
@ -591,8 +591,8 @@ pn53x_writeback_register (nfc_device * pnd)
bool
pn53x_get_firmware_version (nfc_device * pnd, char abtFirmwareText[22])
{
const byte_t abtCmd[] = { GetFirmwareVersion };
byte_t abtFw[4];
const uint8_t abtCmd[] = { GetFirmwareVersion };
uint8_t abtFw[4];
size_t szFwLen = sizeof (abtFw);
if (!pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), abtFw, &szFwLen, NULL)) {
return false;
@ -642,7 +642,7 @@ pn53x_get_firmware_version (nfc_device * pnd, char abtFirmwareText[22])
bool
pn53x_configure (nfc_device * pnd, const nfc_device_option ndo, const bool bEnable)
{
byte_t btValue;
uint8_t btValue;
switch (ndo) {
case NDO_HANDLE_CRC:
// Enable or disable automatic receiving/sending of CRC bytes
@ -827,9 +827,9 @@ pn53x_idle (nfc_device *pnd)
bool
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' };
byte_t abtRx[sizeof(abtExpectedRx)];
const uint8_t abtCmd[] = { Diagnose, 0x00, 'l', 'i', 'b', 'n', 'f', 'c' };
const uint8_t abtExpectedRx[] = { 0x00, 'l', 'i', 'b', 'n', 'f', 'c' };
uint8_t abtRx[sizeof(abtExpectedRx)];
size_t szRx = sizeof (abtRx);
struct timeval timeout;
@ -858,11 +858,11 @@ pn53x_initiator_init (nfc_device * pnd)
bool
pn53x_initiator_select_passive_target_ext (nfc_device * pnd,
const nfc_modulation nm,
const byte_t * pbtInitData, const size_t szInitData,
const uint8_t * pbtInitData, const size_t szInitData,
nfc_target * pnt,
struct timeval* timeout)
{
byte_t abtTargetsData[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
uint8_t abtTargetsData[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
size_t szTargetsData = sizeof(abtTargetsData);
if (nm.nmt == NMT_ISO14443BI || nm.nmt == NMT_ISO14443B2SR || nm.nmt == NMT_ISO14443B2CT) {
@ -884,11 +884,11 @@ pn53x_initiator_select_passive_target_ext (nfc_device * pnd,
pnd->bEasyFraming = false;
if (nm.nmt == NMT_ISO14443B2SR) {
// Some work to do before getting the UID...
byte_t abtInitiate[]="\x06\x00";
uint8_t abtInitiate[]="\x06\x00";
size_t szInitiateLen = 2;
byte_t abtSelect[]="\x0e\x00";
uint8_t abtSelect[]="\x0e\x00";
size_t szSelectLen = 2;
byte_t abtRx[1];
uint8_t abtRx[1];
size_t szRxLen = 1;
// Getting random Chip_ID
if (!pn53x_initiator_transceive_bytes (pnd, abtInitiate, szInitiateLen, abtRx, &szRxLen, timeout)) {
@ -901,7 +901,7 @@ pn53x_initiator_select_passive_target_ext (nfc_device * pnd,
}
else if (nm.nmt == NMT_ISO14443B2CT) {
// Some work to do before getting the UID...
byte_t abtReqt[]="\x10";
uint8_t abtReqt[]="\x10";
size_t szReqtLen = 1;
// Getting product code / fab code & store it in output buffer after the serial nr we'll obtain later
if (!pn53x_initiator_transceive_bytes (pnd, abtReqt, szReqtLen, abtTargetsData+2, &szTargetsData, timeout) || szTargetsData != 2) {
@ -914,7 +914,7 @@ pn53x_initiator_select_passive_target_ext (nfc_device * pnd,
if (nm.nmt == NMT_ISO14443B2CT) {
if (szTargetsData != 2)
return false;
byte_t abtRead[]="\xC4"; // Reading UID_MSB (Read address 4)
uint8_t abtRead[]="\xC4"; // Reading UID_MSB (Read address 4)
size_t szReadLen = 1;
if (!pn53x_initiator_transceive_bytes (pnd, abtRead, szReadLen, abtTargetsData+4, &szTargetsData, timeout) || szTargetsData != 2) {
return false;
@ -930,7 +930,7 @@ pn53x_initiator_select_passive_target_ext (nfc_device * pnd,
}
if (nm.nmt == NMT_ISO14443BI) {
// Select tag
byte_t abtAttrib[6];
uint8_t abtAttrib[6];
size_t szAttribLen = sizeof(abtAttrib);
memcpy(abtAttrib, abtTargetsData, szAttribLen);
abtAttrib[1] = 0x0f; // ATTRIB
@ -968,7 +968,7 @@ pn53x_initiator_select_passive_target_ext (nfc_device * pnd,
bool
pn53x_initiator_select_passive_target (nfc_device * pnd,
const nfc_modulation nm,
const byte_t * pbtInitData, const size_t szInitData,
const uint8_t * pbtInitData, const size_t szInitData,
nfc_target * pnt)
{
return pn53x_initiator_select_passive_target_ext (pnd, nm, pbtInitData, szInitData, pnt, NULL);
@ -1020,7 +1020,7 @@ pn53x_initiator_poll_target (nfc_device * pnd,
do {
for (size_t p=0; p<uiPollNr; p++) {
for (size_t n=0; n<szModulations; n++) {
byte_t *pbtInitiatorData;
uint8_t *pbtInitiatorData;
size_t szInitiatorData;
prepare_initiator_data (pnmModulations[n], &pbtInitiatorData, &szInitiatorData);
const int timeout_ms = uiPeriod * 150;
@ -1047,8 +1047,8 @@ pn53x_initiator_select_dep_target(nfc_device * pnd,
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;
const uint8_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 uint8_t * pbtPassiveInitiatorData = NULL;
switch (nbr) {
case NBR_212:
@ -1070,14 +1070,14 @@ pn53x_initiator_select_dep_target(nfc_device * pnd,
}
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)
pn53x_initiator_transceive_bits (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTxBits,
const uint8_t * pbtTxPar, uint8_t * pbtRx, size_t * pszRxBits, uint8_t * pbtRxPar)
{
size_t szFrameBits = 0;
size_t szFrameBytes = 0;
uint8_t ui8rcc;
uint8_t ui8Bits = 0;
byte_t abtCmd[PN53x_EXTENDED_FRAME__DATA_MAX_LEN] = { InCommunicateThru };
uint8_t abtCmd[PN53x_EXTENDED_FRAME__DATA_MAX_LEN] = { InCommunicateThru };
// Check if we should prepare the parity bits ourself
if (!pnd->bPar) {
@ -1103,7 +1103,7 @@ pn53x_initiator_transceive_bits (nfc_device * pnd, const byte_t * pbtTx, const s
// Send the frame to the PN53X chip and get the answer
// We have to give the amount of bytes + (the command byte 0x42)
byte_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
uint8_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
size_t szRx = sizeof(abtRx);
if (!pn53x_transceive (pnd, abtCmd, szFrameBytes + 1, abtRx, &szRx, NULL))
return false;
@ -1134,11 +1134,11 @@ pn53x_initiator_transceive_bits (nfc_device * pnd, const byte_t * pbtTx, const s
}
bool
pn53x_initiator_transceive_bytes (nfc_device * pnd, const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx,
pn53x_initiator_transceive_bytes (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTx, uint8_t * pbtRx,
size_t * pszRx, struct timeval *timeout)
{
size_t szExtraTxLen;
byte_t abtCmd[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
uint8_t abtCmd[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
// We can not just send bytes without parity if while the PN53X expects we handled them
if (!pnd->bPar) {
@ -1164,7 +1164,7 @@ pn53x_initiator_transceive_bytes (nfc_device * pnd, const byte_t * pbtTx, const
// Send the frame to the PN53X chip and get the answer
// We have to give the amount of bytes + (the two command bytes 0xD4, 0x42)
byte_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
uint8_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
size_t szRx = sizeof(abtRx);
if (!pn53x_transceive (pnd, abtCmd, szTx + szExtraTxLen, abtRx, &szRx, timeout))
return false;
@ -1262,8 +1262,8 @@ uint32_t __pn53x_get_timer(nfc_device * pnd, const uint8_t last_cmd_byte)
}
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)
pn53x_initiator_transceive_bits_timed (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTxBits,
const uint8_t * pbtTxPar, uint8_t * pbtRx, size_t * pszRxBits, uint8_t * pbtRxPar, uint32_t * cycles)
{
// TODO Do something with these bytes...
(void) pbtTxPar;
@ -1364,7 +1364,7 @@ pn53x_initiator_transceive_bits_timed (nfc_device * pnd, const byte_t * pbtTx, c
}
bool
pn53x_initiator_transceive_bytes_timed (nfc_device * pnd, const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx,
pn53x_initiator_transceive_bytes_timed (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTx, uint8_t * pbtRx,
size_t * pszRx, uint32_t * cycles)
{
uint16_t i;
@ -1475,7 +1475,7 @@ pn53x_initiator_deselect_target (nfc_device * pnd)
#define SAK_ISO14443_4_COMPLIANT 0x20
#define SAK_ISO18092_COMPLIANT 0x40
bool
pn53x_target_init (nfc_device * pnd, nfc_target * pnt, byte_t * pbtRx, size_t * pszRx)
pn53x_target_init (nfc_device * pnd, nfc_target * pnt, uint8_t * pbtRx, size_t * pszRx)
{
pn53x_reset_settings(pnd);
@ -1525,16 +1525,16 @@ pn53x_target_init (nfc_device * pnd, nfc_target * pnt, byte_t * pbtRx, size_t *
if (!pn53x_write_register (pnd, PN53X_REG_CIU_TxAuto, SYMBOL_INITIAL_RF_ON, 0x04))
return false;
byte_t abtMifareParams[6];
byte_t * pbtMifareParams = NULL;
byte_t * pbtTkt = NULL;
uint8_t abtMifareParams[6];
uint8_t * pbtMifareParams = NULL;
uint8_t * pbtTkt = NULL;
size_t szTkt = 0;
byte_t abtFeliCaParams[18];
byte_t * pbtFeliCaParams = NULL;
uint8_t abtFeliCaParams[18];
uint8_t * pbtFeliCaParams = NULL;
const byte_t * pbtNFCID3t = NULL;
const byte_t * pbtGBt = NULL;
const uint8_t * pbtNFCID3t = NULL;
const uint8_t * pbtGBt = NULL;
size_t szGBt = 0;
switch(pnt->nm.nmt) {
@ -1625,7 +1625,7 @@ pn53x_target_init (nfc_device * pnd, nfc_target * pnt, byte_t * pbtRx, size_t *
bool targetActivated = false;
while (!targetActivated) {
byte_t btActivatedMode;
uint8_t btActivatedMode;
if(!pn53x_TgInitAsTarget(pnd, ptm, pbtMifareParams, pbtTkt, szTkt, pbtFeliCaParams, pbtNFCID3t, pbtGBt, szGBt, pbtRx, pszRx, &btActivatedMode)) {
return false;
@ -1696,11 +1696,11 @@ pn53x_target_init (nfc_device * pnd, nfc_target * pnt, byte_t * pbtRx, size_t *
}
bool
pn53x_target_receive_bits (nfc_device * pnd, byte_t * pbtRx, size_t * pszRxBits, byte_t * pbtRxPar)
pn53x_target_receive_bits (nfc_device * pnd, uint8_t * pbtRx, size_t * pszRxBits, uint8_t * pbtRxPar)
{
byte_t abtCmd[] = { TgGetInitiatorCommand };
uint8_t abtCmd[] = { TgGetInitiatorCommand };
byte_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
uint8_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
size_t szRx = sizeof (abtRx);
// Try to gather a received frame from the reader
if (!pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), abtRx, &szRx, NULL))
@ -1731,9 +1731,9 @@ pn53x_target_receive_bits (nfc_device * pnd, byte_t * pbtRx, size_t * pszRxBits,
}
bool
pn53x_target_receive_bytes (nfc_device * pnd, byte_t * pbtRx, size_t * pszRx, struct timeval *timeout)
pn53x_target_receive_bytes (nfc_device * pnd, uint8_t * pbtRx, size_t * pszRx, struct timeval *timeout)
{
byte_t abtCmd[1];
uint8_t abtCmd[1];
// XXX I think this is not a clean way to provide some kind of "EasyFraming"
// but at the moment I have no more better than this
@ -1764,7 +1764,7 @@ pn53x_target_receive_bytes (nfc_device * pnd, byte_t * pbtRx, size_t * pszRx, st
}
// Try to gather a received frame from the reader
byte_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
uint8_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
size_t szRx = sizeof (abtRx);
if (!pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), abtRx, &szRx, timeout))
return false;
@ -1780,12 +1780,12 @@ pn53x_target_receive_bytes (nfc_device * pnd, byte_t * pbtRx, size_t * pszRx, st
}
bool
pn53x_target_send_bits (nfc_device * pnd, const byte_t * pbtTx, const size_t szTxBits, const byte_t * pbtTxPar)
pn53x_target_send_bits (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTxBits, const uint8_t * pbtTxPar)
{
size_t szFrameBits = 0;
size_t szFrameBytes = 0;
uint8_t ui8Bits = 0;
byte_t abtCmd[PN53x_EXTENDED_FRAME__DATA_MAX_LEN] = { TgResponseToInitiator };
uint8_t abtCmd[PN53x_EXTENDED_FRAME__DATA_MAX_LEN] = { TgResponseToInitiator };
// Check if we should prepare the parity bits ourself
if (!pnd->bPar) {
@ -1818,9 +1818,9 @@ pn53x_target_send_bits (nfc_device * pnd, const byte_t * pbtTx, const size_t szT
}
bool
pn53x_target_send_bytes (nfc_device * pnd, const byte_t * pbtTx, const size_t szTx, struct timeval *timeout)
pn53x_target_send_bytes (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTx, struct timeval *timeout)
{
byte_t abtCmd[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
uint8_t abtCmd[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
// We can not just send bytes without parity if while the PN53X expects we handled them
if (!pnd->bPar)
@ -1935,14 +1935,14 @@ pn53x_strerror (const nfc_device * pnd)
bool
pn53x_RFConfiguration__RF_field (nfc_device * pnd, bool bEnable)
{
byte_t abtCmd[] = { RFConfiguration, RFCI_FIELD, (bEnable) ? 0x01 : 0x00 };
uint8_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 * pnd, const uint8_t fATR_RES_Timeout, const uint8_t fRetryTimeout)
{
byte_t abtCmd[] = {
uint8_t abtCmd[] = {
RFConfiguration,
RFCI_TIMING,
0x00, // RFU
@ -1955,7 +1955,7 @@ pn53x_RFConfiguration__Various_timings (nfc_device * pnd, const uint8_t fATR_RES
bool
pn53x_RFConfiguration__MaxRtyCOM (nfc_device * pnd, const uint8_t MaxRtyCOM)
{
byte_t abtCmd[] = {
uint8_t abtCmd[] = {
RFConfiguration,
RFCI_RETRY_DATA,
MaxRtyCOM // MaxRtyCOM, default: 0x00 (no retry, only one try), inifite: 0xff
@ -1967,7 +1967,7 @@ bool
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[] = {
uint8_t abtCmd[] = {
RFConfiguration,
RFCI_RETRY_SELECT,
MxRtyATR, // MxRtyATR, default: active = 0xff, passive = 0x02
@ -1980,7 +1980,7 @@ pn53x_RFConfiguration__MaxRetries (nfc_device * pnd, const uint8_t MxRtyATR, con
bool
pn53x_SetParameters (nfc_device * pnd, const uint8_t ui8Value)
{
byte_t abtCmd[] = { SetParameters, ui8Value };
uint8_t abtCmd[] = { SetParameters, ui8Value };
if(!pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, NULL)) {
return false;
@ -1993,7 +1993,7 @@ pn53x_SetParameters (nfc_device * pnd, const uint8_t ui8Value)
bool
pn53x_SAMConfiguration (nfc_device * pnd, const pn532_sam_mode ui8Mode, struct timeval *timeout)
{
byte_t abtCmd[] = { SAMConfiguration, ui8Mode, 0x00, 0x00 };
uint8_t abtCmd[] = { SAMConfiguration, ui8Mode, 0x00, 0x00 };
size_t szCmd = sizeof(abtCmd);
if (CHIP_DATA(pnd)->type != PN532) {
@ -2022,7 +2022,7 @@ pn53x_SAMConfiguration (nfc_device * pnd, const pn532_sam_mode ui8Mode, struct t
bool
pn53x_PowerDown (nfc_device * pnd)
{
byte_t abtCmd[] = { PowerDown, 0xf0 };
uint8_t abtCmd[] = { PowerDown, 0xf0 };
return (pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, NULL));
}
@ -2042,12 +2042,12 @@ 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 szInitiatorData,
byte_t * pbtTargetsData, size_t * pszTargetsData,
const pn53x_modulation pmInitModulation, const uint8_t szMaxTargets,
const uint8_t * pbtInitiatorData, const size_t szInitiatorData,
uint8_t * pbtTargetsData, size_t * pszTargetsData,
struct timeval* timeout)
{
byte_t abtCmd[15] = { InListPassiveTarget };
uint8_t abtCmd[15] = { InListPassiveTarget };
abtCmd[1] = szMaxTargets; // MaxTg
@ -2098,9 +2098,9 @@ 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
byte_t abtStatus[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
uint8_t abtStatus[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
size_t szStatus = sizeof(abtStatus);
byte_t abtCmdGetStatus[] = { GetGeneralStatus };
uint8_t abtCmdGetStatus[] = { GetGeneralStatus };
if (!pn53x_transceive (pnd, abtCmdGetStatus, sizeof (abtCmdGetStatus), abtStatus, &szStatus, NULL)) {
return false;
}
@ -2108,10 +2108,10 @@ pn53x_InDeselect (nfc_device * pnd, const uint8_t ui8Target)
return true;
}
// No much choice what to deselect actually...
byte_t abtCmdRcs360[] = { InDeselect, 0x01, 0x01 };
uint8_t abtCmdRcs360[] = { InDeselect, 0x01, 0x01 };
return (pn53x_transceive (pnd, abtCmdRcs360, sizeof (abtCmdRcs360), NULL, NULL, NULL));
}
byte_t abtCmd[] = { InDeselect, ui8Target };
uint8_t abtCmd[] = { InDeselect, ui8Target };
return (pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, NULL));
}
@ -2120,9 +2120,9 @@ 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
byte_t abtStatus[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
uint8_t abtStatus[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
size_t szStatus = sizeof(abtStatus);
byte_t abtCmdGetStatus[] = { GetGeneralStatus };
uint8_t abtCmdGetStatus[] = { GetGeneralStatus };
if (!pn53x_transceive (pnd, abtCmdGetStatus, sizeof (abtCmdGetStatus), abtStatus, &szStatus, NULL)) {
return false;
}
@ -2130,17 +2130,17 @@ pn53x_InRelease (nfc_device * pnd, const uint8_t ui8Target)
return true;
}
// No much choice what to release actually...
byte_t abtCmdRcs360[] = { InRelease, 0x01, 0x01 };
uint8_t abtCmdRcs360[] = { InRelease, 0x01, 0x01 };
return (pn53x_transceive (pnd, abtCmdRcs360, sizeof (abtCmdRcs360), NULL, NULL, NULL));
}
byte_t abtCmd[] = { InRelease, ui8Target };
uint8_t abtCmd[] = { InRelease, ui8Target };
return (pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, NULL));
}
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)
const uint8_t btPollNr, const uint8_t btPeriod, nfc_target * pntTargets, size_t * pszTargetFound)
{
if (CHIP_DATA(pnd)->type != PN532) {
// This function is not supported by pn531 neither pn533
@ -2150,12 +2150,12 @@ pn53x_InAutoPoll (nfc_device * pnd,
// InAutoPoll frame looks like this { 0xd4, 0x60, 0x0f, 0x01, 0x00 } => { direction, command, pollnr, period, types... }
size_t szTxInAutoPoll = 3 + szTargetTypes;
byte_t abtCmd[3+15] = { InAutoPoll, btPollNr, btPeriod };
uint8_t abtCmd[3+15] = { InAutoPoll, btPollNr, btPeriod };
for (size_t n = 0; n < szTargetTypes; n++) {
abtCmd[3 + n] = ppttTargetTypes[n];
}
byte_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
uint8_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
size_t szRx = sizeof(abtRx);
bool res = pn53x_transceive (pnd, abtCmd, szTxInAutoPoll, abtRx, &szRx, NULL);
@ -2165,7 +2165,7 @@ pn53x_InAutoPoll (nfc_device * pnd,
*pszTargetFound = abtRx[0];
if (*pszTargetFound) {
uint8_t ln;
byte_t *pbt = abtRx + 1;
uint8_t *pbt = abtRx + 1;
/* 1st target */
// Target type
pn53x_target_type ptt = *(pbt++);
@ -2203,13 +2203,13 @@ 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 * pbtGBi, const size_t szGBi,
const uint8_t * pbtPassiveInitiatorData,
const uint8_t * pbtNFCID3i,
const uint8_t * pbtGBi, const size_t szGBi,
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 };
uint8_t abtCmd[67] = { InJumpForDEP, (ndm == NDM_ACTIVE) ? 0x01 : 0x00 };
size_t offset = 4; // 1 byte for command, 1 byte for DEP mode (Active/Passive), 1 byte for baud rate, 1 byte for following parameters flag
@ -2263,7 +2263,7 @@ pn53x_InJumpForDEP (nfc_device * pnd,
offset += szGBi;
}
byte_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
uint8_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
size_t szRx = sizeof (abtRx);
// Try to find a target, call the transceive callback function of the current device
if (!pn53x_transceive (pnd, abtCmd, offset, abtRx, &szRx, NULL))
@ -2295,13 +2295,13 @@ pn53x_InJumpForDEP (nfc_device * pnd,
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,
const byte_t * pbtNFCID3t, const byte_t * pbtGBt, const size_t szGBt,
byte_t * pbtRx, size_t * pszRx, byte_t * pbtModeByte)
const uint8_t * pbtMifareParams,
const uint8_t * pbtTkt, size_t szTkt,
const uint8_t * pbtFeliCaParams,
const uint8_t * pbtNFCID3t, const uint8_t * pbtGBt, const size_t szGBt,
uint8_t * pbtRx, size_t * pszRx, uint8_t * pbtModeByte)
{
byte_t abtCmd[39 + 47 + 48] = { TgInitAsTarget }; // Worst case: 39-byte base, 47 bytes max. for General Bytes, 48 bytes max. for Historical Bytes
uint8_t abtCmd[39 + 47 + 48] = { TgInitAsTarget }; // Worst case: 39-byte base, 47 bytes max. for General Bytes, 48 bytes max. for Historical Bytes
size_t szOptionalBytes = 0;
// Clear the target init struct, reset to all zeros
@ -2329,7 +2329,7 @@ pn53x_TgInitAsTarget (nfc_device * pnd, pn53x_target_mode ptm,
szOptionalBytes = szGBt;
}
} else {
abtCmd[36] = (byte_t)(szGBt);
abtCmd[36] = (uint8_t)(szGBt);
if (szGBt) {
memcpy (abtCmd+37, pbtGBt, szGBt);
}
@ -2337,7 +2337,7 @@ pn53x_TgInitAsTarget (nfc_device * pnd, pn53x_target_mode ptm,
}
// Historical bytes (ISO/IEC 14443-4)
if ((CHIP_DATA(pnd)->type != PN531) && (CHIP_DATA(pnd)->type != RCS360)) { // PN531 does not handle Historical Bytes
abtCmd[36+szOptionalBytes] = (byte_t)(szTkt);
abtCmd[36+szOptionalBytes] = (uint8_t)(szTkt);
if (szTkt) {
memcpy (abtCmd+37+szOptionalBytes, pbtTkt, szTkt);
}
@ -2345,7 +2345,7 @@ pn53x_TgInitAsTarget (nfc_device * pnd, pn53x_target_mode ptm,
}
// Request the initialization as a target
byte_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
uint8_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
size_t szRx = sizeof (abtRx);
if (!pn53x_transceive (pnd, abtCmd, 36 + szOptionalBytes, abtRx, &szRx, NULL))
return false;
@ -2365,7 +2365,7 @@ pn53x_TgInitAsTarget (nfc_device * pnd, pn53x_target_mode ptm,
}
bool
pn53x_check_ack_frame (nfc_device * pnd, const byte_t * pbtRxFrame, const size_t szRxFrameLen)
pn53x_check_ack_frame (nfc_device * pnd, const uint8_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 * pnd, const byte_t * pbtRxFrame, const size_t
}
bool
pn53x_check_error_frame (nfc_device * pnd, const byte_t * pbtRxFrame, const size_t szRxFrameLen)
pn53x_check_error_frame (nfc_device * pnd, const uint8_t * pbtRxFrame, const size_t szRxFrameLen)
{
if (szRxFrameLen >= sizeof (pn53x_error_frame)) {
if (0 == memcmp (pbtRxFrame, pn53x_error_frame, sizeof (pn53x_error_frame))) {
@ -2398,7 +2398,7 @@ pn53x_check_error_frame (nfc_device * pnd, const byte_t * pbtRxFrame, const size
* @note The first byte of pbtData is the Command Code (CC)
*/
bool
pn53x_build_frame (byte_t * pbtFrame, size_t * pszFrame, const byte_t * pbtData, const size_t szData)
pn53x_build_frame (uint8_t * pbtFrame, size_t * pszFrame, const uint8_t * pbtData, const size_t szData)
{
if (szData <= PN53x_NORMAL_FRAME__DATA_MAX_LEN) {
// LEN - Packet length = data length (len) + checksum (1) + end of stream marker (1)
@ -2411,7 +2411,7 @@ pn53x_build_frame (byte_t * pbtFrame, size_t * pszFrame, const byte_t * pbtData,
memcpy (pbtFrame + 6, pbtData, szData);
// DCS - Calculate data payload checksum
byte_t btDCS = (256 - 0xD4);
uint8_t btDCS = (256 - 0xD4);
for (size_t szPos = 0; szPos < szData; szPos++) {
btDCS -= pbtData[szPos];
}
@ -2437,7 +2437,7 @@ pn53x_build_frame (byte_t * pbtFrame, size_t * pszFrame, const byte_t * pbtData,
memcpy (pbtFrame + 9, pbtData, szData);
// DCS - Calculate data payload checksum
byte_t btDCS = (256 - 0xD4);
uint8_t btDCS = (256 - 0xD4);
for (size_t szPos = 0; szPos < szData; szPos++) {
btDCS -= pbtData[szPos];
}

View file

@ -127,8 +127,8 @@ typedef enum {
} pn53x_operating_mode;
struct pn53x_io {
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);
bool (*send)(nfc_device * pnd, const uint8_t * pbtData, const size_t szData, struct timeval *timeout);
int (*receive)(nfc_device * pnd, uint8_t * pbtData, const size_t szDataLen, struct timeval *timeout);
};
/* defines */
@ -252,19 +252,19 @@ typedef enum {
PTM_ISO14443_4_PICC_ONLY = 0x04
} pn53x_target_mode;
extern const byte_t pn53x_ack_frame[6];
extern const byte_t pn53x_nack_frame[6];
extern const uint8_t pn53x_ack_frame[6];
extern const uint8_t pn53x_nack_frame[6];
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_transceive (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTx, uint8_t * pbtRx, size_t *pszRx, struct timeval *timeout);
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,
bool pn53x_wrap_frame (const uint8_t * pbtTx, const size_t szTxBits, const uint8_t * pbtTxPar, uint8_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,
bool pn53x_unwrap_frame (const uint8_t * pbtFrame, const size_t szFrameBits, uint8_t * pbtRx, size_t * pszRxBits,
uint8_t * pbtRxPar);
bool pn53x_decode_target_data (const uint8_t * pbtRawData, size_t szRawData,
pn53x_type chip_type, nfc_modulationype nmt,
nfc_target_info * pnti);
bool pn53x_read_register (nfc_device * pnd, uint16_t ui16Reg, uint8_t * ui8Value);
@ -278,7 +278,7 @@ bool pn53x_idle (nfc_device * pnd);
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,
const uint8_t * pbtInitData, const size_t szInitData,
nfc_target * pnt);
bool pn53x_initiator_poll_target (nfc_device * pnd,
const nfc_modulation * pnmModulations, const size_t szModulations,
@ -288,24 +288,24 @@ 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 * 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 * 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 * pnd, const byte_t * pbtTx, const size_t szTx,
byte_t * pbtRx, size_t * pszRx, uint32_t * cycles);
bool pn53x_initiator_transceive_bits (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTxBits,
const uint8_t * pbtTxPar, uint8_t * pbtRx, size_t * pszRxBits,
uint8_t * pbtRxPar);
bool pn53x_initiator_transceive_bytes (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTx,
uint8_t * pbtRx, size_t * pszRx, struct timeval *timeout);
bool pn53x_initiator_transceive_bits_timed (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTxBits,
const uint8_t * pbtTxPar, uint8_t * pbtRx, size_t * pszRxBits,
uint8_t * pbtRxPar, uint32_t * cycles);
bool pn53x_initiator_transceive_bytes_timed (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTx,
uint8_t * pbtRx, size_t * pszRx, uint32_t * cycles);
bool pn53x_initiator_deselect_target (nfc_device * pnd);
// NFC device as Target functions
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);
bool pn53x_target_init (nfc_device * pnd, nfc_target * pnt, uint8_t * pbtRx, size_t * pszRx);
bool pn53x_target_receive_bits (nfc_device * pnd, uint8_t * pbtRx, size_t * pszRxBits, uint8_t * pbtRxPar);
bool pn53x_target_receive_bytes (nfc_device * pnd, uint8_t * pbtRx, size_t * pszRx, struct timeval *timeout);
bool pn53x_target_send_bits (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTxBits, const uint8_t * pbtTxPar);
bool pn53x_target_send_bytes (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTx, struct timeval *timeout);
// Error handling functions
const char *pn53x_strerror (const nfc_device * pnd);
@ -315,26 +315,26 @@ 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,
const uint8_t szMaxTargets, const uint8_t * pbtInitiatorData,
const size_t szInitiatorDataLen, uint8_t * pbtTargetsData, size_t * pszTargetsData,
struct timeval *timeout);
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,
const uint8_t btPollNr, const uint8_t btPeriod, nfc_target * pntTargets,
size_t * pszTargetFound);
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,
const uint8_t * pbtPassiveInitiatorData,
const uint8_t * pbtNFCID3i,
const uint8_t * pbtGB, const size_t szGB,
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,
const byte_t * pbtNFCID3t, const byte_t * pbtGB, const size_t szGB,
byte_t * pbtRx, size_t * pszRx, byte_t * pbtModeByte);
const uint8_t * pbtMifareParams,
const uint8_t * pbtTkt, size_t szTkt,
const uint8_t * pbtFeliCaParams,
const uint8_t * pbtNFCID3t, const uint8_t * pbtGB, const size_t szGB,
uint8_t * pbtRx, size_t * pszRx, uint8_t * pbtModeByte);
// RFConfiguration
bool pn53x_RFConfiguration__RF_field (nfc_device * pnd, bool bEnable);
@ -343,9 +343,9 @@ bool pn53x_RFConfiguration__MaxRtyCOM (nfc_device * pnd, const uint8_t MaxRty
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 * 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);
bool pn53x_check_ack_frame (nfc_device * pnd, const uint8_t * pbtRxFrame, const size_t szRxFrameLen);
bool pn53x_check_error_frame (nfc_device * pnd, const uint8_t * pbtRxFrame, const size_t szRxFrameLen);
bool pn53x_build_frame (uint8_t * pbtFrame, size_t * pszFrame, const uint8_t * pbtData, const size_t szData);
void pn53x_data_new (nfc_device * pnd, const struct pn53x_io* io);
void pn53x_data_free (nfc_device * pnd);

View file

@ -89,7 +89,7 @@ const char *supported_devices[] = {
struct acr122_data {
SCARDHANDLE hCard;
SCARD_IO_REQUEST ioCard;
byte_t abtRx[ACR122_RESPONSE_LEN];
uint8_t abtRx[ACR122_RESPONSE_LEN];
size_t szRx;
};
@ -310,7 +310,7 @@ acr122_disconnect (nfc_device * pnd)
}
bool
acr122_send (nfc_device * pnd, const byte_t * pbtData, const size_t szData, struct timeval *timeout)
acr122_send (nfc_device * pnd, const uint8_t * pbtData, const size_t szData, struct timeval *timeout)
{
// FIXME: timeout is not handled
(void) timeout;
@ -323,7 +323,7 @@ acr122_send (nfc_device * pnd, const byte_t * pbtData, const size_t szData, stru
// Prepare and transmit the send buffer
const size_t szTxBuf = szData + 6;
byte_t abtTxBuf[ACR122_WRAP_LEN + ACR122_COMMAND_LEN] = { 0xFF, 0x00, 0x00, 0x00, szData + 1, 0xD4 };
uint8_t abtTxBuf[ACR122_WRAP_LEN + ACR122_COMMAND_LEN] = { 0xFF, 0x00, 0x00, 0x00, szData + 1, 0xD4 };
memcpy (abtTxBuf + 6, pbtData, szData);
LOG_HEX ("TX", abtTxBuf, szTxBuf);
@ -381,13 +381,13 @@ acr122_send (nfc_device * pnd, const byte_t * pbtData, const size_t szData, stru
}
int
acr122_receive (nfc_device * pnd, byte_t * pbtData, const size_t szData, struct timeval *timeout)
acr122_receive (nfc_device * pnd, uint8_t * pbtData, const size_t szData, struct timeval *timeout)
{
// FIXME: timeout is not handled
(void) timeout;
int len;
byte_t abtRxCmd[5] = { 0xFF, 0xC0, 0x00, 0x00 };
uint8_t abtRxCmd[5] = { 0xFF, 0xC0, 0x00, 0x00 };
if (DRIVER_DATA (pnd)->ioCard.dwProtocol == SCARD_PROTOCOL_T0) {
/*
@ -424,16 +424,16 @@ acr122_receive (nfc_device * pnd, byte_t * pbtData, const size_t szData, struct
char *
acr122_firmware (nfc_device *pnd)
{
byte_t abtGetFw[5] = { 0xFF, 0x00, 0x48, 0x00, 0x00 };
uint8_t abtGetFw[5] = { 0xFF, 0x00, 0x48, 0x00, 0x00 };
uint32_t uiResult;
static char abtFw[11];
DWORD dwFwLen = sizeof (abtFw);
memset (abtFw, 0x00, sizeof (abtFw));
if (DRIVER_DATA (pnd)->ioCard.dwProtocol == SCARD_PROTOCOL_UNDEFINED) {
uiResult = SCardControl (DRIVER_DATA (pnd)->hCard, IOCTL_CCID_ESCAPE_SCARD_CTL_CODE, abtGetFw, sizeof (abtGetFw), (byte_t *) abtFw, dwFwLen-1, &dwFwLen);
uiResult = SCardControl (DRIVER_DATA (pnd)->hCard, IOCTL_CCID_ESCAPE_SCARD_CTL_CODE, abtGetFw, sizeof (abtGetFw), (uint8_t *) abtFw, dwFwLen-1, &dwFwLen);
} else {
uiResult = SCardTransmit (DRIVER_DATA (pnd)->hCard, &(DRIVER_DATA (pnd)->ioCard), abtGetFw, sizeof (abtGetFw), NULL, (byte_t *) abtFw, &dwFwLen);
uiResult = SCardTransmit (DRIVER_DATA (pnd)->hCard, &(DRIVER_DATA (pnd)->ioCard), abtGetFw, sizeof (abtGetFw), NULL, (uint8_t *) abtFw, &dwFwLen);
}
if (uiResult != SCARD_S_SUCCESS) {
@ -447,8 +447,8 @@ acr122_firmware (nfc_device *pnd)
bool
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];
uint8_t abtLed[9] = { 0xFF, 0x00, 0x40, 0x05, 0x04, 0x00, 0x00, 0x00, 0x00 };
uint8_t abtBuf[2];
DWORD dwBufLen = sizeof (abtBuf);
(void) bOn;
if (DRIVER_DATA (pnd)->ioCard.dwProtocol == SCARD_PROTOCOL_UNDEFINED) {

View file

@ -30,8 +30,8 @@ bool acr122_probe (nfc_connstring connstrings[], size_t connstrings_len, size
// Functions used by developer to handle connection to this device
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);
bool acr122_send (nfc_device * pnd, const uint8_t * pbtData, const size_t szData, struct timeval *timeout);
int acr122_receive (nfc_device * pnd, uint8_t * pbtData, const size_t szData, struct timeval *timeout);
void acr122_disconnect (nfc_device * pnd);
extern const struct nfc_driver_t acr122_driver;

View file

@ -84,9 +84,9 @@ struct arygon_data {
#endif
};
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";
static const uint8_t arygon_error_none[] = "FF000000\x0d\x0a";
static const uint8_t arygon_error_incomplete_command[] = "FF0C0000\x0d\x0a";
static const uint8_t arygon_error_unknown_mode[] = "FF060000\x0d\x0a";
bool arygon_reset_tama (nfc_device * pnd);
void arygon_firmware (nfc_device * pnd, char * str);
@ -304,12 +304,12 @@ arygon_disconnect (nfc_device * 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 * pnd, const byte_t * pbtData, const size_t szData, struct timeval *timeout)
arygon_tama_send (nfc_device * pnd, const uint8_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);
byte_t abtFrame[ARYGON_TX_BUFFER_LEN] = { DEV_ARYGON_PROTOCOL_TAMA, 0x00, 0x00, 0xff }; // Every packet must start with "0x32 0x00 0x00 0xff"
uint8_t abtFrame[ARYGON_TX_BUFFER_LEN] = { DEV_ARYGON_PROTOCOL_TAMA, 0x00, 0x00, 0xff }; // Every packet must start with "0x32 0x00 0x00 0xff"
size_t szFrame = 0;
if (szData > PN53x_NORMAL_FRAME__DATA_MAX_LEN) {
@ -331,7 +331,7 @@ arygon_tama_send (nfc_device * pnd, const byte_t * pbtData, const size_t szData,
return false;
}
byte_t abtRxBuf[6];
uint8_t abtRxBuf[6];
res = uart_receive (DRIVER_DATA (pnd)->port, abtRxBuf, sizeof (abtRxBuf), 0, timeout);
if (res != 0) {
log_put (LOG_CATEGORY, NFC_PRIORITY_ERROR, "%s", "Unable to read ACK");
@ -357,7 +357,7 @@ int
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 };
uint8_t dummy[] = { 0x32, 0x00, 0x00, 0xff, 0x09, 0xf7, 0xd4, 0x00, 0x00, 0x6c, 0x69, 0x62, 0x6e, 0x66, 0x63, 0xbe, 0x00 };
uart_send (DRIVER_DATA (pnd)->port, dummy, sizeof (dummy), NULL);
@ -366,9 +366,9 @@ arygon_abort (nfc_device *pnd)
}
int
arygon_tama_receive (nfc_device * pnd, byte_t * pbtData, const size_t szDataLen, struct timeval *timeout)
arygon_tama_receive (nfc_device * pnd, uint8_t * pbtData, const size_t szDataLen, struct timeval *timeout)
{
byte_t abtRxBuf[5];
uint8_t abtRxBuf[5];
size_t len;
void * abort_p = NULL;
@ -393,7 +393,7 @@ arygon_tama_receive (nfc_device * pnd, byte_t * pbtData, const size_t szDataLen,
return -1;
}
const byte_t pn53x_preamble[3] = { 0x00, 0x00, 0xff };
const uint8_t pn53x_preamble[3] = { 0x00, 0x00, 0xff };
if (0 != (memcmp (abtRxBuf, pn53x_preamble, 3))) {
log_put (LOG_CATEGORY, NFC_PRIORITY_ERROR, "%s", "Frame preamble+start code mismatch");
pnd->iLastError = ECOMIO;
@ -462,7 +462,7 @@ arygon_tama_receive (nfc_device * pnd, byte_t * pbtData, const size_t szDataLen,
return -1;
}
byte_t btDCS = (256 - 0xD5);
uint8_t btDCS = (256 - 0xD5);
btDCS -= CHIP_DATA (pnd)->ui8LastCommand + 1;
for (size_t szPos = 0; szPos < len; szPos++) {
btDCS -= pbtData[szPos];
@ -486,8 +486,8 @@ arygon_tama_receive (nfc_device * pnd, byte_t * pbtData, const size_t szDataLen,
void
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];
const uint8_t arygon_firmware_version_cmd[] = { DEV_ARYGON_PROTOCOL_ARYGON_ASCII, 'a', 'v' };
uint8_t abtRx[16];
size_t szRx = sizeof(abtRx);
@ -503,7 +503,7 @@ arygon_firmware (nfc_device * pnd, char * str)
}
if ( 0 == memcmp (abtRx, arygon_error_none, 6)) {
byte_t * p = abtRx + 6;
uint8_t * p = abtRx + 6;
unsigned int szData;
sscanf ((const char*)p, "%02x%s", &szData, p);
memcpy (str, p, szData);
@ -514,8 +514,8 @@ arygon_firmware (nfc_device * pnd, char * str)
bool
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
const uint8_t arygon_reset_tama_cmd[] = { DEV_ARYGON_PROTOCOL_ARYGON_ASCII, 'a', 'r' };
uint8_t abtRx[10]; // Attempted response is 10 bytes long
size_t szRx = sizeof(abtRx);
int res;

View file

@ -35,8 +35,8 @@ bool arygon_probe (nfc_connstring connstrings[], size_t connstrings_len, size
nfc_device *arygon_connect (const nfc_connstring connstring);
void arygon_disconnect (nfc_device * pnd);
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);
bool arygon_tama_send (nfc_device * pnd, const uint8_t * pbtData, const size_t szData, struct timeval *timeout);
int arygon_tama_receive (nfc_device * pnd, uint8_t * pbtData, const size_t szDat, struct timeval *timeouta);
extern const struct nfc_driver_t arygon_driver;

View file

@ -281,7 +281,7 @@ int
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 };
const uint8_t pn532_wakeup_preamble[] = { 0x55, 0x55, 0x00, 0x00, 0x00 };
int res = uart_send (DRIVER_DATA(pnd)->port, pn532_wakeup_preamble, sizeof (pn532_wakeup_preamble), NULL);
CHIP_DATA(pnd)->power_mode = NORMAL; // PN532 should now be awake
return res;
@ -289,7 +289,7 @@ pn532_uart_wakeup (nfc_device * pnd)
#define PN532_BUFFER_LEN (PN53x_EXTENDED_FRAME__DATA_MAX_LEN + PN53x_EXTENDED_FRAME__OVERHEAD)
bool
pn532_uart_send (nfc_device * pnd, const byte_t * pbtData, const size_t szData, struct timeval *timeout)
pn532_uart_send (nfc_device * pnd, const uint8_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);
@ -320,7 +320,7 @@ pn532_uart_send (nfc_device * pnd, const byte_t * pbtData, const size_t szData,
break;
};
byte_t abtFrame[PN532_BUFFER_LEN] = { 0x00, 0x00, 0xff }; // Every packet must start with "00 00 ff"
uint8_t abtFrame[PN532_BUFFER_LEN] = { 0x00, 0x00, 0xff }; // Every packet must start with "00 00 ff"
size_t szFrame = 0;
if (!pn53x_build_frame (abtFrame, &szFrame, pbtData, szData)) {
@ -335,7 +335,7 @@ pn532_uart_send (nfc_device * pnd, const byte_t * pbtData, const size_t szData,
return false;
}
byte_t abtRxBuf[6];
uint8_t abtRxBuf[6];
res = uart_receive (DRIVER_DATA(pnd)->port, abtRxBuf, 6, 0, timeout);
if (res != 0) {
log_put (LOG_CATEGORY, NFC_PRIORITY_ERROR, "%s", "Unable to read ACK");
@ -352,9 +352,9 @@ pn532_uart_send (nfc_device * pnd, const byte_t * pbtData, const size_t szData,
}
int
pn532_uart_receive (nfc_device * pnd, byte_t * pbtData, const size_t szDataLen, struct timeval *timeout)
pn532_uart_receive (nfc_device * pnd, uint8_t * pbtData, const size_t szDataLen, struct timeval *timeout)
{
byte_t abtRxBuf[5];
uint8_t abtRxBuf[5];
size_t len;
void * abort_p = NULL;
@ -376,7 +376,7 @@ pn532_uart_receive (nfc_device * pnd, byte_t * pbtData, const size_t szDataLen,
return -1;
}
const byte_t pn53x_preamble[3] = { 0x00, 0x00, 0xff };
const uint8_t pn53x_preamble[3] = { 0x00, 0x00, 0xff };
if (0 != (memcmp (abtRxBuf, pn53x_preamble, 3))) {
log_put (LOG_CATEGORY, NFC_PRIORITY_ERROR, "%s", "Frame preamble+start code mismatch");
pnd->iLastError = ECOMIO;
@ -454,7 +454,7 @@ pn532_uart_receive (nfc_device * pnd, byte_t * pbtData, const size_t szDataLen,
return -1;
}
byte_t btDCS = (256 - 0xD5);
uint8_t btDCS = (256 - 0xD5);
btDCS -= CHIP_DATA (pnd)->ui8LastCommand + 1;
for (size_t szPos = 0; szPos < len; szPos++) {
btDCS -= pbtData[szPos];

View file

@ -33,8 +33,8 @@ bool pn532_uart_probe (nfc_connstring connstrings[], size_t connstrings_len,
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);
bool pn532_uart_send (nfc_device * pnd, const uint8_t * pbtData, const size_t szData, struct timeval *timeout);
int pn532_uart_receive (nfc_device * pnd, uint8_t * pbtData, const size_t szData, struct timeval *timeout);
extern const struct nfc_driver_t pn532_uart_driver;

View file

@ -121,7 +121,7 @@ bool pn53x_usb_get_usb_device_name (struct usb_device *dev, usb_dev_handle *udev
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)
pn53x_usb_bulk_read (struct pn53x_usb_data *data, uint8_t abtRx[], const size_t szRx, struct timeval *timeout)
{
int timeout_ms = USB_INFINITE_TIMEOUT;
if (timeout) {
@ -143,7 +143,7 @@ pn53x_usb_bulk_read (struct pn53x_usb_data *data, byte_t abtRx[], const size_t s
}
int
pn53x_usb_bulk_write (struct pn53x_usb_data *data, byte_t abtTx[], const size_t szTx, struct timeval *timeout)
pn53x_usb_bulk_write (struct pn53x_usb_data *data, uint8_t abtTx[], const size_t szTx, struct timeval *timeout)
{
LOG_HEX ("TX", abtTx, szTx);
int timeout_ms = USB_INFINITE_TIMEOUT;
@ -519,9 +519,9 @@ pn53x_usb_disconnect (nfc_device * pnd)
#define PN53X_USB_BUFFER_LEN (PN53x_EXTENDED_FRAME__DATA_MAX_LEN + PN53x_EXTENDED_FRAME__OVERHEAD)
bool
pn53x_usb_send (nfc_device * pnd, const byte_t * pbtData, const size_t szData, struct timeval *timeout)
pn53x_usb_send (nfc_device * pnd, const uint8_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"
uint8_t abtFrame[PN53X_USB_BUFFER_LEN] = { 0x00, 0x00, 0xff }; // Every packet must start with "00 00 ff"
size_t szFrame = 0;
pn53x_build_frame (abtFrame, &szFrame, pbtData, szData);
@ -533,7 +533,7 @@ pn53x_usb_send (nfc_device * pnd, const byte_t * pbtData, const size_t szData, s
return false;
}
byte_t abtRxBuf[PN53X_USB_BUFFER_LEN];
uint8_t abtRxBuf[PN53X_USB_BUFFER_LEN];
res = pn53x_usb_bulk_read (DRIVER_DATA (pnd), abtRxBuf, sizeof (abtRxBuf), timeout);
if (res < 0) {
pnd->iLastError = ECOMIO;
@ -552,7 +552,7 @@ pn53x_usb_send (nfc_device * pnd, const byte_t * pbtData, const size_t szData, s
// pn53x_usb_receive()) will be able to retreive the correct response
// packet.
// FIXME Sony reader is also affected by this bug but NACK is not supported
int res = pn53x_usb_bulk_write (DRIVER_DATA (pnd), (byte_t *)pn53x_nack_frame, sizeof(pn53x_nack_frame), timeout);
int res = pn53x_usb_bulk_write (DRIVER_DATA (pnd), (uint8_t *)pn53x_nack_frame, sizeof(pn53x_nack_frame), timeout);
if (res < 0) {
pnd->iLastError = ECOMIO;
// try to interrupt current device state
@ -565,12 +565,12 @@ pn53x_usb_send (nfc_device * pnd, const byte_t * pbtData, const size_t szData, s
}
int
pn53x_usb_receive (nfc_device * pnd, byte_t * pbtData, const size_t szDataLen, struct timeval *timeout)
pn53x_usb_receive (nfc_device * pnd, uint8_t * pbtData, const size_t szDataLen, struct timeval *timeout)
{
size_t len;
off_t offset = 0;
byte_t abtRxBuf[PN53X_USB_BUFFER_LEN];
uint8_t abtRxBuf[PN53X_USB_BUFFER_LEN];
int res;
/*
@ -627,7 +627,7 @@ read:
return -1;
}
const byte_t pn53x_preamble[3] = { 0x00, 0x00, 0xff };
const uint8_t pn53x_preamble[3] = { 0x00, 0x00, 0xff };
if (0 != (memcmp (abtRxBuf, pn53x_preamble, 3))) {
log_put (LOG_CATEGORY, NFC_PRIORITY_ERROR, "%s", "Frame preamble+start code mismatch");
pnd->iLastError = ECOMIO;
@ -691,7 +691,7 @@ read:
memcpy (pbtData, abtRxBuf + offset, len);
offset += len;
byte_t btDCS = (256 - 0xD5);
uint8_t btDCS = (256 - 0xD5);
btDCS -= CHIP_DATA (pnd)->ui8LastCommand + 1;
for (size_t szPos = 0; szPos < len; szPos++) {
btDCS -= pbtData[szPos];
@ -717,7 +717,7 @@ read:
int
pn53x_usb_ack (nfc_device * pnd)
{
return pn53x_usb_bulk_write (DRIVER_DATA (pnd), (byte_t *) pn53x_ack_frame, sizeof (pn53x_ack_frame), NULL);
return pn53x_usb_bulk_write (DRIVER_DATA (pnd), (uint8_t *) pn53x_ack_frame, sizeof (pn53x_ack_frame), NULL);
}
bool
@ -725,13 +725,13 @@ 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:
const byte_t abtCmd[] = { GetFirmwareVersion };
const uint8_t abtCmd[] = { GetFirmwareVersion };
pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, NULL);
// ...and we don't care about error
pnd->iLastError = 0;
if (SONY_RCS360 == DRIVER_DATA (pnd)->model) {
log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "SONY RC-S360 initialization.");
const byte_t abtCmd2[] = { 0x18, 0x01 };
const uint8_t abtCmd2[] = { 0x18, 0x01 };
pn53x_transceive (pnd, abtCmd2, sizeof (abtCmd2), NULL, NULL, NULL);
pn53x_usb_ack (pnd);
}

View file

@ -31,8 +31,8 @@
bool pn53x_usb_probe (nfc_connstring connstrings[], size_t connstrings_len, size_t * pszDeviceFound);
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);
bool pn53x_usb_send (nfc_device * pnd, const uint8_t * pbtData, const size_t szData, struct timeval *timeout);
int pn53x_usb_receive (nfc_device * pnd, uint8_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;

View file

@ -32,30 +32,30 @@
#include <nfc/nfc.h>
void
iso14443a_crc (byte_t * pbtData, size_t szLen, byte_t * pbtCrc)
iso14443a_crc (uint8_t * pbtData, size_t szLen, uint8_t * pbtCrc)
{
byte_t bt;
uint8_t bt;
uint32_t wCrc = 0x6363;
do {
bt = *pbtData++;
bt = (bt ^ (byte_t) (wCrc & 0x00FF));
bt = (bt ^ (uint8_t) (wCrc & 0x00FF));
bt = (bt ^ (bt << 4));
wCrc = (wCrc >> 8) ^ ((uint32_t) bt << 8) ^ ((uint32_t) bt << 3) ^ ((uint32_t) bt >> 4);
} while (--szLen);
*pbtCrc++ = (byte_t) (wCrc & 0xFF);
*pbtCrc = (byte_t) ((wCrc >> 8) & 0xFF);
*pbtCrc++ = (uint8_t) (wCrc & 0xFF);
*pbtCrc = (uint8_t) ((wCrc >> 8) & 0xFF);
}
void
iso14443a_crc_append (byte_t * pbtData, size_t szLen)
iso14443a_crc_append (uint8_t * pbtData, size_t szLen)
{
iso14443a_crc (pbtData, szLen, pbtData + szLen);
}
byte_t *
iso14443a_locate_historical_bytes (byte_t * pbtAts, size_t szAts, size_t * pszTk)
uint8_t *
iso14443a_locate_historical_bytes (uint8_t * pbtAts, size_t szAts, size_t * pszTk)
{
if (szAts) {
size_t offset = 1;
@ -82,7 +82,7 @@ iso14443a_locate_historical_bytes (byte_t * pbtAts, size_t szAts, size_t * pszTk
* @see ISO/IEC 14443-3 (6.4.4 UID contents and cascade levels)
*/
void
iso14443_cascade_uid (const byte_t abtUID[], const size_t szUID, byte_t * pbtCascadedUID, size_t * pszCascadedUID)
iso14443_cascade_uid (const uint8_t abtUID[], const size_t szUID, uint8_t * pbtCascadedUID, size_t * pszCascadedUID)
{
switch (szUID) {
case 7:

View file

@ -30,7 +30,7 @@
#include "mirror-subr.h"
static const byte_t ByteMirror[256] = {
static const uint8_t ByteMirror[256] = {
0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, 0xd0, 0x30,
0xb0, 0x70, 0xf0, 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, 0x18, 0x98,
0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64,
@ -53,14 +53,14 @@ static const byte_t ByteMirror[256] = {
0xef, 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
};
byte_t
mirror (byte_t bt)
uint8_t
mirror (uint8_t bt)
{
return ByteMirror[bt];
}
void
mirror_bytes (byte_t * pbts, size_t szLen)
mirror_bytes (uint8_t * pbts, size_t szLen)
{
size_t szByteNr;
@ -73,13 +73,13 @@ mirror_bytes (byte_t * pbts, size_t szLen)
uint32_t
mirror32 (uint32_t ui32Bits)
{
mirror_bytes ((byte_t *) & ui32Bits, 4);
mirror_bytes ((uint8_t *) & ui32Bits, 4);
return ui32Bits;
}
uint64_t
mirror64 (uint64_t ui64Bits)
{
mirror_bytes ((byte_t *) & ui64Bits, 8);
mirror_bytes ((uint8_t *) & ui64Bits, 8);
return ui64Bits;
}

View file

@ -29,9 +29,9 @@
# include <nfc/nfc-types.h>
byte_t mirror (byte_t bt);
uint8_t mirror (uint8_t bt);
uint32_t mirror32 (uint32_t ui32Bits);
uint64_t mirror64 (uint64_t ui64Bits);
void mirror_byte_ts (byte_t * pbts, size_t szLen);
void mirror_uint8_ts (uint8_t * pbts, size_t szLen);
#endif // _LIBNFC_MIRROR_SUBR_H_

View file

@ -30,9 +30,9 @@
int
nfc_emulate_target (nfc_device* pnd, struct nfc_emulator *emulator)
{
byte_t abtRx[ISO7816_SHORT_R_APDU_MAX_LEN];
uint8_t abtRx[ISO7816_SHORT_R_APDU_MAX_LEN];
size_t szRx = sizeof(abtRx);
byte_t abtTx[ISO7816_SHORT_C_APDU_MAX_LEN];
uint8_t abtTx[ISO7816_SHORT_C_APDU_MAX_LEN];
int res = 0;
if (!nfc_target_init (pnd, emulator->target, abtRx, &szRx)) {

View file

@ -25,36 +25,36 @@
#include <nfc/nfc.h>
void
prepare_initiator_data (const nfc_modulation nm, byte_t **ppbtInitiatorData, size_t * pszInitiatorData)
prepare_initiator_data (const nfc_modulation nm, uint8_t **ppbtInitiatorData, size_t * pszInitiatorData)
{
switch (nm.nmt) {
case NMT_ISO14443B: {
// Application Family Identifier (AFI) must equals 0x00 in order to wakeup all ISO14443-B PICCs (see ISO/IEC 14443-3)
*ppbtInitiatorData = (byte_t *) "\x00";
*ppbtInitiatorData = (uint8_t *) "\x00";
*pszInitiatorData = 1;
}
break;
case NMT_ISO14443BI: {
// APGEN
*ppbtInitiatorData = (byte_t *) "\x01\x0b\x3f\x80";
*ppbtInitiatorData = (uint8_t *) "\x01\x0b\x3f\x80";
*pszInitiatorData = 4;
}
break;
case NMT_ISO14443B2SR: {
// Get_UID
*ppbtInitiatorData = (byte_t *) "\x0b";
*ppbtInitiatorData = (uint8_t *) "\x0b";
*pszInitiatorData = 1;
}
break;
case NMT_ISO14443B2CT: {
// SELECT-ALL
*ppbtInitiatorData = (byte_t *) "\x9F\xFF\xFF";
*ppbtInitiatorData = (uint8_t *) "\x9F\xFF\xFF";
*pszInitiatorData = 3;
}
break;
case NMT_FELICA: {
// polling payload must be present (see ISO/IEC 18092 11.2.2.5)
*ppbtInitiatorData = (byte_t *) "\x00\xff\xff\x01\x00";
*ppbtInitiatorData = (uint8_t *) "\x00\xff\xff\x01\x00";
*pszInitiatorData = 5;
}
break;

View file

@ -132,20 +132,20 @@ struct nfc_driver_t {
const char *(*strerror) (const nfc_device * pnd);
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_select_passive_target) (nfc_device * pnd, const nfc_modulation nm, const uint8_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 (*initiator_transceive_bytes) (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTx, uint8_t * pbtRx, size_t * pszRx, struct timeval *timeout);
bool (*initiator_transceive_bits) (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTxBits, const uint8_t * pbtTxPar, uint8_t * pbtRx, size_t * pszRxBits, uint8_t * pbtRxPar);
bool (*initiator_transceive_bytes_timed) (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTx, uint8_t * pbtRx, size_t * pszRx, uint32_t * cycles);
bool (*initiator_transceive_bits_timed) (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTxBits, const uint8_t * pbtTxPar, uint8_t * pbtRx, size_t * pszRxBits, uint8_t * pbtRxPar, uint32_t * cycles);
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 (*target_init) (nfc_device * pnd, nfc_target * pnt, uint8_t * pbtRx, size_t * pszRx);
bool (*target_send_bytes) (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTx, struct timeval *timeout);
bool (*target_receive_bytes) (nfc_device * pnd, uint8_t * pbtRx, size_t * pszRx, struct timeval *timeout);
bool (*target_send_bits) (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTxBits, const uint8_t * pbtTxPar);
bool (*target_receive_bits) (nfc_device * pnd, uint8_t * pbtRx, size_t * pszRxBits, uint8_t * pbtRxPar);
bool (*configure) (nfc_device * pnd, const nfc_device_option ndo, const bool bEnable);
@ -156,8 +156,8 @@ struct nfc_driver_t {
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 iso14443_cascade_uid (const uint8_t abtUID[], const size_t szUID, uint8_t * pbtCascadedUID, size_t * pszCascadedUID);
void prepare_initiator_data (const nfc_modulation nm, byte_t **ppbtInitiatorData, size_t * pszInitiatorData);
void prepare_initiator_data (const nfc_modulation nm, uint8_t **ppbtInitiatorData, size_t * pszInitiatorData);
#endif // __NFC_INTERNAL_H__

View file

@ -306,10 +306,10 @@ nfc_initiator_init (nfc_device * pnd)
bool
nfc_initiator_select_passive_target (nfc_device * pnd,
const nfc_modulation nm,
const byte_t * pbtInitData, const size_t szInitData,
const uint8_t * pbtInitData, const size_t szInitData,
nfc_target * pnt)
{
byte_t abtInit[MAX(12, szInitData)];
uint8_t abtInit[MAX(12, szInitData)];
size_t szInit;
switch (nm.nmt) {
@ -350,7 +350,7 @@ nfc_initiator_list_passive_targets (nfc_device * pnd,
{
nfc_target nt;
size_t szTargetFound = 0;
byte_t *pbtInitData = NULL;
uint8_t *pbtInitData = NULL;
size_t szInitDataLen = 0;
pnd->iLastError = 0;
@ -479,7 +479,7 @@ nfc_initiator_deselect_target (nfc_device * 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 * pnd, const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx,
nfc_initiator_transceive_bytes (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTx, uint8_t * pbtRx,
size_t * pszRx, struct timeval *timeout)
{
HAL (initiator_transceive_bytes, pnd, pbtTx, szTx, pbtRx, pszRx, timeout)
@ -521,8 +521,8 @@ nfc_initiator_transceive_bytes (nfc_device * pnd, const byte_t * pbtTx, const si
* CRC bytes. Using this feature you are able to simulate these frames.
*/
bool
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)
nfc_initiator_transceive_bits (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTxBits, const uint8_t * pbtTxPar,
uint8_t * pbtRx, size_t * pszRxBits, uint8_t * pbtRxPar)
{
HAL (initiator_transceive_bits, pnd, pbtTx, szTxBits, pbtTxPar, pbtRx, pszRxBits, pbtRxPar);
}
@ -548,7 +548,7 @@ nfc_initiator_transceive_bits (nfc_device * pnd, const byte_t * pbtTx, const siz
* @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 * pnd, const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx,
nfc_initiator_transceive_bytes_timed (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTx, uint8_t * pbtRx,
size_t * pszRx, uint32_t * cycles)
{
HAL (initiator_transceive_bytes_timed, pnd, pbtTx, szTx, pbtRx, pszRx, cycles)
@ -576,8 +576,8 @@ nfc_initiator_transceive_bytes_timed (nfc_device * pnd, const byte_t * pbtTx, co
* @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 * 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)
nfc_initiator_transceive_bits_timed (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTxBits, const uint8_t * pbtTxPar,
uint8_t * pbtRx, size_t * pszRxBits, uint8_t * pbtRxPar, uint32_t * cycles)
{
HAL (initiator_transceive_bits_timed, pnd, pbtTx, szTxBits, pbtTxPar, pbtRx, pszRxBits, pbtRxPar, cycles);
}
@ -613,7 +613,7 @@ nfc_initiator_transceive_bits_timed (nfc_device * pnd, const byte_t * pbtTx, con
* receive functions can be used.
*/
bool
nfc_target_init (nfc_device * pnd, nfc_target * pnt, byte_t * pbtRx, size_t * pszRx)
nfc_target_init (nfc_device * pnd, nfc_target * pnt, uint8_t * pbtRx, size_t * pszRx)
{
// Disallow invalid frame
if (!nfc_configure (pnd, NDO_ACCEPT_INVALID_FRAMES, false))
@ -691,7 +691,7 @@ nfc_abort_command (nfc_device * 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 * pnd, const byte_t * pbtTx, const size_t szTx, struct timeval *timeout)
nfc_target_send_bytes (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTx, struct timeval *timeout)
{
HAL (target_send_bytes, pnd, pbtTx, szTx, timeout);
}
@ -711,7 +711,7 @@ nfc_target_send_bytes (nfc_device * pnd, const byte_t * pbtTx, const size_t szTx
* 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 * pnd, byte_t * pbtRx, size_t * pszRx, struct timeval *timeout)
nfc_target_receive_bytes (nfc_device * pnd, uint8_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 * pnd, byte_t * pbtRx, size_t * pszRx, stru
* using the specified NFC device (configured as \e target).
*/
bool
nfc_target_send_bits (nfc_device * pnd, const byte_t * pbtTx, const size_t szTxBits, const byte_t * pbtTxPar)
nfc_target_send_bits (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTxBits, const uint8_t * pbtTxPar)
{
HAL (target_send_bits, pnd, pbtTx, szTxBits, pbtTxPar);
}
@ -741,7 +741,7 @@ nfc_target_send_bits (nfc_device * pnd, const byte_t * pbtTx, const size_t szTxB
* frames.
*/
bool
nfc_target_receive_bits (nfc_device * pnd, byte_t * pbtRx, size_t * pszRxBits, byte_t * pbtRxPar)
nfc_target_receive_bits (nfc_device * pnd, uint8_t * pbtRx, size_t * pszRxBits, uint8_t * pbtRxPar)
{
HAL (target_receive_bits, pnd, pbtRx, pszRxBits, pbtRxPar);
}