From 3b5d68454f5538c4cec2b881afb1dbbbe6c391d6 Mon Sep 17 00:00:00 2001 From: Sucareto <28331534+Sucareto@users.noreply.github.com> Date: Fri, 22 Apr 2022 23:20:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E9=BD=90=E6=95=B0=E6=8D=AE=E7=BB=93?= =?UTF-8?q?=E6=9E=84=EF=BC=8C=E4=BD=BF=E7=94=A8=E5=8F=AF=E5=8F=98=E9=95=BF?= =?UTF-8?q?=E5=BA=A6=E6=95=B0=E7=BB=84=EF=BC=9B=E5=88=86=E6=AC=A1=E8=AF=BB?= =?UTF-8?q?=E5=8F=96=E6=95=B0=E6=8D=AE=EF=BC=8C=E8=A7=A3=E5=86=B3=E6=89=A7?= =?UTF-8?q?=E8=A1=8C3=E6=AC=A1=E4=BB=A5=E4=B8=8A=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd.h | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/cmd.h b/cmd.h index 359799d..577e918 100644 --- a/cmd.h +++ b/cmd.h @@ -69,7 +69,7 @@ typedef union packet_req { uint8_t numService;//and NDA_A4 unknown byte uint8_t serviceCodeList[2]; uint8_t numBlock; - uint8_t blockList[4][2]; + uint8_t blockList[1][2];//长度可变 uint8_t blockData[16];//WriteWithoutEncryption,ignore }; uint8_t felica_payload[113]; @@ -116,7 +116,7 @@ typedef union packet_res { struct { uint8_t RW_status[2];//猜测,NDA_06,NDA_08 uint8_t numBlock;//NDA_06 - uint8_t blockData[4][16];//NDA_06 + uint8_t blockData[1][1][16];//NDA_06 }; uint8_t felica_payload[112]; }; @@ -291,21 +291,19 @@ static void sg_nfc_cmd_felica_encap() { break; case FELICA_CMD_NDA_06: { - uint16_t serviceCodeList[1] = {req.serviceCodeList[1] << 8 | req.serviceCodeList[0]}; - uint16_t blockList[4] = { - req.blockList[0][0] << 8 | req.blockList[0][1], - req.blockList[1][0] << 8 | req.blockList[1][1], - req.blockList[2][0] << 8 | req.blockList[2][1], - req.blockList[3][0] << 8 | req.blockList[3][1], - }; - if (nfc.felica_ReadWithoutEncryption(req.numService, serviceCodeList, req.numBlock, blockList, res.blockData) == 1) { - sg_res_init(0x0E + req.numBlock * 16); - res.numBlock = req.numBlock; - } else { - sg_res_init(); - res.status = 1; - return; + uint16_t serviceCodeList[1] = {(uint16_t)(req.serviceCodeList[1] << 8 | req.serviceCodeList[0])};//大小端反转注意 + 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) { + sg_res_init(); + res.status = 1; + return; + } } + res.RW_status[0] = 0; + res.RW_status[1] = 0; + res.numBlock = req.numBlock; + sg_res_init(0x0D + req.numBlock * 16); } break; case FELICA_CMD_NDA_08: