mirror of
https://github.com/flipperdevices/flipperzero-firmware.git
synced 2025-12-12 04:41:26 +04:00
Api Symbols: replace asserts with checks (#3507)
* Api Symbols: replace asserts with checks * Api Symbols: replace asserts with checks part 2 * Update no args function signatures with void, to help compiler to track incorrect usage * More unavoidable void * Update PVS config and code to make it happy * Format sources * nfc: fix checks * dead code cleanup & include fixes Co-authored-by: gornekich <n.gorbadey@gmail.com> Co-authored-by: hedger <hedger@users.noreply.github.com> Co-authored-by: hedger <hedger@nanode.su>
This commit is contained in:
@@ -33,6 +33,8 @@ static uint16_t
|
||||
}
|
||||
|
||||
void iso13239_crc_append(Iso13239CrcType type, BitBuffer* buf) {
|
||||
furi_check(buf);
|
||||
|
||||
const uint8_t* data = bit_buffer_get_data(buf);
|
||||
const size_t data_size = bit_buffer_get_size_bytes(buf);
|
||||
|
||||
@@ -41,6 +43,8 @@ void iso13239_crc_append(Iso13239CrcType type, BitBuffer* buf) {
|
||||
}
|
||||
|
||||
bool iso13239_crc_check(Iso13239CrcType type, const BitBuffer* buf) {
|
||||
furi_check(buf);
|
||||
|
||||
const size_t data_size = bit_buffer_get_size_bytes(buf);
|
||||
if(data_size <= ISO13239_CRC_SIZE) return false;
|
||||
|
||||
@@ -55,6 +59,8 @@ bool iso13239_crc_check(Iso13239CrcType type, const BitBuffer* buf) {
|
||||
}
|
||||
|
||||
void iso13239_crc_trim(BitBuffer* buf) {
|
||||
furi_check(buf);
|
||||
|
||||
const size_t data_size = bit_buffer_get_size_bytes(buf);
|
||||
furi_assert(data_size > ISO13239_CRC_SIZE);
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ static inline void iso14443_4_layer_update_pcb(Iso14443_4Layer* instance) {
|
||||
instance->pcb ^= (uint8_t)0x01;
|
||||
}
|
||||
|
||||
Iso14443_4Layer* iso14443_4_layer_alloc() {
|
||||
Iso14443_4Layer* iso14443_4_layer_alloc(void) {
|
||||
Iso14443_4Layer* instance = malloc(sizeof(Iso14443_4Layer));
|
||||
|
||||
iso14443_4_layer_reset(instance);
|
||||
|
||||
@@ -8,7 +8,7 @@ extern "C" {
|
||||
|
||||
typedef struct Iso14443_4Layer Iso14443_4Layer;
|
||||
|
||||
Iso14443_4Layer* iso14443_4_layer_alloc();
|
||||
Iso14443_4Layer* iso14443_4_layer_alloc(void);
|
||||
|
||||
void iso14443_4_layer_free(Iso14443_4Layer* instance);
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@ static uint16_t
|
||||
}
|
||||
|
||||
void iso14443_crc_append(Iso14443CrcType type, BitBuffer* buf) {
|
||||
furi_check(buf);
|
||||
|
||||
const uint8_t* data = bit_buffer_get_data(buf);
|
||||
const size_t data_size = bit_buffer_get_size_bytes(buf);
|
||||
|
||||
@@ -36,6 +38,8 @@ void iso14443_crc_append(Iso14443CrcType type, BitBuffer* buf) {
|
||||
}
|
||||
|
||||
bool iso14443_crc_check(Iso14443CrcType type, const BitBuffer* buf) {
|
||||
furi_check(buf);
|
||||
|
||||
const size_t data_size = bit_buffer_get_size_bytes(buf);
|
||||
if(data_size <= ISO14443_CRC_SIZE) return false;
|
||||
|
||||
@@ -50,8 +54,9 @@ bool iso14443_crc_check(Iso14443CrcType type, const BitBuffer* buf) {
|
||||
}
|
||||
|
||||
void iso14443_crc_trim(BitBuffer* buf) {
|
||||
furi_check(buf);
|
||||
const size_t data_size = bit_buffer_get_size_bytes(buf);
|
||||
furi_assert(data_size > ISO14443_CRC_SIZE);
|
||||
furi_check(data_size > ISO14443_CRC_SIZE);
|
||||
|
||||
bit_buffer_set_size_bytes(buf, data_size - ISO14443_CRC_SIZE);
|
||||
}
|
||||
|
||||
@@ -552,9 +552,14 @@ static const NfcDataGenerator nfc_data_generator[NfcDataGeneratorTypeNum] = {
|
||||
};
|
||||
|
||||
const char* nfc_data_generator_get_name(NfcDataGeneratorType type) {
|
||||
furi_check(type < NfcDataGeneratorTypeNum);
|
||||
|
||||
return nfc_data_generator[type].name;
|
||||
}
|
||||
|
||||
void nfc_data_generator_fill_data(NfcDataGeneratorType type, NfcDevice* nfc_device) {
|
||||
furi_check(type < NfcDataGeneratorTypeNum);
|
||||
furi_check(nfc_device);
|
||||
|
||||
nfc_data_generator[type].handler(nfc_device);
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ uint8_t nfc_util_odd_parity8(uint8_t data) {
|
||||
}
|
||||
|
||||
void nfc_util_odd_parity(const uint8_t* src, uint8_t* dst, uint8_t len) {
|
||||
furi_assert(src);
|
||||
furi_assert(dst);
|
||||
furi_check(src);
|
||||
furi_check(dst);
|
||||
|
||||
uint8_t parity = 0;
|
||||
uint8_t bit = 0;
|
||||
|
||||
@@ -235,7 +235,7 @@ static int32_t nfc_worker_poller(void* context) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Nfc* nfc_alloc() {
|
||||
Nfc* nfc_alloc(void) {
|
||||
furi_check(furi_hal_nfc_acquire() == FuriHalNfcErrorNone);
|
||||
|
||||
Nfc* instance = malloc(sizeof(Nfc));
|
||||
@@ -253,8 +253,8 @@ Nfc* nfc_alloc() {
|
||||
}
|
||||
|
||||
void nfc_free(Nfc* instance) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->state == NfcStateIdle);
|
||||
furi_check(instance);
|
||||
furi_check(instance->state == NfcStateIdle);
|
||||
|
||||
furi_thread_free(instance->worker_thread);
|
||||
free(instance);
|
||||
@@ -263,10 +263,10 @@ void nfc_free(Nfc* instance) {
|
||||
}
|
||||
|
||||
void nfc_config(Nfc* instance, NfcMode mode, NfcTech tech) {
|
||||
furi_assert(instance);
|
||||
furi_assert(mode < NfcModeNum);
|
||||
furi_assert(tech < NfcTechNum);
|
||||
furi_assert(instance->config_state == NfcConfigurationStateIdle);
|
||||
furi_check(instance);
|
||||
furi_check(mode < NfcModeNum);
|
||||
furi_check(tech < NfcTechNum);
|
||||
furi_check(instance->config_state == NfcConfigurationStateIdle);
|
||||
|
||||
FuriHalNfcTech hal_tech = nfc_tech_table[mode][tech];
|
||||
if(hal_tech == FuriHalNfcTechInvalid) {
|
||||
@@ -282,35 +282,35 @@ void nfc_config(Nfc* instance, NfcMode mode, NfcTech tech) {
|
||||
}
|
||||
|
||||
void nfc_set_fdt_poll_fc(Nfc* instance, uint32_t fdt_poll_fc) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
instance->fdt_poll_fc = fdt_poll_fc;
|
||||
}
|
||||
|
||||
void nfc_set_fdt_listen_fc(Nfc* instance, uint32_t fdt_listen_fc) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
instance->fdt_listen_fc = fdt_listen_fc;
|
||||
}
|
||||
|
||||
void nfc_set_fdt_poll_poll_us(Nfc* instance, uint32_t fdt_poll_poll_us) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
instance->fdt_poll_poll_us = fdt_poll_poll_us;
|
||||
}
|
||||
|
||||
void nfc_set_guard_time_us(Nfc* instance, uint32_t guard_time_us) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
instance->guard_time_us = guard_time_us;
|
||||
}
|
||||
|
||||
void nfc_set_mask_receive_time_fc(Nfc* instance, uint32_t mask_rx_time_fc) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
instance->mask_rx_time_fc = mask_rx_time_fc;
|
||||
}
|
||||
|
||||
void nfc_start(Nfc* instance, NfcEventCallback callback, void* context) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->worker_thread);
|
||||
furi_assert(callback);
|
||||
furi_assert(instance->config_state == NfcConfigurationStateDone);
|
||||
furi_check(instance);
|
||||
furi_check(instance->worker_thread);
|
||||
furi_check(callback);
|
||||
furi_check(instance->config_state == NfcConfigurationStateDone);
|
||||
|
||||
instance->callback = callback;
|
||||
instance->context = context;
|
||||
@@ -324,8 +324,8 @@ void nfc_start(Nfc* instance, NfcEventCallback callback, void* context) {
|
||||
}
|
||||
|
||||
void nfc_stop(Nfc* instance) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->state == NfcStateRunning);
|
||||
furi_check(instance);
|
||||
furi_check(instance->state == NfcStateRunning);
|
||||
|
||||
if(instance->mode == NfcModeListener) {
|
||||
furi_hal_nfc_abort();
|
||||
@@ -336,8 +336,8 @@ void nfc_stop(Nfc* instance) {
|
||||
}
|
||||
|
||||
NfcError nfc_listener_tx(Nfc* instance, const BitBuffer* tx_buffer) {
|
||||
furi_assert(instance);
|
||||
furi_assert(tx_buffer);
|
||||
furi_check(instance);
|
||||
furi_check(tx_buffer);
|
||||
|
||||
NfcError ret = NfcErrorNone;
|
||||
|
||||
@@ -409,11 +409,11 @@ NfcError nfc_iso14443a_poller_trx_custom_parity(
|
||||
const BitBuffer* tx_buffer,
|
||||
BitBuffer* rx_buffer,
|
||||
uint32_t fwt) {
|
||||
furi_assert(instance);
|
||||
furi_assert(tx_buffer);
|
||||
furi_assert(rx_buffer);
|
||||
furi_check(instance);
|
||||
furi_check(tx_buffer);
|
||||
furi_check(rx_buffer);
|
||||
|
||||
furi_assert(instance->poller_state == NfcPollerStateReady);
|
||||
furi_check(instance->poller_state == NfcPollerStateReady);
|
||||
|
||||
NfcError ret = NfcErrorNone;
|
||||
FuriHalNfcError error = FuriHalNfcErrorNone;
|
||||
@@ -462,11 +462,11 @@ NfcError nfc_iso14443a_poller_trx_custom_parity(
|
||||
|
||||
NfcError
|
||||
nfc_poller_trx(Nfc* instance, const BitBuffer* tx_buffer, BitBuffer* rx_buffer, uint32_t fwt) {
|
||||
furi_assert(instance);
|
||||
furi_assert(tx_buffer);
|
||||
furi_assert(rx_buffer);
|
||||
furi_check(instance);
|
||||
furi_check(tx_buffer);
|
||||
furi_check(rx_buffer);
|
||||
|
||||
furi_assert(instance->poller_state == NfcPollerStateReady);
|
||||
furi_check(instance->poller_state == NfcPollerStateReady);
|
||||
|
||||
NfcError ret = NfcErrorNone;
|
||||
FuriHalNfcError error = FuriHalNfcErrorNone;
|
||||
@@ -511,7 +511,7 @@ NfcError nfc_iso14443a_listener_set_col_res_data(
|
||||
uint8_t uid_len,
|
||||
uint8_t* atqa,
|
||||
uint8_t sak) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
FuriHalNfcError error =
|
||||
furi_hal_nfc_iso14443a_listener_set_col_res_data(uid, uid_len, atqa, sak);
|
||||
@@ -524,14 +524,14 @@ NfcError nfc_iso14443a_poller_trx_short_frame(
|
||||
NfcIso14443aShortFrame frame,
|
||||
BitBuffer* rx_buffer,
|
||||
uint32_t fwt) {
|
||||
furi_assert(instance);
|
||||
furi_assert(rx_buffer);
|
||||
furi_check(instance);
|
||||
furi_check(rx_buffer);
|
||||
|
||||
FuriHalNfcaShortFrame short_frame = (frame == NfcIso14443aShortFrameAllReqa) ?
|
||||
FuriHalNfcaShortFrameAllReq :
|
||||
FuriHalNfcaShortFrameSensReq;
|
||||
|
||||
furi_assert(instance->poller_state == NfcPollerStateReady);
|
||||
furi_check(instance->poller_state == NfcPollerStateReady);
|
||||
|
||||
NfcError ret = NfcErrorNone;
|
||||
FuriHalNfcError error = FuriHalNfcErrorNone;
|
||||
@@ -574,11 +574,11 @@ NfcError nfc_iso14443a_poller_trx_sdd_frame(
|
||||
const BitBuffer* tx_buffer,
|
||||
BitBuffer* rx_buffer,
|
||||
uint32_t fwt) {
|
||||
furi_assert(instance);
|
||||
furi_assert(tx_buffer);
|
||||
furi_assert(rx_buffer);
|
||||
furi_check(instance);
|
||||
furi_check(tx_buffer);
|
||||
furi_check(rx_buffer);
|
||||
|
||||
furi_assert(instance->poller_state == NfcPollerStateReady);
|
||||
furi_check(instance->poller_state == NfcPollerStateReady);
|
||||
|
||||
NfcError ret = NfcErrorNone;
|
||||
FuriHalNfcError error = FuriHalNfcErrorNone;
|
||||
@@ -618,8 +618,8 @@ NfcError nfc_iso14443a_poller_trx_sdd_frame(
|
||||
}
|
||||
|
||||
NfcError nfc_iso14443a_listener_tx_custom_parity(Nfc* instance, const BitBuffer* tx_buffer) {
|
||||
furi_assert(instance);
|
||||
furi_assert(tx_buffer);
|
||||
furi_check(instance);
|
||||
furi_check(tx_buffer);
|
||||
|
||||
NfcError ret = NfcErrorNone;
|
||||
FuriHalNfcError error = FuriHalNfcErrorNone;
|
||||
@@ -635,7 +635,7 @@ NfcError nfc_iso14443a_listener_tx_custom_parity(Nfc* instance, const BitBuffer*
|
||||
}
|
||||
|
||||
NfcError nfc_iso15693_listener_tx_sof(Nfc* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
while(furi_hal_nfc_timer_block_tx_is_running()) {
|
||||
}
|
||||
@@ -652,9 +652,7 @@ NfcError nfc_felica_listener_set_sensf_res_data(
|
||||
const uint8_t idm_len,
|
||||
const uint8_t* pmm,
|
||||
const uint8_t pmm_len) {
|
||||
furi_assert(instance);
|
||||
furi_assert(idm);
|
||||
furi_assert(pmm);
|
||||
furi_check(instance);
|
||||
|
||||
FuriHalNfcError error =
|
||||
furi_hal_nfc_felica_listener_set_sensf_res_data(idm, idm_len, pmm, pmm_len);
|
||||
|
||||
@@ -128,7 +128,7 @@ typedef enum {
|
||||
*
|
||||
* @returns pointer to the allocated Nfc instance.
|
||||
*/
|
||||
Nfc* nfc_alloc();
|
||||
Nfc* nfc_alloc(void);
|
||||
|
||||
/**
|
||||
* @brief Delete an Nfc instance.
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
#define NFC_DEVICE_UID_MAX_LEN (10U)
|
||||
|
||||
NfcDevice* nfc_device_alloc() {
|
||||
NfcDevice* nfc_device_alloc(void) {
|
||||
NfcDevice* instance = malloc(sizeof(NfcDevice));
|
||||
instance->protocol = NfcProtocolInvalid;
|
||||
|
||||
@@ -22,14 +22,14 @@ NfcDevice* nfc_device_alloc() {
|
||||
}
|
||||
|
||||
void nfc_device_free(NfcDevice* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
nfc_device_clear(instance);
|
||||
free(instance);
|
||||
}
|
||||
|
||||
void nfc_device_clear(NfcDevice* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
if(instance->protocol == NfcProtocolInvalid) {
|
||||
furi_assert(instance->protocol_data == NULL);
|
||||
@@ -43,8 +43,8 @@ void nfc_device_clear(NfcDevice* instance) {
|
||||
}
|
||||
|
||||
void nfc_device_reset(NfcDevice* instance) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->protocol < NfcProtocolNum);
|
||||
furi_check(instance);
|
||||
furi_check(instance->protocol < NfcProtocolNum);
|
||||
|
||||
if(instance->protocol_data) {
|
||||
nfc_devices[instance->protocol]->reset(instance->protocol_data);
|
||||
@@ -52,37 +52,40 @@ void nfc_device_reset(NfcDevice* instance) {
|
||||
}
|
||||
|
||||
NfcProtocol nfc_device_get_protocol(const NfcDevice* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
return instance->protocol;
|
||||
}
|
||||
|
||||
const NfcDeviceData* nfc_device_get_data(const NfcDevice* instance, NfcProtocol protocol) {
|
||||
furi_check(instance);
|
||||
return nfc_device_get_data_ptr(instance, protocol);
|
||||
}
|
||||
|
||||
const char* nfc_device_get_protocol_name(NfcProtocol protocol) {
|
||||
furi_assert(protocol < NfcProtocolNum);
|
||||
furi_check(protocol < NfcProtocolNum);
|
||||
|
||||
return nfc_devices[protocol]->protocol_name;
|
||||
}
|
||||
|
||||
const char* nfc_device_get_name(const NfcDevice* instance, NfcDeviceNameType name_type) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->protocol < NfcProtocolNum);
|
||||
furi_check(instance);
|
||||
furi_check(instance->protocol < NfcProtocolNum);
|
||||
|
||||
return nfc_devices[instance->protocol]->get_name(instance->protocol_data, name_type);
|
||||
}
|
||||
|
||||
const uint8_t* nfc_device_get_uid(const NfcDevice* instance, size_t* uid_len) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->protocol < NfcProtocolNum);
|
||||
furi_check(instance);
|
||||
furi_check(uid_len);
|
||||
furi_check(instance->protocol < NfcProtocolNum);
|
||||
|
||||
return nfc_devices[instance->protocol]->get_uid(instance->protocol_data, uid_len);
|
||||
}
|
||||
|
||||
bool nfc_device_set_uid(NfcDevice* instance, const uint8_t* uid, size_t uid_len) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->protocol < NfcProtocolNum);
|
||||
furi_check(instance);
|
||||
furi_check(uid);
|
||||
furi_check(instance->protocol < NfcProtocolNum);
|
||||
|
||||
return nfc_devices[instance->protocol]->set_uid(instance->protocol_data, uid, uid_len);
|
||||
}
|
||||
@@ -91,8 +94,9 @@ void nfc_device_set_data(
|
||||
NfcDevice* instance,
|
||||
NfcProtocol protocol,
|
||||
const NfcDeviceData* protocol_data) {
|
||||
furi_assert(instance);
|
||||
furi_assert(protocol < NfcProtocolNum);
|
||||
furi_check(instance);
|
||||
furi_check(protocol_data);
|
||||
furi_check(protocol < NfcProtocolNum);
|
||||
|
||||
nfc_device_clear(instance);
|
||||
|
||||
@@ -106,9 +110,9 @@ void nfc_device_copy_data(
|
||||
const NfcDevice* instance,
|
||||
NfcProtocol protocol,
|
||||
NfcDeviceData* protocol_data) {
|
||||
furi_assert(instance);
|
||||
furi_assert(protocol < NfcProtocolNum);
|
||||
furi_assert(protocol_data);
|
||||
furi_check(instance);
|
||||
furi_check(protocol < NfcProtocolNum);
|
||||
furi_check(protocol_data);
|
||||
|
||||
if(instance->protocol != protocol) {
|
||||
furi_crash(NFC_DEV_TYPE_ERROR);
|
||||
@@ -121,17 +125,17 @@ bool nfc_device_is_equal_data(
|
||||
const NfcDevice* instance,
|
||||
NfcProtocol protocol,
|
||||
const NfcDeviceData* protocol_data) {
|
||||
furi_assert(instance);
|
||||
furi_assert(protocol < NfcProtocolNum);
|
||||
furi_assert(protocol_data);
|
||||
furi_check(instance);
|
||||
furi_check(protocol < NfcProtocolNum);
|
||||
furi_check(protocol_data);
|
||||
|
||||
return instance->protocol == protocol &&
|
||||
nfc_devices[protocol]->is_equal(instance->protocol_data, protocol_data);
|
||||
}
|
||||
|
||||
bool nfc_device_is_equal(const NfcDevice* instance, const NfcDevice* other) {
|
||||
furi_assert(instance);
|
||||
furi_assert(other);
|
||||
furi_check(instance);
|
||||
furi_check(other);
|
||||
|
||||
return nfc_device_is_equal_data(instance, other->protocol, other->protocol_data);
|
||||
}
|
||||
@@ -140,17 +144,17 @@ void nfc_device_set_loading_callback(
|
||||
NfcDevice* instance,
|
||||
NfcLoadingCallback callback,
|
||||
void* context) {
|
||||
furi_assert(instance);
|
||||
furi_assert(callback);
|
||||
furi_check(instance);
|
||||
furi_check(callback);
|
||||
|
||||
instance->loading_callback = callback;
|
||||
instance->loading_callback_context = context;
|
||||
}
|
||||
|
||||
bool nfc_device_save(NfcDevice* instance, const char* path) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->protocol < NfcProtocolNum);
|
||||
furi_assert(path);
|
||||
furi_check(instance);
|
||||
furi_check(instance->protocol < NfcProtocolNum);
|
||||
furi_check(path);
|
||||
|
||||
bool saved = false;
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
@@ -313,8 +317,8 @@ static bool nfc_device_load_legacy(NfcDevice* instance, FlipperFormat* ff, uint3
|
||||
}
|
||||
|
||||
bool nfc_device_load(NfcDevice* instance, const char* path) {
|
||||
furi_assert(instance);
|
||||
furi_assert(path);
|
||||
furi_check(instance);
|
||||
furi_check(path);
|
||||
|
||||
bool loaded = false;
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
|
||||
@@ -47,7 +47,7 @@ typedef void (*NfcLoadingCallback)(void* context, bool state);
|
||||
*
|
||||
* @returns pointer to the allocated instance.
|
||||
*/
|
||||
NfcDevice* nfc_device_alloc();
|
||||
NfcDevice* nfc_device_alloc(void);
|
||||
|
||||
/**
|
||||
* @brief Delete an NfcDevice instance.
|
||||
|
||||
@@ -73,10 +73,10 @@ static void nfc_listener_list_free(NfcListener* instance) {
|
||||
}
|
||||
|
||||
NfcListener* nfc_listener_alloc(Nfc* nfc, NfcProtocol protocol, const NfcDeviceData* data) {
|
||||
furi_assert(nfc);
|
||||
furi_assert(protocol < NfcProtocolNum);
|
||||
furi_assert(data);
|
||||
furi_assert(nfc_listeners_api[protocol]);
|
||||
furi_check(nfc);
|
||||
furi_check(protocol < NfcProtocolNum);
|
||||
furi_check(data);
|
||||
furi_check(nfc_listeners_api[protocol]);
|
||||
|
||||
NfcListener* instance = malloc(sizeof(NfcListener));
|
||||
instance->nfc = nfc;
|
||||
@@ -89,7 +89,7 @@ NfcListener* nfc_listener_alloc(Nfc* nfc, NfcProtocol protocol, const NfcDeviceD
|
||||
}
|
||||
|
||||
void nfc_listener_free(NfcListener* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
nfc_listener_list_free(instance);
|
||||
nfc_device_free(instance->nfc_dev);
|
||||
@@ -116,7 +116,7 @@ NfcCommand nfc_listener_start_callback(NfcEvent event, void* context) {
|
||||
}
|
||||
|
||||
void nfc_listener_start(NfcListener* instance, NfcGenericCallback callback, void* context) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
NfcListenerListElement* tail_element = instance->list.tail;
|
||||
tail_element->listener_api->set_callback(tail_element->listener, callback, context);
|
||||
@@ -124,20 +124,20 @@ void nfc_listener_start(NfcListener* instance, NfcGenericCallback callback, void
|
||||
}
|
||||
|
||||
void nfc_listener_stop(NfcListener* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
nfc_stop(instance->nfc);
|
||||
}
|
||||
|
||||
NfcProtocol nfc_listener_get_protocol(const NfcListener* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
return instance->protocol;
|
||||
}
|
||||
|
||||
const NfcDeviceData* nfc_listener_get_data(const NfcListener* instance, NfcProtocol protocol) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->protocol == protocol);
|
||||
furi_check(instance);
|
||||
furi_check(instance->protocol == protocol);
|
||||
|
||||
NfcListenerListElement* tail_element = instance->list.tail;
|
||||
return tail_element->listener_api->get_data(tail_element->listener);
|
||||
|
||||
@@ -75,8 +75,8 @@ static void nfc_poller_list_free(NfcPoller* instance) {
|
||||
}
|
||||
|
||||
NfcPoller* nfc_poller_alloc(Nfc* nfc, NfcProtocol protocol) {
|
||||
furi_assert(nfc);
|
||||
furi_assert(protocol < NfcProtocolNum);
|
||||
furi_check(nfc);
|
||||
furi_check(protocol < NfcProtocolNum);
|
||||
|
||||
NfcPoller* instance = malloc(sizeof(NfcPoller));
|
||||
instance->session_state = NfcPollerSessionStateIdle;
|
||||
@@ -88,7 +88,7 @@ NfcPoller* nfc_poller_alloc(Nfc* nfc, NfcProtocol protocol) {
|
||||
}
|
||||
|
||||
void nfc_poller_free(NfcPoller* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
nfc_poller_list_free(instance);
|
||||
free(instance);
|
||||
@@ -119,9 +119,9 @@ static NfcCommand nfc_poller_start_callback(NfcEvent event, void* context) {
|
||||
}
|
||||
|
||||
void nfc_poller_start(NfcPoller* instance, NfcGenericCallback callback, void* context) {
|
||||
furi_assert(instance);
|
||||
furi_assert(callback);
|
||||
furi_assert(instance->session_state == NfcPollerSessionStateIdle);
|
||||
furi_check(instance);
|
||||
furi_check(callback);
|
||||
furi_check(instance->session_state == NfcPollerSessionStateIdle);
|
||||
|
||||
NfcPollerListElement* tail_poller = instance->list.tail;
|
||||
tail_poller->poller_api->set_callback(tail_poller->poller, callback, context);
|
||||
@@ -180,9 +180,9 @@ static NfcCommand nfc_poller_start_ex_head_callback(NfcEvent event, void* contex
|
||||
}
|
||||
|
||||
void nfc_poller_start_ex(NfcPoller* instance, NfcGenericCallbackEx callback, void* context) {
|
||||
furi_assert(instance);
|
||||
furi_assert(callback);
|
||||
furi_assert(instance->session_state == NfcPollerSessionStateIdle);
|
||||
furi_check(instance);
|
||||
furi_check(callback);
|
||||
furi_check(instance->session_state == NfcPollerSessionStateIdle);
|
||||
|
||||
instance->callback = callback;
|
||||
instance->context = context;
|
||||
@@ -200,8 +200,8 @@ void nfc_poller_start_ex(NfcPoller* instance, NfcGenericCallbackEx callback, voi
|
||||
}
|
||||
|
||||
void nfc_poller_stop(NfcPoller* instance) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->nfc);
|
||||
furi_check(instance);
|
||||
furi_check(instance->nfc);
|
||||
|
||||
instance->session_state = NfcPollerSessionStateStopRequest;
|
||||
nfc_stop(instance->nfc);
|
||||
@@ -246,8 +246,8 @@ static NfcCommand nfc_poller_detect_head_callback(NfcEvent event, void* context)
|
||||
}
|
||||
|
||||
bool nfc_poller_detect(NfcPoller* instance) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->session_state == NfcPollerSessionStateIdle);
|
||||
furi_check(instance);
|
||||
furi_check(instance->session_state == NfcPollerSessionStateIdle);
|
||||
|
||||
instance->session_state = NfcPollerSessionStateActive;
|
||||
NfcPollerListElement* tail_poller = instance->list.tail;
|
||||
@@ -270,13 +270,13 @@ bool nfc_poller_detect(NfcPoller* instance) {
|
||||
}
|
||||
|
||||
NfcProtocol nfc_poller_get_protocol(const NfcPoller* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
return instance->protocol;
|
||||
}
|
||||
|
||||
const NfcDeviceData* nfc_poller_get_data(const NfcPoller* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
NfcPollerListElement* tail_poller = instance->list.tail;
|
||||
return tail_poller->poller_api->get_data(tail_poller->poller);
|
||||
|
||||
@@ -218,7 +218,7 @@ static int32_t nfc_scanner_worker(void* context) {
|
||||
}
|
||||
|
||||
NfcScanner* nfc_scanner_alloc(Nfc* nfc) {
|
||||
furi_assert(nfc);
|
||||
furi_check(nfc);
|
||||
|
||||
NfcScanner* instance = malloc(sizeof(NfcScanner));
|
||||
instance->nfc = nfc;
|
||||
@@ -227,16 +227,17 @@ NfcScanner* nfc_scanner_alloc(Nfc* nfc) {
|
||||
}
|
||||
|
||||
void nfc_scanner_free(NfcScanner* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
furi_check(instance->state == NfcScannerStateIdle);
|
||||
|
||||
free(instance);
|
||||
}
|
||||
|
||||
void nfc_scanner_start(NfcScanner* instance, NfcScannerCallback callback, void* context) {
|
||||
furi_assert(instance);
|
||||
furi_assert(callback);
|
||||
furi_assert(instance->session_state == NfcScannerSessionStateIdle);
|
||||
furi_assert(instance->scan_worker == NULL);
|
||||
furi_check(instance);
|
||||
furi_check(callback);
|
||||
furi_check(instance->state == NfcScannerStateIdle);
|
||||
furi_check(instance->scan_worker == NULL);
|
||||
|
||||
instance->callback = callback;
|
||||
instance->context = context;
|
||||
@@ -252,8 +253,8 @@ void nfc_scanner_start(NfcScanner* instance, NfcScannerCallback callback, void*
|
||||
}
|
||||
|
||||
void nfc_scanner_stop(NfcScanner* instance) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->scan_worker);
|
||||
furi_check(instance);
|
||||
furi_check(instance->scan_worker);
|
||||
|
||||
instance->session_state = NfcScannerSessionStateStopRequest;
|
||||
furi_thread_join(instance->scan_worker);
|
||||
|
||||
@@ -29,7 +29,7 @@ const NfcDeviceBase nfc_device_felica = {
|
||||
.get_base_data = (NfcDeviceGetBaseData)felica_get_base_data,
|
||||
};
|
||||
|
||||
FelicaData* felica_alloc() {
|
||||
FelicaData* felica_alloc(void) {
|
||||
FelicaData* data = malloc(sizeof(FelicaData));
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ typedef struct {
|
||||
|
||||
extern const NfcDeviceBase nfc_device_felica;
|
||||
|
||||
FelicaData* felica_alloc();
|
||||
FelicaData* felica_alloc(void);
|
||||
|
||||
void felica_free(FelicaData* data);
|
||||
|
||||
|
||||
@@ -28,36 +28,40 @@ const NfcDeviceBase nfc_device_iso14443_3a = {
|
||||
.get_base_data = (NfcDeviceGetBaseData)iso14443_3a_get_base_data,
|
||||
};
|
||||
|
||||
Iso14443_3aData* iso14443_3a_alloc() {
|
||||
Iso14443_3aData* iso14443_3a_alloc(void) {
|
||||
Iso14443_3aData* data = malloc(sizeof(Iso14443_3aData));
|
||||
return data;
|
||||
}
|
||||
|
||||
void iso14443_3a_free(Iso14443_3aData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
free(data);
|
||||
}
|
||||
|
||||
void iso14443_3a_reset(Iso14443_3aData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
memset(data, 0, sizeof(Iso14443_3aData));
|
||||
}
|
||||
|
||||
void iso14443_3a_copy(Iso14443_3aData* data, const Iso14443_3aData* other) {
|
||||
furi_assert(data);
|
||||
furi_assert(other);
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
*data = *other;
|
||||
}
|
||||
|
||||
bool iso14443_3a_verify(Iso14443_3aData* data, const FuriString* device_type) {
|
||||
UNUSED(data);
|
||||
furi_check(device_type);
|
||||
|
||||
return furi_string_equal(device_type, ISO14443_3A_PROTOCOL_NAME_LEGACY);
|
||||
}
|
||||
|
||||
bool iso14443_3a_load(Iso14443_3aData* data, FlipperFormat* ff, uint32_t version) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
|
||||
bool parsed = false;
|
||||
|
||||
@@ -78,7 +82,8 @@ bool iso14443_3a_load(Iso14443_3aData* data, FlipperFormat* ff, uint32_t version
|
||||
}
|
||||
|
||||
bool iso14443_3a_save(const Iso14443_3aData* data, FlipperFormat* ff) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
|
||||
bool saved = false;
|
||||
|
||||
@@ -98,8 +103,8 @@ bool iso14443_3a_save(const Iso14443_3aData* data, FlipperFormat* ff) {
|
||||
}
|
||||
|
||||
bool iso14443_3a_is_equal(const Iso14443_3aData* data, const Iso14443_3aData* other) {
|
||||
furi_assert(data);
|
||||
furi_assert(other);
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
return memcmp(data, other, sizeof(Iso14443_3aData)) == 0;
|
||||
}
|
||||
@@ -111,7 +116,7 @@ const char* iso14443_3a_get_device_name(const Iso14443_3aData* data, NfcDeviceNa
|
||||
}
|
||||
|
||||
const uint8_t* iso14443_3a_get_uid(const Iso14443_3aData* data, size_t* uid_len) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
if(uid_len) {
|
||||
*uid_len = data->uid_len;
|
||||
@@ -121,7 +126,8 @@ const uint8_t* iso14443_3a_get_uid(const Iso14443_3aData* data, size_t* uid_len)
|
||||
}
|
||||
|
||||
bool iso14443_3a_set_uid(Iso14443_3aData* data, const uint8_t* uid, size_t uid_len) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(uid);
|
||||
|
||||
const bool uid_valid = uid_len == ISO14443_3A_UID_4_BYTES ||
|
||||
uid_len == ISO14443_3A_UID_7_BYTES ||
|
||||
@@ -141,7 +147,7 @@ Iso14443_3aData* iso14443_3a_get_base_data(const Iso14443_3aData* data) {
|
||||
}
|
||||
|
||||
uint32_t iso14443_3a_get_cuid(const Iso14443_3aData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
uint32_t cuid = 0;
|
||||
const uint8_t* cuid_start = data->uid;
|
||||
@@ -154,33 +160,33 @@ uint32_t iso14443_3a_get_cuid(const Iso14443_3aData* data) {
|
||||
}
|
||||
|
||||
bool iso14443_3a_supports_iso14443_4(const Iso14443_3aData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
return data->sak & ISO14443A_ATS_BIT;
|
||||
}
|
||||
|
||||
uint8_t iso14443_3a_get_sak(const Iso14443_3aData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
return data->sak;
|
||||
}
|
||||
|
||||
void iso14443_3a_get_atqa(const Iso14443_3aData* data, uint8_t atqa[2]) {
|
||||
furi_assert(data);
|
||||
furi_assert(atqa);
|
||||
furi_check(data);
|
||||
furi_check(atqa);
|
||||
|
||||
memcpy(atqa, data->atqa, sizeof(data->atqa));
|
||||
}
|
||||
|
||||
void iso14443_3a_set_sak(Iso14443_3aData* data, uint8_t sak) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
data->sak = sak;
|
||||
}
|
||||
|
||||
void iso14443_3a_set_atqa(Iso14443_3aData* data, const uint8_t atqa[2]) {
|
||||
furi_assert(data);
|
||||
furi_assert(atqa);
|
||||
furi_check(data);
|
||||
furi_check(atqa);
|
||||
|
||||
memcpy(data->atqa, atqa, sizeof(data->atqa));
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ typedef struct {
|
||||
uint8_t sak;
|
||||
} Iso14443_3aData;
|
||||
|
||||
Iso14443_3aData* iso14443_3a_alloc();
|
||||
Iso14443_3aData* iso14443_3a_alloc(void);
|
||||
|
||||
void iso14443_3a_free(Iso14443_3aData* data);
|
||||
|
||||
|
||||
@@ -55,8 +55,8 @@ static Iso14443_3aError iso14443_3a_poller_standard_frame_exchange(
|
||||
}
|
||||
|
||||
Iso14443_3aError iso14443_3a_poller_check_presence(Iso14443_3aPoller* instance) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->nfc);
|
||||
furi_check(instance);
|
||||
furi_check(instance->nfc);
|
||||
|
||||
NfcError error = NfcErrorNone;
|
||||
Iso14443_3aError ret = Iso14443_3aErrorNone;
|
||||
@@ -80,9 +80,9 @@ Iso14443_3aError iso14443_3a_poller_check_presence(Iso14443_3aPoller* instance)
|
||||
}
|
||||
|
||||
Iso14443_3aError iso14443_3a_poller_halt(Iso14443_3aPoller* instance) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->nfc);
|
||||
furi_assert(instance->tx_buffer);
|
||||
furi_check(instance);
|
||||
furi_check(instance->nfc);
|
||||
furi_check(instance->tx_buffer);
|
||||
|
||||
uint8_t halt_cmd[2] = {0x50, 0x00};
|
||||
bit_buffer_copy_bytes(instance->tx_buffer, halt_cmd, sizeof(halt_cmd));
|
||||
@@ -96,10 +96,10 @@ Iso14443_3aError iso14443_3a_poller_halt(Iso14443_3aPoller* instance) {
|
||||
|
||||
Iso14443_3aError
|
||||
iso14443_3a_poller_activate(Iso14443_3aPoller* instance, Iso14443_3aData* iso14443_3a_data) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->nfc);
|
||||
furi_assert(instance->tx_buffer);
|
||||
furi_assert(instance->rx_buffer);
|
||||
furi_check(instance);
|
||||
furi_check(instance->nfc);
|
||||
furi_check(instance->tx_buffer);
|
||||
furi_check(instance->rx_buffer);
|
||||
|
||||
// Reset Iso14443_3a poller state
|
||||
memset(&instance->col_res, 0, sizeof(instance->col_res));
|
||||
@@ -244,9 +244,9 @@ Iso14443_3aError iso14443_3a_poller_txrx_custom_parity(
|
||||
const BitBuffer* tx_buffer,
|
||||
BitBuffer* rx_buffer,
|
||||
uint32_t fwt) {
|
||||
furi_assert(instance);
|
||||
furi_assert(tx_buffer);
|
||||
furi_assert(rx_buffer);
|
||||
furi_check(instance);
|
||||
furi_check(tx_buffer);
|
||||
furi_check(rx_buffer);
|
||||
|
||||
Iso14443_3aError ret = Iso14443_3aErrorNone;
|
||||
NfcError error =
|
||||
@@ -263,9 +263,9 @@ Iso14443_3aError iso14443_3a_poller_txrx(
|
||||
const BitBuffer* tx_buffer,
|
||||
BitBuffer* rx_buffer,
|
||||
uint32_t fwt) {
|
||||
furi_assert(instance);
|
||||
furi_assert(tx_buffer);
|
||||
furi_assert(rx_buffer);
|
||||
furi_check(instance);
|
||||
furi_check(tx_buffer);
|
||||
furi_check(rx_buffer);
|
||||
|
||||
Iso14443_3aError ret = Iso14443_3aErrorNone;
|
||||
NfcError error = nfc_poller_trx(instance->nfc, tx_buffer, rx_buffer, fwt);
|
||||
@@ -281,9 +281,9 @@ Iso14443_3aError iso14443_3a_poller_send_standard_frame(
|
||||
const BitBuffer* tx_buffer,
|
||||
BitBuffer* rx_buffer,
|
||||
uint32_t fwt) {
|
||||
furi_assert(instance);
|
||||
furi_assert(tx_buffer);
|
||||
furi_assert(rx_buffer);
|
||||
furi_check(instance);
|
||||
furi_check(tx_buffer);
|
||||
furi_check(rx_buffer);
|
||||
|
||||
Iso14443_3aError ret =
|
||||
iso14443_3a_poller_standard_frame_exchange(instance, tx_buffer, rx_buffer, fwt);
|
||||
|
||||
@@ -35,8 +35,8 @@ NfcCommand iso14443_3a_poller_read_callback(NfcGenericEvent event, void* context
|
||||
}
|
||||
|
||||
Iso14443_3aError iso14443_3a_poller_sync_read(Nfc* nfc, Iso14443_3aData* iso14443_3a_data) {
|
||||
furi_assert(nfc);
|
||||
furi_assert(iso14443_3a_data);
|
||||
furi_check(nfc);
|
||||
furi_check(iso14443_3a_data);
|
||||
|
||||
Iso14443_3aPollerContext poller_context = {};
|
||||
poller_context.thread_id = furi_thread_get_current_id();
|
||||
|
||||
@@ -30,24 +30,26 @@ const NfcDeviceBase nfc_device_iso14443_3b = {
|
||||
.get_base_data = (NfcDeviceGetBaseData)iso14443_3b_get_base_data,
|
||||
};
|
||||
|
||||
Iso14443_3bData* iso14443_3b_alloc() {
|
||||
Iso14443_3bData* iso14443_3b_alloc(void) {
|
||||
Iso14443_3bData* data = malloc(sizeof(Iso14443_3bData));
|
||||
return data;
|
||||
}
|
||||
|
||||
void iso14443_3b_free(Iso14443_3bData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
free(data);
|
||||
}
|
||||
|
||||
void iso14443_3b_reset(Iso14443_3bData* data) {
|
||||
furi_check(data);
|
||||
|
||||
memset(data, 0, sizeof(Iso14443_3bData));
|
||||
}
|
||||
|
||||
void iso14443_3b_copy(Iso14443_3bData* data, const Iso14443_3bData* other) {
|
||||
furi_assert(data);
|
||||
furi_assert(other);
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
*data = *other;
|
||||
}
|
||||
@@ -60,7 +62,8 @@ bool iso14443_3b_verify(Iso14443_3bData* data, const FuriString* device_type) {
|
||||
}
|
||||
|
||||
bool iso14443_3b_load(Iso14443_3bData* data, FlipperFormat* ff, uint32_t version) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
|
||||
bool parsed = false;
|
||||
|
||||
@@ -84,7 +87,8 @@ bool iso14443_3b_load(Iso14443_3bData* data, FlipperFormat* ff, uint32_t version
|
||||
}
|
||||
|
||||
bool iso14443_3b_save(const Iso14443_3bData* data, FlipperFormat* ff) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
|
||||
bool saved = false;
|
||||
|
||||
@@ -107,8 +111,8 @@ bool iso14443_3b_save(const Iso14443_3bData* data, FlipperFormat* ff) {
|
||||
}
|
||||
|
||||
bool iso14443_3b_is_equal(const Iso14443_3bData* data, const Iso14443_3bData* other) {
|
||||
furi_assert(data);
|
||||
furi_assert(other);
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
return memcmp(data, other, sizeof(Iso14443_3bData)) == 0;
|
||||
}
|
||||
@@ -121,15 +125,16 @@ const char* iso14443_3b_get_device_name(const Iso14443_3bData* data, NfcDeviceNa
|
||||
}
|
||||
|
||||
const uint8_t* iso14443_3b_get_uid(const Iso14443_3bData* data, size_t* uid_len) {
|
||||
furi_assert(data);
|
||||
furi_assert(uid_len);
|
||||
furi_check(data);
|
||||
furi_check(uid_len);
|
||||
|
||||
*uid_len = ISO14443_3B_UID_SIZE;
|
||||
return data->uid;
|
||||
}
|
||||
|
||||
bool iso14443_3b_set_uid(Iso14443_3bData* data, const uint8_t* uid, size_t uid_len) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(uid);
|
||||
|
||||
const bool uid_valid = uid_len == ISO14443_3B_UID_SIZE;
|
||||
|
||||
@@ -146,13 +151,13 @@ Iso14443_3bData* iso14443_3b_get_base_data(const Iso14443_3bData* data) {
|
||||
}
|
||||
|
||||
bool iso14443_3b_supports_iso14443_4(const Iso14443_3bData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
return data->protocol_info.protocol_type == 0x01;
|
||||
}
|
||||
|
||||
bool iso14443_3b_supports_bit_rate(const Iso14443_3bData* data, Iso14443_3bBitRate bit_rate) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
const uint8_t capability = data->protocol_info.bit_rate_capability;
|
||||
|
||||
@@ -177,7 +182,7 @@ bool iso14443_3b_supports_bit_rate(const Iso14443_3bData* data, Iso14443_3bBitRa
|
||||
}
|
||||
|
||||
bool iso14443_3b_supports_frame_option(const Iso14443_3bData* data, Iso14443_3bFrameOption option) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
switch(option) {
|
||||
case Iso14443_3bFrameOptionNad:
|
||||
@@ -190,15 +195,15 @@ bool iso14443_3b_supports_frame_option(const Iso14443_3bData* data, Iso14443_3bF
|
||||
}
|
||||
|
||||
const uint8_t* iso14443_3b_get_application_data(const Iso14443_3bData* data, size_t* data_size) {
|
||||
furi_assert(data);
|
||||
furi_assert(data_size);
|
||||
furi_check(data);
|
||||
furi_check(data_size);
|
||||
|
||||
*data_size = ISO14443_3B_APP_DATA_SIZE;
|
||||
return data->app_data;
|
||||
}
|
||||
|
||||
uint16_t iso14443_3b_get_frame_size_max(const Iso14443_3bData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
const uint8_t fs_bits = data->protocol_info.max_frame_size;
|
||||
|
||||
@@ -216,7 +221,7 @@ uint16_t iso14443_3b_get_frame_size_max(const Iso14443_3bData* data) {
|
||||
}
|
||||
|
||||
uint32_t iso14443_3b_get_fwt_fc_max(const Iso14443_3bData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
const uint8_t fwi = data->protocol_info.fwi;
|
||||
return fwi < 0x0F ? 4096UL << fwi : ISO14443_3B_FDT_POLL_DEFAULT_FC;
|
||||
|
||||
@@ -40,7 +40,7 @@ typedef struct Iso14443_3bData Iso14443_3bData;
|
||||
|
||||
// Virtual methods
|
||||
|
||||
Iso14443_3bData* iso14443_3b_alloc();
|
||||
Iso14443_3bData* iso14443_3b_alloc(void);
|
||||
|
||||
void iso14443_3b_free(Iso14443_3bData* data);
|
||||
|
||||
|
||||
@@ -64,8 +64,9 @@ static Iso14443_3bError iso14443_3b_poller_frame_exchange(
|
||||
}
|
||||
|
||||
Iso14443_3bError iso14443_3b_poller_activate(Iso14443_3bPoller* instance, Iso14443_3bData* data) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->nfc);
|
||||
furi_check(instance);
|
||||
furi_check(instance->nfc);
|
||||
furi_check(data);
|
||||
|
||||
iso14443_3b_reset(data);
|
||||
|
||||
@@ -155,7 +156,7 @@ Iso14443_3bError iso14443_3b_poller_activate(Iso14443_3bPoller* instance, Iso144
|
||||
}
|
||||
|
||||
Iso14443_3bError iso14443_3b_poller_halt(Iso14443_3bPoller* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
bit_buffer_reset(instance->tx_buffer);
|
||||
bit_buffer_reset(instance->rx_buffer);
|
||||
@@ -188,6 +189,10 @@ Iso14443_3bError iso14443_3b_poller_send_frame(
|
||||
Iso14443_3bPoller* instance,
|
||||
const BitBuffer* tx_buffer,
|
||||
BitBuffer* rx_buffer) {
|
||||
furi_check(instance);
|
||||
furi_check(tx_buffer);
|
||||
furi_check(rx_buffer);
|
||||
|
||||
Iso14443_3bError ret;
|
||||
|
||||
do {
|
||||
|
||||
@@ -35,7 +35,7 @@ const NfcDeviceBase nfc_device_iso14443_4a = {
|
||||
.get_base_data = (NfcDeviceGetBaseData)iso14443_4a_get_base_data,
|
||||
};
|
||||
|
||||
Iso14443_4aData* iso14443_4a_alloc() {
|
||||
Iso14443_4aData* iso14443_4a_alloc(void) {
|
||||
Iso14443_4aData* data = malloc(sizeof(Iso14443_4aData));
|
||||
|
||||
data->iso14443_3a_data = iso14443_3a_alloc();
|
||||
@@ -45,7 +45,7 @@ Iso14443_4aData* iso14443_4a_alloc() {
|
||||
}
|
||||
|
||||
void iso14443_4a_free(Iso14443_4aData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
simple_array_free(data->ats_data.t1_tk);
|
||||
iso14443_3a_free(data->iso14443_3a_data);
|
||||
@@ -54,7 +54,7 @@ void iso14443_4a_free(Iso14443_4aData* data) {
|
||||
}
|
||||
|
||||
void iso14443_4a_reset(Iso14443_4aData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
iso14443_3a_reset(data->iso14443_3a_data);
|
||||
|
||||
@@ -68,8 +68,8 @@ void iso14443_4a_reset(Iso14443_4aData* data) {
|
||||
}
|
||||
|
||||
void iso14443_4a_copy(Iso14443_4aData* data, const Iso14443_4aData* other) {
|
||||
furi_assert(data);
|
||||
furi_assert(other);
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
iso14443_3a_copy(data->iso14443_3a_data, other->iso14443_3a_data);
|
||||
|
||||
@@ -91,7 +91,8 @@ bool iso14443_4a_verify(Iso14443_4aData* data, const FuriString* device_type) {
|
||||
}
|
||||
|
||||
bool iso14443_4a_load(Iso14443_4aData* data, FlipperFormat* ff, uint32_t version) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
|
||||
bool parsed = false;
|
||||
|
||||
@@ -145,7 +146,8 @@ bool iso14443_4a_load(Iso14443_4aData* data, FlipperFormat* ff, uint32_t version
|
||||
}
|
||||
|
||||
bool iso14443_4a_save(const Iso14443_4aData* data, FlipperFormat* ff) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
|
||||
bool saved = false;
|
||||
|
||||
@@ -186,6 +188,9 @@ bool iso14443_4a_save(const Iso14443_4aData* data, FlipperFormat* ff) {
|
||||
}
|
||||
|
||||
bool iso14443_4a_is_equal(const Iso14443_4aData* data, const Iso14443_4aData* other) {
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
return iso14443_3a_is_equal(data->iso14443_3a_data, other->iso14443_3a_data);
|
||||
}
|
||||
|
||||
@@ -196,23 +201,26 @@ const char* iso14443_4a_get_device_name(const Iso14443_4aData* data, NfcDeviceNa
|
||||
}
|
||||
|
||||
const uint8_t* iso14443_4a_get_uid(const Iso14443_4aData* data, size_t* uid_len) {
|
||||
furi_check(data);
|
||||
furi_check(uid_len);
|
||||
|
||||
return iso14443_3a_get_uid(data->iso14443_3a_data, uid_len);
|
||||
}
|
||||
|
||||
bool iso14443_4a_set_uid(Iso14443_4aData* data, const uint8_t* uid, size_t uid_len) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
return iso14443_3a_set_uid(data->iso14443_3a_data, uid, uid_len);
|
||||
}
|
||||
|
||||
Iso14443_3aData* iso14443_4a_get_base_data(const Iso14443_4aData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
return data->iso14443_3a_data;
|
||||
}
|
||||
|
||||
uint16_t iso14443_4a_get_frame_size_max(const Iso14443_4aData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
const uint8_t fsci = data->ats_data.t0 & 0x0F;
|
||||
|
||||
@@ -230,7 +238,7 @@ uint16_t iso14443_4a_get_frame_size_max(const Iso14443_4aData* data) {
|
||||
}
|
||||
|
||||
uint32_t iso14443_4a_get_fwt_fc_max(const Iso14443_4aData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
uint32_t fwt_fc_max = ISO14443_4A_FDT_DEFAULT_FC;
|
||||
|
||||
@@ -248,8 +256,8 @@ uint32_t iso14443_4a_get_fwt_fc_max(const Iso14443_4aData* data) {
|
||||
}
|
||||
|
||||
const uint8_t* iso14443_4a_get_historical_bytes(const Iso14443_4aData* data, uint32_t* count) {
|
||||
furi_assert(data);
|
||||
furi_assert(count);
|
||||
furi_check(data);
|
||||
furi_check(count);
|
||||
|
||||
*count = simple_array_get_count(data->ats_data.t1_tk);
|
||||
const uint8_t* hist_bytes = NULL;
|
||||
@@ -261,7 +269,7 @@ const uint8_t* iso14443_4a_get_historical_bytes(const Iso14443_4aData* data, uin
|
||||
}
|
||||
|
||||
bool iso14443_4a_supports_bit_rate(const Iso14443_4aData* data, Iso14443_4aBitRate bit_rate) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
if(!(data->ats_data.t0 & ISO14443_4A_ATS_T0_TA1))
|
||||
return bit_rate == Iso14443_4aBitRateBoth106Kbit;
|
||||
@@ -289,7 +297,7 @@ bool iso14443_4a_supports_bit_rate(const Iso14443_4aData* data, Iso14443_4aBitRa
|
||||
}
|
||||
|
||||
bool iso14443_4a_supports_frame_option(const Iso14443_4aData* data, Iso14443_4aFrameOption option) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
const Iso14443_4aAtsData* ats_data = &data->ats_data;
|
||||
if(!(ats_data->t0 & ISO14443_4A_ATS_T0_TC1)) return false;
|
||||
|
||||
@@ -46,7 +46,7 @@ typedef struct {
|
||||
|
||||
// Virtual methods
|
||||
|
||||
Iso14443_4aData* iso14443_4a_alloc();
|
||||
Iso14443_4aData* iso14443_4a_alloc(void);
|
||||
|
||||
void iso14443_4a_free(Iso14443_4aData* data);
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#define ISO14443_4A_FSDI_256 (0x8U)
|
||||
|
||||
Iso14443_4aError iso14443_4a_poller_halt(Iso14443_4aPoller* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
iso14443_3a_poller_halt(instance->iso14443_3a_poller);
|
||||
instance->poller_state = Iso14443_4aPollerStateIdle;
|
||||
@@ -19,7 +19,8 @@ Iso14443_4aError iso14443_4a_poller_halt(Iso14443_4aPoller* instance) {
|
||||
|
||||
Iso14443_4aError
|
||||
iso14443_4a_poller_read_ats(Iso14443_4aPoller* instance, Iso14443_4aAtsData* data) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
furi_check(data);
|
||||
|
||||
bit_buffer_reset(instance->tx_buffer);
|
||||
bit_buffer_append_byte(instance->tx_buffer, ISO14443_4A_CMD_READ_ATS);
|
||||
@@ -54,7 +55,9 @@ Iso14443_4aError iso14443_4a_poller_send_block(
|
||||
Iso14443_4aPoller* instance,
|
||||
const BitBuffer* tx_buffer,
|
||||
BitBuffer* rx_buffer) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
furi_check(tx_buffer);
|
||||
furi_check(rx_buffer);
|
||||
|
||||
bit_buffer_reset(instance->tx_buffer);
|
||||
iso14443_4_layer_encode_block(instance->iso14443_4_layer, tx_buffer, instance->tx_buffer);
|
||||
|
||||
@@ -22,7 +22,7 @@ const NfcDeviceBase nfc_device_iso14443_4b = {
|
||||
.get_base_data = (NfcDeviceGetBaseData)iso14443_4b_get_base_data,
|
||||
};
|
||||
|
||||
Iso14443_4bData* iso14443_4b_alloc() {
|
||||
Iso14443_4bData* iso14443_4b_alloc(void) {
|
||||
Iso14443_4bData* data = malloc(sizeof(Iso14443_4bData));
|
||||
|
||||
data->iso14443_3b_data = iso14443_3b_alloc();
|
||||
@@ -30,21 +30,21 @@ Iso14443_4bData* iso14443_4b_alloc() {
|
||||
}
|
||||
|
||||
void iso14443_4b_free(Iso14443_4bData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
iso14443_3b_free(data->iso14443_3b_data);
|
||||
free(data);
|
||||
}
|
||||
|
||||
void iso14443_4b_reset(Iso14443_4bData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
iso14443_3b_reset(data->iso14443_3b_data);
|
||||
}
|
||||
|
||||
void iso14443_4b_copy(Iso14443_4bData* data, const Iso14443_4bData* other) {
|
||||
furi_assert(data);
|
||||
furi_assert(other);
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
iso14443_3b_copy(data->iso14443_3b_data, other->iso14443_3b_data);
|
||||
}
|
||||
@@ -58,16 +58,21 @@ bool iso14443_4b_verify(Iso14443_4bData* data, const FuriString* device_type) {
|
||||
}
|
||||
|
||||
bool iso14443_4b_load(Iso14443_4bData* data, FlipperFormat* ff, uint32_t version) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
return iso14443_3b_load(data->iso14443_3b_data, ff, version);
|
||||
}
|
||||
|
||||
bool iso14443_4b_save(const Iso14443_4bData* data, FlipperFormat* ff) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
return iso14443_3b_save(data->iso14443_3b_data, ff);
|
||||
}
|
||||
|
||||
bool iso14443_4b_is_equal(const Iso14443_4bData* data, const Iso14443_4bData* other) {
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
return iso14443_3b_is_equal(data->iso14443_3b_data, other->iso14443_3b_data);
|
||||
}
|
||||
|
||||
@@ -78,17 +83,21 @@ const char* iso14443_4b_get_device_name(const Iso14443_4bData* data, NfcDeviceNa
|
||||
}
|
||||
|
||||
const uint8_t* iso14443_4b_get_uid(const Iso14443_4bData* data, size_t* uid_len) {
|
||||
furi_check(data);
|
||||
furi_check(uid_len);
|
||||
|
||||
return iso14443_3b_get_uid(data->iso14443_3b_data, uid_len);
|
||||
}
|
||||
|
||||
bool iso14443_4b_set_uid(Iso14443_4bData* data, const uint8_t* uid, size_t uid_len) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(uid);
|
||||
|
||||
return iso14443_3b_set_uid(data->iso14443_3b_data, uid, uid_len);
|
||||
}
|
||||
|
||||
Iso14443_3bData* iso14443_4b_get_base_data(const Iso14443_4bData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
return data->iso14443_3b_data;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ typedef struct Iso14443_4bData Iso14443_4bData;
|
||||
|
||||
// Virtual methods
|
||||
|
||||
Iso14443_4bData* iso14443_4b_alloc();
|
||||
Iso14443_4bData* iso14443_4b_alloc(void);
|
||||
|
||||
void iso14443_4b_free(Iso14443_4bData* data);
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#define TAG "Iso14443_4bPoller"
|
||||
|
||||
Iso14443_4bError iso14443_4b_poller_halt(Iso14443_4bPoller* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
iso14443_3b_poller_halt(instance->iso14443_3b_poller);
|
||||
instance->poller_state = Iso14443_4bPollerStateIdle;
|
||||
@@ -19,7 +19,9 @@ Iso14443_4bError iso14443_4b_poller_send_block(
|
||||
Iso14443_4bPoller* instance,
|
||||
const BitBuffer* tx_buffer,
|
||||
BitBuffer* rx_buffer) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
furi_check(tx_buffer);
|
||||
furi_check(rx_buffer);
|
||||
|
||||
bit_buffer_reset(instance->tx_buffer);
|
||||
iso14443_4_layer_encode_block(instance->iso14443_4_layer, tx_buffer, instance->tx_buffer);
|
||||
|
||||
@@ -36,7 +36,7 @@ const NfcDeviceBase nfc_device_iso15693_3 = {
|
||||
.get_base_data = (NfcDeviceGetBaseData)iso15693_3_get_base_data,
|
||||
};
|
||||
|
||||
Iso15693_3Data* iso15693_3_alloc() {
|
||||
Iso15693_3Data* iso15693_3_alloc(void) {
|
||||
Iso15693_3Data* data = malloc(sizeof(Iso15693_3Data));
|
||||
|
||||
data->block_data = simple_array_alloc(&simple_array_config_uint8_t);
|
||||
@@ -46,7 +46,7 @@ Iso15693_3Data* iso15693_3_alloc() {
|
||||
}
|
||||
|
||||
void iso15693_3_free(Iso15693_3Data* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
simple_array_free(data->block_data);
|
||||
simple_array_free(data->block_security);
|
||||
@@ -54,7 +54,7 @@ void iso15693_3_free(Iso15693_3Data* data) {
|
||||
}
|
||||
|
||||
void iso15693_3_reset(Iso15693_3Data* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
memset(data->uid, 0, ISO15693_3_UID_SIZE);
|
||||
memset(&data->system_info, 0, sizeof(Iso15693_3SystemInfo));
|
||||
@@ -65,8 +65,8 @@ void iso15693_3_reset(Iso15693_3Data* data) {
|
||||
}
|
||||
|
||||
void iso15693_3_copy(Iso15693_3Data* data, const Iso15693_3Data* other) {
|
||||
furi_assert(data);
|
||||
furi_assert(other);
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
memcpy(data->uid, other->uid, ISO15693_3_UID_SIZE);
|
||||
|
||||
@@ -79,6 +79,8 @@ void iso15693_3_copy(Iso15693_3Data* data, const Iso15693_3Data* other) {
|
||||
|
||||
bool iso15693_3_verify(Iso15693_3Data* data, const FuriString* device_type) {
|
||||
UNUSED(data);
|
||||
furi_check(device_type);
|
||||
|
||||
return furi_string_equal(device_type, ISO15693_3_PROTOCOL_NAME_LEGACY);
|
||||
}
|
||||
|
||||
@@ -136,7 +138,8 @@ static inline bool iso15693_3_load_security(Iso15693_3Data* data, FlipperFormat*
|
||||
}
|
||||
|
||||
bool iso15693_3_load(Iso15693_3Data* data, FlipperFormat* ff, uint32_t version) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
UNUSED(version);
|
||||
|
||||
bool loaded = false;
|
||||
@@ -207,7 +210,8 @@ bool iso15693_3_load(Iso15693_3Data* data, FlipperFormat* ff, uint32_t version)
|
||||
}
|
||||
|
||||
bool iso15693_3_save(const Iso15693_3Data* data, FlipperFormat* ff) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
|
||||
bool saved = false;
|
||||
|
||||
@@ -280,12 +284,15 @@ bool iso15693_3_save(const Iso15693_3Data* data, FlipperFormat* ff) {
|
||||
}
|
||||
|
||||
bool iso15693_3_is_equal(const Iso15693_3Data* data, const Iso15693_3Data* other) {
|
||||
furi_assert(data);
|
||||
furi_assert(other);
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
return memcmp(data->uid, other->uid, ISO15693_3_UID_SIZE) == 0 &&
|
||||
memcmp(&data->settings, &other->settings, sizeof(Iso15693_3Settings)) == 0 &&
|
||||
memcmp(&data->system_info, &other->system_info, sizeof(Iso15693_3SystemInfo)) == 0 &&
|
||||
memcmp( //-V1103
|
||||
&data->system_info,
|
||||
&other->system_info,
|
||||
sizeof(Iso15693_3SystemInfo)) == 0 &&
|
||||
simple_array_is_equal(data->block_data, other->block_data) &&
|
||||
simple_array_is_equal(data->block_security, other->block_security);
|
||||
}
|
||||
@@ -298,15 +305,15 @@ const char* iso15693_3_get_device_name(const Iso15693_3Data* data, NfcDeviceName
|
||||
}
|
||||
|
||||
const uint8_t* iso15693_3_get_uid(const Iso15693_3Data* data, size_t* uid_len) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
if(uid_len) *uid_len = ISO15693_3_UID_SIZE;
|
||||
return data->uid;
|
||||
}
|
||||
|
||||
bool iso15693_3_set_uid(Iso15693_3Data* data, const uint8_t* uid, size_t uid_len) {
|
||||
furi_assert(data);
|
||||
furi_assert(uid);
|
||||
furi_check(data);
|
||||
furi_check(uid);
|
||||
|
||||
bool uid_valid = uid_len == ISO15693_3_UID_SIZE;
|
||||
|
||||
@@ -325,33 +332,33 @@ Iso15693_3Data* iso15693_3_get_base_data(const Iso15693_3Data* data) {
|
||||
}
|
||||
|
||||
bool iso15693_3_is_block_locked(const Iso15693_3Data* data, uint8_t block_index) {
|
||||
furi_assert(data);
|
||||
furi_assert(block_index < data->system_info.block_count);
|
||||
furi_check(data);
|
||||
furi_check(block_index < data->system_info.block_count);
|
||||
|
||||
return *(const uint8_t*)simple_array_cget(data->block_security, block_index);
|
||||
}
|
||||
|
||||
uint8_t iso15693_3_get_manufacturer_id(const Iso15693_3Data* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
return data->uid[1];
|
||||
}
|
||||
|
||||
uint16_t iso15693_3_get_block_count(const Iso15693_3Data* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
return data->system_info.block_count;
|
||||
}
|
||||
|
||||
uint8_t iso15693_3_get_block_size(const Iso15693_3Data* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
return data->system_info.block_size;
|
||||
}
|
||||
|
||||
const uint8_t* iso15693_3_get_block_data(const Iso15693_3Data* data, uint8_t block_index) {
|
||||
furi_assert(data);
|
||||
furi_assert(data->system_info.block_count > block_index);
|
||||
furi_check(data);
|
||||
furi_check(data->system_info.block_count > block_index);
|
||||
|
||||
return (const uint8_t*)simple_array_cget(
|
||||
data->block_data, block_index * data->system_info.block_size);
|
||||
|
||||
@@ -122,7 +122,7 @@ typedef struct {
|
||||
SimpleArray* block_security;
|
||||
} Iso15693_3Data;
|
||||
|
||||
Iso15693_3Data* iso15693_3_alloc();
|
||||
Iso15693_3Data* iso15693_3_alloc(void);
|
||||
|
||||
void iso15693_3_free(Iso15693_3Data* data);
|
||||
|
||||
|
||||
@@ -38,6 +38,8 @@ Iso15693_3Error iso15693_3_poller_send_frame(
|
||||
BitBuffer* rx_buffer,
|
||||
uint32_t fwt) {
|
||||
furi_assert(instance);
|
||||
furi_check(tx_buffer);
|
||||
furi_check(rx_buffer);
|
||||
|
||||
Iso15693_3Error ret = Iso15693_3ErrorNone;
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#define BEBIT(x, n) FURI_BIT(x, (n) ^ 24)
|
||||
|
||||
Crypto1* crypto1_alloc() {
|
||||
Crypto1* crypto1_alloc(void) {
|
||||
Crypto1* instance = malloc(sizeof(Crypto1));
|
||||
|
||||
return instance;
|
||||
|
||||
@@ -11,7 +11,7 @@ typedef struct {
|
||||
uint32_t even;
|
||||
} Crypto1;
|
||||
|
||||
Crypto1* crypto1_alloc();
|
||||
Crypto1* crypto1_alloc(void);
|
||||
|
||||
void crypto1_free(Crypto1* instance);
|
||||
|
||||
|
||||
@@ -56,28 +56,28 @@ const NfcDeviceBase nfc_device_mf_classic = {
|
||||
.get_base_data = (NfcDeviceGetBaseData)mf_classic_get_base_data,
|
||||
};
|
||||
|
||||
MfClassicData* mf_classic_alloc() {
|
||||
MfClassicData* mf_classic_alloc(void) {
|
||||
MfClassicData* data = malloc(sizeof(MfClassicData));
|
||||
data->iso14443_3a_data = iso14443_3a_alloc();
|
||||
return data;
|
||||
}
|
||||
|
||||
void mf_classic_free(MfClassicData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
iso14443_3a_free(data->iso14443_3a_data);
|
||||
free(data);
|
||||
}
|
||||
|
||||
void mf_classic_reset(MfClassicData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
iso14443_3a_reset(data->iso14443_3a_data);
|
||||
}
|
||||
|
||||
void mf_classic_copy(MfClassicData* data, const MfClassicData* other) {
|
||||
furi_assert(data);
|
||||
furi_assert(other);
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
iso14443_3a_copy(data->iso14443_3a_data, other->iso14443_3a_data);
|
||||
for(size_t i = 0; i < COUNT_OF(data->block); i++) {
|
||||
@@ -92,7 +92,9 @@ void mf_classic_copy(MfClassicData* data, const MfClassicData* other) {
|
||||
}
|
||||
|
||||
bool mf_classic_verify(MfClassicData* data, const FuriString* device_type) {
|
||||
furi_check(device_type);
|
||||
UNUSED(data);
|
||||
|
||||
return furi_string_equal_str(device_type, "Mifare Classic");
|
||||
}
|
||||
|
||||
@@ -146,7 +148,8 @@ static void mf_classic_parse_block(FuriString* block_str, MfClassicData* data, u
|
||||
}
|
||||
|
||||
bool mf_classic_load(MfClassicData* data, FlipperFormat* ff, uint32_t version) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
|
||||
FuriString* temp_str = furi_string_alloc();
|
||||
bool parsed = false;
|
||||
@@ -255,7 +258,8 @@ static void
|
||||
}
|
||||
|
||||
bool mf_classic_save(const MfClassicData* data, FlipperFormat* ff) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
|
||||
FuriString* temp_str = furi_string_alloc();
|
||||
bool saved = false;
|
||||
@@ -297,6 +301,9 @@ bool mf_classic_save(const MfClassicData* data, FlipperFormat* ff) {
|
||||
}
|
||||
|
||||
bool mf_classic_is_equal(const MfClassicData* data, const MfClassicData* other) {
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
bool is_equal = false;
|
||||
bool data_array_is_equal = true;
|
||||
|
||||
@@ -329,8 +336,8 @@ bool mf_classic_is_equal(const MfClassicData* data, const MfClassicData* other)
|
||||
}
|
||||
|
||||
const char* mf_classic_get_device_name(const MfClassicData* data, NfcDeviceNameType name_type) {
|
||||
furi_assert(data);
|
||||
furi_assert(data->type < MfClassicTypeNum);
|
||||
furi_check(data);
|
||||
furi_check(data->type < MfClassicTypeNum);
|
||||
|
||||
if(name_type == NfcDeviceNameTypeFull) {
|
||||
return mf_classic_features[data->type].full_name;
|
||||
@@ -340,13 +347,13 @@ const char* mf_classic_get_device_name(const MfClassicData* data, NfcDeviceNameT
|
||||
}
|
||||
|
||||
const uint8_t* mf_classic_get_uid(const MfClassicData* data, size_t* uid_len) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
return iso14443_3a_get_uid(data->iso14443_3a_data, uid_len);
|
||||
}
|
||||
|
||||
bool mf_classic_set_uid(MfClassicData* data, const uint8_t* uid, size_t uid_len) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
bool uid_valid = iso14443_3a_set_uid(data->iso14443_3a_data, uid, uid_len);
|
||||
|
||||
@@ -370,16 +377,18 @@ bool mf_classic_set_uid(MfClassicData* data, const uint8_t* uid, size_t uid_len)
|
||||
}
|
||||
|
||||
Iso14443_3aData* mf_classic_get_base_data(const MfClassicData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
return data->iso14443_3a_data;
|
||||
}
|
||||
|
||||
uint8_t mf_classic_get_total_sectors_num(MfClassicType type) {
|
||||
furi_check(type < MfClassicTypeNum);
|
||||
return mf_classic_features[type].sectors_total;
|
||||
}
|
||||
|
||||
uint16_t mf_classic_get_total_block_num(MfClassicType type) {
|
||||
furi_check(type < MfClassicTypeNum);
|
||||
return mf_classic_features[type].blocks_total;
|
||||
}
|
||||
|
||||
@@ -411,7 +420,7 @@ uint8_t mf_classic_get_sector_trailer_num_by_block(uint8_t block) {
|
||||
|
||||
MfClassicSectorTrailer*
|
||||
mf_classic_get_sector_trailer_by_sector(const MfClassicData* data, uint8_t sector_num) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
uint8_t sec_tr_block = mf_classic_get_sector_trailer_num_by_sector(sector_num);
|
||||
MfClassicSectorTrailer* sec_trailer = (MfClassicSectorTrailer*)&data->block[sec_tr_block];
|
||||
@@ -436,7 +445,8 @@ uint8_t mf_classic_get_sector_by_block(uint8_t block) {
|
||||
}
|
||||
|
||||
bool mf_classic_block_to_value(const MfClassicBlock* block, int32_t* value, uint8_t* addr) {
|
||||
furi_assert(block);
|
||||
furi_check(block);
|
||||
furi_check(value);
|
||||
|
||||
uint32_t v = *(uint32_t*)&block->data[0];
|
||||
uint32_t v_inv = *(uint32_t*)&block->data[sizeof(uint32_t)];
|
||||
@@ -445,9 +455,7 @@ bool mf_classic_block_to_value(const MfClassicBlock* block, int32_t* value, uint
|
||||
bool val_checks =
|
||||
((v == v1) && (v == ~v_inv) && (block->data[12] == (~block->data[13] & 0xFF)) &&
|
||||
(block->data[14] == (~block->data[15] & 0xFF)) && (block->data[12] == block->data[14]));
|
||||
if(value) {
|
||||
*value = (int32_t)v;
|
||||
}
|
||||
*value = (int32_t)v;
|
||||
if(addr) {
|
||||
*addr = block->data[12];
|
||||
}
|
||||
@@ -455,7 +463,7 @@ bool mf_classic_block_to_value(const MfClassicBlock* block, int32_t* value, uint
|
||||
}
|
||||
|
||||
void mf_classic_value_to_block(int32_t value, uint8_t addr, MfClassicBlock* block) {
|
||||
furi_assert(block);
|
||||
furi_check(block);
|
||||
|
||||
uint32_t v_inv = ~((uint32_t)value);
|
||||
|
||||
@@ -473,7 +481,7 @@ bool mf_classic_is_key_found(
|
||||
const MfClassicData* data,
|
||||
uint8_t sector_num,
|
||||
MfClassicKeyType key_type) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
bool key_found = false;
|
||||
if(key_type == MfClassicKeyTypeA) {
|
||||
@@ -490,7 +498,7 @@ void mf_classic_set_key_found(
|
||||
uint8_t sector_num,
|
||||
MfClassicKeyType key_type,
|
||||
uint64_t key) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
uint8_t key_arr[6] = {};
|
||||
MfClassicSectorTrailer* sec_trailer =
|
||||
@@ -509,7 +517,7 @@ void mf_classic_set_key_not_found(
|
||||
MfClassicData* data,
|
||||
uint8_t sector_num,
|
||||
MfClassicKeyType key_type) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
if(key_type == MfClassicKeyTypeA) {
|
||||
FURI_BIT_CLEAR(data->key_a_mask, sector_num);
|
||||
@@ -519,13 +527,14 @@ void mf_classic_set_key_not_found(
|
||||
}
|
||||
|
||||
bool mf_classic_is_block_read(const MfClassicData* data, uint8_t block_num) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
return (FURI_BIT(data->block_read_mask[block_num / 32], block_num % 32) == 1);
|
||||
}
|
||||
|
||||
void mf_classic_set_block_read(MfClassicData* data, uint8_t block_num, MfClassicBlock* block_data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(block_data);
|
||||
|
||||
if(mf_classic_is_sector_trailer(block_num)) {
|
||||
memcpy(&data->block[block_num].data[6], &block_data->data[6], 4);
|
||||
@@ -536,7 +545,7 @@ void mf_classic_set_block_read(MfClassicData* data, uint8_t block_num, MfClassic
|
||||
}
|
||||
|
||||
uint8_t mf_classic_get_first_block_num_of_sector(uint8_t sector) {
|
||||
furi_assert(sector < 40);
|
||||
furi_check(sector < 40);
|
||||
|
||||
uint8_t block = 0;
|
||||
if(sector < 32) {
|
||||
@@ -549,7 +558,8 @@ uint8_t mf_classic_get_first_block_num_of_sector(uint8_t sector) {
|
||||
}
|
||||
|
||||
uint8_t mf_classic_get_blocks_num_in_sector(uint8_t sector) {
|
||||
furi_assert(sector < 40);
|
||||
furi_check(sector < 40);
|
||||
|
||||
return sector < 32 ? 4 : 16;
|
||||
}
|
||||
|
||||
@@ -557,9 +567,9 @@ void mf_classic_get_read_sectors_and_keys(
|
||||
const MfClassicData* data,
|
||||
uint8_t* sectors_read,
|
||||
uint8_t* keys_found) {
|
||||
furi_assert(data);
|
||||
furi_assert(sectors_read);
|
||||
furi_assert(keys_found);
|
||||
furi_check(data);
|
||||
furi_check(sectors_read);
|
||||
furi_check(keys_found);
|
||||
|
||||
*sectors_read = 0;
|
||||
*keys_found = 0;
|
||||
@@ -585,7 +595,7 @@ void mf_classic_get_read_sectors_and_keys(
|
||||
}
|
||||
|
||||
bool mf_classic_is_card_read(const MfClassicData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
uint8_t sectors_total = mf_classic_get_total_sectors_num(data->type);
|
||||
uint8_t sectors_read = 0;
|
||||
@@ -597,7 +607,7 @@ bool mf_classic_is_card_read(const MfClassicData* data) {
|
||||
}
|
||||
|
||||
bool mf_classic_is_sector_read(const MfClassicData* data, uint8_t sector_num) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
bool sector_read = false;
|
||||
do {
|
||||
@@ -662,7 +672,7 @@ bool mf_classic_is_allowed_access_data_block(
|
||||
uint8_t block_num,
|
||||
MfClassicKeyType key_type,
|
||||
MfClassicAction action) {
|
||||
furi_assert(sec_tr);
|
||||
furi_check(sec_tr);
|
||||
|
||||
uint8_t* access_bits_arr = sec_tr->access_bits.data;
|
||||
|
||||
@@ -732,7 +742,7 @@ bool mf_classic_is_allowed_access(
|
||||
uint8_t block_num,
|
||||
MfClassicKeyType key_type,
|
||||
MfClassicAction action) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
bool access_allowed = false;
|
||||
if(mf_classic_is_sector_trailer(block_num)) {
|
||||
@@ -749,7 +759,7 @@ bool mf_classic_is_allowed_access(
|
||||
}
|
||||
|
||||
bool mf_classic_is_value_block(MfClassicSectorTrailer* sec_tr, uint8_t block_num) {
|
||||
furi_assert(sec_tr);
|
||||
furi_check(sec_tr);
|
||||
|
||||
// Check if key A can write, if it can, it's transport configuration, not data block
|
||||
return !mf_classic_is_allowed_access_data_block(
|
||||
|
||||
@@ -143,7 +143,7 @@ typedef struct {
|
||||
|
||||
extern const NfcDeviceBase nfc_device_mf_classic;
|
||||
|
||||
MfClassicData* mf_classic_alloc();
|
||||
MfClassicData* mf_classic_alloc(void);
|
||||
|
||||
void mf_classic_free(MfClassicData* data);
|
||||
|
||||
|
||||
@@ -90,6 +90,8 @@ MfClassicError mf_classic_poller_get_nt(
|
||||
uint8_t block_num,
|
||||
MfClassicKeyType key_type,
|
||||
MfClassicNt* nt) {
|
||||
furi_check(instance);
|
||||
|
||||
return mf_classic_poller_get_nt_common(instance, block_num, key_type, nt, false);
|
||||
}
|
||||
|
||||
@@ -98,6 +100,8 @@ MfClassicError mf_classic_poller_get_nt_nested(
|
||||
uint8_t block_num,
|
||||
MfClassicKeyType key_type,
|
||||
MfClassicNt* nt) {
|
||||
furi_check(instance);
|
||||
|
||||
return mf_classic_poller_get_nt_common(instance, block_num, key_type, nt, true);
|
||||
}
|
||||
|
||||
@@ -179,6 +183,8 @@ MfClassicError mf_classic_poller_auth(
|
||||
MfClassicKey* key,
|
||||
MfClassicKeyType key_type,
|
||||
MfClassicAuthContext* data) {
|
||||
furi_check(instance);
|
||||
furi_check(key);
|
||||
return mf_classic_poller_auth_common(instance, block_num, key, key_type, data, false);
|
||||
}
|
||||
|
||||
@@ -188,10 +194,14 @@ MfClassicError mf_classic_poller_auth_nested(
|
||||
MfClassicKey* key,
|
||||
MfClassicKeyType key_type,
|
||||
MfClassicAuthContext* data) {
|
||||
furi_check(instance);
|
||||
furi_check(key);
|
||||
return mf_classic_poller_auth_common(instance, block_num, key, key_type, data, true);
|
||||
}
|
||||
|
||||
MfClassicError mf_classic_poller_halt(MfClassicPoller* instance) {
|
||||
furi_check(instance);
|
||||
|
||||
MfClassicError ret = MfClassicErrorNone;
|
||||
Iso14443_3aError error = Iso14443_3aErrorNone;
|
||||
|
||||
@@ -223,6 +233,9 @@ MfClassicError mf_classic_poller_read_block(
|
||||
MfClassicPoller* instance,
|
||||
uint8_t block_num,
|
||||
MfClassicBlock* data) {
|
||||
furi_check(instance);
|
||||
furi_check(data);
|
||||
|
||||
MfClassicError ret = MfClassicErrorNone;
|
||||
Iso14443_3aError error = Iso14443_3aErrorNone;
|
||||
|
||||
@@ -269,6 +282,9 @@ MfClassicError mf_classic_poller_write_block(
|
||||
MfClassicPoller* instance,
|
||||
uint8_t block_num,
|
||||
MfClassicBlock* data) {
|
||||
furi_check(instance);
|
||||
furi_check(data);
|
||||
|
||||
MfClassicError ret = MfClassicErrorNone;
|
||||
Iso14443_3aError error = Iso14443_3aErrorNone;
|
||||
|
||||
@@ -341,6 +357,8 @@ MfClassicError mf_classic_poller_value_cmd(
|
||||
uint8_t block_num,
|
||||
MfClassicValueCommand cmd,
|
||||
int32_t data) {
|
||||
furi_check(instance);
|
||||
|
||||
MfClassicError ret = MfClassicErrorNone;
|
||||
Iso14443_3aError error = Iso14443_3aErrorNone;
|
||||
|
||||
@@ -407,6 +425,8 @@ MfClassicError mf_classic_poller_value_cmd(
|
||||
}
|
||||
|
||||
MfClassicError mf_classic_poller_value_transfer(MfClassicPoller* instance, uint8_t block_num) {
|
||||
furi_check(instance);
|
||||
|
||||
MfClassicError ret = MfClassicErrorNone;
|
||||
Iso14443_3aError error = Iso14443_3aErrorNone;
|
||||
|
||||
|
||||
@@ -225,7 +225,7 @@ MfClassicError mf_classic_poller_sync_collect_nt(
|
||||
uint8_t block_num,
|
||||
MfClassicKeyType key_type,
|
||||
MfClassicNt* nt) {
|
||||
furi_assert(nfc);
|
||||
furi_check(nfc);
|
||||
|
||||
MfClassicPollerContext poller_context = {
|
||||
.cmd_type = MfClassicPollerCmdTypeCollectNt,
|
||||
@@ -250,8 +250,8 @@ MfClassicError mf_classic_poller_sync_auth(
|
||||
MfClassicKey* key,
|
||||
MfClassicKeyType key_type,
|
||||
MfClassicAuthContext* data) {
|
||||
furi_assert(nfc);
|
||||
furi_assert(key);
|
||||
furi_check(nfc);
|
||||
furi_check(key);
|
||||
|
||||
MfClassicPollerContext poller_context = {
|
||||
.cmd_type = MfClassicPollerCmdTypeAuth,
|
||||
@@ -277,9 +277,9 @@ MfClassicError mf_classic_poller_sync_read_block(
|
||||
MfClassicKey* key,
|
||||
MfClassicKeyType key_type,
|
||||
MfClassicBlock* data) {
|
||||
furi_assert(nfc);
|
||||
furi_assert(key);
|
||||
furi_assert(data);
|
||||
furi_check(nfc);
|
||||
furi_check(key);
|
||||
furi_check(data);
|
||||
|
||||
MfClassicPollerContext poller_context = {
|
||||
.cmd_type = MfClassicPollerCmdTypeReadBlock,
|
||||
@@ -303,9 +303,9 @@ MfClassicError mf_classic_poller_sync_write_block(
|
||||
MfClassicKey* key,
|
||||
MfClassicKeyType key_type,
|
||||
MfClassicBlock* data) {
|
||||
furi_assert(nfc);
|
||||
furi_assert(key);
|
||||
furi_assert(data);
|
||||
furi_check(nfc);
|
||||
furi_check(key);
|
||||
furi_check(data);
|
||||
|
||||
MfClassicPollerContext poller_context = {
|
||||
.cmd_type = MfClassicPollerCmdTypeWriteBlock,
|
||||
@@ -326,9 +326,9 @@ MfClassicError mf_classic_poller_sync_read_value(
|
||||
MfClassicKey* key,
|
||||
MfClassicKeyType key_type,
|
||||
int32_t* value) {
|
||||
furi_assert(nfc);
|
||||
furi_assert(key);
|
||||
furi_assert(value);
|
||||
furi_check(nfc);
|
||||
furi_check(key);
|
||||
furi_check(value);
|
||||
|
||||
MfClassicPollerContext poller_context = {
|
||||
.cmd_type = MfClassicPollerCmdTypeReadValue,
|
||||
@@ -353,9 +353,9 @@ MfClassicError mf_classic_poller_sync_change_value(
|
||||
MfClassicKeyType key_type,
|
||||
int32_t data,
|
||||
int32_t* new_value) {
|
||||
furi_assert(nfc);
|
||||
furi_assert(key);
|
||||
furi_assert(new_value);
|
||||
furi_check(nfc);
|
||||
furi_check(key);
|
||||
furi_check(new_value);
|
||||
|
||||
MfClassicValueCommand command = MfClassicValueCommandRestore;
|
||||
int32_t command_data = 0;
|
||||
@@ -459,9 +459,9 @@ NfcCommand mf_classic_poller_read_callback(NfcGenericEvent event, void* context)
|
||||
|
||||
MfClassicError
|
||||
mf_classic_poller_sync_read(Nfc* nfc, const MfClassicDeviceKeys* keys, MfClassicData* data) {
|
||||
furi_assert(nfc);
|
||||
furi_assert(keys);
|
||||
furi_assert(data);
|
||||
furi_check(nfc);
|
||||
furi_check(keys);
|
||||
furi_check(data);
|
||||
|
||||
MfClassicError error = MfClassicErrorNone;
|
||||
MfClassicPollerContext poller_context = {};
|
||||
@@ -493,8 +493,8 @@ MfClassicError
|
||||
}
|
||||
|
||||
MfClassicError mf_classic_poller_sync_detect_type(Nfc* nfc, MfClassicType* type) {
|
||||
furi_assert(nfc);
|
||||
furi_assert(type);
|
||||
furi_check(nfc);
|
||||
furi_check(type);
|
||||
|
||||
MfClassicError error = MfClassicErrorNone;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ const NfcDeviceBase nfc_device_mf_desfire = {
|
||||
.get_base_data = (NfcDeviceGetBaseData)mf_desfire_get_base_data,
|
||||
};
|
||||
|
||||
MfDesfireData* mf_desfire_alloc() {
|
||||
MfDesfireData* mf_desfire_alloc(void) {
|
||||
MfDesfireData* data = malloc(sizeof(MfDesfireData));
|
||||
data->iso14443_4a_data = iso14443_4a_alloc();
|
||||
data->master_key_versions = simple_array_alloc(&mf_desfire_key_version_array_config);
|
||||
@@ -31,7 +31,7 @@ MfDesfireData* mf_desfire_alloc() {
|
||||
}
|
||||
|
||||
void mf_desfire_free(MfDesfireData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
mf_desfire_reset(data);
|
||||
simple_array_free(data->applications);
|
||||
@@ -42,7 +42,7 @@ void mf_desfire_free(MfDesfireData* data) {
|
||||
}
|
||||
|
||||
void mf_desfire_reset(MfDesfireData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
iso14443_4a_reset(data->iso14443_4a_data);
|
||||
|
||||
@@ -55,8 +55,8 @@ void mf_desfire_reset(MfDesfireData* data) {
|
||||
}
|
||||
|
||||
void mf_desfire_copy(MfDesfireData* data, const MfDesfireData* other) {
|
||||
furi_assert(data);
|
||||
furi_assert(other);
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
mf_desfire_reset(data);
|
||||
|
||||
@@ -77,7 +77,8 @@ bool mf_desfire_verify(MfDesfireData* data, const FuriString* device_type) {
|
||||
}
|
||||
|
||||
bool mf_desfire_load(MfDesfireData* data, FlipperFormat* ff, uint32_t version) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
|
||||
FuriString* prefix = furi_string_alloc();
|
||||
|
||||
@@ -143,7 +144,8 @@ bool mf_desfire_load(MfDesfireData* data, FlipperFormat* ff, uint32_t version) {
|
||||
}
|
||||
|
||||
bool mf_desfire_save(const MfDesfireData* data, FlipperFormat* ff) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
|
||||
FuriString* prefix = furi_string_alloc();
|
||||
|
||||
@@ -208,12 +210,15 @@ bool mf_desfire_save(const MfDesfireData* data, FlipperFormat* ff) {
|
||||
}
|
||||
|
||||
bool mf_desfire_is_equal(const MfDesfireData* data, const MfDesfireData* other) {
|
||||
furi_assert(data);
|
||||
furi_assert(other);
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
return iso14443_4a_is_equal(data->iso14443_4a_data, other->iso14443_4a_data) &&
|
||||
memcmp(&data->version, &other->version, sizeof(MfDesfireVersion)) == 0 &&
|
||||
memcmp(&data->free_memory, &other->free_memory, sizeof(MfDesfireFreeMemory)) == 0 &&
|
||||
memcmp( //-V1103
|
||||
&data->free_memory,
|
||||
&other->free_memory,
|
||||
sizeof(MfDesfireFreeMemory)) == 0 &&
|
||||
memcmp(
|
||||
&data->master_key_settings,
|
||||
&other->master_key_settings,
|
||||
@@ -230,25 +235,29 @@ const char* mf_desfire_get_device_name(const MfDesfireData* data, NfcDeviceNameT
|
||||
}
|
||||
|
||||
const uint8_t* mf_desfire_get_uid(const MfDesfireData* data, size_t* uid_len) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(uid_len);
|
||||
|
||||
return iso14443_4a_get_uid(data->iso14443_4a_data, uid_len);
|
||||
}
|
||||
|
||||
bool mf_desfire_set_uid(MfDesfireData* data, const uint8_t* uid, size_t uid_len) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
return iso14443_4a_set_uid(data->iso14443_4a_data, uid, uid_len);
|
||||
}
|
||||
|
||||
Iso14443_4aData* mf_desfire_get_base_data(const MfDesfireData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
return data->iso14443_4a_data;
|
||||
}
|
||||
|
||||
const MfDesfireApplication*
|
||||
mf_desfire_get_application(const MfDesfireData* data, const MfDesfireApplicationId* app_id) {
|
||||
furi_check(data);
|
||||
furi_check(app_id);
|
||||
|
||||
MfDesfireApplication* app = NULL;
|
||||
|
||||
for(uint32_t i = 0; i < simple_array_get_count(data->application_ids); ++i) {
|
||||
@@ -263,6 +272,9 @@ const MfDesfireApplication*
|
||||
|
||||
const MfDesfireFileSettings*
|
||||
mf_desfire_get_file_settings(const MfDesfireApplication* data, const MfDesfireFileId* file_id) {
|
||||
furi_check(data);
|
||||
furi_check(file_id);
|
||||
|
||||
MfDesfireFileSettings* file_settings = NULL;
|
||||
|
||||
for(uint32_t i = 0; i < simple_array_get_count(data->file_ids); ++i) {
|
||||
@@ -277,6 +289,9 @@ const MfDesfireFileSettings*
|
||||
|
||||
const MfDesfireFileData*
|
||||
mf_desfire_get_file_data(const MfDesfireApplication* data, const MfDesfireFileId* file_id) {
|
||||
furi_check(data);
|
||||
furi_check(file_id);
|
||||
|
||||
MfDesfireFileData* file_data = NULL;
|
||||
|
||||
for(uint32_t i = 0; i < simple_array_get_count(data->file_ids); ++i) {
|
||||
|
||||
@@ -152,7 +152,7 @@ extern const NfcDeviceBase nfc_device_mf_desfire;
|
||||
|
||||
// Virtual methods
|
||||
|
||||
MfDesfireData* mf_desfire_alloc();
|
||||
MfDesfireData* mf_desfire_alloc(void);
|
||||
|
||||
void mf_desfire_free(MfDesfireData* data);
|
||||
|
||||
|
||||
@@ -23,12 +23,12 @@ MfDesfireError mf_desfire_send_chunks(
|
||||
MfDesfirePoller* instance,
|
||||
const BitBuffer* tx_buffer,
|
||||
BitBuffer* rx_buffer) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->iso14443_4a_poller);
|
||||
furi_assert(instance->tx_buffer);
|
||||
furi_assert(instance->rx_buffer);
|
||||
furi_assert(tx_buffer);
|
||||
furi_assert(rx_buffer);
|
||||
furi_check(instance);
|
||||
furi_check(instance->iso14443_4a_poller);
|
||||
furi_check(instance->tx_buffer);
|
||||
furi_check(instance->rx_buffer);
|
||||
furi_check(tx_buffer);
|
||||
furi_check(rx_buffer);
|
||||
|
||||
MfDesfireError error = MfDesfireErrorNone;
|
||||
|
||||
@@ -75,7 +75,7 @@ MfDesfireError mf_desfire_send_chunks(
|
||||
}
|
||||
|
||||
MfDesfireError mf_desfire_poller_read_version(MfDesfirePoller* instance, MfDesfireVersion* data) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
bit_buffer_reset(instance->input_buffer);
|
||||
bit_buffer_append_byte(instance->input_buffer, MF_DESFIRE_CMD_GET_VERSION);
|
||||
@@ -97,7 +97,7 @@ MfDesfireError mf_desfire_poller_read_version(MfDesfirePoller* instance, MfDesfi
|
||||
|
||||
MfDesfireError
|
||||
mf_desfire_poller_read_free_memory(MfDesfirePoller* instance, MfDesfireFreeMemory* data) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
bit_buffer_reset(instance->input_buffer);
|
||||
bit_buffer_append_byte(instance->input_buffer, MF_DESFIRE_CMD_GET_FREE_MEMORY);
|
||||
@@ -119,7 +119,7 @@ MfDesfireError
|
||||
|
||||
MfDesfireError
|
||||
mf_desfire_poller_read_key_settings(MfDesfirePoller* instance, MfDesfireKeySettings* data) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
bit_buffer_reset(instance->input_buffer);
|
||||
bit_buffer_append_byte(instance->input_buffer, MF_DESFIRE_CMD_GET_KEY_SETTINGS);
|
||||
@@ -143,8 +143,8 @@ MfDesfireError mf_desfire_poller_read_key_versions(
|
||||
MfDesfirePoller* instance,
|
||||
SimpleArray* data,
|
||||
uint32_t count) {
|
||||
furi_assert(instance);
|
||||
furi_assert(count > 0);
|
||||
furi_check(instance);
|
||||
furi_check(count > 0);
|
||||
|
||||
simple_array_init(data, count);
|
||||
|
||||
@@ -171,7 +171,8 @@ MfDesfireError mf_desfire_poller_read_key_versions(
|
||||
|
||||
MfDesfireError
|
||||
mf_desfire_poller_read_application_ids(MfDesfirePoller* instance, SimpleArray* data) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
furi_check(data);
|
||||
|
||||
bit_buffer_reset(instance->input_buffer);
|
||||
bit_buffer_append_byte(instance->input_buffer, MF_DESFIRE_CMD_GET_APPLICATION_IDS);
|
||||
@@ -204,7 +205,7 @@ MfDesfireError
|
||||
MfDesfireError mf_desfire_poller_select_application(
|
||||
MfDesfirePoller* instance,
|
||||
const MfDesfireApplicationId* id) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
bit_buffer_reset(instance->input_buffer);
|
||||
bit_buffer_append_byte(instance->input_buffer, MF_DESFIRE_CMD_SELECT_APPLICATION);
|
||||
@@ -218,7 +219,8 @@ MfDesfireError mf_desfire_poller_select_application(
|
||||
}
|
||||
|
||||
MfDesfireError mf_desfire_poller_read_file_ids(MfDesfirePoller* instance, SimpleArray* data) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
furi_check(data);
|
||||
|
||||
bit_buffer_reset(instance->input_buffer);
|
||||
bit_buffer_append_byte(instance->input_buffer, MF_DESFIRE_CMD_GET_FILE_IDS);
|
||||
@@ -251,7 +253,8 @@ MfDesfireError mf_desfire_poller_read_file_settings(
|
||||
MfDesfirePoller* instance,
|
||||
MfDesfireFileId id,
|
||||
MfDesfireFileSettings* data) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
furi_check(data);
|
||||
|
||||
bit_buffer_reset(instance->input_buffer);
|
||||
bit_buffer_append_byte(instance->input_buffer, MF_DESFIRE_CMD_GET_FILE_SETTINGS);
|
||||
@@ -276,7 +279,9 @@ MfDesfireError mf_desfire_poller_read_file_settings_multi(
|
||||
MfDesfirePoller* instance,
|
||||
const SimpleArray* file_ids,
|
||||
SimpleArray* data) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
furi_check(file_ids);
|
||||
furi_check(data);
|
||||
|
||||
MfDesfireError error = MfDesfireErrorNone;
|
||||
|
||||
@@ -300,7 +305,8 @@ MfDesfireError mf_desfire_poller_read_file_data(
|
||||
uint32_t offset,
|
||||
size_t size,
|
||||
MfDesfireFileData* data) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
furi_check(data);
|
||||
|
||||
bit_buffer_reset(instance->input_buffer);
|
||||
bit_buffer_append_byte(instance->input_buffer, MF_DESFIRE_CMD_READ_DATA);
|
||||
@@ -327,7 +333,8 @@ MfDesfireError mf_desfire_poller_read_file_value(
|
||||
MfDesfirePoller* instance,
|
||||
MfDesfireFileId id,
|
||||
MfDesfireFileData* data) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
furi_check(data);
|
||||
|
||||
bit_buffer_reset(instance->input_buffer);
|
||||
bit_buffer_append_byte(instance->input_buffer, MF_DESFIRE_CMD_GET_VALUE);
|
||||
@@ -354,7 +361,8 @@ MfDesfireError mf_desfire_poller_read_file_records(
|
||||
uint32_t offset,
|
||||
size_t size,
|
||||
MfDesfireFileData* data) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
furi_check(data);
|
||||
|
||||
bit_buffer_reset(instance->input_buffer);
|
||||
bit_buffer_append_byte(instance->input_buffer, MF_DESFIRE_CMD_READ_RECORDS);
|
||||
@@ -382,8 +390,11 @@ MfDesfireError mf_desfire_poller_read_file_data_multi(
|
||||
const SimpleArray* file_ids,
|
||||
const SimpleArray* file_settings,
|
||||
SimpleArray* data) {
|
||||
furi_assert(instance);
|
||||
furi_assert(simple_array_get_count(file_ids) == simple_array_get_count(file_settings));
|
||||
furi_check(instance);
|
||||
furi_check(file_ids);
|
||||
furi_check(file_settings);
|
||||
furi_check(data);
|
||||
furi_check(simple_array_get_count(file_ids) == simple_array_get_count(file_settings));
|
||||
|
||||
MfDesfireError error = MfDesfireErrorNone;
|
||||
|
||||
@@ -419,8 +430,8 @@ MfDesfireError mf_desfire_poller_read_file_data_multi(
|
||||
|
||||
MfDesfireError
|
||||
mf_desfire_poller_read_application(MfDesfirePoller* instance, MfDesfireApplication* data) {
|
||||
furi_assert(instance);
|
||||
furi_assert(data);
|
||||
furi_check(instance);
|
||||
furi_check(data);
|
||||
|
||||
MfDesfireError error;
|
||||
|
||||
@@ -452,7 +463,8 @@ MfDesfireError mf_desfire_poller_read_applications(
|
||||
MfDesfirePoller* instance,
|
||||
const SimpleArray* app_ids,
|
||||
SimpleArray* data) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
furi_check(data);
|
||||
|
||||
MfDesfireError error = MfDesfireErrorNone;
|
||||
|
||||
|
||||
@@ -168,28 +168,28 @@ const NfcDeviceBase nfc_device_mf_ultralight = {
|
||||
.get_base_data = (NfcDeviceGetBaseData)mf_ultralight_get_base_data,
|
||||
};
|
||||
|
||||
MfUltralightData* mf_ultralight_alloc() {
|
||||
MfUltralightData* mf_ultralight_alloc(void) {
|
||||
MfUltralightData* data = malloc(sizeof(MfUltralightData));
|
||||
data->iso14443_3a_data = iso14443_3a_alloc();
|
||||
return data;
|
||||
}
|
||||
|
||||
void mf_ultralight_free(MfUltralightData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
iso14443_3a_free(data->iso14443_3a_data);
|
||||
free(data);
|
||||
}
|
||||
|
||||
void mf_ultralight_reset(MfUltralightData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
iso14443_3a_reset(data->iso14443_3a_data);
|
||||
}
|
||||
|
||||
void mf_ultralight_copy(MfUltralightData* data, const MfUltralightData* other) {
|
||||
furi_assert(data);
|
||||
furi_assert(other);
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
iso14443_3a_copy(data->iso14443_3a_data, other->iso14443_3a_data);
|
||||
for(size_t i = 0; i < COUNT_OF(data->counter); i++) {
|
||||
@@ -222,7 +222,8 @@ static const char*
|
||||
}
|
||||
|
||||
bool mf_ultralight_verify(MfUltralightData* data, const FuriString* device_type) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(device_type);
|
||||
|
||||
bool verified = false;
|
||||
|
||||
@@ -239,7 +240,8 @@ bool mf_ultralight_verify(MfUltralightData* data, const FuriString* device_type)
|
||||
}
|
||||
|
||||
bool mf_ultralight_load(MfUltralightData* data, FlipperFormat* ff, uint32_t version) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
|
||||
FuriString* temp_str = furi_string_alloc();
|
||||
bool parsed = false;
|
||||
@@ -338,7 +340,8 @@ bool mf_ultralight_load(MfUltralightData* data, FlipperFormat* ff, uint32_t vers
|
||||
}
|
||||
|
||||
bool mf_ultralight_save(const MfUltralightData* data, FlipperFormat* ff) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
|
||||
FuriString* temp_str = furi_string_alloc();
|
||||
bool saved = false;
|
||||
@@ -419,6 +422,9 @@ bool mf_ultralight_save(const MfUltralightData* data, FlipperFormat* ff) {
|
||||
}
|
||||
|
||||
bool mf_ultralight_is_equal(const MfUltralightData* data, const MfUltralightData* other) {
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
bool is_equal = false;
|
||||
bool data_array_is_equal = true;
|
||||
|
||||
@@ -467,20 +473,20 @@ bool mf_ultralight_is_equal(const MfUltralightData* data, const MfUltralightData
|
||||
|
||||
const char*
|
||||
mf_ultralight_get_device_name(const MfUltralightData* data, NfcDeviceNameType name_type) {
|
||||
furi_assert(data);
|
||||
furi_assert(data->type < MfUltralightTypeNum);
|
||||
furi_check(data);
|
||||
furi_check(data->type < MfUltralightTypeNum);
|
||||
|
||||
return mf_ultralight_get_device_name_by_type(data->type, name_type);
|
||||
}
|
||||
|
||||
const uint8_t* mf_ultralight_get_uid(const MfUltralightData* data, size_t* uid_len) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
return iso14443_3a_get_uid(data->iso14443_3a_data, uid_len);
|
||||
}
|
||||
|
||||
bool mf_ultralight_set_uid(MfUltralightData* data, const uint8_t* uid, size_t uid_len) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
bool uid_valid = iso14443_3a_set_uid(data->iso14443_3a_data, uid, uid_len);
|
||||
|
||||
@@ -498,13 +504,13 @@ bool mf_ultralight_set_uid(MfUltralightData* data, const uint8_t* uid, size_t ui
|
||||
}
|
||||
|
||||
Iso14443_3aData* mf_ultralight_get_base_data(const MfUltralightData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
return data->iso14443_3a_data;
|
||||
}
|
||||
|
||||
MfUltralightType mf_ultralight_get_type_by_version(MfUltralightVersion* version) {
|
||||
furi_assert(version);
|
||||
furi_check(version);
|
||||
|
||||
MfUltralightType type = MfUltralightTypeUnknown;
|
||||
|
||||
@@ -538,15 +544,19 @@ MfUltralightType mf_ultralight_get_type_by_version(MfUltralightVersion* version)
|
||||
}
|
||||
|
||||
uint16_t mf_ultralight_get_pages_total(MfUltralightType type) {
|
||||
furi_check(type < MfUltralightTypeNum);
|
||||
|
||||
return mf_ultralight_features[type].total_pages;
|
||||
}
|
||||
|
||||
uint32_t mf_ultralight_get_feature_support_set(MfUltralightType type) {
|
||||
furi_check(type < MfUltralightTypeNum);
|
||||
|
||||
return mf_ultralight_features[type].feature_set;
|
||||
}
|
||||
|
||||
bool mf_ultralight_detect_protocol(const Iso14443_3aData* iso14443_3a_data) {
|
||||
furi_assert(iso14443_3a_data);
|
||||
furi_check(iso14443_3a_data);
|
||||
|
||||
bool mfu_detected = (iso14443_3a_data->atqa[0] == 0x44) &&
|
||||
(iso14443_3a_data->atqa[1] == 0x00) && (iso14443_3a_data->sak == 0x00);
|
||||
@@ -555,10 +565,14 @@ bool mf_ultralight_detect_protocol(const Iso14443_3aData* iso14443_3a_data) {
|
||||
}
|
||||
|
||||
uint16_t mf_ultralight_get_config_page_num(MfUltralightType type) {
|
||||
furi_check(type < MfUltralightTypeNum);
|
||||
|
||||
return mf_ultralight_features[type].config_page;
|
||||
}
|
||||
|
||||
uint8_t mf_ultralight_get_pwd_page_num(MfUltralightType type) {
|
||||
furi_check(type < MfUltralightTypeNum);
|
||||
|
||||
uint8_t config_page = mf_ultralight_features[type].config_page;
|
||||
return (config_page != 0) ? config_page + 2 : 0;
|
||||
}
|
||||
@@ -574,8 +588,8 @@ bool mf_ultralight_support_feature(const uint32_t feature_set, const uint32_t fe
|
||||
}
|
||||
|
||||
bool mf_ultralight_get_config_page(const MfUltralightData* data, MfUltralightConfigPages** config) {
|
||||
furi_assert(data);
|
||||
furi_assert(config);
|
||||
furi_check(data);
|
||||
furi_check(config);
|
||||
|
||||
bool config_pages_found = false;
|
||||
|
||||
@@ -589,7 +603,7 @@ bool mf_ultralight_get_config_page(const MfUltralightData* data, MfUltralightCon
|
||||
}
|
||||
|
||||
bool mf_ultralight_is_all_data_read(const MfUltralightData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
bool all_read = false;
|
||||
if(data->pages_read == data->pages_total ||
|
||||
@@ -616,7 +630,7 @@ bool mf_ultralight_is_all_data_read(const MfUltralightData* data) {
|
||||
}
|
||||
|
||||
bool mf_ultralight_is_counter_configured(const MfUltralightData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
MfUltralightConfigPages* config = NULL;
|
||||
bool configured = false;
|
||||
|
||||
@@ -177,7 +177,7 @@ typedef struct {
|
||||
|
||||
extern const NfcDeviceBase nfc_device_mf_ultralight;
|
||||
|
||||
MfUltralightData* mf_ultralight_alloc();
|
||||
MfUltralightData* mf_ultralight_alloc(void);
|
||||
|
||||
void mf_ultralight_free(MfUltralightData* data);
|
||||
|
||||
|
||||
@@ -33,6 +33,9 @@ MfUltralightError mf_ultralight_process_error(Iso14443_3aError error) {
|
||||
MfUltralightError mf_ultralight_poller_auth_pwd(
|
||||
MfUltralightPoller* instance,
|
||||
MfUltralightPollerAuthContext* data) {
|
||||
furi_check(instance);
|
||||
furi_check(data);
|
||||
|
||||
uint8_t auth_cmd[5] = {MF_ULTRALIGHT_CMD_PWD_AUTH}; //-V1009
|
||||
memccpy(&auth_cmd[1], data->password.data, 0, MF_ULTRALIGHT_AUTH_PASSWORD_SIZE);
|
||||
bit_buffer_copy_bytes(instance->tx_buffer, auth_cmd, sizeof(auth_cmd));
|
||||
@@ -60,6 +63,8 @@ MfUltralightError mf_ultralight_poller_auth_pwd(
|
||||
}
|
||||
|
||||
MfUltralightError mf_ultralight_poller_authenticate(MfUltralightPoller* instance) {
|
||||
furi_check(instance);
|
||||
|
||||
uint8_t auth_cmd[2] = {MF_ULTRALIGHT_CMD_AUTH, 0x00};
|
||||
bit_buffer_copy_bytes(instance->tx_buffer, auth_cmd, sizeof(auth_cmd));
|
||||
|
||||
@@ -91,6 +96,9 @@ MfUltralightError mf_ultralight_poller_read_page_from_sector(
|
||||
uint8_t sector,
|
||||
uint8_t tag,
|
||||
MfUltralightPageReadCommandData* data) {
|
||||
furi_check(instance);
|
||||
furi_check(data);
|
||||
|
||||
MfUltralightError ret = MfUltralightErrorNone;
|
||||
Iso14443_3aError error = Iso14443_3aErrorNone;
|
||||
|
||||
@@ -132,6 +140,9 @@ MfUltralightError mf_ultralight_poller_read_page(
|
||||
MfUltralightPoller* instance,
|
||||
uint8_t start_page,
|
||||
MfUltralightPageReadCommandData* data) {
|
||||
furi_check(instance);
|
||||
furi_check(data);
|
||||
|
||||
MfUltralightError ret = MfUltralightErrorNone;
|
||||
Iso14443_3aError error = Iso14443_3aErrorNone;
|
||||
|
||||
@@ -162,6 +173,9 @@ MfUltralightError mf_ultralight_poller_write_page(
|
||||
MfUltralightPoller* instance,
|
||||
uint8_t page,
|
||||
const MfUltralightPage* data) {
|
||||
furi_check(instance);
|
||||
furi_check(data);
|
||||
|
||||
MfUltralightError ret = MfUltralightErrorNone;
|
||||
Iso14443_3aError error = Iso14443_3aErrorNone;
|
||||
|
||||
@@ -193,6 +207,9 @@ MfUltralightError mf_ultralight_poller_write_page(
|
||||
|
||||
MfUltralightError
|
||||
mf_ultralight_poller_read_version(MfUltralightPoller* instance, MfUltralightVersion* data) {
|
||||
furi_check(instance);
|
||||
furi_check(data);
|
||||
|
||||
MfUltralightError ret = MfUltralightErrorNone;
|
||||
Iso14443_3aError error = Iso14443_3aErrorNone;
|
||||
|
||||
@@ -222,6 +239,9 @@ MfUltralightError
|
||||
|
||||
MfUltralightError
|
||||
mf_ultralight_poller_read_signature(MfUltralightPoller* instance, MfUltralightSignature* data) {
|
||||
furi_check(instance);
|
||||
furi_check(data);
|
||||
|
||||
MfUltralightError ret = MfUltralightErrorNone;
|
||||
Iso14443_3aError error = Iso14443_3aErrorNone;
|
||||
|
||||
@@ -251,6 +271,9 @@ MfUltralightError mf_ultralight_poller_read_counter(
|
||||
MfUltralightPoller* instance,
|
||||
uint8_t counter_num,
|
||||
MfUltralightCounter* data) {
|
||||
furi_check(instance);
|
||||
furi_check(data);
|
||||
|
||||
MfUltralightError ret = MfUltralightErrorNone;
|
||||
Iso14443_3aError error = Iso14443_3aErrorNone;
|
||||
|
||||
@@ -280,6 +303,9 @@ MfUltralightError mf_ultralight_poller_read_tearing_flag(
|
||||
MfUltralightPoller* instance,
|
||||
uint8_t tearing_falg_num,
|
||||
MfUltralightTearingFlag* data) {
|
||||
furi_check(instance);
|
||||
furi_check(data);
|
||||
|
||||
MfUltralightError ret = MfUltralightErrorNone;
|
||||
Iso14443_3aError error = Iso14443_3aErrorNone;
|
||||
|
||||
|
||||
@@ -119,8 +119,8 @@ static MfUltralightError
|
||||
|
||||
MfUltralightError
|
||||
mf_ultralight_poller_sync_read_page(Nfc* nfc, uint16_t page, MfUltralightPage* data) {
|
||||
furi_assert(nfc);
|
||||
furi_assert(data);
|
||||
furi_check(nfc);
|
||||
furi_check(data);
|
||||
|
||||
MfUltralightPollerContext poller_context = {
|
||||
.cmd_type = MfUltralightPollerCmdTypeReadPage,
|
||||
@@ -138,8 +138,8 @@ MfUltralightError
|
||||
|
||||
MfUltralightError
|
||||
mf_ultralight_poller_sync_write_page(Nfc* nfc, uint16_t page, MfUltralightPage* data) {
|
||||
furi_assert(nfc);
|
||||
furi_assert(data);
|
||||
furi_check(nfc);
|
||||
furi_check(data);
|
||||
|
||||
MfUltralightPollerContext poller_context = {
|
||||
.cmd_type = MfUltralightPollerCmdTypeWritePage,
|
||||
@@ -156,8 +156,8 @@ MfUltralightError
|
||||
}
|
||||
|
||||
MfUltralightError mf_ultralight_poller_sync_read_version(Nfc* nfc, MfUltralightVersion* data) {
|
||||
furi_assert(nfc);
|
||||
furi_assert(data);
|
||||
furi_check(nfc);
|
||||
furi_check(data);
|
||||
|
||||
MfUltralightPollerContext poller_context = {
|
||||
.cmd_type = MfUltralightPollerCmdTypeReadVersion,
|
||||
@@ -173,8 +173,8 @@ MfUltralightError mf_ultralight_poller_sync_read_version(Nfc* nfc, MfUltralightV
|
||||
}
|
||||
|
||||
MfUltralightError mf_ultralight_poller_sync_read_signature(Nfc* nfc, MfUltralightSignature* data) {
|
||||
furi_assert(nfc);
|
||||
furi_assert(data);
|
||||
furi_check(nfc);
|
||||
furi_check(data);
|
||||
|
||||
MfUltralightPollerContext poller_context = {
|
||||
.cmd_type = MfUltralightPollerCmdTypeReadSignature,
|
||||
@@ -193,8 +193,8 @@ MfUltralightError mf_ultralight_poller_sync_read_counter(
|
||||
Nfc* nfc,
|
||||
uint8_t counter_num,
|
||||
MfUltralightCounter* data) {
|
||||
furi_assert(nfc);
|
||||
furi_assert(data);
|
||||
furi_check(nfc);
|
||||
furi_check(data);
|
||||
|
||||
MfUltralightPollerContext poller_context = {
|
||||
.cmd_type = MfUltralightPollerCmdTypeReadCounter,
|
||||
@@ -214,8 +214,8 @@ MfUltralightError mf_ultralight_poller_sync_read_tearing_flag(
|
||||
Nfc* nfc,
|
||||
uint8_t flag_num,
|
||||
MfUltralightTearingFlag* data) {
|
||||
furi_assert(nfc);
|
||||
furi_assert(data);
|
||||
furi_check(nfc);
|
||||
furi_check(data);
|
||||
|
||||
MfUltralightPollerContext poller_context = {
|
||||
.cmd_type = MfUltralightPollerCmdTypeReadTearingFlag,
|
||||
@@ -261,8 +261,8 @@ static NfcCommand mf_ultralight_poller_read_callback(NfcGenericEvent event, void
|
||||
}
|
||||
|
||||
MfUltralightError mf_ultralight_poller_sync_read_card(Nfc* nfc, MfUltralightData* data) {
|
||||
furi_assert(nfc);
|
||||
furi_assert(data);
|
||||
furi_check(nfc);
|
||||
furi_check(data);
|
||||
|
||||
MfUltralightPollerContext poller_context = {};
|
||||
poller_context.thread_id = furi_thread_get_current_id();
|
||||
|
||||
@@ -20,7 +20,7 @@ extern "C" {
|
||||
*
|
||||
* @returns pointer to the allocated instance.
|
||||
*/
|
||||
typedef NfcDeviceData* (*NfcDeviceAlloc)();
|
||||
typedef NfcDeviceData* (*NfcDeviceAlloc)(void);
|
||||
|
||||
/**
|
||||
* @brief Delete the protocol-specific NFC device data instance.
|
||||
|
||||
@@ -150,14 +150,14 @@ static const NfcProtocolTreeNode nfc_protocol_nodes[NfcProtocolNum] = {
|
||||
};
|
||||
|
||||
NfcProtocol nfc_protocol_get_parent(NfcProtocol protocol) {
|
||||
furi_assert(protocol < NfcProtocolNum);
|
||||
furi_check(protocol < NfcProtocolNum);
|
||||
|
||||
return nfc_protocol_nodes[protocol].parent_protocol;
|
||||
}
|
||||
|
||||
bool nfc_protocol_has_parent(NfcProtocol protocol, NfcProtocol parent_protocol) {
|
||||
furi_assert(protocol < NfcProtocolNum);
|
||||
furi_assert(parent_protocol < NfcProtocolNum);
|
||||
furi_check(protocol < NfcProtocolNum);
|
||||
furi_check(parent_protocol < NfcProtocolNum);
|
||||
|
||||
bool parent_found = false;
|
||||
const NfcProtocolTreeNode* iter = &nfc_protocol_nodes[protocol];
|
||||
|
||||
@@ -89,7 +89,7 @@ static void slix_password_set_defaults(SlixPassword* passwords) {
|
||||
}
|
||||
}
|
||||
|
||||
SlixData* slix_alloc() {
|
||||
SlixData* slix_alloc(void) {
|
||||
SlixData* data = malloc(sizeof(SlixData));
|
||||
|
||||
data->iso15693_3_data = iso15693_3_alloc();
|
||||
@@ -99,7 +99,7 @@ SlixData* slix_alloc() {
|
||||
}
|
||||
|
||||
void slix_free(SlixData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
iso15693_3_free(data->iso15693_3_data);
|
||||
|
||||
@@ -107,7 +107,7 @@ void slix_free(SlixData* data) {
|
||||
}
|
||||
|
||||
void slix_reset(SlixData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
iso15693_3_reset(data->iso15693_3_data);
|
||||
slix_password_set_defaults(data->passwords);
|
||||
@@ -119,8 +119,8 @@ void slix_reset(SlixData* data) {
|
||||
}
|
||||
|
||||
void slix_copy(SlixData* data, const SlixData* other) {
|
||||
furi_assert(data);
|
||||
furi_assert(other);
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
iso15693_3_copy(data->iso15693_3_data, other->iso15693_3_data);
|
||||
|
||||
@@ -160,7 +160,8 @@ static bool slix_load_passwords(SlixPassword* passwords, SlixType slix_type, Fli
|
||||
}
|
||||
|
||||
bool slix_load(SlixData* data, FlipperFormat* ff, uint32_t version) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
|
||||
bool loaded = false;
|
||||
|
||||
@@ -238,7 +239,8 @@ static bool
|
||||
}
|
||||
|
||||
bool slix_save(const SlixData* data, FlipperFormat* ff) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
|
||||
bool saved = false;
|
||||
|
||||
@@ -303,6 +305,9 @@ bool slix_save(const SlixData* data, FlipperFormat* ff) {
|
||||
}
|
||||
|
||||
bool slix_is_equal(const SlixData* data, const SlixData* other) {
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
return iso15693_3_is_equal(data->iso15693_3_data, other->iso15693_3_data) &&
|
||||
memcmp(&data->system_info, &other->system_info, sizeof(SlixSystemInfo)) == 0 &&
|
||||
memcmp(
|
||||
@@ -313,6 +318,7 @@ bool slix_is_equal(const SlixData* data, const SlixData* other) {
|
||||
}
|
||||
|
||||
const char* slix_get_device_name(const SlixData* data, NfcDeviceNameType name_type) {
|
||||
furi_check(data);
|
||||
UNUSED(name_type);
|
||||
|
||||
const SlixType slix_type = slix_get_type(data);
|
||||
@@ -322,22 +328,25 @@ const char* slix_get_device_name(const SlixData* data, NfcDeviceNameType name_ty
|
||||
}
|
||||
|
||||
const uint8_t* slix_get_uid(const SlixData* data, size_t* uid_len) {
|
||||
furi_check(data);
|
||||
return iso15693_3_get_uid(data->iso15693_3_data, uid_len);
|
||||
}
|
||||
|
||||
bool slix_set_uid(SlixData* data, const uint8_t* uid, size_t uid_len) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
return iso15693_3_set_uid(data->iso15693_3_data, uid, uid_len);
|
||||
}
|
||||
|
||||
const Iso15693_3Data* slix_get_base_data(const SlixData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
return data->iso15693_3_data;
|
||||
}
|
||||
|
||||
SlixType slix_get_type(const SlixData* data) {
|
||||
furi_check(data);
|
||||
|
||||
SlixType type = SlixTypeUnknown;
|
||||
|
||||
do {
|
||||
@@ -364,14 +373,14 @@ SlixType slix_get_type(const SlixData* data) {
|
||||
}
|
||||
|
||||
SlixPassword slix_get_password(const SlixData* data, SlixPasswordType password_type) {
|
||||
furi_assert(data);
|
||||
furi_assert(password_type < SlixPasswordTypeCount);
|
||||
furi_check(data);
|
||||
furi_check(password_type < SlixPasswordTypeCount);
|
||||
|
||||
return data->passwords[password_type];
|
||||
}
|
||||
|
||||
uint16_t slix_get_counter(const SlixData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
const SlixCounter* counter = (const SlixCounter*)iso15693_3_get_block_data(
|
||||
data->iso15693_3_data, SLIX_COUNTER_BLOCK_NUM);
|
||||
|
||||
@@ -379,7 +388,7 @@ uint16_t slix_get_counter(const SlixData* data) {
|
||||
}
|
||||
|
||||
bool slix_is_privacy_mode(const SlixData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
return data->privacy;
|
||||
}
|
||||
@@ -388,8 +397,8 @@ bool slix_is_block_protected(
|
||||
const SlixData* data,
|
||||
SlixPasswordType password_type,
|
||||
uint8_t block_num) {
|
||||
furi_assert(data);
|
||||
furi_assert(password_type < SlixPasswordTypeCount);
|
||||
furi_check(data);
|
||||
furi_check(password_type < SlixPasswordTypeCount);
|
||||
|
||||
bool ret = false;
|
||||
|
||||
@@ -411,7 +420,7 @@ bool slix_is_block_protected(
|
||||
}
|
||||
|
||||
bool slix_is_counter_increment_protected(const SlixData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
const SlixCounter* counter = (const SlixCounter*)iso15693_3_get_block_data(
|
||||
data->iso15693_3_data, SLIX_COUNTER_BLOCK_NUM);
|
||||
@@ -420,14 +429,14 @@ bool slix_is_counter_increment_protected(const SlixData* data) {
|
||||
}
|
||||
|
||||
bool slix_type_has_features(SlixType slix_type, SlixTypeFeatures features) {
|
||||
furi_assert(slix_type < SlixTypeCount);
|
||||
furi_check(slix_type < SlixTypeCount);
|
||||
|
||||
return (slix_type_features[slix_type] & features) == features;
|
||||
}
|
||||
|
||||
bool slix_type_supports_password(SlixType slix_type, SlixPasswordType password_type) {
|
||||
furi_assert(slix_type < SlixTypeCount);
|
||||
furi_assert(password_type < SlixPasswordTypeCount);
|
||||
furi_check(slix_type < SlixTypeCount);
|
||||
furi_check(password_type < SlixPasswordTypeCount);
|
||||
|
||||
return slix_type_features[slix_type] & slix_password_configs[password_type].feature_flag;
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ typedef struct {
|
||||
SlixPrivacy privacy;
|
||||
} SlixData;
|
||||
|
||||
SlixData* slix_alloc();
|
||||
SlixData* slix_alloc(void);
|
||||
|
||||
void slix_free(SlixData* data);
|
||||
|
||||
|
||||
@@ -79,35 +79,39 @@ const NfcDeviceBase nfc_device_st25tb = {
|
||||
.get_base_data = (NfcDeviceGetBaseData)st25tb_get_base_data,
|
||||
};
|
||||
|
||||
St25tbData* st25tb_alloc() {
|
||||
St25tbData* st25tb_alloc(void) {
|
||||
St25tbData* data = malloc(sizeof(St25tbData));
|
||||
return data;
|
||||
}
|
||||
|
||||
void st25tb_free(St25tbData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
free(data);
|
||||
}
|
||||
|
||||
void st25tb_reset(St25tbData* data) {
|
||||
furi_check(data);
|
||||
memset(data, 0, sizeof(St25tbData));
|
||||
}
|
||||
|
||||
void st25tb_copy(St25tbData* data, const St25tbData* other) {
|
||||
furi_assert(data);
|
||||
furi_assert(other);
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
*data = *other;
|
||||
}
|
||||
|
||||
bool st25tb_verify(St25tbData* data, const FuriString* device_type) {
|
||||
furi_check(device_type);
|
||||
UNUSED(data);
|
||||
|
||||
return furi_string_equal_str(device_type, ST25TB_PROTOCOL_NAME);
|
||||
}
|
||||
|
||||
bool st25tb_load(St25tbData* data, FlipperFormat* ff, uint32_t version) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
|
||||
bool parsed = false;
|
||||
|
||||
@@ -150,7 +154,8 @@ bool st25tb_load(St25tbData* data, FlipperFormat* ff, uint32_t version) {
|
||||
}
|
||||
|
||||
bool st25tb_save(const St25tbData* data, FlipperFormat* ff) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
|
||||
FuriString* temp_str = furi_string_alloc();
|
||||
bool saved = false;
|
||||
@@ -184,19 +189,21 @@ bool st25tb_save(const St25tbData* data, FlipperFormat* ff) {
|
||||
}
|
||||
|
||||
bool st25tb_is_equal(const St25tbData* data, const St25tbData* other) {
|
||||
furi_assert(data);
|
||||
furi_assert(other);
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
return memcmp(data, other, sizeof(St25tbData)) == 0;
|
||||
return memcmp(data, other, sizeof(St25tbData)) == 0; //-V1103
|
||||
}
|
||||
|
||||
uint8_t st25tb_get_block_count(St25tbType type) {
|
||||
furi_check(type < St25tbTypeNum);
|
||||
|
||||
return st25tb_features[type].blocks_total;
|
||||
}
|
||||
|
||||
const char* st25tb_get_device_name(const St25tbData* data, NfcDeviceNameType name_type) {
|
||||
furi_assert(data);
|
||||
furi_assert(data->type < St25tbTypeNum);
|
||||
furi_check(data);
|
||||
furi_check(data->type < St25tbTypeNum);
|
||||
|
||||
if(name_type == NfcDeviceNameTypeFull) {
|
||||
return st25tb_features[data->type].full_name;
|
||||
@@ -206,7 +213,7 @@ const char* st25tb_get_device_name(const St25tbData* data, NfcDeviceNameType nam
|
||||
}
|
||||
|
||||
const uint8_t* st25tb_get_uid(const St25tbData* data, size_t* uid_len) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
if(uid_len) {
|
||||
*uid_len = ST25TB_UID_SIZE;
|
||||
@@ -216,7 +223,8 @@ const uint8_t* st25tb_get_uid(const St25tbData* data, size_t* uid_len) {
|
||||
}
|
||||
|
||||
bool st25tb_set_uid(St25tbData* data, const uint8_t* uid, size_t uid_len) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(uid);
|
||||
|
||||
const bool uid_valid = uid_len == ST25TB_UID_SIZE;
|
||||
|
||||
@@ -233,6 +241,8 @@ St25tbData* st25tb_get_base_data(const St25tbData* data) {
|
||||
}
|
||||
|
||||
St25tbType st25tb_get_type_from_uid(const uint8_t* uid) {
|
||||
furi_check(uid);
|
||||
|
||||
switch(uid[2] >> 2) {
|
||||
case 0x0:
|
||||
case 0x3:
|
||||
|
||||
@@ -48,7 +48,7 @@ typedef struct {
|
||||
|
||||
extern const NfcDeviceBase nfc_device_st25tb;
|
||||
|
||||
St25tbData* st25tb_alloc();
|
||||
St25tbData* st25tb_alloc(void);
|
||||
|
||||
void st25tb_free(St25tbData* data);
|
||||
|
||||
|
||||
@@ -20,7 +20,9 @@ St25tbError st25tb_poller_send_frame(
|
||||
const BitBuffer* tx_buffer,
|
||||
BitBuffer* rx_buffer,
|
||||
uint32_t fwt) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
furi_check(tx_buffer);
|
||||
furi_check(rx_buffer);
|
||||
|
||||
const size_t tx_bytes = bit_buffer_get_size_bytes(tx_buffer);
|
||||
furi_assert(
|
||||
@@ -54,8 +56,8 @@ St25tbError st25tb_poller_send_frame(
|
||||
|
||||
St25tbError st25tb_poller_initiate(St25tbPoller* instance, uint8_t* chip_id_ptr) {
|
||||
// Send Initiate()
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->nfc);
|
||||
furi_check(instance);
|
||||
furi_check(instance->nfc);
|
||||
|
||||
bit_buffer_reset(instance->tx_buffer);
|
||||
bit_buffer_reset(instance->rx_buffer);
|
||||
@@ -86,8 +88,8 @@ St25tbError st25tb_poller_initiate(St25tbPoller* instance, uint8_t* chip_id_ptr)
|
||||
}
|
||||
|
||||
St25tbError st25tb_poller_select(St25tbPoller* instance, uint8_t* chip_id_ptr) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->nfc);
|
||||
furi_check(instance);
|
||||
furi_check(instance->nfc);
|
||||
|
||||
St25tbError ret;
|
||||
|
||||
@@ -169,8 +171,9 @@ St25tbError st25tb_poller_read(St25tbPoller* instance, St25tbData* data) {
|
||||
}
|
||||
|
||||
St25tbError st25tb_poller_get_uid(St25tbPoller* instance, uint8_t* uid) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->nfc);
|
||||
furi_check(instance);
|
||||
furi_check(instance->nfc);
|
||||
furi_check(uid);
|
||||
|
||||
St25tbError ret;
|
||||
|
||||
@@ -213,10 +216,10 @@ St25tbError st25tb_poller_get_uid(St25tbPoller* instance, uint8_t* uid) {
|
||||
|
||||
St25tbError
|
||||
st25tb_poller_read_block(St25tbPoller* instance, uint32_t* block, uint8_t block_number) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->nfc);
|
||||
furi_assert(block);
|
||||
furi_assert(
|
||||
furi_check(instance);
|
||||
furi_check(instance->nfc);
|
||||
furi_check(block);
|
||||
furi_check(
|
||||
(block_number <= st25tb_get_block_count(instance->data->type)) ||
|
||||
block_number == ST25TB_SYSTEM_OTP_BLOCK);
|
||||
FURI_LOG_T(TAG, "reading block %d", block_number);
|
||||
@@ -248,9 +251,9 @@ St25tbError
|
||||
|
||||
St25tbError
|
||||
st25tb_poller_write_block(St25tbPoller* instance, uint32_t block, uint8_t block_number) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->nfc);
|
||||
furi_assert(
|
||||
furi_check(instance);
|
||||
furi_check(instance->nfc);
|
||||
furi_check(
|
||||
(block_number <= st25tb_get_block_count(instance->data->type)) ||
|
||||
block_number == ST25TB_SYSTEM_OTP_BLOCK);
|
||||
FURI_LOG_T(TAG, "writing block %d", block_number);
|
||||
@@ -292,7 +295,7 @@ St25tbError
|
||||
}
|
||||
|
||||
St25tbError st25tb_poller_halt(St25tbPoller* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
bit_buffer_reset(instance->tx_buffer);
|
||||
bit_buffer_reset(instance->rx_buffer);
|
||||
|
||||
@@ -109,7 +109,8 @@ static St25tbError st25tb_poller_cmd_execute(Nfc* nfc, St25tbPollerSyncContext*
|
||||
}
|
||||
|
||||
St25tbError st25tb_poller_sync_read_block(Nfc* nfc, uint8_t block_num, uint32_t* block) {
|
||||
furi_assert(block);
|
||||
furi_check(nfc);
|
||||
furi_check(block);
|
||||
St25tbPollerSyncContext poller_context = {
|
||||
.cmd_type = St25tbPollerCmdTypeReadBlock,
|
||||
.cmd_data =
|
||||
@@ -125,6 +126,7 @@ St25tbError st25tb_poller_sync_read_block(Nfc* nfc, uint8_t block_num, uint32_t*
|
||||
}
|
||||
|
||||
St25tbError st25tb_poller_sync_write_block(Nfc* nfc, uint8_t block_num, uint32_t block) {
|
||||
furi_check(nfc);
|
||||
St25tbPollerSyncContext poller_context = {
|
||||
.cmd_type = St25tbPollerCmdTypeWriteBlock,
|
||||
.cmd_data =
|
||||
@@ -140,7 +142,8 @@ St25tbError st25tb_poller_sync_write_block(Nfc* nfc, uint8_t block_num, uint32_t
|
||||
}
|
||||
|
||||
St25tbError st25tb_poller_sync_detect_type(Nfc* nfc, St25tbType* type) {
|
||||
furi_assert(type);
|
||||
furi_check(nfc);
|
||||
furi_check(type);
|
||||
St25tbPollerSyncContext poller_context = {
|
||||
.cmd_type = St25tbPollerCmdTypeDetectType,
|
||||
.cmd_data =
|
||||
@@ -185,8 +188,8 @@ static NfcCommand nfc_scene_read_poller_callback_st25tb(NfcGenericEvent event, v
|
||||
}
|
||||
|
||||
St25tbError st25tb_poller_sync_read(Nfc* nfc, St25tbData* data) {
|
||||
furi_assert(nfc);
|
||||
furi_assert(data);
|
||||
furi_check(nfc);
|
||||
furi_check(data);
|
||||
|
||||
St25tbPollerSyncContext poller_context = {
|
||||
.thread_id = furi_thread_get_current_id(),
|
||||
|
||||
Reference in New Issue
Block a user