1
0
mirror of synced 2024-11-27 17:11:01 +01:00

Merge pull request #19 from QHPaeek/master

正确实现 FeliCa 读写;跳过读卡器固件更新。
This commit is contained in:
Sucareto 2024-10-18 13:48:30 +08:00 committed by GitHub
commit c46147829b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 7 deletions

View File

@ -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[0][0] << 8 | req.blockList[0][1]);
nfc.felica_WriteWithoutEncryption(1, &serviceCodeList, 1, &blockList, &req.blockData);
res_init(0x0C);
res.RW_status[0] = 0;
res.RW_status[1] = 0;
}

View File

@ -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: