From 10539ef0d7224d4e1c0a168f73f7854fbea2052c Mon Sep 17 00:00:00 2001 From: "Zhibin (Ryan) Wen" Date: Wed, 20 May 2026 15:56:30 +0800 Subject: [PATCH] fix: wait for NFC-A frame availability before reading Signed-off-by: Zhibin (Ryan) Wen --- src/unit/unit_ST25R3916_nfca.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/unit/unit_ST25R3916_nfca.cpp b/src/unit/unit_ST25R3916_nfca.cpp index 221b6e7..aa4040d 100644 --- a/src/unit/unit_ST25R3916_nfca.cpp +++ b/src/unit/unit_ST25R3916_nfca.cpp @@ -225,7 +225,9 @@ bool UnitST25R3916::nfcaReceive(uint8_t* rx, uint16_t& rx_len, const uint32_t ti return false; } - if (!wait_for_FIFO(timeout_ms, rx_len_org)) { + // rx_len_org is the caller's buffer capacity, not an expected frame length. + // Wait only until a frame is available, then read up to the provided capacity. + if (!wait_for_FIFO(timeout_ms, 1)) { // M5_LIB_LOGE("nfcaReceive timeout rx_len=%u timeout_ms=%u", rx_len_org, timeout_ms); M5_LIB_LOGD("Timeout"); return false;