|
18 | 18 | #include "bsp_wdt.h" |
19 | 19 | #include "lf_reader_generic.h" |
20 | 20 | #include "lf_em4x05_data.h" |
| 21 | +#include "lf_psk_reader.h" |
21 | 22 | #endif |
22 | 23 | #include "nfc_14a.h" |
23 | 24 |
|
@@ -823,6 +824,35 @@ static data_frame_tx_t *cmd_processor_viking_write_to_t55xx(uint16_t cmd, uint16 |
823 | 824 | return data_frame_make(cmd, status, 0, NULL); |
824 | 825 | } |
825 | 826 |
|
| 827 | +static data_frame_tx_t *cmd_processor_indala_scan(uint16_t cmd, uint16_t status, uint16_t length, uint8_t *data) { |
| 828 | + uint8_t card_buffer[LF_INDALA_TAG_ID_SIZE] = {0x00}; |
| 829 | + status = scan_indala(card_buffer); |
| 830 | + if (status != STATUS_LF_TAG_OK) { |
| 831 | + return data_frame_make(cmd, status, 0, NULL); |
| 832 | + } |
| 833 | + return data_frame_make(cmd, STATUS_LF_TAG_OK, sizeof(card_buffer), card_buffer); |
| 834 | +} |
| 835 | + |
| 836 | +static data_frame_tx_t *cmd_processor_indala_write_to_t55xx(uint16_t cmd, uint16_t status, uint16_t length, uint8_t *data) { |
| 837 | + typedef struct { |
| 838 | + uint8_t id[LF_INDALA_TAG_ID_SIZE]; |
| 839 | + uint8_t new_key[4]; |
| 840 | + uint8_t old_keys[4]; |
| 841 | + } PACKED payload_t; |
| 842 | + payload_t *payload = (payload_t *)data; |
| 843 | + if (length < sizeof(payload_t)) { |
| 844 | + return data_frame_make(cmd, STATUS_PAR_ERR, 0, NULL); |
| 845 | + } |
| 846 | + uint16_t tail = length - offsetof(payload_t, old_keys); |
| 847 | + bool fc8 = (tail % 4 == 1) ? data[length - 1] : 0; |
| 848 | + uint8_t key_count = (tail - (tail % 4 == 1 ? 1 : 0)) / 4; |
| 849 | + if (key_count == 0) { |
| 850 | + return data_frame_make(cmd, STATUS_PAR_ERR, 0, NULL); |
| 851 | + } |
| 852 | + status = write_indala_to_t55xx(payload->id, payload->new_key, payload->old_keys, key_count, fc8); |
| 853 | + return data_frame_make(cmd, status, 0, NULL); |
| 854 | +} |
| 855 | + |
826 | 856 | #define GENERIC_READ_LEN 800 |
827 | 857 | #define GENERIC_READ_TIMEOUT_MS 500 |
828 | 858 | static data_frame_tx_t *cmd_processor_generic_read(uint16_t cmd, uint16_t status, uint16_t length, uint8_t *data) { |
@@ -1072,6 +1102,26 @@ static data_frame_tx_t *cmd_processor_viking_get_emu_id(uint16_t cmd, uint16_t s |
1072 | 1102 | return data_frame_make(cmd, STATUS_SUCCESS, LF_VIKING_TAG_ID_SIZE, buffer->buffer); |
1073 | 1103 | } |
1074 | 1104 |
|
| 1105 | +static data_frame_tx_t *cmd_processor_indala_set_emu_id(uint16_t cmd, uint16_t status, uint16_t length, uint8_t *data) { |
| 1106 | + if (length != LF_INDALA_TAG_ID_SIZE) { |
| 1107 | + return data_frame_make(cmd, STATUS_PAR_ERR, 0, NULL); |
| 1108 | + } |
| 1109 | + tag_data_buffer_t *buffer = get_buffer_by_tag_type(TAG_TYPE_INDALA); |
| 1110 | + memcpy(buffer->buffer, data, LF_INDALA_TAG_ID_SIZE); |
| 1111 | + tag_emulation_load_by_buffer(TAG_TYPE_INDALA, false); |
| 1112 | + return data_frame_make(cmd, STATUS_SUCCESS, 0, NULL); |
| 1113 | +} |
| 1114 | + |
| 1115 | +static data_frame_tx_t *cmd_processor_indala_get_emu_id(uint16_t cmd, uint16_t status, uint16_t length, uint8_t *data) { |
| 1116 | + tag_slot_specific_type_t tag_types; |
| 1117 | + tag_emulation_get_specific_types_by_slot(tag_emulation_get_slot(), &tag_types); |
| 1118 | + if (tag_types.tag_lf != TAG_TYPE_INDALA) { |
| 1119 | + return data_frame_make(cmd, STATUS_PAR_ERR, 0, NULL); |
| 1120 | + } |
| 1121 | + tag_data_buffer_t *buffer = get_buffer_by_tag_type(TAG_TYPE_INDALA); |
| 1122 | + return data_frame_make(cmd, STATUS_SUCCESS, LF_INDALA_TAG_ID_SIZE, buffer->buffer); |
| 1123 | +} |
| 1124 | + |
1075 | 1125 | static nfc_tag_14a_coll_res_reference_t *get_coll_res_data(bool write) { |
1076 | 1126 | nfc_tag_14a_coll_res_reference_t *info; |
1077 | 1127 | tag_slot_specific_type_t tag_types; |
@@ -1915,6 +1965,8 @@ static cmd_data_map_t m_data_cmd_map[] = { |
1915 | 1965 | { DATA_CMD_VIKING_WRITE_TO_T55XX, before_reader_run, cmd_processor_viking_write_to_t55xx, NULL }, |
1916 | 1966 | { DATA_CMD_IOPROX_SCAN, before_reader_run, cmd_processor_ioprox_scan, NULL }, |
1917 | 1967 | { DATA_CMD_IOPROX_WRITE_TO_T55XX, before_reader_run, cmd_processor_ioprox_write_to_t55xx, NULL }, |
| 1968 | + { DATA_CMD_INDALA_SCAN, before_reader_run, cmd_processor_indala_scan, NULL }, |
| 1969 | + { DATA_CMD_INDALA_WRITE_TO_T55XX, before_reader_run, cmd_processor_indala_write_to_t55xx, NULL }, |
1918 | 1970 | { DATA_CMD_ADC_GENERIC_READ, before_reader_run, cmd_processor_generic_read, NULL }, |
1919 | 1971 |
|
1920 | 1972 | { DATA_CMD_HF14A_SET_FIELD_ON, before_reader_run, cmd_processor_hf14a_set_field_on, NULL }, |
@@ -1980,6 +2032,8 @@ static cmd_data_map_t m_data_cmd_map[] = { |
1980 | 2032 | { DATA_CMD_IOPROX_GET_EMU_ID, NULL, cmd_processor_ioprox_get_emu_id, NULL }, |
1981 | 2033 | { DATA_CMD_VIKING_SET_EMU_ID, NULL, cmd_processor_viking_set_emu_id, NULL }, |
1982 | 2034 | { DATA_CMD_VIKING_GET_EMU_ID, NULL, cmd_processor_viking_get_emu_id, NULL }, |
| 2035 | + { DATA_CMD_INDALA_SET_EMU_ID, NULL, cmd_processor_indala_set_emu_id, NULL }, |
| 2036 | + { DATA_CMD_INDALA_GET_EMU_ID, NULL, cmd_processor_indala_get_emu_id, NULL }, |
1983 | 2037 | }; |
1984 | 2038 |
|
1985 | 2039 | data_frame_tx_t *cmd_processor_get_device_capabilities(uint16_t cmd, uint16_t status, uint16_t length, uint8_t *data) { |
|
0 commit comments