mirror of
https://github.com/RfidResearchGroup/ChameleonUltra.git
synced 2026-05-12 11:22:59 -07:00
Add ability to delete sense type per slot
This commit is contained in:
@@ -304,6 +304,23 @@ data_frame_tx_t* cmd_processor_set_slot_tag_type(uint16_t cmd, uint16_t status,
|
||||
return data_frame_make(cmd, status, 0, NULL);
|
||||
}
|
||||
|
||||
data_frame_tx_t* cmd_processor_delete_slot_sense_type(uint16_t cmd, uint16_t status, uint16_t length, uint8_t* data) {
|
||||
status = STATUS_PAR_ERR;
|
||||
if (length == 2 && data[0] < TAG_MAX_SLOT_NUM && (data[1] == TAG_SENSE_HF || data[1] == TAG_SENSE_LF)) {
|
||||
uint8_t slot_num = data[0];
|
||||
uint8_t sense_type = data[1];
|
||||
uint8_t other_st_index = sense_type == TAG_SENSE_LF ? 0 : 1;
|
||||
|
||||
tag_specific_type_t tag_types[2];
|
||||
tag_emulation_get_specific_type_by_slot(slot_num, tag_types);
|
||||
if (tag_types[other_st_index] != TAG_TYPE_UNKNOWN) {
|
||||
tag_emulation_delete_data(slot_num, sense_type);
|
||||
status = STATUS_DEVICE_SUCCESS;
|
||||
}
|
||||
}
|
||||
return data_frame_make(cmd, status, 0, NULL);
|
||||
}
|
||||
|
||||
data_frame_tx_t* cmd_processor_set_slot_data_default(uint16_t cmd, uint16_t status, uint16_t length, uint8_t *data) {
|
||||
if (length == 2 && data[0] < TAG_MAX_SLOT_NUM && data[1] != TAG_TYPE_UNKNOWN) {
|
||||
uint8_t num_slot = data[0];
|
||||
@@ -768,6 +785,7 @@ static cmd_data_map_t m_data_cmd_map[] = {
|
||||
{ DATA_CMD_GET_SLOT_INFO, NULL, cmd_processor_get_slot_info, NULL },
|
||||
{ DATA_CMD_WIPE_FDS, NULL, cmd_processor_wipe_fds, NULL },
|
||||
{ DATA_CMD_GET_ENABLED_SLOTS, NULL, cmd_processor_get_enabled_slots, NULL },
|
||||
{ DATA_CMD_DELETE_SLOT_SENSE_TYPE, NULL, cmd_processor_delete_slot_sense_type, NULL },
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#define DATA_CMD_GET_SLOT_INFO (1019)
|
||||
#define DATA_CMD_WIPE_FDS (1020)
|
||||
#define DATA_CMD_GET_ENABLED_SLOTS (1023)
|
||||
#define DATA_CMD_DELETE_SLOT_SENSE_TYPE (1024)
|
||||
//
|
||||
// ******************************************************************
|
||||
|
||||
|
||||
@@ -1012,6 +1012,23 @@ class HWSlotTagType(TagTypeRequiredUnit, SlotIndexRequireUnit):
|
||||
print(f' - Set slot tag type success.')
|
||||
|
||||
|
||||
@hw_slot.command('delete', 'Delete sense type data for slot')
|
||||
class HWDeleteSlotSense(SlotIndexRequireUnit, SenseTypeRequireUnit):
|
||||
def args_parser(self) -> ArgumentParserNoExit:
|
||||
parser = ArgumentParserNoExit()
|
||||
parser.description = "Delete sense type data for a specific slot. " \
|
||||
"The slot needs to have the other sense type correctly configured, " \
|
||||
"otherwise an error will be thrown."
|
||||
self.add_slot_args(parser)
|
||||
self.add_sense_type_args(parser)
|
||||
return parser
|
||||
|
||||
def on_exec(self, args: argparse.Namespace):
|
||||
slot = args.slot
|
||||
sense_type = args.sense_type
|
||||
self.cmd.delete_slot_sense_type(slot, sense_type)
|
||||
|
||||
|
||||
@hw_slot.command('init', 'Set emulation tag data to default')
|
||||
class HWSlotDataDefault(TagTypeRequiredUnit, SlotIndexRequireUnit):
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ DATA_CMD_GET_SLOT_INFO = 1019
|
||||
DATA_CMD_WIPE_FDS = 1020
|
||||
|
||||
DATA_CMD_GET_ENABLED_SLOTS = 1023
|
||||
DATA_CMD_DELETE_SLOT_SENSE_TYPE = 1024
|
||||
|
||||
DATA_CMD_SCAN_14A_TAG = 2000
|
||||
DATA_CMD_MF1_SUPPORT_DETECT = 2001
|
||||
@@ -432,6 +433,21 @@ class ChameleonCMD:
|
||||
data.append(tag_type)
|
||||
return self.device.send_cmd_sync(DATA_CMD_SET_SLOT_TAG_TYPE, 0x00, data)
|
||||
|
||||
@expect_response(chameleon_status.Device.STATUS_DEVICE_SUCCESS)
|
||||
def delete_slot_sense_type(self, slot_index: SlotNumber, sense_type: TagSenseType):
|
||||
"""
|
||||
Delete a sense type for a specific slot.
|
||||
Another sense type must be enabled for the same slot,
|
||||
otherwise an error will be thrown.
|
||||
:param slot_index: Slot index
|
||||
:param sense_type: Sense type to disable
|
||||
:return:
|
||||
"""
|
||||
return self.device.send_cmd_sync(DATA_CMD_DELETE_SLOT_SENSE_TYPE, 0x00, bytearray([
|
||||
SlotNumber.to_fw(slot_index),
|
||||
sense_type,
|
||||
]))
|
||||
|
||||
@expect_response(chameleon_status.Device.STATUS_DEVICE_SUCCESS)
|
||||
def set_slot_data_default(self, slot_index: SlotNumber, tag_type: TagSpecificType):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user