Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FL-2470],[FL-2385],[FL-2411] NFC fixes #1138

Merged
merged 4 commits into from
Apr 20, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 9 additions & 4 deletions applications/nfc/nfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,16 @@ int32_t nfc_app(void* p) {
char* args = p;

// Check argument and run corresponding scene
if((*args != '\0') && nfc_device_load(nfc->dev, p)) {
if(nfc->dev->format == NfcDeviceSaveFormatMifareUl) {
scene_manager_next_scene(nfc->scene_manager, NfcSceneEmulateMifareUl);
if((*args != '\0')) {
if(nfc_device_load(nfc->dev, p)) {
if(nfc->dev->format == NfcDeviceSaveFormatMifareUl) {
scene_manager_next_scene(nfc->scene_manager, NfcSceneEmulateMifareUl);
} else {
scene_manager_next_scene(nfc->scene_manager, NfcSceneEmulateUid);
}
} else {
scene_manager_next_scene(nfc->scene_manager, NfcSceneEmulateUid);
// Exit app
view_dispatcher_stop(nfc->view_dispatcher);
}
} else {
scene_manager_next_scene(nfc->scene_manager, NfcSceneStart);
Expand Down
2 changes: 1 addition & 1 deletion firmware/targets/f7/furi_hal/furi_hal_nfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ bool furi_hal_nfc_detect(FuriHalNfcDevData* nfc_data, uint32_t timeout) {
FURI_LOG_T(TAG, "Timeout");
break;
}
osThreadYield();
osDelay(1);
}
rfalNfcGetDevicesFound(&dev_list, &dev_cnt);
if(detected) {
Expand Down
6 changes: 3 additions & 3 deletions lib/nfc_protocols/mifare_classic.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ static bool mf_classic_auth(
tx_rx->tx_data[1] = block;
tx_rx->tx_rx_type = FuriHalNfcTxRxTypeRxNoCrc;
tx_rx->tx_bits = 2 * 8;
if(!furi_hal_nfc_tx_rx(tx_rx, 4)) break;
if(!furi_hal_nfc_tx_rx(tx_rx, 5)) break;
DrZlo13 marked this conversation as resolved.
Show resolved Hide resolved

uint32_t nt = (uint32_t)nfc_util_bytes2num(tx_rx->rx_data, 4);
crypto1_init(crypto, key);
Expand All @@ -140,7 +140,7 @@ static bool mf_classic_auth(
}
tx_rx->tx_rx_type = FuriHalNfcTxRxTypeRaw;
tx_rx->tx_bits = 8 * 8;
if(!furi_hal_nfc_tx_rx(tx_rx, 4)) break;
if(!furi_hal_nfc_tx_rx(tx_rx, 5)) break;
if(tx_rx->rx_bits == 32) {
crypto1_word(crypto, 0, 0);
auth_success = true;
Expand Down Expand Up @@ -220,7 +220,7 @@ bool mf_classic_read_block(
tx_rx->tx_bits = 4 * 9;
tx_rx->tx_rx_type = FuriHalNfcTxRxTypeRaw;

if(furi_hal_nfc_tx_rx(tx_rx, 4)) {
if(furi_hal_nfc_tx_rx(tx_rx, 5)) {
if(tx_rx->rx_bits == 8 * 18) {
for(uint8_t i = 0; i < 18; i++) {
block->value[i] = crypto1_byte(crypto, 0, 0) ^ tx_rx->rx_data[i];
Expand Down