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:
Audrey Diacre 2011-11-23 15:55:40 +00:00
parent 55daa29a7c
commit c718fafee7
47 changed files with 546 additions and 533 deletions

View file

@ -10,8 +10,8 @@
int int
main (int argc, const char *argv[]) main (int argc, const char *argv[])
{ {
nfc_device_t *pnd; nfc_device *pnd;
nfc_target_info_t nti; nfc_target_info nti;
// Display libnfc version // Display libnfc version
const char *acLibnfcVersion = nfc_version (); const char *acLibnfcVersion = nfc_version ();
@ -30,7 +30,7 @@ main (int argc, const char *argv[])
printf ("Connected to NFC reader: %s\n", pnd->acName); printf ("Connected to NFC reader: %s\n", pnd->acName);
// Poll for a ISO14443A (MIFARE) tag // Poll for a ISO14443A (MIFARE) tag
const nfc_modulation_t nmMifare = { const nfc_modulation nmMifare = {
.nmt = NMT_ISO14443A, .nmt = NMT_ISO14443A,
.nbr = NBR_106, .nbr = NBR_106,
}; };

View file

@ -60,7 +60,7 @@ static byte_t abtSak;
static byte_t abtAts[MAX_FRAME_LEN]; static byte_t abtAts[MAX_FRAME_LEN];
static byte_t szAts = 0; static byte_t szAts = 0;
static size_t szCL = 1;//Always start with Cascade Level 1 (CL1) static size_t szCL = 1;//Always start with Cascade Level 1 (CL1)
static nfc_device_t *pnd; static nfc_device *pnd;
bool quiet_output = false; bool quiet_output = false;
bool force_rats = false; bool force_rats = false;

View file

@ -48,7 +48,7 @@
#define MAX_FRAME_LEN 264 #define MAX_FRAME_LEN 264
static nfc_device_t *pnd; static nfc_device *pnd;
void stop_dep_communication (int sig) void stop_dep_communication (int sig)
{ {
@ -62,7 +62,7 @@ void stop_dep_communication (int sig)
int int
main (int argc, const char *argv[]) main (int argc, const char *argv[])
{ {
nfc_target_t nt; nfc_target nt;
byte_t abtRx[MAX_FRAME_LEN]; byte_t abtRx[MAX_FRAME_LEN];
size_t szRx = sizeof(abtRx); size_t szRx = sizeof(abtRx);
byte_t abtTx[] = "Hello World!"; byte_t abtTx[] = "Hello World!";

View file

@ -47,7 +47,7 @@
#define MAX_FRAME_LEN 264 #define MAX_FRAME_LEN 264
static nfc_device_t *pnd; static nfc_device *pnd;
void stop_dep_communication (int sig) void stop_dep_communication (int sig)
{ {
@ -86,7 +86,7 @@ main (int argc, const char *argv[])
return EXIT_FAILURE; return EXIT_FAILURE;
} }
nfc_target_t nt = { nfc_target nt = {
.nm = { .nm = {
.nmt = NMT_DEP, .nmt = NMT_DEP,
.nbr = NBR_UNDEFINED .nbr = NBR_UNDEFINED

View file

@ -56,7 +56,7 @@
static byte_t abtRx[MAX_FRAME_LEN]; static byte_t abtRx[MAX_FRAME_LEN];
static size_t szRx = sizeof(abtRx); static size_t szRx = sizeof(abtRx);
static nfc_device_t *pnd; static nfc_device *pnd;
static bool quiet_output = false; static bool quiet_output = false;
static bool init_mfc_auth = false; static bool init_mfc_auth = false;
@ -71,7 +71,7 @@ intr_hdlr (void)
} }
bool bool
target_io( nfc_target_t * pnt, const byte_t * pbtInput, const size_t szInput, byte_t * pbtOutput, size_t *pszOutput ) target_io( nfc_target * pnt, const byte_t * pbtInput, const size_t szInput, byte_t * pbtOutput, size_t *pszOutput )
{ {
bool loop = true; bool loop = true;
*pszOutput = 0; *pszOutput = 0;
@ -134,7 +134,7 @@ target_io( nfc_target_t * pnt, const byte_t * pbtInput, const size_t szInput, by
} }
bool bool
nfc_target_emulate_tag(nfc_device_t* pnd, nfc_target_t * pnt) nfc_target_emulate_tag(nfc_device* pnd, nfc_target * pnt)
{ {
size_t szTx; size_t szTx;
byte_t abtTx[MAX_FRAME_LEN]; byte_t abtTx[MAX_FRAME_LEN];
@ -203,7 +203,7 @@ main (int argc, char *argv[])
// Example of a Mifare Classic Mini // Example of a Mifare Classic Mini
// Note that crypto1 is not implemented in this example // Note that crypto1 is not implemented in this example
nfc_target_t nt = { nfc_target nt = {
.nm = { .nm = {
.nmt = NMT_ISO14443A, .nmt = NMT_ISO14443A,
.nbr = NBR_UNDEFINED, .nbr = NBR_UNDEFINED,
@ -220,25 +220,37 @@ main (int argc, char *argv[])
}; };
/* /*
// Example of a FeliCa // Example of a FeliCa
nfc_target_t nt = { nfc_target nt = {
.nm.nmt = NMT_FELICA, .nm = {
.nm.nbr = NBR_UNDEFINED, .nmt = NMT_FELICA,
.nti.nfi.abtId = { 0x01, 0xFE, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xFF }, .nbr = NBR_UNDEFINED,
.nti.nfi.abtPad = { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xFF }, },
.nti.nfi.abtSysCode = { 0xFF, 0xFF }, .nti = {
.nfi = {
.abtId = { 0x01, 0xFE, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xFF },
.abtPad = { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xFF },
.abtSysCode = { 0xFF, 0xFF },
},
},
}; };
*/ */
/* /*
// Example of a ISO14443-4 (DESfire) // Example of a ISO14443-4 (DESfire)
nfc_target_t nt = { nfc_target nt = {
.nm.nmt = NMT_ISO14443A, .nm = {
.nm.nbr = NBR_UNDEFINED, .nmt = NMT_ISO14443A,
.nti.nai.abtAtqa = { 0x03, 0x44 }, .nbr = NBR_UNDEFINED,
.nti.nai.abtUid = { 0x08, 0xab, 0xcd, 0xef }, },
.nti.nai.btSak = 0x20, .nti = {
.nti.nai.szUidLen = 4, .nai = {
.nti.nai.abtAts = { 0x75, 0x77, 0x81, 0x02, 0x80 }, abtAtqa = { 0x03, 0x44 },
.nti.nai.szAtsLen = 5, abtUid = { 0x08, 0xab, 0xcd, 0xef },
btSak = 0x20,
.szUidLen = 4,
.abtAts = { 0x75, 0x77, 0x81, 0x02, 0x80 },
.szAtsLen = 5,
},
},
}; };
*/ */

View file

@ -58,7 +58,7 @@
static byte_t abtRecv[MAX_FRAME_LEN]; static byte_t abtRecv[MAX_FRAME_LEN];
static size_t szRecvBits; static size_t szRecvBits;
static nfc_device_t *pnd; static nfc_device *pnd;
// ISO14443A Anti-Collision response // ISO14443A Anti-Collision response
byte_t abtAtqa[2] = { 0x04, 0x00 }; byte_t abtAtqa[2] = { 0x04, 0x00 };
@ -139,8 +139,8 @@ main (int argc, char *argv[])
printf ("[+] To do this, please send any command after the anti-collision\n"); printf ("[+] To do this, please send any command after the anti-collision\n");
printf ("[+] For example, send a RATS command or use the \"nfc-anticol\" or \"nfc-list\" tool.\n"); printf ("[+] For example, send a RATS command or use the \"nfc-anticol\" or \"nfc-list\" tool.\n");
// Note: We have to build a "fake" nfc_target_t in order to do exactly the same that was done before the new nfc_target_init() was introduced. // Note: We have to build a "fake" nfc_target in order to do exactly the same that was done before the new nfc_target_init() was introduced.
nfc_target_t nt = { nfc_target nt = {
.nm = { .nm = {
.nmt = NMT_ISO14443A, .nmt = NMT_ISO14443A,
.nbr = NBR_UNDEFINED, .nbr = NBR_UNDEFINED,

View file

@ -51,7 +51,7 @@
#define MAX_DEVICE_COUNT 16 #define MAX_DEVICE_COUNT 16
static nfc_device_t *pnd = NULL; static nfc_device *pnd = NULL;
void stop_polling (int sig) void stop_polling (int sig)
{ {
@ -80,7 +80,7 @@ main (int argc, const char *argv[])
const uint8_t uiPollNr = 20; const uint8_t uiPollNr = 20;
const uint8_t uiPeriod = 2; const uint8_t uiPeriod = 2;
const nfc_modulation_t nmModulations[5] = { const nfc_modulation nmModulations[5] = {
{ .nmt = NMT_ISO14443A, .nbr = NBR_106 }, { .nmt = NMT_ISO14443A, .nbr = NBR_106 },
{ .nmt = NMT_ISO14443B, .nbr = NBR_106 }, { .nmt = NMT_ISO14443B, .nbr = NBR_106 },
{ .nmt = NMT_FELICA, .nbr = NBR_212 }, { .nmt = NMT_FELICA, .nbr = NBR_212 },
@ -89,7 +89,7 @@ main (int argc, const char *argv[])
}; };
const size_t szModulations = 5; const size_t szModulations = 5;
nfc_target_t nt; nfc_target nt;
bool res; bool res;
pnd = nfc_connect (NULL); pnd = nfc_connect (NULL);

View file

@ -56,8 +56,8 @@ static size_t szReaderRxBits;
static byte_t abtTagRx[MAX_FRAME_LEN]; static byte_t abtTagRx[MAX_FRAME_LEN];
static byte_t abtTagRxPar[MAX_FRAME_LEN]; static byte_t abtTagRxPar[MAX_FRAME_LEN];
static size_t szTagRxBits; static size_t szTagRxBits;
static nfc_device_t *pndReader; static nfc_device *pndReader;
static nfc_device_t *pndTag; static nfc_device *pndTag;
static bool quitting = false; static bool quitting = false;
void void
@ -130,7 +130,7 @@ main (int argc, char *argv[])
printf ("[+] To do this, please send any command after the anti-collision\n"); printf ("[+] To do this, please send any command after the anti-collision\n");
printf ("[+] For example, send a RATS command or use the \"nfc-anticol\" tool\n"); printf ("[+] For example, send a RATS command or use the \"nfc-anticol\" tool\n");
nfc_target_t nt = { nfc_target nt = {
.nm = { .nm = {
.nmt = NMT_ISO14443A, .nmt = NMT_ISO14443A,
.nbr = NBR_UNDEFINED, .nbr = NBR_UNDEFINED,

View file

@ -54,7 +54,7 @@ main (int argc, const char *argv[])
{ {
size_t szFound; size_t szFound;
size_t i; size_t i;
nfc_device_t *pnd; nfc_device *pnd;
const char *acLibnfcVersion; const char *acLibnfcVersion;
bool result; bool result;

View file

@ -72,7 +72,7 @@ wait_one_minute ()
int int
main (int argc, const char *argv[]) main (int argc, const char *argv[])
{ {
nfc_device_t *pnd; nfc_device *pnd;
(void) argc; (void) argc;
(void) argv; (void) argv;
@ -125,7 +125,7 @@ main (int argc, const char *argv[])
case PSM_WIRED_CARD: case PSM_WIRED_CARD:
{ {
nfc_target_t nt; nfc_target nt;
// Set connected NFC device to initiator mode // Set connected NFC device to initiator mode
nfc_initiator_init (pnd); nfc_initiator_init (pnd);
@ -136,7 +136,7 @@ main (int argc, const char *argv[])
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
// Read the SAM's info // Read the SAM's info
const nfc_modulation_t nmSAM = { const nfc_modulation nmSAM = {
.nmt = NMT_ISO14443A, .nmt = NMT_ISO14443A,
.nbr = NBR_106, .nbr = NBR_106,
}; };
@ -156,7 +156,7 @@ main (int argc, const char *argv[])
byte_t abtRx[MAX_FRAME_LEN]; byte_t abtRx[MAX_FRAME_LEN];
size_t szRx = sizeof(abtRx); size_t szRx = sizeof(abtRx);
nfc_target_t nt = { nfc_target nt = {
.nm = { .nm = {
.nmt = NMT_ISO14443A, .nmt = NMT_ISO14443A,
.nbr = NBR_UNDEFINED, .nbr = NBR_UNDEFINED,

View file

@ -71,7 +71,7 @@
int main(int argc, const char* argv[]) int main(int argc, const char* argv[])
{ {
nfc_device_t* pnd; nfc_device* pnd;
byte_t abtRx[MAX_FRAME_LEN]; byte_t abtRx[MAX_FRAME_LEN];
byte_t abtTx[MAX_FRAME_LEN]; byte_t abtTx[MAX_FRAME_LEN];
size_t szRx = sizeof(abtRx); size_t szRx = sizeof(abtRx);

View file

@ -32,7 +32,7 @@ struct nfc_emulation_state_machine;
struct nfc_emulator { struct nfc_emulator {
nfc_target_t *target; nfc_target *target;
struct nfc_emulation_state_machine *state_machine; struct nfc_emulation_state_machine *state_machine;
void *user_data; void *user_data;
}; };
@ -42,7 +42,7 @@ struct nfc_emulation_state_machine {
void *data; void *data;
}; };
NFC_EXPORT int nfc_emulate_target (nfc_device_t* pnd, struct nfc_emulator *emulator); NFC_EXPORT int nfc_emulate_target (nfc_device* pnd, struct nfc_emulator *emulator);
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -38,7 +38,7 @@ typedef uint8_t byte_t;
# define DEVICE_PORT_LENGTH 64 # define DEVICE_PORT_LENGTH 64
/** /**
* @struct nfc_device_t * @struct nfc_device
* @brief NFC device information * @brief NFC device information
*/ */
typedef struct { typedef struct {
@ -69,7 +69,7 @@ typedef struct {
* +----------- Driver-level general error (common to all drivers) * +----------- Driver-level general error (common to all drivers)
*/ */
int iLastError; int iLastError;
} nfc_device_t; } nfc_device;
typedef char nfc_connstring[1024]; typedef char nfc_connstring[1024];
@ -77,7 +77,7 @@ typedef char nfc_connstring[1024];
# pragma pack(1) # pragma pack(1)
/** /**
* @enum nfc_device_option_t * @enum nfc_device_option
* @brief NFC device option * @brief NFC device option
*/ */
typedef enum { typedef enum {
@ -137,20 +137,20 @@ typedef enum {
NDO_FORCE_ISO14443_B = 0x43, NDO_FORCE_ISO14443_B = 0x43,
/** Force the chip to run at 106 kbps */ /** Force the chip to run at 106 kbps */
NDO_FORCE_SPEED_106 = 0x50, NDO_FORCE_SPEED_106 = 0x50,
} nfc_device_option_t; } nfc_device_option;
/** /**
* @enum nfc_dep_mode_t * @enum nfc_dep_mode
* @brief NFC D.E.P. (Data Exchange Protocol) active/passive mode * @brief NFC D.E.P. (Data Exchange Protocol) active/passive mode
*/ */
typedef enum { typedef enum {
NDM_UNDEFINED = 0, NDM_UNDEFINED = 0,
NDM_PASSIVE, NDM_PASSIVE,
NDM_ACTIVE, NDM_ACTIVE,
} nfc_dep_mode_t; } nfc_dep_mode;
/** /**
* @struct nfc_dep_info_t * @struct nfc_dep_info
* @brief NFC target information in D.E.P. (Data Exchange Protocol) see ISO/IEC 18092 (NFCIP-1) * @brief NFC target information in D.E.P. (Data Exchange Protocol) see ISO/IEC 18092 (NFCIP-1)
*/ */
typedef struct { typedef struct {
@ -170,11 +170,11 @@ typedef struct {
byte_t abtGB[48]; byte_t abtGB[48];
size_t szGB; size_t szGB;
/** DEP mode */ /** DEP mode */
nfc_dep_mode_t ndm; nfc_dep_mode ndm;
} nfc_dep_info_t; } nfc_dep_info;
/** /**
* @struct nfc_iso14443a_info_t * @struct nfc_iso14443a_info
* @brief NFC ISO14443A tag (MIFARE) information * @brief NFC ISO14443A tag (MIFARE) information
*/ */
typedef struct { typedef struct {
@ -184,10 +184,10 @@ typedef struct {
byte_t abtUid[10]; byte_t abtUid[10];
size_t szAtsLen; size_t szAtsLen;
byte_t abtAts[254]; // Maximal theoretical ATS is FSD-2, FSD=256 for FSDI=8 in RATS byte_t abtAts[254]; // Maximal theoretical ATS is FSD-2, FSD=256 for FSDI=8 in RATS
} nfc_iso14443a_info_t; } nfc_iso14443a_info;
/** /**
* @struct nfc_felica_info_t * @struct nfc_felica_info
* @brief NFC FeLiCa tag information * @brief NFC FeLiCa tag information
*/ */
typedef struct { typedef struct {
@ -196,10 +196,10 @@ typedef struct {
byte_t abtId[8]; byte_t abtId[8];
byte_t abtPad[8]; byte_t abtPad[8];
byte_t abtSysCode[2]; byte_t abtSysCode[2];
} nfc_felica_info_t; } nfc_felica_info;
/** /**
* @struct nfc_iso14443b_info_t * @struct nfc_iso14443b_info
* @brief NFC ISO14443B tag information * @brief NFC ISO14443B tag information
*/ */
typedef struct { typedef struct {
@ -211,10 +211,10 @@ typedef struct {
byte_t abtProtocolInfo[3]; byte_t abtProtocolInfo[3];
/** ui8CardIdentifier store CID (Card Identifier) attributted by PCD to the PICC */ /** ui8CardIdentifier store CID (Card Identifier) attributted by PCD to the PICC */
uint8_t ui8CardIdentifier; uint8_t ui8CardIdentifier;
} nfc_iso14443b_info_t; } nfc_iso14443b_info;
/** /**
* @struct nfc_iso14443bi_info_t * @struct nfc_iso14443bi_info
* @brief NFC ISO14443B' tag information * @brief NFC ISO14443B' tag information
*/ */
typedef struct { typedef struct {
@ -227,52 +227,52 @@ typedef struct {
/** ATR, if any */ /** ATR, if any */
size_t szAtrLen; size_t szAtrLen;
byte_t abtAtr[33]; byte_t abtAtr[33];
} nfc_iso14443bi_info_t; } nfc_iso14443bi_info;
/** /**
* @struct nfc_iso14443b2sr_info_t * @struct nfc_iso14443b2sr_info
* @brief NFC ISO14443-2B ST SRx tag information * @brief NFC ISO14443-2B ST SRx tag information
*/ */
typedef struct { typedef struct {
byte_t abtUID[8]; byte_t abtUID[8];
} nfc_iso14443b2sr_info_t; } nfc_iso14443b2sr_info;
/** /**
* @struct nfc_iso14443b2ct_info_t * @struct nfc_iso14443b2ct_info
* @brief NFC ISO14443-2B ASK CTx tag information * @brief NFC ISO14443-2B ASK CTx tag information
*/ */
typedef struct { typedef struct {
byte_t abtUID[4]; byte_t abtUID[4];
byte_t btProdCode; byte_t btProdCode;
byte_t btFabCode; byte_t btFabCode;
} nfc_iso14443b2ct_info_t; } nfc_iso14443b2ct_info;
/** /**
* @struct nfc_jewel_info_t * @struct nfc_jewel_info
* @brief NFC Jewel tag information * @brief NFC Jewel tag information
*/ */
typedef struct { typedef struct {
byte_t btSensRes[2]; byte_t btSensRes[2];
byte_t btId[4]; byte_t btId[4];
} nfc_jewel_info_t; } nfc_jewel_info;
/** /**
* @union nfc_target_info_t * @union nfc_target_info
* @brief Union between all kind of tags information structures. * @brief Union between all kind of tags information structures.
*/ */
typedef union { typedef union {
nfc_iso14443a_info_t nai; nfc_iso14443a_info nai;
nfc_felica_info_t nfi; nfc_felica_info nfi;
nfc_iso14443b_info_t nbi; nfc_iso14443b_info nbi;
nfc_iso14443bi_info_t nii; nfc_iso14443bi_info nii;
nfc_iso14443b2sr_info_t nsi; nfc_iso14443b2sr_info nsi;
nfc_iso14443b2ct_info_t nci; nfc_iso14443b2ct_info nci;
nfc_jewel_info_t nji; nfc_jewel_info nji;
nfc_dep_info_t ndi; nfc_dep_info ndi;
} nfc_target_info_t; } nfc_target_info;
/** /**
* @enum nfc_baud_rate_t * @enum nfc_baud_rate
* @brief NFC baud rate enumeration * @brief NFC baud rate enumeration
*/ */
typedef enum { typedef enum {
@ -281,10 +281,10 @@ typedef enum {
NBR_212, NBR_212,
NBR_424, NBR_424,
NBR_847, NBR_847,
} nfc_baud_rate_t; } nfc_baud_rate;
/** /**
* @enum nfc_modulation_type_t * @enum nfc_modulationype
* @brief NFC modulation type enumeration * @brief NFC modulation type enumeration
*/ */
typedef enum { typedef enum {
@ -296,25 +296,25 @@ typedef enum {
NMT_ISO14443B2CT, // ISO14443-2B ASK CTx NMT_ISO14443B2CT, // ISO14443-2B ASK CTx
NMT_FELICA, NMT_FELICA,
NMT_DEP, NMT_DEP,
} nfc_modulation_type_t; } nfc_modulationype;
/** /**
* @struct nfc_modulation_t * @struct nfc_modulation
* @brief NFC modulation structure * @brief NFC modulation structure
*/ */
typedef struct { typedef struct {
nfc_modulation_type_t nmt; nfc_modulationype nmt;
nfc_baud_rate_t nbr; nfc_baud_rate nbr;
} nfc_modulation_t; } nfc_modulation;
/** /**
* @struct nfc_target_t * @struct nfc_target
* @brief NFC target structure * @brief NFC target structure
*/ */
typedef struct { typedef struct {
nfc_target_info_t nti; nfc_target_info nti;
nfc_modulation_t nm; nfc_modulation nm;
} nfc_target_t; } nfc_target;
// Reset struct alignment to default // Reset struct alignment to default
# pragma pack() # pragma pack()

View file

@ -64,39 +64,39 @@ extern "C" {
/* NFC Device/Hardware manipulation */ /* NFC Device/Hardware manipulation */
NFC_EXPORT bool nfc_get_default_device (nfc_connstring *connstring); NFC_EXPORT bool nfc_get_default_device (nfc_connstring *connstring);
NFC_EXPORT nfc_device_t *nfc_connect (const nfc_connstring connstring); NFC_EXPORT nfc_device *nfc_connect (const nfc_connstring connstring);
NFC_EXPORT void nfc_disconnect (nfc_device_t * pnd); NFC_EXPORT void nfc_disconnect (nfc_device * pnd);
NFC_EXPORT bool nfc_abort_command (nfc_device_t * pnd); NFC_EXPORT bool nfc_abort_command (nfc_device * pnd);
NFC_EXPORT void nfc_list_devices (nfc_connstring connstrings[], size_t connstrings_len, size_t * pszDeviceFound); NFC_EXPORT void nfc_list_devices (nfc_connstring connstrings[], size_t connstrings_len, size_t * pszDeviceFound);
NFC_EXPORT bool nfc_configure (nfc_device_t * pnd, const nfc_device_option_t ndo, const bool bEnable); NFC_EXPORT bool nfc_configure (nfc_device * pnd, const nfc_device_option ndo, const bool bEnable);
NFC_EXPORT bool nfc_idle (nfc_device_t * pnd); NFC_EXPORT bool nfc_idle (nfc_device * pnd);
/* NFC initiator: act as "reader" */ /* NFC initiator: act as "reader" */
NFC_EXPORT bool nfc_initiator_init (nfc_device_t * pnd); NFC_EXPORT bool nfc_initiator_init (nfc_device * pnd);
NFC_EXPORT bool nfc_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); NFC_EXPORT bool nfc_initiator_select_passive_target (nfc_device * pnd, const nfc_modulation nm, const byte_t * pbtInitData, const size_t szInitData, nfc_target * pnt);
NFC_EXPORT 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_EXPORT bool nfc_initiator_list_passive_targets (nfc_device * pnd, const nfc_modulation nm, nfc_target ant[], const size_t szTargets, size_t * pszTargetFound);
NFC_EXPORT bool nfc_initiator_poll_target (nfc_device_t * pnd, const nfc_modulation_t * pnmTargetTypes, const size_t szTargetTypes, const uint8_t uiPollNr, const uint8_t uiPeriod, nfc_target_t * pnt); NFC_EXPORT bool nfc_initiator_poll_target (nfc_device * pnd, const nfc_modulation * pnmTargetTypes, const size_t szTargetTypes, const uint8_t uiPollNr, const uint8_t uiPeriod, nfc_target * pnt);
NFC_EXPORT 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_EXPORT bool 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);
NFC_EXPORT bool nfc_initiator_deselect_target (nfc_device_t * pnd); NFC_EXPORT bool nfc_initiator_deselect_target (nfc_device * pnd);
NFC_EXPORT bool nfc_initiator_transceive_bytes (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx, size_t * pszRx, struct timeval *timeout); NFC_EXPORT bool nfc_initiator_transceive_bytes (nfc_device * pnd, const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx, size_t * pszRx, struct timeval *timeout);
NFC_EXPORT bool nfc_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); NFC_EXPORT 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_EXPORT bool nfc_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); NFC_EXPORT bool 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);
NFC_EXPORT bool nfc_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); NFC_EXPORT 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 target: act as tag (i.e. MIFARE Classic) or NFC target device. */ /* NFC target: act as tag (i.e. MIFARE Classic) or NFC target device. */
NFC_EXPORT bool nfc_target_init (nfc_device_t * pnd, nfc_target_t * pnt, byte_t * pbtRx, size_t * pszRx); NFC_EXPORT bool nfc_target_init (nfc_device * pnd, nfc_target * pnt, byte_t * pbtRx, size_t * pszRx);
NFC_EXPORT bool nfc_target_send_bytes (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx, struct timeval *timout); NFC_EXPORT bool nfc_target_send_bytes (nfc_device * pnd, const byte_t * pbtTx, const size_t szTx, struct timeval *timout);
NFC_EXPORT bool nfc_target_receive_bytes (nfc_device_t * pnd, byte_t * pbtRx, size_t * pszRx, struct timeval *timout); NFC_EXPORT bool nfc_target_receive_bytes (nfc_device * pnd, byte_t * pbtRx, size_t * pszRx, struct timeval *timout);
NFC_EXPORT bool nfc_target_send_bits (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTxBits, const byte_t * pbtTxPar); NFC_EXPORT bool nfc_target_send_bits (nfc_device * pnd, const byte_t * pbtTx, const size_t szTxBits, const byte_t * pbtTxPar);
NFC_EXPORT bool nfc_target_receive_bits (nfc_device_t * pnd, byte_t * pbtRx, size_t * pszRxBits, byte_t * pbtRxPar); NFC_EXPORT bool nfc_target_receive_bits (nfc_device * pnd, byte_t * pbtRx, size_t * pszRxBits, byte_t * pbtRxPar);
/* Error reporting */ /* Error reporting */
NFC_EXPORT const char *nfc_strerror (const nfc_device_t * pnd); NFC_EXPORT const char *nfc_strerror (const nfc_device * pnd);
NFC_EXPORT int nfc_strerror_r (const nfc_device_t * pnd, char *pcStrErrBuf, size_t szBufLen); NFC_EXPORT int nfc_strerror_r (const nfc_device * pnd, char *pcStrErrBuf, size_t szBufLen);
NFC_EXPORT void nfc_perror (const nfc_device_t * pnd, const char *pcString); NFC_EXPORT void nfc_perror (const nfc_device * pnd, const char *pcString);
/* Special data accessors */ /* Special data accessors */
NFC_EXPORT const char *nfc_device_name (nfc_device_t * pnd); NFC_EXPORT const char *nfc_device_name (nfc_device * pnd);
/* Misc. functions */ /* Misc. functions */
NFC_EXPORT void iso14443a_crc (byte_t * pbtData, size_t szLen, byte_t * pbtCrc); NFC_EXPORT void iso14443a_crc (byte_t * pbtData, size_t szLen, byte_t * pbtCrc);

View file

@ -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 // Work-around to claim uart interface using the c_iflag (software input processing) from the termios struct
# define CCLAIMED 0x80000000 # define CCLAIMED 0x80000000
typedef struct { struct serial_port_unix{
int fd; // Serial port file descriptor int fd; // Serial port file descriptor
struct termios termios_backup; // Terminal info before using the port struct termios termios_backup; // Terminal info before using the port
struct termios termios_new; // Terminal info during the transaction 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); void uart_close_ext (const serial_port sp, const bool restore_termios);
serial_port serial_port
uart_open (const char *pcPortName) 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) if (sp == 0)
return INVALID_SERIAL_PORT; return INVALID_SERIAL_PORT;
@ -114,12 +116,12 @@ void
uart_flush_input (serial_port sp) uart_flush_input (serial_port sp)
{ {
// This line seems to produce absolutely no effect on my system (GNU/Linux 2.6.35) // 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 // So, I wrote this byte-eater
// Retrieve the count of the incoming bytes // Retrieve the count of the incoming bytes
int available_bytes_count = 0; int available_bytes_count = 0;
int res; 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) { if (res != 0) {
return; return;
} }
@ -128,7 +130,7 @@ uart_flush_input (serial_port sp)
} }
char* rx = malloc (available_bytes_count); char* rx = malloc (available_bytes_count);
// There is something available, read the data // 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); log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "%d bytes have eatten.", available_bytes_count);
free (rx); free (rx);
} }
@ -137,7 +139,7 @@ void
uart_set_speed (serial_port sp, const uint32_t uiPortSpeed) 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); 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 // Portability note: on some systems, B9600 != 9600 so we have to do
// uint32_t <=> speed_t associations by hand. // uint32_t <=> speed_t associations by hand.
@ -190,7 +192,7 @@ uint32_t
uart_get_speed (serial_port sp) uart_get_speed (serial_port sp)
{ {
uint32_t uiPortSpeed = 0; 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)) { switch (cfgetispeed (&spu->termios_new)) {
case B9600: case B9600:
uiPortSpeed = 9600; uiPortSpeed = 9600;
@ -229,10 +231,10 @@ uart_get_speed (serial_port sp)
void void
uart_close_ext (const serial_port sp, const bool restore_termios) 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) if (restore_termios)
tcsetattr (((serial_port_unix *) sp)->fd, TCSANOW, &((serial_port_unix *) sp)->termios_backup); tcsetattr (((struct serial_port_unix *) sp)->fd, TCSANOW, &((struct serial_port_unix *) sp)->termios_backup);
close (((serial_port_unix *) sp)->fd); close (((struct serial_port_unix *) sp)->fd);
} }
free (sp); free (sp);
} }
@ -261,7 +263,7 @@ uart_receive (serial_port sp, byte_t * pbtRx, const size_t szRx, void * abort_p,
select: select:
// Reset file descriptor // Reset file descriptor
FD_ZERO (&rfds); FD_ZERO (&rfds);
FD_SET (((serial_port_unix *) sp)->fd, &rfds); FD_SET (((struct serial_port_unix *) sp)->fd, &rfds);
if (iAbortFd) { if (iAbortFd) {
FD_SET (iAbortFd, &rfds); FD_SET (iAbortFd, &rfds);
@ -277,7 +279,7 @@ select:
timeout = &fixed_timeout; 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)) { if ((res < 0) && (EINTR == errno)) {
// The system call was interupted by a signal and a signal handler was // 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 // 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) { if (res != 0) {
return ECOMIO; return ECOMIO;
} }
// There is something available, read the data // 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 // Stop if the OS has some troubles reading the data
if (res <= 0) { if (res <= 0) {
return ECOMIO; return ECOMIO;
@ -331,7 +333,7 @@ uart_send (serial_port sp, const byte_t * pbtTx, const size_t szTx, struct timev
{ {
(void) timeout; (void) timeout;
LOG_HEX ("TX", pbtTx, szTx); 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; return 0;
else else
return ECOMIO; return ECOMIO;

View file

@ -31,17 +31,17 @@
#include "contrib/windows.h" #include "contrib/windows.h"
#define delay_ms( X ) Sleep( X ) #define delay_ms( X ) Sleep( X )
typedef struct { struct serial_port_windows {
HANDLE hPort; // Serial port handle HANDLE hPort; // Serial port handle
DCB dcb; // Device control settings DCB dcb; // Device control settings
COMMTIMEOUTS ct; // Serial port time-out configuration COMMTIMEOUTS ct; // Serial port time-out configuration
} serial_port_windows; };
serial_port serial_port
uart_open (const char *pcPortName) uart_open (const char *pcPortName)
{ {
char acPortName[255]; 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 // Copy the input "com?" to "\\.\COM?" format
sprintf (acPortName, "\\\\.\\%s", pcPortName); sprintf (acPortName, "\\\\.\\%s", pcPortName);
@ -85,8 +85,8 @@ uart_open (const char *pcPortName)
void void
uart_close (const serial_port sp) uart_close (const serial_port sp)
{ {
if (((serial_port_windows *) sp)->hPort != INVALID_HANDLE_VALUE) { if (((struct serial_port_windows *) sp)->hPort != INVALID_HANDLE_VALUE) {
CloseHandle (((serial_port_windows *) sp)->hPort); CloseHandle (((struct serial_port_windows *) sp)->hPort);
} }
free (sp); free (sp);
} }
@ -94,13 +94,13 @@ uart_close (const serial_port sp)
void void
uart_flush_input (const serial_port sp) 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 void
uart_set_speed (serial_port sp, const uint32_t uiPortSpeed) 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); log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "Serial port speed requested to be set to %d bauds.", uiPortSpeed);
// Set port speed (Input and Output) // 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); 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; return;
}; };
spw = (serial_port_windows *) sp; spw = (struct serial_port_windows *) sp;
// Set baud rate // Set baud rate
spw->dcb.BaudRate = uiPortSpeed; spw->dcb.BaudRate = uiPortSpeed;
@ -131,7 +131,7 @@ uart_set_speed (serial_port sp, const uint32_t uiPortSpeed)
uint32_t uint32_t
uart_get_speed (const serial_port sp) 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)) if (!GetCommState (spw->hPort, (serial_port) & spw->dcb))
return spw->dcb.BaudRate; 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.WriteTotalTimeoutMultiplier = 0;
timeouts.WriteTotalTimeoutConstant = timeout_ms; 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."); log_put (LOG_CATEGORY, NFC_PRIORITY_ERROR, "Unable to apply new timeout settings.");
return ECOMIO; 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; volatile bool * abort_flag_p = (volatile bool *)abort_p;
do { do {
log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "ReadFile"); 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, dwBytesToGet,
&dwBytesReceived, NULL); &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.WriteTotalTimeoutMultiplier = 0;
timeouts.WriteTotalTimeoutConstant = timeout ? ((timeout->tv_sec * 1000) + (timeout->tv_usec / 1000)) : 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."); log_put (LOG_CATEGORY, NFC_PRIORITY_ERROR, "Unable to apply new timeout settings.");
return ECOMIO; return ECOMIO;
} }
LOG_HEX ("TX", pbtTx, szTx); 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; return ECOMIO;
} }
if (!dwTxLen) if (!dwTxLen)

View file

@ -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 }; static const byte_t pn53x_error_frame[] = { 0x00, 0x00, 0xff, 0x01, 0xff, 0x7f, 0x81, 0x00 };
/* prototypes */ /* prototypes */
bool pn53x_reset_settings (nfc_device_t * pnd); bool pn53x_reset_settings (nfc_device * pnd);
bool pn53x_writeback_register (nfc_device_t * pnd); bool pn53x_writeback_register (nfc_device * pnd);
nfc_modulation_t pn53x_ptt_to_nm (const pn53x_target_type_t ptt); nfc_modulation pn53x_ptt_to_nm (const pn53x_target_type ptt);
pn53x_modulation_t pn53x_nm_to_pm (const nfc_modulation_t nm); pn53x_modulation pn53x_nm_to_pm (const nfc_modulation nm);
pn53x_target_type_t pn53x_nm_to_ptt (const nfc_modulation_t nm); pn53x_target_type pn53x_nm_to_ptt (const nfc_modulation nm);
bool 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) // GetFirmwareVersion command is used to set PN53x chips type (PN531, PN532 or PN533)
char abtFirmwareText[22]; char abtFirmwareText[22];
@ -89,7 +89,7 @@ pn53x_init(nfc_device_t * pnd)
} }
bool 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 // Reset the ending transmission bits register, it is unknown what the last tranmission used there
CHIP_DATA (pnd)->ui8TxBits = 0; CHIP_DATA (pnd)->ui8TxBits = 0;
@ -100,7 +100,7 @@ pn53x_reset_settings(nfc_device_t * pnd)
} }
bool 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 (CHIP_DATA (pnd)->wb_trigged) {
if (!pn53x_writeback_register (pnd)) { 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 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)); uint8_t ui8Value = (bEnable) ? (CHIP_DATA (pnd)->ui8Parameters | ui8Parameter) : (CHIP_DATA (pnd)->ui8Parameters & ~(ui8Parameter));
if (ui8Value != CHIP_DATA (pnd)->ui8Parameters) { if (ui8Value != CHIP_DATA (pnd)->ui8Parameters) {
@ -200,7 +200,7 @@ pn53x_set_parameters (nfc_device_t * pnd, const uint8_t ui8Parameter, const bool
} }
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 // Test if we need to update the transmission bits register setting
if (CHIP_DATA (pnd)->ui8TxBits != ui8Bits) { if (CHIP_DATA (pnd)->ui8TxBits != ui8Bits) {
@ -318,8 +318,8 @@ pn53x_unwrap_frame (const byte_t * pbtFrame, const size_t szFrameBits, byte_t *
} }
bool bool
pn53x_decode_target_data (const byte_t * pbtRawData, size_t szRawData, pn53x_type type, nfc_modulation_type_t nmt, pn53x_decode_target_data (const byte_t * pbtRawData, size_t szRawData, pn53x_type type, nfc_modulationype nmt,
nfc_target_info_t * pnti) nfc_target_info * pnti)
{ {
uint8_t szAttribRes; uint8_t szAttribRes;
@ -462,7 +462,7 @@ pn53x_decode_target_data (const byte_t * pbtRawData, size_t szRawData, pn53x_typ
} }
bool 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 abtCmd[] = { ReadRegister, ui16RegisterAddress >> 8, ui16RegisterAddress & 0xff };
byte_t abtRegValue[2]; byte_t abtRegValue[2];
@ -481,13 +481,13 @@ pn53x_ReadRegister (nfc_device_t * pnd, uint16_t ui16RegisterAddress, uint8_t *
return true; 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); return pn53x_ReadRegister (pnd, ui16RegisterAddress, ui8Value);
} }
bool 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 }; byte_t abtCmd[] = { WriteRegister, ui16RegisterAddress >> 8, ui16RegisterAddress & 0xff, ui8Value };
PNREG_TRACE (ui16RegisterAddress); PNREG_TRACE (ui16RegisterAddress);
@ -495,7 +495,7 @@ pn53x_WriteRegister (nfc_device_t * pnd, const uint16_t ui16RegisterAddress, con
} }
bool 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)) { if ((ui16RegisterAddress < PN53X_CACHE_REGISTER_MIN_ADDRESS) || (ui16RegisterAddress > PN53X_CACHE_REGISTER_MAX_ADDRESS)) {
// Direct write // Direct write
@ -521,7 +521,7 @@ pn53x_write_register (nfc_device_t * pnd, const uint16_t ui16RegisterAddress, co
} }
bool 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 // 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); BUFFER_INIT (abtReadRegisterCmd, PN53x_EXTENDED_FRAME__DATA_MAX_LEN);
@ -589,7 +589,7 @@ pn53x_writeback_register (nfc_device_t * pnd)
} }
bool 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 }; const byte_t abtCmd[] = { GetFirmwareVersion };
byte_t abtFw[4]; byte_t abtFw[4];
@ -640,7 +640,7 @@ pn53x_get_firmware_version (nfc_device_t * pnd, char abtFirmwareText[22])
} }
bool 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; byte_t btValue;
switch (ndo) { switch (ndo) {
@ -777,7 +777,7 @@ pn53x_configure (nfc_device_t * pnd, const nfc_device_option_t ndo, const bool b
} }
bool bool
pn53x_idle (nfc_device_t *pnd) pn53x_idle (nfc_device *pnd)
{ {
switch (CHIP_DATA (pnd)->operating_mode) { switch (CHIP_DATA (pnd)->operating_mode) {
case TARGET: case TARGET:
@ -825,7 +825,7 @@ pn53x_idle (nfc_device_t *pnd)
} }
bool 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 abtCmd[] = { Diagnose, 0x00, 'l', 'i', 'b', 'n', 'f', 'c' };
const byte_t abtExpectedRx[] = { 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 bool
pn53x_initiator_init (nfc_device_t * pnd) pn53x_initiator_init (nfc_device * pnd)
{ {
pn53x_reset_settings(pnd); pn53x_reset_settings(pnd);
@ -856,10 +856,10 @@ pn53x_initiator_init (nfc_device_t * pnd)
} }
bool bool
pn53x_initiator_select_passive_target_ext (nfc_device_t * pnd, pn53x_initiator_select_passive_target_ext (nfc_device * pnd,
const nfc_modulation_t nm, const nfc_modulation nm,
const byte_t * pbtInitData, const size_t szInitData, const byte_t * pbtInitData, const size_t szInitData,
nfc_target_t * pnt, nfc_target * pnt,
struct timeval* timeout) struct timeval* timeout)
{ {
byte_t abtTargetsData[PN53x_EXTENDED_FRAME__DATA_MAX_LEN]; 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; return true;
} // else: } // else:
const pn53x_modulation_t pm = pn53x_nm_to_pm(nm); const pn53x_modulation pm = pn53x_nm_to_pm(nm);
if (PM_UNDEFINED == pm) { if (PM_UNDEFINED == pm) {
pnd->iLastError = EINVALARG; pnd->iLastError = EINVALARG;
return false; return false;
@ -966,25 +966,25 @@ pn53x_initiator_select_passive_target_ext (nfc_device_t * pnd,
} }
bool bool
pn53x_initiator_select_passive_target (nfc_device_t * pnd, pn53x_initiator_select_passive_target (nfc_device * pnd,
const nfc_modulation_t nm, const nfc_modulation nm,
const byte_t * pbtInitData, const size_t szInitData, 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); return pn53x_initiator_select_passive_target_ext (pnd, nm, pbtInitData, szInitData, pnt, NULL);
} }
bool bool
pn53x_initiator_poll_target (nfc_device_t * pnd, pn53x_initiator_poll_target (nfc_device * pnd,
const nfc_modulation_t * pnmModulations, const size_t szModulations, const nfc_modulation * pnmModulations, const size_t szModulations,
const uint8_t uiPollNr, const uint8_t uiPeriod, const uint8_t uiPollNr, const uint8_t uiPeriod,
nfc_target_t * pnt) nfc_target * pnt)
{ {
if (CHIP_DATA(pnd)->type == PN532) { if (CHIP_DATA(pnd)->type == PN532) {
size_t szTargetTypes = 0; size_t szTargetTypes = 0;
pn53x_target_type_t apttTargetTypes[32]; pn53x_target_type apttTargetTypes[32];
for (size_t n=0; n<szModulations; n++) { 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) { if (PTT_UNDEFINED == ptt) {
pnd->iLastError = EINVALARG; pnd->iLastError = EINVALARG;
return false; return false;
@ -998,7 +998,7 @@ pn53x_initiator_poll_target (nfc_device_t * pnd,
szTargetTypes++; szTargetTypes++;
} }
size_t szTargetFound = 0; size_t szTargetFound = 0;
nfc_target_t ntTargets[2]; nfc_target ntTargets[2];
if (!pn53x_InAutoPoll (pnd, apttTargetTypes, szTargetTypes, uiPollNr, uiPeriod, ntTargets, &szTargetFound)) if (!pn53x_InAutoPoll (pnd, apttTargetTypes, szTargetTypes, uiPollNr, uiPeriod, ntTargets, &szTargetFound))
return false; return false;
switch (szTargetFound) { switch (szTargetFound) {
@ -1042,10 +1042,10 @@ pn53x_initiator_poll_target (nfc_device_t * pnd,
} }
bool bool
pn53x_initiator_select_dep_target(nfc_device_t * pnd, pn53x_initiator_select_dep_target(nfc_device * pnd,
const nfc_dep_mode_t ndm, const nfc_baud_rate_t nbr, const nfc_dep_mode ndm, const nfc_baud_rate nbr,
const nfc_dep_info_t * pndiInitiator, const nfc_dep_info * pndiInitiator,
nfc_target_t * pnt) 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 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 byte_t * pbtPassiveInitiatorData = NULL;
@ -1070,7 +1070,7 @@ pn53x_initiator_select_dep_target(nfc_device_t * pnd,
} }
bool 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) const byte_t * pbtTxPar, byte_t * pbtRx, size_t * pszRxBits, byte_t * pbtRxPar)
{ {
size_t szFrameBits = 0; size_t szFrameBits = 0;
@ -1134,7 +1134,7 @@ pn53x_initiator_transceive_bits (nfc_device_t * pnd, const byte_t * pbtTx, const
} }
bool 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 * pszRx, struct timeval *timeout)
{ {
size_t szExtraTxLen; size_t szExtraTxLen;
@ -1180,7 +1180,7 @@ pn53x_initiator_transceive_bytes (nfc_device_t * pnd, const byte_t * pbtTx, cons
return true; 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 prescaler will dictate what will be the precision and
// the largest delay to measure before saturation. Some examples: // 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); 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 parity;
uint8_t counter_hi, counter_lo; 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 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) const byte_t * pbtTxPar, byte_t * pbtRx, size_t * pszRxBits, byte_t * pbtRxPar, uint32_t * cycles)
{ {
// TODO Do something with these bytes... // TODO Do something with these bytes...
@ -1364,7 +1364,7 @@ pn53x_initiator_transceive_bits_timed (nfc_device_t * pnd, const byte_t * pbtTx,
} }
bool 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) size_t * pszRx, uint32_t * cycles)
{ {
uint16_t i; uint16_t i;
@ -1467,7 +1467,7 @@ pn53x_initiator_transceive_bytes_timed (nfc_device_t * pnd, const byte_t * pbtTx
} }
bool 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 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_ISO14443_4_COMPLIANT 0x20
#define SAK_ISO18092_COMPLIANT 0x40 #define SAK_ISO18092_COMPLIANT 0x40
bool 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); pn53x_reset_settings(pnd);
CHIP_DATA (pnd)->operating_mode = TARGET; CHIP_DATA (pnd)->operating_mode = TARGET;
pn53x_target_mode_t ptm = PTM_NORMAL; pn53x_target_mode ptm = PTM_NORMAL;
switch (pnt->nm.nmt) { switch (pnt->nm.nmt) {
case NMT_ISO14443A: case NMT_ISO14443A:
@ -1631,11 +1631,11 @@ pn53x_target_init (nfc_device_t * pnd, nfc_target_t * pnt, byte_t * pbtRx, size_
return false; return false;
} }
nfc_modulation_t nm = { nfc_modulation nm = {
.nmt = NMT_DEP, // Silent compilation warnings .nmt = NMT_DEP, // Silent compilation warnings
.nbr = NBR_UNDEFINED .nbr = NBR_UNDEFINED
}; };
nfc_dep_mode_t ndm = NDM_UNDEFINED; nfc_dep_mode ndm = NDM_UNDEFINED;
// Decode activated "mode" // Decode activated "mode"
switch(btActivatedMode & 0x70) { // Baud rate switch(btActivatedMode & 0x70) { // Baud rate
case 0x00: // 106kbps 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) { if (CHIP_DATA (pnd)->current_target) {
free (CHIP_DATA (pnd)->current_target); free (CHIP_DATA (pnd)->current_target);
} }
CHIP_DATA (pnd)->current_target = malloc (sizeof(nfc_target_t)); CHIP_DATA (pnd)->current_target = malloc (sizeof(nfc_target));
memcpy (CHIP_DATA (pnd)->current_target, pnt, sizeof(nfc_target_t)); memcpy (CHIP_DATA (pnd)->current_target, pnt, sizeof(nfc_target));
if (ptm & PTM_ISO14443_4_PICC_ONLY) { if (ptm & PTM_ISO14443_4_PICC_ONLY) {
// When PN532 is in PICC target mode, it automatically reply to RATS so // 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 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 }; byte_t abtCmd[] = { TgGetInitiatorCommand };
@ -1731,7 +1731,7 @@ pn53x_target_receive_bits (nfc_device_t * pnd, byte_t * pbtRx, size_t * pszRxBit
} }
bool 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]; byte_t abtCmd[1];
@ -1780,7 +1780,7 @@ pn53x_target_receive_bytes (nfc_device_t * pnd, byte_t * pbtRx, size_t * pszRx,
} }
bool 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 szFrameBits = 0;
size_t szFrameBytes = 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 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]; byte_t abtCmd[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
@ -1917,7 +1917,7 @@ static struct sErrorMessage {
}; };
const char * const char *
pn53x_strerror (const nfc_device_t * pnd) pn53x_strerror (const nfc_device * pnd)
{ {
const char *pcRes = "Unknown error"; const char *pcRes = "Unknown error";
size_t i; size_t i;
@ -1933,14 +1933,14 @@ pn53x_strerror (const nfc_device_t * pnd)
} }
bool 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 }; byte_t abtCmd[] = { RFConfiguration, RFCI_FIELD, (bEnable) ? 0x01 : 0x00 };
return pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, NULL); return pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, NULL);
} }
bool 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[] = { byte_t abtCmd[] = {
RFConfiguration, RFConfiguration,
@ -1953,7 +1953,7 @@ pn53x_RFConfiguration__Various_timings (nfc_device_t * pnd, const uint8_t fATR_R
} }
bool 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[] = { byte_t abtCmd[] = {
RFConfiguration, RFConfiguration,
@ -1964,7 +1964,7 @@ pn53x_RFConfiguration__MaxRtyCOM (nfc_device_t * pnd, const uint8_t MaxRtyCOM)
} }
bool 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 // Retry format: 0x00 means only 1 try, 0xff means infinite
byte_t abtCmd[] = { byte_t abtCmd[] = {
@ -1978,7 +1978,7 @@ pn53x_RFConfiguration__MaxRetries (nfc_device_t * pnd, const uint8_t MxRtyATR, c
} }
bool 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 }; byte_t abtCmd[] = { SetParameters, ui8Value };
@ -1991,7 +1991,7 @@ pn53x_SetParameters (nfc_device_t * pnd, const uint8_t ui8Value)
} }
bool 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 }; byte_t abtCmd[] = { SAMConfiguration, ui8Mode, 0x00, 0x00 };
size_t szCmd = sizeof(abtCmd); size_t szCmd = sizeof(abtCmd);
@ -2020,7 +2020,7 @@ pn53x_SAMConfiguration (nfc_device_t * pnd, const pn532_sam_mode ui8Mode, struct
} }
bool bool
pn53x_PowerDown (nfc_device_t * pnd) pn53x_PowerDown (nfc_device * pnd)
{ {
byte_t abtCmd[] = { PowerDown, 0xf0 }; byte_t abtCmd[] = { PowerDown, 0xf0 };
return (pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, NULL)); 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 * @brief C wrapper to InListPassiveTarget command
* @return true if command is successfully sent * @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 pmInitModulation Desired modulation
* @param pbtInitiatorData Optional initiator data used for Felica, ISO14443B, Topaz Polling or for ISO14443A selecting a specific UID * @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 * @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 * @note To decode theses TargetData[n], there is @fn pn53x_decode_target_data
*/ */
bool bool
pn53x_InListPassiveTarget (nfc_device_t * pnd, pn53x_InListPassiveTarget (nfc_device * pnd,
const pn53x_modulation_t pmInitModulation, const byte_t szMaxTargets, const pn53x_modulation pmInitModulation, const byte_t szMaxTargets,
const byte_t * pbtInitiatorData, const size_t szInitiatorData, const byte_t * pbtInitiatorData, const size_t szInitiatorData,
byte_t * pbtTargetsData, size_t * pszTargetsData, byte_t * pbtTargetsData, size_t * pszTargetsData,
struct timeval* timeout) struct timeval* timeout)
@ -2094,7 +2094,7 @@ pn53x_InListPassiveTarget (nfc_device_t * pnd,
} }
bool 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) { if (CHIP_DATA(pnd)->type == RCS360) {
// We should do act here *only* if a target was previously selected // 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 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) { if (CHIP_DATA(pnd)->type == RCS360) {
// We should do act here *only* if a target was previously selected // 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 bool
pn53x_InAutoPoll (nfc_device_t * pnd, pn53x_InAutoPoll (nfc_device * pnd,
const pn53x_target_type_t * ppttTargetTypes, const size_t szTargetTypes, const pn53x_target_type * ppttTargetTypes, const size_t szTargetTypes,
const byte_t btPollNr, const byte_t btPeriod, nfc_target_t * pntTargets, size_t * pszTargetFound) const byte_t btPollNr, const byte_t btPeriod, nfc_target * pntTargets, size_t * pszTargetFound)
{ {
if (CHIP_DATA(pnd)->type != PN532) { if (CHIP_DATA(pnd)->type != PN532) {
// This function is not supported by pn531 neither pn533 // This function is not supported by pn531 neither pn533
@ -2168,7 +2168,7 @@ pn53x_InAutoPoll (nfc_device_t * pnd,
byte_t *pbt = abtRx + 1; byte_t *pbt = abtRx + 1;
/* 1st target */ /* 1st target */
// Target type // Target type
pn53x_target_type_t ptt = *(pbt++); pn53x_target_type ptt = *(pbt++);
pntTargets[0].nm = pn53x_ptt_to_nm(ptt); pntTargets[0].nm = pn53x_ptt_to_nm(ptt);
// AutoPollTargetData length // AutoPollTargetData length
ln = *(pbt++); ln = *(pbt++);
@ -2197,16 +2197,16 @@ pn53x_InAutoPoll (nfc_device_t * pnd,
* @param pbtNFCID3i NFCID3 of the initiator * @param pbtNFCID3i NFCID3 of the initiator
* @param pbtGBi General Bytes of the initiator * @param pbtGBi General Bytes of the initiator
* @param szGBi count of General Bytes * @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 bool
pn53x_InJumpForDEP (nfc_device_t * pnd, pn53x_InJumpForDEP (nfc_device * pnd,
const nfc_dep_mode_t ndm, const nfc_dep_mode ndm,
const nfc_baud_rate_t nbr, const nfc_baud_rate nbr,
const byte_t * pbtPassiveInitiatorData, const byte_t * pbtPassiveInitiatorData,
const byte_t * pbtNFCID3i, const byte_t * pbtNFCID3i,
const byte_t * pbtGBi, const size_t szGBi, 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 // 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 }; byte_t abtCmd[67] = { InJumpForDEP, (ndm == NDM_ACTIVE) ? 0x01 : 0x00 };
@ -2294,7 +2294,7 @@ pn53x_InJumpForDEP (nfc_device_t * pnd,
} }
bool 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 * pbtMifareParams,
const byte_t * pbtTkt, size_t szTkt, const byte_t * pbtTkt, size_t szTkt,
const byte_t * pbtFeliCaParams, const byte_t * pbtFeliCaParams,
@ -2365,7 +2365,7 @@ pn53x_TgInitAsTarget (nfc_device_t * pnd, pn53x_target_mode_t ptm,
} }
bool 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 (szRxFrameLen >= sizeof (pn53x_ack_frame)) {
if (0 == memcmp (pbtRxFrame, pn53x_ack_frame, 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 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 (szRxFrameLen >= sizeof (pn53x_error_frame)) {
if (0 == memcmp (pbtRxFrame, pn53x_error_frame, 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; return true;
} }
pn53x_modulation_t pn53x_modulation
pn53x_nm_to_pm(const nfc_modulation_t nm) pn53x_nm_to_pm(const nfc_modulation nm)
{ {
switch(nm.nmt) { switch(nm.nmt) {
case NMT_ISO14443A: case NMT_ISO14443A:
@ -2511,8 +2511,8 @@ pn53x_nm_to_pm(const nfc_modulation_t nm)
return PM_UNDEFINED; return PM_UNDEFINED;
} }
nfc_modulation_t nfc_modulation
pn53x_ptt_to_nm( const pn53x_target_type_t ptt ) pn53x_ptt_to_nm( const pn53x_target_type ptt )
{ {
switch (ptt) { switch (ptt) {
case PTT_GENERIC_PASSIVE_106: case PTT_GENERIC_PASSIVE_106:
@ -2524,44 +2524,44 @@ pn53x_ptt_to_nm( const pn53x_target_type_t ptt )
case PTT_MIFARE: case PTT_MIFARE:
case PTT_ISO14443_4A_106: 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; break;
case PTT_ISO14443_4B_106: case PTT_ISO14443_4B_106:
case PTT_ISO14443_4B_TCL_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; break;
case PTT_JEWEL_106: 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; break;
case PTT_FELICA_212: 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; break;
case PTT_FELICA_424: 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; break;
case PTT_DEP_PASSIVE_106: case PTT_DEP_PASSIVE_106:
case PTT_DEP_ACTIVE_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; break;
case PTT_DEP_PASSIVE_212: case PTT_DEP_PASSIVE_212:
case PTT_DEP_ACTIVE_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; break;
case PTT_DEP_PASSIVE_424: case PTT_DEP_PASSIVE_424:
case PTT_DEP_ACTIVE_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; break;
} }
// We should never be here, this line silent compilation warning // 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_target_type
pn53x_nm_to_ptt(const nfc_modulation_t nm) pn53x_nm_to_ptt(const nfc_modulation nm)
{ {
switch(nm.nmt) { switch(nm.nmt) {
case NMT_ISO14443A: case NMT_ISO14443A:
@ -2614,7 +2614,7 @@ pn53x_nm_to_ptt(const nfc_modulation_t nm)
} }
void 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)); 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 void
pn53x_data_free (nfc_device_t * pnd) pn53x_data_free (nfc_device * pnd)
{ {
if (CHIP_DATA (pnd)->current_target) { if (CHIP_DATA (pnd)->current_target) {
free (CHIP_DATA (pnd)->current_target); free (CHIP_DATA (pnd)->current_target);

View file

@ -127,8 +127,8 @@ typedef enum {
} pn53x_operating_mode; } pn53x_operating_mode;
struct pn53x_io { struct pn53x_io {
bool (*send)(nfc_device_t * pnd, const byte_t * pbtData, const size_t szData, struct timeval *timeout); bool (*send)(nfc_device * 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); int (*receive)(nfc_device * pnd, byte_t * pbtData, const size_t szDataLen, struct timeval *timeout);
}; };
/* defines */ /* defines */
@ -143,7 +143,7 @@ struct pn53x_data {
/** Current operating mode */ /** Current operating mode */
pn53x_operating_mode operating_mode; pn53x_operating_mode operating_mode;
/** Current emulated target */ /** Current emulated target */
nfc_target_t* current_target; nfc_target* current_target;
/** PN53x I/O functions stored in struct */ /** PN53x I/O functions stored in struct */
const struct pn53x_io * io; 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 */ /** 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)) #define CHIP_DATA(pnd) ((struct pn53x_data*)(pnd->chip_data))
/** /**
* @enum pn53x_modulation_t * @enum pn53x_modulation
* @brief NFC modulation * @brief NFC modulation
*/ */
typedef enum { typedef enum {
@ -187,10 +187,10 @@ typedef enum {
PM_ISO14443B_424 = 0x07, PM_ISO14443B_424 = 0x07,
/** ISO14443-B http://en.wikipedia.org/wiki/ISO/IEC_14443 (Not supported by PN531 nor PN532) */ /** ISO14443-B http://en.wikipedia.org/wiki/ISO/IEC_14443 (Not supported by PN531 nor PN532) */
PM_ISO14443B_847 = 0x08, PM_ISO14443B_847 = 0x08,
} pn53x_modulation_t; } pn53x_modulation;
/** /**
* @enum pn53x_target_type_t * @enum pn53x_target_type
* @brief NFC target type enumeration * @brief NFC target type enumeration
*/ */
typedef enum { typedef enum {
@ -228,7 +228,7 @@ typedef enum {
PTT_DEP_ACTIVE_212 = 0x81, PTT_DEP_ACTIVE_212 = 0x81,
/** DEP active 424 kbps */ /** DEP active 424 kbps */
PTT_DEP_ACTIVE_424 = 0x82, PTT_DEP_ACTIVE_424 = 0x82,
} pn53x_target_type_t; } pn53x_target_type;
typedef enum { typedef enum {
PSM_NORMAL = 0x01, PSM_NORMAL = 0x01,
@ -238,7 +238,7 @@ typedef enum {
} pn532_sam_mode; } pn532_sam_mode;
/** /**
* @enum pn53x_target_mode_t * @enum pn53x_target_mode
* @brief PN53x target mode enumeration * @brief PN53x target mode enumeration
*/ */
typedef enum { typedef enum {
@ -250,86 +250,86 @@ typedef enum {
PTM_DEP_ONLY = 0x02, PTM_DEP_ONLY = 0x02,
/** Configure the PN532 to accept to be initialized only as ISO/IEC14443-4 PICC */ /** Configure the PN532 to accept to be initialized only as ISO/IEC14443-4 PICC */
PTM_ISO14443_4_PICC_ONLY = 0x04 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_ack_frame[6];
extern const byte_t pn53x_nack_frame[6]; extern const byte_t pn53x_nack_frame[6];
bool pn53x_init(nfc_device_t * pnd); bool pn53x_init(nfc_device * 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_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_parameters (nfc_device * pnd, const uint8_t ui8Value, const bool bEnable);
bool pn53x_set_tx_bits (nfc_device_t * pnd, const uint8_t ui8Bits); 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 byte_t * pbtTx, const size_t szTxBits, const byte_t * pbtTxPar, byte_t * pbtFrame,
size_t * pszFrameBits); size_t * pszFrameBits);
bool pn53x_unwrap_frame (const byte_t * pbtFrame, const size_t szFrameBits, byte_t * pbtRx, size_t * pszRxBits, bool pn53x_unwrap_frame (const byte_t * pbtFrame, const size_t szFrameBits, byte_t * pbtRx, size_t * pszRxBits,
byte_t * pbtRxPar); byte_t * pbtRxPar);
bool pn53x_decode_target_data (const byte_t * pbtRawData, size_t szRawData, bool pn53x_decode_target_data (const byte_t * pbtRawData, size_t szRawData,
pn53x_type chip_type, nfc_modulation_type_t nmt, pn53x_type chip_type, nfc_modulationype nmt,
nfc_target_info_t * pnti); nfc_target_info * pnti);
bool pn53x_read_register (nfc_device_t * pnd, uint16_t ui16Reg, uint8_t * ui8Value); bool pn53x_read_register (nfc_device * 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_write_register (nfc_device * pnd, uint16_t ui16Reg, uint8_t ui8SymbolMask, uint8_t ui8Value);
bool pn53x_get_firmware_version (nfc_device_t * pnd, char abtFirmwareText[22]); bool pn53x_get_firmware_version (nfc_device * pnd, char abtFirmwareText[22]);
bool pn53x_configure (nfc_device_t * pnd, const nfc_device_option_t ndo, const bool bEnable); bool pn53x_configure (nfc_device * pnd, const nfc_device_option ndo, const bool bEnable);
bool pn53x_check_communication (nfc_device_t *pnd); bool pn53x_check_communication (nfc_device *pnd);
bool pn53x_idle (nfc_device_t * pnd); bool pn53x_idle (nfc_device * pnd);
// NFC device as Initiator functions // NFC device as Initiator functions
bool pn53x_initiator_init (nfc_device_t * pnd); bool pn53x_initiator_init (nfc_device * pnd);
bool pn53x_initiator_select_passive_target (nfc_device_t * pnd, bool pn53x_initiator_select_passive_target (nfc_device * pnd,
const nfc_modulation_t nm, const nfc_modulation nm,
const byte_t * pbtInitData, const size_t szInitData, const byte_t * pbtInitData, const size_t szInitData,
nfc_target_t * pnt); nfc_target * pnt);
bool pn53x_initiator_poll_target (nfc_device_t * pnd, bool pn53x_initiator_poll_target (nfc_device * pnd,
const nfc_modulation_t * pnmModulations, const size_t szModulations, const nfc_modulation * pnmModulations, const size_t szModulations,
const uint8_t uiPollNr, const uint8_t uiPeriod, const uint8_t uiPollNr, const uint8_t uiPeriod,
nfc_target_t * pnt); nfc_target * pnt);
bool pn53x_initiator_select_dep_target (nfc_device_t * pnd, bool pn53x_initiator_select_dep_target (nfc_device * pnd,
const nfc_dep_mode_t ndm, const nfc_baud_rate_t nbr, const nfc_dep_mode ndm, const nfc_baud_rate nbr,
const nfc_dep_info_t * pndiInitiator, const nfc_dep_info * pndiInitiator,
nfc_target_t * pnt); nfc_target * pnt);
bool pn53x_initiator_transceive_bits (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTxBits, 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, const byte_t * pbtTxPar, byte_t * pbtRx, size_t * pszRxBits,
byte_t * pbtRxPar); 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); 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, const byte_t * pbtTxPar, byte_t * pbtRx, size_t * pszRxBits,
byte_t * pbtRxPar, uint32_t * cycles); 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); 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 // 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_init (nfc_device * pnd, nfc_target * 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_bits (nfc_device * 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_receive_bytes (nfc_device * 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_bits (nfc_device * 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_send_bytes (nfc_device * pnd, const byte_t * pbtTx, const size_t szTx, struct timeval *timeout);
// Error handling functions // 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 // C wrappers for PN53x commands
bool pn53x_SetParameters (nfc_device_t * pnd, const uint8_t ui8Value); bool pn53x_SetParameters (nfc_device * pnd, const uint8_t ui8Value);
bool pn53x_SAMConfiguration (nfc_device_t * pnd, const pn532_sam_mode mode, struct timeval *timeout); bool pn53x_SAMConfiguration (nfc_device * pnd, const pn532_sam_mode mode, struct timeval *timeout);
bool pn53x_PowerDown (nfc_device_t * pnd); bool pn53x_PowerDown (nfc_device * pnd);
bool pn53x_InListPassiveTarget (nfc_device_t * pnd, const pn53x_modulation_t pmInitModulation, bool pn53x_InListPassiveTarget (nfc_device * pnd, const pn53x_modulation pmInitModulation,
const byte_t szMaxTargets, const byte_t * pbtInitiatorData, const byte_t szMaxTargets, const byte_t * pbtInitiatorData,
const size_t szInitiatorDataLen, byte_t * pbtTargetsData, size_t * pszTargetsData, const size_t szInitiatorDataLen, byte_t * pbtTargetsData, size_t * pszTargetsData,
struct timeval *timeout); struct timeval *timeout);
bool pn53x_InDeselect (nfc_device_t * pnd, const uint8_t ui8Target); bool pn53x_InDeselect (nfc_device * pnd, const uint8_t ui8Target);
bool pn53x_InRelease (nfc_device_t * pnd, const uint8_t ui8Target); bool pn53x_InRelease (nfc_device * pnd, const uint8_t ui8Target);
bool pn53x_InAutoPoll (nfc_device_t * pnd, const pn53x_target_type_t * ppttTargetTypes, const size_t szTargetTypes, 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_t * pntTargets, const byte_t btPollNr, const byte_t btPeriod, nfc_target * pntTargets,
size_t * pszTargetFound); size_t * pszTargetFound);
bool pn53x_InJumpForDEP (nfc_device_t * pnd, bool pn53x_InJumpForDEP (nfc_device * pnd,
const nfc_dep_mode_t ndm, const nfc_baud_rate_t nbr, const nfc_dep_mode ndm, const nfc_baud_rate nbr,
const byte_t * pbtPassiveInitiatorData, const byte_t * pbtPassiveInitiatorData,
const byte_t * pbtNFCID3i, const byte_t * pbtNFCID3i,
const byte_t * pbtGB, const size_t szGB, const byte_t * pbtGB, const size_t szGB,
nfc_target_t * pnt); nfc_target * pnt);
bool pn53x_TgInitAsTarget (nfc_device_t * pnd, pn53x_target_mode_t ptm, bool pn53x_TgInitAsTarget (nfc_device * pnd, pn53x_target_mode ptm,
const byte_t * pbtMifareParams, const byte_t * pbtMifareParams,
const byte_t * pbtTkt, size_t szTkt, const byte_t * pbtTkt, size_t szTkt,
const byte_t * pbtFeliCaParams, 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); byte_t * pbtRx, size_t * pszRx, byte_t * pbtModeByte);
// RFConfiguration // RFConfiguration
bool pn53x_RFConfiguration__RF_field (nfc_device_t * pnd, bool bEnable); bool pn53x_RFConfiguration__RF_field (nfc_device * 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__Various_timings (nfc_device * 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__MaxRtyCOM (nfc_device * 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__MaxRetries (nfc_device * pnd, const uint8_t MxRtyATR, const uint8_t MxRtyPSL, const uint8_t MxRtyPassiveActivation);
// Misc // Misc
bool pn53x_check_ack_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_t * 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_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_new (nfc_device * pnd, const struct pn53x_io* io);
void pn53x_data_free (nfc_device_t * pnd); void pn53x_data_free (nfc_device * pnd);
#endif // __NFC_CHIPS_PN53X_H__ #endif // __NFC_CHIPS_PN53X_H__

View file

@ -76,7 +76,7 @@
const struct pn53x_io acr122_io; const struct pn53x_io acr122_io;
char *acr122_firmware (nfc_device_t *pnd); char *acr122_firmware (nfc_device *pnd);
const char *supported_devices[] = { const char *supported_devices[] = {
"ACS ACR122", // ACR122U & Touchatag, last version "ACS ACR122", // ACR122U & Touchatag, last version
@ -239,7 +239,7 @@ acr122_connstring_decode (const nfc_connstring connstring, struct acr122_descrip
return 3; return 3;
} }
nfc_device_t * nfc_device *
acr122_connect (const nfc_connstring connstring) acr122_connect (const nfc_connstring connstring)
{ {
struct acr122_descriptor ndd; struct acr122_descriptor ndd;
@ -251,7 +251,7 @@ acr122_connect (const nfc_connstring connstring)
// FIXME: acr122_connect() does not take care about bus index // FIXME: acr122_connect() does not take care about bus index
char *pcFirmware; char *pcFirmware;
nfc_device_t *pnd = nfc_device_new (); nfc_device *pnd = nfc_device_new ();
pnd->driver_data = malloc (sizeof (struct acr122_data)); pnd->driver_data = malloc (sizeof (struct acr122_data));
// Alloc and init chip's data // Alloc and init chip's data
@ -300,7 +300,7 @@ error:
} }
void void
acr122_disconnect (nfc_device_t * pnd) acr122_disconnect (nfc_device * pnd)
{ {
SCardDisconnect (DRIVER_DATA (pnd)->hCard, SCARD_LEAVE_CARD); SCardDisconnect (DRIVER_DATA (pnd)->hCard, SCARD_LEAVE_CARD);
acr122_free_scardcontext (); acr122_free_scardcontext ();
@ -310,7 +310,7 @@ acr122_disconnect (nfc_device_t * pnd)
} }
bool 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 // FIXME: timeout is not handled
(void) timeout; (void) timeout;
@ -381,7 +381,7 @@ acr122_send (nfc_device_t * pnd, const byte_t * pbtData, const size_t szData, st
} }
int 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 // FIXME: timeout is not handled
(void) timeout; (void) timeout;
@ -422,7 +422,7 @@ acr122_receive (nfc_device_t * pnd, byte_t * pbtData, const size_t szData, struc
} }
char * char *
acr122_firmware (nfc_device_t *pnd) acr122_firmware (nfc_device *pnd)
{ {
byte_t abtGetFw[5] = { 0xFF, 0x00, 0x48, 0x00, 0x00 }; byte_t abtGetFw[5] = { 0xFF, 0x00, 0x48, 0x00, 0x00 };
uint32_t uiResult; uint32_t uiResult;
@ -445,7 +445,7 @@ acr122_firmware (nfc_device_t *pnd)
#if 0 #if 0
bool 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 abtLed[9] = { 0xFF, 0x00, 0x40, 0x05, 0x04, 0x00, 0x00, 0x00, 0x00 };
byte_t abtBuf[2]; byte_t abtBuf[2];

View file

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

View file

@ -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_incomplete_command[] = "FF0C0000\x0d\x0a";
static const byte_t arygon_error_unknown_mode[] = "FF060000\x0d\x0a"; static const byte_t arygon_error_unknown_mode[] = "FF060000\x0d\x0a";
bool arygon_reset_tama (nfc_device_t * pnd); bool arygon_reset_tama (nfc_device * pnd);
void arygon_firmware (nfc_device_t * pnd, char * str); void arygon_firmware (nfc_device * pnd, char * str);
bool bool
arygon_probe (nfc_connstring connstrings[], size_t connstrings_len, size_t * pszDeviceFound) 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_flush_input (sp);
uart_set_speed (sp, ARYGON_DEFAULT_SPEED); 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 = &arygon_driver;
pnd->driver_data = malloc(sizeof(struct arygon_data)); pnd->driver_data = malloc(sizeof(struct arygon_data));
DRIVER_DATA (pnd)->port = sp; DRIVER_DATA (pnd)->port = sp;
@ -215,7 +215,7 @@ arygon_connstring_decode (const nfc_connstring connstring, struct arygon_descrip
return 3; return 3;
} }
nfc_device_t * nfc_device *
arygon_connect (const nfc_connstring connstring) arygon_connect (const nfc_connstring connstring)
{ {
struct arygon_descriptor ndd; struct arygon_descriptor ndd;
@ -228,7 +228,7 @@ arygon_connect (const nfc_connstring connstring)
ndd.speed = ARYGON_DEFAULT_SPEED; ndd.speed = ARYGON_DEFAULT_SPEED;
} }
serial_port sp; 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); log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "Attempt to connect to: %s at %d bauds.", ndd.port, ndd.speed);
sp = uart_open (ndd.port); sp = uart_open (ndd.port);
@ -286,7 +286,7 @@ arygon_connect (const nfc_connstring connstring)
} }
void void
arygon_disconnect (nfc_device_t * pnd) arygon_disconnect (nfc_device * pnd)
{ {
// Release UART port // Release UART port
uart_close (DRIVER_DATA (pnd)->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_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) #define ARYGON_RX_BUFFER_LEN (PN53x_EXTENDED_FRAME__DATA_MAX_LEN + PN53x_EXTENDED_FRAME__OVERHEAD)
bool 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 // Before sending anything, we need to discard from any junk bytes
uart_flush_input (DRIVER_DATA(pnd)->port); 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 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) // 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 }; 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 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]; byte_t abtRxBuf[5];
size_t len; size_t len;
@ -484,7 +484,7 @@ arygon_tama_receive (nfc_device_t * pnd, byte_t * pbtData, const size_t szDataLe
} }
void 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' }; const byte_t arygon_firmware_version_cmd[] = { DEV_ARYGON_PROTOCOL_ARYGON_ASCII, 'a', 'v' };
byte_t abtRx[16]; byte_t abtRx[16];
@ -512,7 +512,7 @@ arygon_firmware (nfc_device_t * pnd, char * str)
} }
bool 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' }; const byte_t arygon_reset_tama_cmd[] = { DEV_ARYGON_PROTOCOL_ARYGON_ASCII, 'a', 'r' };
byte_t abtRx[10]; // Attempted response is 10 bytes long byte_t abtRx[10]; // Attempted response is 10 bytes long
@ -541,7 +541,7 @@ arygon_reset_tama (nfc_device_t * pnd)
} }
bool bool
arygon_abort_command (nfc_device_t * pnd) arygon_abort_command (nfc_device * pnd)
{ {
if (pnd) { if (pnd) {
#ifndef WIN32 #ifndef WIN32

View file

@ -32,11 +32,11 @@
bool arygon_probe (nfc_connstring connstrings[], size_t connstrings_len, size_t * pszDeviceFound); bool arygon_probe (nfc_connstring connstrings[], size_t connstrings_len, size_t * pszDeviceFound);
nfc_device_t *arygon_connect (const nfc_connstring connstring); nfc_device *arygon_connect (const nfc_connstring connstring);
void arygon_disconnect (nfc_device_t * pnd); 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); bool arygon_tama_send (nfc_device * 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); 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; extern const struct nfc_driver_t arygon_driver;

View file

@ -48,8 +48,8 @@
#define PN532_UART_DRIVER_NAME "pn532_uart" #define PN532_UART_DRIVER_NAME "pn532_uart"
#define LOG_CATEGORY "libnfc.driver.pn532_uart" #define LOG_CATEGORY "libnfc.driver.pn532_uart"
int pn532_uart_ack (nfc_device_t * pnd); int pn532_uart_ack (nfc_device * pnd);
int pn532_uart_wakeup (nfc_device_t * pnd); int pn532_uart_wakeup (nfc_device * pnd);
const struct pn53x_io pn532_uart_io; 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. // Serial port claimed but we need to check if a PN532_UART is connected.
uart_set_speed (sp, PN532_UART_DEFAULT_SPEED); 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 = &pn532_uart_driver;
pnd->driver_data = malloc(sizeof(struct pn532_uart_data)); pnd->driver_data = malloc(sizeof(struct pn532_uart_data));
DRIVER_DATA (pnd)->port = sp; DRIVER_DATA (pnd)->port = sp;
@ -196,7 +196,7 @@ pn532_connstring_decode (const nfc_connstring connstring, struct pn532_uart_desc
return 3; return 3;
} }
nfc_device_t * nfc_device *
pn532_uart_connect (const nfc_connstring connstring) pn532_uart_connect (const nfc_connstring connstring)
{ {
struct pn532_uart_descriptor ndd; struct pn532_uart_descriptor ndd;
@ -209,7 +209,7 @@ pn532_uart_connect (const nfc_connstring connstring)
ndd.speed = PN532_UART_DEFAULT_SPEED; ndd.speed = PN532_UART_DEFAULT_SPEED;
} }
serial_port sp; 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); log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "Attempt to connect to: %s at %d bauds.", ndd.port, ndd.speed);
sp = uart_open (ndd.port); sp = uart_open (ndd.port);
@ -262,7 +262,7 @@ pn532_uart_connect (const nfc_connstring connstring)
} }
void void
pn532_uart_disconnect (nfc_device_t * pnd) pn532_uart_disconnect (nfc_device * pnd)
{ {
// Release UART port // Release UART port
uart_close (DRIVER_DATA(pnd)->port); uart_close (DRIVER_DATA(pnd)->port);
@ -278,7 +278,7 @@ pn532_uart_disconnect (nfc_device_t * pnd)
} }
int 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. */ /* 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 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) #define PN532_BUFFER_LEN (PN53x_EXTENDED_FRAME__DATA_MAX_LEN + PN53x_EXTENDED_FRAME__OVERHEAD)
bool 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 // Before sending anything, we need to discard from any junk bytes
uart_flush_input (DRIVER_DATA(pnd)->port); 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 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]; byte_t abtRxBuf[5];
size_t len; size_t len;
@ -476,7 +476,7 @@ pn532_uart_receive (nfc_device_t * pnd, byte_t * pbtData, const size_t szDataLen
} }
int int
pn532_uart_ack (nfc_device_t * pnd) pn532_uart_ack (nfc_device * pnd)
{ {
if (POWERDOWN == CHIP_DATA(pnd)->power_mode) { if (POWERDOWN == CHIP_DATA(pnd)->power_mode) {
if (-1 == pn532_uart_wakeup(pnd)) { if (-1 == pn532_uart_wakeup(pnd)) {
@ -487,7 +487,7 @@ pn532_uart_ack (nfc_device_t * pnd)
} }
bool bool
pn532_uart_abort_command (nfc_device_t * pnd) pn532_uart_abort_command (nfc_device * pnd)
{ {
if (pnd) { if (pnd) {
#ifndef WIN32 #ifndef WIN32

View file

@ -31,10 +31,10 @@
bool pn532_uart_probe (nfc_connstring connstrings[], size_t connstrings_len, size_t * pszDeviceFound); bool pn532_uart_probe (nfc_connstring connstrings[], size_t connstrings_len, size_t * pszDeviceFound);
nfc_device_t *pn532_uart_connect (const nfc_connstring connstring); nfc_device *pn532_uart_connect (const nfc_connstring connstring);
void pn532_uart_disconnect (nfc_device_t * pnd); void pn532_uart_disconnect (nfc_device * pnd);
bool pn532_uart_send (nfc_device_t * pnd, const byte_t * pbtData, const size_t szData, struct timeval *timeout); bool pn532_uart_send (nfc_device * 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); 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; extern const struct nfc_driver_t pn532_uart_driver;

View file

@ -118,7 +118,7 @@ struct pn53x_usb_data {
const struct pn53x_io pn53x_usb_io; 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_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 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, 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; return UNKNOWN;
} }
int pn53x_usb_ack (nfc_device_t * pnd); int pn53x_usb_ack (nfc_device * pnd);
// Find transfer endpoints for bulk transfers // Find transfer endpoints for bulk transfers
void void
@ -378,7 +378,7 @@ pn53x_usb_get_usb_device_name (struct usb_device *dev, usb_dev_handle *udev, cha
return false; return false;
} }
nfc_device_t * nfc_device *
pn53x_usb_connect (const nfc_connstring connstring) pn53x_usb_connect (const nfc_connstring connstring)
{ {
struct pn53x_usb_descriptor desc; struct pn53x_usb_descriptor desc;
@ -388,7 +388,7 @@ pn53x_usb_connect (const nfc_connstring connstring)
return NULL; return NULL;
} }
nfc_device_t *pnd = NULL; nfc_device *pnd = NULL;
struct pn53x_usb_data data = { struct pn53x_usb_data data = {
.pudh = NULL, .pudh = NULL,
.uiEndPointIn = 0, .uiEndPointIn = 0,
@ -492,7 +492,7 @@ error:
} }
void void
pn53x_usb_disconnect (nfc_device_t * pnd) pn53x_usb_disconnect (nfc_device * pnd)
{ {
pn53x_usb_ack (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) #define PN53X_USB_BUFFER_LEN (PN53x_EXTENDED_FRAME__DATA_MAX_LEN + PN53x_EXTENDED_FRAME__OVERHEAD)
bool 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" byte_t abtFrame[PN53X_USB_BUFFER_LEN] = { 0x00, 0x00, 0xff }; // Every packet must start with "00 00 ff"
size_t szFrame = 0; size_t szFrame = 0;
@ -565,7 +565,7 @@ pn53x_usb_send (nfc_device_t * pnd, const byte_t * pbtData, const size_t szData,
} }
int 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; size_t len;
off_t offset = 0; off_t offset = 0;
@ -715,13 +715,13 @@ read:
} }
int 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); return pn53x_usb_bulk_write (DRIVER_DATA (pnd), (byte_t *) pn53x_ack_frame, sizeof (pn53x_ack_frame), NULL);
} }
bool 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... // 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: //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 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)) if (!pn53x_configure (pnd, ndo, bEnable))
return false; return false;
@ -806,7 +806,7 @@ pn53x_usb_configure (nfc_device_t * pnd, const nfc_device_option_t ndo, const bo
} }
bool bool
pn53x_usb_abort_command (nfc_device_t * pnd) pn53x_usb_abort_command (nfc_device * pnd)
{ {
DRIVER_DATA (pnd)->abort_flag = true; DRIVER_DATA (pnd)->abort_flag = true;
return true; return true;

View file

@ -30,10 +30,10 @@
# include <nfc/nfc-types.h> # include <nfc/nfc-types.h>
bool pn53x_usb_probe (nfc_connstring connstrings[], size_t connstrings_len, size_t * pszDeviceFound); bool pn53x_usb_probe (nfc_connstring connstrings[], size_t connstrings_len, size_t * pszDeviceFound);
nfc_device_t *pn53x_usb_connect (const nfc_connstring connstring); nfc_device *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); bool pn53x_usb_send (nfc_device * 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); int pn53x_usb_receive (nfc_device * pnd, byte_t * pbtData, const size_t szData, struct timeval *timeout);
void pn53x_usb_disconnect (nfc_device_t * pnd); void pn53x_usb_disconnect (nfc_device * pnd);
extern const struct nfc_driver_t pn53x_usb_driver; extern const struct nfc_driver_t pn53x_usb_driver;

View file

@ -19,7 +19,7 @@
/** /**
* @file nfc-device.c * @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: */ /* vim:set et sw=2 ts=2: */
@ -32,10 +32,10 @@
#include "nfc-internal.h" #include "nfc-internal.h"
nfc_device_t * nfc_device *
nfc_device_new (void) nfc_device_new (void)
{ {
nfc_device_t *res = malloc (sizeof (*res)); nfc_device *res = malloc (sizeof (*res));
if (!res) { if (!res) {
err (EXIT_FAILURE, "nfc_device_new: malloc"); err (EXIT_FAILURE, "nfc_device_new: malloc");
@ -57,7 +57,7 @@ nfc_device_new (void)
} }
void void
nfc_device_free (nfc_device_t *nfc_device) nfc_device_free (nfc_device *nfc_device)
{ {
if (nfc_device) { if (nfc_device) {
free (nfc_device->driver_data); free (nfc_device->driver_data);

View file

@ -28,7 +28,7 @@
#include "iso7816.h" #include "iso7816.h"
int 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]; byte_t abtRx[ISO7816_SHORT_R_APDU_MAX_LEN];
size_t szRx = sizeof(abtRx); size_t szRx = sizeof(abtRx);

View file

@ -23,10 +23,9 @@
*/ */
#include <nfc/nfc.h> #include <nfc/nfc.h>
#include <nfc/nfc-emulation.h>
void 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) { switch (nm.nmt) {
case NMT_ISO14443B: { case NMT_ISO14443B: {

View file

@ -127,37 +127,37 @@
struct nfc_driver_t { struct nfc_driver_t {
const char *name; const char *name;
bool (*probe)(nfc_connstring connstrings[], size_t connstrings_len, size_t * pszDeviceFound); bool (*probe)(nfc_connstring connstrings[], size_t connstrings_len, size_t * pszDeviceFound);
nfc_device_t * (*connect) (const nfc_connstring connstring); nfc_device * (*connect) (const nfc_connstring connstring);
void (*disconnect) (nfc_device_t * pnd); void (*disconnect) (nfc_device * pnd);
const char *(*strerror) (const nfc_device_t * pnd); const char *(*strerror) (const nfc_device * pnd);
bool (*initiator_init) (nfc_device_t * pnd); bool (*initiator_init) (nfc_device * 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_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_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_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_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_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_t * pnd); bool (*initiator_deselect_target) (nfc_device * 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_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_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_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_t * pnd, const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx, size_t * pszRx, uint32_t * cycles); 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_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_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_init) (nfc_device * pnd, nfc_target * 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_send_bytes) (nfc_device * 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_receive_bytes) (nfc_device * 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_send_bits) (nfc_device * 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_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 (*abort_command) (nfc_device * pnd);
bool (*idle) (nfc_device_t * pnd); bool (*idle) (nfc_device * pnd);
}; };
nfc_device_t *nfc_device_new (void); nfc_device *nfc_device_new (void);
void nfc_device_free (nfc_device_t *nfc_device); 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 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__ #endif // __NFC_INTERNAL_H__

View file

@ -98,24 +98,24 @@ nfc_get_default_device (nfc_connstring *connstring)
/** /**
* @brief Connect to a NFC device * @brief Connect to a NFC device
* @param connstring The device connection string if specific device is wanted, \c NULL otherwise * @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 \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. * 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. * 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. * 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(), * @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. * 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) nfc_connect (const nfc_connstring connstring)
{ {
log_init (); log_init ();
nfc_device_t *pnd = NULL; nfc_device *pnd = NULL;
nfc_connstring ncs; nfc_connstring ncs;
if (connstring == NULL) { if (connstring == NULL) {
@ -158,12 +158,12 @@ nfc_connect (const nfc_connstring connstring)
/** /**
* @brief Disconnect from a NFC device * @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 void
nfc_disconnect (nfc_device_t * pnd) nfc_disconnect (nfc_device * pnd)
{ {
if (pnd) { if (pnd) {
// Go in idle mode // 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 * @brief Configure advanced NFC device settings
* @return Returns \c true if action was successfully performed; otherwise returns \c false. * @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 ndo \a nfc_device_option_t struct that contains option to set to device * @param ndo \a nfc_device_option struct that contains option to set to device
* @param bEnable boolean to activate/disactivate the option * @param bEnable boolean to activate/disactivate the option
* *
* Configures parameters and registers that control for example timing, * 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). * accept).
*/ */
bool 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); 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) * @brief Initialize NFC device as initiator (reader)
* @return Returns \c true if action was successfully performed; otherwise returns \c false. * @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. * 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. * 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 * - RF field is shortly dropped (if it was enabled) then activated again
*/ */
bool bool
nfc_initiator_init (nfc_device_t * pnd) nfc_initiator_init (nfc_device * pnd)
{ {
// Drop the field for a while // Drop the field for a while
if (!nfc_configure (pnd, NDO_ACTIVATE_FIELD, false)) 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 * @brief Select a passive or emulated tag
* @return Returns \c true if action was successfully performed; otherwise returns \c false. * @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 nm desired modulation
* @param pbtInitData optional initiator data used for Felica, ISO14443B, Topaz polling or to select a specific UID in ISO14443A. * @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. * @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 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). * - 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. * 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. * the initial modulation and speed (106, 212 or 424 kbps) should be supplied.
*/ */
bool bool
nfc_initiator_select_passive_target (nfc_device_t * pnd, nfc_initiator_select_passive_target (nfc_device * pnd,
const nfc_modulation_t nm, const nfc_modulation nm,
const byte_t * pbtInitData, const size_t szInitData, const byte_t * pbtInitData, const size_t szInitData,
nfc_target_t * pnt) nfc_target * pnt)
{ {
byte_t abtInit[MAX(12, szInitData)]; byte_t abtInit[MAX(12, szInitData)];
size_t szInit; size_t szInit;
@ -330,9 +330,9 @@ nfc_initiator_select_passive_target (nfc_device_t * pnd,
* @brief List passive or emulated tags * @brief List passive or emulated tags
* @return Returns \c true if action was successfully performed; otherwise returns \c false. * @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 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 szTargets size of \a ant (will be the max targets listed)
* @param[out] pszTargetFound pointer where target found counter will be stored * @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. * should be supplied.
*/ */
bool bool
nfc_initiator_list_passive_targets (nfc_device_t * pnd, nfc_initiator_list_passive_targets (nfc_device * pnd,
const nfc_modulation_t nm, const nfc_modulation nm,
nfc_target_t ant[], const size_t szTargets, size_t * pszTargetFound) nfc_target ant[], const size_t szTargets, size_t * pszTargetFound)
{ {
nfc_target_t nt; nfc_target nt;
size_t szTargetFound = 0; size_t szTargetFound = 0;
byte_t *pbtInitData = NULL; byte_t *pbtInitData = NULL;
size_t szInitDataLen = 0; size_t szInitDataLen = 0;
@ -371,14 +371,14 @@ nfc_initiator_list_passive_targets (nfc_device_t * pnd,
bool seen = false; bool seen = false;
// Check if we've already seen this tag // Check if we've already seen this tag
for (i = 0; i < szTargetFound; i++) { 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; seen = true;
} }
} }
if (seen) { if (seen) {
break; break;
} }
memcpy (&(ant[szTargetFound]), &nt, sizeof (nfc_target_t)); memcpy (&(ant[szTargetFound]), &nt, sizeof (nfc_target));
szTargetFound++; szTargetFound++;
// deselect has no effect on FeliCa and Jewel cards so we'll stop after one... // 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 // 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 * @brief Polling for NFC targets
* @return Returns \c true if action was successfully performed; otherwise returns \c false. * @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 ppttTargetTypes array of desired target types
* @param szTargetTypes \e ppttTargetTypes count * @param szTargetTypes \e ppttTargetTypes count
* @param uiPollNr specifies the number of polling (0x01 0xFE: 1 up to 254 polling, 0xFF: Endless polling) * @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 * @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) * @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 * @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 bool
nfc_initiator_poll_target (nfc_device_t * pnd, nfc_initiator_poll_target (nfc_device * pnd,
const nfc_modulation_t * pnmModulations, const size_t szModulations, const nfc_modulation * pnmModulations, const size_t szModulations,
const uint8_t uiPollNr, const uint8_t uiPeriod, 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); 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) * @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. * @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 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 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_t struct pointer where target information will be put. * @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 * 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 * (ISO18092 and ECMA-340) describe the modulation that can be used for reader
* to passive communications. * 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 bool
nfc_initiator_select_dep_target (nfc_device_t * pnd, nfc_initiator_select_dep_target (nfc_device * pnd,
const nfc_dep_mode_t ndm, const nfc_baud_rate_t nbr, const nfc_dep_mode ndm, const nfc_baud_rate nbr,
const nfc_dep_info_t * pndiInitiator, nfc_target_t * pnt) const nfc_dep_info * pndiInitiator, nfc_target * pnt)
{ {
HAL (initiator_select_dep_target, pnd, ndm, nbr, pndiInitiator, 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 * @brief Deselect a selected passive or emulated tag
* @return Returns \c true if action was successfully performed; otherwise returns \c false. * @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 * 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 * 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. * the next tag until the correct tag is found.
*/ */
bool bool
nfc_initiator_deselect_target (nfc_device_t * pnd) nfc_initiator_deselect_target (nfc_device * pnd)
{ {
HAL (initiator_deselect_target, 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). * @warning The configuration option \a NDO_HANDLE_PARITY must be set to \c true (the default value).
*/ */
bool 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) size_t * pszRx, struct timeval *timeout)
{ {
HAL (initiator_transceive_bytes, pnd, pbtTx, szTx, pbtRx, pszRx, 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. * CRC bytes. Using this feature you are able to simulate these frames.
*/ */
bool 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) byte_t * pbtRx, size_t * pszRxBits, byte_t * pbtRxPar)
{ {
HAL (initiator_transceive_bits, pnd, pbtTx, szTxBits, pbtTxPar, pbtRx, pszRxBits, 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). * @warning The configuration option \a NDO_HANDLE_PARITY must be set to \c true (the default value).
*/ */
bool 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) size_t * pszRx, uint32_t * cycles)
{ {
HAL (initiator_transceive_bytes_timed, pnd, pbtTx, szTx, pbtRx, pszRx, 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). * @warning The configuration option \a NDO_HANDLE_PARITY must be set to \c true (the default value).
*/ */
bool 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) 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); 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 * @brief Initialize NFC device as an emulated tag
* @return Returns \c true if action was successfully performed; otherwise returns \c false. * @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 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 * @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. * 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. * receive functions can be used.
*/ */
bool 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 // Disallow invalid frame
if (!nfc_configure (pnd, NDO_ACCEPT_INVALID_FRAMES, false)) 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 * @brief Turn NFC device in idle mode
* @return Returns \c true if action was successfully performed; otherwise returns \c false. * @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. * 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 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). * 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 bool
nfc_idle (nfc_device_t * pnd) nfc_idle (nfc_device * pnd)
{ {
HAL (idle, pnd); HAL (idle, pnd);
} }
@ -662,7 +662,7 @@ nfc_idle (nfc_device_t * pnd)
* @brief Abort current running command * @brief Abort current running command
* @return Returns \c true if action was successfully performed; otherwise returns \c false. * @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). * 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. * 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. * @note The blocking function (ie. nfc_target_init()) will failed with DEABORT error.
*/ */
bool bool
nfc_abort_command (nfc_device_t * pnd) nfc_abort_command (nfc_device * pnd)
{ {
HAL (abort_command, pnd); HAL (abort_command, pnd);
} }
@ -679,7 +679,7 @@ nfc_abort_command (nfc_device_t * pnd)
* @brief Send bytes and APDU frames * @brief Send bytes and APDU frames
* @return Returns \c true if action was successfully performed; otherwise returns \c false. * @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 pbtTx pointer to Tx buffer
* @param szTx size of Tx buffer * @param szTx size of Tx buffer
* @param timeout timeval struct pointer (NULL means infinite) * @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). * If timeout is a null pointer, the function blocks indefinitely (until an error is raised or function is completed).
*/ */
bool 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); 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 * @brief Receive bytes and APDU frames
* @return Returns \c true if action was successfully performed; otherwise returns \c false. * @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] pbtRx pointer to Rx buffer
* @param[out] pszRx received byte count * @param[out] pszRx received byte count
* @param timeout timeval struct pointer (NULL means infinite) * @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). * If timeout is a null pointer, the function blocks indefinitely (until an error is raised or function is completed).
*/ */
bool 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); 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). * using the specified NFC device (configured as \e target).
*/ */
bool 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); 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. * frames.
*/ */
bool 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); 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 * @return Returns a string
*/ */
const char * const char *
nfc_strerror (const nfc_device_t * pnd) nfc_strerror (const nfc_device * pnd)
{ {
return pnd->driver->strerror (pnd); return pnd->driver->strerror (pnd);
} }
@ -761,7 +761,7 @@ nfc_strerror (const nfc_device_t * pnd)
* @return Returns 0 upon success * @return Returns 0 upon success
*/ */
int 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; 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 * @brief Display the PCD error a-la perror
*/ */
void 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)); 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 * @return Returns a string with the device name
*/ */
const char * const char *
nfc_device_name (nfc_device_t * pnd) nfc_device_name (nfc_device * pnd)
{ {
return pnd->acName; return pnd->acName;
} }

View file

@ -14,31 +14,31 @@ void
test_access_storm (void) test_access_storm (void)
{ {
int n = NTESTS; int n = NTESTS;
nfc_device_desc_t devices[MAX_DEVICE_COUNT]; nfc_connstring connstrings[MAX_DEVICE_COUNT];
size_t device_count, ref_device_count, target_count; size_t device_count, ref_device_count, target_count;
bool res; bool res;
nfc_list_devices (devices, MAX_DEVICE_COUNT, &ref_device_count); nfc_list_devices (connstrings, MAX_DEVICE_COUNT, &ref_device_count);
if (!ref_device_count) if (!ref_device_count)
cut_omit ("No NFC device found"); cut_omit ("No NFC device found");
while (n) { while (n) {
size_t i; size_t i;
nfc_list_devices (devices, MAX_DEVICE_COUNT, &device_count); nfc_list_devices (connstrings, MAX_DEVICE_COUNT, &device_count);
cut_assert_equal_int (ref_device_count, device_count, cut_message ("device count")); cut_assert_equal_int (ref_device_count, device_count, cut_message ("device count"));
for (i = 0; i < device_count; i++) { for (i = 0; i < device_count; i++) {
nfc_device_t *device; nfc_device *device;
nfc_target_t ant[MAX_TARGET_COUNT]; nfc_target ant[MAX_TARGET_COUNT];
device = nfc_connect (&(devices[i])); device = nfc_connect (&(connstrings[i]));
cut_assert_not_null (device, cut_message ("nfc_connect")); cut_assert_not_null (device, cut_message ("nfc_connect"));
res = nfc_initiator_init(device); res = nfc_initiator_init(device);
cut_assert_true (res, cut_message ("nfc_initiator_init")); cut_assert_true (res, cut_message ("nfc_initiator_init"));
const nfc_modulation_t nm = { const nfc_modulation nm = {
.nmt = NMT_ISO14443A, .nmt = NMT_ISO14443A,
.nbr = NBR_106, .nbr = NBR_106,
}; };

View file

@ -9,8 +9,8 @@
#define TARGET 1 #define TARGET 1
pthread_t threads[2]; pthread_t threads[2];
nfc_device_desc_t device_descriptions[2]; nfc_connstring connstrings[2];
nfc_device_t *devices[2]; nfc_device *devices[2];
intptr_t result[2]; intptr_t result[2];
void void
@ -28,13 +28,13 @@ cut_setup (void)
{ {
size_t n; size_t n;
nfc_list_devices (device_descriptions, 2, &n); nfc_list_devices (connstrings, 2, &n);
if (n < 2) { if (n < 2) {
cut_omit ("At least two NFC devices must be plugged-in to run this test"); cut_omit ("At least two NFC devices must be plugged-in to run this test");
} }
devices[TARGET] = nfc_connect (&device_descriptions[TARGET]); devices[TARGET] = nfc_connect (&connstrings[TARGET]);
devices[INITIATOR] = nfc_connect (&device_descriptions[INITIATOR]); devices[INITIATOR] = nfc_connect (&connstrings[INITIATOR]);
signal (SIGINT, abort_test_by_keypress); signal (SIGINT, abort_test_by_keypress);
} }
@ -47,7 +47,7 @@ cut_teardown (void)
} }
struct thread_data { struct thread_data {
nfc_device_t *device; nfc_device *device;
void *cut_test_context; void *cut_test_context;
}; };
@ -55,11 +55,11 @@ void *
target_thread (void *arg) target_thread (void *arg)
{ {
intptr_t thread_res = 0; intptr_t thread_res = 0;
// nfc_device_t *device = ((struct thread_data *) arg)->device; // nfc_device *device = ((struct thread_data *) arg)->device;
cut_set_current_test_context (((struct thread_data *) arg)->cut_test_context); cut_set_current_test_context (((struct thread_data *) arg)->cut_test_context);
#if 0 #if 0
nfc_target_t nt = { nfc_target nt = {
.nm = { .nm = {
.nmt = NMT_DEP, .nmt = NMT_DEP,
.nbr = NBR_UNDEFINED .nbr = NBR_UNDEFINED
@ -106,7 +106,7 @@ void *
initiator_thread (void *arg) initiator_thread (void *arg)
{ {
intptr_t thread_res = 0; intptr_t thread_res = 0;
// nfc_device_t *device = ((struct thread_data *) arg)->device; // nfc_device *device = ((struct thread_data *) arg)->device;
cut_set_current_test_context (((struct thread_data *) arg)->cut_test_context); cut_set_current_test_context (((struct thread_data *) arg)->cut_test_context);
cut_fail("plop"); cut_fail("plop");
@ -122,7 +122,7 @@ initiator_thread (void *arg)
bool res = nfc_initiator_init (device); bool res = nfc_initiator_init (device);
// cut_assert_true (res, cut_message ("Can't initialize NFC device as initiator")); // cut_assert_true (res, cut_message ("Can't initialize NFC device as initiator"));
nfc_target_t nt; nfc_target nt;
// Passive mode / 212Kbps // Passive mode / 212Kbps
res = nfc_initiator_select_dep_target (device, NDM_PASSIVE, NBR_212, NULL, &nt); res = nfc_initiator_select_dep_target (device, NDM_PASSIVE, NBR_212, NULL, &nt);

View file

@ -9,17 +9,17 @@
void void
test_register_endianness (void) test_register_endianness (void)
{ {
nfc_device_desc_t devices[MAX_DEVICE_COUNT]; nfc_connstring connstrings[MAX_DEVICE_COUNT];
size_t device_count; size_t device_count;
bool res; bool res;
nfc_list_devices (devices, MAX_DEVICE_COUNT, &device_count); nfc_list_devices (connstrings, MAX_DEVICE_COUNT, &device_count);
if (!device_count) if (!device_count)
cut_omit ("No NFC device found"); cut_omit ("No NFC device found");
nfc_device_t *device; nfc_device *device;
device = nfc_connect (&(devices[0])); device = nfc_connect (&(connstrings[0]));
cut_assert_not_null (device, cut_message ("nfc_connect")); cut_assert_not_null (device, cut_message ("nfc_connect"));
uint8_t value; uint8_t value;

View file

@ -10,17 +10,17 @@
void void
test_register_endianness (void) test_register_endianness (void)
{ {
nfc_device_desc_t devices[MAX_DEVICE_COUNT]; nfc_connstring connstrings[MAX_DEVICE_COUNT];
size_t device_count; size_t device_count;
bool res; bool res;
nfc_list_devices (devices, MAX_DEVICE_COUNT, &device_count); nfc_list_devices (connstrings, MAX_DEVICE_COUNT, &device_count);
if (!device_count) if (!device_count)
cut_omit ("No NFC device found"); cut_omit ("No NFC device found");
nfc_device_t *device; nfc_device *device;
device = nfc_connect (&(devices[0])); device = nfc_connect (&(connstrings[0]));
cut_assert_not_null (device, cut_message ("nfc_connect")); cut_assert_not_null (device, cut_message ("nfc_connect"));
uint8_t value; uint8_t value;

View file

@ -48,7 +48,7 @@
* The MIFARE Classic Specification (http://www.nxp.com/acrobat/other/identification/M001053_MF1ICS50_rev5_3.pdf) explains more about this process. * The MIFARE Classic Specification (http://www.nxp.com/acrobat/other/identification/M001053_MF1ICS50_rev5_3.pdf) explains more about this process.
*/ */
bool bool
nfc_initiator_mifare_cmd (nfc_device_t * pnd, const mifare_cmd mc, const uint8_t ui8Block, mifare_param * pmp) nfc_initiator_mifare_cmd (nfc_device * pnd, const mifare_cmd mc, const uint8_t ui8Block, mifare_param * pmp)
{ {
byte_t abtRx[265]; byte_t abtRx[265];
size_t szRx = sizeof(abtRx); size_t szRx = sizeof(abtRx);
@ -69,19 +69,19 @@ nfc_initiator_mifare_cmd (nfc_device_t * pnd, const mifare_cmd mc, const uint8_t
// Authenticate command // Authenticate command
case MC_AUTH_A: case MC_AUTH_A:
case MC_AUTH_B: case MC_AUTH_B:
szParamLen = sizeof (mifare_param_auth); szParamLen = sizeof (struct mifare_param_auth);
break; break;
// Data command // Data command
case MC_WRITE: case MC_WRITE:
szParamLen = sizeof (mifare_param_data); szParamLen = sizeof (struct mifare_param_data);
break; break;
// Value command // Value command
case MC_DECREMENT: case MC_DECREMENT:
case MC_INCREMENT: case MC_INCREMENT:
case MC_TRANSFER: case MC_TRANSFER:
szParamLen = sizeof (mifare_param_value); szParamLen = sizeof (struct mifare_param_value);
break; break;
// Please fix your code, you never should reach this statement // Please fix your code, you never should reach this statement

View file

@ -53,29 +53,29 @@ typedef enum {
} mifare_cmd; } mifare_cmd;
// MIFARE command params // MIFARE command params
typedef struct { struct mifare_param_auth {
byte_t abtKey[6]; byte_t abtKey[6];
byte_t abtUid[4]; byte_t abtUid[4];
} mifare_param_auth; };
typedef struct { struct mifare_param_data {
byte_t abtData[16]; byte_t abtData[16];
} mifare_param_data; };
typedef struct { struct mifare_param_value {
byte_t abtValue[4]; byte_t abtValue[4];
} mifare_param_value; };
typedef union { typedef union {
mifare_param_auth mpa; struct mifare_param_auth mpa;
mifare_param_data mpd; struct mifare_param_data mpd;
mifare_param_value mpv; struct mifare_param_value mpv;
} mifare_param; } mifare_param;
// Reset struct alignment to default // Reset struct alignment to default
# pragma pack() # pragma pack()
bool nfc_initiator_mifare_cmd (nfc_device_t * pnd, const mifare_cmd mc, const uint8_t ui8Block, mifare_param * pmp); bool nfc_initiator_mifare_cmd (nfc_device * pnd, const mifare_cmd mc, const uint8_t ui8Block, mifare_param * pmp);
// Compiler directive, set struct alignment to 1 byte_t for compatibility // Compiler directive, set struct alignment to 1 byte_t for compatibility
# pragma pack(1) # pragma pack(1)

View file

@ -71,7 +71,7 @@
#include "nfc-utils.h" #include "nfc-utils.h"
static nfc_device_t *pnd; static nfc_device *pnd;
void void
stop_emulation (int sig) stop_emulation (int sig)
@ -155,7 +155,7 @@ main(int argc, char *argv[])
(void)argc; (void)argc;
(void)argv; (void)argv;
nfc_target_t nt = { nfc_target nt = {
.nm = { .nm = {
.nmt = NMT_ISO14443A, .nmt = NMT_ISO14443A,
.nbr = NBR_UNDEFINED, // Will be updated by nfc_target_init() .nbr = NBR_UNDEFINED, // Will be updated by nfc_target_init()

View file

@ -68,7 +68,7 @@
#include "nfc-utils.h" #include "nfc-utils.h"
static nfc_device_t *pnd; static nfc_device *pnd;
static bool quiet_output = false; static bool quiet_output = false;
#define SYMBOL_PARAM_fISO14443_4_PICC 0x20 #define SYMBOL_PARAM_fISO14443_4_PICC 0x20
@ -289,7 +289,7 @@ usage (char *progname)
int int
main (int argc, char *argv[]) main (int argc, char *argv[])
{ {
nfc_target_t nt = { nfc_target nt = {
.nm = { .nm = {
.nmt = NMT_ISO14443A, .nmt = NMT_ISO14443A,
.nbr = NBR_UNDEFINED, // Will be updated by nfc_target_init() .nbr = NBR_UNDEFINED, // Will be updated by nfc_target_init()

View file

@ -57,7 +57,7 @@
#define MAX_DEVICE_COUNT 16 #define MAX_DEVICE_COUNT 16
#define MAX_TARGET_COUNT 16 #define MAX_TARGET_COUNT 16
static nfc_device_t *pnd; static nfc_device *pnd;
int int
main (int argc, const char *argv[]) main (int argc, const char *argv[])
@ -108,7 +108,7 @@ main (int argc, const char *argv[])
} }
for (i = 0; i < szDeviceFound; i++) { for (i = 0; i < szDeviceFound; i++) {
nfc_target_t ant[MAX_TARGET_COUNT]; nfc_target ant[MAX_TARGET_COUNT];
pnd = nfc_connect (connstrings[i]); pnd = nfc_connect (connstrings[i]);
if (pnd == NULL) { if (pnd == NULL) {
@ -119,7 +119,7 @@ main (int argc, const char *argv[])
printf ("Connected to NFC device: %s\n", pnd->acName); printf ("Connected to NFC device: %s\n", pnd->acName);
nfc_modulation_t nm; nfc_modulation nm;
nm.nmt = NMT_ISO14443A; nm.nmt = NMT_ISO14443A;
nm.nbr = NBR_106; nm.nbr = NBR_106;

View file

@ -52,8 +52,8 @@
#include "mifare.h" #include "mifare.h"
#include "nfc-utils.h" #include "nfc-utils.h"
static nfc_device_t *pnd; static nfc_device *pnd;
static nfc_target_t nt; static nfc_target nt;
static mifare_param mp; static mifare_param mp;
static mifare_classic_tag mtKeys; static mifare_classic_tag mtKeys;
static mifare_classic_tag mtDump; static mifare_classic_tag mtDump;
@ -72,7 +72,7 @@ static byte_t keys[] = {
0xab, 0xcd, 0xef, 0x12, 0x34, 0x56 0xab, 0xcd, 0xef, 0x12, 0x34, 0x56
}; };
static const nfc_modulation_t nmMifare = { static const nfc_modulation nmMifare = {
.nmt = NMT_ISO14443A, .nmt = NMT_ISO14443A,
.nbr = NBR_106, .nbr = NBR_106,
}; };

View file

@ -65,7 +65,7 @@ static byte_t abtSak;
static byte_t abtAts[MAX_FRAME_LEN]; static byte_t abtAts[MAX_FRAME_LEN];
static byte_t szAts = 0; static byte_t szAts = 0;
static size_t szCL = 1;//Always start with Cascade Level 1 (CL1) static size_t szCL = 1;//Always start with Cascade Level 1 (CL1)
static nfc_device_t *pnd; static nfc_device *pnd;
bool quiet_output = false; bool quiet_output = false;
bool iso_ats_supported = false; bool iso_ats_supported = false;

View file

@ -51,13 +51,13 @@
#include "nfc-utils.h" #include "nfc-utils.h"
#include "mifare.h" #include "mifare.h"
static nfc_device_t *pnd; static nfc_device *pnd;
static nfc_target_t nt; static nfc_target nt;
static mifare_param mp; static mifare_param mp;
static mifareul_tag mtDump; static mifareul_tag mtDump;
static uint32_t uiBlocks = 0xF; static uint32_t uiBlocks = 0xF;
static const nfc_modulation_t nmMifare = { static const nfc_modulation nmMifare = {
.nmt = NMT_ISO14443A, .nmt = NMT_ISO14443A,
.nbr = NBR_106, .nbr = NBR_106,
}; };

View file

@ -57,7 +57,7 @@
#include "nfc-utils.h" #include "nfc-utils.h"
static nfc_device_t *pnd; static nfc_device *pnd;
void void
print_usage(char *progname) print_usage(char *progname)
@ -77,7 +77,7 @@ void stop_select (int sig)
} }
void void
build_felica_frame(const nfc_felica_info_t nfi, const byte_t command, const byte_t* payload, const size_t payload_len, byte_t * frame, size_t * frame_len) build_felica_frame(const nfc_felica_info nfi, const byte_t command, const byte_t* payload, const size_t payload_len, byte_t * frame, size_t * frame_len)
{ {
frame[0] = 1 + 1 + 8 + payload_len; frame[0] = 1 + 1 + 8 + payload_len;
*frame_len = frame[0]; *frame_len = frame[0];
@ -88,7 +88,7 @@ build_felica_frame(const nfc_felica_info_t nfi, const byte_t command, const byte
#define CHECK 0x06 #define CHECK 0x06
int int
nfc_forum_tag_type3_check (nfc_device_t *pnd, const nfc_target_t nt, const uint16_t block, const uint8_t block_count, byte_t * data, size_t * data_len) nfc_forum_tag_type3_check (nfc_device *pnd, const nfc_target nt, const uint16_t block, const uint8_t block_count, byte_t * data, size_t * data_len)
{ {
byte_t payload[1024] = { byte_t payload[1024] = {
1, // Services 1, // Services
@ -204,14 +204,14 @@ main(int argc, char *argv[])
fprintf (message_stream, "Connected to NFC device: %s\n", pnd->acName); fprintf (message_stream, "Connected to NFC device: %s\n", pnd->acName);
nfc_modulation_t nm = { nfc_modulation nm = {
.nmt = NMT_FELICA, .nmt = NMT_FELICA,
.nbr = NBR_212, .nbr = NBR_212,
}; };
signal (SIGINT, stop_select); signal (SIGINT, stop_select);
nfc_target_t nt; nfc_target nt;
nfc_initiator_init(pnd); nfc_initiator_init(pnd);
fprintf (message_stream, "Place your NFC Forum Tag Type 3 in the field...\n"); fprintf (message_stream, "Place your NFC Forum Tag Type 3 in the field...\n");

View file

@ -61,8 +61,8 @@ static byte_t abtCapdu[MAX_FRAME_LEN];
static size_t szCapduLen; static size_t szCapduLen;
static byte_t abtRapdu[MAX_FRAME_LEN]; static byte_t abtRapdu[MAX_FRAME_LEN];
static size_t szRapduLen; static size_t szRapduLen;
static nfc_device_t *pndInitiator; static nfc_device *pndInitiator;
static nfc_device_t *pndTarget; static nfc_device *pndTarget;
static bool quitting = false; static bool quitting = false;
static bool quiet_output = false; static bool quiet_output = false;
static bool initiator_only_mode = false; static bool initiator_only_mode = false;
@ -151,7 +151,7 @@ main (int argc, char *argv[])
int arg; int arg;
size_t szFound; size_t szFound;
const char *acLibnfcVersion = nfc_version (); const char *acLibnfcVersion = nfc_version ();
nfc_target_t ntRealTarget; nfc_target ntRealTarget;
// Get commandline options // Get commandline options
for (arg = 1; arg < argc; arg++) { for (arg = 1; arg < argc; arg++) {
@ -236,7 +236,7 @@ main (int argc, char *argv[])
} }
// Try to find a ISO 14443-4A tag // Try to find a ISO 14443-4A tag
nfc_modulation_t nm = { nfc_modulation nm = {
.nmt = NMT_ISO14443A, .nmt = NMT_ISO14443A,
.nbr = NBR_106, .nbr = NBR_106,
}; };
@ -279,7 +279,7 @@ main (int argc, char *argv[])
printf ("Hint: tag <---> initiator (relay) <---> target (relay) <---> original reader\n\n"); printf ("Hint: tag <---> initiator (relay) <---> target (relay) <---> original reader\n\n");
} }
if (!initiator_only_mode) { if (!initiator_only_mode) {
nfc_target_t ntEmulatedTarget = { nfc_target ntEmulatedTarget = {
.nm = { .nm = {
.nmt = NMT_ISO14443A, .nmt = NMT_ISO14443A,
.nbr = NBR_106, .nbr = NBR_106,

View file

@ -133,7 +133,7 @@ print_hex_par (const byte_t * pbtData, const size_t szBits, const byte_t * pbtDa
#define SAK_ISO18092_COMPLIANT 0x40 #define SAK_ISO18092_COMPLIANT 0x40
void void
print_nfc_iso14443a_info (const nfc_iso14443a_info_t nai, bool verbose) print_nfc_iso14443a_info (const nfc_iso14443a_info nai, bool verbose)
{ {
printf (" ATQA (SENS_RES): "); printf (" ATQA (SENS_RES): ");
print_hex (nai.abtAtqa, 2); print_hex (nai.abtAtqa, 2);
@ -530,7 +530,7 @@ print_nfc_iso14443a_info (const nfc_iso14443a_info_t nai, bool verbose)
} }
void void
print_nfc_felica_info (const nfc_felica_info_t nfi, bool verbose) print_nfc_felica_info (const nfc_felica_info nfi, bool verbose)
{ {
(void) verbose; (void) verbose;
printf (" ID (NFCID2): "); printf (" ID (NFCID2): ");
@ -542,7 +542,7 @@ print_nfc_felica_info (const nfc_felica_info_t nfi, bool verbose)
} }
void void
print_nfc_jewel_info (const nfc_jewel_info_t nji, bool verbose) print_nfc_jewel_info (const nfc_jewel_info nji, bool verbose)
{ {
(void) verbose; (void) verbose;
printf (" ATQA (SENS_RES): "); printf (" ATQA (SENS_RES): ");
@ -555,7 +555,7 @@ print_nfc_jewel_info (const nfc_jewel_info_t nji, bool verbose)
#define PI_NAD_SUPPORTED 0x01 #define PI_NAD_SUPPORTED 0x01
#define PI_CID_SUPPORTED 0x02 #define PI_CID_SUPPORTED 0x02
void void
print_nfc_iso14443b_info (const nfc_iso14443b_info_t nbi, bool verbose) print_nfc_iso14443b_info (const nfc_iso14443b_info nbi, bool verbose)
{ {
const int iMaxFrameSizes[] = { 16, 24, 32, 40, 48, 64, 96, 128, 256 }; const int iMaxFrameSizes[] = { 16, 24, 32, 40, 48, 64, 96, 128, 256 };
printf (" PUPI: "); printf (" PUPI: ");
@ -610,7 +610,7 @@ print_nfc_iso14443b_info (const nfc_iso14443b_info_t nbi, bool verbose)
} }
void void
print_nfc_iso14443bi_info (const nfc_iso14443bi_info_t nii, bool verbose) print_nfc_iso14443bi_info (const nfc_iso14443bi_info nii, bool verbose)
{ {
printf (" DIV: "); printf (" DIV: ");
print_hex (nii.abtDIV, 4); print_hex (nii.abtDIV, 4);
@ -634,7 +634,7 @@ print_nfc_iso14443bi_info (const nfc_iso14443bi_info_t nii, bool verbose)
} }
void void
print_nfc_iso14443b2sr_info (const nfc_iso14443b2sr_info_t nsi, bool verbose) print_nfc_iso14443b2sr_info (const nfc_iso14443b2sr_info nsi, bool verbose)
{ {
(void) verbose; (void) verbose;
printf (" UID: "); printf (" UID: ");
@ -642,7 +642,7 @@ print_nfc_iso14443b2sr_info (const nfc_iso14443b2sr_info_t nsi, bool verbose)
} }
void void
print_nfc_iso14443b2ct_info (const nfc_iso14443b2ct_info_t nci, bool verbose) print_nfc_iso14443b2ct_info (const nfc_iso14443b2ct_info nci, bool verbose)
{ {
(void) verbose; (void) verbose;
uint32_t uid; uint32_t uid;
@ -655,7 +655,7 @@ print_nfc_iso14443b2ct_info (const nfc_iso14443b2ct_info_t nci, bool verbose)
} }
void void
print_nfc_dep_info (const nfc_dep_info_t ndi, bool verbose) print_nfc_dep_info (const nfc_dep_info ndi, bool verbose)
{ {
(void) verbose; (void) verbose;
printf (" NFCID3: "); printf (" NFCID3: ");
@ -671,7 +671,7 @@ print_nfc_dep_info (const nfc_dep_info_t ndi, bool verbose)
} }
const char * const char *
str_nfc_baud_rate (const nfc_baud_rate_t nbr) str_nfc_baud_rate (const nfc_baud_rate nbr)
{ {
switch(nbr) { switch(nbr) {
case NBR_UNDEFINED: case NBR_UNDEFINED:
@ -694,7 +694,7 @@ str_nfc_baud_rate (const nfc_baud_rate_t nbr)
} }
void void
print_nfc_target (const nfc_target_t nt, bool verbose) print_nfc_target (const nfc_target nt, bool verbose)
{ {
switch(nt.nm.nmt) { switch(nt.nm.nmt) {
case NMT_ISO14443A: case NMT_ISO14443A:

View file

@ -86,15 +86,15 @@ void print_hex (const byte_t * pbtData, const size_t szLen);
void print_hex_bits (const byte_t * pbtData, const size_t szBits); void print_hex_bits (const byte_t * pbtData, const size_t szBits);
void print_hex_par (const byte_t * pbtData, const size_t szBits, const byte_t * pbtDataPar); void print_hex_par (const byte_t * pbtData, const size_t szBits, const byte_t * pbtDataPar);
void print_nfc_iso14443a_info (const nfc_iso14443a_info_t nai, bool verbose); void print_nfc_iso14443a_info (const nfc_iso14443a_info nai, bool verbose);
void print_nfc_iso14443b_info (const nfc_iso14443b_info_t nbi, bool verbose); void print_nfc_iso14443b_info (const nfc_iso14443b_info nbi, bool verbose);
void print_nfc_iso14443bi_info (const nfc_iso14443bi_info_t nii, bool verbose); void print_nfc_iso14443bi_info (const nfc_iso14443bi_info nii, bool verbose);
void print_nfc_iso14443b2sr_info (const nfc_iso14443b2sr_info_t nsi, bool verbose); void print_nfc_iso14443b2sr_info (const nfc_iso14443b2sr_info nsi, bool verbose);
void print_nfc_iso14443b2ct_info (const nfc_iso14443b2ct_info_t nci, bool verbose); void print_nfc_iso14443b2ct_info (const nfc_iso14443b2ct_info nci, bool verbose);
void print_nfc_felica_info (const nfc_felica_info_t nfi, bool verbose); void print_nfc_felica_info (const nfc_felica_info nfi, bool verbose);
void print_nfc_jewel_info (const nfc_jewel_info_t nji, bool verbose); void print_nfc_jewel_info (const nfc_jewel_info nji, bool verbose);
void print_nfc_dep_info (const nfc_dep_info_t ndi, bool verbose); void print_nfc_dep_info (const nfc_dep_info ndi, bool verbose);
void print_nfc_target (const nfc_target_t nt, bool verbose); void print_nfc_target (const nfc_target nt, bool verbose);
#endif #endif