NFC refactoring (#3050)
"A long time ago in a galaxy far, far away...." we started NFC subsystem refactoring.
Starring:
- @gornekich - NFC refactoring project lead, architect, senior developer
- @gsurkov - architect, senior developer
- @RebornedBrain - senior developer
Supporting roles:
- @skotopes, @DrZlo13, @hedger - general architecture advisors, code review
- @Astrrra, @doomwastaken, @Hellitron, @ImagineVagon333 - quality assurance
Special thanks:
@bettse, @pcunning, @nxv, @noproto, @AloneLiberty and everyone else who has been helping us all this time and contributing valuable knowledges, ideas and source code.
2023-10-24 06:08:09 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "iso14443_3a.h"
|
|
|
|
#include <lib/nfc/nfc.h>
|
|
|
|
|
|
|
|
#include <nfc/nfc_poller.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2023-11-15 11:32:45 +03:00
|
|
|
/**
|
|
|
|
* @brief Iso14443_3aPoller opaque type definition.
|
|
|
|
*/
|
NFC refactoring (#3050)
"A long time ago in a galaxy far, far away...." we started NFC subsystem refactoring.
Starring:
- @gornekich - NFC refactoring project lead, architect, senior developer
- @gsurkov - architect, senior developer
- @RebornedBrain - senior developer
Supporting roles:
- @skotopes, @DrZlo13, @hedger - general architecture advisors, code review
- @Astrrra, @doomwastaken, @Hellitron, @ImagineVagon333 - quality assurance
Special thanks:
@bettse, @pcunning, @nxv, @noproto, @AloneLiberty and everyone else who has been helping us all this time and contributing valuable knowledges, ideas and source code.
2023-10-24 06:08:09 +03:00
|
|
|
typedef struct Iso14443_3aPoller Iso14443_3aPoller;
|
|
|
|
|
2023-11-15 11:32:45 +03:00
|
|
|
/**
|
|
|
|
* @brief Enumeration of possible Iso14443_3a poller event types.
|
|
|
|
*/
|
NFC refactoring (#3050)
"A long time ago in a galaxy far, far away...." we started NFC subsystem refactoring.
Starring:
- @gornekich - NFC refactoring project lead, architect, senior developer
- @gsurkov - architect, senior developer
- @RebornedBrain - senior developer
Supporting roles:
- @skotopes, @DrZlo13, @hedger - general architecture advisors, code review
- @Astrrra, @doomwastaken, @Hellitron, @ImagineVagon333 - quality assurance
Special thanks:
@bettse, @pcunning, @nxv, @noproto, @AloneLiberty and everyone else who has been helping us all this time and contributing valuable knowledges, ideas and source code.
2023-10-24 06:08:09 +03:00
|
|
|
typedef enum {
|
2023-11-15 11:32:45 +03:00
|
|
|
Iso14443_3aPollerEventTypeError, /**< The card was activated by the poller. */
|
|
|
|
Iso14443_3aPollerEventTypeReady, /**< An error occured during activation procedure. */
|
NFC refactoring (#3050)
"A long time ago in a galaxy far, far away...." we started NFC subsystem refactoring.
Starring:
- @gornekich - NFC refactoring project lead, architect, senior developer
- @gsurkov - architect, senior developer
- @RebornedBrain - senior developer
Supporting roles:
- @skotopes, @DrZlo13, @hedger - general architecture advisors, code review
- @Astrrra, @doomwastaken, @Hellitron, @ImagineVagon333 - quality assurance
Special thanks:
@bettse, @pcunning, @nxv, @noproto, @AloneLiberty and everyone else who has been helping us all this time and contributing valuable knowledges, ideas and source code.
2023-10-24 06:08:09 +03:00
|
|
|
} Iso14443_3aPollerEventType;
|
|
|
|
|
2023-11-15 11:32:45 +03:00
|
|
|
/**
|
|
|
|
* @brief Iso14443_3a poller event data.
|
|
|
|
*/
|
|
|
|
typedef union {
|
|
|
|
Iso14443_3aError error; /**< Error code indicating card activation fail reason. */
|
NFC refactoring (#3050)
"A long time ago in a galaxy far, far away...." we started NFC subsystem refactoring.
Starring:
- @gornekich - NFC refactoring project lead, architect, senior developer
- @gsurkov - architect, senior developer
- @RebornedBrain - senior developer
Supporting roles:
- @skotopes, @DrZlo13, @hedger - general architecture advisors, code review
- @Astrrra, @doomwastaken, @Hellitron, @ImagineVagon333 - quality assurance
Special thanks:
@bettse, @pcunning, @nxv, @noproto, @AloneLiberty and everyone else who has been helping us all this time and contributing valuable knowledges, ideas and source code.
2023-10-24 06:08:09 +03:00
|
|
|
} Iso14443_3aPollerEventData;
|
|
|
|
|
2023-11-15 11:32:45 +03:00
|
|
|
/**
|
|
|
|
* @brief Iso14443_3a poller event structure.
|
|
|
|
*
|
|
|
|
* Upon emission of an event, an instance of this struct will be passed to the callback.
|
|
|
|
*/
|
NFC refactoring (#3050)
"A long time ago in a galaxy far, far away...." we started NFC subsystem refactoring.
Starring:
- @gornekich - NFC refactoring project lead, architect, senior developer
- @gsurkov - architect, senior developer
- @RebornedBrain - senior developer
Supporting roles:
- @skotopes, @DrZlo13, @hedger - general architecture advisors, code review
- @Astrrra, @doomwastaken, @Hellitron, @ImagineVagon333 - quality assurance
Special thanks:
@bettse, @pcunning, @nxv, @noproto, @AloneLiberty and everyone else who has been helping us all this time and contributing valuable knowledges, ideas and source code.
2023-10-24 06:08:09 +03:00
|
|
|
typedef struct {
|
2023-11-15 11:32:45 +03:00
|
|
|
Iso14443_3aPollerEventType type; /**< Type of emmitted event. */
|
|
|
|
Iso14443_3aPollerEventData* data; /**< Pointer to event specific data. */
|
NFC refactoring (#3050)
"A long time ago in a galaxy far, far away...." we started NFC subsystem refactoring.
Starring:
- @gornekich - NFC refactoring project lead, architect, senior developer
- @gsurkov - architect, senior developer
- @RebornedBrain - senior developer
Supporting roles:
- @skotopes, @DrZlo13, @hedger - general architecture advisors, code review
- @Astrrra, @doomwastaken, @Hellitron, @ImagineVagon333 - quality assurance
Special thanks:
@bettse, @pcunning, @nxv, @noproto, @AloneLiberty and everyone else who has been helping us all this time and contributing valuable knowledges, ideas and source code.
2023-10-24 06:08:09 +03:00
|
|
|
} Iso14443_3aPollerEvent;
|
|
|
|
|
2023-11-15 11:32:45 +03:00
|
|
|
/**
|
|
|
|
* @brief Transmit and receive Iso14443_3a frames in poller mode.
|
|
|
|
*
|
|
|
|
* Must ONLY be used inside the callback function.
|
|
|
|
*
|
|
|
|
* The rx_buffer will be filled with any data received as a response to data
|
|
|
|
* sent from tx_buffer, with a timeout defined by the fwt parameter.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param[in, out] instance pointer to the instance to be used in the transaction.
|
|
|
|
* @param[in] tx_buffer pointer to the buffer containing the data to be transmitted.
|
|
|
|
* @param[out] rx_buffer pointer to the buffer to be filled with received data.
|
|
|
|
* @param[in] fwt frame wait time (response timeout), in carrier cycles.
|
|
|
|
* @return Iso14443_3aErrorNone on success, an error code on failure.
|
|
|
|
*/
|
NFC refactoring (#3050)
"A long time ago in a galaxy far, far away...." we started NFC subsystem refactoring.
Starring:
- @gornekich - NFC refactoring project lead, architect, senior developer
- @gsurkov - architect, senior developer
- @RebornedBrain - senior developer
Supporting roles:
- @skotopes, @DrZlo13, @hedger - general architecture advisors, code review
- @Astrrra, @doomwastaken, @Hellitron, @ImagineVagon333 - quality assurance
Special thanks:
@bettse, @pcunning, @nxv, @noproto, @AloneLiberty and everyone else who has been helping us all this time and contributing valuable knowledges, ideas and source code.
2023-10-24 06:08:09 +03:00
|
|
|
Iso14443_3aError iso14443_3a_poller_txrx(
|
|
|
|
Iso14443_3aPoller* instance,
|
|
|
|
const BitBuffer* tx_buffer,
|
|
|
|
BitBuffer* rx_buffer,
|
|
|
|
uint32_t fwt);
|
|
|
|
|
2023-11-15 11:32:45 +03:00
|
|
|
/**
|
|
|
|
* @brief Transmit and receive Iso14443_3a standard frames in poller mode.
|
|
|
|
*
|
|
|
|
* Must ONLY be used inside the callback function.
|
|
|
|
*
|
|
|
|
* The rx_buffer will be filled with any data received as a response to data
|
|
|
|
* sent from tx_buffer, with a timeout defined by the fwt parameter.
|
|
|
|
*
|
|
|
|
* @param[in, out] instance pointer to the instance to be used in the transaction.
|
|
|
|
* @param[in] tx_buffer pointer to the buffer containing the data to be transmitted.
|
|
|
|
* @param[out] rx_buffer pointer to the buffer to be filled with received data.
|
|
|
|
* @param[in] fwt frame wait time (response timeout), in carrier cycles.
|
|
|
|
* @return Iso14443_3aErrorNone on success, an error code on failure.
|
|
|
|
*/
|
NFC refactoring (#3050)
"A long time ago in a galaxy far, far away...." we started NFC subsystem refactoring.
Starring:
- @gornekich - NFC refactoring project lead, architect, senior developer
- @gsurkov - architect, senior developer
- @RebornedBrain - senior developer
Supporting roles:
- @skotopes, @DrZlo13, @hedger - general architecture advisors, code review
- @Astrrra, @doomwastaken, @Hellitron, @ImagineVagon333 - quality assurance
Special thanks:
@bettse, @pcunning, @nxv, @noproto, @AloneLiberty and everyone else who has been helping us all this time and contributing valuable knowledges, ideas and source code.
2023-10-24 06:08:09 +03:00
|
|
|
Iso14443_3aError iso14443_3a_poller_send_standard_frame(
|
|
|
|
Iso14443_3aPoller* instance,
|
|
|
|
const BitBuffer* tx_buffer,
|
|
|
|
BitBuffer* rx_buffer,
|
|
|
|
uint32_t fwt);
|
|
|
|
|
2023-11-15 11:32:45 +03:00
|
|
|
/**
|
|
|
|
* @brief Transmit and receive Iso14443_3a frames with custom parity bits in poller mode.
|
|
|
|
*
|
|
|
|
* Must ONLY be used inside the callback function.
|
|
|
|
*
|
|
|
|
* The rx_buffer will be filled with any data received as a response to data
|
|
|
|
* sent from tx_buffer, with a timeout defined by the fwt parameter.
|
|
|
|
*
|
|
|
|
* Custom parity bits must be set in the tx_buffer. The rx_buffer will contain
|
|
|
|
* the received data with the parity bits.
|
|
|
|
*
|
|
|
|
* @param[in, out] instance pointer to the instance to be used in the transaction.
|
|
|
|
* @param[in] tx_buffer pointer to the buffer containing the data to be transmitted.
|
|
|
|
* @param[out] rx_buffer pointer to the buffer to be filled with received data.
|
|
|
|
* @param[in] fwt frame wait time (response timeout), in carrier cycles.
|
|
|
|
* @return Iso14443_3aErrorNone on success, an error code on failure.
|
|
|
|
*/
|
|
|
|
Iso14443_3aError iso14443_3a_poller_txrx_custom_parity(
|
|
|
|
Iso14443_3aPoller* instance,
|
|
|
|
const BitBuffer* tx_buffer,
|
|
|
|
BitBuffer* rx_buffer,
|
|
|
|
uint32_t fwt);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Checks presence of Iso14443_3a complient card.
|
|
|
|
*
|
|
|
|
* Must ONLY be used inside the callback function.
|
|
|
|
*
|
|
|
|
* @param[in, out] instance pointer to the instance to be used in the transaction.
|
|
|
|
* @return Iso14443_3aErrorNone if card is present, an error code otherwise.
|
|
|
|
*/
|
|
|
|
Iso14443_3aError iso14443_3a_poller_check_presence(Iso14443_3aPoller* instance);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Perform collision resolution procedure.
|
|
|
|
*
|
|
|
|
* Must ONLY be used inside the callback function.
|
|
|
|
*
|
|
|
|
* Perfoms the collision resolution procedure as defined in Iso14443-3a. The iso14443_3a_data
|
|
|
|
* field will be filled with Iso14443-3a data on success.
|
|
|
|
*
|
|
|
|
* @param[in, out] instance pointer to the instance to be used in the transaction.
|
|
|
|
* @param[out] iso14443_3a_data pointer to the Iso14443_3a data structure to be filled.
|
|
|
|
* @return Iso14443_3aErrorNone on success, an error code on failure.
|
|
|
|
*/
|
|
|
|
Iso14443_3aError
|
|
|
|
iso14443_3a_poller_activate(Iso14443_3aPoller* instance, Iso14443_3aData* iso14443_3a_data);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Send HALT command to the card.
|
|
|
|
*
|
|
|
|
* Must ONLY be used inside the callback function.
|
|
|
|
*
|
|
|
|
* Halts card and changes internal Iso14443_3aPoller state to Idle.
|
|
|
|
*
|
|
|
|
* @param[in, out] instance pointer to the instance to be used in the transaction.
|
|
|
|
* @return Iso14443_3aErrorNone on success, an error code on failure.
|
|
|
|
*/
|
|
|
|
Iso14443_3aError iso14443_3a_poller_halt(Iso14443_3aPoller* instance);
|
|
|
|
|
NFC refactoring (#3050)
"A long time ago in a galaxy far, far away...." we started NFC subsystem refactoring.
Starring:
- @gornekich - NFC refactoring project lead, architect, senior developer
- @gsurkov - architect, senior developer
- @RebornedBrain - senior developer
Supporting roles:
- @skotopes, @DrZlo13, @hedger - general architecture advisors, code review
- @Astrrra, @doomwastaken, @Hellitron, @ImagineVagon333 - quality assurance
Special thanks:
@bettse, @pcunning, @nxv, @noproto, @AloneLiberty and everyone else who has been helping us all this time and contributing valuable knowledges, ideas and source code.
2023-10-24 06:08:09 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|