Skip to content

Commit

Permalink
nfc/dnfc/nfc bbio modes refactoring cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bvernoux committed Jul 4, 2021
1 parent 77ea467 commit b2bb3a3
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 128 deletions.
3 changes: 2 additions & 1 deletion src/hydranfc_v2/ce.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
#include "st25r3916.h"

#include "bsp_print_dbg.h"

#include "hydranfc_v2.h"
#include "hydranfc_v2_ce.h"
#include "hydranfc_v2_nfc_mode.h"

void ceNfcaCardemu4A(uint8_t mode, rfalIsoDepTxRxParam *isoDepTxRxParam);
void ceNfcfCardemu3(uint8_t mode, rfalTransceiveContext *ctx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
#include "st25r3916_irq.h"
#include "st25r3916_aat.h"

#include "hydranfc_v2_common.h"
#include "hydranfc_v2_nfc_mode.h"
#include "hydranfc_v2.h"

/*
static volatile int irq_count;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
* limitations under the License.
*/

#ifndef _HYDRANFC_V2_COMMON_H_
#define _HYDRANFC_V2_COMMON_H_
#ifndef _HYDRANFC_V2_H_
#define _HYDRANFC_V2_H_

#include "common.h"

Expand Down Expand Up @@ -54,5 +54,5 @@ void hydranfc_v2_set_irq(irq_callback_t st25r3916_irq_callback);

void hydranfc_v2_cleanup(t_hydra_console *con);

#endif /* _HYDRANFC_V2_NFC_MODE_H_ */
#endif /* _HYDRANFC_V2_H_ */

2 changes: 1 addition & 1 deletion src/hydranfc_v2/hydranfc_v2.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# List of all the hydranfc related files.
HYDRANFC_V2_SRC = hydranfc_v2/hydranfc_v2_common.c \
HYDRANFC_V2_SRC = hydranfc_v2/hydranfc_v2.c \
hydranfc_v2/hydranfc_v2_nfc_mode.c \
hydranfc_v2/hydranfc_v2_dnfc_mode.c \
hydranfc_v2/hydranfc_v2_ce.c \
Expand Down
3 changes: 1 addition & 2 deletions src/hydranfc_v2/hydranfc_v2_bbio_card_emulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@
#include "bsp_print_dbg.h"
#include <string.h>

#include "hydranfc_v2_common.h"
#include "hydranfc_v2_nfc_mode.h"
#include "hydranfc_v2.h"
#include "hydranfc_v2_bbio_card_emulator.h"

enum cardEmulationCommand {
Expand Down
3 changes: 1 addition & 2 deletions src/hydranfc_v2/hydranfc_v2_bbio_reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
#include "rfal_nfcb.h"
#include "rfal_nfcv.h"

#include "hydranfc_v2_common.h"
#include "hydranfc_v2_nfc_mode.h"
#include "hydranfc_v2.h"

extern t_mode_config mode_con1;

Expand Down
6 changes: 3 additions & 3 deletions src/hydranfc_v2/hydranfc_v2_ce.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* HydraBus/HydraNFC v2
*
* Copyright (C) 2020 Benjamin VERNOUX
* Copyright (C) 2020/2021 Benjamin VERNOUX
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -34,12 +34,12 @@
#include "st25r3916_irq.h"

#include "bsp_print_dbg.h"
#include "hydranfc_v2_ce.h"
#include "hydranfc_v2_nfc_mode.h"

#include "ff.h"
#include "microsd.h"

#include "hydranfc_v2.h"
#include "hydranfc_v2_ce.h"

static uint8_t rxtxFrameBuf[512] __attribute__ ((section(".cmm")));

Expand Down
5 changes: 2 additions & 3 deletions src/hydranfc_v2/hydranfc_v2_dnfc_mode.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@
#include "rfal_poller.h"
#include "rfal_nfca.h"

#include "hydranfc_v2_common.h"
#include "hydranfc_v2_nfc_mode.h"
#include "hydranfc_v2_dnfc_mode.h"
#include "hydrabus_mode.h"
#include "hydranfc_v2.h"

static int exec(t_hydra_console *con, t_tokenline_parsed *p, int token_pos);
static int show(t_hydra_console *con, t_tokenline_parsed *p);
Expand Down
25 changes: 0 additions & 25 deletions src/hydranfc_v2/hydranfc_v2_dnfc_mode.h

This file was deleted.

58 changes: 56 additions & 2 deletions src/hydranfc_v2/hydranfc_v2_nfc_mode.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "common.h"
#include "tokenline.h"
#include "hydrabus_mode.h"
#include "hydranfc_v2_nfc_mode.h"
#include "bsp_spi.h"
#include "bsp_gpio.h"
#include "ff.h"
Expand Down Expand Up @@ -51,10 +50,65 @@

#include "rfal_poller.h"

#include "hydranfc_v2_common.h"
#include "hydranfc_v2.h"
#include "hydranfc_v2_ce.h"
#include "hydranfc_v2_reader.h"

#define MIFARE_DATA_MAX 20
/* Does not managed UID > 4+BCC to be done later ... */
#define MIFARE_UID_MAX 11
#define VICINITY_UID_MAX 16

#define MIFARE_ATQA_MAX (4)
#define MIFARE_SAK_MAX (4)
#define MIFARE_HALT_MAX (4)
#define MIFARE_UL_DATA_MAX (64)

#define NFC_TX_RAWDATA_BUF_SIZE (64)
extern unsigned char nfc_tx_rawdata_buf[NFC_TX_RAWDATA_BUF_SIZE+1];

/* Structure used & filled by hydranfc_scan_iso14443A() */
typedef struct {
uint8_t atqa_buf_nb_rx_data;
uint8_t atqa_buf[MIFARE_ATQA_MAX];

uint8_t uid_buf_nb_rx_data;
uint8_t uid_buf[MIFARE_UID_MAX];

uint8_t sak1_buf_nb_rx_data;
uint8_t sak1_buf[MIFARE_SAK_MAX];

uint8_t sak2_buf_nb_rx_data;
uint8_t sak2_buf[MIFARE_SAK_MAX];

uint8_t halt_buf_nb_rx_data;
uint8_t halt_buf[MIFARE_HALT_MAX];

uint8_t mf_ul_data_nb_rx_data;
uint8_t mf_ul_data[MIFARE_UL_DATA_MAX];
} t_hydranfc_scan_iso14443A;

bool hydranfc_init(t_hydra_console *con);
void hydranfc_cleanup(t_hydra_console *con);

void hydranfc_show_registers(t_hydra_console *con);

void hydranfc_scan_iso14443A(t_hydranfc_scan_iso14443A *data);

void hydranfc_scan_mifare(t_hydra_console *con);
void hydranfc_scan_vicinity(t_hydra_console *con);

void hydranfc_sniff_14443A(t_hydra_console *con, bool start_of_frame, bool end_of_frame, bool sniff_trace_uart1);
void hydranfc_sniff_14443A_bin(t_hydra_console *con, bool start_of_frame, bool end_of_frame, bool parity);
void hydranfc_sniff_14443AB_bin_raw(t_hydra_console *con, bool start_of_frame, bool end_of_frame);

void hydranfc_emul_mifare(t_hydra_console *con, uint32_t mifare_uid);

void hydranfc_emul_iso14443a(t_hydra_console *con);

void hydranfc_emul_mf_ultralight(t_hydra_console *con);
int hydranfc_emul_mf_ultralight_file(t_hydra_console *con, char* filename);

extern void hydranfc_ce_common(t_hydra_console *con, bool quiet);
extern uint32_t user_uid_len;
extern uint8_t user_uid[8];
Expand Down
81 changes: 0 additions & 81 deletions src/hydranfc_v2/hydranfc_v2_nfc_mode.h

This file was deleted.

7 changes: 4 additions & 3 deletions src/hydranfc_v2/hydranfc_v2_reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* HydraBus/HydraNFC
*
* Copyright (C) 2020 Guillaume VINET
* Copyright (C) 2014-2020 Benjamin VERNOUX
* Copyright (C) 2014-2021 Benjamin VERNOUX
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,7 +19,6 @@

#include "common.h"
#include "tokenline.h"
#include "hydranfc_v2_nfc_mode.h"
#include "rfal_rf.h"
#include "hydrabus_bbio.h"
#include "hydranfc_v2_bbio_reader.h"
Expand All @@ -31,9 +30,11 @@
#include "rfal_nfca.h"
#include "rfal_nfcb.h"
#include "rfal_nfcv.h"
#include "hydranfc_v2_reader.h"
#include <string.h>

#include "hydranfc_v2.h"
#include "hydranfc_v2_reader.h"

static uint8_t tx_buffer[260];
static uint8_t rx_buffer[260];
static uint16_t tx_buffer_len, rx_buffer_len;
Expand Down

0 comments on commit b2bb3a3

Please sign in to comment.