From ebb2565ce4c43e8de275790f52bebee381d0bca7 Mon Sep 17 00:00:00 2001 From: QHPaeek Date: Sat, 14 Sep 2024 11:57:48 +0800 Subject: [PATCH 1/3] fix felica read and write --- Aime_Reader.h | 18 ++++++++++-------- Arduino-Aime-Reader.ino | 4 ++++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Aime_Reader.h b/Aime_Reader.h index c3a427e..59ade96 100644 --- a/Aime_Reader.h +++ b/Aime_Reader.h @@ -7,7 +7,7 @@ #elif defined(ESP8266) #pragma message "当前的开发板是 ESP8266" #define SerialDevice Serial -#define PN532_SPI_SS D4 +//#define PN532_SPI_SS D4 #define LED_PIN D5 #elif defined(ESP32) @@ -196,7 +196,7 @@ typedef union { struct { uint8_t RW_status[2]; uint8_t numBlock; - uint8_t blockData[1][1][16]; + uint8_t blockData[4][16]; }; uint8_t felica_payload[1]; }; @@ -385,13 +385,12 @@ void nfc_felica_through() { break; case FelicaReadWithoutEncryptData: { - uint16_t serviceCodeList[1] = { (uint16_t)(req.serviceCodeList[1] << 8 | req.serviceCodeList[0]) }; + uint16_t serviceCodeList = req.serviceCodeList[1] << 8 | req.serviceCodeList[0]; + uint16_t blockList[4]; for (uint8_t i = 0; i < req.numBlock; i++) { - uint16_t blockList[1] = { (uint16_t)(req.blockList[i][0] << 8 | req.blockList[i][1]) }; - if (nfc.felica_ReadWithoutEncryption(1, serviceCodeList, 1, blockList, res.blockData[i]) != 1) { - memset(res.blockData[i], 0, 16); // dummy data - } + blockList[i] = (uint16_t)(req.blockList[i][0] << 8 | req.blockList[i][1]); } + nfc.felica_ReadWithoutEncryption(1, &serviceCodeList, req.numBlock, blockList, res.blockData); res.RW_status[0] = 0; res.RW_status[1] = 0; res.numBlock = req.numBlock; @@ -400,7 +399,10 @@ void nfc_felica_through() { break; case FelicaWriteWithoutEncryptData: { - res_init(0x0C); // WriteWithoutEncryption,ignore + uint16_t serviceCodeList = req.serviceCodeList[1] << 8 | req.serviceCodeList[0]; + uint16_t blockList = (uint16_t)(req.blockList_write[0][0] << 8 | req.blockList_write[0][1]); + nfc.felica_WriteWithoutEncryption(1, &serviceCodeList, 1, &blockList, &req.blockData); + res_init(0x0C); res.RW_status[0] = 0; res.RW_status[1] = 0; } diff --git a/Arduino-Aime-Reader.ino b/Arduino-Aime-Reader.ino index 2da040d..6f469c0 100644 --- a/Arduino-Aime-Reader.ino +++ b/Arduino-Aime-Reader.ino @@ -95,8 +95,12 @@ void loop() { case CMD_CARD_HALT: case CMD_EXT_TO_NORMAL_MODE: case CMD_TO_UPDATER_MODE: + res_init(); + break; + case CMD_SEND_HEX_DATA: res_init(); + res.status = STATUS_COMP_DUMMY_3RD; break; case STATUS_SUM_ERROR: From 4c2d0b2f04a2b62ce6d757d63a26513bebcd423b Mon Sep 17 00:00:00 2001 From: QHPaeek Date: Sat, 14 Sep 2024 12:05:15 +0800 Subject: [PATCH 2/3] fix some name error --- Aime_Reader.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Aime_Reader.h b/Aime_Reader.h index 59ade96..032025a 100644 --- a/Aime_Reader.h +++ b/Aime_Reader.h @@ -400,7 +400,7 @@ void nfc_felica_through() { case FelicaWriteWithoutEncryptData: { uint16_t serviceCodeList = req.serviceCodeList[1] << 8 | req.serviceCodeList[0]; - uint16_t blockList = (uint16_t)(req.blockList_write[0][0] << 8 | req.blockList_write[0][1]); + uint16_t blockList = (uint16_t)(req.blockList[0][0] << 8 | req.blockList[0][1]); nfc.felica_WriteWithoutEncryption(1, &serviceCodeList, 1, &blockList, &req.blockData); res_init(0x0C); res.RW_status[0] = 0; From 4a08ab2bb47574f557438419aff5bb535b4f5fe1 Mon Sep 17 00:00:00 2001 From: Sucareto <28331534+Sucareto@users.noreply.github.com> Date: Sat, 28 Sep 2024 11:38:29 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E8=BF=99=E4=B8=AA=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=92=8C=E6=9C=AC=E6=AC=A1pr=E6=97=A0=E5=85=B3=EF=BC=8C?= =?UTF-8?q?=E5=85=88=E8=BF=98=E5=8E=9F=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Aime_Reader.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Aime_Reader.h b/Aime_Reader.h index 032025a..f488034 100644 --- a/Aime_Reader.h +++ b/Aime_Reader.h @@ -7,7 +7,7 @@ #elif defined(ESP8266) #pragma message "当前的开发板是 ESP8266" #define SerialDevice Serial -//#define PN532_SPI_SS D4 +#define PN532_SPI_SS D4 #define LED_PIN D5 #elif defined(ESP32)