Appearance
Protocol layer
Connect over WebUSB, receive decoded device frames, and clock raw bytes onto the I/O line. Your page plays the card.
Two namespaces meet here: link owns the physical connection (bytes in, bytes out, no idea what a frame is), and protocol owns a link and speaks frames over it.
js
import {link, protocol} from 'yolocard-sdk';
// TS T0 [historical: 80 31 e0 73], no interface bytes, T=0 only (no TCK).
const ATR = '3B 04 80 31 E0 73';
const comm = protocol.createCommunicator(await link.requestUsbTransport());
comm.onATRSet(atr => console.log('New ATR', atr))
comm.onResetCold(_ => console.log('Cold reset'))
comm.onResetWarm(_ => console.log('Warm reset'))
comm.onATRTransmitted(_ => console.log('ATR Transmitted'))
comm.onSpeedNegotiated((fi, di) => console.log('Negotiated speed:', fi, di))
comm.onVoltageSkip(voltage => console.log('Skipped voltage class:', voltage))
comm.onClockStart(_ => console.log('Clocking started'))
comm.onClockStop(_ => console.log('Clock is down'))
comm.onHardwareFail(_ => console.log('Yolocard reported it has an internal failure.'))
comm.onFrame(frame => {
console.log(`${frame.side}\t${frame.clock}\t-> ${frame.byteHex}`)
});
await comm.connect(); // may raise Firmware Unsupported
await comm.setAtr(ATR);
// Ready to insert!
// comm.clearCallbacks()
// comm.disconnect()Console output appears here. Needs Chromium and the YoloCard plugged in.
Command boundaries aren't tracked here — collect bytes yourself and hand them to card.parseApdu, or let the state machine do it for you on T=0.
PPS is handled by the device — ModeUpdate just reports the result, and the PPS bytes pass through as ordinary RxByte/TxByte. Firmware is checked automatically; unsupported keeps streaming but raises error.
requestUsbTransport() needs a user gesture. reconnectUsbTransport() re-attaches without one. In Node, swap in new link.NodeUsbTransport(device).