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

Long awaited mifare UL card emulator #17

Merged
merged 7 commits into from
Sep 23, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
mif ul support - r3 merged
  • Loading branch information
AAsyunkin-se committed Sep 23, 2020
commit b8dd0743491e28c4a1ac2d399bb9498b5321535e
7 changes: 7 additions & 0 deletions src/hydranfc_v2/ce.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ rfalTransceiveState tStatePrev = 3;

static rfalLmState state;

uint16_t (*cardA_activated_ptr)(void) = NULL;

void ce_set_cardA_activated_ptr(void * ptr)
{
cardA_activated_ptr = ptr;
}

void ceInitalize( void )
{
transceiveCtx.txBuf = txBuf_ce;
Expand Down
7 changes: 2 additions & 5 deletions src/hydranfc_v2/hydranfc_v2_ce.c
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@ void dispatcherInterruptHandler()
static void ceRun(t_hydra_console *con, bool quiet)
{
(void)con;
(void)quiet;
ReturnCode err = ERR_NONE;
uint16_t dataSize;
int i;
Expand Down Expand Up @@ -590,7 +591,7 @@ void hydranfc_ce_set_processCmd_ptr(void * ptr)
current_processCmdPtr = ptr;
}

void hydranfc_ce_common(t_hydra_console *con)
void hydranfc_ce_common(t_hydra_console *con, bool quiet)
{
uint16_t length = 0;
ReturnCode err = ERR_NONE;
Expand All @@ -609,10 +610,6 @@ void hydranfc_ce_common(t_hydra_console *con)
};
// ats = 07 78 00 80 00 73 74 00

// if (user_tag_properties.uri != NULL) {
// // safe strcpy
// snprintf(w_uri.URI_Message, sizeof(w_uri.URI_Message) - 1, "%s", (char *)user_tag_properties.uri);
// }
NDEF_PrepareURIMessage(&w_uri, &NDEF_Buffer[2], &length);
NDEF_Buffer[0] = length >> 8;
NDEF_Buffer[1] = length & 0xFF;
Expand Down
2 changes: 1 addition & 1 deletion src/hydranfc_v2/hydranfc_v2_ce.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ typedef struct {
extern sUserTagProperties user_tag_properties;
extern uint8_t ul_cwrite_page_set;

void hydranfc_ce_common(t_hydra_console *con);
void hydranfc_ce_common(t_hydra_console *con, bool quiet);
void hydranfc_ce_set_uri(uint8_t *uri_ptr);

#endif
Expand Down
62 changes: 12 additions & 50 deletions src/hydranfc_v2/hydranfc_v2_nfc_mode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,6 @@ static int exec(t_hydra_console *con, t_tokenline_parsed *p, int token_pos)
// printf_dbg("uri: token 0=%d, 1=%d, 2=%d\n", p->tokens[t+0],p->tokens[t+1],p->tokens[t+2]);
if (p->tokens[t+1] == T_ARG_STRING) {
memcpy(&str_offset, &p->tokens[t+2], sizeof(int));
// user_tag_properties.uri = (uint8_t *)(p->buf + str_offset);
hydranfc_ce_set_uri((uint8_t *)(p->buf + str_offset));
t += 2;
} else {
Expand Down Expand Up @@ -1203,49 +1202,9 @@ static int exec(t_hydra_console *con, t_tokenline_parsed *p, int token_pos)
cprintf(con, "NFC Observation mode disabled\r\n");
}

irq_count = 0;
st25r3916_irq_fn = NULL;
break;
}

case T_READ_MF_ULTRALIGHT:
cprintf(con, "T_READ_MF_ULTRALIGHT not implemented.\r\n");
// TODO T_READ_MF_ULTRALIGHT
//hydranfc_v2_read_mifare_ul(con, sd_file.filename);
break;

case T_EMUL_MF_ULTRALIGHT:
cprintf(con, "Mifare Ultralight card emulation.\r\n");
if(sd_file.filename[0] != 0)
{
cprintf(con, "Using image file %s.\r\n", sd_file.filename);
user_tag_properties.ce_image_filename = sd_file.filename;
}else
{
cprintf(con, "Using 'factory' image file.\r\n");
user_tag_properties.ce_image_filename = NULL;
}
user_tag_properties.l3EmulationMode = L3_MODE_MIF_UL;
hydranfc_card_emul_iso14443a(con);
user_tag_properties.l3EmulationMode = L3_MODE_NOT_SET;
user_tag_properties.ce_image_filename = NULL;
break;

case T_CLONE_MF_ULTRALIGHT:
cprintf(con, "T_CLONE_MF_ULTRALIGHT not implemented.\r\n");
break;

case T_SNIFF:
// TODO T_SNIFF
cprintf(con, "T_SNIFF not implemented.\r\n");
#if 0
if(sniff_bin) {
if(sniff_raw) {
/* Sniffer Binary RAW UART1 only */
hydranfc_sniff_14443AB_bin_raw(con, sniff_frame_time, sniff_frame_time);
} else {
/* Sniffer Binary UART1 only */
hydranfc_sniff_14443A_bin(con, sniff_frame_time, sniff_frame_time, sniff_parity);
if(1 == nfc_obsv) {
rfalSetObsvMode(nfc_obsv_tx, nfc_obsv_rx);
cprintf(con, "NFC Observation mode enabled\r\n");
}
}
break;
Expand Down Expand Up @@ -1408,17 +1367,20 @@ static int exec(t_hydra_console *con, t_tokenline_parsed *p, int token_pos)
break;

case T_EMUL_MF_ULTRALIGHT:
cprintf(con, "T_EMUL_MF_ULTRALIGHT not implemented.\r\n");
// TODO T_EMUL_MF_ULTRALIGHT
/*
cprintf(con, "Mifare Ultralight card emulation.\r\n");
if(sd_file.filename[0] != 0)
{
hydranfc_emul_mf_ultralight_file(con, sd_file.filename);
cprintf(con, "Using image file %s.\r\n", sd_file.filename);
user_tag_properties.ce_image_filename = sd_file.filename;
}else
{
hydranfc_emul_mf_ultralight(con);
cprintf(con, "Using 'factory' image file.\r\n");
user_tag_properties.ce_image_filename = NULL;
}
*/
user_tag_properties.l3EmulationMode = L3_MODE_MIF_UL;
hydranfc_card_emul_iso14443a(con);
user_tag_properties.l3EmulationMode = L3_MODE_NOT_SET;
user_tag_properties.ce_image_filename = NULL;
break;

case T_CLONE_MF_ULTRALIGHT:
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.