Keyple C++  0.9.0
Keyple, an Open Source SDK for Ticketing
Public Member Functions | Protected Member Functions | List of all members
keyple::plugin::pcsc::PcscReaderImpl Class Reference

#include <PcscReaderImpl.h>

Inherits keyple::core::seproxy::plugin::AbstractObservableLocalReader, keyple::plugin::pcsc::PcscReader, keyple::core::seproxy::plugin::SmartInsertionReader, and keyple::core::seproxy::plugin::SmartRemovalReader.

Public Member Functions

 PcscReaderImpl (const std::string &pluginName, const PcscTerminal &terminal)
 
 ~PcscReaderImpl ()
 
void setParameter (const std::string &name, const std::string &value) override
 
const std::map< const std::string, const std::string > & getParameters () const override
 
const TransmissionModegetTransmissionMode () const override
 
std::shared_ptr< ObservableReaderStateServiceinitStateService () override
 
virtual const std::string & getName () const final
 
virtual void setParameters (const std::map< const std::string, const std::string > &parameters) final
 
- Public Member Functions inherited from keyple::core::seproxy::plugin::AbstractObservableLocalReader
 AbstractObservableLocalReader (const std::string &pluginName, const std::string &readerName)
 
virtual ~AbstractObservableLocalReader ()=default
 
bool isSePresent () override
 
void startSeDetection (const ObservableReader::PollingMode pollingMode) final
 
void stopSeDetection () final
 
void setDefaultSelectionRequest (std::shared_ptr< AbstractDefaultSelectionsRequest > defaultSelectionsRequest, const ObservableReader::NotificationMode &notificationMode) final
 
void setDefaultSelectionRequest (std::shared_ptr< AbstractDefaultSelectionsRequest > defaultSelectionsRequest, const ObservableReader::NotificationMode &notificationMode, const ObservableReader::PollingMode pollingMode) final
 
virtual std::shared_ptr< ReaderEventprocessSeInserted ()
 
bool isSePresentPing ()
 
void processSeRemoved ()
 
const ObservableReader::PollingModegetPollingMode () const
 
const MonitoringStategetCurrentMonitoringState () const
 
void switchState (const MonitoringState stateId)
 
void addObserver (const std::shared_ptr< ObservableReader::ReaderObserver > observer) final
 
void removeObserver (const std::shared_ptr< ObservableReader::ReaderObserver > observer) final
 
void notifyObservers (const std::shared_ptr< ReaderEvent > event) final
 
int countObservers () const final
 
void clearObservers () final
 
void terminateSeCommunication () override
 
void finalizeSeProcessing () override
 
void onEvent (const InternalEvent event)
 
- Public Member Functions inherited from keyple::core::seproxy::plugin::AbstractLocalReader
 AbstractLocalReader (const std::string &pluginName, const std::string &readerName)
 
virtual ~AbstractLocalReader ()=default
 
virtual bool isLogicalChannelOpen () const final
 
void addSeProtocolSetting (std::shared_ptr< SeProtocol > seProtocol, const std::string &protocolRule) override
 
virtual void setSeProtocolSetting (const std::map< std::shared_ptr< SeProtocol >, std::string > &protocolSetting) override
 
virtual std::shared_ptr< SelectionStatusopenLogicalChannel (std::shared_ptr< SeSelector > seSelector)
 
std::shared_ptr< SelectionStatusopenLogicalChannelAndSelect (std::shared_ptr< SeSelector > seSelector)
 
virtual std::vector< std::shared_ptr< SeResponse > > processSeRequests (const std::vector< std::shared_ptr< SeRequest >> &seRequests, const MultiSeRequestProcessing &multiSeRequestProcessing, const ChannelControl &channelControl) override
 
virtual std::shared_ptr< SeResponseprocessSeRequest (const std::shared_ptr< SeRequest > seRequest, const ChannelControl &channelControl) override
 
- Public Member Functions inherited from keyple::core::seproxy::plugin::AbstractReader
std::vector< std::shared_ptr< SeResponse > > transmitSeRequests (const std::vector< std::shared_ptr< SeRequest >> &seRequests, const MultiSeRequestProcessing &multiSeRequestProcessing, const ChannelControl &channelControl) override
 
std::shared_ptr< SeResponsetransmitSeRequest (std::shared_ptr< SeRequest > seRequest, const ChannelControl &channelControl) override
 
const std::string & getPluginName () const
 
- Public Member Functions inherited from keyple::core::seproxy::plugin::AbstractSeProxyComponent
 AbstractSeProxyComponent (const std::string &name)
 
virtual ~AbstractSeProxyComponent ()=default
 
const std::string & getName () const
 
void setParameters (const std::map< const std::string, const std::string > &parameters)
 
- Public Member Functions inherited from keyple::core::seproxy::message::ProxyReader
virtual ~ProxyReader ()
 
- Public Member Functions inherited from keyple::core::seproxy::SeReader
virtual ~SeReader ()
 
virtual bool operator== (const SeReader &o) const
 
- Public Member Functions inherited from keyple::core::seproxy::ProxyElement
virtual ~ProxyElement ()=default
 
- Public Member Functions inherited from keyple::core::seproxy::plugin::ObservableReaderNotifier
 ObservableReaderNotifier ()
 
virtual ~ObservableReaderNotifier ()
 
- Public Member Functions inherited from keyple::core::seproxy::event::ObservableReader
virtual ~ObservableReader ()=default
 
virtual void addObserver (const std::shared_ptr< ReaderObserver > observer)=0
 
virtual void removeObserver (const std::shared_ptr< ReaderObserver > observer)=0
 
- Public Member Functions inherited from keyple::core::seproxy::plugin::SmartInsertionReader
virtual ~SmartInsertionReader ()
 
- Public Member Functions inherited from keyple::core::seproxy::plugin::SmartRemovalReader
virtual ~SmartRemovalReader ()
 

Protected Member Functions

void closePhysicalChannel () override
 
bool checkSePresence () override
 
bool waitForCardPresent () override
 
void stopWaitForCard () override
 
bool waitForCardAbsentNative () override
 
void stopWaitForCardRemoval () override
 
std::vector< uint8_t > transmitApdu (const std::vector< uint8_t > &apduIn) override
 
bool protocolFlagMatches (const std::shared_ptr< SeProtocol > protocolFlag) override
 
const std::vector< uint8_t > & getATR () override
 
bool isPhysicalChannelOpen () override
 
void openPhysicalChannel () override
 
- Protected Member Functions inherited from keyple::core::seproxy::plugin::AbstractLocalReader
void closeLogicalAndPhysicalChannels ()
 
virtual void setForceGetDataFlag (bool forceGetDataFlag)
 
void closeLogicalChannel ()
 
std::shared_ptr< ApduResponseprocessApduRequest (std::shared_ptr< ApduRequest > apduRequest)
 
const std::map< std::shared_ptr< SeProtocol >, std::string > & getProtocolsMap () const
 
- Protected Member Functions inherited from keyple::core::seproxy::plugin::AbstractReader
 AbstractReader (const std::string &pluginName, const std::string &name)
 
virtual ~AbstractReader ()=default
 

Additional Inherited Members

- Public Types inherited from keyple::core::seproxy::event::ObservableReader
enum  PollingMode { PollingMode::REPEATING, PollingMode::SINGLESHOT }
 
- Public Attributes inherited from keyple::core::seproxy::plugin::ObservableReaderNotifier
std::atomic< bool > mShuttingDown
 
- Static Public Attributes inherited from keyple::plugin::pcsc::PcscReader
static const std::string SETTING_KEY_TRANSMISSION_MODE
 
static const std::string SETTING_TRANSMISSION_MODE_CONTACTS = "contacts"
 
static const std::string SETTING_TRANSMISSION_MODE_CONTACTLESS
 
static const std::string SETTING_KEY_PROTOCOL = "protocol"
 
static const std::string SETTING_PROTOCOL_T0 = "T0"
 
static const std::string SETTING_PROTOCOL_T1 = "T1"
 
static const std::string SETTING_PROTOCOL_T_CL = "TCL"
 
static const std::string SETTING_PROTOCOL_TX = "Tx"
 
static const std::string SETTING_KEY_MODE = "mode"
 
static const std::string SETTING_MODE_EXCLUSIVE = "exclusive"
 
static const std::string SETTING_MODE_SHARED = "shared"
 
static const std::string SETTING_KEY_DISCONNECT = "disconnect"
 
static const std::string SETTING_DISCONNECT_RESET = "reset"
 
static const std::string SETTING_DISCONNECT_UNPOWER = "unpower"
 
static const std::string SETTING_DISCONNECT_LEAVE = "leave"
 
static const std::string SETTING_DISCONNECT_EJECT = "eject"
 
- Static Protected Member Functions inherited from keyple::core::seproxy::plugin::AbstractLocalReader
static bool startsWith (const std::vector< uint8_t > &source, const std::vector< uint8_t > &match)
 
- Protected Attributes inherited from keyple::core::seproxy::plugin::AbstractObservableLocalReader
std::shared_ptr< ObservableReaderStateServicemStateService
 
- Protected Attributes inherited from keyple::core::seproxy::plugin::AbstractReader
std::shared_ptr< DefaultSelectionsRequestmDefaultSelectionsRequest
 
ObservableReader::NotificationMode mNotificationMode
 

Constructor & Destructor Documentation

◆ PcscReaderImpl()

keyple::plugin::pcsc::PcscReaderImpl::PcscReaderImpl ( const std::string &  pluginName,
const PcscTerminal terminal 
)

This constructor should only be called by PcscPlugin PCSC reader parameters are initialized with their default values as defined in setParameter. See setParameter() for more details

Parameters
pluginNamethe name of the plugin
terminalthe PC/SC terminal

◆ ~PcscReaderImpl()

keyple::plugin::pcsc::PcscReaderImpl::~PcscReaderImpl ( )

Member Function Documentation

◆ checkSePresence()

bool keyple::plugin::pcsc::PcscReaderImpl::checkSePresence ( )
overrideprotectedvirtual

Wrapper for the native method of the plugin specific local reader to verify the presence of the SE.

This method must be implemented by the ProxyReader plugin (e.g. Pcsc reader plugin).

This method is invoked by isSePresent.

Returns
true if the SE is present
Exceptions
KeypleReaderIOExceptionif the communication with the reader or the SE has failed

Implements keyple::core::seproxy::plugin::AbstractLocalReader.

◆ closePhysicalChannel()

void keyple::plugin::pcsc::PcscReaderImpl::closePhysicalChannel ( )
overrideprotectedvirtual

Closes the current physical channel.

This method must be implemented by the ProxyReader plugin (e.g. Pcsc/Nfc/Omapi Reader).

Exceptions
KeypleReaderIOExceptionif the communication with the reader or the SE has failed

Implements keyple::core::seproxy::plugin::AbstractLocalReader.

◆ getATR()

const std::vector< uint8_t > & keyple::plugin::pcsc::PcscReaderImpl::getATR ( )
overrideprotectedvirtual

This abstract method must be implemented by the derived class in order to provide the SE ATR when available.

Gets the SE Answer to reset

Returns
ATR returned by the SE or reconstructed by the reader (contactless)

Implements keyple::core::seproxy::plugin::AbstractLocalReader.

◆ getName()

virtual const std::string& keyple::plugin::pcsc::PcscReaderImpl::getName ( ) const
inlinefinalvirtual

C++ vs. Java: temp hack

Reimplemented from keyple::core::seproxy::plugin::AbstractReader.

◆ getParameters()

const std::map< const std::string, const std::string > & keyple::plugin::pcsc::PcscReaderImpl::getParameters ( ) const
overridevirtual

Gets the parameters

Returns
the configuration of the item

Implements keyple::core::seproxy::ProxyElement.

◆ getTransmissionMode()

const TransmissionMode & keyple::plugin::pcsc::PcscReaderImpl::getTransmissionMode ( ) const
overridevirtual

The transmission mode can set with setParameter(SETTING_KEY_TRANSMISSION_MODE, )

When the transmission mode has not explicitly set, it is deduced from the protocol:

  • T=0: contacts mode
  • T=1: contactless mode
Returns
the current transmission mode

Implements keyple::core::seproxy::SeReader.

◆ initStateService()

std::shared_ptr< ObservableReaderStateService > keyple::plugin::pcsc::PcscReaderImpl::initStateService ( )
overridevirtual

Initialize the ObservableReaderStateService with the possible states and their implementation. ObservableReaderStateService define the initial state.

Make sure to initialize the stateService in your reader constructor with stateService = initStateService()

Returns
initialized state stateService with possible states and the init state

Implements keyple::core::seproxy::plugin::AbstractObservableLocalReader.

◆ isPhysicalChannelOpen()

bool keyple::plugin::pcsc::PcscReaderImpl::isPhysicalChannelOpen ( )
overrideprotectedvirtual

Tells if a physical channel is open

This status may be wrong if the card has been removed.

The caller should test the card presence with isSePresent before calling this method.

Returns
true if the physical channel is open

Implements keyple::core::seproxy::plugin::AbstractLocalReader.

◆ openPhysicalChannel()

void keyple::plugin::pcsc::PcscReaderImpl::openPhysicalChannel ( )
overrideprotectedvirtual

Opens a physical channel

The card access may be set to 'Exclusive' through the reader's settings.

In this case be aware that on some platforms (ex. Windows 8+), the exclusivity is granted for a limited time (ex. 5 seconds). After this delay, the card is automatically resetted.

Exceptions
KeypleReaderIOExceptionif the communication with the reader or the SE has failed

Implements keyple::core::seproxy::plugin::AbstractLocalReader.

◆ protocolFlagMatches()

bool keyple::plugin::pcsc::PcscReaderImpl::protocolFlagMatches ( const std::shared_ptr< SeProtocol protocolFlag)
overrideprotectedvirtual

Tells if the current SE protocol matches the provided protocol flag. If the protocol flag is not defined (null), we consider here that it matches. An exception is returned when the provided protocolFlag is not found in the current protocolMap.

Parameters
protocolFlagthe protocol flag
Returns
true if the current SE matches the protocol flag
Exceptions
KeypleReaderIOExceptionif the communication with the reader or the SE has failed

Implements keyple::core::seproxy::plugin::AbstractLocalReader.

◆ setParameter()

void keyple::plugin::pcsc::PcscReaderImpl::setParameter ( const std::string &  name,
const std::string &  value 
)
overridevirtual

Set a parameter.

These are the parameters you can use with their associated values:

  • protocol:
    • Tx: Automatic negotiation (default)
    • T0: T0 protocol
    • T1: T1 protocol
  • mode:
    • shared: Shared between apps and threads (default)
    • exclusive: Exclusive to this app and the current thread
  • disconnect:
    • reset: Reset the card
    • unpower: Simply unpower it
    • leave: Unsupported
    • eject: Eject
  • thread_wait_timeout: Number of milliseconds towait
Parameters
nameParameter name
valueParameter value
Exceptions
KeypleReaderIOExceptionif the communication with the reader or the SE has failed, when disabling the exclusive mode as it's executed instantly

Implements keyple::core::seproxy::plugin::AbstractSeProxyComponent.

◆ setParameters()

virtual void keyple::plugin::pcsc::PcscReaderImpl::setParameters ( const std::map< const std::string, const std::string > &  parameters)
inlinefinalvirtual

C++ vs Java: temp hack

Reimplemented from keyple::core::seproxy::ProxyElement.

◆ stopWaitForCard()

void keyple::plugin::pcsc::PcscReaderImpl::stopWaitForCard ( )
overrideprotectedvirtual

Interrupts the waiting of a SE

Reimplemented from keyple::core::seproxy::plugin::SmartInsertionReader.

◆ stopWaitForCardRemoval()

void keyple::plugin::pcsc::PcscReaderImpl::stopWaitForCardRemoval ( )
overrideprotectedvirtual

Interrupts the waiting of the removal of the SE

Reimplemented from keyple::core::seproxy::plugin::SmartRemovalReader.

◆ transmitApdu()

std::vector< uint8_t > keyple::plugin::pcsc::PcscReaderImpl::transmitApdu ( const std::vector< uint8_t > &  apduIn)
overrideprotectedvirtual

Transmission of single APDU

Parameters
apduInAPDU in buffer
Returns
apduOut buffer
Exceptions
KeypleIOReaderExceptionif the transmission failed

Implements keyple::core::seproxy::plugin::AbstractLocalReader.

◆ waitForCardAbsentNative()

bool keyple::plugin::pcsc::PcscReaderImpl::waitForCardAbsentNative ( )
overrideprotectedvirtual

Wait for the card absent event from smartcard.io

Returns
true if the card is removed within the delay

Implements keyple::core::seproxy::plugin::SmartRemovalReader.

◆ waitForCardPresent()

bool keyple::plugin::pcsc::PcscReaderImpl::waitForCardPresent ( )
overrideprotectedvirtual

Waits for a SE. Returns true if a SE is detected before the end of the provided timeout.

This method must be implemented by the plugin's reader class when it implements the keyple::core::seproxy::plugin::SmartInsertionReader interface.

Returns false if no SE is detected

Returns
presence status
Exceptions
KeypleReaderIOExceptionif the communication with the reader or the SE has failed (disconnection)

Implements keyple::core::seproxy::plugin::SmartInsertionReader.


The documentation for this class was generated from the following files: