mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-26 22:40:25 +00:00
Merge branch 'ofw_dev' into nfcrefactoring
This commit is contained in:
commit
593b5fc098
16 changed files with 55 additions and 26 deletions
|
@ -190,6 +190,8 @@ void nfc_render_mf_desfire_file_settings_data(
|
||||||
uint32_t record_count = 1;
|
uint32_t record_count = 1;
|
||||||
uint32_t record_size = 0;
|
uint32_t record_size = 0;
|
||||||
|
|
||||||
|
const uint32_t total_size = simple_array_get_count(data->data);
|
||||||
|
|
||||||
switch(settings->type) {
|
switch(settings->type) {
|
||||||
case MfDesfireFileTypeStandard:
|
case MfDesfireFileTypeStandard:
|
||||||
case MfDesfireFileTypeBackup:
|
case MfDesfireFileTypeBackup:
|
||||||
|
@ -197,6 +199,7 @@ void nfc_render_mf_desfire_file_settings_data(
|
||||||
furi_string_cat_printf(str, "size %lu\n", record_size);
|
furi_string_cat_printf(str, "size %lu\n", record_size);
|
||||||
break;
|
break;
|
||||||
case MfDesfireFileTypeValue:
|
case MfDesfireFileTypeValue:
|
||||||
|
record_size = MF_DESFIRE_VALUE_SIZE;
|
||||||
furi_string_cat_printf(
|
furi_string_cat_printf(
|
||||||
str, "lo %lu hi %lu\n", settings->value.lo_limit, settings->value.hi_limit);
|
str, "lo %lu hi %lu\n", settings->value.lo_limit, settings->value.hi_limit);
|
||||||
furi_string_cat_printf(
|
furi_string_cat_printf(
|
||||||
|
@ -219,9 +222,20 @@ void nfc_render_mf_desfire_file_settings_data(
|
||||||
}
|
}
|
||||||
|
|
||||||
for(uint32_t rec = 0; rec < record_count; rec++) {
|
for(uint32_t rec = 0; rec < record_count; rec++) {
|
||||||
furi_string_cat_printf(str, "record %lu\n", rec);
|
const uint32_t size_offset = rec * record_size;
|
||||||
|
const uint32_t size_remaining = total_size > size_offset ? total_size - size_offset : 0;
|
||||||
|
|
||||||
|
if(size_remaining < record_size) {
|
||||||
|
furi_string_cat_printf(
|
||||||
|
str, "record %lu (partial %lu of %lu)\n", rec, size_remaining, record_size);
|
||||||
|
record_size = size_remaining;
|
||||||
|
} else {
|
||||||
|
furi_string_cat_printf(str, "record %lu\n", rec);
|
||||||
|
}
|
||||||
|
|
||||||
for(uint32_t ch = 0; ch < record_size; ch += 4) {
|
for(uint32_t ch = 0; ch < record_size; ch += 4) {
|
||||||
furi_string_cat_printf(str, "%03lx|", ch);
|
furi_string_cat_printf(str, "%03lx|", ch);
|
||||||
|
|
||||||
for(uint32_t i = 0; i < 4; i++) {
|
for(uint32_t i = 0; i < 4; i++) {
|
||||||
if(ch + i < record_size) {
|
if(ch + i < record_size) {
|
||||||
const uint32_t data_index = rec * record_size + ch + i;
|
const uint32_t data_index = rec * record_size + ch + i;
|
||||||
|
@ -232,6 +246,7 @@ void nfc_render_mf_desfire_file_settings_data(
|
||||||
furi_string_cat_printf(str, " ");
|
furi_string_cat_printf(str, " ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(uint32_t i = 0; i < 4 && ch + i < record_size; i++) {
|
for(uint32_t i = 0; i < 4 && ch + i < record_size; i++) {
|
||||||
const uint32_t data_index = rec * record_size + ch + i;
|
const uint32_t data_index = rec * record_size + ch + i;
|
||||||
const uint8_t data_byte =
|
const uint8_t data_byte =
|
||||||
|
@ -242,8 +257,10 @@ void nfc_render_mf_desfire_file_settings_data(
|
||||||
furi_string_cat_printf(str, ".");
|
furi_string_cat_printf(str, ".");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
furi_string_push_back(str, '\n');
|
furi_string_push_back(str, '\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
furi_string_push_back(str, '\n');
|
furi_string_push_back(str, '\n');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,6 +95,11 @@ const NfcProtocolSupportBase nfc_protocol_support_st25tb = {
|
||||||
.on_enter = nfc_protocol_support_common_on_enter_empty,
|
.on_enter = nfc_protocol_support_common_on_enter_empty,
|
||||||
.on_event = nfc_scene_saved_menu_on_event_st25tb,
|
.on_event = nfc_scene_saved_menu_on_event_st25tb,
|
||||||
},
|
},
|
||||||
|
.scene_save_name =
|
||||||
|
{
|
||||||
|
.on_enter = nfc_protocol_support_common_on_enter_empty,
|
||||||
|
.on_event = nfc_protocol_support_common_on_event_empty,
|
||||||
|
},
|
||||||
.scene_emulate =
|
.scene_emulate =
|
||||||
{
|
{
|
||||||
.on_enter = nfc_protocol_support_common_on_enter_empty,
|
.on_enter = nfc_protocol_support_common_on_enter_empty,
|
||||||
|
|
|
@ -71,15 +71,6 @@ env = ENV.Clone(
|
||||||
"FURI_DEBUG" if ENV["DEBUG"] else "FURI_NDEBUG",
|
"FURI_DEBUG" if ENV["DEBUG"] else "FURI_NDEBUG",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"nfc": {
|
|
||||||
"CCFLAGS": [
|
|
||||||
"-Og",
|
|
||||||
],
|
|
||||||
"CPPDEFINES": [
|
|
||||||
"NDEBUG",
|
|
||||||
"FURI_DEBUG",
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
FW_API_TABLE=None,
|
FW_API_TABLE=None,
|
||||||
_APP_ICONS=None,
|
_APP_ICONS=None,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
entry,status,name,type,params
|
entry,status,name,type,params
|
||||||
Version,+,40.0,,
|
Version,+,40.1,,
|
||||||
Header,+,applications/services/bt/bt_service/bt.h,,
|
Header,+,applications/services/bt/bt_service/bt.h,,
|
||||||
Header,+,applications/services/cli/cli.h,,
|
Header,+,applications/services/cli/cli.h,,
|
||||||
Header,+,applications/services/cli/cli_vcp.h,,
|
Header,+,applications/services/cli/cli_vcp.h,,
|
||||||
|
|
|
|
@ -1,5 +1,5 @@
|
||||||
entry,status,name,type,params
|
entry,status,name,type,params
|
||||||
Version,+,40.0,,
|
Version,+,40.1,,
|
||||||
Header,+,applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h,,
|
Header,+,applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h,,
|
||||||
Header,+,applications/services/bt/bt_service/bt.h,,
|
Header,+,applications/services/bt/bt_service/bt.h,,
|
||||||
Header,+,applications/services/cli/cli.h,,
|
Header,+,applications/services/cli/cli.h,,
|
||||||
|
|
|
|
@ -25,9 +25,10 @@ FuriHalNfcError furi_hal_nfc_event_stop() {
|
||||||
|
|
||||||
void furi_hal_nfc_event_set(FuriHalNfcEventInternalType event) {
|
void furi_hal_nfc_event_set(FuriHalNfcEventInternalType event) {
|
||||||
furi_assert(furi_hal_nfc_event);
|
furi_assert(furi_hal_nfc_event);
|
||||||
furi_assert(furi_hal_nfc_event->thread);
|
|
||||||
|
|
||||||
furi_thread_flags_set(furi_hal_nfc_event->thread, event);
|
if(furi_hal_nfc_event->thread) {
|
||||||
|
furi_thread_flags_set(furi_hal_nfc_event->thread, event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FuriHalNfcError furi_hal_nfc_abort() {
|
FuriHalNfcError furi_hal_nfc_abort() {
|
||||||
|
|
|
@ -23,6 +23,6 @@ void furi_hal_nfc_init_gpio_isr() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void furi_hal_nfc_deinit_gpio_isr() {
|
void furi_hal_nfc_deinit_gpio_isr() {
|
||||||
furi_hal_gpio_init(&gpio_nfc_irq_rfid_pull, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedLow);
|
|
||||||
furi_hal_gpio_remove_int_callback(&gpio_nfc_irq_rfid_pull);
|
furi_hal_gpio_remove_int_callback(&gpio_nfc_irq_rfid_pull);
|
||||||
|
furi_hal_gpio_init(&gpio_nfc_irq_rfid_pull, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ static FuriHalNfcIso15693Listener* furi_hal_nfc_iso15693_listener_alloc() {
|
||||||
|
|
||||||
instance->signal = iso15693_signal_alloc(&gpio_spi_r_mosi);
|
instance->signal = iso15693_signal_alloc(&gpio_spi_r_mosi);
|
||||||
instance->parser =
|
instance->parser =
|
||||||
iso15693_parser_alloc(&gpio_spi_r_miso, FURI_HAL_NFC_ISO15693_MAX_FRAME_SIZE);
|
iso15693_parser_alloc(&gpio_nfc_irq_rfid_pull, FURI_HAL_NFC_ISO15693_MAX_FRAME_SIZE);
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
// FreeRTOS timer, REMOVE AFTER REFACTORING
|
// FreeRTOS timer, REMOVE AFTER REFACTORING
|
||||||
#include <timers.h>
|
#include <timers.h>
|
||||||
|
|
||||||
|
// Workaround for math.h leaking through HAL in older versions
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -51,7 +51,7 @@ env.Append(
|
||||||
libenv = env.Clone(FW_LIB_NAME="nfc")
|
libenv = env.Clone(FW_LIB_NAME="nfc")
|
||||||
libenv.ApplyLibFlags()
|
libenv.ApplyLibFlags()
|
||||||
|
|
||||||
sources = libenv.GlobRecursive("*.c*", exclude="deprecated/*c")
|
sources = libenv.GlobRecursive("*.c*")
|
||||||
|
|
||||||
lib = libenv.StaticLibrary("${FW_LIB_NAME}", sources)
|
lib = libenv.StaticLibrary("${FW_LIB_NAME}", sources)
|
||||||
libenv.Install("${LIB_DIST_DIR}", lib)
|
libenv.Install("${LIB_DIST_DIR}", lib)
|
||||||
|
|
|
@ -29,6 +29,7 @@ extern "C" {
|
||||||
#define MF_DESFIRE_UID_SIZE (7)
|
#define MF_DESFIRE_UID_SIZE (7)
|
||||||
#define MF_DESFIRE_BATCH_SIZE (5)
|
#define MF_DESFIRE_BATCH_SIZE (5)
|
||||||
#define MF_DESFIRE_APP_ID_SIZE (3)
|
#define MF_DESFIRE_APP_ID_SIZE (3)
|
||||||
|
#define MF_DESFIRE_VALUE_SIZE (4)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t hw_vendor;
|
uint8_t hw_vendor;
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
|
|
||||||
#define TAG "MfDesfirePoller"
|
#define TAG "MfDesfirePoller"
|
||||||
|
|
||||||
#define MF_DESFIRE_BUF_SIZE_MAX (64U)
|
#define MF_DESFIRE_BUF_SIZE (64U)
|
||||||
|
#define MF_DESFIRE_RESULT_BUF_SIZE (512U)
|
||||||
|
|
||||||
typedef NfcCommand (*MfDesfirePollerReadHandler)(MfDesfirePoller* instance);
|
typedef NfcCommand (*MfDesfirePollerReadHandler)(MfDesfirePoller* instance);
|
||||||
|
|
||||||
|
@ -20,10 +21,10 @@ static MfDesfirePoller* mf_desfire_poller_alloc(Iso14443_4aPoller* iso14443_4a_p
|
||||||
MfDesfirePoller* instance = malloc(sizeof(MfDesfirePoller));
|
MfDesfirePoller* instance = malloc(sizeof(MfDesfirePoller));
|
||||||
instance->iso14443_4a_poller = iso14443_4a_poller;
|
instance->iso14443_4a_poller = iso14443_4a_poller;
|
||||||
instance->data = mf_desfire_alloc();
|
instance->data = mf_desfire_alloc();
|
||||||
instance->tx_buffer = bit_buffer_alloc(MF_DESFIRE_BUF_SIZE_MAX);
|
instance->tx_buffer = bit_buffer_alloc(MF_DESFIRE_BUF_SIZE);
|
||||||
instance->rx_buffer = bit_buffer_alloc(MF_DESFIRE_BUF_SIZE_MAX);
|
instance->rx_buffer = bit_buffer_alloc(MF_DESFIRE_BUF_SIZE);
|
||||||
instance->input_buffer = bit_buffer_alloc(MF_DESFIRE_BUF_SIZE_MAX);
|
instance->input_buffer = bit_buffer_alloc(MF_DESFIRE_BUF_SIZE);
|
||||||
instance->result_buffer = bit_buffer_alloc(MF_DESFIRE_BUF_SIZE_MAX);
|
instance->result_buffer = bit_buffer_alloc(MF_DESFIRE_RESULT_BUF_SIZE);
|
||||||
|
|
||||||
instance->mf_desfire_event.data = &instance->mf_desfire_event_data;
|
instance->mf_desfire_event.data = &instance->mf_desfire_event_data;
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,15 @@ MfDesfireError mf_desfire_send_chunks(
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
bit_buffer_append_right(rx_buffer, instance->rx_buffer, sizeof(uint8_t));
|
const size_t rx_size = bit_buffer_get_size_bytes(instance->rx_buffer);
|
||||||
|
const size_t rx_capacity_remaining =
|
||||||
|
bit_buffer_get_capacity_bytes(rx_buffer) - bit_buffer_get_size_bytes(rx_buffer);
|
||||||
|
|
||||||
|
if(rx_size <= rx_capacity_remaining) {
|
||||||
|
bit_buffer_append_right(rx_buffer, instance->rx_buffer, sizeof(uint8_t));
|
||||||
|
} else {
|
||||||
|
FURI_LOG_W(TAG, "RX buffer overflow: ignoring %zu bytes", rx_size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} while(false);
|
} while(false);
|
||||||
|
|
||||||
|
@ -353,7 +361,7 @@ MfDesfireError mf_desfire_poller_async_read_file_records(
|
||||||
furi_assert(instance);
|
furi_assert(instance);
|
||||||
|
|
||||||
bit_buffer_reset(instance->input_buffer);
|
bit_buffer_reset(instance->input_buffer);
|
||||||
bit_buffer_append_byte(instance->input_buffer, MF_DESFIRE_CMD_READ_DATA);
|
bit_buffer_append_byte(instance->input_buffer, MF_DESFIRE_CMD_READ_RECORDS);
|
||||||
bit_buffer_append_byte(instance->input_buffer, id);
|
bit_buffer_append_byte(instance->input_buffer, id);
|
||||||
bit_buffer_append_bytes(instance->input_buffer, (const uint8_t*)&offset, 3);
|
bit_buffer_append_bytes(instance->input_buffer, (const uint8_t*)&offset, 3);
|
||||||
bit_buffer_append_bytes(instance->input_buffer, (const uint8_t*)&size, 3);
|
bit_buffer_append_bytes(instance->input_buffer, (const uint8_t*)&size, 3);
|
||||||
|
|
|
@ -297,7 +297,7 @@ bool mf_ultralight_load(MfUltralightData* data, FlipperFormat* ff, uint32_t vers
|
||||||
uint32_t pages_total = 0;
|
uint32_t pages_total = 0;
|
||||||
if(!flipper_format_read_uint32(ff, MF_ULTRALIGHT_PAGES_TOTAL_KEY, &pages_total, 1)) break;
|
if(!flipper_format_read_uint32(ff, MF_ULTRALIGHT_PAGES_TOTAL_KEY, &pages_total, 1)) break;
|
||||||
uint32_t pages_read = 0;
|
uint32_t pages_read = 0;
|
||||||
if(data_format_version < mf_ultralight_data_format_version) {
|
if(data_format_version < mf_ultralight_data_format_version) { //-V547
|
||||||
pages_read = pages_total;
|
pages_read = pages_total;
|
||||||
} else {
|
} else {
|
||||||
if(!flipper_format_read_uint32(ff, MF_ULTRALIGHT_PAGES_READ_KEY, &pages_read, 1))
|
if(!flipper_format_read_uint32(ff, MF_ULTRALIGHT_PAGES_READ_KEY, &pages_read, 1))
|
||||||
|
|
|
@ -518,6 +518,8 @@ static uint16_t mf_ultralight_get_upper_page_bound(MfUltralightType type) {
|
||||||
upper_page_bound = 511;
|
upper_page_bound = 511;
|
||||||
else if(type == MfUltralightTypeNTAGI2C2K)
|
else if(type == MfUltralightTypeNTAGI2C2K)
|
||||||
upper_page_bound = 479;
|
upper_page_bound = 479;
|
||||||
|
else if(type == MfUltralightTypeNTAGI2C1K)
|
||||||
|
upper_page_bound = 225;
|
||||||
else {
|
else {
|
||||||
upper_page_bound = mf_ultralight_get_config_page_num(type) - 2;
|
upper_page_bound = mf_ultralight_get_config_page_num(type) - 2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ Iso15693Parser* iso15693_parser_alloc(const GpioPin* pin, size_t max_frame_size)
|
||||||
signal_reader_set_sample_rate(
|
signal_reader_set_sample_rate(
|
||||||
instance->signal_reader, SignalReaderTimeUnit64Mhz, ISO15693_PARSER_BITRATE_F64MHZ);
|
instance->signal_reader, SignalReaderTimeUnit64Mhz, ISO15693_PARSER_BITRATE_F64MHZ);
|
||||||
signal_reader_set_pull(instance->signal_reader, GpioPullDown);
|
signal_reader_set_pull(instance->signal_reader, GpioPullDown);
|
||||||
signal_reader_set_polarity(instance->signal_reader, SignalReaderPolarityInverted);
|
signal_reader_set_polarity(instance->signal_reader, SignalReaderPolarityNormal);
|
||||||
signal_reader_set_trigger(instance->signal_reader, SignalReaderTriggerRisingFallingEdge);
|
signal_reader_set_trigger(instance->signal_reader, SignalReaderTriggerRisingFallingEdge);
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
|
|
Loading…
Reference in a new issue