Class pn532::p2p::pn532_target

Inheritance Relationships

Base Type

Class Documentation

class pn532_target : public pn532::p2p::target

Specialization of initiator which uses a controller as target. This is a move-only object.

Public Functions

pn532_target() = default

Default-constructs the target class. The receive and send methods will always return channel_error::app_error.

explicit pn532_target(controller &controller)

Wraps a controller to work as a P2P target.

Note

This method does not itself put controller into target mode. The caller should do this themselves. The method init_as_dep_target is provided as a shorthand.

Parameters:

controller – The PN532 controller. This reference must stay valid throughout the whole lifetime of this object.

pn532_target(pn532_target const&) = delete
pn532_target &operator=(pn532_target const&) = delete
pn532_target(pn532_target&&) noexcept = default
pn532_target &operator=(pn532_target&&) noexcept = default
result<pn532::activation_as_target> init_as_dep_target(std::array<std::uint8_t, 5> nfcid_data, ms timeout = 5s)

Shorthand method which initializes the given controller as a DEP target. This method will make up some of the parameters needed for initialization, and must be called before an exchange can begin. Of course the caller may also call controller::target_init_as_target by themselves, providing custom parameters. This method will initialize a DEP-only, passive or active target for P2P NFC communications.

Parameters:
  • nfcid_data – These bytes will be used to generate the NFC ID. Due to PN532 restrictions and requirements from ISO/IEC 14443-3, the resulting NFC ids will be

    • NFCID1: 0x08 XX XX

    • NFCID2: 0x88 0x08 XX XX 0x88 XX XX XX

    • NFCID3: 0x88 0x08 XX XX 0x88 XX XX XX 0x00 0x00 where all the XX fields are filled with consecutive bytes from nfcid_data

  • timeout – Maximum time after which channel_error::timeout is returned.

virtual result<mlab::bin_data> receive(ms timeout) override

Receives data over controller::target_get_data.

virtual result send(mlab::bin_data const &data, ms timeout) override

Receives data over controller::target_set_data.