|
ProtoCore v0.0.1
Deterministic, zero-heap network stack for embedded targets
|
Layer: Foundation ยท Build flags: PC_ENABLE_PN532, PC_ENABLE_GATEWAY
An NFC/RFID reader plugged into the gateway - the ubiquitous NXP PN532 over I2C. Scanning a tag becomes a northbound event: the tag UID is enveloped and published.
The only hardware-specific code is the I2C carry of the frame bytes. The PN532 protocol - build a command, verify the 6-byte ACK, parse the response - is services/pn532:
Each frame is 00 00 FF | LEN | LCS | TFI | PData | DCS | 00 with a length checksum and a data checksum, both verified by the codec. This sketch runs GetFirmwareVersion at boot to confirm the chip, then polls InListPassiveTarget and bridges each detected tag's UID. The codec is host-tested against the documented command / response frames in test/test_pn532.
| PN532 | ESP32 |
|---|---|
| SDA | GPIO 21 |
| SCL | GPIO 22 |
| VCC | 3V3 |
| GND | GND |
Set the PN532's DIP switches to I2C. Its I2C address is 0x24.
The flags must reach the library build, so pass them as build flags: