nfc_device struct is not exposed as public API anymore (partial commit)
- split libnfc's errors and chip's errors - fix nfc_property enum
This commit is contained in:
parent
98355d36a7
commit
9bdc20353c
11 changed files with 329 additions and 314 deletions
|
|
@ -32,42 +32,10 @@
|
|||
# include <stdbool.h>
|
||||
# include <stdio.h>
|
||||
|
||||
# define DEVICE_NAME_LENGTH 256
|
||||
# define DEVICE_PORT_LENGTH 64
|
||||
|
||||
/**
|
||||
* @struct nfc_device
|
||||
* @brief NFC device information
|
||||
* NFC device
|
||||
*/
|
||||
typedef struct {
|
||||
/** Driver's functions for handling device specific wrapping */
|
||||
const struct nfc_driver_t *driver;
|
||||
void *driver_data;
|
||||
void *chip_data;
|
||||
|
||||
/** Device name string, including device wrapper firmware */
|
||||
char acName[DEVICE_NAME_LENGTH];
|
||||
/** Is the crc automaticly added, checked and removed from the frames */
|
||||
bool bCrc;
|
||||
/** Does the chip handle parity bits, all parities are handled as data */
|
||||
bool bPar;
|
||||
/** Should the chip handle frames encapsulation and chaining */
|
||||
bool bEasyFraming;
|
||||
/** Should the chip switch automatically activate ISO14443-4 when
|
||||
selecting tags supporting it? */
|
||||
bool bAutoIso14443_4;
|
||||
/** Supported modulation encoded in a byte */
|
||||
uint8_t btSupportByte;
|
||||
/** Last error reported by the PCD / encountered by the PCD driver
|
||||
* MSB LSB
|
||||
* | 00 | 00 |
|
||||
* || ||
|
||||
* || ++----- Chip-level error (as reported by the PCD)
|
||||
* |+---------- Driver-level specific error
|
||||
* +----------- Driver-level general error (common to all drivers)
|
||||
*/
|
||||
int iLastError;
|
||||
} nfc_device;
|
||||
typedef struct nfc_device nfc_device;
|
||||
|
||||
/**
|
||||
* Connection string
|
||||
|
|
@ -103,7 +71,7 @@ typedef enum {
|
|||
* incorrect CRC bytes this option should be disabled. Example frames where
|
||||
* this is useful are the ATQA and UID+BCC that are transmitted without CRC
|
||||
* bytes during the anti-collision phase of the ISO14443-A protocol. */
|
||||
NP_HANDLE_CRC = 0x00,
|
||||
NP_HANDLE_CRC,
|
||||
/** Parity bits in the network layer of ISO14443-A are by default generated and
|
||||
* validated in the PN53X chip. This is a very convenient feature. On certain
|
||||
* times though it is useful to get full control of the transmitted data. The
|
||||
|
|
@ -111,31 +79,31 @@ typedef enum {
|
|||
* parity bits. For interoperability it is required to be completely
|
||||
* compatible, including the arbitrary parity bits. When this option is
|
||||
* disabled, the functions to communicating bits should be used. */
|
||||
NP_HANDLE_PARITY = 0x01,
|
||||
NP_HANDLE_PARITY,
|
||||
/** This option can be used to enable or disable the electronic field of the
|
||||
* NFC device. */
|
||||
NP_ACTIVATE_FIELD = 0x10,
|
||||
NP_ACTIVATE_FIELD,
|
||||
/** The internal CRYPTO1 co-processor can be used to transmit messages
|
||||
* encrypted. This option is automatically activated after a successful MIFARE
|
||||
* Classic authentication. */
|
||||
NP_ACTIVATE_CRYPTO1 = 0x11,
|
||||
NP_ACTIVATE_CRYPTO1,
|
||||
/** The default configuration defines that the PN53X chip will try indefinitely
|
||||
* to invite a tag in the field to respond. This could be desired when it is
|
||||
* certain a tag will enter the field. On the other hand, when this is
|
||||
* uncertain, it will block the application. This option could best be compared
|
||||
* to the (NON)BLOCKING option used by (socket)network programming. */
|
||||
NP_INFINITE_SELECT = 0x20,
|
||||
NP_INFINITE_SELECT,
|
||||
/** If this option is enabled, frames that carry less than 4 bits are allowed.
|
||||
* According to the standards these frames should normally be handles as
|
||||
* invalid frames. */
|
||||
NP_ACCEPT_INVALID_FRAMES = 0x30,
|
||||
NP_ACCEPT_INVALID_FRAMES,
|
||||
/** If the NFC device should only listen to frames, it could be useful to let
|
||||
* it gather multiple frames in a sequence. They will be stored in the internal
|
||||
* FIFO of the PN53X chip. This could be retrieved by using the receive data
|
||||
* functions. Note that if the chip runs out of bytes (FIFO = 64 bytes long),
|
||||
* it will overwrite the first received frames, so quick retrieving of the
|
||||
* received data is desirable. */
|
||||
NP_ACCEPT_MULTIPLE_FRAMES = 0x31,
|
||||
NP_ACCEPT_MULTIPLE_FRAMES,
|
||||
/** This option can be used to enable or disable the auto-switching mode to
|
||||
* ISO14443-4 is device is compliant.
|
||||
* In initiator mode, it means that NFC chip will send RATS automatically when
|
||||
|
|
@ -143,15 +111,15 @@ typedef enum {
|
|||
* requested.
|
||||
* In target mode, with a NFC chip compiliant (ie. PN532), the chip will
|
||||
* emulate a 14443-4 PICC using hardware capability */
|
||||
NP_AUTO_ISO14443_4 = 0x40,
|
||||
NP_AUTO_ISO14443_4,
|
||||
/** Use automatic frames encapsulation and chaining. */
|
||||
NP_EASY_FRAMING = 0x41,
|
||||
NP_EASY_FRAMING,
|
||||
/** Force the chip to switch in ISO14443-A */
|
||||
NP_FORCE_ISO14443_A = 0x42,
|
||||
NP_FORCE_ISO14443_A,
|
||||
/** Force the chip to switch in ISO14443-B */
|
||||
NP_FORCE_ISO14443_B = 0x43,
|
||||
NP_FORCE_ISO14443_B,
|
||||
/** Force the chip to run at 106 kbps */
|
||||
NP_FORCE_SPEED_106 = 0x50,
|
||||
NP_FORCE_SPEED_106,
|
||||
} nfc_property;
|
||||
|
||||
// Compiler directive, set struct alignment to 1 uint8_t for compatibility
|
||||
|
|
|
|||
|
|
@ -91,11 +91,11 @@ extern "C" {
|
|||
|
||||
/* Error reporting */
|
||||
NFC_EXPORT const char *nfc_strerror (const nfc_device *pnd);
|
||||
NFC_EXPORT int nfc_strerror_r (const nfc_device *pnd, char *pcStrErrBuf, size_t szBufLen);
|
||||
NFC_EXPORT void nfc_perror (const nfc_device *pnd, const char *pcString);
|
||||
NFC_EXPORT int nfc_strerror_r (const nfc_device *pnd, char *buf, size_t buflen);
|
||||
NFC_EXPORT void nfc_perror (const nfc_device *pnd, const char *s);
|
||||
|
||||
/* Special data accessors */
|
||||
NFC_EXPORT const char *nfc_device_name (nfc_device *pnd);
|
||||
NFC_EXPORT const char *nfc_device_get_name (nfc_device *pnd);
|
||||
|
||||
/* Properties accessors */
|
||||
NFC_EXPORT int nfc_device_set_property_int (nfc_device *pnd, const nfc_property property, const int value);
|
||||
|
|
@ -108,11 +108,17 @@ extern "C" {
|
|||
NFC_EXPORT const char *nfc_version (void);
|
||||
|
||||
/* Error codes */
|
||||
#define NFC_SUCCESS 0 // No error
|
||||
#define NFC_EIO -1 // Input / output error, device will not be usable anymore
|
||||
#define NFC_ENOTSUP -2 // Operation not supported
|
||||
#define NFC_EINVARG -3 // Invalid argument(s)
|
||||
#define NFC_DEVICE_ERROR -4 //Device error
|
||||
#define NFC_SUCCESS 0 // No error
|
||||
#define NFC_EIO -1 // Input / output error, device will not be usable anymore
|
||||
#define NFC_EINVARG -2 // Invalid argument(s)
|
||||
#define NFC_ENOTSUCHDEV -3 // No such device
|
||||
#define NFC_ETIMEOUT -4 // Operation timed out
|
||||
#define NFC_EOVFLOW -5 // Buffer overflow
|
||||
#define NFC_EOPABORTED -6 // Operation aborted (by user)
|
||||
#define NFC_ECHIP -7 // Device's internal chip error
|
||||
#define NFC_EDEVNOTSUPP -8 // Operation not supported by device
|
||||
#define NFC_ENOTIMPL -9 // Not (yet) implemented
|
||||
|
||||
|
||||
/* PN53x specific errors */
|
||||
// TODO: Be not PN53x-specific here
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue