Common interface layer for each chip of the NFC-A emulation.
More...
#include <emulation_layer_a.hpp>
|
| enum class | State {
None
, Off
, Idle
, Ready
,
Active
, Halt
} |
| | Emulation state for NFC-A.
|
| |
|
|
| EmulationLayerA (m5::unit::UnitST25R3916 &u) |
| | Construct with UnitST25R3916 (I2C)
|
| |
|
| EmulationLayerA (m5::unit::CapST25R3916 &u) |
| | Construct with CapST25R3916 (SPI)
|
| |
|
State | state () const |
| | Gets the current emulation state.
|
| |
|
const m5::nfc::a::PICC & | emulatePICC () const |
| | Gets the emulated PICC information.
|
| |
|
uint32_t | expiredTime () const |
| | Gets the expiration time (ms)
|
| |
| void | setExpiredTime (const uint32_t ms) |
| | Sets the expiration time (ms)
|
| |
|
bool | begin (const m5::nfc::a::PICC &picc, uint8_t *ptr, const uint32_t size) |
| | Begin NFC-A emulation.
|
| |
|
bool | end () |
| | End NFC-A emulation.
|
| |
|
void | update () |
| | Update emulation state machine.
|
| |
| virtual State | receive_callback (const uint8_t *rx, const uint32_t rx_len) |
| | Handles a command received from the reader.
|
| |
|
|
void | update_expired () |
| |
|
bool | transmit (const uint8_t *tx, const uint16_t tx_len, const uint32_t timeout_ms) |
| |
|
|
uint8_t * | _memory {} |
| |
|
uint32_t | _memory_size {} |
| |
Common interface layer for each chip of the NFC-A emulation.
- Note
- The chip emulates one technology at a time, so this cannot run alongside EmulationLayerF. The unit must be configured for NFC-A emulation before begin().
◆ receive_callback()
| EmulationLayerA::State m5::nfc::EmulationLayerA::receive_callback |
( |
const uint8_t * | rx, |
|
|
const uint32_t | rx_len ) |
|
virtual |
Handles a command received from the reader.
- Parameters
-
| rx | Received frame (without CRC) |
| rx_len | Received length |
- Returns
- State to move to. State::Active keeps the emulation listening for the next command of the same session, State::Idle or State::Halt ends it
- Note
- Override this to answer commands that the library does not handle, and call EmulationLayerA::receive_callback for the rest. Answer with transmit()
◆ setExpiredTime()
| void m5::nfc::EmulationLayerA::setExpiredTime |
( |
const uint32_t | ms | ) |
|
|
inline |
Sets the expiration time (ms)
- Parameters
-
| ms | How long a state may last before the emulation returns to State::Off. Zero turns this off |
- Note
- A reader that leaves in the middle of a session leaves the emulation waiting in that state, and nothing on the RF side tells it to stop. Going back to Off lets the next reader find it again. State::Off itself never expires
-
The time is measured from the last RF traffic, so a session that keeps talking is not cut off however long it runs