[FL-2369] NFC refactoring (#1095)

* nfc: clean up scenes
* nfc worker: remove field on from worker
* nfc worker: move full data exchange to furi hal
* nfc_device: check UID length
* nfc protocol: introduce mifare common API
* nfc: move common data to furi hal nfc
* nfc: rename emv_decoder -> emv
* nfc: move emv data structure to emv lib
* nfc: remove deactivate after detection
* nfc: rework furi hal nfc detect
* nfc: clean up CLI commands and type
* nfc: remove unused includes and function
* nfc: add TxRxType enum
* nfc: read mifare ultralight refactoring
* nfc: refactore mifare ultralight start
* rfal: fix custom data exchange
* nfc: refactor read bank card
* nfc: refactor read emv application
* nfc: refactor emv test emulation
* nfc: refactor uid emulation
* nfc: add limit to uid emulation logger
* fix source formatting
* furi_hal_nfc: fix data exchange full
* nfc: fix mifare ultralight type load

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
gornekich
2022-04-19 18:23:58 +03:00
committed by GitHub
parent e55d1572da
commit 956788c09b
58 changed files with 1349 additions and 1601 deletions

View File

@@ -3015,7 +3015,7 @@ ReturnCode rfalIsoDepGetApduTransceiveStatus(void) {
}
/* Update output param rxLen */
*gIsoDep.APDUParam.rxLen = gIsoDep.APDURxPos;
*gIsoDep.APDUParam.rxLen = gIsoDep.APDURxPos * 8;
/* Wait for following I-Block or APDU TxRx has finished */
return ((ret == ERR_AGAIN) ? ERR_BUSY : ERR_NONE);

View File

@@ -725,9 +725,14 @@ ReturnCode rfalNfcDataExchangeCustomStart(
{
/*******************************************************************************/
case RFAL_NFC_INTERFACE_RF:
ctx.rxBuf = gNfcDev.rxBuf.rfBuf, ctx.rxBufLen = sizeof(gNfcDev.rxBuf.rfBuf),
ctx.rxRcvdLen = &gNfcDev.rxLen, ctx.txBuf = txData, ctx.txBufLen = txDataLen,
ctx.flags = flags, ctx.fwt = fwt, *rxData = (uint8_t*)gNfcDev.rxBuf.rfBuf;
ctx.rxBuf = gNfcDev.rxBuf.rfBuf;
ctx.rxBufLen = 8 * sizeof(gNfcDev.rxBuf.rfBuf);
ctx.rxRcvdLen = &gNfcDev.rxLen;
ctx.txBuf = txData;
ctx.txBufLen = txDataLen;
ctx.flags = flags;
ctx.fwt = fwt;
*rxData = (uint8_t*)gNfcDev.rxBuf.rfBuf;
*rvdLen = (uint16_t*)&gNfcDev.rxLen;
err = rfalStartTransceive(&ctx);
break;
@@ -736,13 +741,14 @@ ReturnCode rfalNfcDataExchangeCustomStart(
/*******************************************************************************/
case RFAL_NFC_INTERFACE_ISODEP: {
rfalIsoDepApduTxRxParam isoDepTxRx;
uint16_t tx_bytes = txDataLen / 8;
if(txDataLen > sizeof(gNfcDev.txBuf.isoDepBuf.apdu)) {
if(tx_bytes > sizeof(gNfcDev.txBuf.isoDepBuf.apdu)) {
return ERR_NOMEM;
}
if(txDataLen > 0U) {
ST_MEMCPY((uint8_t*)gNfcDev.txBuf.isoDepBuf.apdu, txData, txDataLen);
if(tx_bytes > 0U) {
ST_MEMCPY((uint8_t*)gNfcDev.txBuf.isoDepBuf.apdu, txData, tx_bytes);
}
isoDepTxRx.DID = RFAL_ISODEP_NO_DID;
@@ -751,7 +757,7 @@ ReturnCode rfalNfcDataExchangeCustomStart(
isoDepTxRx.dFWT = gNfcDev.activeDev->proto.isoDep.info.dFWT;
isoDepTxRx.FWT = gNfcDev.activeDev->proto.isoDep.info.FWT;
isoDepTxRx.txBuf = &gNfcDev.txBuf.isoDepBuf;
isoDepTxRx.txBufLen = txDataLen;
isoDepTxRx.txBufLen = tx_bytes;
isoDepTxRx.rxBuf = &gNfcDev.rxBuf.isoDepBuf;
isoDepTxRx.rxLen = &gNfcDev.rxLen;
isoDepTxRx.tmpBuf = &gNfcDev.tmpBuf.isoDepBuf;