|
1 | | -# nfc-cdc-browser-reader |
| 1 | +# NFC CDC Browser Reader |
| 2 | + |
| 3 | +A web-based NFC reader interface that uses WebUSB to communicate with ACS ACR518 (ACR1281S-C1) and compatible NFC readers configured in CDC (serial) mode. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- **WebUSB CDC Communication**: Direct USB communication with NFC readers in CDC/serial mode |
| 8 | +- **Card UID Reading**: Read NFC card unique identifiers (MIFARE, ISO14443-A) |
| 9 | +- **Reader Commands**: Send common reader commands (firmware version, serial number, antenna control) |
| 10 | +- **MIFARE Classic Support**: Authenticate and read MIFARE Classic card blocks |
| 11 | +- **Custom APDU**: Send custom APDU commands for advanced operations |
| 12 | +- **Continuous Polling**: Auto-detect cards when placed on the reader |
| 13 | +- **LED/Buzzer Control**: Control reader LEDs and buzzer for feedback |
| 14 | + |
| 15 | +## Supported Readers |
| 16 | + |
| 17 | +- ACS ACR1281S-C1 (ACR518) |
| 18 | +- ACS ACR122U |
| 19 | +- ACS ACR1252U |
| 20 | +- Other ACS readers in CDC mode |
| 21 | +- Generic USB-CDC NFC readers |
| 22 | + |
| 23 | +## Browser Requirements |
| 24 | + |
| 25 | +WebUSB is required. Supported browsers: |
| 26 | +- Google Chrome (recommended) |
| 27 | +- Microsoft Edge |
| 28 | +- Opera |
| 29 | + |
| 30 | +**Note**: Firefox and Safari do not support WebUSB. |
| 31 | + |
| 32 | +## How to Read a Card UID |
| 33 | + |
| 34 | +1. Open the application in a supported browser |
| 35 | +2. Click "Connect Reader" and select your NFC reader from the popup |
| 36 | +3. Place an NFC card on the reader |
| 37 | +4. Click "Get UID" to read the card's unique identifier |
| 38 | + |
| 39 | +For continuous reading, click "Auto Poll" to automatically detect cards. |
| 40 | + |
| 41 | +## Common APDU Commands |
| 42 | + |
| 43 | +| Command | Description | |
| 44 | +|---------|-------------| |
| 45 | +| `FF CA 00 00 00` | Get Card UID | |
| 46 | +| `FF CA 01 00 00` | Get Card ATS/Historical Bytes | |
| 47 | +| `FF 00 48 00 00` | Get Firmware Version | |
| 48 | +| `FF 00 4A 00 00` | Get Serial Number | |
| 49 | +| `FF 00 52 0A 00` | Buzzer (100ms) | |
| 50 | +| `FF 82 00 00 06 FF FF FF FF FF FF` | Load Default Key | |
| 51 | +| `FF 86 00 00 05 01 00 BB 60 00` | Authenticate Block BB with Key A | |
| 52 | +| `FF B0 00 BB 10` | Read Block BB (16 bytes) | |
| 53 | + |
| 54 | +## ACR518 CDC Mode Setup |
| 55 | + |
| 56 | +To configure an ACS ACR1281S-C1 (ACR518) for CDC mode: |
| 57 | + |
| 58 | +1. Use the ACS reader configuration tool |
| 59 | +2. Set the operation mode to "CDC" or "Serial" |
| 60 | +3. The reader will appear as a USB CDC device (COM port on Windows, ttyACM on Linux) |
| 61 | + |
| 62 | +## Development |
| 63 | + |
| 64 | +```bash |
| 65 | +# Install dependencies |
| 66 | +npm install |
| 67 | + |
| 68 | +# Start development server |
| 69 | +npm run dev |
| 70 | + |
| 71 | +# Build for production |
| 72 | +npm run build |
| 73 | + |
| 74 | +# Preview production build |
| 75 | +npm run preview |
| 76 | +``` |
| 77 | + |
| 78 | +## Deployment |
| 79 | + |
| 80 | +This project is configured to deploy to GitHub Pages automatically when pushing to the main branch. |
| 81 | + |
| 82 | +The GitHub Actions workflow will: |
| 83 | +1. Install dependencies |
| 84 | +2. Build the project with `./` as the base path |
| 85 | +3. Deploy to GitHub Pages |
| 86 | + |
| 87 | +## Technical Details |
| 88 | + |
| 89 | +### Protocol |
| 90 | + |
| 91 | +The application uses the USB CDC (Communications Device Class) protocol to communicate with NFC readers. For ACS readers in CDC mode: |
| 92 | + |
| 93 | +- Commands are wrapped in a frame: `STX (0x02) + LEN (2 bytes) + DATA + ETX (0x03) + LRC` |
| 94 | +- APDU commands use the PC/SC-lite pseudo-APDU format with CLA=0xFF |
| 95 | +- Responses follow the same framing with SW1/SW2 status bytes |
| 96 | + |
| 97 | +### Security Note |
| 98 | + |
| 99 | +WebUSB requires user interaction to connect to devices, ensuring that web pages cannot access USB devices without explicit permission. |
| 100 | + |
| 101 | +## License |
| 102 | + |
| 103 | +MIT |
0 commit comments