mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-11-10 17:49:32 +08:00
changed LED behavior
This commit is contained in:
parent
1c3d3b350a
commit
82de4c134c
2 changed files with 63 additions and 53 deletions
|
@ -93,9 +93,11 @@ static bool get_input_data_from_file(uint32_t *tag, char *inputfile) {
|
||||||
rdv40_spiffs_read_as_filetype(inputfile, mem, size, RDV40_SPIFFS_SAFETY_SAFE);
|
rdv40_spiffs_read_as_filetype(inputfile, mem, size, RDV40_SPIFFS_SAFETY_SAFE);
|
||||||
|
|
||||||
now = size / 9;
|
now = size / 9;
|
||||||
for (int i = 0; i < now; i++)
|
for (int i = 0; i < now; i++) {
|
||||||
for (int j = 0; j < 4; j++)
|
for (int j = 0; j < 4; j++) {
|
||||||
tag[i] |= (hex2int(mem[2 * j + 9 * i]) << 4 | hex2int(mem[2 * j + 1 + 9 * i])) << ((3 - j) * 8);
|
tag[i] |= (hex2int(mem[2 * j + 9 * i]) << 4 | hex2int(mem[2 * j + 1 + 9 * i])) << ((3 - j) * 8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Dbprintf(_YELLOW_("read tag data from input file"));
|
Dbprintf(_YELLOW_("read tag data from input file"));
|
||||||
}
|
}
|
||||||
|
@ -107,14 +109,12 @@ static bool get_input_data_from_file(uint32_t *tag, char *inputfile) {
|
||||||
|
|
||||||
static void append(const char *filename, uint8_t *entry, size_t entry_len) {
|
static void append(const char *filename, uint8_t *entry, size_t entry_len) {
|
||||||
|
|
||||||
LED_D_ON();
|
|
||||||
if (log_exists == false) {
|
if (log_exists == false) {
|
||||||
rdv40_spiffs_write(filename, entry, entry_len, RDV40_SPIFFS_SAFETY_SAFE);
|
rdv40_spiffs_write(filename, entry, entry_len, RDV40_SPIFFS_SAFETY_SAFE);
|
||||||
log_exists = true;
|
log_exists = true;
|
||||||
} else {
|
} else {
|
||||||
rdv40_spiffs_append(filename, entry, entry_len, RDV40_SPIFFS_SAFETY_SAFE);
|
rdv40_spiffs_append(filename, entry, entry_len, RDV40_SPIFFS_SAFETY_SAFE);
|
||||||
}
|
}
|
||||||
LED_D_OFF();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModInfo(void) {
|
void ModInfo(void) {
|
||||||
|
@ -179,6 +179,7 @@ void RunMod(void) {
|
||||||
// init; start with command = standard read mode
|
// init; start with command = standard read mode
|
||||||
em4x50_setup_sim();
|
em4x50_setup_sim();
|
||||||
gLogin = false;
|
gLogin = false;
|
||||||
|
LED_D_OFF();
|
||||||
gWritePasswordProcess = false;
|
gWritePasswordProcess = false;
|
||||||
command = EM4X50_COMMAND_STANDARD_READ;
|
command = EM4X50_COMMAND_STANDARD_READ;
|
||||||
|
|
||||||
|
@ -197,6 +198,7 @@ void RunMod(void) {
|
||||||
if (command == PM3_ETIMEOUT) {
|
if (command == PM3_ETIMEOUT) {
|
||||||
command = EM4X50_COMMAND_STANDARD_READ;
|
command = EM4X50_COMMAND_STANDARD_READ;
|
||||||
gLogin = false;
|
gLogin = false;
|
||||||
|
LED_D_OFF();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (state == STATE_READ) {
|
} else if (state == STATE_READ) {
|
||||||
|
|
106
armsrc/em4x50.c
106
armsrc/em4x50.c
|
@ -167,8 +167,6 @@ void em4x50_setup_sim(void) {
|
||||||
|
|
||||||
// Watchdog hit
|
// Watchdog hit
|
||||||
WDT_HIT();
|
WDT_HIT();
|
||||||
|
|
||||||
LEDsoff();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate signal properties (mean amplitudes) from measured data:
|
// calculate signal properties (mean amplitudes) from measured data:
|
||||||
|
@ -184,8 +182,6 @@ bool get_signalproperties(void) {
|
||||||
uint32_t tval = 0;
|
uint32_t tval = 0;
|
||||||
memset(sample_max, 0x00, sizeof(sample_max));
|
memset(sample_max, 0x00, sizeof(sample_max));
|
||||||
|
|
||||||
LED_A_ON();
|
|
||||||
|
|
||||||
// wait until signal/noise > 1 (max. 32 periods)
|
// wait until signal/noise > 1 (max. 32 periods)
|
||||||
for (int i = 0; i < EM4X50_T_TAG_WAITING_FOR_SIGNAL; i++) {
|
for (int i = 0; i < EM4X50_T_TAG_WAITING_FOR_SIGNAL; i++) {
|
||||||
|
|
||||||
|
@ -202,7 +198,6 @@ bool get_signalproperties(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (signal_found == false) {
|
if (signal_found == false) {
|
||||||
LED_A_OFF();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,8 +225,6 @@ bool get_signalproperties(void) {
|
||||||
gHigh = sample_ref + pct * (sample_max_mean - sample_ref) / 100;
|
gHigh = sample_ref + pct * (sample_max_mean - sample_ref) / 100;
|
||||||
gLow = sample_ref - pct * (sample_max_mean - sample_ref) / 100;
|
gLow = sample_ref - pct * (sample_max_mean - sample_ref) / 100;
|
||||||
|
|
||||||
LED_A_OFF();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,8 +361,6 @@ static void em4x50_reader_send_word(const uint32_t word) {
|
||||||
static bool find_single_listen_window(void) {
|
static bool find_single_listen_window(void) {
|
||||||
int cnt_pulses = 0;
|
int cnt_pulses = 0;
|
||||||
|
|
||||||
LED_B_ON();
|
|
||||||
|
|
||||||
while (cnt_pulses < EM4X50_T_WAITING_FOR_SNGLLIW) {
|
while (cnt_pulses < EM4X50_T_WAITING_FOR_SNGLLIW) {
|
||||||
|
|
||||||
// identification of listen window is done via evaluation of
|
// identification of listen window is done via evaluation of
|
||||||
|
@ -379,14 +370,12 @@ static bool find_single_listen_window(void) {
|
||||||
if (check_pulse_length(get_pulse_length(), 2 * EM4X50_T_TAG_FULL_PERIOD)) {
|
if (check_pulse_length(get_pulse_length(), 2 * EM4X50_T_TAG_FULL_PERIOD)) {
|
||||||
|
|
||||||
// found listen window
|
// found listen window
|
||||||
LED_B_OFF();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cnt_pulses++;
|
cnt_pulses++;
|
||||||
}
|
}
|
||||||
|
|
||||||
LED_B_OFF();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -398,12 +387,11 @@ static bool find_single_listen_window(void) {
|
||||||
static int find_double_listen_window(bool bcommand) {
|
static int find_double_listen_window(bool bcommand) {
|
||||||
int cnt_pulses = 0;
|
int cnt_pulses = 0;
|
||||||
|
|
||||||
LED_B_ON();
|
|
||||||
|
|
||||||
while (cnt_pulses < EM4X50_T_WAITING_FOR_DBLLIW) {
|
while (cnt_pulses < EM4X50_T_WAITING_FOR_DBLLIW) {
|
||||||
|
|
||||||
if (BUTTON_PRESS())
|
if (BUTTON_PRESS()) {
|
||||||
return PM3_EOPABORTED;
|
return PM3_EOPABORTED;
|
||||||
|
}
|
||||||
|
|
||||||
// identification of listen window is done via evaluation of
|
// identification of listen window is done via evaluation of
|
||||||
// pulse lengths
|
// pulse lengths
|
||||||
|
@ -434,8 +422,6 @@ static int find_double_listen_window(bool bcommand) {
|
||||||
em4x50_reader_send_bit(0);
|
em4x50_reader_send_bit(0);
|
||||||
em4x50_reader_send_bit(0);
|
em4x50_reader_send_bit(0);
|
||||||
|
|
||||||
LED_B_OFF();
|
|
||||||
|
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,8 +429,6 @@ static int find_double_listen_window(bool bcommand) {
|
||||||
|
|
||||||
if (check_pulse_length(get_pulse_length(), 3 * EM4X50_T_TAG_FULL_PERIOD)) {
|
if (check_pulse_length(get_pulse_length(), 3 * EM4X50_T_TAG_FULL_PERIOD)) {
|
||||||
|
|
||||||
LED_B_OFF();
|
|
||||||
|
|
||||||
// return although second listen window consists of one
|
// return although second listen window consists of one
|
||||||
// more bit period but this period is necessary for
|
// more bit period but this period is necessary for
|
||||||
// evaluating further pulse lengths
|
// evaluating further pulse lengths
|
||||||
|
@ -455,7 +439,6 @@ static int find_double_listen_window(bool bcommand) {
|
||||||
cnt_pulses++;
|
cnt_pulses++;
|
||||||
}
|
}
|
||||||
|
|
||||||
LED_B_OFF();
|
|
||||||
return PM3_EFAILED;
|
return PM3_EFAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -535,8 +518,6 @@ static int get_word_from_bitstream(uint32_t *data) {
|
||||||
uint32_t pl = 0;
|
uint32_t pl = 0;
|
||||||
uint64_t word = 0x0;
|
uint64_t word = 0x0;
|
||||||
|
|
||||||
LED_C_ON();
|
|
||||||
|
|
||||||
*data = 0x0;
|
*data = 0x0;
|
||||||
|
|
||||||
// initial bit value depends on last pulse length of listen window
|
// initial bit value depends on last pulse length of listen window
|
||||||
|
@ -607,8 +588,6 @@ static int get_word_from_bitstream(uint32_t *data) {
|
||||||
|
|
||||||
} else if (check_pulse_length(pl, 3 * EM4X50_T_TAG_FULL_PERIOD)) {
|
} else if (check_pulse_length(pl, 3 * EM4X50_T_TAG_FULL_PERIOD)) {
|
||||||
|
|
||||||
LED_C_OFF();
|
|
||||||
|
|
||||||
// pulse length of 3 indicates listen window -> clear last
|
// pulse length of 3 indicates listen window -> clear last
|
||||||
// bit (= 0) and return (without parities)
|
// bit (= 0) and return (without parities)
|
||||||
word >>= 2;
|
word >>= 2;
|
||||||
|
@ -616,8 +595,6 @@ static int get_word_from_bitstream(uint32_t *data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LED_C_OFF();
|
|
||||||
|
|
||||||
return PM3_EOPABORTED;
|
return PM3_EOPABORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -700,9 +677,14 @@ void em4x50_login(uint32_t *password) {
|
||||||
em4x50_setup_read();
|
em4x50_setup_read();
|
||||||
|
|
||||||
uint8_t status = PM3_EFAILED;
|
uint8_t status = PM3_EFAILED;
|
||||||
if (get_signalproperties() && find_em4x50_tag())
|
LED_C_ON();
|
||||||
|
if (get_signalproperties() && find_em4x50_tag()) {
|
||||||
|
LED_C_OFF();
|
||||||
|
LED_D_ON();
|
||||||
status = login(*password);
|
status = login(*password);
|
||||||
|
}
|
||||||
|
|
||||||
|
LEDsoff();
|
||||||
lf_finalize();
|
lf_finalize();
|
||||||
reply_ng(CMD_LF_EM4X50_LOGIN, status, NULL, 0);
|
reply_ng(CMD_LF_EM4X50_LOGIN, status, NULL, 0);
|
||||||
}
|
}
|
||||||
|
@ -713,9 +695,14 @@ void em4x50_brute(em4x50_data_t *etd) {
|
||||||
|
|
||||||
bool bsuccess = false;
|
bool bsuccess = false;
|
||||||
uint32_t pwd = 0x0;
|
uint32_t pwd = 0x0;
|
||||||
if (get_signalproperties() && find_em4x50_tag())
|
LED_C_ON();
|
||||||
|
if (get_signalproperties() && find_em4x50_tag()) {
|
||||||
|
LED_C_OFF();
|
||||||
|
LED_D_ON();
|
||||||
bsuccess = brute(etd->password1, etd->password2, &pwd);
|
bsuccess = brute(etd->password1, etd->password2, &pwd);
|
||||||
|
}
|
||||||
|
|
||||||
|
LEDsoff();
|
||||||
lf_finalize();
|
lf_finalize();
|
||||||
reply_ng(CMD_LF_EM4X50_BRUTE, bsuccess ? PM3_SUCCESS : PM3_EFAILED, (uint8_t *)(&pwd), sizeof(pwd));
|
reply_ng(CMD_LF_EM4X50_BRUTE, bsuccess ? PM3_SUCCESS : PM3_EFAILED, (uint8_t *)(&pwd), sizeof(pwd));
|
||||||
}
|
}
|
||||||
|
@ -743,8 +730,12 @@ void em4x50_chk(uint8_t *filename) {
|
||||||
em4x50_setup_read();
|
em4x50_setup_read();
|
||||||
|
|
||||||
// set gHigh and gLow
|
// set gHigh and gLow
|
||||||
|
LED_C_ON();
|
||||||
if (get_signalproperties() && find_em4x50_tag()) {
|
if (get_signalproperties() && find_em4x50_tag()) {
|
||||||
|
|
||||||
|
LED_C_OFF();
|
||||||
|
LED_D_ON();
|
||||||
|
|
||||||
// try to login with current password
|
// try to login with current password
|
||||||
for (int i = 0; i < pwd_count; i++) {
|
for (int i = 0; i < pwd_count; i++) {
|
||||||
|
|
||||||
|
@ -759,8 +750,11 @@ void em4x50_chk(uint8_t *filename) {
|
||||||
for (int j = 0; j < 4; j++)
|
for (int j = 0; j < 4; j++)
|
||||||
pwd |= (*(pwds + 4 * i + j)) << ((3 - j) * 8);
|
pwd |= (*(pwds + 4 * i + j)) << ((3 - j) * 8);
|
||||||
|
|
||||||
if ((status = login(pwd)) == PM3_SUCCESS)
|
if ((status = login(pwd)) == PM3_SUCCESS) {
|
||||||
|
SpinUp(50);
|
||||||
|
SpinDown(50);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -768,6 +762,7 @@ void em4x50_chk(uint8_t *filename) {
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
LEDsoff();
|
||||||
lf_finalize();
|
lf_finalize();
|
||||||
reply_ng(CMD_LF_EM4X50_CHK, status, (uint8_t *)&pwd, sizeof(pwd));
|
reply_ng(CMD_LF_EM4X50_CHK, status, (uint8_t *)&pwd, sizeof(pwd));
|
||||||
}
|
}
|
||||||
|
@ -859,8 +854,12 @@ void em4x50_read(em4x50_data_t *etd) {
|
||||||
em4x50_setup_read();
|
em4x50_setup_read();
|
||||||
|
|
||||||
// set gHigh and gLow
|
// set gHigh and gLow
|
||||||
|
LED_C_ON();
|
||||||
if (get_signalproperties() && find_em4x50_tag()) {
|
if (get_signalproperties() && find_em4x50_tag()) {
|
||||||
|
|
||||||
|
LED_C_OFF();
|
||||||
|
LED_D_ON();
|
||||||
|
|
||||||
// try to login with given password
|
// try to login with given password
|
||||||
if (etd->pwd_given)
|
if (etd->pwd_given)
|
||||||
blogin = (login(etd->password1) == PM3_SUCCESS);
|
blogin = (login(etd->password1) == PM3_SUCCESS);
|
||||||
|
@ -870,9 +869,9 @@ void em4x50_read(em4x50_data_t *etd) {
|
||||||
status = selective_read(etd->addresses, words);
|
status = selective_read(etd->addresses, words);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LEDsoff();
|
||||||
LOW(GPIO_SSC_DOUT);
|
LOW(GPIO_SSC_DOUT);
|
||||||
lf_finalize();
|
lf_finalize();
|
||||||
|
|
||||||
reply_ng(CMD_LF_EM4X50_READ, status, (uint8_t *)words, EM4X50_TAG_MAX_NO_BYTES);
|
reply_ng(CMD_LF_EM4X50_READ, status, (uint8_t *)words, EM4X50_TAG_MAX_NO_BYTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -886,7 +885,10 @@ void em4x50_info(em4x50_data_t *etd) {
|
||||||
|
|
||||||
em4x50_setup_read();
|
em4x50_setup_read();
|
||||||
|
|
||||||
|
LED_C_ON();
|
||||||
if (get_signalproperties() && find_em4x50_tag()) {
|
if (get_signalproperties() && find_em4x50_tag()) {
|
||||||
|
LED_C_OFF();
|
||||||
|
LED_D_ON();
|
||||||
|
|
||||||
// login with given password
|
// login with given password
|
||||||
if (etd->pwd_given)
|
if (etd->pwd_given)
|
||||||
|
@ -896,8 +898,8 @@ void em4x50_info(em4x50_data_t *etd) {
|
||||||
status = selective_read(addresses, words);
|
status = selective_read(addresses, words);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LEDsoff();
|
||||||
lf_finalize();
|
lf_finalize();
|
||||||
|
|
||||||
reply_ng(CMD_LF_EM4X50_INFO, status, (uint8_t *)words, EM4X50_TAG_MAX_NO_BYTES);
|
reply_ng(CMD_LF_EM4X50_INFO, status, (uint8_t *)words, EM4X50_TAG_MAX_NO_BYTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -909,9 +911,14 @@ void em4x50_reader(void) {
|
||||||
|
|
||||||
em4x50_setup_read();
|
em4x50_setup_read();
|
||||||
|
|
||||||
if (get_signalproperties() && find_em4x50_tag())
|
LED_C_ON();
|
||||||
|
if (get_signalproperties() && find_em4x50_tag()) {
|
||||||
|
LED_C_OFF();
|
||||||
|
LED_D_ON();
|
||||||
standard_read(&now, words);
|
standard_read(&now, words);
|
||||||
|
}
|
||||||
|
|
||||||
|
LEDsoff();
|
||||||
LOW(GPIO_SSC_DOUT);
|
LOW(GPIO_SSC_DOUT);
|
||||||
lf_finalize();
|
lf_finalize();
|
||||||
reply_ng(CMD_LF_EM4X50_READER, now, (uint8_t *)words, 4 * now);
|
reply_ng(CMD_LF_EM4X50_READER, now, (uint8_t *)words, 4 * now);
|
||||||
|
@ -1018,8 +1025,12 @@ void em4x50_write(em4x50_data_t *etd) {
|
||||||
|
|
||||||
em4x50_setup_read();
|
em4x50_setup_read();
|
||||||
|
|
||||||
|
LED_C_ON();
|
||||||
if (get_signalproperties() && find_em4x50_tag()) {
|
if (get_signalproperties() && find_em4x50_tag()) {
|
||||||
|
|
||||||
|
LED_C_OFF();
|
||||||
|
LED_D_ON();
|
||||||
|
|
||||||
// if password is given try to login first
|
// if password is given try to login first
|
||||||
status = PM3_SUCCESS;
|
status = PM3_SUCCESS;
|
||||||
if (etd->pwd_given)
|
if (etd->pwd_given)
|
||||||
|
@ -1060,6 +1071,7 @@ void em4x50_write(em4x50_data_t *etd) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LEDsoff();
|
||||||
lf_finalize();
|
lf_finalize();
|
||||||
reply_ng(CMD_LF_EM4X50_WRITE, status, (uint8_t *)words, EM4X50_TAG_MAX_NO_BYTES);
|
reply_ng(CMD_LF_EM4X50_WRITE, status, (uint8_t *)words, EM4X50_TAG_MAX_NO_BYTES);
|
||||||
}
|
}
|
||||||
|
@ -1070,8 +1082,12 @@ void em4x50_writepwd(em4x50_data_t *etd) {
|
||||||
|
|
||||||
em4x50_setup_read();
|
em4x50_setup_read();
|
||||||
|
|
||||||
|
LED_C_ON();
|
||||||
if (get_signalproperties() && find_em4x50_tag()) {
|
if (get_signalproperties() && find_em4x50_tag()) {
|
||||||
|
|
||||||
|
LED_C_OFF();
|
||||||
|
LED_D_ON();
|
||||||
|
|
||||||
// login and change password
|
// login and change password
|
||||||
if (login(etd->password1) == PM3_SUCCESS) {
|
if (login(etd->password1) == PM3_SUCCESS) {
|
||||||
|
|
||||||
|
@ -1083,6 +1099,7 @@ void em4x50_writepwd(em4x50_data_t *etd) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LEDsoff();
|
||||||
lf_finalize();
|
lf_finalize();
|
||||||
reply_ng(CMD_LF_EM4X50_WRITEPWD, status, NULL, 0);
|
reply_ng(CMD_LF_EM4X50_WRITEPWD, status, NULL, 0);
|
||||||
}
|
}
|
||||||
|
@ -1308,6 +1325,8 @@ static int check_rm_request(uint32_t *tag) {
|
||||||
bit = em4x50_sim_read_bit();
|
bit = em4x50_sim_read_bit();
|
||||||
if (bit == 0) {
|
if (bit == 0) {
|
||||||
|
|
||||||
|
LED_C_ON();
|
||||||
|
|
||||||
// if command before was EM4X50_COMMAND_WRITE_PASSWORD
|
// if command before was EM4X50_COMMAND_WRITE_PASSWORD
|
||||||
// switch to separate process
|
// switch to separate process
|
||||||
if (gWritePasswordProcess) {
|
if (gWritePasswordProcess) {
|
||||||
|
@ -1508,11 +1527,11 @@ static int em4x50_sim_handle_login_command(uint32_t *tag) {
|
||||||
if (pwd && (password == reflect32(tag[EM4X50_DEVICE_PASSWORD]))) {
|
if (pwd && (password == reflect32(tag[EM4X50_DEVICE_PASSWORD]))) {
|
||||||
em4x50_sim_send_ack();
|
em4x50_sim_send_ack();
|
||||||
gLogin = true;
|
gLogin = true;
|
||||||
LED_A_ON();
|
LED_D_ON();
|
||||||
} else {
|
} else {
|
||||||
em4x50_sim_send_nak();
|
em4x50_sim_send_nak();
|
||||||
gLogin = false;
|
gLogin = false;
|
||||||
LED_A_OFF();
|
LED_D_OFF();
|
||||||
}
|
}
|
||||||
// continue with standard read mode
|
// continue with standard read mode
|
||||||
return EM4X50_COMMAND_STANDARD_READ;
|
return EM4X50_COMMAND_STANDARD_READ;
|
||||||
|
@ -1527,7 +1546,7 @@ static int em4x50_sim_handle_reset_command(uint32_t *tag) {
|
||||||
// send ACK
|
// send ACK
|
||||||
em4x50_sim_send_ack();
|
em4x50_sim_send_ack();
|
||||||
gLogin = false;
|
gLogin = false;
|
||||||
LED_A_OFF();
|
LED_D_OFF();
|
||||||
|
|
||||||
// wait for initialization (tinit)
|
// wait for initialization (tinit)
|
||||||
wait_cycles(EM4X50_T_TAG_TINIT);
|
wait_cycles(EM4X50_T_TAG_TINIT);
|
||||||
|
@ -1712,37 +1731,26 @@ void em4x50_handle_commands(int *command, uint32_t *tag) {
|
||||||
switch (*command) {
|
switch (*command) {
|
||||||
|
|
||||||
case EM4X50_COMMAND_LOGIN:
|
case EM4X50_COMMAND_LOGIN:
|
||||||
LED_B_OFF();
|
|
||||||
LED_C_OFF();
|
|
||||||
*command = em4x50_sim_handle_login_command(tag);
|
*command = em4x50_sim_handle_login_command(tag);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EM4X50_COMMAND_RESET:
|
case EM4X50_COMMAND_RESET:
|
||||||
LED_B_OFF();
|
|
||||||
LED_C_OFF();
|
|
||||||
*command = em4x50_sim_handle_reset_command(tag);
|
*command = em4x50_sim_handle_reset_command(tag);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EM4X50_COMMAND_WRITE:
|
case EM4X50_COMMAND_WRITE:
|
||||||
LED_B_OFF();
|
|
||||||
LED_C_OFF();
|
|
||||||
*command = em4x50_sim_handle_write_command(tag);
|
*command = em4x50_sim_handle_write_command(tag);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EM4X50_COMMAND_WRITE_PASSWORD:
|
case EM4X50_COMMAND_WRITE_PASSWORD:
|
||||||
LED_B_OFF();
|
|
||||||
LED_C_OFF();
|
|
||||||
*command = em4x50_sim_handle_writepwd_command(tag);
|
*command = em4x50_sim_handle_writepwd_command(tag);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EM4X50_COMMAND_SELECTIVE_READ:
|
case EM4X50_COMMAND_SELECTIVE_READ:
|
||||||
LED_B_OFF();
|
|
||||||
LED_C_ON();
|
|
||||||
*command = em4x50_sim_handle_selective_read_command(tag);
|
*command = em4x50_sim_handle_selective_read_command(tag);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EM4X50_COMMAND_STANDARD_READ:
|
case EM4X50_COMMAND_STANDARD_READ:
|
||||||
LED_B_ON();
|
|
||||||
LED_C_OFF();
|
LED_C_OFF();
|
||||||
*command = em4x50_sim_handle_standard_read_command(tag);
|
*command = em4x50_sim_handle_standard_read_command(tag);
|
||||||
break;
|
break;
|
||||||
|
@ -1756,9 +1764,8 @@ void em4x50_handle_commands(int *command, uint32_t *tag) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// simulate uploaded data in emulator memory
|
// simulate uploaded data in emulator memory
|
||||||
// LED A -> operations that require authentication are possible
|
// LED C -> reader command has been detected
|
||||||
// LED B -> standard read mode is active
|
// LED D -> operations that require authentication are possible
|
||||||
// LED C -> command has been transmitted by reader
|
|
||||||
void em4x50_sim(uint32_t *password) {
|
void em4x50_sim(uint32_t *password) {
|
||||||
|
|
||||||
int command = 0;
|
int command = 0;
|
||||||
|
@ -1778,6 +1785,7 @@ void em4x50_sim(uint32_t *password) {
|
||||||
if (tag[EM4X50_DEVICE_SERIAL] != tag[EM4X50_DEVICE_ID]) {
|
if (tag[EM4X50_DEVICE_SERIAL] != tag[EM4X50_DEVICE_ID]) {
|
||||||
|
|
||||||
// init
|
// init
|
||||||
|
LEDsoff();
|
||||||
em4x50_setup_sim();
|
em4x50_setup_sim();
|
||||||
gLogin = false;
|
gLogin = false;
|
||||||
gWritePasswordProcess = false;
|
gWritePasswordProcess = false;
|
||||||
|
@ -1799,7 +1807,7 @@ void em4x50_sim(uint32_t *password) {
|
||||||
if (command == PM3_ETIMEOUT) {
|
if (command == PM3_ETIMEOUT) {
|
||||||
command = EM4X50_COMMAND_STANDARD_READ;
|
command = EM4X50_COMMAND_STANDARD_READ;
|
||||||
gLogin = false;
|
gLogin = false;
|
||||||
LED_A_OFF();
|
LED_D_OFF();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue