import { useState } from "react"; import LabFixtureLoad from "../LabFixtureLoad"; import { LAB_PURPOSE_NOTE } from "../validationFixtures"; import { apiUrl } from "../api"; import { useToast } from "../toast"; export default function Emulate() { const toast = useToast(); const [hex, setHex] = useState("8C"); const [out, setOut] = useState(""); const [busy, setBusy] = useState(false); const send = async () => { setBusy(true); setOut(""); try { const r = await fetch(apiUrl("/api/nfc/emulate-raw"), { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ hex: hex.replace(/\s/g, "") }), }); const t = await r.text(); if (!r.ok) { throw new Error(t); } try { setOut(JSON.stringify(JSON.parse(t), null, 2)); } catch { setOut(t); } toast("PN532 emulation command sent"); } catch (e) { toast(String(e), "err"); } finally { setBusy(false); } }; return (
Sends TgInitAsTarget (0x8C) and following bytes as one PN532
payload. Real card emulation depends on UID length, timing, and reader behavior — this is an{" "}
expert / experimental path. Build the byte sequence from NXP UM0701 or community
examples. Wrong frames can leave the RF stack busy; power-cycle if the field acts stuck.
{LAB_PURPOSE_NOTE}
{out}
)}