APDU commands for NFCTagType4 emulated tag with react-native-hce

79 Views Asked by At

I'm creating an emulated NFC Tag with this code in react-native using react-native-hce

const startEmulation = useCallback(async () => {
    try {
      const session = await HCESession.getInstance();
      
      // Creamos el contenido de la etiqueta
      const efContent = 'HOLA';

      // Creamos la etiqueta NFC emulada
      const emulatedTag = new NFCTagType4({
        type: NFCTagType4NDEFContentType.Text,
        content: efContent,
        writable: true,
      });

      // Establecemos la aplicación emulada
      await session.setApplication(emulatedTag);

      // Habilitamos la sesión
      await session.setEnabled(true);

      // Manejamos la actualización del estado
      await session.handleStateUpdate(HCESession.Events.HCE_STATE_WRITE_FULL);

      // Obtenemos el contenido de la etiqueta
      setTagContent(emulatedTag.content.content);
    } catch (error) {
      console.error('Error en la emulación:', error);
    }
  }, []);

It works well since it emulates the tag, which has IsoDep and NfcA tech on it.

Using the app NFC-tools, i'm able to send the SELECT command

00:A4:04:00:07:D2:76:00:00:85:01:01

And it returns 90:00.

From this point, i'm unable to do anything with the tag. Found some commands on the NFC Forum Tag: https://nfc-forum.org/uploads/specifications/97-NFCForum-TS-T4T-1.2.pdf

But couldn't make it work. Almost all the commands returns me 69:86, and I can't see the error.

Could someone help me out?

Thanks in advance!

1

There are 1 best solutions below

0
Vladimir Tsykunov On

6986 means error "Command not allowed (no current EF)"

Try to read ISO/IEC 7816-4.

Also this reading might be useful NFC Forum Type 4 Tag IC with 16-Kbit EEPROM