nfc_properties replace now nfc_options and nfc_configure is replaced by nfc_device_set_property_bool which returns error code.

This commit is contained in:
Audrey Diacre 2011-12-14 16:01:00 +00:00
parent c181cb35ec
commit a615d969fd
20 changed files with 292 additions and 298 deletions

View file

@ -96,24 +96,14 @@ typedef enum {
* Default value for this property is 52 ms).
*/
NP_TIMEOUT_COM,
} nfc_property;
// Compiler directive, set struct alignment to 1 uint8_t for compatibility
# pragma pack(1)
/**
* @enum nfc_device_option
* @brief NFC device option
*/
typedef enum {
/** Let the PN53X chip handle the CRC bytes. This means that the chip appends
/** Let the PN53X chip handle the CRC bytes. This means that the chip appends
* the CRC bytes to the frames that are transmitted. It will parse the last
* bytes from received frames as incoming CRC bytes. They will be verified
* against the used modulation and protocol. If an frame is expected with
* 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. */
NDO_HANDLE_CRC = 0x00,
NP_HANDLE_CRC = 0x00,
/** 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
@ -121,31 +111,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. */
NDO_HANDLE_PARITY = 0x01,
NP_HANDLE_PARITY = 0x01,
/** This option can be used to enable or disable the electronic field of the
* NFC device. */
NDO_ACTIVATE_FIELD = 0x10,
NP_ACTIVATE_FIELD = 0x10,
/** The internal CRYPTO1 co-processor can be used to transmit messages
* encrypted. This option is automatically activated after a successful MIFARE
* Classic authentication. */
NDO_ACTIVATE_CRYPTO1 = 0x11,
NP_ACTIVATE_CRYPTO1 = 0x11,
/** 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. */
NDO_INFINITE_SELECT = 0x20,
NP_INFINITE_SELECT = 0x20,
/** 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. */
NDO_ACCEPT_INVALID_FRAMES = 0x30,
NP_ACCEPT_INVALID_FRAMES = 0x30,
/** 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. */
NDO_ACCEPT_MULTIPLE_FRAMES = 0x31,
NP_ACCEPT_MULTIPLE_FRAMES = 0x31,
/** 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
@ -153,16 +143,19 @@ typedef enum {
* requested.
* In target mode, with a NFC chip compiliant (ie. PN532), the chip will
* emulate a 14443-4 PICC using hardware capability */
NDO_AUTO_ISO14443_4 = 0x40,
NP_AUTO_ISO14443_4 = 0x40,
/** Use automatic frames encapsulation and chaining. */
NDO_EASY_FRAMING = 0x41,
NP_EASY_FRAMING = 0x41,
/** Force the chip to switch in ISO14443-A */
NDO_FORCE_ISO14443_A = 0x42,
NP_FORCE_ISO14443_A = 0x42,
/** Force the chip to switch in ISO14443-B */
NDO_FORCE_ISO14443_B = 0x43,
NP_FORCE_ISO14443_B = 0x43,
/** Force the chip to run at 106 kbps */
NDO_FORCE_SPEED_106 = 0x50,
} nfc_device_option;
NP_FORCE_SPEED_106 = 0x50,
} nfc_property;
// Compiler directive, set struct alignment to 1 uint8_t for compatibility
# pragma pack(1)
/**
* @enum nfc_dep_mode

View file

@ -68,7 +68,6 @@ extern "C" {
NFC_EXPORT void nfc_disconnect (nfc_device *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 bool nfc_configure (nfc_device *pnd, const nfc_device_option ndo, const bool bEnable);
NFC_EXPORT bool nfc_idle (nfc_device *pnd);
/* NFC initiator: act as "reader" */
@ -100,7 +99,7 @@ extern "C" {
/* Properties accessors */
NFC_EXPORT int nfc_device_set_property_int (nfc_device *pnd, const nfc_property property, const int value);
// NFC_EXPORT int nfc_device_set_property_bool (nfc_device *pnd, const nfc_property property, const int value);
NFC_EXPORT int nfc_device_set_property_bool (nfc_device *pnd, const nfc_property property, const bool bEnable);
/* Misc. functions */
NFC_EXPORT void iso14443a_crc (uint8_t *pbtData, size_t szLen, uint8_t *pbtCrc);
@ -113,6 +112,7 @@ extern "C" {
#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
/* PN53x specific errors */
// TODO: Be not PN53x-specific here