M*LIB: non-inlined strings, FuriString primitive (#1795)
* Quicksave 1 * Header stage complete * Source stage complete * Lint & merge fixes * Includes * Documentation step 1 * FBT: output free size considering BT STACK * Documentation step 2 * py lint * Fix music player plugin * unit test stage 1: string allocator, mem, getters, setters, appends, compare, search. * unit test: string equality * unit test: string replace * unit test: string start_with, end_with * unit test: string trim * unit test: utf-8 * Rename * Revert fw_size changes * Simplify CLI backspace handling * Simplify CLI character insert * Merge fixes * Furi: correct filenaming and spelling * Bt: remove furi string include Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
@@ -7,12 +7,12 @@ static const uint32_t nfc_resources_file_version = 1;
|
||||
static bool nfc_emv_parser_search_data(
|
||||
Storage* storage,
|
||||
const char* file_name,
|
||||
string_t key,
|
||||
string_t data) {
|
||||
FuriString* key,
|
||||
FuriString* data) {
|
||||
bool parsed = false;
|
||||
FlipperFormat* file = flipper_format_file_alloc(storage);
|
||||
string_t temp_str;
|
||||
string_init(temp_str);
|
||||
FuriString* temp_str;
|
||||
temp_str = furi_string_alloc();
|
||||
|
||||
do {
|
||||
// Open file
|
||||
@@ -20,14 +20,14 @@ static bool nfc_emv_parser_search_data(
|
||||
// Read file header and version
|
||||
uint32_t version = 0;
|
||||
if(!flipper_format_read_header(file, temp_str, &version)) break;
|
||||
if(string_cmp_str(temp_str, nfc_resources_header) ||
|
||||
if(furi_string_cmp_str(temp_str, nfc_resources_header) ||
|
||||
(version != nfc_resources_file_version))
|
||||
break;
|
||||
if(!flipper_format_read_string(file, string_get_cstr(key), data)) break;
|
||||
if(!flipper_format_read_string(file, furi_string_get_cstr(key), data)) break;
|
||||
parsed = true;
|
||||
} while(false);
|
||||
|
||||
string_clear(temp_str);
|
||||
furi_string_free(temp_str);
|
||||
flipper_format_free(file);
|
||||
return parsed;
|
||||
}
|
||||
@@ -36,47 +36,47 @@ bool nfc_emv_parser_get_aid_name(
|
||||
Storage* storage,
|
||||
uint8_t* aid,
|
||||
uint8_t aid_len,
|
||||
string_t aid_name) {
|
||||
FuriString* aid_name) {
|
||||
furi_assert(storage);
|
||||
bool parsed = false;
|
||||
string_t key;
|
||||
string_init(key);
|
||||
FuriString* key;
|
||||
key = furi_string_alloc();
|
||||
for(uint8_t i = 0; i < aid_len; i++) {
|
||||
string_cat_printf(key, "%02X", aid[i]);
|
||||
furi_string_cat_printf(key, "%02X", aid[i]);
|
||||
}
|
||||
if(nfc_emv_parser_search_data(storage, EXT_PATH("nfc/assets/aid.nfc"), key, aid_name)) {
|
||||
parsed = true;
|
||||
}
|
||||
string_clear(key);
|
||||
furi_string_free(key);
|
||||
return parsed;
|
||||
}
|
||||
|
||||
bool nfc_emv_parser_get_country_name(
|
||||
Storage* storage,
|
||||
uint16_t country_code,
|
||||
string_t country_name) {
|
||||
FuriString* country_name) {
|
||||
bool parsed = false;
|
||||
string_t key;
|
||||
string_init_printf(key, "%04X", country_code);
|
||||
FuriString* key;
|
||||
key = furi_string_alloc_printf("%04X", country_code);
|
||||
if(nfc_emv_parser_search_data(
|
||||
storage, EXT_PATH("nfc/assets/country_code.nfc"), key, country_name)) {
|
||||
parsed = true;
|
||||
}
|
||||
string_clear(key);
|
||||
furi_string_free(key);
|
||||
return parsed;
|
||||
}
|
||||
|
||||
bool nfc_emv_parser_get_currency_name(
|
||||
Storage* storage,
|
||||
uint16_t currency_code,
|
||||
string_t currency_name) {
|
||||
FuriString* currency_name) {
|
||||
bool parsed = false;
|
||||
string_t key;
|
||||
string_init_printf(key, "%04X", currency_code);
|
||||
FuriString* key;
|
||||
key = furi_string_alloc_printf("%04X", currency_code);
|
||||
if(nfc_emv_parser_search_data(
|
||||
storage, EXT_PATH("nfc/assets/currency_code.nfc"), key, currency_name)) {
|
||||
parsed = true;
|
||||
}
|
||||
string_clear(key);
|
||||
furi_string_free(key);
|
||||
return parsed;
|
||||
}
|
||||
|
@@ -2,7 +2,6 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <m-string.h>
|
||||
#include <storage/storage.h>
|
||||
|
||||
/** Get EMV application name by number
|
||||
@@ -16,7 +15,7 @@ bool nfc_emv_parser_get_aid_name(
|
||||
Storage* storage,
|
||||
uint8_t* aid,
|
||||
uint8_t aid_len,
|
||||
string_t aid_name);
|
||||
FuriString* aid_name);
|
||||
|
||||
/** Get country name by country code
|
||||
* @param storage Storage instance
|
||||
@@ -27,7 +26,7 @@ bool nfc_emv_parser_get_aid_name(
|
||||
bool nfc_emv_parser_get_country_name(
|
||||
Storage* storage,
|
||||
uint16_t country_code,
|
||||
string_t country_name);
|
||||
FuriString* country_name);
|
||||
|
||||
/** Get currency name by currency code
|
||||
* @param storage Storage instance
|
||||
@@ -38,4 +37,4 @@ bool nfc_emv_parser_get_country_name(
|
||||
bool nfc_emv_parser_get_currency_name(
|
||||
Storage* storage,
|
||||
uint16_t currency_code,
|
||||
string_t currency_name);
|
||||
FuriString* currency_name);
|
||||
|
@@ -83,7 +83,7 @@ Nfc* nfc_alloc() {
|
||||
nfc->text_box = text_box_alloc();
|
||||
view_dispatcher_add_view(
|
||||
nfc->view_dispatcher, NfcViewTextBox, text_box_get_view(nfc->text_box));
|
||||
string_init(nfc->text_box_store);
|
||||
nfc->text_box_store = furi_string_alloc();
|
||||
|
||||
// Custom Widget
|
||||
nfc->widget = widget_alloc();
|
||||
@@ -153,7 +153,7 @@ void nfc_free(Nfc* nfc) {
|
||||
// TextBox
|
||||
view_dispatcher_remove_view(nfc->view_dispatcher, NfcViewTextBox);
|
||||
text_box_free(nfc->text_box);
|
||||
string_clear(nfc->text_box_store);
|
||||
furi_string_free(nfc->text_box_store);
|
||||
|
||||
// Custom Widget
|
||||
view_dispatcher_remove_view(nfc->view_dispatcher, NfcViewWidget);
|
||||
|
@@ -17,7 +17,7 @@ static void nfc_cli_print_usage() {
|
||||
}
|
||||
}
|
||||
|
||||
static void nfc_cli_detect(Cli* cli, string_t args) {
|
||||
static void nfc_cli_detect(Cli* cli, FuriString* args) {
|
||||
UNUSED(args);
|
||||
// Check if nfc worker is not busy
|
||||
if(furi_hal_nfc_is_busy()) {
|
||||
@@ -46,7 +46,7 @@ static void nfc_cli_detect(Cli* cli, string_t args) {
|
||||
furi_hal_nfc_sleep();
|
||||
}
|
||||
|
||||
static void nfc_cli_emulate(Cli* cli, string_t args) {
|
||||
static void nfc_cli_emulate(Cli* cli, FuriString* args) {
|
||||
UNUSED(args);
|
||||
// Check if nfc worker is not busy
|
||||
if(furi_hal_nfc_is_busy()) {
|
||||
@@ -76,7 +76,7 @@ static void nfc_cli_emulate(Cli* cli, string_t args) {
|
||||
furi_hal_nfc_sleep();
|
||||
}
|
||||
|
||||
static void nfc_cli_field(Cli* cli, string_t args) {
|
||||
static void nfc_cli_field(Cli* cli, FuriString* args) {
|
||||
UNUSED(args);
|
||||
// Check if nfc worker is not busy
|
||||
if(furi_hal_nfc_is_busy()) {
|
||||
@@ -98,27 +98,27 @@ static void nfc_cli_field(Cli* cli, string_t args) {
|
||||
furi_hal_nfc_sleep();
|
||||
}
|
||||
|
||||
static void nfc_cli(Cli* cli, string_t args, void* context) {
|
||||
static void nfc_cli(Cli* cli, FuriString* args, void* context) {
|
||||
UNUSED(context);
|
||||
string_t cmd;
|
||||
string_init(cmd);
|
||||
FuriString* cmd;
|
||||
cmd = furi_string_alloc();
|
||||
|
||||
do {
|
||||
if(!args_read_string_and_trim(args, cmd)) {
|
||||
nfc_cli_print_usage();
|
||||
break;
|
||||
}
|
||||
if(string_cmp_str(cmd, "detect") == 0) {
|
||||
if(furi_string_cmp_str(cmd, "detect") == 0) {
|
||||
nfc_cli_detect(cli, args);
|
||||
break;
|
||||
}
|
||||
if(string_cmp_str(cmd, "emulate") == 0) {
|
||||
if(furi_string_cmp_str(cmd, "emulate") == 0) {
|
||||
nfc_cli_emulate(cli, args);
|
||||
break;
|
||||
}
|
||||
|
||||
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
||||
if(string_cmp_str(cmd, "field") == 0) {
|
||||
if(furi_string_cmp_str(cmd, "field") == 0) {
|
||||
nfc_cli_field(cli, args);
|
||||
break;
|
||||
}
|
||||
@@ -127,7 +127,7 @@ static void nfc_cli(Cli* cli, string_t args, void* context) {
|
||||
nfc_cli_print_usage();
|
||||
} while(false);
|
||||
|
||||
string_clear(cmd);
|
||||
furi_string_free(cmd);
|
||||
}
|
||||
|
||||
void nfc_on_system_start() {
|
||||
|
@@ -62,7 +62,7 @@ struct Nfc {
|
||||
FuriHalNfcDevData dev_edit_data;
|
||||
|
||||
char text_store[NFC_TEXT_STORE_SIZE + 1];
|
||||
string_t text_box_store;
|
||||
FuriString* text_box_store;
|
||||
uint8_t byte_input_store[6];
|
||||
MfClassicUserKeys_t mfc_key_strs; // Used in MFC key listing
|
||||
|
||||
|
@@ -12,40 +12,40 @@ void nfc_scene_delete_on_enter(void* context) {
|
||||
FuriHalNfcDevData* nfc_data = &nfc->dev->dev_data.nfc_data;
|
||||
|
||||
// Setup Custom Widget view
|
||||
string_t temp_str;
|
||||
string_init(temp_str);
|
||||
FuriString* temp_str;
|
||||
temp_str = furi_string_alloc();
|
||||
|
||||
string_printf(temp_str, "\e#Delete %s?\e#", nfc->dev->dev_name);
|
||||
furi_string_printf(temp_str, "\e#Delete %s?\e#", nfc->dev->dev_name);
|
||||
widget_add_text_box_element(
|
||||
nfc->widget, 0, 0, 128, 23, AlignCenter, AlignCenter, string_get_cstr(temp_str), false);
|
||||
nfc->widget, 0, 0, 128, 23, AlignCenter, AlignCenter, furi_string_get_cstr(temp_str), false);
|
||||
widget_add_button_element(
|
||||
nfc->widget, GuiButtonTypeLeft, "Cancel", nfc_scene_delete_widget_callback, nfc);
|
||||
widget_add_button_element(
|
||||
nfc->widget, GuiButtonTypeRight, "Delete", nfc_scene_delete_widget_callback, nfc);
|
||||
|
||||
string_set_str(temp_str, "UID:");
|
||||
furi_string_set(temp_str, "UID:");
|
||||
for(size_t i = 0; i < nfc_data->uid_len; i++) {
|
||||
string_cat_printf(temp_str, " %02X", nfc_data->uid[i]);
|
||||
furi_string_cat_printf(temp_str, " %02X", nfc_data->uid[i]);
|
||||
}
|
||||
widget_add_string_element(
|
||||
nfc->widget, 64, 24, AlignCenter, AlignTop, FontSecondary, string_get_cstr(temp_str));
|
||||
nfc->widget, 64, 24, AlignCenter, AlignTop, FontSecondary, furi_string_get_cstr(temp_str));
|
||||
|
||||
NfcProtocol protocol = nfc->dev->dev_data.protocol;
|
||||
if(protocol == NfcDeviceProtocolEMV) {
|
||||
string_set_str(temp_str, "EMV bank card");
|
||||
furi_string_set(temp_str, "EMV bank card");
|
||||
} else if(protocol == NfcDeviceProtocolMifareUl) {
|
||||
string_set_str(temp_str, nfc_mf_ul_type(nfc->dev->dev_data.mf_ul_data.type, true));
|
||||
furi_string_set(temp_str, nfc_mf_ul_type(nfc->dev->dev_data.mf_ul_data.type, true));
|
||||
} else if(protocol == NfcDeviceProtocolMifareClassic) {
|
||||
string_set_str(temp_str, nfc_mf_classic_type(nfc->dev->dev_data.mf_classic_data.type));
|
||||
furi_string_set(temp_str, nfc_mf_classic_type(nfc->dev->dev_data.mf_classic_data.type));
|
||||
} else if(protocol == NfcDeviceProtocolMifareDesfire) {
|
||||
string_set_str(temp_str, "MIFARE DESFire");
|
||||
furi_string_set(temp_str, "MIFARE DESFire");
|
||||
} else {
|
||||
string_set_str(temp_str, "Unknown ISO tag");
|
||||
furi_string_set(temp_str, "Unknown ISO tag");
|
||||
}
|
||||
widget_add_string_element(
|
||||
nfc->widget, 64, 34, AlignCenter, AlignTop, FontSecondary, string_get_cstr(temp_str));
|
||||
nfc->widget, 64, 34, AlignCenter, AlignTop, FontSecondary, furi_string_get_cstr(temp_str));
|
||||
widget_add_string_element(nfc->widget, 64, 44, AlignCenter, AlignTop, FontSecondary, "NFC-A");
|
||||
string_clear(temp_str);
|
||||
furi_string_free(temp_str);
|
||||
|
||||
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewWidget);
|
||||
}
|
||||
|
@@ -12,49 +12,52 @@ void nfc_scene_device_info_on_enter(void* context) {
|
||||
Nfc* nfc = context;
|
||||
NfcDeviceData* dev_data = &nfc->dev->dev_data;
|
||||
|
||||
string_t temp_str;
|
||||
string_init(temp_str);
|
||||
FuriString* temp_str;
|
||||
temp_str = furi_string_alloc();
|
||||
|
||||
if(dev_data->protocol == NfcDeviceProtocolEMV) {
|
||||
EmvData* emv_data = &dev_data->emv_data;
|
||||
string_printf(temp_str, "\e#%s\n", emv_data->name);
|
||||
furi_string_printf(temp_str, "\e#%s\n", emv_data->name);
|
||||
for(uint8_t i = 0; i < emv_data->number_len; i += 2) {
|
||||
string_cat_printf(temp_str, "%02X%02X ", emv_data->number[i], emv_data->number[i + 1]);
|
||||
furi_string_cat_printf(
|
||||
temp_str, "%02X%02X ", emv_data->number[i], emv_data->number[i + 1]);
|
||||
}
|
||||
string_strim(temp_str);
|
||||
furi_string_trim(temp_str);
|
||||
|
||||
// Add expiration date
|
||||
if(emv_data->exp_mon) {
|
||||
string_cat_printf(temp_str, "\nExp: %02X/%02X", emv_data->exp_mon, emv_data->exp_year);
|
||||
furi_string_cat_printf(
|
||||
temp_str, "\nExp: %02X/%02X", emv_data->exp_mon, emv_data->exp_year);
|
||||
}
|
||||
// Parse currency code
|
||||
if((emv_data->currency_code)) {
|
||||
string_t currency_name;
|
||||
string_init(currency_name);
|
||||
FuriString* currency_name;
|
||||
currency_name = furi_string_alloc();
|
||||
if(nfc_emv_parser_get_currency_name(
|
||||
nfc->dev->storage, emv_data->currency_code, currency_name)) {
|
||||
string_cat_printf(temp_str, "\nCur: %s ", string_get_cstr(currency_name));
|
||||
furi_string_cat_printf(
|
||||
temp_str, "\nCur: %s ", furi_string_get_cstr(currency_name));
|
||||
}
|
||||
string_clear(currency_name);
|
||||
furi_string_free(currency_name);
|
||||
}
|
||||
// Parse country code
|
||||
if((emv_data->country_code)) {
|
||||
string_t country_name;
|
||||
string_init(country_name);
|
||||
FuriString* country_name;
|
||||
country_name = furi_string_alloc();
|
||||
if(nfc_emv_parser_get_country_name(
|
||||
nfc->dev->storage, emv_data->country_code, country_name)) {
|
||||
string_cat_printf(temp_str, "Reg: %s", string_get_cstr(country_name));
|
||||
furi_string_cat_printf(temp_str, "Reg: %s", furi_string_get_cstr(country_name));
|
||||
}
|
||||
string_clear(country_name);
|
||||
furi_string_free(country_name);
|
||||
}
|
||||
} else if(
|
||||
dev_data->protocol == NfcDeviceProtocolMifareClassic ||
|
||||
dev_data->protocol == NfcDeviceProtocolMifareUl) {
|
||||
string_set(temp_str, nfc->dev->dev_data.parsed_data);
|
||||
furi_string_set(temp_str, nfc->dev->dev_data.parsed_data);
|
||||
}
|
||||
|
||||
widget_add_text_scroll_element(nfc->widget, 0, 0, 128, 52, string_get_cstr(temp_str));
|
||||
string_clear(temp_str);
|
||||
widget_add_text_scroll_element(nfc->widget, 0, 0, 128, 52, furi_string_get_cstr(temp_str));
|
||||
furi_string_free(temp_str);
|
||||
|
||||
widget_add_button_element(
|
||||
nfc->widget, GuiButtonTypeRight, "More", nfc_scene_device_info_widget_callback, nfc);
|
||||
|
@@ -35,22 +35,22 @@ static void nfc_scene_emulate_uid_widget_config(Nfc* nfc, bool data_received) {
|
||||
FuriHalNfcDevData* data = &nfc->dev->dev_data.nfc_data;
|
||||
Widget* widget = nfc->widget;
|
||||
widget_reset(widget);
|
||||
string_t info_str;
|
||||
string_init(info_str);
|
||||
FuriString* info_str;
|
||||
info_str = furi_string_alloc();
|
||||
|
||||
widget_add_icon_element(widget, 0, 3, &I_RFIDDolphinSend_97x61);
|
||||
widget_add_string_element(widget, 89, 32, AlignCenter, AlignTop, FontPrimary, "Emulating UID");
|
||||
if(strcmp(nfc->dev->dev_name, "")) {
|
||||
string_printf(info_str, "%s", nfc->dev->dev_name);
|
||||
furi_string_printf(info_str, "%s", nfc->dev->dev_name);
|
||||
} else {
|
||||
for(uint8_t i = 0; i < data->uid_len; i++) {
|
||||
string_cat_printf(info_str, "%02X ", data->uid[i]);
|
||||
furi_string_cat_printf(info_str, "%02X ", data->uid[i]);
|
||||
}
|
||||
}
|
||||
string_strim(info_str);
|
||||
furi_string_trim(info_str);
|
||||
widget_add_text_box_element(
|
||||
widget, 56, 43, 70, 21, AlignCenter, AlignTop, string_get_cstr(info_str), true);
|
||||
string_clear(info_str);
|
||||
widget, 56, 43, 70, 21, AlignCenter, AlignTop, furi_string_get_cstr(info_str), true);
|
||||
furi_string_free(info_str);
|
||||
if(data_received) {
|
||||
widget_add_button_element(
|
||||
widget, GuiButtonTypeCenter, "Log", nfc_scene_emulate_uid_widget_callback, nfc);
|
||||
@@ -67,7 +67,7 @@ void nfc_scene_emulate_uid_on_enter(void* context) {
|
||||
TextBox* text_box = nfc->text_box;
|
||||
text_box_set_font(text_box, TextBoxFontHex);
|
||||
text_box_set_focus(text_box, TextBoxFocusEnd);
|
||||
string_reset(nfc->text_box_store);
|
||||
furi_string_reset(nfc->text_box_store);
|
||||
|
||||
// Set Widget state and view
|
||||
scene_manager_set_scene_state(
|
||||
@@ -94,17 +94,17 @@ bool nfc_scene_emulate_uid_on_event(void* context, SceneManagerEvent event) {
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == NfcCustomEventWorkerExit) {
|
||||
// Add data button to widget if data is received for the first time
|
||||
if(!string_size(nfc->text_box_store)) {
|
||||
if(!furi_string_size(nfc->text_box_store)) {
|
||||
nfc_scene_emulate_uid_widget_config(nfc, true);
|
||||
}
|
||||
// Update TextBox data
|
||||
if(string_size(nfc->text_box_store) < NFC_SCENE_EMULATE_UID_LOG_SIZE_MAX) {
|
||||
string_cat_printf(nfc->text_box_store, "R:");
|
||||
if(furi_string_size(nfc->text_box_store) < NFC_SCENE_EMULATE_UID_LOG_SIZE_MAX) {
|
||||
furi_string_cat_printf(nfc->text_box_store, "R:");
|
||||
for(uint16_t i = 0; i < reader_data->size; i++) {
|
||||
string_cat_printf(nfc->text_box_store, " %02X", reader_data->data[i]);
|
||||
furi_string_cat_printf(nfc->text_box_store, " %02X", reader_data->data[i]);
|
||||
}
|
||||
string_push_back(nfc->text_box_store, '\n');
|
||||
text_box_set_text(nfc->text_box, string_get_cstr(nfc->text_box_store));
|
||||
furi_string_push_back(nfc->text_box_store, '\n');
|
||||
text_box_set_text(nfc->text_box, furi_string_get_cstr(nfc->text_box_store));
|
||||
}
|
||||
memset(reader_data, 0, sizeof(NfcReaderRequestData));
|
||||
consumed = true;
|
||||
@@ -140,7 +140,7 @@ void nfc_scene_emulate_uid_on_exit(void* context) {
|
||||
// Clear view
|
||||
widget_reset(nfc->widget);
|
||||
text_box_reset(nfc->text_box);
|
||||
string_reset(nfc->text_box_store);
|
||||
furi_string_reset(nfc->text_box_store);
|
||||
|
||||
nfc_blink_stop(nfc);
|
||||
}
|
||||
|
@@ -23,42 +23,44 @@ void nfc_scene_emv_read_success_on_enter(void* context) {
|
||||
widget_add_button_element(
|
||||
nfc->widget, GuiButtonTypeRight, "More", nfc_scene_emv_read_success_widget_callback, nfc);
|
||||
|
||||
string_t temp_str;
|
||||
string_init_printf(temp_str, "\e#%s\n", emv_data->name);
|
||||
FuriString* temp_str;
|
||||
temp_str = furi_string_alloc_printf("\e#%s\n", emv_data->name);
|
||||
for(uint8_t i = 0; i < emv_data->number_len; i += 2) {
|
||||
string_cat_printf(temp_str, "%02X%02X ", emv_data->number[i], emv_data->number[i + 1]);
|
||||
furi_string_cat_printf(
|
||||
temp_str, "%02X%02X ", emv_data->number[i], emv_data->number[i + 1]);
|
||||
}
|
||||
string_strim(temp_str);
|
||||
furi_string_trim(temp_str);
|
||||
|
||||
// Add expiration date
|
||||
if(emv_data->exp_mon) {
|
||||
string_cat_printf(temp_str, "\nExp: %02X/%02X", emv_data->exp_mon, emv_data->exp_year);
|
||||
furi_string_cat_printf(
|
||||
temp_str, "\nExp: %02X/%02X", emv_data->exp_mon, emv_data->exp_year);
|
||||
}
|
||||
// Parse currency code
|
||||
if((emv_data->currency_code)) {
|
||||
string_t currency_name;
|
||||
string_init(currency_name);
|
||||
FuriString* currency_name;
|
||||
currency_name = furi_string_alloc();
|
||||
if(nfc_emv_parser_get_currency_name(
|
||||
nfc->dev->storage, emv_data->currency_code, currency_name)) {
|
||||
string_cat_printf(temp_str, "\nCur: %s ", string_get_cstr(currency_name));
|
||||
furi_string_cat_printf(temp_str, "\nCur: %s ", furi_string_get_cstr(currency_name));
|
||||
}
|
||||
string_clear(currency_name);
|
||||
furi_string_free(currency_name);
|
||||
}
|
||||
// Parse country code
|
||||
if((emv_data->country_code)) {
|
||||
string_t country_name;
|
||||
string_init(country_name);
|
||||
FuriString* country_name;
|
||||
country_name = furi_string_alloc();
|
||||
if(nfc_emv_parser_get_country_name(
|
||||
nfc->dev->storage, emv_data->country_code, country_name)) {
|
||||
string_cat_printf(temp_str, "Reg: %s", string_get_cstr(country_name));
|
||||
furi_string_cat_printf(temp_str, "Reg: %s", furi_string_get_cstr(country_name));
|
||||
}
|
||||
string_clear(country_name);
|
||||
furi_string_free(country_name);
|
||||
}
|
||||
|
||||
notification_message_block(nfc->notifications, &sequence_set_green_255);
|
||||
|
||||
widget_add_text_scroll_element(nfc->widget, 0, 0, 128, 52, string_get_cstr(temp_str));
|
||||
string_clear(temp_str);
|
||||
widget_add_text_scroll_element(nfc->widget, 0, 0, 128, 52, furi_string_get_cstr(temp_str));
|
||||
furi_string_free(temp_str);
|
||||
|
||||
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewWidget);
|
||||
}
|
||||
|
@@ -16,15 +16,15 @@ void nfc_scene_generate_info_on_enter(void* context) {
|
||||
dialog_ex_set_right_button_text(dialog_ex, "More");
|
||||
|
||||
// Create info text
|
||||
string_t info_str;
|
||||
string_init_printf(
|
||||
info_str, "%s\n%s\nUID:", nfc->generator->name, nfc_get_dev_type(data->type));
|
||||
FuriString* info_str = furi_string_alloc_printf(
|
||||
"%s\n%s\nUID:", nfc->generator->name, nfc_get_dev_type(data->type));
|
||||
|
||||
// Append UID
|
||||
for(int i = 0; i < data->uid_len; ++i) {
|
||||
string_cat_printf(info_str, " %02X", data->uid[i]);
|
||||
furi_string_cat_printf(info_str, " %02X", data->uid[i]);
|
||||
}
|
||||
nfc_text_store_set(nfc, string_get_cstr(info_str));
|
||||
string_clear(info_str);
|
||||
nfc_text_store_set(nfc, furi_string_get_cstr(info_str));
|
||||
furi_string_free(info_str);
|
||||
|
||||
dialog_ex_set_text(dialog_ex, nfc->text_store, 0, 0, AlignLeft, AlignTop);
|
||||
dialog_ex_set_context(dialog_ex, nfc);
|
||||
|
@@ -16,8 +16,8 @@ void nfc_scene_mf_classic_keys_delete_on_enter(void* context) {
|
||||
uint32_t key_index =
|
||||
scene_manager_get_scene_state(nfc->scene_manager, NfcSceneMfClassicKeysDelete);
|
||||
// Setup Custom Widget view
|
||||
string_t key_str;
|
||||
string_init(key_str);
|
||||
FuriString* key_str;
|
||||
key_str = furi_string_alloc();
|
||||
|
||||
widget_add_string_element(
|
||||
nfc->widget, 64, 0, AlignCenter, AlignTop, FontPrimary, "Delete this key?");
|
||||
@@ -36,9 +36,15 @@ void nfc_scene_mf_classic_keys_delete_on_enter(void* context) {
|
||||
|
||||
mf_classic_dict_get_key_at_index_str(dict, key_str, key_index);
|
||||
widget_add_string_element(
|
||||
nfc->widget, 64, 32, AlignCenter, AlignCenter, FontSecondary, string_get_cstr(key_str));
|
||||
nfc->widget,
|
||||
64,
|
||||
32,
|
||||
AlignCenter,
|
||||
AlignCenter,
|
||||
FontSecondary,
|
||||
furi_string_get_cstr(key_str));
|
||||
|
||||
string_clear(key_str);
|
||||
furi_string_free(key_str);
|
||||
mf_classic_dict_free(dict);
|
||||
|
||||
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewWidget);
|
||||
|
@@ -19,19 +19,19 @@ void nfc_scene_mf_classic_keys_list_popup_callback(void* context) {
|
||||
void nfc_scene_mf_classic_keys_list_prepare(Nfc* nfc, MfClassicDict* dict) {
|
||||
Submenu* submenu = nfc->submenu;
|
||||
uint32_t index = 0;
|
||||
string_t temp_key;
|
||||
string_init(temp_key);
|
||||
FuriString* temp_key;
|
||||
temp_key = furi_string_alloc();
|
||||
|
||||
submenu_set_header(submenu, "Select key to delete:");
|
||||
while(mf_classic_dict_get_next_key_str(dict, temp_key)) {
|
||||
char* current_key = (char*)malloc(sizeof(char) * 13);
|
||||
strncpy(current_key, string_get_cstr(temp_key), 12);
|
||||
strncpy(current_key, furi_string_get_cstr(temp_key), 12);
|
||||
MfClassicUserKeys_push_back(nfc->mfc_key_strs, current_key);
|
||||
FURI_LOG_D("ListKeys", "Key %d: %s", index, current_key);
|
||||
submenu_add_item(
|
||||
submenu, current_key, index++, nfc_scene_mf_classic_keys_list_submenu_callback, nfc);
|
||||
}
|
||||
string_clear(temp_key);
|
||||
furi_string_free(temp_key);
|
||||
}
|
||||
|
||||
void nfc_scene_mf_classic_keys_list_on_enter(void* context) {
|
||||
|
@@ -27,26 +27,26 @@ void nfc_scene_mf_classic_read_success_on_enter(void* context) {
|
||||
widget_add_button_element(
|
||||
widget, GuiButtonTypeRight, "More", nfc_scene_mf_classic_read_success_widget_callback, nfc);
|
||||
|
||||
string_t temp_str;
|
||||
if(string_size(nfc->dev->dev_data.parsed_data)) {
|
||||
string_init_set(temp_str, nfc->dev->dev_data.parsed_data);
|
||||
FuriString* temp_str;
|
||||
if(furi_string_size(nfc->dev->dev_data.parsed_data)) {
|
||||
temp_str = furi_string_alloc_set(nfc->dev->dev_data.parsed_data);
|
||||
} else {
|
||||
string_init_printf(temp_str, "\e#%s\n", nfc_mf_classic_type(mf_data->type));
|
||||
string_cat_printf(temp_str, "UID:");
|
||||
temp_str = furi_string_alloc_printf("\e#%s\n", nfc_mf_classic_type(mf_data->type));
|
||||
furi_string_cat_printf(temp_str, "UID:");
|
||||
for(size_t i = 0; i < dev_data->nfc_data.uid_len; i++) {
|
||||
string_cat_printf(temp_str, " %02X", dev_data->nfc_data.uid[i]);
|
||||
furi_string_cat_printf(temp_str, " %02X", dev_data->nfc_data.uid[i]);
|
||||
}
|
||||
uint8_t sectors_total = mf_classic_get_total_sectors_num(mf_data->type);
|
||||
uint8_t keys_total = sectors_total * 2;
|
||||
uint8_t keys_found = 0;
|
||||
uint8_t sectors_read = 0;
|
||||
mf_classic_get_read_sectors_and_keys(mf_data, §ors_read, &keys_found);
|
||||
string_cat_printf(temp_str, "\nKeys Found: %d/%d", keys_found, keys_total);
|
||||
string_cat_printf(temp_str, "\nSectors Read: %d/%d", sectors_read, sectors_total);
|
||||
furi_string_cat_printf(temp_str, "\nKeys Found: %d/%d", keys_found, keys_total);
|
||||
furi_string_cat_printf(temp_str, "\nSectors Read: %d/%d", sectors_read, sectors_total);
|
||||
}
|
||||
|
||||
widget_add_text_scroll_element(widget, 0, 0, 128, 52, string_get_cstr(temp_str));
|
||||
string_clear(temp_str);
|
||||
widget_add_text_scroll_element(widget, 0, 0, 128, 52, furi_string_get_cstr(temp_str));
|
||||
furi_string_free(temp_str);
|
||||
|
||||
notification_message_block(nfc->notifications, &sequence_set_green_255);
|
||||
|
||||
|
@@ -84,7 +84,7 @@ bool nfc_scene_mf_desfire_app_on_event(void* context, SceneManagerEvent event) {
|
||||
} else {
|
||||
MifareDesfireApplication* app = nfc_scene_mf_desfire_app_get_app(nfc);
|
||||
TextBox* text_box = nfc->text_box;
|
||||
string_reset(nfc->text_box_store);
|
||||
furi_string_reset(nfc->text_box_store);
|
||||
if(event.event == SubmenuIndexAppInfo) {
|
||||
mf_df_cat_application_info(app, nfc->text_box_store);
|
||||
} else {
|
||||
@@ -98,7 +98,7 @@ bool nfc_scene_mf_desfire_app_on_event(void* context, SceneManagerEvent event) {
|
||||
}
|
||||
mf_df_cat_file(file, nfc->text_box_store);
|
||||
}
|
||||
text_box_set_text(text_box, string_get_cstr(nfc->text_box_store));
|
||||
text_box_set_text(text_box, furi_string_get_cstr(nfc->text_box_store));
|
||||
scene_manager_set_scene_state(nfc->scene_manager, NfcSceneMfDesfireApp, state | 1);
|
||||
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewTextBox);
|
||||
consumed = true;
|
||||
@@ -120,6 +120,6 @@ void nfc_scene_mf_desfire_app_on_exit(void* context) {
|
||||
// Clear views
|
||||
popup_reset(nfc->popup);
|
||||
text_box_reset(nfc->text_box);
|
||||
string_reset(nfc->text_box_store);
|
||||
furi_string_reset(nfc->text_box_store);
|
||||
submenu_reset(nfc->submenu);
|
||||
}
|
||||
|
@@ -67,10 +67,10 @@ bool nfc_scene_mf_desfire_data_on_event(void* context, SceneManagerEvent event)
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
TextBox* text_box = nfc->text_box;
|
||||
string_reset(nfc->text_box_store);
|
||||
furi_string_reset(nfc->text_box_store);
|
||||
if(event.event == SubmenuIndexCardInfo) {
|
||||
mf_df_cat_card_info(data, nfc->text_box_store);
|
||||
text_box_set_text(text_box, string_get_cstr(nfc->text_box_store));
|
||||
text_box_set_text(text_box, furi_string_get_cstr(nfc->text_box_store));
|
||||
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewTextBox);
|
||||
scene_manager_set_scene_state(
|
||||
nfc->scene_manager,
|
||||
@@ -102,6 +102,6 @@ void nfc_scene_mf_desfire_data_on_exit(void* context) {
|
||||
|
||||
// Clear views
|
||||
text_box_reset(nfc->text_box);
|
||||
string_reset(nfc->text_box_store);
|
||||
furi_string_reset(nfc->text_box_store);
|
||||
submenu_reset(nfc->submenu);
|
||||
}
|
||||
|
@@ -20,20 +20,19 @@ void nfc_scene_mf_desfire_read_success_on_enter(void* context) {
|
||||
Widget* widget = nfc->widget;
|
||||
|
||||
// Prepare string for data display
|
||||
string_t temp_str;
|
||||
string_init_printf(temp_str, "\e#MIFARE DESfire\n");
|
||||
string_cat_printf(temp_str, "UID:");
|
||||
FuriString* temp_str = furi_string_alloc_printf("\e#MIFARE DESfire\n");
|
||||
furi_string_cat_printf(temp_str, "UID:");
|
||||
for(size_t i = 0; i < nfc_data->uid_len; i++) {
|
||||
string_cat_printf(temp_str, " %02X", nfc_data->uid[i]);
|
||||
furi_string_cat_printf(temp_str, " %02X", nfc_data->uid[i]);
|
||||
}
|
||||
|
||||
uint32_t bytes_total = 1 << (data->version.sw_storage >> 1);
|
||||
uint32_t bytes_free = data->free_memory ? data->free_memory->bytes : 0;
|
||||
string_cat_printf(temp_str, "\n%d", bytes_total);
|
||||
furi_string_cat_printf(temp_str, "\n%d", bytes_total);
|
||||
if(data->version.sw_storage & 1) {
|
||||
string_push_back(temp_str, '+');
|
||||
furi_string_push_back(temp_str, '+');
|
||||
}
|
||||
string_cat_printf(temp_str, " bytes, %d bytes free\n", bytes_free);
|
||||
furi_string_cat_printf(temp_str, " bytes, %d bytes free\n", bytes_free);
|
||||
|
||||
uint16_t n_apps = 0;
|
||||
uint16_t n_files = 0;
|
||||
@@ -43,20 +42,20 @@ void nfc_scene_mf_desfire_read_success_on_enter(void* context) {
|
||||
n_files++;
|
||||
}
|
||||
}
|
||||
string_cat_printf(temp_str, "%d Application", n_apps);
|
||||
furi_string_cat_printf(temp_str, "%d Application", n_apps);
|
||||
if(n_apps != 1) {
|
||||
string_push_back(temp_str, 's');
|
||||
furi_string_push_back(temp_str, 's');
|
||||
}
|
||||
string_cat_printf(temp_str, ", %d file", n_files);
|
||||
furi_string_cat_printf(temp_str, ", %d file", n_files);
|
||||
if(n_files != 1) {
|
||||
string_push_back(temp_str, 's');
|
||||
furi_string_push_back(temp_str, 's');
|
||||
}
|
||||
|
||||
notification_message_block(nfc->notifications, &sequence_set_green_255);
|
||||
|
||||
// Add text scroll element
|
||||
widget_add_text_scroll_element(widget, 0, 0, 128, 52, string_get_cstr(temp_str));
|
||||
string_clear(temp_str);
|
||||
widget_add_text_scroll_element(widget, 0, 0, 128, 52, furi_string_get_cstr(temp_str));
|
||||
furi_string_free(temp_str);
|
||||
|
||||
// Add button elements
|
||||
widget_add_button_element(
|
||||
|
@@ -8,11 +8,11 @@ void nfc_scene_mf_ultralight_data_on_enter(void* context) {
|
||||
text_box_set_font(text_box, TextBoxFontHex);
|
||||
for(uint16_t i = 0; i < data->data_size; i += 2) {
|
||||
if(!(i % 8) && i) {
|
||||
string_push_back(nfc->text_box_store, '\n');
|
||||
furi_string_push_back(nfc->text_box_store, '\n');
|
||||
}
|
||||
string_cat_printf(nfc->text_box_store, "%02X%02X ", data->data[i], data->data[i + 1]);
|
||||
furi_string_cat_printf(nfc->text_box_store, "%02X%02X ", data->data[i], data->data[i + 1]);
|
||||
}
|
||||
text_box_set_text(text_box, string_get_cstr(nfc->text_box_store));
|
||||
text_box_set_text(text_box, furi_string_get_cstr(nfc->text_box_store));
|
||||
|
||||
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewTextBox);
|
||||
}
|
||||
@@ -28,5 +28,5 @@ void nfc_scene_mf_ultralight_data_on_exit(void* context) {
|
||||
|
||||
// Clean view
|
||||
text_box_reset(nfc->text_box);
|
||||
string_reset(nfc->text_box_store);
|
||||
furi_string_reset(nfc->text_box_store);
|
||||
}
|
@@ -21,8 +21,8 @@ void nfc_scene_mf_ultralight_read_auth_result_on_enter(void* context) {
|
||||
MfUltralightData* mf_ul_data = &nfc->dev->dev_data.mf_ul_data;
|
||||
MfUltralightConfigPages* config_pages = mf_ultralight_get_config_pages(mf_ul_data);
|
||||
Widget* widget = nfc->widget;
|
||||
string_t temp_str;
|
||||
string_init(temp_str);
|
||||
FuriString* temp_str;
|
||||
temp_str = furi_string_alloc();
|
||||
|
||||
if((mf_ul_data->data_read == mf_ul_data->data_size) && (mf_ul_data->data_read > 0)) {
|
||||
widget_add_string_element(
|
||||
@@ -31,14 +31,14 @@ void nfc_scene_mf_ultralight_read_auth_result_on_enter(void* context) {
|
||||
widget_add_string_element(
|
||||
widget, 64, 0, AlignCenter, AlignTop, FontPrimary, "Not all pages unlocked!");
|
||||
}
|
||||
string_set_str(temp_str, "UID:");
|
||||
furi_string_set(temp_str, "UID:");
|
||||
for(size_t i = 0; i < nfc_data->uid_len; i++) {
|
||||
string_cat_printf(temp_str, " %02X", nfc_data->uid[i]);
|
||||
furi_string_cat_printf(temp_str, " %02X", nfc_data->uid[i]);
|
||||
}
|
||||
widget_add_string_element(
|
||||
widget, 0, 17, AlignLeft, AlignTop, FontSecondary, string_get_cstr(temp_str));
|
||||
widget, 0, 17, AlignLeft, AlignTop, FontSecondary, furi_string_get_cstr(temp_str));
|
||||
if(mf_ul_data->auth_success) {
|
||||
string_printf(
|
||||
furi_string_printf(
|
||||
temp_str,
|
||||
"Password: %02X %02X %02X %02X",
|
||||
config_pages->auth_data.pwd.raw[0],
|
||||
@@ -46,19 +46,19 @@ void nfc_scene_mf_ultralight_read_auth_result_on_enter(void* context) {
|
||||
config_pages->auth_data.pwd.raw[2],
|
||||
config_pages->auth_data.pwd.raw[3]);
|
||||
widget_add_string_element(
|
||||
widget, 0, 28, AlignLeft, AlignTop, FontSecondary, string_get_cstr(temp_str));
|
||||
string_printf(
|
||||
widget, 0, 28, AlignLeft, AlignTop, FontSecondary, furi_string_get_cstr(temp_str));
|
||||
furi_string_printf(
|
||||
temp_str,
|
||||
"PACK: %02X %02X",
|
||||
config_pages->auth_data.pack.raw[0],
|
||||
config_pages->auth_data.pack.raw[1]);
|
||||
widget_add_string_element(
|
||||
widget, 0, 39, AlignLeft, AlignTop, FontSecondary, string_get_cstr(temp_str));
|
||||
widget, 0, 39, AlignLeft, AlignTop, FontSecondary, furi_string_get_cstr(temp_str));
|
||||
}
|
||||
string_printf(
|
||||
furi_string_printf(
|
||||
temp_str, "Pages Read: %d/%d", mf_ul_data->data_read / 4, mf_ul_data->data_size / 4);
|
||||
widget_add_string_element(
|
||||
widget, 0, 50, AlignLeft, AlignTop, FontSecondary, string_get_cstr(temp_str));
|
||||
widget, 0, 50, AlignLeft, AlignTop, FontSecondary, furi_string_get_cstr(temp_str));
|
||||
widget_add_button_element(
|
||||
widget,
|
||||
GuiButtonTypeRight,
|
||||
@@ -66,7 +66,7 @@ void nfc_scene_mf_ultralight_read_auth_result_on_enter(void* context) {
|
||||
nfc_scene_mf_ultralight_read_auth_result_widget_callback,
|
||||
nfc);
|
||||
|
||||
string_clear(temp_str);
|
||||
furi_string_free(temp_str);
|
||||
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewWidget);
|
||||
}
|
||||
|
||||
|
@@ -33,23 +33,23 @@ void nfc_scene_mf_ultralight_read_success_on_enter(void* context) {
|
||||
nfc_scene_mf_ultralight_read_success_widget_callback,
|
||||
nfc);
|
||||
|
||||
string_t temp_str;
|
||||
if(string_size(nfc->dev->dev_data.parsed_data)) {
|
||||
string_init_set(temp_str, nfc->dev->dev_data.parsed_data);
|
||||
FuriString* temp_str;
|
||||
if(furi_string_size(nfc->dev->dev_data.parsed_data)) {
|
||||
temp_str = furi_string_alloc_set(nfc->dev->dev_data.parsed_data);
|
||||
} else {
|
||||
string_init_printf(temp_str, "\e#%s\n", nfc_mf_ul_type(mf_ul_data->type, true));
|
||||
string_cat_printf(temp_str, "UID:");
|
||||
temp_str = furi_string_alloc_printf("\e#%s\n", nfc_mf_ul_type(mf_ul_data->type, true));
|
||||
furi_string_cat_printf(temp_str, "UID:");
|
||||
for(size_t i = 0; i < data->uid_len; i++) {
|
||||
string_cat_printf(temp_str, " %02X", data->uid[i]);
|
||||
furi_string_cat_printf(temp_str, " %02X", data->uid[i]);
|
||||
}
|
||||
string_cat_printf(
|
||||
furi_string_cat_printf(
|
||||
temp_str, "\nPages Read: %d/%d", mf_ul_data->data_read / 4, mf_ul_data->data_size / 4);
|
||||
if(mf_ul_data->data_read != mf_ul_data->data_size) {
|
||||
string_cat_printf(temp_str, "\nPassword-protected pages!");
|
||||
furi_string_cat_printf(temp_str, "\nPassword-protected pages!");
|
||||
}
|
||||
}
|
||||
widget_add_text_scroll_element(widget, 0, 0, 128, 52, string_get_cstr(temp_str));
|
||||
string_clear(temp_str);
|
||||
widget_add_text_scroll_element(widget, 0, 0, 128, 52, furi_string_get_cstr(temp_str));
|
||||
furi_string_free(temp_str);
|
||||
|
||||
notification_message_block(nfc->notifications, &sequence_set_green_255);
|
||||
|
||||
|
@@ -11,21 +11,21 @@ void nfc_scene_mfkey_nonces_info_callback(GuiButtonType result, InputType type,
|
||||
void nfc_scene_mfkey_nonces_info_on_enter(void* context) {
|
||||
Nfc* nfc = context;
|
||||
|
||||
string_t temp_str;
|
||||
string_init(temp_str);
|
||||
FuriString* temp_str;
|
||||
temp_str = furi_string_alloc();
|
||||
|
||||
uint16_t nonces_saved = mfkey32_get_auth_sectors(temp_str);
|
||||
widget_add_text_scroll_element(nfc->widget, 0, 22, 128, 42, string_get_cstr(temp_str));
|
||||
string_printf(temp_str, "Nonces saved %d", nonces_saved);
|
||||
widget_add_text_scroll_element(nfc->widget, 0, 22, 128, 42, furi_string_get_cstr(temp_str));
|
||||
furi_string_printf(temp_str, "Nonces saved %d", nonces_saved);
|
||||
widget_add_string_element(
|
||||
nfc->widget, 0, 0, AlignLeft, AlignTop, FontPrimary, string_get_cstr(temp_str));
|
||||
nfc->widget, 0, 0, AlignLeft, AlignTop, FontPrimary, furi_string_get_cstr(temp_str));
|
||||
widget_add_string_element(
|
||||
nfc->widget, 0, 12, AlignLeft, AlignTop, FontSecondary, "Authenticated sectors:");
|
||||
|
||||
widget_add_button_element(
|
||||
nfc->widget, GuiButtonTypeRight, "Next", nfc_scene_mfkey_nonces_info_callback, nfc);
|
||||
|
||||
string_clear(temp_str);
|
||||
furi_string_free(temp_str);
|
||||
|
||||
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewWidget);
|
||||
}
|
||||
|
@@ -22,47 +22,48 @@ void nfc_scene_nfc_data_info_on_enter(void* context) {
|
||||
text_scroll_height = 64;
|
||||
}
|
||||
|
||||
string_t temp_str;
|
||||
string_init(temp_str);
|
||||
FuriString* temp_str;
|
||||
temp_str = furi_string_alloc();
|
||||
// Set name if present
|
||||
if(nfc->dev->dev_name[0] != '\0') {
|
||||
string_printf(temp_str, "\ec%s\n", nfc->dev->dev_name);
|
||||
furi_string_printf(temp_str, "\ec%s\n", nfc->dev->dev_name);
|
||||
}
|
||||
|
||||
// Set tag type
|
||||
if(protocol == NfcDeviceProtocolEMV) {
|
||||
string_cat_printf(temp_str, "\e#EMV Bank Card\n");
|
||||
furi_string_cat_printf(temp_str, "\e#EMV Bank Card\n");
|
||||
} else if(protocol == NfcDeviceProtocolMifareUl) {
|
||||
string_cat_printf(temp_str, "\e#%s\n", nfc_mf_ul_type(dev_data->mf_ul_data.type, true));
|
||||
furi_string_cat_printf(
|
||||
temp_str, "\e#%s\n", nfc_mf_ul_type(dev_data->mf_ul_data.type, true));
|
||||
} else if(protocol == NfcDeviceProtocolMifareClassic) {
|
||||
string_cat_printf(
|
||||
furi_string_cat_printf(
|
||||
temp_str, "\e#%s\n", nfc_mf_classic_type(dev_data->mf_classic_data.type));
|
||||
} else if(protocol == NfcDeviceProtocolMifareDesfire) {
|
||||
string_cat_printf(temp_str, "\e#MIFARE DESfire\n");
|
||||
furi_string_cat_printf(temp_str, "\e#MIFARE DESfire\n");
|
||||
} else {
|
||||
string_cat_printf(temp_str, "\e#Unknown ISO tag\n");
|
||||
furi_string_cat_printf(temp_str, "\e#Unknown ISO tag\n");
|
||||
}
|
||||
|
||||
// Set tag iso data
|
||||
char iso_type = FURI_BIT(nfc_data->sak, 5) ? '4' : '3';
|
||||
string_cat_printf(temp_str, "ISO 14443-%c (NFC-A)\n", iso_type);
|
||||
string_cat_printf(temp_str, "UID:");
|
||||
furi_string_cat_printf(temp_str, "ISO 14443-%c (NFC-A)\n", iso_type);
|
||||
furi_string_cat_printf(temp_str, "UID:");
|
||||
for(size_t i = 0; i < nfc_data->uid_len; i++) {
|
||||
string_cat_printf(temp_str, " %02X", nfc_data->uid[i]);
|
||||
furi_string_cat_printf(temp_str, " %02X", nfc_data->uid[i]);
|
||||
}
|
||||
string_cat_printf(temp_str, "\nATQA: %02X %02X ", nfc_data->atqa[1], nfc_data->atqa[0]);
|
||||
string_cat_printf(temp_str, " SAK: %02X", nfc_data->sak);
|
||||
furi_string_cat_printf(temp_str, "\nATQA: %02X %02X ", nfc_data->atqa[1], nfc_data->atqa[0]);
|
||||
furi_string_cat_printf(temp_str, " SAK: %02X", nfc_data->sak);
|
||||
|
||||
// Set application specific data
|
||||
if(protocol == NfcDeviceProtocolMifareDesfire) {
|
||||
MifareDesfireData* data = &dev_data->mf_df_data;
|
||||
uint32_t bytes_total = 1 << (data->version.sw_storage >> 1);
|
||||
uint32_t bytes_free = data->free_memory ? data->free_memory->bytes : 0;
|
||||
string_cat_printf(temp_str, "\n%d", bytes_total);
|
||||
furi_string_cat_printf(temp_str, "\n%d", bytes_total);
|
||||
if(data->version.sw_storage & 1) {
|
||||
string_push_back(temp_str, '+');
|
||||
furi_string_push_back(temp_str, '+');
|
||||
}
|
||||
string_cat_printf(temp_str, " bytes, %d bytes free\n", bytes_free);
|
||||
furi_string_cat_printf(temp_str, " bytes, %d bytes free\n", bytes_free);
|
||||
|
||||
uint16_t n_apps = 0;
|
||||
uint16_t n_files = 0;
|
||||
@@ -72,20 +73,20 @@ void nfc_scene_nfc_data_info_on_enter(void* context) {
|
||||
n_files++;
|
||||
}
|
||||
}
|
||||
string_cat_printf(temp_str, "%d Application", n_apps);
|
||||
furi_string_cat_printf(temp_str, "%d Application", n_apps);
|
||||
if(n_apps != 1) {
|
||||
string_push_back(temp_str, 's');
|
||||
furi_string_push_back(temp_str, 's');
|
||||
}
|
||||
string_cat_printf(temp_str, ", %d file", n_files);
|
||||
furi_string_cat_printf(temp_str, ", %d file", n_files);
|
||||
if(n_files != 1) {
|
||||
string_push_back(temp_str, 's');
|
||||
furi_string_push_back(temp_str, 's');
|
||||
}
|
||||
} else if(protocol == NfcDeviceProtocolMifareUl) {
|
||||
MfUltralightData* data = &dev_data->mf_ul_data;
|
||||
string_cat_printf(
|
||||
furi_string_cat_printf(
|
||||
temp_str, "\nPages Read %d/%d", data->data_read / 4, data->data_size / 4);
|
||||
if(data->data_size > data->data_read) {
|
||||
string_cat_printf(temp_str, "\nPassword-protected");
|
||||
furi_string_cat_printf(temp_str, "\nPassword-protected");
|
||||
}
|
||||
} else if(protocol == NfcDeviceProtocolMifareClassic) {
|
||||
MfClassicData* data = &dev_data->mf_classic_data;
|
||||
@@ -94,14 +95,14 @@ void nfc_scene_nfc_data_info_on_enter(void* context) {
|
||||
uint8_t keys_found = 0;
|
||||
uint8_t sectors_read = 0;
|
||||
mf_classic_get_read_sectors_and_keys(data, §ors_read, &keys_found);
|
||||
string_cat_printf(temp_str, "\nKeys Found %d/%d", keys_found, keys_total);
|
||||
string_cat_printf(temp_str, "\nSectors Read %d/%d", sectors_read, sectors_total);
|
||||
furi_string_cat_printf(temp_str, "\nKeys Found %d/%d", keys_found, keys_total);
|
||||
furi_string_cat_printf(temp_str, "\nSectors Read %d/%d", sectors_read, sectors_total);
|
||||
}
|
||||
|
||||
// Add text scroll widget
|
||||
widget_add_text_scroll_element(
|
||||
widget, 0, 0, 128, text_scroll_height, string_get_cstr(temp_str));
|
||||
string_clear(temp_str);
|
||||
widget, 0, 0, 128, text_scroll_height, furi_string_get_cstr(temp_str));
|
||||
furi_string_free(temp_str);
|
||||
|
||||
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewWidget);
|
||||
}
|
||||
|
@@ -22,22 +22,22 @@ void nfc_scene_nfca_read_success_on_enter(void* context) {
|
||||
FuriHalNfcDevData* data = &nfc->dev->dev_data.nfc_data;
|
||||
Widget* widget = nfc->widget;
|
||||
|
||||
string_t temp_str;
|
||||
string_init_set_str(temp_str, "\e#Unknown ISO tag\n");
|
||||
FuriString* temp_str;
|
||||
temp_str = furi_string_alloc_set("\e#Unknown ISO tag\n");
|
||||
|
||||
notification_message_block(nfc->notifications, &sequence_set_green_255);
|
||||
|
||||
char iso_type = FURI_BIT(data->sak, 5) ? '4' : '3';
|
||||
string_cat_printf(temp_str, "ISO 14443-%c (NFC-A)\n", iso_type);
|
||||
string_cat_printf(temp_str, "UID:");
|
||||
furi_string_cat_printf(temp_str, "ISO 14443-%c (NFC-A)\n", iso_type);
|
||||
furi_string_cat_printf(temp_str, "UID:");
|
||||
for(size_t i = 0; i < data->uid_len; i++) {
|
||||
string_cat_printf(temp_str, " %02X", data->uid[i]);
|
||||
furi_string_cat_printf(temp_str, " %02X", data->uid[i]);
|
||||
}
|
||||
string_cat_printf(temp_str, "\nATQA: %02X %02X ", data->atqa[1], data->atqa[0]);
|
||||
string_cat_printf(temp_str, " SAK: %02X", data->sak);
|
||||
furi_string_cat_printf(temp_str, "\nATQA: %02X %02X ", data->atqa[1], data->atqa[0]);
|
||||
furi_string_cat_printf(temp_str, " SAK: %02X", data->sak);
|
||||
|
||||
widget_add_text_scroll_element(widget, 0, 0, 128, 52, string_get_cstr(temp_str));
|
||||
string_clear(temp_str);
|
||||
widget_add_text_scroll_element(widget, 0, 0, 128, 52, furi_string_get_cstr(temp_str));
|
||||
furi_string_free(temp_str);
|
||||
|
||||
widget_add_button_element(
|
||||
widget, GuiButtonTypeLeft, "Retry", nfc_scene_nfca_read_success_widget_callback, nfc);
|
||||
|
@@ -16,26 +16,26 @@ void nfc_scene_read_card_success_widget_callback(
|
||||
void nfc_scene_read_card_success_on_enter(void* context) {
|
||||
Nfc* nfc = context;
|
||||
|
||||
string_t temp_str;
|
||||
string_init(temp_str);
|
||||
FuriString* temp_str;
|
||||
temp_str = furi_string_alloc();
|
||||
DOLPHIN_DEED(DolphinDeedNfcReadSuccess);
|
||||
|
||||
// Setup view
|
||||
FuriHalNfcDevData* data = &nfc->dev->dev_data.nfc_data;
|
||||
Widget* widget = nfc->widget;
|
||||
string_set_str(temp_str, nfc_get_dev_type(data->type));
|
||||
furi_string_set(temp_str, nfc_get_dev_type(data->type));
|
||||
widget_add_string_element(
|
||||
widget, 64, 12, AlignCenter, AlignBottom, FontPrimary, string_get_cstr(temp_str));
|
||||
string_set_str(temp_str, "UID:");
|
||||
widget, 64, 12, AlignCenter, AlignBottom, FontPrimary, furi_string_get_cstr(temp_str));
|
||||
furi_string_set(temp_str, "UID:");
|
||||
for(uint8_t i = 0; i < data->uid_len; i++) {
|
||||
string_cat_printf(temp_str, " %02X", data->uid[i]);
|
||||
furi_string_cat_printf(temp_str, " %02X", data->uid[i]);
|
||||
}
|
||||
widget_add_string_element(
|
||||
widget, 64, 32, AlignCenter, AlignCenter, FontSecondary, string_get_cstr(temp_str));
|
||||
widget, 64, 32, AlignCenter, AlignCenter, FontSecondary, furi_string_get_cstr(temp_str));
|
||||
widget_add_button_element(
|
||||
widget, GuiButtonTypeLeft, "Retry", nfc_scene_read_card_success_widget_callback, nfc);
|
||||
|
||||
string_clear(temp_str);
|
||||
furi_string_free(temp_str);
|
||||
|
||||
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewWidget);
|
||||
}
|
||||
|
@@ -1,5 +1,4 @@
|
||||
#include "../nfc_i.h"
|
||||
#include "m-string.h"
|
||||
#include <lib/toolbox/random_name.h>
|
||||
#include <gui/modules/validators.h>
|
||||
#include <toolbox/path.h>
|
||||
@@ -31,22 +30,22 @@ void nfc_scene_save_name_on_enter(void* context) {
|
||||
NFC_DEV_NAME_MAX_LEN,
|
||||
dev_name_empty);
|
||||
|
||||
string_t folder_path;
|
||||
string_init(folder_path);
|
||||
FuriString* folder_path;
|
||||
folder_path = furi_string_alloc();
|
||||
|
||||
if(string_end_with_str_p(nfc->dev->load_path, NFC_APP_EXTENSION)) {
|
||||
path_extract_dirname(string_get_cstr(nfc->dev->load_path), folder_path);
|
||||
if(furi_string_end_with(nfc->dev->load_path, NFC_APP_EXTENSION)) {
|
||||
path_extract_dirname(furi_string_get_cstr(nfc->dev->load_path), folder_path);
|
||||
} else {
|
||||
string_set_str(folder_path, NFC_APP_FOLDER);
|
||||
furi_string_set(folder_path, NFC_APP_FOLDER);
|
||||
}
|
||||
|
||||
ValidatorIsFile* validator_is_file = validator_is_file_alloc_init(
|
||||
string_get_cstr(folder_path), NFC_APP_EXTENSION, nfc->dev->dev_name);
|
||||
furi_string_get_cstr(folder_path), NFC_APP_EXTENSION, nfc->dev->dev_name);
|
||||
text_input_set_validator(text_input, validator_is_file_callback, validator_is_file);
|
||||
|
||||
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewTextInput);
|
||||
|
||||
string_clear(folder_path);
|
||||
furi_string_free(folder_path);
|
||||
}
|
||||
|
||||
bool nfc_scene_save_name_on_event(void* context, SceneManagerEvent event) {
|
||||
|
@@ -1,5 +1,4 @@
|
||||
#include "../nfc_i.h"
|
||||
#include "m-string.h"
|
||||
#include "../helpers/nfc_generators.h"
|
||||
|
||||
enum SubmenuIndex {
|
||||
@@ -19,7 +18,7 @@ void nfc_scene_set_type_on_enter(void* context) {
|
||||
Submenu* submenu = nfc->submenu;
|
||||
// Clear device name
|
||||
nfc_device_set_name(nfc->dev, "");
|
||||
string_set_str(nfc->dev->load_path, "");
|
||||
furi_string_set(nfc->dev->load_path, "");
|
||||
submenu_add_item(
|
||||
submenu, "NFC-A 7-bytes UID", SubmenuIndexNFCA7, nfc_scene_set_type_submenu_callback, nfc);
|
||||
submenu_add_item(
|
||||
|
@@ -1,6 +1,5 @@
|
||||
#include "dict_attack.h"
|
||||
|
||||
#include <m-string.h>
|
||||
#include <gui/elements.h>
|
||||
|
||||
typedef enum {
|
||||
@@ -17,7 +16,7 @@ struct DictAttack {
|
||||
typedef struct {
|
||||
DictAttackState state;
|
||||
MfClassicType type;
|
||||
string_t header;
|
||||
FuriString* header;
|
||||
uint8_t sectors_total;
|
||||
uint8_t sectors_read;
|
||||
uint8_t sector_current;
|
||||
@@ -38,7 +37,8 @@ static void dict_attack_draw_callback(Canvas* canvas, void* model) {
|
||||
} else if(m->state == DictAttackStateRead) {
|
||||
char draw_str[32] = {};
|
||||
canvas_set_font(canvas, FontPrimary);
|
||||
canvas_draw_str_aligned(canvas, 64, 2, AlignCenter, AlignTop, string_get_cstr(m->header));
|
||||
canvas_draw_str_aligned(
|
||||
canvas, 64, 2, AlignCenter, AlignTop, furi_string_get_cstr(m->header));
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
float dict_progress = m->dict_keys_total == 0 ?
|
||||
0 :
|
||||
@@ -81,7 +81,7 @@ DictAttack* dict_attack_alloc() {
|
||||
view_set_context(dict_attack->view, dict_attack);
|
||||
with_view_model(
|
||||
dict_attack->view, (DictAttackViewModel * model) {
|
||||
string_init(model->header);
|
||||
model->header = furi_string_alloc();
|
||||
return false;
|
||||
});
|
||||
return dict_attack;
|
||||
@@ -91,7 +91,7 @@ void dict_attack_free(DictAttack* dict_attack) {
|
||||
furi_assert(dict_attack);
|
||||
with_view_model(
|
||||
dict_attack->view, (DictAttackViewModel * model) {
|
||||
string_clear(model->header);
|
||||
furi_string_free(model->header);
|
||||
return false;
|
||||
});
|
||||
view_free(dict_attack->view);
|
||||
@@ -111,7 +111,7 @@ void dict_attack_reset(DictAttack* dict_attack) {
|
||||
model->keys_found = 0;
|
||||
model->dict_keys_total = 0;
|
||||
model->dict_keys_current = 0;
|
||||
string_reset(model->header);
|
||||
furi_string_reset(model->header);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
@@ -134,7 +134,7 @@ void dict_attack_set_header(DictAttack* dict_attack, const char* header) {
|
||||
|
||||
with_view_model(
|
||||
dict_attack->view, (DictAttackViewModel * model) {
|
||||
string_set_str(model->header, header);
|
||||
furi_string_set(model->header, header);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user