Open shaan-lee opened 1 month ago
Since this is a card emulation, the phone in this case acts as a passive device. A request must come to it from the outside, and we can only register any response to a certain type of request. That is, 'port' in this case allows you to create 256 interaction options.
Here is an example of the structure that stm32 sends via pn532:
struct apduCommand_t
{
uint8_t target; // for pn532
uint8_t CLA;
uint8_t INS;
uint8_t P1;
uint8_t P2;
uint8_t AID_LENGHT;
uint8_t data[64];
} _apduCommand{
.target = 1,
.CLA = 0x00,
.INS = 0xA4,
.P1 = 0x04,
.P2 = 0,
.AID_LENGHT = 7,
.data = {MY, 7, BYTES, AID, IN, FLUTTER, APP},
};
/// @param port any value in the interval [0..0xFF]
/// @param data a pointer to the data array to send
/// @param dataLength the size of the data to be sent in bytes
/// @param response a pointer to the data array to receive
/// @param responseLength the size of the reception in bytes (more data may come, but only this amount will be copied to response)
int _exchangeDataWithAndroid(uint8_t port, void *data, uint8_t dataLength, uint8_t *response, uint8_t responseLength)
{
_apduCommand.P2 = port;
memcpy(&_apduCommand.data[_apduCommand.AID_LENGHT], data, dataLength);
return _pn532dataExchange((uint8_t *)&_apduCommand, 6 + _apduCommand.AID_LENGHT + dataLength, response, responseLength);
}
_pn532dataExchange is low-level function that you should write by yourself.
I can't understand about 'port'. anybody plz explain to me how to use this package. I want to use hce function to auth rfid.