NFC - Help to exchange data between RC522 & Android HCE

I will explain my project :

I have my RC522 and a door connected on my Arduino UNO.

I can currently open the door with a MIFARE classic.

But now I want to open it with my Android smartphone, this is why I develop a HCE applet to accept the good APDU with the selected AID, then my phone will transfer the data in order to open the door.

But the problem is :

I don't know how to send an APDU command with my Arduino using the RC522.

Currently, for my MIFARE Cards, I use the GitHub - miguelbalboa/rfid: Arduino RFID Library for MFRC522 library.

My test code :

byte selectApdu = {
0x00, /* CLA /
0xA4, /
0x04, /
P1 /
0x00, /
P2 /
0x05, /
Length of AID */
0xF2, 0x22, 0x22, 0x22, 0x22,
byte * backData = (byte )malloc(16sizeof(byte));
byte * dataLen = (byte *)16;

status = mfrc522.PCD_TransceiveData(selectApdu,10,backData,dataLen,NULL,0,false);
if ( status != MFRC522::STATUS_OK) {
Serial.print(F("PCD_TransceiveData() failed: "));
Serial.println(F("PICC_TransceiveData() success "));

Neverless, it doesn't work ( "Timeout in communication"), and I slowly need to think that the RC522 is not compatible...