mirror of https://github.com/ARMmbed/mbed-os.git
Add documemtation for ISO7816App
parent
f6a0cb3ae2
commit
b14e18d170
|
@ -25,47 +25,101 @@
|
|||
namespace mbed {
|
||||
namespace nfc {
|
||||
|
||||
/**
|
||||
* @addtogroup nfc
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* This base class represents an ISO7816-4 application.
|
||||
*/
|
||||
class ISO7816App {
|
||||
/**
|
||||
* This class describes an ISO7816-4 exchange (Command/Response).
|
||||
*/
|
||||
class Exchange {
|
||||
public:
|
||||
/**
|
||||
* A Command APDU (Application Protocol Data Unit) .
|
||||
*/
|
||||
struct CAPDU
|
||||
{
|
||||
uint8_t cla;
|
||||
uint8_t ins;
|
||||
uint8_t p1;
|
||||
uint8_t p2;
|
||||
ac_buffer_t dataIn;
|
||||
size_t maxRespLength;
|
||||
uint8_t cla; ///< CLA - Instruction class
|
||||
uint8_t ins; ///< INS - Instruction code
|
||||
uint8_t p1; ///< P1 - First parameter
|
||||
uint8_t p2; ///< P2 - Second parameter
|
||||
ac_buffer_t dataIn; ///< Command data
|
||||
size_t maxRespLength; ///< Maximum response length
|
||||
};
|
||||
|
||||
/**
|
||||
* A Response APDU (Application Protocol Data Unit)
|
||||
*/
|
||||
struct RAPDU
|
||||
{
|
||||
ac_buffer_t dataOut;
|
||||
uint16_t sw;
|
||||
ac_buffer_t dataOut; ///< Response data
|
||||
uint16_t sw; ///< Status word
|
||||
};
|
||||
|
||||
/**
|
||||
* Access Command APDU.
|
||||
*
|
||||
* @return a const reference to the Command ADPU
|
||||
*/
|
||||
const CAPDU& command() const;
|
||||
|
||||
/**
|
||||
* Access Response APDU.
|
||||
*
|
||||
* @return a mutable reference to the Command ADPU
|
||||
*/
|
||||
RAPDU& response();
|
||||
|
||||
/**
|
||||
* Respond to command.
|
||||
*
|
||||
* @return NFC_OK if the response could be sent back successfully, or an error code otherwise
|
||||
*/
|
||||
nfc_err_t respond();
|
||||
|
||||
private:
|
||||
Command _command;
|
||||
Response _response;
|
||||
ISO7816Application* _app;
|
||||
CAPDU _command;
|
||||
RAPDU _response;
|
||||
ISO7816App* _app;
|
||||
};
|
||||
|
||||
struct Delegate {
|
||||
virtual void on_selected() {}
|
||||
private:
|
||||
/**
|
||||
* Retrieve the application's identifier (AID).
|
||||
* AIDs are composed of a RID (Registered Application Provider Identifier) that needs to be registered and a custom suffix.
|
||||
*
|
||||
* @return a pointer to a const buffer containing the application's identifier (AID).
|
||||
*/
|
||||
virtual const ac_buffer_t* get_aid() const;
|
||||
|
||||
virtual void on_deselected() {}
|
||||
/**
|
||||
* Called when the application is selected and before any exchange is performed.
|
||||
*/
|
||||
virtual void on_selected();
|
||||
|
||||
virtual void on_exchange(Exchange* exchange) {}
|
||||
};
|
||||
|
||||
void set_delegate(Delegate* delegate);
|
||||
/**
|
||||
* Called when the application is deselected (or link is lost).
|
||||
*/
|
||||
virtual void on_deselected();
|
||||
|
||||
/**
|
||||
* Called when an exchange is performed.
|
||||
* The application must respond using the respond() method of the Exchange class.
|
||||
*
|
||||
* @param[in] exchange an instance of the Exchange class populated with the C-APDU which was received
|
||||
*/
|
||||
virtual void on_exchange(Exchange* exchange);
|
||||
};
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
} // namespace nfc
|
||||
} // namespace mbed
|
||||
|
||||
|
|
Loading…
Reference in New Issue