[FL-2274] Inventing streams and moving FFF to them (#981)
* Streams: string stream * String stream: updated insert/delete api * Streams: generic stream interface and string stream implementation * Streams: helpers for insert and delete_and_insert * FFF: now compatible with streams * MinUnit: introduced tests with arguments * FFF: stream access violation * Streams: copy data between streams * Streams: file stream * FFF: documentation * FFStream: documentation * FFF: alloc as file * MinUnit: support for nested tests * Streams: changed delete_and_insert, now it returns success flag. Added ability dump stream inner parameters and data to cout. * FFF: simplified file open function * Streams: unit tests * FFF: tests * Streams: declare cache_size constant as define, to allow variable modified arrays * FFF: lib moved to a separate folder * iButton: new FFF * RFID: new FFF * Animations: new FFF * IR: new FFF * NFC: new FFF * Flipper file format: delete lib * U2F: new FFF * Subghz: new FFF and streams * Streams: read line * Streams: split * FuriCore: implement memset with extra asserts * FuriCore: implement extra heap asserts without inventing memset * Scene manager: protected access to the scene id stack with a size check * NFC worker: dirty fix for issue where hal_nfc was busy on app start * Furi: update allocator to erase memory on allocation. Replace furi_alloc with malloc. * FuriCore: cleanup memmgr code. * Furi HAL: furi_hal_init is split into critical and non-critical parts. The critical part is currently clock and console. * Memmgr: added ability to track allocations and deallocations through console. * FFStream: some speedup * Streams, FF: minor fixes * Tests: restore * File stream: a slightly more thread-safe version of file_stream_delete_and_insert Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
parent
242241987e
commit
274c12fc56
@ -13,7 +13,7 @@ bool archive_back_event_callback(void* context) {
|
||||
}
|
||||
|
||||
ArchiveApp* archive_alloc() {
|
||||
ArchiveApp* archive = furi_alloc(sizeof(ArchiveApp));
|
||||
ArchiveApp* archive = malloc(sizeof(ArchiveApp));
|
||||
|
||||
archive->gui = furi_record_open("gui");
|
||||
archive->text_input = text_input_alloc();
|
||||
|
@ -305,7 +305,7 @@ bool archive_view_input(InputEvent* event, void* context) {
|
||||
}
|
||||
|
||||
ArchiveBrowserView* browser_alloc() {
|
||||
ArchiveBrowserView* browser = furi_alloc(sizeof(ArchiveBrowserView));
|
||||
ArchiveBrowserView* browser = malloc(sizeof(ArchiveBrowserView));
|
||||
browser->view = view_alloc();
|
||||
view_allocate_model(browser->view, ViewModelTypeLocking, sizeof(ArchiveBrowserViewModel));
|
||||
view_set_context(browser->view, browser);
|
||||
|
@ -41,7 +41,7 @@ static bool bad_usb_check_assets() {
|
||||
}
|
||||
|
||||
BadUsbApp* bad_usb_app_alloc(char* arg) {
|
||||
BadUsbApp* app = furi_alloc(sizeof(BadUsbApp));
|
||||
BadUsbApp* app = malloc(sizeof(BadUsbApp));
|
||||
|
||||
if(arg != NULL) {
|
||||
string_t filename;
|
||||
|
@ -524,7 +524,7 @@ static int32_t bad_usb_worker(void* context) {
|
||||
BadUsbScript* bad_usb_script_open(string_t file_path) {
|
||||
furi_assert(file_path);
|
||||
|
||||
BadUsbScript* bad_usb = furi_alloc(sizeof(BadUsbScript));
|
||||
BadUsbScript* bad_usb = malloc(sizeof(BadUsbScript));
|
||||
string_init(bad_usb->file_path);
|
||||
string_set(bad_usb->file_path, file_path);
|
||||
|
||||
|
@ -115,7 +115,7 @@ static bool bad_usb_input_callback(InputEvent* event, void* context) {
|
||||
}
|
||||
|
||||
BadUsb* bad_usb_alloc() {
|
||||
BadUsb* bad_usb = furi_alloc(sizeof(BadUsb));
|
||||
BadUsb* bad_usb = malloc(sizeof(BadUsb));
|
||||
|
||||
bad_usb->view = view_alloc();
|
||||
view_allocate_model(bad_usb->view, ViewModelTypeLocking, sizeof(BadUsbModel));
|
||||
|
@ -27,7 +27,7 @@ uint32_t bt_debug_start_view(void* context) {
|
||||
}
|
||||
|
||||
BtDebugApp* bt_debug_app_alloc() {
|
||||
BtDebugApp* app = furi_alloc(sizeof(BtDebugApp));
|
||||
BtDebugApp* app = malloc(sizeof(BtDebugApp));
|
||||
|
||||
// Load settings
|
||||
bt_settings_load(&app->settings);
|
||||
|
@ -130,7 +130,7 @@ static void bt_test_carrier_timer_callback(void* context) {
|
||||
}
|
||||
|
||||
BtCarrierTest* bt_carrier_test_alloc() {
|
||||
BtCarrierTest* bt_carrier_test = furi_alloc(sizeof(BtCarrierTest));
|
||||
BtCarrierTest* bt_carrier_test = malloc(sizeof(BtCarrierTest));
|
||||
bt_carrier_test->bt_test = bt_test_alloc();
|
||||
bt_test_set_context(bt_carrier_test->bt_test, bt_carrier_test);
|
||||
bt_test_set_change_state_callback(
|
||||
|
@ -98,7 +98,7 @@ static void bt_test_packet_timer_callback(void* context) {
|
||||
}
|
||||
|
||||
BtPacketTest* bt_packet_test_alloc() {
|
||||
BtPacketTest* bt_packet_test = furi_alloc(sizeof(BtPacketTest));
|
||||
BtPacketTest* bt_packet_test = malloc(sizeof(BtPacketTest));
|
||||
bt_packet_test->bt_test = bt_test_alloc();
|
||||
bt_test_set_context(bt_packet_test->bt_test, bt_packet_test);
|
||||
bt_test_set_change_state_callback(
|
||||
|
@ -291,7 +291,7 @@ void bt_test_process_back(BtTest* bt_test) {
|
||||
}
|
||||
|
||||
BtTest* bt_test_alloc() {
|
||||
BtTest* bt_test = furi_alloc(sizeof(BtTest));
|
||||
BtTest* bt_test = malloc(sizeof(BtTest));
|
||||
bt_test->view = view_alloc();
|
||||
view_set_context(bt_test->view, bt_test);
|
||||
view_allocate_model(bt_test->view, ViewModelTypeLocking, sizeof(BtTestModel));
|
||||
|
@ -54,7 +54,7 @@ void bt_hid_connection_status_changed_callback(BtStatus status, void* context) {
|
||||
}
|
||||
|
||||
BtHid* bt_hid_app_alloc() {
|
||||
BtHid* app = furi_alloc(sizeof(BtHid));
|
||||
BtHid* app = malloc(sizeof(BtHid));
|
||||
|
||||
// Gui
|
||||
app->gui = furi_record_open("gui");
|
||||
|
@ -161,7 +161,7 @@ static bool bt_hid_keynote_input_callback(InputEvent* event, void* context) {
|
||||
}
|
||||
|
||||
BtHidKeynote* bt_hid_keynote_alloc() {
|
||||
BtHidKeynote* bt_hid_keynote = furi_alloc(sizeof(BtHidKeynote));
|
||||
BtHidKeynote* bt_hid_keynote = malloc(sizeof(BtHidKeynote));
|
||||
bt_hid_keynote->view = view_alloc();
|
||||
view_set_context(bt_hid_keynote->view, bt_hid_keynote);
|
||||
view_allocate_model(bt_hid_keynote->view, ViewModelTypeLocking, sizeof(BtHidKeynoteModel));
|
||||
|
@ -162,7 +162,7 @@ static bool bt_hid_media_input_callback(InputEvent* event, void* context) {
|
||||
}
|
||||
|
||||
BtHidMedia* bt_hid_media_alloc() {
|
||||
BtHidMedia* bt_hid_media = furi_alloc(sizeof(BtHidMedia));
|
||||
BtHidMedia* bt_hid_media = malloc(sizeof(BtHidMedia));
|
||||
bt_hid_media->view = view_alloc();
|
||||
view_set_context(bt_hid_media->view, bt_hid_media);
|
||||
view_allocate_model(bt_hid_media->view, ViewModelTypeLocking, sizeof(BtHidMediaModel));
|
||||
|
@ -101,7 +101,7 @@ static void bt_battery_level_changed_callback(const void* _event, void* context)
|
||||
}
|
||||
|
||||
Bt* bt_alloc() {
|
||||
Bt* bt = furi_alloc(sizeof(Bt));
|
||||
Bt* bt = malloc(sizeof(Bt));
|
||||
// Init default maximum packet size
|
||||
bt->max_packet_size = FURI_HAL_BT_SERIAL_PACKET_SIZE_MAX;
|
||||
bt->profile = BtProfileSerial;
|
||||
|
@ -13,7 +13,7 @@ static bool bt_settings_back_event_callback(void* context) {
|
||||
}
|
||||
|
||||
BtSettingsApp* bt_settings_app_alloc() {
|
||||
BtSettingsApp* app = furi_alloc(sizeof(BtSettingsApp));
|
||||
BtSettingsApp* app = malloc(sizeof(BtSettingsApp));
|
||||
|
||||
// Load settings
|
||||
bt_settings_load(&app->settings);
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <loader/loader.h>
|
||||
|
||||
Cli* cli_alloc() {
|
||||
Cli* cli = furi_alloc(sizeof(Cli));
|
||||
Cli* cli = malloc(sizeof(Cli));
|
||||
|
||||
CliCommandTree_init(cli->commands);
|
||||
|
||||
|
@ -67,7 +67,7 @@ void crypto_cli_encrypt(Cli* cli, string_t args) {
|
||||
size = size - remain + 16;
|
||||
}
|
||||
string_reserve(input, size);
|
||||
uint8_t* output = furi_alloc(size);
|
||||
uint8_t* output = malloc(size);
|
||||
if(!furi_hal_crypto_encrypt((const uint8_t*)string_get_cstr(input), output, size)) {
|
||||
printf("Failed to encrypt input");
|
||||
} else {
|
||||
@ -135,8 +135,8 @@ void crypto_cli_decrypt(Cli* cli, string_t args) {
|
||||
size_t hex_size = string_size(hex_input);
|
||||
if(hex_size > 0 && hex_size % 2 == 0) {
|
||||
size_t size = hex_size / 2;
|
||||
uint8_t* input = furi_alloc(size);
|
||||
uint8_t* output = furi_alloc(size);
|
||||
uint8_t* input = malloc(size);
|
||||
uint8_t* output = malloc(size);
|
||||
|
||||
if(args_read_hex_bytes(hex_input, input, size)) {
|
||||
if(furi_hal_crypto_decrypt(input, output, size)) {
|
||||
|
@ -121,7 +121,7 @@ static void display_config_set_contrast(VariableItem* item) {
|
||||
}
|
||||
|
||||
DisplayTest* display_test_alloc() {
|
||||
DisplayTest* instance = furi_alloc(sizeof(DisplayTest));
|
||||
DisplayTest* instance = malloc(sizeof(DisplayTest));
|
||||
|
||||
View* view = NULL;
|
||||
|
||||
|
@ -155,7 +155,7 @@ static void view_display_test_timer_callback(void* context) {
|
||||
}
|
||||
|
||||
ViewDisplayTest* view_display_test_alloc() {
|
||||
ViewDisplayTest* instance = furi_alloc(sizeof(ViewDisplayTest));
|
||||
ViewDisplayTest* instance = malloc(sizeof(ViewDisplayTest));
|
||||
|
||||
instance->view = view_alloc();
|
||||
view_set_context(instance->view, instance);
|
||||
|
@ -178,7 +178,7 @@ static int32_t uart_echo_worker(void* context) {
|
||||
}
|
||||
|
||||
static UartEchoApp* uart_echo_app_alloc() {
|
||||
UartEchoApp* app = furi_alloc(sizeof(UartEchoApp));
|
||||
UartEchoApp* app = malloc(sizeof(UartEchoApp));
|
||||
|
||||
app->rx_stream = xStreamBufferCreate(2048, 1);
|
||||
|
||||
@ -201,7 +201,7 @@ static UartEchoApp* uart_echo_app_alloc() {
|
||||
for(size_t i = 0; i < LINES_ON_SCREEN; i++) {
|
||||
model->line = 0;
|
||||
model->escape = false;
|
||||
model->list[i] = furi_alloc(sizeof(ListElement));
|
||||
model->list[i] = malloc(sizeof(ListElement));
|
||||
string_init(model->list[i]->text);
|
||||
}
|
||||
return true;
|
||||
|
@ -47,7 +47,7 @@ uint32_t usb_test_exit(void* context) {
|
||||
}
|
||||
|
||||
UsbTestApp* usb_test_app_alloc() {
|
||||
UsbTestApp* app = furi_alloc(sizeof(UsbTestApp));
|
||||
UsbTestApp* app = malloc(sizeof(UsbTestApp));
|
||||
|
||||
// Gui
|
||||
app->gui = furi_record_open("gui");
|
||||
|
@ -258,7 +258,7 @@ static void animation_manager_replace_current_animation(
|
||||
}
|
||||
|
||||
AnimationManager* animation_manager_alloc(void) {
|
||||
AnimationManager* animation_manager = furi_alloc(sizeof(AnimationManager));
|
||||
AnimationManager* animation_manager = malloc(sizeof(AnimationManager));
|
||||
animation_manager->animation_view = bubble_animation_view_alloc();
|
||||
animation_manager->view_stack = view_stack_alloc();
|
||||
View* animation_view = bubble_animation_get_view(animation_manager->animation_view);
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <flipper_file.h>
|
||||
#include <flipper_format/flipper_format.h>
|
||||
#include <furi.h>
|
||||
#include <furi/dangerous_defines.h>
|
||||
#include <storage/storage.h>
|
||||
@ -30,41 +30,41 @@ static bool animation_storage_load_single_manifest_info(
|
||||
|
||||
bool result = false;
|
||||
Storage* storage = furi_record_open("storage");
|
||||
FlipperFile* file = flipper_file_alloc(storage);
|
||||
flipper_file_set_strict_mode(file, true);
|
||||
FlipperFormat* file = flipper_format_file_alloc(storage);
|
||||
flipper_format_set_strict_mode(file, true);
|
||||
string_t read_string;
|
||||
string_init(read_string);
|
||||
|
||||
do {
|
||||
uint32_t u32value;
|
||||
if(FSE_OK != storage_sd_status(storage)) break;
|
||||
if(!flipper_file_open_existing(file, ANIMATION_MANIFEST_FILE)) break;
|
||||
if(!flipper_format_file_open_existing(file, ANIMATION_MANIFEST_FILE)) break;
|
||||
|
||||
if(!flipper_file_read_header(file, read_string, &u32value)) break;
|
||||
if(!flipper_format_read_header(file, read_string, &u32value)) break;
|
||||
if(string_cmp_str(read_string, "Flipper Animation Manifest")) break;
|
||||
|
||||
manifest_info->name = NULL;
|
||||
|
||||
/* skip other animation names */
|
||||
flipper_file_set_strict_mode(file, false);
|
||||
while(flipper_file_read_string(file, "Name", read_string) &&
|
||||
flipper_format_set_strict_mode(file, false);
|
||||
while(flipper_format_read_string(file, "Name", read_string) &&
|
||||
string_cmp_str(read_string, name))
|
||||
;
|
||||
if(string_cmp_str(read_string, name)) break;
|
||||
flipper_file_set_strict_mode(file, true);
|
||||
flipper_format_set_strict_mode(file, true);
|
||||
|
||||
manifest_info->name = furi_alloc(string_size(read_string) + 1);
|
||||
manifest_info->name = malloc(string_size(read_string) + 1);
|
||||
strcpy((char*)manifest_info->name, string_get_cstr(read_string));
|
||||
|
||||
if(!flipper_file_read_uint32(file, "Min butthurt", &u32value, 1)) break;
|
||||
if(!flipper_format_read_uint32(file, "Min butthurt", &u32value, 1)) break;
|
||||
manifest_info->min_butthurt = u32value;
|
||||
if(!flipper_file_read_uint32(file, "Max butthurt", &u32value, 1)) break;
|
||||
if(!flipper_format_read_uint32(file, "Max butthurt", &u32value, 1)) break;
|
||||
manifest_info->max_butthurt = u32value;
|
||||
if(!flipper_file_read_uint32(file, "Min level", &u32value, 1)) break;
|
||||
if(!flipper_format_read_uint32(file, "Min level", &u32value, 1)) break;
|
||||
manifest_info->min_level = u32value;
|
||||
if(!flipper_file_read_uint32(file, "Max level", &u32value, 1)) break;
|
||||
if(!flipper_format_read_uint32(file, "Max level", &u32value, 1)) break;
|
||||
manifest_info->max_level = u32value;
|
||||
if(!flipper_file_read_uint32(file, "Weight", &u32value, 1)) break;
|
||||
if(!flipper_format_read_uint32(file, "Weight", &u32value, 1)) break;
|
||||
manifest_info->weight = u32value;
|
||||
result = true;
|
||||
} while(0);
|
||||
@ -73,8 +73,7 @@ static bool animation_storage_load_single_manifest_info(
|
||||
free((void*)manifest_info->name);
|
||||
}
|
||||
string_clear(read_string);
|
||||
flipper_file_close(file);
|
||||
flipper_file_free(file);
|
||||
flipper_format_free(file);
|
||||
|
||||
furi_record_close("storage");
|
||||
|
||||
@ -86,9 +85,9 @@ void animation_storage_fill_animation_list(StorageAnimationList_t* animation_lis
|
||||
furi_assert(!StorageAnimationList_size(*animation_list));
|
||||
|
||||
Storage* storage = furi_record_open("storage");
|
||||
FlipperFile* file = flipper_file_alloc(storage);
|
||||
FlipperFormat* file = flipper_format_file_alloc(storage);
|
||||
/* Forbid skipping fields */
|
||||
flipper_file_set_strict_mode(file, true);
|
||||
flipper_format_set_strict_mode(file, true);
|
||||
string_t read_string;
|
||||
string_init(read_string);
|
||||
|
||||
@ -97,28 +96,28 @@ void animation_storage_fill_animation_list(StorageAnimationList_t* animation_lis
|
||||
StorageAnimation* storage_animation = NULL;
|
||||
|
||||
if(FSE_OK != storage_sd_status(storage)) break;
|
||||
if(!flipper_file_open_existing(file, ANIMATION_MANIFEST_FILE)) break;
|
||||
if(!flipper_file_read_header(file, read_string, &u32value)) break;
|
||||
if(!flipper_format_file_open_existing(file, ANIMATION_MANIFEST_FILE)) break;
|
||||
if(!flipper_format_read_header(file, read_string, &u32value)) break;
|
||||
if(string_cmp_str(read_string, "Flipper Animation Manifest")) break;
|
||||
do {
|
||||
storage_animation = furi_alloc(sizeof(StorageAnimation));
|
||||
storage_animation = malloc(sizeof(StorageAnimation));
|
||||
storage_animation->external = true;
|
||||
storage_animation->animation = NULL;
|
||||
storage_animation->manifest_info.name = NULL;
|
||||
|
||||
if(!flipper_file_read_string(file, "Name", read_string)) break;
|
||||
storage_animation->manifest_info.name = furi_alloc(string_size(read_string) + 1);
|
||||
if(!flipper_format_read_string(file, "Name", read_string)) break;
|
||||
storage_animation->manifest_info.name = malloc(string_size(read_string) + 1);
|
||||
strcpy((char*)storage_animation->manifest_info.name, string_get_cstr(read_string));
|
||||
|
||||
if(!flipper_file_read_uint32(file, "Min butthurt", &u32value, 1)) break;
|
||||
if(!flipper_format_read_uint32(file, "Min butthurt", &u32value, 1)) break;
|
||||
storage_animation->manifest_info.min_butthurt = u32value;
|
||||
if(!flipper_file_read_uint32(file, "Max butthurt", &u32value, 1)) break;
|
||||
if(!flipper_format_read_uint32(file, "Max butthurt", &u32value, 1)) break;
|
||||
storage_animation->manifest_info.max_butthurt = u32value;
|
||||
if(!flipper_file_read_uint32(file, "Min level", &u32value, 1)) break;
|
||||
if(!flipper_format_read_uint32(file, "Min level", &u32value, 1)) break;
|
||||
storage_animation->manifest_info.min_level = u32value;
|
||||
if(!flipper_file_read_uint32(file, "Max level", &u32value, 1)) break;
|
||||
if(!flipper_format_read_uint32(file, "Max level", &u32value, 1)) break;
|
||||
storage_animation->manifest_info.max_level = u32value;
|
||||
if(!flipper_file_read_uint32(file, "Weight", &u32value, 1)) break;
|
||||
if(!flipper_format_read_uint32(file, "Weight", &u32value, 1)) break;
|
||||
storage_animation->manifest_info.weight = u32value;
|
||||
|
||||
StorageAnimationList_push_back(*animation_list, storage_animation);
|
||||
@ -128,8 +127,7 @@ void animation_storage_fill_animation_list(StorageAnimationList_t* animation_lis
|
||||
} while(0);
|
||||
|
||||
string_clear(read_string);
|
||||
flipper_file_close(file);
|
||||
flipper_file_free(file);
|
||||
flipper_format_free(file);
|
||||
|
||||
// add hard-coded animations
|
||||
for(int i = 0; i < dolphin_internal_size; ++i) {
|
||||
@ -162,7 +160,7 @@ StorageAnimation* animation_storage_find_animation(const char* name) {
|
||||
|
||||
/* look through external animations */
|
||||
if(!storage_animation) {
|
||||
storage_animation = furi_alloc(sizeof(StorageAnimation));
|
||||
storage_animation = malloc(sizeof(StorageAnimation));
|
||||
storage_animation->external = true;
|
||||
|
||||
bool result = false;
|
||||
@ -288,7 +286,7 @@ static bool animation_storage_load_frames(
|
||||
FURI_CONST_ASSIGN(icon->frame_rate, 0);
|
||||
FURI_CONST_ASSIGN(icon->height, height);
|
||||
FURI_CONST_ASSIGN(icon->width, width);
|
||||
icon->frames = furi_alloc(sizeof(const uint8_t*) * icon->frame_count);
|
||||
icon->frames = malloc(sizeof(const uint8_t*) * icon->frame_count);
|
||||
|
||||
bool frames_ok = false;
|
||||
File* file = storage_file_alloc(storage);
|
||||
@ -317,7 +315,7 @@ static bool animation_storage_load_frames(
|
||||
break;
|
||||
}
|
||||
|
||||
FURI_CONST_ASSIGN_PTR(icon->frames[i], furi_alloc(file_info.size));
|
||||
FURI_CONST_ASSIGN_PTR(icon->frames[i], malloc(file_info.size));
|
||||
if(storage_file_read(file, (void*)icon->frames[i], file_info.size) != file_info.size) {
|
||||
FURI_LOG_E(TAG, "Read failed: \'%s\'", string_get_cstr(filename));
|
||||
break;
|
||||
@ -348,7 +346,7 @@ static bool animation_storage_load_frames(
|
||||
return frames_ok;
|
||||
}
|
||||
|
||||
static bool animation_storage_load_bubbles(BubbleAnimation* animation, FlipperFile* ff) {
|
||||
static bool animation_storage_load_bubbles(BubbleAnimation* animation, FlipperFormat* ff) {
|
||||
uint32_t u32value;
|
||||
string_t str;
|
||||
string_init(str);
|
||||
@ -356,7 +354,7 @@ static bool animation_storage_load_bubbles(BubbleAnimation* animation, FlipperFi
|
||||
furi_assert(!animation->frame_bubble_sequences);
|
||||
|
||||
do {
|
||||
if(!flipper_file_read_uint32(ff, "Bubble slots", &u32value, 1)) break;
|
||||
if(!flipper_format_read_uint32(ff, "Bubble slots", &u32value, 1)) break;
|
||||
if(u32value > 20) break;
|
||||
animation->frame_bubble_sequences_count = u32value;
|
||||
if(animation->frame_bubble_sequences_count == 0) {
|
||||
@ -365,22 +363,22 @@ static bool animation_storage_load_bubbles(BubbleAnimation* animation, FlipperFi
|
||||
break;
|
||||
}
|
||||
animation->frame_bubble_sequences =
|
||||
furi_alloc(sizeof(FrameBubble*) * animation->frame_bubble_sequences_count);
|
||||
malloc(sizeof(FrameBubble*) * animation->frame_bubble_sequences_count);
|
||||
|
||||
uint32_t current_slot = 0;
|
||||
for(int i = 0; i < animation->frame_bubble_sequences_count; ++i) {
|
||||
FURI_CONST_ASSIGN_PTR(
|
||||
animation->frame_bubble_sequences[i], furi_alloc(sizeof(FrameBubble)));
|
||||
animation->frame_bubble_sequences[i], malloc(sizeof(FrameBubble)));
|
||||
}
|
||||
|
||||
const FrameBubble* bubble = animation->frame_bubble_sequences[0];
|
||||
int8_t index = -1;
|
||||
for(;;) {
|
||||
if(!flipper_file_read_uint32(ff, "Slot", ¤t_slot, 1)) break;
|
||||
if(!flipper_format_read_uint32(ff, "Slot", ¤t_slot, 1)) break;
|
||||
if((current_slot != 0) && (index == -1)) break;
|
||||
|
||||
if(current_slot == index) {
|
||||
FURI_CONST_ASSIGN_PTR(bubble->next_bubble, furi_alloc(sizeof(FrameBubble)));
|
||||
FURI_CONST_ASSIGN_PTR(bubble->next_bubble, malloc(sizeof(FrameBubble)));
|
||||
bubble = bubble->next_bubble;
|
||||
} else if(current_slot == index + 1) {
|
||||
++index;
|
||||
@ -392,27 +390,27 @@ static bool animation_storage_load_bubbles(BubbleAnimation* animation, FlipperFi
|
||||
}
|
||||
if(index >= animation->frame_bubble_sequences_count) break;
|
||||
|
||||
if(!flipper_file_read_uint32(ff, "X", &u32value, 1)) break;
|
||||
if(!flipper_format_read_uint32(ff, "X", &u32value, 1)) break;
|
||||
FURI_CONST_ASSIGN(bubble->bubble.x, u32value);
|
||||
if(!flipper_file_read_uint32(ff, "Y", &u32value, 1)) break;
|
||||
if(!flipper_format_read_uint32(ff, "Y", &u32value, 1)) break;
|
||||
FURI_CONST_ASSIGN(bubble->bubble.y, u32value);
|
||||
|
||||
if(!flipper_file_read_string(ff, "Text", str)) break;
|
||||
if(!flipper_format_read_string(ff, "Text", str)) break;
|
||||
if(string_size(str) > 100) break;
|
||||
|
||||
string_replace_all_str(str, "\\n", "\n");
|
||||
|
||||
FURI_CONST_ASSIGN_PTR(bubble->bubble.text, furi_alloc(string_size(str) + 1));
|
||||
FURI_CONST_ASSIGN_PTR(bubble->bubble.text, malloc(string_size(str) + 1));
|
||||
strcpy((char*)bubble->bubble.text, string_get_cstr(str));
|
||||
|
||||
if(!flipper_file_read_string(ff, "AlignH", str)) break;
|
||||
if(!flipper_format_read_string(ff, "AlignH", str)) break;
|
||||
if(!animation_storage_cast_align(str, (Align*)&bubble->bubble.align_h)) break;
|
||||
if(!flipper_file_read_string(ff, "AlignV", str)) break;
|
||||
if(!flipper_format_read_string(ff, "AlignV", str)) break;
|
||||
if(!animation_storage_cast_align(str, (Align*)&bubble->bubble.align_v)) break;
|
||||
|
||||
if(!flipper_file_read_uint32(ff, "StartFrame", &u32value, 1)) break;
|
||||
if(!flipper_format_read_uint32(ff, "StartFrame", &u32value, 1)) break;
|
||||
FURI_CONST_ASSIGN(bubble->start_frame, u32value);
|
||||
if(!flipper_file_read_uint32(ff, "EndFrame", &u32value, 1)) break;
|
||||
if(!flipper_format_read_uint32(ff, "EndFrame", &u32value, 1)) break;
|
||||
FURI_CONST_ASSIGN(bubble->end_frame, u32value);
|
||||
}
|
||||
success = (index + 1) == animation->frame_bubble_sequences_count;
|
||||
@ -431,15 +429,15 @@ static bool animation_storage_load_bubbles(BubbleAnimation* animation, FlipperFi
|
||||
|
||||
static BubbleAnimation* animation_storage_load_animation(const char* name) {
|
||||
furi_assert(name);
|
||||
BubbleAnimation* animation = furi_alloc(sizeof(BubbleAnimation));
|
||||
BubbleAnimation* animation = malloc(sizeof(BubbleAnimation));
|
||||
|
||||
uint32_t height = 0;
|
||||
uint32_t width = 0;
|
||||
uint32_t* u32array = NULL;
|
||||
Storage* storage = furi_record_open("storage");
|
||||
FlipperFile* ff = flipper_file_alloc(storage);
|
||||
FlipperFormat* ff = flipper_format_file_alloc(storage);
|
||||
/* Forbid skipping fields */
|
||||
flipper_file_set_strict_mode(ff, true);
|
||||
flipper_format_set_strict_mode(ff, true);
|
||||
string_t str;
|
||||
string_init(str);
|
||||
animation->frame_bubble_sequences = NULL;
|
||||
@ -451,28 +449,28 @@ static BubbleAnimation* animation_storage_load_animation(const char* name) {
|
||||
if(FSE_OK != storage_sd_status(storage)) break;
|
||||
|
||||
string_printf(str, ANIMATION_DIR "/%s/" ANIMATION_META_FILE, name);
|
||||
if(!flipper_file_open_existing(ff, string_get_cstr(str))) break;
|
||||
if(!flipper_file_read_header(ff, str, &u32value)) break;
|
||||
if(!flipper_format_file_open_existing(ff, string_get_cstr(str))) break;
|
||||
if(!flipper_format_read_header(ff, str, &u32value)) break;
|
||||
if(string_cmp_str(str, "Flipper Animation")) break;
|
||||
|
||||
if(!flipper_file_read_uint32(ff, "Width", &width, 1)) break;
|
||||
if(!flipper_file_read_uint32(ff, "Height", &height, 1)) break;
|
||||
if(!flipper_format_read_uint32(ff, "Width", &width, 1)) break;
|
||||
if(!flipper_format_read_uint32(ff, "Height", &height, 1)) break;
|
||||
|
||||
if(!flipper_file_read_uint32(ff, "Passive frames", &u32value, 1)) break;
|
||||
if(!flipper_format_read_uint32(ff, "Passive frames", &u32value, 1)) break;
|
||||
animation->passive_frames = u32value;
|
||||
if(!flipper_file_read_uint32(ff, "Active frames", &u32value, 1)) break;
|
||||
if(!flipper_format_read_uint32(ff, "Active frames", &u32value, 1)) break;
|
||||
animation->active_frames = u32value;
|
||||
|
||||
uint8_t frames = animation->passive_frames + animation->active_frames;
|
||||
uint32_t count = 0;
|
||||
if(!flipper_file_get_value_count(ff, "Frames order", &count)) break;
|
||||
if(!flipper_format_get_value_count(ff, "Frames order", &count)) break;
|
||||
if(count != frames) {
|
||||
FURI_LOG_E(TAG, "Error loading animation: frames order");
|
||||
break;
|
||||
}
|
||||
u32array = furi_alloc(sizeof(uint32_t) * frames);
|
||||
if(!flipper_file_read_uint32(ff, "Frames order", u32array, frames)) break;
|
||||
animation->frame_order = furi_alloc(sizeof(uint8_t) * frames);
|
||||
u32array = malloc(sizeof(uint32_t) * frames);
|
||||
if(!flipper_format_read_uint32(ff, "Frames order", u32array, frames)) break;
|
||||
animation->frame_order = malloc(sizeof(uint8_t) * frames);
|
||||
for(int i = 0; i < frames; ++i) {
|
||||
FURI_CONST_ASSIGN(animation->frame_order[i], u32array[i]);
|
||||
}
|
||||
@ -481,13 +479,13 @@ static BubbleAnimation* animation_storage_load_animation(const char* name) {
|
||||
if(!animation_storage_load_frames(storage, name, animation, u32array, width, height))
|
||||
break;
|
||||
|
||||
if(!flipper_file_read_uint32(ff, "Active cycles", &u32value, 1)) break;
|
||||
if(!flipper_format_read_uint32(ff, "Active cycles", &u32value, 1)) break;
|
||||
animation->active_cycles = u32value;
|
||||
if(!flipper_file_read_uint32(ff, "Frame rate", &u32value, 1)) break;
|
||||
if(!flipper_format_read_uint32(ff, "Frame rate", &u32value, 1)) break;
|
||||
FURI_CONST_ASSIGN(animation->icon_animation.frame_rate, u32value);
|
||||
if(!flipper_file_read_uint32(ff, "Duration", &u32value, 1)) break;
|
||||
if(!flipper_format_read_uint32(ff, "Duration", &u32value, 1)) break;
|
||||
animation->duration = u32value;
|
||||
if(!flipper_file_read_uint32(ff, "Active cooldown", &u32value, 1)) break;
|
||||
if(!flipper_format_read_uint32(ff, "Active cooldown", &u32value, 1)) break;
|
||||
animation->active_cooldown = u32value;
|
||||
|
||||
if(!animation_storage_load_bubbles(animation, ff)) break;
|
||||
@ -495,8 +493,7 @@ static BubbleAnimation* animation_storage_load_animation(const char* name) {
|
||||
} while(0);
|
||||
|
||||
string_clear(str);
|
||||
flipper_file_close(ff);
|
||||
flipper_file_free(ff);
|
||||
flipper_format_free(ff);
|
||||
if(u32array) {
|
||||
free(u32array);
|
||||
}
|
||||
|
@ -256,17 +256,17 @@ static Icon* bubble_animation_clone_first_frame(const Icon* icon_orig) {
|
||||
furi_assert(icon_orig->frames);
|
||||
furi_assert(icon_orig->frames[0]);
|
||||
|
||||
Icon* icon_clone = furi_alloc(sizeof(Icon));
|
||||
Icon* icon_clone = malloc(sizeof(Icon));
|
||||
memcpy(icon_clone, icon_orig, sizeof(Icon));
|
||||
|
||||
icon_clone->frames = furi_alloc(sizeof(uint8_t*));
|
||||
icon_clone->frames = malloc(sizeof(uint8_t*));
|
||||
/* icon bitmap can be either compressed or not. It is compressed if
|
||||
* compressed size is less than original, so max size for bitmap is
|
||||
* uncompressed (width * height) + 1 byte (in uncompressed case)
|
||||
* for compressed header
|
||||
*/
|
||||
size_t max_bitmap_size = ROUND_UP_TO(icon_orig->width, 8) * icon_orig->height + 1;
|
||||
FURI_CONST_ASSIGN_PTR(icon_clone->frames[0], furi_alloc(max_bitmap_size));
|
||||
FURI_CONST_ASSIGN_PTR(icon_clone->frames[0], malloc(max_bitmap_size));
|
||||
memcpy((void*)icon_clone->frames[0], icon_orig->frames[0], max_bitmap_size);
|
||||
FURI_CONST_ASSIGN(icon_clone->frame_count, 1);
|
||||
|
||||
@ -304,7 +304,7 @@ static void bubble_animation_exit(void* context) {
|
||||
}
|
||||
|
||||
BubbleAnimationView* bubble_animation_view_alloc(void) {
|
||||
BubbleAnimationView* view = furi_alloc(sizeof(BubbleAnimationView));
|
||||
BubbleAnimationView* view = malloc(sizeof(BubbleAnimationView));
|
||||
view->view = view_alloc();
|
||||
view->interact_callback = NULL;
|
||||
view->timer = osTimerNew(bubble_animation_timer_callback, osTimerPeriodic, view, NULL);
|
||||
|
@ -78,7 +78,7 @@ static bool one_shot_view_input(InputEvent* event, void* context) {
|
||||
}
|
||||
|
||||
OneShotView* one_shot_view_alloc(void) {
|
||||
OneShotView* view = furi_alloc(sizeof(OneShotView));
|
||||
OneShotView* view = malloc(sizeof(OneShotView));
|
||||
view->view = view_alloc();
|
||||
view->update_timer =
|
||||
xTimerCreate(NULL, 1000, pdTRUE, view, one_shot_view_update_timer_callback);
|
||||
|
@ -39,7 +39,7 @@ static void desktop_tick_event_callback(void* context) {
|
||||
}
|
||||
|
||||
Desktop* desktop_alloc() {
|
||||
Desktop* desktop = furi_alloc(sizeof(Desktop));
|
||||
Desktop* desktop = malloc(sizeof(Desktop));
|
||||
|
||||
desktop->unload_animation_semaphore = osSemaphoreNew(1, 0, NULL);
|
||||
desktop->animation_manager = animation_manager_alloc();
|
||||
|
@ -19,7 +19,7 @@ static bool desktop_settings_back_event_callback(void* context) {
|
||||
}
|
||||
|
||||
DesktopSettingsApp* desktop_settings_app_alloc() {
|
||||
DesktopSettingsApp* app = furi_alloc(sizeof(DesktopSettingsApp));
|
||||
DesktopSettingsApp* app = malloc(sizeof(DesktopSettingsApp));
|
||||
|
||||
app->gui = furi_record_open("gui");
|
||||
app->view_dispatcher = view_dispatcher_alloc();
|
||||
|
@ -55,7 +55,7 @@ void desktop_settings_view_pin_setup_howto_set_callback(
|
||||
}
|
||||
|
||||
DesktopSettingsViewPinSetupHowto* desktop_settings_view_pin_setup_howto_alloc() {
|
||||
DesktopSettingsViewPinSetupHowto* view = furi_alloc(sizeof(DesktopSettingsViewPinSetupHowto));
|
||||
DesktopSettingsViewPinSetupHowto* view = malloc(sizeof(DesktopSettingsViewPinSetupHowto));
|
||||
view->view = view_alloc();
|
||||
view_allocate_model(view->view, ViewModelTypeLockFree, 1);
|
||||
view_set_context(view->view, view);
|
||||
|
@ -77,8 +77,7 @@ void desktop_settings_view_pin_setup_howto2_set_ok_callback(
|
||||
}
|
||||
|
||||
DesktopSettingsViewPinSetupHowto2* desktop_settings_view_pin_setup_howto2_alloc() {
|
||||
DesktopSettingsViewPinSetupHowto2* view =
|
||||
furi_alloc(sizeof(DesktopSettingsViewPinSetupHowto2));
|
||||
DesktopSettingsViewPinSetupHowto2* view = malloc(sizeof(DesktopSettingsViewPinSetupHowto2));
|
||||
view->view = view_alloc();
|
||||
view_allocate_model(view->view, ViewModelTypeLockFree, 1);
|
||||
view_set_context(view->view, view);
|
||||
|
@ -16,7 +16,7 @@ void desktop_scene_hw_mismatch_on_enter(void* context) {
|
||||
furi_assert(desktop);
|
||||
Popup* popup = desktop->hw_mismatch_popup;
|
||||
|
||||
char* text_buffer = furi_alloc(256);
|
||||
char* text_buffer = malloc(256);
|
||||
scene_manager_set_scene_state(
|
||||
desktop->scene_manager, DesktopSceneHwMismatch, (uint32_t)text_buffer);
|
||||
|
||||
|
@ -80,7 +80,7 @@ void desktop_scene_pin_input_on_enter(void* context) {
|
||||
desktop_view_pin_input_set_done_callback(
|
||||
desktop->pin_input_view, desktop_scene_pin_input_done_callback);
|
||||
|
||||
DesktopScenePinInputState* state = furi_alloc(sizeof(DesktopScenePinInputState));
|
||||
DesktopScenePinInputState* state = malloc(sizeof(DesktopScenePinInputState));
|
||||
state->timer =
|
||||
xTimerCreate(NULL, 10000, pdFALSE, desktop, desktop_scene_pin_input_timer_callback);
|
||||
scene_manager_set_scene_state(desktop->scene_manager, DesktopScenePinInput, (uint32_t)state);
|
||||
|
@ -150,7 +150,7 @@ bool desktop_debug_input(InputEvent* event, void* context) {
|
||||
}
|
||||
|
||||
DesktopDebugView* desktop_debug_alloc() {
|
||||
DesktopDebugView* debug_view = furi_alloc(sizeof(DesktopDebugView));
|
||||
DesktopDebugView* debug_view = malloc(sizeof(DesktopDebugView));
|
||||
debug_view->view = view_alloc();
|
||||
view_allocate_model(debug_view->view, ViewModelTypeLocking, sizeof(DesktopDebugViewModel));
|
||||
view_set_context(debug_view->view, debug_view);
|
||||
|
@ -131,7 +131,7 @@ static void desktop_first_start_exit(void* context) {
|
||||
}
|
||||
|
||||
DesktopFirstStartView* desktop_first_start_alloc() {
|
||||
DesktopFirstStartView* instance = furi_alloc(sizeof(DesktopFirstStartView));
|
||||
DesktopFirstStartView* instance = malloc(sizeof(DesktopFirstStartView));
|
||||
instance->view = view_alloc();
|
||||
view_allocate_model(instance->view, ViewModelTypeLocking, sizeof(DesktopFirstStartViewModel));
|
||||
view_set_context(instance->view, instance);
|
||||
|
@ -112,7 +112,7 @@ bool desktop_lock_menu_input(InputEvent* event, void* context) {
|
||||
}
|
||||
|
||||
DesktopLockMenuView* desktop_lock_menu_alloc() {
|
||||
DesktopLockMenuView* lock_menu = furi_alloc(sizeof(DesktopLockMenuView));
|
||||
DesktopLockMenuView* lock_menu = malloc(sizeof(DesktopLockMenuView));
|
||||
lock_menu->view = view_alloc();
|
||||
view_allocate_model(lock_menu->view, ViewModelTypeLocking, sizeof(DesktopLockMenuViewModel));
|
||||
view_set_context(lock_menu->view, lock_menu);
|
||||
|
@ -184,7 +184,7 @@ static bool desktop_view_locked_input(InputEvent* event, void* context) {
|
||||
}
|
||||
|
||||
DesktopViewLocked* desktop_view_locked_alloc() {
|
||||
DesktopViewLocked* locked_view = furi_alloc(sizeof(DesktopViewLocked));
|
||||
DesktopViewLocked* locked_view = malloc(sizeof(DesktopViewLocked));
|
||||
locked_view->view = view_alloc();
|
||||
locked_view->timer =
|
||||
xTimerCreate(NULL, 1000 / 16, pdTRUE, locked_view, locked_view_timer_callback);
|
||||
|
@ -58,7 +58,7 @@ bool desktop_main_input(InputEvent* event, void* context) {
|
||||
}
|
||||
|
||||
DesktopMainView* desktop_main_alloc() {
|
||||
DesktopMainView* main_view = furi_alloc(sizeof(DesktopMainView));
|
||||
DesktopMainView* main_view = malloc(sizeof(DesktopMainView));
|
||||
|
||||
main_view->view = view_alloc();
|
||||
view_allocate_model(main_view->view, ViewModelTypeLockFree, 1);
|
||||
|
@ -185,7 +185,7 @@ static void desktop_view_pin_input_exit(void* context) {
|
||||
}
|
||||
|
||||
DesktopViewPinInput* desktop_view_pin_input_alloc(void) {
|
||||
DesktopViewPinInput* pin_input = furi_alloc(sizeof(DesktopViewPinInput));
|
||||
DesktopViewPinInput* pin_input = malloc(sizeof(DesktopViewPinInput));
|
||||
pin_input->view = view_alloc();
|
||||
view_allocate_model(pin_input->view, ViewModelTypeLocking, sizeof(DesktopViewPinInputModel));
|
||||
view_set_context(pin_input->view, pin_input);
|
||||
|
@ -57,7 +57,7 @@ void desktop_view_pin_done_set_callback(
|
||||
}
|
||||
|
||||
DesktopViewPinSetupDone* desktop_view_pin_done_alloc() {
|
||||
DesktopViewPinSetupDone* view = furi_alloc(sizeof(DesktopViewPinSetupDone));
|
||||
DesktopViewPinSetupDone* view = malloc(sizeof(DesktopViewPinSetupDone));
|
||||
view->view = view_alloc();
|
||||
view_allocate_model(view->view, ViewModelTypeLockFree, 1);
|
||||
view_set_context(view->view, view);
|
||||
|
@ -77,7 +77,7 @@ void desktop_view_pin_timeout_free(DesktopViewPinTimeout* instance) {
|
||||
}
|
||||
|
||||
DesktopViewPinTimeout* desktop_view_pin_timeout_alloc(void) {
|
||||
DesktopViewPinTimeout* instance = furi_alloc(sizeof(DesktopViewPinTimeout));
|
||||
DesktopViewPinTimeout* instance = malloc(sizeof(DesktopViewPinTimeout));
|
||||
instance->timer = xTimerCreate(
|
||||
NULL, pdMS_TO_TICKS(1000), pdTRUE, instance, desktop_view_pin_timeout_timer_callback);
|
||||
|
||||
|
@ -25,8 +25,7 @@ bool dialogs_app_process_module_file_select(const DialogsAppMessageDataFileSelec
|
||||
bool ret = false;
|
||||
Gui* gui = furi_record_open("gui");
|
||||
|
||||
DialogsAppFileSelectContext* file_select_context =
|
||||
furi_alloc(sizeof(DialogsAppFileSelectContext));
|
||||
DialogsAppFileSelectContext* file_select_context = malloc(sizeof(DialogsAppFileSelectContext));
|
||||
file_select_context->lock = API_LOCK_INIT_LOCKED();
|
||||
|
||||
ViewHolder* view_holder = view_holder_alloc();
|
||||
|
@ -54,7 +54,7 @@ DialogMessageButton dialogs_app_process_module_message(const DialogsAppMessageDa
|
||||
DialogMessageButton ret = DialogMessageButtonBack;
|
||||
Gui* gui = furi_record_open("gui");
|
||||
const DialogMessage* message = data->message;
|
||||
DialogsAppMessageContext* message_context = furi_alloc(sizeof(DialogsAppMessageContext));
|
||||
DialogsAppMessageContext* message_context = malloc(sizeof(DialogsAppMessageContext));
|
||||
message_context->lock = API_LOCK_INIT_LOCKED();
|
||||
|
||||
ViewHolder* view_holder = view_holder_alloc();
|
||||
@ -100,7 +100,7 @@ DialogMessageButton dialogs_app_process_module_message(const DialogsAppMessageDa
|
||||
}
|
||||
|
||||
DialogMessage* dialog_message_alloc() {
|
||||
DialogMessage* message = furi_alloc(sizeof(DialogMessage));
|
||||
DialogMessage* message = malloc(sizeof(DialogMessage));
|
||||
return message;
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ static void view_holder_draw_callback(Canvas* canvas, void* context);
|
||||
static void view_holder_input_callback(InputEvent* event, void* context);
|
||||
|
||||
ViewHolder* view_holder_alloc() {
|
||||
ViewHolder* view_holder = furi_alloc(sizeof(ViewHolder));
|
||||
ViewHolder* view_holder = malloc(sizeof(ViewHolder));
|
||||
|
||||
view_holder->view_port = view_port_alloc();
|
||||
view_port_draw_callback_set(view_holder->view_port, view_holder_draw_callback, view_holder);
|
||||
|
@ -74,7 +74,7 @@ void dolphin_clear_limits_timer_callback(TimerHandle_t xTimer) {
|
||||
}
|
||||
|
||||
Dolphin* dolphin_alloc() {
|
||||
Dolphin* dolphin = furi_alloc(sizeof(Dolphin));
|
||||
Dolphin* dolphin = malloc(sizeof(Dolphin));
|
||||
|
||||
dolphin->state = dolphin_state_alloc();
|
||||
dolphin->event_queue = osMessageQueueNew(8, sizeof(DolphinEvent), NULL);
|
||||
|
@ -17,7 +17,7 @@
|
||||
#define BUTTHURT_MIN 0
|
||||
|
||||
DolphinState* dolphin_state_alloc() {
|
||||
return furi_alloc(sizeof(DolphinState));
|
||||
return malloc(sizeof(DolphinState));
|
||||
}
|
||||
|
||||
void dolphin_state_free(DolphinState* dolphin_state) {
|
||||
|
@ -22,7 +22,7 @@ static void gpio_app_tick_event_callback(void* context) {
|
||||
}
|
||||
|
||||
GpioApp* gpio_app_alloc() {
|
||||
GpioApp* app = furi_alloc(sizeof(GpioApp));
|
||||
GpioApp* app = malloc(sizeof(GpioApp));
|
||||
|
||||
app->gui = furi_record_open("gui");
|
||||
|
||||
|
@ -18,7 +18,7 @@ void gpio_scene_usb_uart_on_enter(void* context) {
|
||||
GpioApp* app = context;
|
||||
uint32_t prev_state = scene_manager_get_scene_state(app->scene_manager, GpioAppViewUsbUart);
|
||||
if(prev_state == 0) {
|
||||
scene_usb_uart = furi_alloc(sizeof(SceneUsbUartBridge));
|
||||
scene_usb_uart = malloc(sizeof(SceneUsbUartBridge));
|
||||
scene_usb_uart->cfg.vcp_ch = 0; // TODO: settings load
|
||||
scene_usb_uart->cfg.uart_ch = 0;
|
||||
scene_usb_uart->cfg.flow_pins = 0;
|
||||
|
@ -91,7 +91,7 @@ void gpio_scene_usb_uart_cfg_on_enter(void* context) {
|
||||
GpioApp* app = context;
|
||||
VariableItemList* var_item_list = app->var_item_list;
|
||||
|
||||
cfg_set = furi_alloc(sizeof(UsbUartConfig));
|
||||
cfg_set = malloc(sizeof(UsbUartConfig));
|
||||
usb_uart_get_config(app->usb_uart_bridge, cfg_set);
|
||||
|
||||
VariableItem* item;
|
||||
|
@ -312,7 +312,7 @@ static void vcp_on_line_config(void* context, struct usb_cdc_line_coding* config
|
||||
}
|
||||
|
||||
UsbUartBridge* usb_uart_enable(UsbUartConfig* cfg) {
|
||||
UsbUartBridge* usb_uart = furi_alloc(sizeof(UsbUartBridge));
|
||||
UsbUartBridge* usb_uart = malloc(sizeof(UsbUartBridge));
|
||||
|
||||
memcpy(&(usb_uart->cfg_new), cfg, sizeof(UsbUartConfig));
|
||||
|
||||
|
@ -96,7 +96,7 @@ static bool gpio_test_process_ok(GpioTest* gpio_test, InputEvent* event) {
|
||||
}
|
||||
|
||||
GpioTest* gpio_test_alloc() {
|
||||
GpioTest* gpio_test = furi_alloc(sizeof(GpioTest));
|
||||
GpioTest* gpio_test = malloc(sizeof(GpioTest));
|
||||
|
||||
gpio_test->view = view_alloc();
|
||||
view_allocate_model(gpio_test->view, ViewModelTypeLocking, sizeof(GpioTestModel));
|
||||
|
@ -102,7 +102,7 @@ static bool gpio_usb_uart_input_callback(InputEvent* event, void* context) {
|
||||
}
|
||||
|
||||
GpioUsbUart* gpio_usb_uart_alloc() {
|
||||
GpioUsbUart* usb_uart = furi_alloc(sizeof(GpioUsbUart));
|
||||
GpioUsbUart* usb_uart = malloc(sizeof(GpioUsbUart));
|
||||
|
||||
usb_uart->view = view_alloc();
|
||||
view_allocate_model(usb_uart->view, ViewModelTypeLocking, sizeof(GpioUsbUartModel));
|
||||
|
@ -15,7 +15,7 @@ const CanvasFontParameters canvas_font_params[FontTotalNumber] = {
|
||||
};
|
||||
|
||||
Canvas* canvas_init() {
|
||||
Canvas* canvas = furi_alloc(sizeof(Canvas));
|
||||
Canvas* canvas = malloc(sizeof(Canvas));
|
||||
|
||||
furi_hal_power_insomnia_enter();
|
||||
|
||||
|
@ -417,7 +417,7 @@ void gui_set_lockdown(Gui* gui, bool lockdown) {
|
||||
}
|
||||
|
||||
Gui* gui_alloc() {
|
||||
Gui* gui = furi_alloc(sizeof(Gui));
|
||||
Gui* gui = malloc(sizeof(Gui));
|
||||
// Thread ID
|
||||
gui->thread = osThreadGetId();
|
||||
// Allocate mutex
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
IconAnimation* icon_animation_alloc(const Icon* icon) {
|
||||
furi_assert(icon);
|
||||
IconAnimation* instance = furi_alloc(sizeof(IconAnimation));
|
||||
IconAnimation* instance = malloc(sizeof(IconAnimation));
|
||||
instance->icon = icon;
|
||||
instance->timer = osTimerNew(icon_animation_timer_callback, osTimerPeriodic, instance, NULL);
|
||||
return instance;
|
||||
|
@ -290,7 +290,7 @@ ButtonMenuItem* button_menu_add_item(
|
||||
}
|
||||
|
||||
ButtonMenu* button_menu_alloc(void) {
|
||||
ButtonMenu* button_menu = furi_alloc(sizeof(ButtonMenu));
|
||||
ButtonMenu* button_menu = malloc(sizeof(ButtonMenu));
|
||||
button_menu->view = view_alloc();
|
||||
view_set_orientation(button_menu->view, ViewOrientationVertical);
|
||||
view_set_context(button_menu->view, button_menu);
|
||||
|
@ -65,7 +65,7 @@ static void button_panel_view_draw_callback(Canvas* canvas, void* _model);
|
||||
static bool button_panel_view_input_callback(InputEvent* event, void* context);
|
||||
|
||||
ButtonPanel* button_panel_alloc() {
|
||||
ButtonPanel* button_panel = furi_alloc(sizeof(ButtonPanel));
|
||||
ButtonPanel* button_panel = malloc(sizeof(ButtonPanel));
|
||||
button_panel->view = view_alloc();
|
||||
view_set_orientation(button_panel->view, ViewOrientationVertical);
|
||||
view_set_context(button_panel->view, button_panel);
|
||||
@ -173,7 +173,7 @@ void button_panel_add_item(
|
||||
ButtonItem** button_item_ptr =
|
||||
button_panel_get_item(model, matrix_place_x, matrix_place_y);
|
||||
furi_check(*button_item_ptr == NULL);
|
||||
*button_item_ptr = furi_alloc(sizeof(ButtonItem));
|
||||
*button_item_ptr = malloc(sizeof(ButtonItem));
|
||||
ButtonItem* button_item = *button_item_ptr;
|
||||
button_item->callback = callback;
|
||||
button_item->callback_context = callback_context;
|
||||
|
@ -695,7 +695,7 @@ static void byte_input_reset_model_input_data(ByteInputModel* model) {
|
||||
* @return ByteInput instance pointer
|
||||
*/
|
||||
ByteInput* byte_input_alloc() {
|
||||
ByteInput* byte_input = furi_alloc(sizeof(ByteInput));
|
||||
ByteInput* byte_input = malloc(sizeof(ByteInput));
|
||||
byte_input->view = view_alloc();
|
||||
view_set_context(byte_input->view, byte_input);
|
||||
view_allocate_model(byte_input->view, ViewModelTypeLocking, sizeof(ByteInputModel));
|
||||
|
@ -60,7 +60,7 @@ static bool dialog_view_input_callback(InputEvent* event, void* context) {
|
||||
}
|
||||
|
||||
Dialog* dialog_alloc() {
|
||||
Dialog* dialog = furi_alloc(sizeof(Dialog));
|
||||
Dialog* dialog = malloc(sizeof(Dialog));
|
||||
dialog->view = view_alloc();
|
||||
view_set_context(dialog->view, dialog);
|
||||
view_allocate_model(dialog->view, ViewModelTypeLockFree, sizeof(DialogModel));
|
||||
|
@ -114,7 +114,7 @@ static bool dialog_ex_view_input_callback(InputEvent* event, void* context) {
|
||||
}
|
||||
|
||||
DialogEx* dialog_ex_alloc() {
|
||||
DialogEx* dialog_ex = furi_alloc(sizeof(DialogEx));
|
||||
DialogEx* dialog_ex = malloc(sizeof(DialogEx));
|
||||
dialog_ex->view = view_alloc();
|
||||
view_set_context(dialog_ex->view, dialog_ex);
|
||||
view_allocate_model(dialog_ex->view, ViewModelTypeLockFree, sizeof(DialogExModel));
|
||||
|
@ -14,7 +14,7 @@ static bool empty_screen_view_input_callback(InputEvent* event, void* context) {
|
||||
}
|
||||
|
||||
EmptyScreen* empty_screen_alloc() {
|
||||
EmptyScreen* empty_screen = furi_alloc(sizeof(EmptyScreen));
|
||||
EmptyScreen* empty_screen = malloc(sizeof(EmptyScreen));
|
||||
empty_screen->view = view_alloc();
|
||||
view_set_context(empty_screen->view, empty_screen);
|
||||
view_set_draw_callback(empty_screen->view, empty_screen_view_draw_callback);
|
||||
|
@ -181,7 +181,7 @@ static bool file_select_init_inner(FileSelect* file_select) {
|
||||
}
|
||||
|
||||
FileSelect* file_select_alloc() {
|
||||
FileSelect* file_select = furi_alloc(sizeof(FileSelect));
|
||||
FileSelect* file_select = malloc(sizeof(FileSelect));
|
||||
file_select->view = view_alloc();
|
||||
file_select->fs_api = furi_record_open("storage");
|
||||
|
||||
@ -278,7 +278,7 @@ bool file_select_fill_strings(FileSelect* file_select) {
|
||||
uint8_t string_counter = 0;
|
||||
uint16_t file_counter = 0;
|
||||
const uint8_t name_length = 100;
|
||||
char* name = furi_alloc(name_length);
|
||||
char* name = malloc(name_length);
|
||||
uint16_t first_file_index = 0;
|
||||
|
||||
with_view_model(
|
||||
@ -346,7 +346,7 @@ bool file_select_fill_count(FileSelect* file_select) {
|
||||
|
||||
uint16_t file_counter = 0;
|
||||
const uint8_t name_length = 100;
|
||||
char* name = furi_alloc(name_length);
|
||||
char* name = malloc(name_length);
|
||||
|
||||
if(!storage_dir_open(directory, file_select->path)) {
|
||||
storage_dir_close(directory);
|
||||
@ -397,7 +397,7 @@ void file_select_set_selected_file_internal(FileSelect* file_select, const char*
|
||||
File* directory = storage_file_alloc(file_select->fs_api);
|
||||
|
||||
const uint8_t name_length = 100;
|
||||
char* name = furi_alloc(name_length);
|
||||
char* name = malloc(name_length);
|
||||
uint16_t file_position = 0;
|
||||
bool file_found = false;
|
||||
|
||||
|
@ -125,7 +125,7 @@ static void menu_exit(void* context) {
|
||||
}
|
||||
|
||||
Menu* menu_alloc() {
|
||||
Menu* menu = furi_alloc(sizeof(Menu));
|
||||
Menu* menu = malloc(sizeof(Menu));
|
||||
menu->view = view_alloc(menu->view);
|
||||
view_set_context(menu->view, menu);
|
||||
view_allocate_model(menu->view, ViewModelTypeLocking, sizeof(MenuModel));
|
||||
|
@ -108,7 +108,7 @@ void popup_stop_timer(void* context) {
|
||||
}
|
||||
|
||||
Popup* popup_alloc() {
|
||||
Popup* popup = furi_alloc(sizeof(Popup));
|
||||
Popup* popup = malloc(sizeof(Popup));
|
||||
popup->view = view_alloc();
|
||||
popup->timer = osTimerNew(popup_timer_callback, osTimerOnce, popup, NULL);
|
||||
furi_assert(popup->timer);
|
||||
|
@ -120,7 +120,7 @@ static bool submenu_view_input_callback(InputEvent* event, void* context) {
|
||||
}
|
||||
|
||||
Submenu* submenu_alloc() {
|
||||
Submenu* submenu = furi_alloc(sizeof(Submenu));
|
||||
Submenu* submenu = malloc(sizeof(Submenu));
|
||||
submenu->view = view_alloc();
|
||||
view_set_context(submenu->view, submenu);
|
||||
view_allocate_model(submenu->view, ViewModelTypeLocking, sizeof(SubmenuModel));
|
||||
|
@ -128,7 +128,7 @@ static bool text_box_view_input_callback(InputEvent* event, void* context) {
|
||||
}
|
||||
|
||||
TextBox* text_box_alloc() {
|
||||
TextBox* text_box = furi_alloc(sizeof(TextBox));
|
||||
TextBox* text_box = malloc(sizeof(TextBox));
|
||||
text_box->view = view_alloc();
|
||||
view_set_context(text_box->view, text_box);
|
||||
view_allocate_model(text_box->view, ViewModelTypeLocking, sizeof(TextBoxModel));
|
||||
|
@ -410,7 +410,7 @@ void text_input_timer_callback(void* context) {
|
||||
}
|
||||
|
||||
TextInput* text_input_alloc() {
|
||||
TextInput* text_input = furi_alloc(sizeof(TextInput));
|
||||
TextInput* text_input = malloc(sizeof(TextInput));
|
||||
text_input->view = view_alloc();
|
||||
view_set_context(text_input->view, text_input);
|
||||
view_allocate_model(text_input->view, ViewModelTypeLocking, sizeof(TextInputModel));
|
||||
|
@ -28,7 +28,7 @@ bool validator_is_file_callback(const char* text, string_t error, void* context)
|
||||
|
||||
ValidatorIsFile*
|
||||
validator_is_file_alloc_init(const char* app_path_folder, const char* app_extension) {
|
||||
ValidatorIsFile* instance = furi_alloc(sizeof(ValidatorIsFile));
|
||||
ValidatorIsFile* instance = malloc(sizeof(ValidatorIsFile));
|
||||
|
||||
instance->app_path_folder = app_path_folder;
|
||||
instance->app_extension = app_extension;
|
||||
|
@ -276,7 +276,7 @@ void variable_item_list_process_ok(VariableItemList* variable_item_list) {
|
||||
}
|
||||
|
||||
VariableItemList* variable_item_list_alloc() {
|
||||
VariableItemList* variable_item_list = furi_alloc(sizeof(VariableItemList));
|
||||
VariableItemList* variable_item_list = malloc(sizeof(VariableItemList));
|
||||
variable_item_list->view = view_alloc();
|
||||
view_set_context(variable_item_list->view, variable_item_list);
|
||||
view_allocate_model(
|
||||
|
@ -52,7 +52,7 @@ static bool gui_widget_view_input_callback(InputEvent* event, void* context) {
|
||||
}
|
||||
|
||||
Widget* widget_alloc() {
|
||||
Widget* widget = furi_alloc(sizeof(Widget));
|
||||
Widget* widget = malloc(sizeof(Widget));
|
||||
widget->view = view_alloc();
|
||||
view_set_context(widget->view, widget);
|
||||
view_allocate_model(widget->view, ViewModelTypeLocking, sizeof(GuiWidgetModel));
|
||||
|
@ -61,14 +61,14 @@ WidgetElement* widget_element_button_create(
|
||||
ButtonCallback callback,
|
||||
void* context) {
|
||||
// Allocate and init model
|
||||
GuiButtonModel* model = furi_alloc(sizeof(GuiButtonModel));
|
||||
GuiButtonModel* model = malloc(sizeof(GuiButtonModel));
|
||||
model->button_type = button_type;
|
||||
model->callback = callback;
|
||||
model->context = context;
|
||||
string_init_set_str(model->text, text);
|
||||
|
||||
// Allocate and init Element
|
||||
WidgetElement* gui_button = furi_alloc(sizeof(WidgetElement));
|
||||
WidgetElement* gui_button = malloc(sizeof(WidgetElement));
|
||||
gui_button->parent = NULL;
|
||||
gui_button->input = gui_button_input;
|
||||
gui_button->draw = gui_button_draw;
|
||||
|
@ -29,7 +29,7 @@ WidgetElement* widget_element_frame_create(
|
||||
uint8_t height,
|
||||
uint8_t radius) {
|
||||
// Allocate and init model
|
||||
GuiFrameModel* model = furi_alloc(sizeof(GuiFrameModel));
|
||||
GuiFrameModel* model = malloc(sizeof(GuiFrameModel));
|
||||
model->x = x;
|
||||
model->y = y;
|
||||
model->width = width;
|
||||
@ -37,7 +37,7 @@ WidgetElement* widget_element_frame_create(
|
||||
model->radius = radius;
|
||||
|
||||
// Allocate and init Element
|
||||
WidgetElement* gui_frame = furi_alloc(sizeof(WidgetElement));
|
||||
WidgetElement* gui_frame = malloc(sizeof(WidgetElement));
|
||||
gui_frame->parent = NULL;
|
||||
gui_frame->input = NULL;
|
||||
gui_frame->draw = gui_frame_draw;
|
||||
|
@ -27,13 +27,13 @@ WidgetElement* widget_element_icon_create(uint8_t x, uint8_t y, const Icon* icon
|
||||
furi_assert(icon);
|
||||
|
||||
// Allocate and init model
|
||||
GuiIconModel* model = furi_alloc(sizeof(GuiIconModel));
|
||||
GuiIconModel* model = malloc(sizeof(GuiIconModel));
|
||||
model->x = x;
|
||||
model->y = y;
|
||||
model->icon = icon;
|
||||
|
||||
// Allocate and init Element
|
||||
WidgetElement* gui_icon = furi_alloc(sizeof(WidgetElement));
|
||||
WidgetElement* gui_icon = malloc(sizeof(WidgetElement));
|
||||
gui_icon->parent = NULL;
|
||||
gui_icon->input = NULL;
|
||||
gui_icon->draw = gui_icon_draw;
|
||||
|
@ -46,7 +46,7 @@ WidgetElement* widget_element_string_create(
|
||||
furi_assert(text);
|
||||
|
||||
// Allocate and init model
|
||||
GuiStringModel* model = furi_alloc(sizeof(GuiStringModel));
|
||||
GuiStringModel* model = malloc(sizeof(GuiStringModel));
|
||||
model->x = x;
|
||||
model->y = y;
|
||||
model->horizontal = horizontal;
|
||||
@ -55,7 +55,7 @@ WidgetElement* widget_element_string_create(
|
||||
string_init_set_str(model->text, text);
|
||||
|
||||
// Allocate and init Element
|
||||
WidgetElement* gui_string = furi_alloc(sizeof(WidgetElement));
|
||||
WidgetElement* gui_string = malloc(sizeof(WidgetElement));
|
||||
gui_string->parent = NULL;
|
||||
gui_string->input = NULL;
|
||||
gui_string->draw = gui_string_draw;
|
||||
|
@ -47,7 +47,7 @@ WidgetElement* widget_element_string_multiline_create(
|
||||
furi_assert(text);
|
||||
|
||||
// Allocate and init model
|
||||
GuiStringMultiLineModel* model = furi_alloc(sizeof(GuiStringMultiLineModel));
|
||||
GuiStringMultiLineModel* model = malloc(sizeof(GuiStringMultiLineModel));
|
||||
model->x = x;
|
||||
model->y = y;
|
||||
model->horizontal = horizontal;
|
||||
@ -56,7 +56,7 @@ WidgetElement* widget_element_string_multiline_create(
|
||||
string_init_set_str(model->text, text);
|
||||
|
||||
// Allocate and init Element
|
||||
WidgetElement* gui_string = furi_alloc(sizeof(WidgetElement));
|
||||
WidgetElement* gui_string = malloc(sizeof(WidgetElement));
|
||||
gui_string->parent = NULL;
|
||||
gui_string->input = NULL;
|
||||
gui_string->draw = gui_string_multiline_draw;
|
||||
|
@ -50,7 +50,7 @@ WidgetElement* widget_element_text_box_create(
|
||||
furi_assert(text);
|
||||
|
||||
// Allocate and init model
|
||||
GuiTextBoxModel* model = furi_alloc(sizeof(GuiTextBoxModel));
|
||||
GuiTextBoxModel* model = malloc(sizeof(GuiTextBoxModel));
|
||||
model->x = x;
|
||||
model->y = y;
|
||||
model->width = width;
|
||||
@ -60,7 +60,7 @@ WidgetElement* widget_element_text_box_create(
|
||||
string_init_set_str(model->text, text);
|
||||
|
||||
// Allocate and init Element
|
||||
WidgetElement* gui_string = furi_alloc(sizeof(WidgetElement));
|
||||
WidgetElement* gui_string = malloc(sizeof(WidgetElement));
|
||||
gui_string->parent = NULL;
|
||||
gui_string->input = NULL;
|
||||
gui_string->draw = gui_text_box_draw;
|
||||
|
@ -4,12 +4,12 @@
|
||||
SceneManager* scene_manager_alloc(const SceneManagerHandlers* app_scene_handlers, void* context) {
|
||||
furi_assert(context);
|
||||
|
||||
SceneManager* scene_manager = furi_alloc(sizeof(SceneManager));
|
||||
SceneManager* scene_manager = malloc(sizeof(SceneManager));
|
||||
// Set SceneManager context and scene handlers
|
||||
scene_manager->context = context;
|
||||
scene_manager->scene_handlers = app_scene_handlers;
|
||||
// Allocate all scenes
|
||||
scene_manager->scene = furi_alloc(sizeof(AppScene) * app_scene_handlers->scene_num);
|
||||
scene_manager->scene = malloc(sizeof(AppScene) * app_scene_handlers->scene_num);
|
||||
// Initialize ScaneManager array for navigation
|
||||
SceneManagerIdStack_init(scene_manager->scene_id_stack);
|
||||
|
||||
@ -48,9 +48,16 @@ bool scene_manager_handle_custom_event(SceneManager* scene_manager, uint32_t cus
|
||||
.type = SceneManagerEventTypeCustom,
|
||||
.event = custom_event,
|
||||
};
|
||||
uint32_t scene_id = *SceneManagerIdStack_back(scene_manager->scene_id_stack);
|
||||
return scene_manager->scene_handlers->on_event_handlers[scene_id](
|
||||
|
||||
bool result = false;
|
||||
if(SceneManagerIdStack_size(scene_manager->scene_id_stack) > 0) {
|
||||
uint32_t* scene_id_p = SceneManagerIdStack_back(scene_manager->scene_id_stack);
|
||||
uint32_t scene_id = *scene_id_p;
|
||||
result = scene_manager->scene_handlers->on_event_handlers[scene_id](
|
||||
scene_manager->context, event);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool scene_manager_handle_back_event(SceneManager* scene_manager) {
|
||||
@ -59,9 +66,15 @@ bool scene_manager_handle_back_event(SceneManager* scene_manager) {
|
||||
SceneManagerEvent event = {
|
||||
.type = SceneManagerEventTypeBack,
|
||||
};
|
||||
uint32_t scene_id = *SceneManagerIdStack_back(scene_manager->scene_id_stack);
|
||||
bool consumed =
|
||||
scene_manager->scene_handlers->on_event_handlers[scene_id](scene_manager->context, event);
|
||||
|
||||
bool consumed = false;
|
||||
if(SceneManagerIdStack_size(scene_manager->scene_id_stack) > 0) {
|
||||
uint32_t* scene_id_p = SceneManagerIdStack_back(scene_manager->scene_id_stack);
|
||||
uint32_t scene_id = *scene_id_p;
|
||||
consumed = scene_manager->scene_handlers->on_event_handlers[scene_id](
|
||||
scene_manager->context, event);
|
||||
}
|
||||
|
||||
if(!consumed) {
|
||||
consumed = scene_manager_previous_scene(scene_manager);
|
||||
}
|
||||
@ -74,8 +87,12 @@ void scene_manager_handle_tick_event(SceneManager* scene_manager) {
|
||||
SceneManagerEvent event = {
|
||||
.type = SceneManagerEventTypeTick,
|
||||
};
|
||||
uint32_t scene_id = *SceneManagerIdStack_back(scene_manager->scene_id_stack);
|
||||
|
||||
if(SceneManagerIdStack_size(scene_manager->scene_id_stack) > 0) {
|
||||
uint32_t* scene_id_p = SceneManagerIdStack_back(scene_manager->scene_id_stack);
|
||||
uint32_t scene_id = *scene_id_p;
|
||||
scene_manager->scene_handlers->on_event_handlers[scene_id](scene_manager->context, event);
|
||||
}
|
||||
}
|
||||
|
||||
void scene_manager_next_scene(SceneManager* scene_manager, uint32_t next_scene_id) {
|
||||
@ -83,7 +100,7 @@ void scene_manager_next_scene(SceneManager* scene_manager, uint32_t next_scene_i
|
||||
furi_assert(next_scene_id < scene_manager->scene_handlers->scene_num);
|
||||
|
||||
// Check if it is not the first scene
|
||||
if(SceneManagerIdStack_size(scene_manager->scene_id_stack)) {
|
||||
if(SceneManagerIdStack_size(scene_manager->scene_id_stack) > 0) {
|
||||
uint32_t cur_scene_id = *SceneManagerIdStack_back(scene_manager->scene_id_stack);
|
||||
scene_manager->scene_handlers->on_exit_handlers[cur_scene_id](scene_manager->context);
|
||||
}
|
||||
@ -95,6 +112,7 @@ void scene_manager_next_scene(SceneManager* scene_manager, uint32_t next_scene_i
|
||||
bool scene_manager_previous_scene(SceneManager* scene_manager) {
|
||||
furi_assert(scene_manager);
|
||||
|
||||
if(SceneManagerIdStack_size(scene_manager->scene_id_stack) > 0) {
|
||||
uint32_t cur_scene_id = 0;
|
||||
SceneManagerIdStack_pop_back(&cur_scene_id, scene_manager->scene_id_stack);
|
||||
|
||||
@ -107,6 +125,9 @@ bool scene_manager_previous_scene(SceneManager* scene_manager) {
|
||||
scene_manager->scene_handlers->on_exit_handlers[cur_scene_id](scene_manager->context);
|
||||
scene_manager->scene_handlers->on_enter_handlers[prev_scene_id](scene_manager->context);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool scene_manager_search_and_switch_to_previous_scene(
|
||||
@ -114,6 +135,7 @@ bool scene_manager_search_and_switch_to_previous_scene(
|
||||
uint32_t scene_id) {
|
||||
furi_assert(scene_manager);
|
||||
|
||||
if(SceneManagerIdStack_size(scene_manager->scene_id_stack) > 0) {
|
||||
uint32_t prev_scene_id = 0;
|
||||
uint32_t cur_scene_id = *SceneManagerIdStack_back(scene_manager->scene_id_stack);
|
||||
SceneManagerIdStack_it_t scene_it;
|
||||
@ -138,11 +160,16 @@ bool scene_manager_search_and_switch_to_previous_scene(
|
||||
scene_manager->scene_handlers->on_enter_handlers[prev_scene_id](scene_manager->context);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool scene_manager_has_previous_scene(SceneManager* scene_manager, uint32_t scene_id) {
|
||||
furi_assert(scene_manager);
|
||||
bool scene_found = false;
|
||||
|
||||
if(SceneManagerIdStack_size(scene_manager->scene_id_stack) > 0) {
|
||||
uint32_t prev_scene_id;
|
||||
SceneManagerIdStack_it_t scene_it;
|
||||
SceneManagerIdStack_it_last(scene_it, scene_manager->scene_id_stack);
|
||||
@ -158,6 +185,7 @@ bool scene_manager_has_previous_scene(SceneManager* scene_manager, uint32_t scen
|
||||
scene_found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return scene_found;
|
||||
}
|
||||
|
||||
@ -167,6 +195,7 @@ bool scene_manager_search_and_switch_to_another_scene(
|
||||
furi_assert(scene_manager);
|
||||
furi_assert(scene_id < scene_manager->scene_handlers->scene_num);
|
||||
|
||||
if(SceneManagerIdStack_size(scene_manager->scene_id_stack) > 0) {
|
||||
uint32_t cur_scene_id = *SceneManagerIdStack_back(scene_manager->scene_id_stack);
|
||||
SceneManagerIdStack_it_t scene_it;
|
||||
SceneManagerIdStack_it(scene_it, scene_manager->scene_id_stack);
|
||||
@ -180,12 +209,15 @@ bool scene_manager_search_and_switch_to_another_scene(
|
||||
scene_manager->scene_handlers->on_enter_handlers[scene_id](scene_manager->context);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void scene_manager_stop(SceneManager* scene_manager) {
|
||||
furi_assert(scene_manager);
|
||||
|
||||
if(SceneManagerIdStack_size(scene_manager->scene_id_stack)) {
|
||||
if(SceneManagerIdStack_size(scene_manager->scene_id_stack) > 0) {
|
||||
uint32_t cur_scene_id = *SceneManagerIdStack_back(scene_manager->scene_id_stack);
|
||||
scene_manager->scene_handlers->on_exit_handlers[cur_scene_id](scene_manager->context);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "view_i.h"
|
||||
|
||||
View* view_alloc() {
|
||||
View* view = furi_alloc(sizeof(View));
|
||||
View* view = malloc(sizeof(View));
|
||||
view->orientation = ViewOrientationHorizontal;
|
||||
return view;
|
||||
}
|
||||
@ -78,12 +78,12 @@ void view_allocate_model(View* view, ViewModelType type, size_t size) {
|
||||
furi_assert(view->model == NULL);
|
||||
view->model_type = type;
|
||||
if(view->model_type == ViewModelTypeLockFree) {
|
||||
view->model = furi_alloc(size);
|
||||
view->model = malloc(size);
|
||||
} else if(view->model_type == ViewModelTypeLocking) {
|
||||
ViewModelLocking* model = furi_alloc(sizeof(ViewModelLocking));
|
||||
ViewModelLocking* model = malloc(sizeof(ViewModelLocking));
|
||||
model->mutex = osMutexNew(NULL);
|
||||
furi_check(model->mutex);
|
||||
model->data = furi_alloc(size);
|
||||
model->data = malloc(size);
|
||||
view->model = model;
|
||||
} else {
|
||||
furi_assert(false);
|
||||
|
@ -3,7 +3,7 @@
|
||||
#define TAG "ViewDispatcher"
|
||||
|
||||
ViewDispatcher* view_dispatcher_alloc() {
|
||||
ViewDispatcher* view_dispatcher = furi_alloc(sizeof(ViewDispatcher));
|
||||
ViewDispatcher* view_dispatcher = malloc(sizeof(ViewDispatcher));
|
||||
|
||||
view_dispatcher->view_port = view_port_alloc();
|
||||
view_port_draw_callback_set(
|
||||
|
@ -35,7 +35,7 @@ static void view_port_setup_canvas_orientation(const ViewPort* view_port, Canvas
|
||||
}
|
||||
|
||||
ViewPort* view_port_alloc() {
|
||||
ViewPort* view_port = furi_alloc(sizeof(ViewPort));
|
||||
ViewPort* view_port = malloc(sizeof(ViewPort));
|
||||
view_port->orientation = ViewPortOrientationHorizontal;
|
||||
view_port->is_enabled = true;
|
||||
return view_port;
|
||||
|
@ -62,7 +62,7 @@ static void view_stack_exit(void* context) {
|
||||
}
|
||||
|
||||
ViewStack* view_stack_alloc(void) {
|
||||
ViewStack* view_stack = furi_alloc(sizeof(ViewStack));
|
||||
ViewStack* view_stack = malloc(sizeof(ViewStack));
|
||||
view_stack->view = view_alloc();
|
||||
|
||||
view_allocate_model(view_stack->view, ViewModelTypeLocking, sizeof(ViewStackModel));
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <callback-connector.h>
|
||||
#include <m-string.h>
|
||||
#include <toolbox/path.h>
|
||||
#include <flipper_file/flipper_file.h>
|
||||
#include <flipper_format/flipper_format.h>
|
||||
|
||||
const char* iButtonApp::app_folder = "/any/ibutton";
|
||||
const char* iButtonApp::app_extension = ".ibtn";
|
||||
@ -191,7 +191,7 @@ bool iButtonApp::save_key(const char* key_name) {
|
||||
// Create ibutton directory if necessary
|
||||
make_app_folder();
|
||||
|
||||
FlipperFile* file = flipper_file_alloc(storage);
|
||||
FlipperFormat* file = flipper_format_file_alloc(storage);
|
||||
string_t key_file_name;
|
||||
bool result = false;
|
||||
string_init(key_file_name);
|
||||
@ -207,29 +207,29 @@ bool iButtonApp::save_key(const char* key_name) {
|
||||
string_printf(key_file_name, "%s/%s%s", app_folder, key.get_name(), app_extension);
|
||||
|
||||
// Open file for write
|
||||
if(!flipper_file_open_always(file, string_get_cstr(key_file_name))) break;
|
||||
if(!flipper_format_file_open_always(file, string_get_cstr(key_file_name))) break;
|
||||
|
||||
// Write header
|
||||
if(!flipper_file_write_header_cstr(file, iButtonApp::app_filetype, 1)) break;
|
||||
if(!flipper_format_write_header_cstr(file, iButtonApp::app_filetype, 1)) break;
|
||||
|
||||
// Write key type
|
||||
if(!flipper_file_write_comment_cstr(file, "Key type can be Cyfral, Dallas or Metakom"))
|
||||
if(!flipper_format_write_comment_cstr(file, "Key type can be Cyfral, Dallas or Metakom"))
|
||||
break;
|
||||
const char* key_type = key.get_key_type_string_by_type(key.get_key_type());
|
||||
if(!flipper_file_write_string_cstr(file, "Key type", key_type)) break;
|
||||
if(!flipper_format_write_string_cstr(file, "Key type", key_type)) break;
|
||||
|
||||
// Write data
|
||||
if(!flipper_file_write_comment_cstr(
|
||||
if(!flipper_format_write_comment_cstr(
|
||||
file, "Data size for Cyfral is 2, for Metakom is 4, for Dallas is 8"))
|
||||
break;
|
||||
|
||||
if(!flipper_file_write_hex(file, "Data", key.get_data(), key.get_type_data_size())) break;
|
||||
if(!flipper_format_write_hex(file, "Data", key.get_data(), key.get_type_data_size()))
|
||||
break;
|
||||
result = true;
|
||||
|
||||
} while(false);
|
||||
|
||||
flipper_file_close(file);
|
||||
flipper_file_free(file);
|
||||
flipper_format_free(file);
|
||||
|
||||
string_clear(key_file_name);
|
||||
|
||||
@ -241,28 +241,28 @@ bool iButtonApp::save_key(const char* key_name) {
|
||||
}
|
||||
|
||||
bool iButtonApp::load_key_data(string_t key_path) {
|
||||
FlipperFile* file = flipper_file_alloc(storage);
|
||||
FlipperFormat* file = flipper_format_file_alloc(storage);
|
||||
bool result = false;
|
||||
string_t data;
|
||||
string_init(data);
|
||||
|
||||
do {
|
||||
if(!flipper_file_open_existing(file, string_get_cstr(key_path))) break;
|
||||
if(!flipper_format_file_open_existing(file, string_get_cstr(key_path))) break;
|
||||
|
||||
// header
|
||||
uint32_t version;
|
||||
if(!flipper_file_read_header(file, data, &version)) break;
|
||||
if(!flipper_format_read_header(file, data, &version)) break;
|
||||
if(string_cmp_str(data, iButtonApp::app_filetype) != 0) break;
|
||||
if(version != 1) break;
|
||||
|
||||
// key type
|
||||
iButtonKeyType type;
|
||||
if(!flipper_file_read_string(file, "Key type", data)) break;
|
||||
if(!flipper_format_read_string(file, "Key type", data)) break;
|
||||
if(!key.get_key_type_by_type_string(string_get_cstr(data), &type)) break;
|
||||
|
||||
// key data
|
||||
uint8_t key_data[IBUTTON_KEY_DATA_SIZE] = {0};
|
||||
if(!flipper_file_read_hex(file, "Data", key_data, key.get_type_data_size_by_type(type)))
|
||||
if(!flipper_format_read_hex(file, "Data", key_data, key.get_type_data_size_by_type(type)))
|
||||
break;
|
||||
|
||||
key.set_type(type);
|
||||
@ -271,8 +271,7 @@ bool iButtonApp::load_key_data(string_t key_path) {
|
||||
result = true;
|
||||
} while(false);
|
||||
|
||||
flipper_file_close(file);
|
||||
flipper_file_free(file);
|
||||
flipper_format_free(file);
|
||||
string_clear(data);
|
||||
|
||||
if(!result) {
|
||||
|
@ -66,7 +66,7 @@ const char* input_get_type_name(InputType type) {
|
||||
}
|
||||
|
||||
int32_t input_srv() {
|
||||
input = furi_alloc(sizeof(Input));
|
||||
input = malloc(sizeof(Input));
|
||||
input->thread = osThreadGetId();
|
||||
input->event_pubsub = furi_pubsub_alloc();
|
||||
furi_record_create("input_events", input->event_pubsub);
|
||||
@ -78,7 +78,7 @@ int32_t input_srv() {
|
||||
}
|
||||
#endif
|
||||
|
||||
input->pin_states = furi_alloc(input_pins_count * sizeof(InputPinState));
|
||||
input->pin_states = malloc(input_pins_count * sizeof(InputPinState));
|
||||
|
||||
for(size_t i = 0; i < input_pins_count; i++) {
|
||||
GpioPin gpio = {(GPIO_TypeDef*)input_pins[i].port, (uint16_t)input_pins[i].pin};
|
||||
|
@ -145,7 +145,7 @@ static void irda_cli_start_ir_tx(Cli* cli, string_t args) {
|
||||
uint32_t frequency;
|
||||
float duty_cycle;
|
||||
uint32_t timings_cnt = MAX_TIMINGS_AMOUNT;
|
||||
uint32_t* timings = (uint32_t*)furi_alloc(sizeof(uint32_t) * timings_cnt);
|
||||
uint32_t* timings = (uint32_t*)malloc(sizeof(uint32_t) * timings_cnt);
|
||||
|
||||
if(parse_message(str, &message)) {
|
||||
irda_send(&message, 1);
|
||||
|
@ -4,37 +4,42 @@
|
||||
#include "irda/helpers/irda_parser.h"
|
||||
#include "irda_worker.h"
|
||||
#include "m-string.h"
|
||||
#include <flipper_file.h>
|
||||
#include <flipper_format/flipper_format.h>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <furi_hal_irda.h>
|
||||
|
||||
#define TAG "IrdaParser"
|
||||
|
||||
bool irda_parser_save_signal(FlipperFile* ff, const IrdaAppSignal& signal, const std::string& name) {
|
||||
bool irda_parser_save_signal(
|
||||
FlipperFormat* ff,
|
||||
const IrdaAppSignal& signal,
|
||||
const std::string& name) {
|
||||
furi_assert(ff);
|
||||
furi_assert(!name.empty());
|
||||
|
||||
bool result = false;
|
||||
|
||||
do {
|
||||
if(!flipper_file_write_comment_cstr(ff, "")) break;
|
||||
if(!flipper_file_write_string_cstr(ff, "name", name.c_str())) break;
|
||||
if(!flipper_format_write_comment_cstr(ff, "")) break;
|
||||
if(!flipper_format_write_string_cstr(ff, "name", name.c_str())) break;
|
||||
if(signal.is_raw()) {
|
||||
furi_assert(signal.get_raw_signal().timings_cnt <= MAX_TIMINGS_AMOUNT);
|
||||
auto raw_signal = signal.get_raw_signal();
|
||||
if(!flipper_file_write_string_cstr(ff, "type", "raw")) break;
|
||||
if(!flipper_file_write_uint32(ff, "frequency", &raw_signal.frequency, 1)) break;
|
||||
if(!flipper_file_write_float(ff, "duty_cycle", &raw_signal.duty_cycle, 1)) break;
|
||||
if(!flipper_file_write_uint32(ff, "data", raw_signal.timings, raw_signal.timings_cnt))
|
||||
if(!flipper_format_write_string_cstr(ff, "type", "raw")) break;
|
||||
if(!flipper_format_write_uint32(ff, "frequency", &raw_signal.frequency, 1)) break;
|
||||
if(!flipper_format_write_float(ff, "duty_cycle", &raw_signal.duty_cycle, 1)) break;
|
||||
if(!flipper_format_write_uint32(ff, "data", raw_signal.timings, raw_signal.timings_cnt))
|
||||
break;
|
||||
} else {
|
||||
auto parsed_signal = signal.get_message();
|
||||
const char* protocol_name = irda_get_protocol_name(parsed_signal.protocol);
|
||||
if(!flipper_file_write_string_cstr(ff, "type", "parsed")) break;
|
||||
if(!flipper_file_write_string_cstr(ff, "protocol", protocol_name)) break;
|
||||
if(!flipper_file_write_hex(ff, "address", (uint8_t*)&parsed_signal.address, 4)) break;
|
||||
if(!flipper_file_write_hex(ff, "command", (uint8_t*)&parsed_signal.command, 4)) break;
|
||||
if(!flipper_format_write_string_cstr(ff, "type", "parsed")) break;
|
||||
if(!flipper_format_write_string_cstr(ff, "protocol", protocol_name)) break;
|
||||
if(!flipper_format_write_hex(ff, "address", (uint8_t*)&parsed_signal.address, 4))
|
||||
break;
|
||||
if(!flipper_format_write_hex(ff, "command", (uint8_t*)&parsed_signal.command, 4))
|
||||
break;
|
||||
}
|
||||
result = true;
|
||||
} while(0);
|
||||
@ -42,7 +47,7 @@ bool irda_parser_save_signal(FlipperFile* ff, const IrdaAppSignal& signal, const
|
||||
return result;
|
||||
}
|
||||
|
||||
bool irda_parser_read_signal(FlipperFile* ff, IrdaAppSignal& signal, std::string& name) {
|
||||
bool irda_parser_read_signal(FlipperFormat* ff, IrdaAppSignal& signal, std::string& name) {
|
||||
furi_assert(ff);
|
||||
|
||||
bool result = false;
|
||||
@ -50,31 +55,31 @@ bool irda_parser_read_signal(FlipperFile* ff, IrdaAppSignal& signal, std::string
|
||||
string_init(read_string);
|
||||
|
||||
do {
|
||||
if(!flipper_file_read_string(ff, "name", read_string)) break;
|
||||
if(!flipper_format_read_string(ff, "name", read_string)) break;
|
||||
name = string_get_cstr(read_string);
|
||||
if(!flipper_file_read_string(ff, "type", read_string)) break;
|
||||
if(!flipper_format_read_string(ff, "type", read_string)) break;
|
||||
if(!string_cmp_str(read_string, "raw")) {
|
||||
uint32_t* timings = nullptr;
|
||||
uint32_t timings_cnt = 0;
|
||||
uint32_t frequency = 0;
|
||||
float duty_cycle = 0;
|
||||
|
||||
if(!flipper_file_read_uint32(ff, "frequency", &frequency, 1)) break;
|
||||
if(!flipper_file_read_float(ff, "duty_cycle", &duty_cycle, 1)) break;
|
||||
if(!flipper_file_get_value_count(ff, "data", &timings_cnt)) break;
|
||||
if(!flipper_format_read_uint32(ff, "frequency", &frequency, 1)) break;
|
||||
if(!flipper_format_read_float(ff, "duty_cycle", &duty_cycle, 1)) break;
|
||||
if(!flipper_format_get_value_count(ff, "data", &timings_cnt)) break;
|
||||
if(timings_cnt > MAX_TIMINGS_AMOUNT) break;
|
||||
timings = (uint32_t*)furi_alloc(sizeof(uint32_t) * timings_cnt);
|
||||
if(flipper_file_read_uint32(ff, "data", timings, timings_cnt)) {
|
||||
timings = (uint32_t*)malloc(sizeof(uint32_t) * timings_cnt);
|
||||
if(flipper_format_read_uint32(ff, "data", timings, timings_cnt)) {
|
||||
signal.set_raw_signal(timings, timings_cnt, frequency, duty_cycle);
|
||||
result = true;
|
||||
}
|
||||
free(timings);
|
||||
} else if(!string_cmp_str(read_string, "parsed")) {
|
||||
IrdaMessage parsed_signal;
|
||||
if(!flipper_file_read_string(ff, "protocol", read_string)) break;
|
||||
if(!flipper_format_read_string(ff, "protocol", read_string)) break;
|
||||
parsed_signal.protocol = irda_get_protocol_by_name(string_get_cstr(read_string));
|
||||
if(!flipper_file_read_hex(ff, "address", (uint8_t*)&parsed_signal.address, 4)) break;
|
||||
if(!flipper_file_read_hex(ff, "command", (uint8_t*)&parsed_signal.command, 4)) break;
|
||||
if(!flipper_format_read_hex(ff, "address", (uint8_t*)&parsed_signal.address, 4)) break;
|
||||
if(!flipper_format_read_hex(ff, "command", (uint8_t*)&parsed_signal.command, 4)) break;
|
||||
if(!irda_parser_is_parsed_signal_valid(&parsed_signal)) break;
|
||||
signal.set_message(&parsed_signal);
|
||||
result = true;
|
||||
|
@ -1,10 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "../irda_app_signal.h"
|
||||
#include <flipper_file.h>
|
||||
#include <flipper_format/flipper_format.h>
|
||||
#include <string>
|
||||
|
||||
bool irda_parser_save_signal(FlipperFile* ff, const IrdaAppSignal& signal, const std::string& name);
|
||||
bool irda_parser_read_signal(FlipperFile* ff, IrdaAppSignal& signal, std::string& name);
|
||||
bool irda_parser_save_signal(
|
||||
FlipperFormat* ff,
|
||||
const IrdaAppSignal& signal,
|
||||
const std::string& name);
|
||||
bool irda_parser_read_signal(FlipperFormat* ff, IrdaAppSignal& signal, std::string& name);
|
||||
bool irda_parser_is_parsed_signal_valid(const IrdaMessage* signal);
|
||||
bool irda_parser_is_raw_signal_valid(uint32_t frequency, float duty_cycle, uint32_t timings_cnt);
|
||||
|
@ -16,15 +16,15 @@ bool IrdaAppBruteForce::calculate_messages() {
|
||||
bool result = false;
|
||||
|
||||
Storage* storage = static_cast<Storage*>(furi_record_open("storage"));
|
||||
FlipperFile* ff = flipper_file_alloc(storage);
|
||||
result = flipper_file_open_existing(ff, universal_db_filename);
|
||||
FlipperFormat* ff = flipper_format_file_alloc(storage);
|
||||
result = flipper_format_file_open_existing(ff, universal_db_filename);
|
||||
|
||||
if(result) {
|
||||
IrdaAppSignal signal;
|
||||
|
||||
string_t signal_name;
|
||||
string_init(signal_name);
|
||||
while(flipper_file_read_string(ff, "name", signal_name)) {
|
||||
while(flipper_format_read_string(ff, "name", signal_name)) {
|
||||
auto element = records.find(string_get_cstr(signal_name));
|
||||
if(element != records.cend()) {
|
||||
++element->second.amount;
|
||||
@ -33,8 +33,7 @@ bool IrdaAppBruteForce::calculate_messages() {
|
||||
string_clear(signal_name);
|
||||
}
|
||||
|
||||
flipper_file_close(ff);
|
||||
flipper_file_free(ff);
|
||||
flipper_format_free(ff);
|
||||
furi_record_close("storage");
|
||||
return result;
|
||||
}
|
||||
@ -45,8 +44,7 @@ void IrdaAppBruteForce::stop_bruteforce() {
|
||||
if(current_record.size()) {
|
||||
furi_assert(ff);
|
||||
current_record.clear();
|
||||
flipper_file_close(ff);
|
||||
flipper_file_free(ff);
|
||||
flipper_format_free(ff);
|
||||
furi_record_close("storage");
|
||||
}
|
||||
}
|
||||
@ -84,11 +82,10 @@ bool IrdaAppBruteForce::start_bruteforce(int index, int& record_amount) {
|
||||
|
||||
if(record_amount) {
|
||||
Storage* storage = static_cast<Storage*>(furi_record_open("storage"));
|
||||
ff = flipper_file_alloc(storage);
|
||||
result = flipper_file_open_existing(ff, universal_db_filename);
|
||||
ff = flipper_format_file_alloc(storage);
|
||||
result = flipper_format_file_open_existing(ff, universal_db_filename);
|
||||
if(!result) {
|
||||
flipper_file_close(ff);
|
||||
flipper_file_free(ff);
|
||||
flipper_format_free(ff);
|
||||
furi_record_close("storage");
|
||||
}
|
||||
}
|
||||
|
@ -2,12 +2,12 @@
|
||||
|
||||
#include <unordered_map>
|
||||
#include <memory>
|
||||
#include <flipper_file.h>
|
||||
#include <flipper_format/flipper_format.h>
|
||||
|
||||
class IrdaAppBruteForce {
|
||||
const char* universal_db_filename;
|
||||
std::string current_record;
|
||||
FlipperFile* ff;
|
||||
FlipperFormat* ff;
|
||||
|
||||
typedef struct {
|
||||
int index;
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <file_worker_cpp.h>
|
||||
#include <flipper_file.h>
|
||||
#include <flipper_format/flipper_format.h>
|
||||
#include "irda_app_remote_manager.h"
|
||||
#include "irda/helpers/irda_parser.h"
|
||||
#include "irda/irda_app_signal.h"
|
||||
@ -169,12 +169,12 @@ bool IrdaAppRemoteManager::store(void) {
|
||||
if(!file_worker.mkdir(IrdaApp::irda_directory)) return false;
|
||||
|
||||
Storage* storage = static_cast<Storage*>(furi_record_open("storage"));
|
||||
FlipperFile* ff = flipper_file_alloc(storage);
|
||||
FlipperFormat* ff = flipper_format_file_alloc(storage);
|
||||
|
||||
FURI_LOG_I("RemoteManager", "store file: \'%s\'", make_full_name(remote->name).c_str());
|
||||
result = flipper_file_open_always(ff, make_full_name(remote->name).c_str());
|
||||
result = flipper_format_file_open_always(ff, make_full_name(remote->name).c_str());
|
||||
if(result) {
|
||||
result = flipper_file_write_header_cstr(ff, "IR signals file", 1);
|
||||
result = flipper_format_write_header_cstr(ff, "IR signals file", 1);
|
||||
}
|
||||
if(result) {
|
||||
for(const auto& button : remote->buttons) {
|
||||
@ -185,8 +185,7 @@ bool IrdaAppRemoteManager::store(void) {
|
||||
}
|
||||
}
|
||||
|
||||
flipper_file_close(ff);
|
||||
flipper_file_free(ff);
|
||||
flipper_format_free(ff);
|
||||
furi_record_close("storage");
|
||||
return result;
|
||||
}
|
||||
@ -194,15 +193,15 @@ bool IrdaAppRemoteManager::store(void) {
|
||||
bool IrdaAppRemoteManager::load(const std::string& remote_name) {
|
||||
bool result = false;
|
||||
Storage* storage = static_cast<Storage*>(furi_record_open("storage"));
|
||||
FlipperFile* ff = flipper_file_alloc(storage);
|
||||
FlipperFormat* ff = flipper_format_file_alloc(storage);
|
||||
|
||||
FURI_LOG_I("RemoteManager", "load file: \'%s\'", make_full_name(remote_name).c_str());
|
||||
result = flipper_file_open_existing(ff, make_full_name(remote_name).c_str());
|
||||
result = flipper_format_file_open_existing(ff, make_full_name(remote_name).c_str());
|
||||
if(result) {
|
||||
string_t header;
|
||||
string_init(header);
|
||||
uint32_t version;
|
||||
result = flipper_file_read_header(ff, header, &version);
|
||||
result = flipper_format_read_header(ff, header, &version);
|
||||
if(result) {
|
||||
result = !string_cmp_str(header, "IR signals file") && (version == 1);
|
||||
}
|
||||
@ -217,8 +216,7 @@ bool IrdaAppRemoteManager::load(const std::string& remote_name) {
|
||||
}
|
||||
}
|
||||
|
||||
flipper_file_close(ff);
|
||||
flipper_file_free(ff);
|
||||
flipper_format_free(ff);
|
||||
furi_record_close("storage");
|
||||
return result;
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ void popup_brut_set_progress_max(IrdaAppPopupBrut* popup_brut, uint16_t progress
|
||||
}
|
||||
|
||||
IrdaAppPopupBrut* popup_brut_alloc(void) {
|
||||
return (IrdaAppPopupBrut*)furi_alloc(sizeof(IrdaAppPopupBrut));
|
||||
return (IrdaAppPopupBrut*)malloc(sizeof(IrdaAppPopupBrut));
|
||||
}
|
||||
|
||||
void popup_brut_free(IrdaAppPopupBrut* popup_brut) {
|
||||
|
@ -99,7 +99,7 @@ static void signal_received_callback(void* context, IrdaWorkerSignal* received_s
|
||||
int32_t irda_monitor_app(void* p) {
|
||||
(void)p;
|
||||
|
||||
IrdaMonitor* irda_monitor = furi_alloc(sizeof(IrdaMonitor));
|
||||
IrdaMonitor* irda_monitor = malloc(sizeof(IrdaMonitor));
|
||||
irda_monitor->display_text[0] = 0;
|
||||
irda_monitor->event_queue = osMessageQueueNew(1, sizeof(InputEvent), NULL);
|
||||
irda_monitor->view_port = view_port_alloc();
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include "scene/lfrfid_app_scene_delete_success.h"
|
||||
|
||||
#include <toolbox/path.h>
|
||||
#include <flipper_file/flipper_file.h>
|
||||
#include <flipper_format/flipper_format.h>
|
||||
|
||||
const char* LfRfidApp::app_folder = "/any/lfrfid";
|
||||
const char* LfRfidApp::app_extension = ".rfid";
|
||||
@ -119,17 +119,17 @@ bool LfRfidApp::delete_key(RfidKey* key) {
|
||||
}
|
||||
|
||||
bool LfRfidApp::load_key_data(const char* path, RfidKey* key) {
|
||||
FlipperFile* file = flipper_file_alloc(storage);
|
||||
FlipperFormat* file = flipper_format_file_alloc(storage);
|
||||
bool result = false;
|
||||
string_t str_result;
|
||||
string_init(str_result);
|
||||
|
||||
do {
|
||||
if(!flipper_file_open_existing(file, path)) break;
|
||||
if(!flipper_format_file_open_existing(file, path)) break;
|
||||
|
||||
// header
|
||||
uint32_t version;
|
||||
if(!flipper_file_read_header(file, str_result, &version)) break;
|
||||
if(!flipper_format_read_header(file, str_result, &version)) break;
|
||||
if(string_cmp_str(str_result, app_filetype) != 0) break;
|
||||
if(version != 1) break;
|
||||
|
||||
@ -137,13 +137,14 @@ bool LfRfidApp::load_key_data(const char* path, RfidKey* key) {
|
||||
LfrfidKeyType type;
|
||||
RfidKey loaded_key;
|
||||
|
||||
if(!flipper_file_read_string(file, "Key type", str_result)) break;
|
||||
if(!flipper_format_read_string(file, "Key type", str_result)) break;
|
||||
if(!lfrfid_key_get_string_type(string_get_cstr(str_result), &type)) break;
|
||||
loaded_key.set_type(type);
|
||||
|
||||
// key data
|
||||
uint8_t key_data[loaded_key.get_type_data_count()] = {};
|
||||
if(!flipper_file_read_hex(file, "Data", key_data, loaded_key.get_type_data_count())) break;
|
||||
if(!flipper_format_read_hex(file, "Data", key_data, loaded_key.get_type_data_count()))
|
||||
break;
|
||||
loaded_key.set_data(key_data, loaded_key.get_type_data_count());
|
||||
|
||||
path_extract_filename_no_ext(path, str_result);
|
||||
@ -153,8 +154,7 @@ bool LfRfidApp::load_key_data(const char* path, RfidKey* key) {
|
||||
result = true;
|
||||
} while(0);
|
||||
|
||||
flipper_file_close(file);
|
||||
flipper_file_free(file);
|
||||
flipper_format_free(file);
|
||||
string_clear(str_result);
|
||||
|
||||
if(!result) {
|
||||
@ -165,27 +165,26 @@ bool LfRfidApp::load_key_data(const char* path, RfidKey* key) {
|
||||
}
|
||||
|
||||
bool LfRfidApp::save_key_data(const char* path, RfidKey* key) {
|
||||
FlipperFile* file = flipper_file_alloc(storage);
|
||||
FlipperFormat* file = flipper_format_file_alloc(storage);
|
||||
bool result = false;
|
||||
|
||||
do {
|
||||
if(!flipper_file_open_always(file, path)) break;
|
||||
if(!flipper_file_write_header_cstr(file, app_filetype, 1)) break;
|
||||
if(!flipper_file_write_comment_cstr(file, "Key type can be EM4100, H10301 or I40134"))
|
||||
if(!flipper_format_file_open_always(file, path)) break;
|
||||
if(!flipper_format_write_header_cstr(file, app_filetype, 1)) break;
|
||||
if(!flipper_format_write_comment_cstr(file, "Key type can be EM4100, H10301 or I40134"))
|
||||
break;
|
||||
if(!flipper_file_write_string_cstr(
|
||||
if(!flipper_format_write_string_cstr(
|
||||
file, "Key type", lfrfid_key_get_type_string(key->get_type())))
|
||||
break;
|
||||
if(!flipper_file_write_comment_cstr(
|
||||
if(!flipper_format_write_comment_cstr(
|
||||
file, "Data size for EM4100 is 5, for H10301 is 3, for I40134 is 3"))
|
||||
break;
|
||||
if(!flipper_file_write_hex(file, "Data", key->get_data(), key->get_type_data_count()))
|
||||
if(!flipper_format_write_hex(file, "Data", key->get_data(), key->get_type_data_count()))
|
||||
break;
|
||||
result = true;
|
||||
} while(0);
|
||||
|
||||
flipper_file_close(file);
|
||||
flipper_file_free(file);
|
||||
flipper_format_free(file);
|
||||
|
||||
if(!result) {
|
||||
dialog_message_show_storage_error(dialogs, "Cannot save\nkey file");
|
||||
|
@ -278,7 +278,7 @@ static uint32_t loader_back_to_primary_menu(void* context) {
|
||||
}
|
||||
|
||||
static Loader* loader_alloc() {
|
||||
Loader* instance = furi_alloc(sizeof(Loader));
|
||||
Loader* instance = malloc(sizeof(Loader));
|
||||
|
||||
instance->application_thread = furi_thread_alloc();
|
||||
furi_thread_enable_heap_trace(instance->application_thread);
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "nfc_emv_parser.h"
|
||||
#include <lib/flipper_file/flipper_file.h>
|
||||
#include <flipper_format/flipper_format.h>
|
||||
|
||||
static const char* nfc_resources_header = "Flipper EMV resources";
|
||||
static const uint32_t nfc_resources_file_version = 1;
|
||||
@ -10,25 +10,25 @@ static bool nfc_emv_parser_search_data(
|
||||
string_t key,
|
||||
string_t data) {
|
||||
bool parsed = false;
|
||||
FlipperFile* file = flipper_file_alloc(storage);
|
||||
FlipperFormat* file = flipper_format_file_alloc(storage);
|
||||
string_t temp_str;
|
||||
string_init(temp_str);
|
||||
|
||||
do {
|
||||
// Open file
|
||||
if(!flipper_file_open_existing(file, file_name)) break;
|
||||
if(!flipper_format_file_open_existing(file, file_name)) break;
|
||||
// Read file header and version
|
||||
uint32_t version = 0;
|
||||
if(!flipper_file_read_header(file, temp_str, &version)) break;
|
||||
if(!flipper_format_read_header(file, temp_str, &version)) break;
|
||||
if(string_cmp_str(temp_str, nfc_resources_header) ||
|
||||
(version != nfc_resources_file_version))
|
||||
break;
|
||||
if(!flipper_file_read_string(file, string_get_cstr(key), data)) break;
|
||||
if(!flipper_format_read_string(file, string_get_cstr(key), data)) break;
|
||||
parsed = true;
|
||||
} while(false);
|
||||
|
||||
string_clear(temp_str);
|
||||
flipper_file_free(file);
|
||||
flipper_format_free(file);
|
||||
return parsed;
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ void nfc_tick_event_callback(void* context) {
|
||||
}
|
||||
|
||||
Nfc* nfc_alloc() {
|
||||
Nfc* nfc = furi_alloc(sizeof(Nfc));
|
||||
Nfc* nfc = malloc(sizeof(Nfc));
|
||||
|
||||
nfc->worker = nfc_worker_alloc();
|
||||
nfc->view_dispatcher = view_dispatcher_alloc();
|
||||
|
@ -1,14 +1,14 @@
|
||||
#include "nfc_device.h"
|
||||
#include "nfc_types.h"
|
||||
|
||||
#include <lib/toolbox/path.h>
|
||||
#include <lib/flipper_file/flipper_file.h>
|
||||
#include <toolbox/path.h>
|
||||
#include <flipper_format/flipper_format.h>
|
||||
|
||||
static const char* nfc_file_header = "Flipper NFC device";
|
||||
static const uint32_t nfc_file_version = 2;
|
||||
|
||||
NfcDevice* nfc_device_alloc() {
|
||||
NfcDevice* nfc_dev = furi_alloc(sizeof(NfcDevice));
|
||||
NfcDevice* nfc_dev = malloc(sizeof(NfcDevice));
|
||||
nfc_dev->storage = furi_record_open("storage");
|
||||
nfc_dev->dialogs = furi_record_open("dialogs");
|
||||
return nfc_dev;
|
||||
@ -56,7 +56,7 @@ bool nfc_device_parse_format_string(NfcDevice* dev, string_t format_string) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool nfc_device_save_mifare_ul_data(FlipperFile* file, NfcDevice* dev) {
|
||||
static bool nfc_device_save_mifare_ul_data(FlipperFormat* file, NfcDevice* dev) {
|
||||
bool saved = false;
|
||||
MifareUlData* data = &dev->dev_data.mf_ul_data;
|
||||
string_t temp_str;
|
||||
@ -64,22 +64,23 @@ static bool nfc_device_save_mifare_ul_data(FlipperFile* file, NfcDevice* dev) {
|
||||
|
||||
// Save Mifare Ultralight specific data
|
||||
do {
|
||||
if(!flipper_file_write_comment_cstr(file, "Mifare Ultralight specific data")) break;
|
||||
if(!flipper_file_write_hex(file, "Signature", data->signature, sizeof(data->signature)))
|
||||
if(!flipper_format_write_comment_cstr(file, "Mifare Ultralight specific data")) break;
|
||||
if(!flipper_format_write_hex(file, "Signature", data->signature, sizeof(data->signature)))
|
||||
break;
|
||||
if(!flipper_file_write_hex(
|
||||
if(!flipper_format_write_hex(
|
||||
file, "Mifare version", (uint8_t*)&data->version, sizeof(data->version)))
|
||||
break;
|
||||
// Write conters and tearing flags data
|
||||
bool counters_saved = true;
|
||||
for(uint8_t i = 0; i < 3; i++) {
|
||||
string_printf(temp_str, "Counter %d", i);
|
||||
if(!flipper_file_write_uint32(file, string_get_cstr(temp_str), &data->counter[i], 1)) {
|
||||
if(!flipper_format_write_uint32(
|
||||
file, string_get_cstr(temp_str), &data->counter[i], 1)) {
|
||||
counters_saved = false;
|
||||
break;
|
||||
}
|
||||
string_printf(temp_str, "Tearing %d", i);
|
||||
if(!flipper_file_write_hex(file, string_get_cstr(temp_str), &data->tearing[i], 1)) {
|
||||
if(!flipper_format_write_hex(file, string_get_cstr(temp_str), &data->tearing[i], 1)) {
|
||||
counters_saved = false;
|
||||
break;
|
||||
}
|
||||
@ -87,11 +88,11 @@ static bool nfc_device_save_mifare_ul_data(FlipperFile* file, NfcDevice* dev) {
|
||||
if(!counters_saved) break;
|
||||
// Write pages data
|
||||
uint32_t pages_total = data->data_size / 4;
|
||||
if(!flipper_file_write_uint32(file, "Pages total", &pages_total, 1)) break;
|
||||
if(!flipper_format_write_uint32(file, "Pages total", &pages_total, 1)) break;
|
||||
bool pages_saved = true;
|
||||
for(uint16_t i = 0; i < data->data_size; i += 4) {
|
||||
string_printf(temp_str, "Page %d", i / 4);
|
||||
if(!flipper_file_write_hex(file, string_get_cstr(temp_str), &data->data[i], 4)) {
|
||||
if(!flipper_format_write_hex(file, string_get_cstr(temp_str), &data->data[i], 4)) {
|
||||
pages_saved = false;
|
||||
break;
|
||||
}
|
||||
@ -104,7 +105,7 @@ static bool nfc_device_save_mifare_ul_data(FlipperFile* file, NfcDevice* dev) {
|
||||
return saved;
|
||||
}
|
||||
|
||||
bool nfc_device_load_mifare_ul_data(FlipperFile* file, NfcDevice* dev) {
|
||||
bool nfc_device_load_mifare_ul_data(FlipperFormat* file, NfcDevice* dev) {
|
||||
bool parsed = false;
|
||||
MifareUlData* data = &dev->dev_data.mf_ul_data;
|
||||
string_t temp_str;
|
||||
@ -112,22 +113,22 @@ bool nfc_device_load_mifare_ul_data(FlipperFile* file, NfcDevice* dev) {
|
||||
|
||||
do {
|
||||
// Read signature
|
||||
if(!flipper_file_read_hex(file, "Signature", data->signature, sizeof(data->signature)))
|
||||
if(!flipper_format_read_hex(file, "Signature", data->signature, sizeof(data->signature)))
|
||||
break;
|
||||
// Read Mifare version
|
||||
if(!flipper_file_read_hex(
|
||||
if(!flipper_format_read_hex(
|
||||
file, "Mifare version", (uint8_t*)&data->version, sizeof(data->version)))
|
||||
break;
|
||||
// Read counters and tearing flags
|
||||
bool counters_parsed = true;
|
||||
for(uint8_t i = 0; i < 3; i++) {
|
||||
string_printf(temp_str, "Counter %d", i);
|
||||
if(!flipper_file_read_uint32(file, string_get_cstr(temp_str), &data->counter[i], 1)) {
|
||||
if(!flipper_format_read_uint32(file, string_get_cstr(temp_str), &data->counter[i], 1)) {
|
||||
counters_parsed = false;
|
||||
break;
|
||||
}
|
||||
string_printf(temp_str, "Tearing %d", i);
|
||||
if(!flipper_file_read_hex(file, string_get_cstr(temp_str), &data->tearing[i], 1)) {
|
||||
if(!flipper_format_read_hex(file, string_get_cstr(temp_str), &data->tearing[i], 1)) {
|
||||
counters_parsed = false;
|
||||
break;
|
||||
}
|
||||
@ -135,12 +136,12 @@ bool nfc_device_load_mifare_ul_data(FlipperFile* file, NfcDevice* dev) {
|
||||
if(!counters_parsed) break;
|
||||
// Read pages
|
||||
uint32_t pages = 0;
|
||||
if(!flipper_file_read_uint32(file, "Pages total", &pages, 1)) break;
|
||||
if(!flipper_format_read_uint32(file, "Pages total", &pages, 1)) break;
|
||||
data->data_size = pages * 4;
|
||||
bool pages_parsed = true;
|
||||
for(uint16_t i = 0; i < pages; i++) {
|
||||
string_printf(temp_str, "Page %d", i);
|
||||
if(!flipper_file_read_hex(file, string_get_cstr(temp_str), &data->data[i * 4], 4)) {
|
||||
if(!flipper_format_read_hex(file, string_get_cstr(temp_str), &data->data[i * 4], 4)) {
|
||||
pages_parsed = false;
|
||||
break;
|
||||
}
|
||||
@ -153,28 +154,28 @@ bool nfc_device_load_mifare_ul_data(FlipperFile* file, NfcDevice* dev) {
|
||||
return parsed;
|
||||
}
|
||||
|
||||
static bool nfc_device_save_bank_card_data(FlipperFile* file, NfcDevice* dev) {
|
||||
static bool nfc_device_save_bank_card_data(FlipperFormat* file, NfcDevice* dev) {
|
||||
bool saved = false;
|
||||
NfcEmvData* data = &dev->dev_data.emv_data;
|
||||
uint32_t data_temp = 0;
|
||||
|
||||
do {
|
||||
// Write Bank card specific data
|
||||
if(!flipper_file_write_comment_cstr(file, "Bank card specific data")) break;
|
||||
if(!flipper_file_write_hex(file, "AID", data->aid, data->aid_len)) break;
|
||||
if(!flipper_file_write_string_cstr(file, "Name", data->name)) break;
|
||||
if(!flipper_file_write_hex(file, "Number", data->number, data->number_len)) break;
|
||||
if(!flipper_format_write_comment_cstr(file, "Bank card specific data")) break;
|
||||
if(!flipper_format_write_hex(file, "AID", data->aid, data->aid_len)) break;
|
||||
if(!flipper_format_write_string_cstr(file, "Name", data->name)) break;
|
||||
if(!flipper_format_write_hex(file, "Number", data->number, data->number_len)) break;
|
||||
if(data->exp_mon) {
|
||||
uint8_t exp_data[2] = {data->exp_mon, data->exp_year};
|
||||
if(!flipper_file_write_hex(file, "Exp data", exp_data, sizeof(exp_data))) break;
|
||||
if(!flipper_format_write_hex(file, "Exp data", exp_data, sizeof(exp_data))) break;
|
||||
}
|
||||
if(data->country_code) {
|
||||
data_temp = data->country_code;
|
||||
if(!flipper_file_write_uint32(file, "Country code", &data_temp, 1)) break;
|
||||
if(!flipper_format_write_uint32(file, "Country code", &data_temp, 1)) break;
|
||||
}
|
||||
if(data->currency_code) {
|
||||
data_temp = data->currency_code;
|
||||
if(!flipper_file_write_uint32(file, "Currency code", &data_temp, 1)) break;
|
||||
if(!flipper_format_write_uint32(file, "Currency code", &data_temp, 1)) break;
|
||||
}
|
||||
saved = true;
|
||||
} while(false);
|
||||
@ -182,7 +183,7 @@ static bool nfc_device_save_bank_card_data(FlipperFile* file, NfcDevice* dev) {
|
||||
return saved;
|
||||
}
|
||||
|
||||
bool nfc_device_load_bank_card_data(FlipperFile* file, NfcDevice* dev) {
|
||||
bool nfc_device_load_bank_card_data(FlipperFormat* file, NfcDevice* dev) {
|
||||
bool parsed = false;
|
||||
NfcEmvData* data = &dev->dev_data.emv_data;
|
||||
memset(data, 0, sizeof(NfcEmvData));
|
||||
@ -192,25 +193,25 @@ bool nfc_device_load_bank_card_data(FlipperFile* file, NfcDevice* dev) {
|
||||
|
||||
do {
|
||||
// Load essential data
|
||||
if(!flipper_file_get_value_count(file, "AID", &data_cnt)) break;
|
||||
if(!flipper_format_get_value_count(file, "AID", &data_cnt)) break;
|
||||
data->aid_len = data_cnt;
|
||||
if(!flipper_file_read_hex(file, "AID", data->aid, data->aid_len)) break;
|
||||
if(!flipper_file_read_string(file, "Name", temp_str)) break;
|
||||
if(!flipper_format_read_hex(file, "AID", data->aid, data->aid_len)) break;
|
||||
if(!flipper_format_read_string(file, "Name", temp_str)) break;
|
||||
strlcpy(data->name, string_get_cstr(temp_str), sizeof(data->name));
|
||||
if(!flipper_file_get_value_count(file, "Number", &data_cnt)) break;
|
||||
if(!flipper_format_get_value_count(file, "Number", &data_cnt)) break;
|
||||
data->number_len = data_cnt;
|
||||
if(!flipper_file_read_hex(file, "Number", data->number, data->number_len)) break;
|
||||
if(!flipper_format_read_hex(file, "Number", data->number, data->number_len)) break;
|
||||
parsed = true;
|
||||
// Load optional data
|
||||
uint8_t exp_data[2] = {};
|
||||
if(flipper_file_read_hex(file, "Exp data", exp_data, 2)) {
|
||||
if(flipper_format_read_hex(file, "Exp data", exp_data, 2)) {
|
||||
data->exp_mon = exp_data[0];
|
||||
data->exp_year = exp_data[1];
|
||||
}
|
||||
if(flipper_file_read_uint32(file, "Country code", &data_cnt, 1)) {
|
||||
if(flipper_format_read_uint32(file, "Country code", &data_cnt, 1)) {
|
||||
data->country_code = data_cnt;
|
||||
}
|
||||
if(flipper_file_read_uint32(file, "Currency code", &data_cnt, 1)) {
|
||||
if(flipper_format_read_uint32(file, "Currency code", &data_cnt, 1)) {
|
||||
data->currency_code = data_cnt;
|
||||
}
|
||||
} while(false);
|
||||
@ -233,7 +234,7 @@ static bool nfc_device_save_file(
|
||||
furi_assert(dev);
|
||||
|
||||
bool saved = false;
|
||||
FlipperFile* file = flipper_file_alloc(dev->storage);
|
||||
FlipperFormat* file = flipper_format_file_alloc(dev->storage);
|
||||
NfcDeviceCommonData* data = &dev->dev_data.nfc_data;
|
||||
string_t temp_str;
|
||||
string_init(temp_str);
|
||||
@ -244,21 +245,21 @@ static bool nfc_device_save_file(
|
||||
// First remove nfc device file if it was saved
|
||||
string_printf(temp_str, "%s/%s%s", folder, dev_name, extension);
|
||||
// Open file
|
||||
if(!flipper_file_open_always(file, string_get_cstr(temp_str))) break;
|
||||
if(!flipper_format_file_open_always(file, string_get_cstr(temp_str))) break;
|
||||
// Write header
|
||||
if(!flipper_file_write_header_cstr(file, nfc_file_header, nfc_file_version)) break;
|
||||
if(!flipper_format_write_header_cstr(file, nfc_file_header, nfc_file_version)) break;
|
||||
// Write nfc device type
|
||||
if(!flipper_file_write_comment_cstr(
|
||||
if(!flipper_format_write_comment_cstr(
|
||||
file, "Nfc device type can be UID, Mifare Ultralight, Bank card"))
|
||||
break;
|
||||
nfc_device_prepare_format_string(dev, temp_str);
|
||||
if(!flipper_file_write_string(file, "Device type", temp_str)) break;
|
||||
if(!flipper_format_write_string(file, "Device type", temp_str)) break;
|
||||
// Write UID, ATQA, SAK
|
||||
if(!flipper_file_write_comment_cstr(file, "UID, ATQA and SAK are common for all formats"))
|
||||
if(!flipper_format_write_comment_cstr(file, "UID, ATQA and SAK are common for all formats"))
|
||||
break;
|
||||
if(!flipper_file_write_hex(file, "UID", data->uid, data->uid_len)) break;
|
||||
if(!flipper_file_write_hex(file, "ATQA", data->atqa, 2)) break;
|
||||
if(!flipper_file_write_hex(file, "SAK", &data->sak, 1)) break;
|
||||
if(!flipper_format_write_hex(file, "UID", data->uid, data->uid_len)) break;
|
||||
if(!flipper_format_write_hex(file, "ATQA", data->atqa, 2)) break;
|
||||
if(!flipper_format_write_hex(file, "SAK", &data->sak, 1)) break;
|
||||
// Save more data if necessary
|
||||
if(dev->format == NfcDeviceSaveFormatMifareUl) {
|
||||
if(!nfc_device_save_mifare_ul_data(file, dev)) break;
|
||||
@ -272,8 +273,7 @@ static bool nfc_device_save_file(
|
||||
dialog_message_show_storage_error(dev->dialogs, "Can not save\nkey file");
|
||||
}
|
||||
string_clear(temp_str);
|
||||
flipper_file_close(file);
|
||||
flipper_file_free(file);
|
||||
flipper_format_free(file);
|
||||
return saved;
|
||||
}
|
||||
|
||||
@ -288,7 +288,7 @@ bool nfc_device_save_shadow(NfcDevice* dev, const char* dev_name) {
|
||||
|
||||
static bool nfc_device_load_data(NfcDevice* dev, string_t path) {
|
||||
bool parsed = false;
|
||||
FlipperFile* file = flipper_file_alloc(dev->storage);
|
||||
FlipperFormat* file = flipper_format_file_alloc(dev->storage);
|
||||
NfcDeviceCommonData* data = &dev->dev_data.nfc_data;
|
||||
uint32_t data_cnt = 0;
|
||||
string_t temp_str;
|
||||
@ -304,26 +304,26 @@ static bool nfc_device_load_data(NfcDevice* dev, string_t path) {
|
||||
storage_common_stat(dev->storage, string_get_cstr(temp_str), NULL) == FSE_OK;
|
||||
// Open shadow file if it exists. If not - open original
|
||||
if(dev->shadow_file_exist) {
|
||||
if(!flipper_file_open_existing(file, string_get_cstr(temp_str))) break;
|
||||
if(!flipper_format_file_open_existing(file, string_get_cstr(temp_str))) break;
|
||||
} else {
|
||||
if(!flipper_file_open_existing(file, string_get_cstr(path))) break;
|
||||
if(!flipper_format_file_open_existing(file, string_get_cstr(path))) break;
|
||||
}
|
||||
// Read and verify file header
|
||||
uint32_t version = 0;
|
||||
if(!flipper_file_read_header(file, temp_str, &version)) break;
|
||||
if(!flipper_format_read_header(file, temp_str, &version)) break;
|
||||
if(string_cmp_str(temp_str, nfc_file_header) || (version != nfc_file_version)) {
|
||||
depricated_version = true;
|
||||
break;
|
||||
}
|
||||
// Read Nfc device type
|
||||
if(!flipper_file_read_string(file, "Device type", temp_str)) break;
|
||||
if(!flipper_format_read_string(file, "Device type", temp_str)) break;
|
||||
if(!nfc_device_parse_format_string(dev, temp_str)) break;
|
||||
// Read and parse UID, ATQA and SAK
|
||||
if(!flipper_file_get_value_count(file, "UID", &data_cnt)) break;
|
||||
if(!flipper_format_get_value_count(file, "UID", &data_cnt)) break;
|
||||
data->uid_len = data_cnt;
|
||||
if(!flipper_file_read_hex(file, "UID", data->uid, data->uid_len)) break;
|
||||
if(!flipper_file_read_hex(file, "ATQA", data->atqa, 2)) break;
|
||||
if(!flipper_file_read_hex(file, "SAK", &data->sak, 1)) break;
|
||||
if(!flipper_format_read_hex(file, "UID", data->uid, data->uid_len)) break;
|
||||
if(!flipper_format_read_hex(file, "ATQA", data->atqa, 2)) break;
|
||||
if(!flipper_format_read_hex(file, "SAK", &data->sak, 1)) break;
|
||||
// Parse other data
|
||||
if(dev->format == NfcDeviceSaveFormatMifareUl) {
|
||||
if(!nfc_device_load_mifare_ul_data(file, dev)) break;
|
||||
@ -342,8 +342,7 @@ static bool nfc_device_load_data(NfcDevice* dev, string_t path) {
|
||||
}
|
||||
|
||||
string_clear(temp_str);
|
||||
flipper_file_close(file);
|
||||
flipper_file_free(file);
|
||||
flipper_format_free(file);
|
||||
return parsed;
|
||||
}
|
||||
|
||||
|
@ -8,18 +8,17 @@
|
||||
/***************************** NFC Worker API *******************************/
|
||||
|
||||
NfcWorker* nfc_worker_alloc() {
|
||||
NfcWorker* nfc_worker = furi_alloc(sizeof(NfcWorker));
|
||||
NfcWorker* nfc_worker = malloc(sizeof(NfcWorker));
|
||||
// Worker thread attributes
|
||||
nfc_worker->thread_attr.name = "NfcWorker";
|
||||
nfc_worker->thread_attr.stack_size = 8192;
|
||||
nfc_worker->callback = NULL;
|
||||
nfc_worker->context = NULL;
|
||||
// Initialize rfal
|
||||
if(!furi_hal_nfc_is_busy()) {
|
||||
nfc_worker_change_state(nfc_worker, NfcWorkerStateReady);
|
||||
} else {
|
||||
nfc_worker_change_state(nfc_worker, NfcWorkerStateBroken);
|
||||
while(furi_hal_nfc_is_busy()) {
|
||||
osDelay(10);
|
||||
}
|
||||
nfc_worker_change_state(nfc_worker, NfcWorkerStateReady);
|
||||
|
||||
return nfc_worker;
|
||||
}
|
||||
@ -41,7 +40,7 @@ void nfc_worker_start(
|
||||
void* context) {
|
||||
furi_assert(nfc_worker);
|
||||
furi_assert(dev_data);
|
||||
while(nfc_worker->state != NfcWorkerStateReady) {
|
||||
while(furi_hal_nfc_is_busy()) {
|
||||
osDelay(10);
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ struct BankCard {
|
||||
};
|
||||
|
||||
BankCard* bank_card_alloc() {
|
||||
BankCard* bank_card = furi_alloc(sizeof(BankCard));
|
||||
BankCard* bank_card = malloc(sizeof(BankCard));
|
||||
bank_card->widget = widget_alloc();
|
||||
return bank_card;
|
||||
}
|
||||
|
@ -403,7 +403,7 @@ static void input_event_callback(const void* value, void* context) {
|
||||
|
||||
// App alloc
|
||||
static NotificationApp* notification_app_alloc() {
|
||||
NotificationApp* app = furi_alloc(sizeof(NotificationApp));
|
||||
NotificationApp* app = malloc(sizeof(NotificationApp));
|
||||
app->queue = osMessageQueueNew(8, sizeof(NotificationAppMessage), NULL);
|
||||
app->display_timer = osTimerNew(notification_display_timer, osTimerOnce, app, NULL);
|
||||
|
||||
|
@ -32,7 +32,7 @@ static void battery_test_battery_info_update_model(void* context) {
|
||||
}
|
||||
|
||||
BatteryTestApp* battery_test_alloc() {
|
||||
BatteryTestApp* app = furi_alloc(sizeof(BatteryTestApp));
|
||||
BatteryTestApp* app = malloc(sizeof(BatteryTestApp));
|
||||
|
||||
// Records
|
||||
app->gui = furi_record_open("gui");
|
||||
|
@ -32,7 +32,7 @@ static ViewPort* power_battery_view_port_alloc(Power* power) {
|
||||
}
|
||||
|
||||
Power* power_alloc() {
|
||||
Power* power = furi_alloc(sizeof(Power));
|
||||
Power* power = malloc(sizeof(Power));
|
||||
|
||||
// Records
|
||||
power->notification = furi_record_open("notification");
|
||||
|
@ -29,7 +29,7 @@ static void power_off_draw_callback(Canvas* canvas, void* _model) {
|
||||
}
|
||||
|
||||
PowerOff* power_off_alloc() {
|
||||
PowerOff* power_off = furi_alloc(sizeof(PowerOff));
|
||||
PowerOff* power_off = malloc(sizeof(PowerOff));
|
||||
power_off->view = view_alloc();
|
||||
view_allocate_model(power_off->view, ViewModelTypeLocking, sizeof(PowerOffModel));
|
||||
view_set_draw_callback(power_off->view, power_off_draw_callback);
|
||||
|
@ -19,7 +19,7 @@ static void power_settings_tick_event_callback(void* context) {
|
||||
}
|
||||
|
||||
PowerSettingsApp* power_settings_app_alloc() {
|
||||
PowerSettingsApp* app = furi_alloc(sizeof(PowerSettingsApp));
|
||||
PowerSettingsApp* app = malloc(sizeof(PowerSettingsApp));
|
||||
|
||||
// Records
|
||||
app->gui = furi_record_open("gui");
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user