New DELETE_SLOT_TAG_NICK

This commit is contained in:
Philippe Teuwen
2023-09-27 23:09:59 +02:00
parent 43cadeb84d
commit 6915ee19a4
6 changed files with 56 additions and 0 deletions
+1
View File
@@ -6,6 +6,7 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac
- Add PyInstaller support for CLI client (@augustozanellato)
## [v2.0.0][2023-09-26]
- Added `hw slot nick delete` and DELETE_SLOT_TAG_NICK (@doegox)
- Changed APP_FW_VER now deduced from git tag vx.y.z (@doegox)
- Changed initial button wakeup from 4 to 8 seconds (@aramova)
- Added MIFARE Ultralight reading features (@FlUxIuS & @doegox)
+4
View File
@@ -146,6 +146,10 @@ Notes: the returned string is the output of `git describe --abbrev=7 --dirty --a
* Command: no data
* Response: no data. Status is `STATUS_DEVICE_SUCCESS` or `STATUS_FLASH_WRITE_FAIL`. The device will reboot shortly after this command.
* CLI: cf `hw factory_reset`
### 1021: DELETE_SLOT_TAG_NICK
* Command: 2 bytes. `slot_number|sense_type` with `slot_number` between 0 and 7 and `sense_type` according to `tag_sense_type_t` enum.
* Response: no data
* CLI: cf `hw slot nick delete`
### 1023: GET_ENABLED_SLOTS
* Command: no data
* Response: 16 bytes, 8*2 bool = `0x00` or `0x01`, 2 bytes for each slot from 0 to 7, as `enabled_hf|enabled_lf`
+20
View File
@@ -792,6 +792,25 @@ static data_frame_tx_t *cmd_processor_get_slot_tag_nick(uint16_t cmd, uint16_t s
return data_frame_make(cmd, STATUS_DEVICE_SUCCESS, buffer[0], &buffer[1]);
}
static data_frame_tx_t *cmd_processor_delete_slot_tag_nick(uint16_t cmd, uint16_t status, uint16_t length, uint8_t *data) {
if (length != 2) {
return data_frame_make(cmd, STATUS_PAR_ERR, 0, NULL);
}
uint8_t slot = data[0];
uint8_t sense_type = data[1];
fds_slot_record_map_t map_info;
if (slot >= TAG_MAX_SLOT_NUM || (sense_type != TAG_SENSE_HF && sense_type != TAG_SENSE_LF)) {
return data_frame_make(cmd, STATUS_PAR_ERR, 0, NULL);
}
get_fds_map_by_slot_sense_type_for_nick(slot, sense_type, &map_info);
bool ret = fds_delete_sync(map_info.id, map_info.key);
if (!ret) {
return data_frame_make(cmd, STATUS_FLASH_WRITE_FAIL, 0, NULL);
}
return data_frame_make(cmd, STATUS_DEVICE_SUCCESS, 0, NULL);
}
static data_frame_tx_t *cmd_processor_mf1_get_emulator_config(uint16_t cmd, uint16_t status, uint16_t length, uint8_t *data) {
uint8_t mf1_info[5] = {};
mf1_info[0] = nfc_tag_mf1_is_detection_enable();
@@ -965,6 +984,7 @@ static cmd_data_map_t m_data_cmd_map[] = {
{ DATA_CMD_GET_ACTIVE_SLOT, NULL, cmd_processor_get_active_slot, NULL },
{ DATA_CMD_GET_SLOT_INFO, NULL, cmd_processor_get_slot_info, NULL },
{ DATA_CMD_WIPE_FDS, NULL, cmd_processor_wipe_fds, NULL },
{ DATA_CMD_DELETE_SLOT_TAG_NICK, NULL, cmd_processor_delete_slot_tag_nick, 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 },
{ DATA_CMD_GET_BATTERY_INFO, NULL, cmd_processor_get_battery_info, NULL },
+1
View File
@@ -28,6 +28,7 @@
#define DATA_CMD_GET_ACTIVE_SLOT (1018)
#define DATA_CMD_GET_SLOT_INFO (1019)
#define DATA_CMD_WIPE_FDS (1020)
#define DATA_CMD_DELETE_SLOT_TAG_NICK (1021)
#define DATA_CMD_GET_ENABLED_SLOTS (1023)
#define DATA_CMD_DELETE_SLOT_SENSE_TYPE (1024)
+16
View File
@@ -1392,6 +1392,22 @@ class HWSlotNickGet(SlotIndexRequireUnit, SenseTypeRequireUnit):
print(f' - Get tag nick name for slot {slot_num}: {res.decode(encoding="utf8")}')
@hw_slot_nick.command('delete', 'Delete tag nick name for slot')
class HWSlotNickGet(SlotIndexRequireUnit, SenseTypeRequireUnit):
def args_parser(self) -> ArgumentParserNoExit or None:
parser = ArgumentParserNoExit()
self.add_slot_args(parser)
self.add_sense_type_args(parser)
return parser
# hw slot nick delete -s 1 -st 1
def on_exec(self, args: argparse.Namespace):
slot_num = args.slot
sense_type = args.sense_type
res = self.cmd.delete_slot_tag_nick(slot_num, sense_type)
print(f' - Delete tag nick name for slot {slot_num}: {res.decode(encoding="utf8")}')
@hw_slot.command('update', 'Update config & data to device flash')
class HWSlotUpdate(DeviceRequiredUnit):
def args_parser(self) -> ArgumentParserNoExit or None:
+14
View File
@@ -37,6 +37,8 @@ DATA_CMD_GET_SLOT_INFO = 1019
DATA_CMD_WIPE_FDS = 1020
DATA_CMD_DELETE_SLOT_TAG_NICK = 1021
DATA_CMD_GET_ENABLED_SLOTS = 1023
DATA_CMD_DELETE_SLOT_SENSE_TYPE = 1024
@@ -912,6 +914,18 @@ class ChameleonCMD:
data = struct.pack('!BB', SlotNumber.to_fw(slot), sense_type)
return self.device.send_cmd_sync(DATA_CMD_GET_SLOT_TAG_NICK, data)
@expect_response(chameleon_status.Device.STATUS_DEVICE_SUCCESS)
def delete_slot_tag_nick(self, slot: SlotNumber, sense_type: TagSenseType):
"""
Delete the nick name of the slot
:param slot: Card slot number
:param sense_type: field type
:return:
"""
# SlotNumber() will raise error for us if slot not in slot range
data = struct.pack('!BB', SlotNumber.to_fw(slot), sense_type)
return self.device.send_cmd_sync(DATA_CMD_DELETE_SLOT_TAG_NICK, data)
@expect_response(chameleon_status.Device.STATUS_DEVICE_SUCCESS)
def mf1_get_emulator_config(self):
"""