M*LIB: non-inlined strings, FuriString primitive (#1795)
* Quicksave 1 * Header stage complete * Source stage complete * Lint & merge fixes * Includes * Documentation step 1 * FBT: output free size considering BT STACK * Documentation step 2 * py lint * Fix music player plugin * unit test stage 1: string allocator, mem, getters, setters, appends, compare, search. * unit test: string equality * unit test: string replace * unit test: string start_with, end_with * unit test: string trim * unit test: utf-8 * Rename * Revert fw_size changes * Simplify CLI backspace handling * Simplify CLI character insert * Merge fixes * Furi: correct filenaming and spelling * Bt: remove furi string include Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
@@ -11,17 +11,23 @@ void subghz_scene_delete_callback(GuiButtonType result, InputType type, void* co
|
||||
|
||||
void subghz_scene_delete_on_enter(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
string_t frequency_str;
|
||||
string_t modulation_str;
|
||||
string_t text;
|
||||
FuriString* frequency_str;
|
||||
FuriString* modulation_str;
|
||||
FuriString* text;
|
||||
|
||||
string_init(frequency_str);
|
||||
string_init(modulation_str);
|
||||
string_init(text);
|
||||
frequency_str = furi_string_alloc();
|
||||
modulation_str = furi_string_alloc();
|
||||
text = furi_string_alloc();
|
||||
|
||||
subghz_get_frequency_modulation(subghz, frequency_str, modulation_str);
|
||||
widget_add_string_element(
|
||||
subghz->widget, 78, 0, AlignLeft, AlignTop, FontSecondary, string_get_cstr(frequency_str));
|
||||
subghz->widget,
|
||||
78,
|
||||
0,
|
||||
AlignLeft,
|
||||
AlignTop,
|
||||
FontSecondary,
|
||||
furi_string_get_cstr(frequency_str));
|
||||
|
||||
widget_add_string_element(
|
||||
subghz->widget,
|
||||
@@ -30,14 +36,14 @@ void subghz_scene_delete_on_enter(void* context) {
|
||||
AlignLeft,
|
||||
AlignTop,
|
||||
FontSecondary,
|
||||
string_get_cstr(modulation_str));
|
||||
furi_string_get_cstr(modulation_str));
|
||||
subghz_protocol_decoder_base_get_string(subghz->txrx->decoder_result, text);
|
||||
widget_add_string_multiline_element(
|
||||
subghz->widget, 0, 0, AlignLeft, AlignTop, FontSecondary, string_get_cstr(text));
|
||||
subghz->widget, 0, 0, AlignLeft, AlignTop, FontSecondary, furi_string_get_cstr(text));
|
||||
|
||||
string_clear(frequency_str);
|
||||
string_clear(modulation_str);
|
||||
string_clear(text);
|
||||
furi_string_free(frequency_str);
|
||||
furi_string_free(modulation_str);
|
||||
furi_string_free(text);
|
||||
|
||||
widget_add_button_element(
|
||||
subghz->widget, GuiButtonTypeRight, "Delete", subghz_scene_delete_callback, subghz);
|
||||
@@ -49,7 +55,7 @@ bool subghz_scene_delete_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubGhzCustomEventSceneDelete) {
|
||||
string_set(subghz->file_path_tmp, subghz->file_path);
|
||||
furi_string_set(subghz->file_path_tmp, subghz->file_path);
|
||||
if(subghz_delete_file(subghz)) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneDeleteSuccess);
|
||||
} else {
|
||||
|
||||
@@ -15,18 +15,18 @@ void subghz_scene_delete_raw_callback(GuiButtonType result, InputType type, void
|
||||
|
||||
void subghz_scene_delete_raw_on_enter(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
string_t frequency_str;
|
||||
string_t modulation_str;
|
||||
FuriString* frequency_str;
|
||||
FuriString* modulation_str;
|
||||
|
||||
string_init(frequency_str);
|
||||
string_init(modulation_str);
|
||||
frequency_str = furi_string_alloc();
|
||||
modulation_str = furi_string_alloc();
|
||||
|
||||
char delete_str[SUBGHZ_MAX_LEN_NAME + 16];
|
||||
string_t file_name;
|
||||
string_init(file_name);
|
||||
FuriString* file_name;
|
||||
file_name = furi_string_alloc();
|
||||
path_extract_filename(subghz->file_path, file_name, true);
|
||||
snprintf(delete_str, sizeof(delete_str), "\e#Delete %s?\e#", string_get_cstr(file_name));
|
||||
string_clear(file_name);
|
||||
snprintf(delete_str, sizeof(delete_str), "\e#Delete %s?\e#", furi_string_get_cstr(file_name));
|
||||
furi_string_free(file_name);
|
||||
|
||||
widget_add_text_box_element(
|
||||
subghz->widget, 0, 0, 128, 23, AlignCenter, AlignCenter, delete_str, false);
|
||||
@@ -35,7 +35,13 @@ void subghz_scene_delete_raw_on_enter(void* context) {
|
||||
subghz->widget, 38, 25, AlignLeft, AlignTop, FontSecondary, "RAW signal");
|
||||
subghz_get_frequency_modulation(subghz, frequency_str, modulation_str);
|
||||
widget_add_string_element(
|
||||
subghz->widget, 35, 37, AlignLeft, AlignTop, FontSecondary, string_get_cstr(frequency_str));
|
||||
subghz->widget,
|
||||
35,
|
||||
37,
|
||||
AlignLeft,
|
||||
AlignTop,
|
||||
FontSecondary,
|
||||
furi_string_get_cstr(frequency_str));
|
||||
|
||||
widget_add_string_element(
|
||||
subghz->widget,
|
||||
@@ -44,10 +50,10 @@ void subghz_scene_delete_raw_on_enter(void* context) {
|
||||
AlignLeft,
|
||||
AlignTop,
|
||||
FontSecondary,
|
||||
string_get_cstr(modulation_str));
|
||||
furi_string_get_cstr(modulation_str));
|
||||
|
||||
string_clear(frequency_str);
|
||||
string_clear(modulation_str);
|
||||
furi_string_free(frequency_str);
|
||||
furi_string_free(modulation_str);
|
||||
|
||||
widget_add_button_element(
|
||||
subghz->widget, GuiButtonTypeRight, "Delete", subghz_scene_delete_raw_callback, subghz);
|
||||
@@ -61,7 +67,7 @@ bool subghz_scene_delete_raw_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubGhzCustomEventSceneDeleteRAW) {
|
||||
string_set(subghz->file_path_tmp, subghz->file_path);
|
||||
furi_string_set(subghz->file_path_tmp, subghz->file_path);
|
||||
if(subghz_delete_file(subghz)) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneDeleteSuccess);
|
||||
} else {
|
||||
|
||||
@@ -45,7 +45,7 @@ bool subghz_scene_more_raw_on_event(void* context, SceneManagerEvent event) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneDeleteRAW);
|
||||
return true;
|
||||
} else if(event.event == SubmenuIndexEdit) {
|
||||
string_reset(subghz->file_path_tmp);
|
||||
furi_string_reset(subghz->file_path_tmp);
|
||||
scene_manager_set_scene_state(
|
||||
subghz->scene_manager, SubGhzSceneMoreRAW, SubmenuIndexEdit);
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaveName);
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
bool subghz_scene_read_raw_update_filename(SubGhz* subghz) {
|
||||
bool ret = false;
|
||||
//set the path to read the file
|
||||
string_t temp_str;
|
||||
string_init(temp_str);
|
||||
FuriString* temp_str;
|
||||
temp_str = furi_string_alloc();
|
||||
do {
|
||||
if(!flipper_format_rewind(subghz->txrx->fff_data)) {
|
||||
FURI_LOG_E(TAG, "Rewind error");
|
||||
@@ -23,12 +23,12 @@ bool subghz_scene_read_raw_update_filename(SubGhz* subghz) {
|
||||
break;
|
||||
}
|
||||
|
||||
string_set(subghz->file_path, temp_str);
|
||||
furi_string_set(subghz->file_path, temp_str);
|
||||
|
||||
ret = true;
|
||||
} while(false);
|
||||
|
||||
string_clear(temp_str);
|
||||
furi_string_free(temp_str);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -36,18 +36,20 @@ static void subghz_scene_read_raw_update_statusbar(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhz* subghz = context;
|
||||
|
||||
string_t frequency_str;
|
||||
string_t modulation_str;
|
||||
FuriString* frequency_str;
|
||||
FuriString* modulation_str;
|
||||
|
||||
string_init(frequency_str);
|
||||
string_init(modulation_str);
|
||||
frequency_str = furi_string_alloc();
|
||||
modulation_str = furi_string_alloc();
|
||||
|
||||
subghz_get_frequency_modulation(subghz, frequency_str, modulation_str);
|
||||
subghz_read_raw_add_data_statusbar(
|
||||
subghz->subghz_read_raw, string_get_cstr(frequency_str), string_get_cstr(modulation_str));
|
||||
subghz->subghz_read_raw,
|
||||
furi_string_get_cstr(frequency_str),
|
||||
furi_string_get_cstr(modulation_str));
|
||||
|
||||
string_clear(frequency_str);
|
||||
string_clear(modulation_str);
|
||||
furi_string_free(frequency_str);
|
||||
furi_string_free(modulation_str);
|
||||
}
|
||||
|
||||
void subghz_scene_read_raw_callback(SubGhzCustomEvent event, void* context) {
|
||||
@@ -65,8 +67,8 @@ void subghz_scene_read_raw_callback_end_tx(void* context) {
|
||||
|
||||
void subghz_scene_read_raw_on_enter(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
string_t file_name;
|
||||
string_init(file_name);
|
||||
FuriString* file_name;
|
||||
file_name = furi_string_alloc();
|
||||
|
||||
switch(subghz->txrx->rx_key_state) {
|
||||
case SubGhzRxKeyStateBack:
|
||||
@@ -75,13 +77,15 @@ void subghz_scene_read_raw_on_enter(void* context) {
|
||||
case SubGhzRxKeyStateRAWLoad:
|
||||
path_extract_filename(subghz->file_path, file_name, true);
|
||||
subghz_read_raw_set_status(
|
||||
subghz->subghz_read_raw, SubGhzReadRAWStatusLoadKeyTX, string_get_cstr(file_name));
|
||||
subghz->subghz_read_raw,
|
||||
SubGhzReadRAWStatusLoadKeyTX,
|
||||
furi_string_get_cstr(file_name));
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
|
||||
break;
|
||||
case SubGhzRxKeyStateRAWSave:
|
||||
path_extract_filename(subghz->file_path, file_name, true);
|
||||
subghz_read_raw_set_status(
|
||||
subghz->subghz_read_raw, SubGhzReadRAWStatusSaveKey, string_get_cstr(file_name));
|
||||
subghz->subghz_read_raw, SubGhzReadRAWStatusSaveKey, furi_string_get_cstr(file_name));
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
|
||||
break;
|
||||
default:
|
||||
@@ -89,7 +93,7 @@ void subghz_scene_read_raw_on_enter(void* context) {
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
|
||||
break;
|
||||
}
|
||||
string_clear(file_name);
|
||||
furi_string_free(file_name);
|
||||
subghz_scene_read_raw_update_statusbar(subghz);
|
||||
|
||||
//set callback view raw
|
||||
@@ -174,7 +178,7 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
|
||||
case SubGhzCustomEventViewReadRAWErase:
|
||||
if(subghz->txrx->rx_key_state == SubGhzRxKeyStateAddKey) {
|
||||
if(subghz_scene_read_raw_update_filename(subghz)) {
|
||||
string_set(subghz->file_path_tmp, subghz->file_path);
|
||||
furi_string_set(subghz->file_path_tmp, subghz->file_path);
|
||||
subghz_delete_file(subghz);
|
||||
}
|
||||
}
|
||||
@@ -245,12 +249,13 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
|
||||
subghz_protocol_raw_save_to_file_stop(
|
||||
(SubGhzProtocolDecoderRAW*)subghz->txrx->decoder_result);
|
||||
|
||||
string_t temp_str;
|
||||
string_init(temp_str);
|
||||
string_printf(
|
||||
FuriString* temp_str;
|
||||
temp_str = furi_string_alloc();
|
||||
furi_string_printf(
|
||||
temp_str, "%s/%s%s", SUBGHZ_RAW_FOLDER, RAW_FILE_NAME, SUBGHZ_APP_EXTENSION);
|
||||
subghz_protocol_raw_gen_fff_data(subghz->txrx->fff_data, string_get_cstr(temp_str));
|
||||
string_clear(temp_str);
|
||||
subghz_protocol_raw_gen_fff_data(
|
||||
subghz->txrx->fff_data, furi_string_get_cstr(temp_str));
|
||||
furi_string_free(temp_str);
|
||||
|
||||
if(spl_count > 0) {
|
||||
notification_message(subghz->notifications, &sequence_set_green_255);
|
||||
@@ -279,13 +284,14 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
|
||||
subghz_begin(
|
||||
subghz,
|
||||
subghz_setting_get_preset_data_by_name(
|
||||
subghz->setting, string_get_cstr(subghz->txrx->preset->name)));
|
||||
subghz->setting,
|
||||
furi_string_get_cstr(subghz->txrx->preset->name)));
|
||||
subghz_rx(subghz, subghz->txrx->preset->frequency);
|
||||
}
|
||||
subghz->state_notifications = SubGhzNotificationStateRx;
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateAddKey;
|
||||
} else {
|
||||
string_set_str(subghz->error_str, "Function requires\nan SD card.");
|
||||
furi_string_set(subghz->error_str, "Function requires\nan SD card.");
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,31 +33,31 @@ static const NotificationSequence subghs_sequence_rx_locked = {
|
||||
|
||||
static void subghz_scene_receiver_update_statusbar(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
string_t history_stat_str;
|
||||
string_init(history_stat_str);
|
||||
FuriString* history_stat_str;
|
||||
history_stat_str = furi_string_alloc();
|
||||
if(!subghz_history_get_text_space_left(subghz->txrx->history, history_stat_str)) {
|
||||
string_t frequency_str;
|
||||
string_t modulation_str;
|
||||
FuriString* frequency_str;
|
||||
FuriString* modulation_str;
|
||||
|
||||
string_init(frequency_str);
|
||||
string_init(modulation_str);
|
||||
frequency_str = furi_string_alloc();
|
||||
modulation_str = furi_string_alloc();
|
||||
|
||||
subghz_get_frequency_modulation(subghz, frequency_str, modulation_str);
|
||||
|
||||
subghz_view_receiver_add_data_statusbar(
|
||||
subghz->subghz_receiver,
|
||||
string_get_cstr(frequency_str),
|
||||
string_get_cstr(modulation_str),
|
||||
string_get_cstr(history_stat_str));
|
||||
furi_string_get_cstr(frequency_str),
|
||||
furi_string_get_cstr(modulation_str),
|
||||
furi_string_get_cstr(history_stat_str));
|
||||
|
||||
string_clear(frequency_str);
|
||||
string_clear(modulation_str);
|
||||
furi_string_free(frequency_str);
|
||||
furi_string_free(modulation_str);
|
||||
} else {
|
||||
subghz_view_receiver_add_data_statusbar(
|
||||
subghz->subghz_receiver, string_get_cstr(history_stat_str), "", "");
|
||||
subghz->subghz_receiver, furi_string_get_cstr(history_stat_str), "", "");
|
||||
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
||||
}
|
||||
string_clear(history_stat_str);
|
||||
furi_string_free(history_stat_str);
|
||||
}
|
||||
|
||||
void subghz_scene_receiver_callback(SubGhzCustomEvent event, void* context) {
|
||||
@@ -72,11 +72,11 @@ static void subghz_scene_add_to_history_callback(
|
||||
void* context) {
|
||||
furi_assert(context);
|
||||
SubGhz* subghz = context;
|
||||
string_t str_buff;
|
||||
string_init(str_buff);
|
||||
FuriString* str_buff;
|
||||
str_buff = furi_string_alloc();
|
||||
|
||||
if(subghz_history_add_to_history(subghz->txrx->history, decoder_base, subghz->txrx->preset)) {
|
||||
string_reset(str_buff);
|
||||
furi_string_reset(str_buff);
|
||||
|
||||
subghz->state_notifications = SubGhzNotificationStateRxDone;
|
||||
|
||||
@@ -84,22 +84,22 @@ static void subghz_scene_add_to_history_callback(
|
||||
subghz->txrx->history, str_buff, subghz_history_get_item(subghz->txrx->history) - 1);
|
||||
subghz_view_receiver_add_item_to_menu(
|
||||
subghz->subghz_receiver,
|
||||
string_get_cstr(str_buff),
|
||||
furi_string_get_cstr(str_buff),
|
||||
subghz_history_get_type_protocol(
|
||||
subghz->txrx->history, subghz_history_get_item(subghz->txrx->history) - 1));
|
||||
|
||||
subghz_scene_receiver_update_statusbar(subghz);
|
||||
}
|
||||
subghz_receiver_reset(receiver);
|
||||
string_clear(str_buff);
|
||||
furi_string_free(str_buff);
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateAddKey;
|
||||
}
|
||||
|
||||
void subghz_scene_receiver_on_enter(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
string_t str_buff;
|
||||
string_init(str_buff);
|
||||
FuriString* str_buff;
|
||||
str_buff = furi_string_alloc();
|
||||
|
||||
if(subghz->txrx->rx_key_state == SubGhzRxKeyStateIDLE) {
|
||||
subghz_preset_init(
|
||||
@@ -113,15 +113,15 @@ void subghz_scene_receiver_on_enter(void* context) {
|
||||
//Load history to receiver
|
||||
subghz_view_receiver_exit(subghz->subghz_receiver);
|
||||
for(uint8_t i = 0; i < subghz_history_get_item(subghz->txrx->history); i++) {
|
||||
string_reset(str_buff);
|
||||
furi_string_reset(str_buff);
|
||||
subghz_history_get_text_item_menu(subghz->txrx->history, str_buff, i);
|
||||
subghz_view_receiver_add_item_to_menu(
|
||||
subghz->subghz_receiver,
|
||||
string_get_cstr(str_buff),
|
||||
furi_string_get_cstr(str_buff),
|
||||
subghz_history_get_type_protocol(subghz->txrx->history, i));
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateAddKey;
|
||||
}
|
||||
string_clear(str_buff);
|
||||
furi_string_free(str_buff);
|
||||
subghz_scene_receiver_update_statusbar(subghz);
|
||||
subghz_view_receiver_set_callback(
|
||||
subghz->subghz_receiver, subghz_scene_receiver_callback, subghz);
|
||||
@@ -137,7 +137,7 @@ void subghz_scene_receiver_on_enter(void* context) {
|
||||
subghz_begin(
|
||||
subghz,
|
||||
subghz_setting_get_preset_data_by_name(
|
||||
subghz->setting, string_get_cstr(subghz->txrx->preset->name)));
|
||||
subghz->setting, furi_string_get_cstr(subghz->txrx->preset->name)));
|
||||
subghz_rx(subghz, subghz->txrx->preset->frequency);
|
||||
}
|
||||
subghz_view_receiver_set_idx_menu(subghz->subghz_receiver, subghz->txrx->idx_menu_chosen);
|
||||
|
||||
@@ -191,7 +191,7 @@ void subghz_scene_receiver_config_on_enter(void* context) {
|
||||
subghz_scene_receiver_config_set_preset,
|
||||
subghz);
|
||||
value_index = subghz_scene_receiver_config_next_preset(
|
||||
string_get_cstr(subghz->txrx->preset->name), subghz);
|
||||
furi_string_get_cstr(subghz->txrx->preset->name), subghz);
|
||||
variable_item_set_current_value_index(item, value_index);
|
||||
variable_item_set_current_value_text(
|
||||
item, subghz_setting_get_preset_name(subghz->setting, value_index));
|
||||
|
||||
@@ -32,7 +32,7 @@ static bool subghz_scene_receiver_info_update_parser(void* context) {
|
||||
subghz_history_get_preset_def(subghz->txrx->history, subghz->txrx->idx_menu_chosen);
|
||||
subghz_preset_init(
|
||||
subghz,
|
||||
string_get_cstr(preset->name),
|
||||
furi_string_get_cstr(preset->name),
|
||||
preset->frequency,
|
||||
preset->data,
|
||||
preset->data_size);
|
||||
@@ -47,13 +47,13 @@ void subghz_scene_receiver_info_on_enter(void* context) {
|
||||
|
||||
DOLPHIN_DEED(DolphinDeedSubGhzReceiverInfo);
|
||||
if(subghz_scene_receiver_info_update_parser(subghz)) {
|
||||
string_t frequency_str;
|
||||
string_t modulation_str;
|
||||
string_t text;
|
||||
FuriString* frequency_str;
|
||||
FuriString* modulation_str;
|
||||
FuriString* text;
|
||||
|
||||
string_init(frequency_str);
|
||||
string_init(modulation_str);
|
||||
string_init(text);
|
||||
frequency_str = furi_string_alloc();
|
||||
modulation_str = furi_string_alloc();
|
||||
text = furi_string_alloc();
|
||||
|
||||
subghz_get_frequency_modulation(subghz, frequency_str, modulation_str);
|
||||
widget_add_string_element(
|
||||
@@ -63,7 +63,7 @@ void subghz_scene_receiver_info_on_enter(void* context) {
|
||||
AlignLeft,
|
||||
AlignTop,
|
||||
FontSecondary,
|
||||
string_get_cstr(frequency_str));
|
||||
furi_string_get_cstr(frequency_str));
|
||||
|
||||
widget_add_string_element(
|
||||
subghz->widget,
|
||||
@@ -72,14 +72,14 @@ void subghz_scene_receiver_info_on_enter(void* context) {
|
||||
AlignLeft,
|
||||
AlignTop,
|
||||
FontSecondary,
|
||||
string_get_cstr(modulation_str));
|
||||
furi_string_get_cstr(modulation_str));
|
||||
subghz_protocol_decoder_base_get_string(subghz->txrx->decoder_result, text);
|
||||
widget_add_string_multiline_element(
|
||||
subghz->widget, 0, 0, AlignLeft, AlignTop, FontSecondary, string_get_cstr(text));
|
||||
subghz->widget, 0, 0, AlignLeft, AlignTop, FontSecondary, furi_string_get_cstr(text));
|
||||
|
||||
string_clear(frequency_str);
|
||||
string_clear(modulation_str);
|
||||
string_clear(text);
|
||||
furi_string_free(frequency_str);
|
||||
furi_string_free(modulation_str);
|
||||
furi_string_free(text);
|
||||
|
||||
if((subghz->txrx->decoder_result->protocol->flag & SubGhzProtocolFlag_Save) ==
|
||||
SubGhzProtocolFlag_Save) {
|
||||
@@ -146,7 +146,7 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event)
|
||||
subghz_begin(
|
||||
subghz,
|
||||
subghz_setting_get_preset_data_by_name(
|
||||
subghz->setting, string_get_cstr(subghz->txrx->preset->name)));
|
||||
subghz->setting, furi_string_get_cstr(subghz->txrx->preset->name)));
|
||||
subghz_rx(subghz, subghz->txrx->preset->frequency);
|
||||
}
|
||||
if(subghz->txrx->hopper_state == SubGhzHopperStatePause) {
|
||||
|
||||
@@ -61,20 +61,20 @@ bool subghz_scene_rpc_on_event(void* context, SceneManagerEvent event) {
|
||||
if(subghz_key_load(subghz, arg, false)) {
|
||||
scene_manager_set_scene_state(
|
||||
subghz->scene_manager, SubGhzSceneRpc, SubGhzRpcStateLoaded);
|
||||
string_set_str(subghz->file_path, arg);
|
||||
furi_string_set(subghz->file_path, arg);
|
||||
result = true;
|
||||
string_t file_name;
|
||||
string_init(file_name);
|
||||
FuriString* file_name;
|
||||
file_name = furi_string_alloc();
|
||||
path_extract_filename(subghz->file_path, file_name, true);
|
||||
|
||||
snprintf(
|
||||
subghz->file_name_tmp,
|
||||
SUBGHZ_MAX_LEN_NAME,
|
||||
"loaded\n%s",
|
||||
string_get_cstr(file_name));
|
||||
furi_string_get_cstr(file_name));
|
||||
popup_set_text(popup, subghz->file_name_tmp, 89, 44, AlignCenter, AlignTop);
|
||||
|
||||
string_clear(file_name);
|
||||
furi_string_free(file_name);
|
||||
}
|
||||
}
|
||||
rpc_system_app_confirm(subghz->rpc_ctx, RpcAppEventLoadFile, result);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "../subghz_i.h"
|
||||
#include "m-string.h"
|
||||
#include "subghz/types.h"
|
||||
#include <lib/toolbox/random_name.h>
|
||||
#include "../helpers/subghz_custom_event.h"
|
||||
@@ -21,21 +20,21 @@ void subghz_scene_save_name_on_enter(void* context) {
|
||||
TextInput* text_input = subghz->text_input;
|
||||
bool dev_name_empty = false;
|
||||
|
||||
string_t file_name;
|
||||
string_t dir_name;
|
||||
string_init(file_name);
|
||||
string_init(dir_name);
|
||||
FuriString* file_name;
|
||||
FuriString* dir_name;
|
||||
file_name = furi_string_alloc();
|
||||
dir_name = furi_string_alloc();
|
||||
|
||||
if(!subghz_path_is_file(subghz->file_path)) {
|
||||
char file_name_buf[SUBGHZ_MAX_LEN_NAME] = {0};
|
||||
set_random_name(file_name_buf, SUBGHZ_MAX_LEN_NAME);
|
||||
string_set_str(file_name, file_name_buf);
|
||||
string_set_str(subghz->file_path, SUBGHZ_APP_FOLDER);
|
||||
furi_string_set(file_name, file_name_buf);
|
||||
furi_string_set(subghz->file_path, SUBGHZ_APP_FOLDER);
|
||||
//highlighting the entire filename by default
|
||||
dev_name_empty = true;
|
||||
} else {
|
||||
string_set(subghz->file_path_tmp, subghz->file_path);
|
||||
path_extract_dirname(string_get_cstr(subghz->file_path), dir_name);
|
||||
furi_string_set(subghz->file_path_tmp, subghz->file_path);
|
||||
path_extract_dirname(furi_string_get_cstr(subghz->file_path), dir_name);
|
||||
path_extract_filename(subghz->file_path, file_name, true);
|
||||
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) !=
|
||||
SubGhzCustomEventManagerNoSet) {
|
||||
@@ -46,10 +45,10 @@ void subghz_scene_save_name_on_enter(void* context) {
|
||||
}
|
||||
path_extract_filename(subghz->file_path, file_name, true);
|
||||
}
|
||||
string_set(subghz->file_path, dir_name);
|
||||
furi_string_set(subghz->file_path, dir_name);
|
||||
}
|
||||
|
||||
strncpy(subghz->file_name_tmp, string_get_cstr(file_name), SUBGHZ_MAX_LEN_NAME);
|
||||
strncpy(subghz->file_name_tmp, furi_string_get_cstr(file_name), SUBGHZ_MAX_LEN_NAME);
|
||||
text_input_set_header_text(text_input, "Name signal");
|
||||
text_input_set_result_callback(
|
||||
text_input,
|
||||
@@ -59,12 +58,12 @@ void subghz_scene_save_name_on_enter(void* context) {
|
||||
MAX_TEXT_INPUT_LEN, // buffer size
|
||||
dev_name_empty);
|
||||
|
||||
ValidatorIsFile* validator_is_file =
|
||||
validator_is_file_alloc_init(string_get_cstr(subghz->file_path), SUBGHZ_APP_EXTENSION, "");
|
||||
ValidatorIsFile* validator_is_file = validator_is_file_alloc_init(
|
||||
furi_string_get_cstr(subghz->file_path), SUBGHZ_APP_EXTENSION, "");
|
||||
text_input_set_validator(text_input, validator_is_file_callback, validator_is_file);
|
||||
|
||||
string_clear(file_name);
|
||||
string_clear(dir_name);
|
||||
furi_string_free(file_name);
|
||||
furi_string_free(dir_name);
|
||||
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdTextInput);
|
||||
}
|
||||
@@ -75,14 +74,14 @@ bool subghz_scene_save_name_on_event(void* context, SceneManagerEvent event) {
|
||||
if(!strcmp(subghz->file_name_tmp, "") ||
|
||||
scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) !=
|
||||
SubGhzCustomEventManagerNoSet) {
|
||||
string_set(subghz->file_path, subghz->file_path_tmp);
|
||||
furi_string_set(subghz->file_path, subghz->file_path_tmp);
|
||||
}
|
||||
scene_manager_previous_scene(subghz->scene_manager);
|
||||
return true;
|
||||
} else if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubGhzCustomEventSceneSaveName) {
|
||||
if(strcmp(subghz->file_name_tmp, "")) {
|
||||
string_cat_printf(
|
||||
furi_string_cat_printf(
|
||||
subghz->file_path, "/%s%s", subghz->file_name_tmp, SUBGHZ_APP_EXTENSION);
|
||||
if(subghz_path_is_file(subghz->file_path_tmp)) {
|
||||
if(!subghz_rename_file(subghz)) {
|
||||
@@ -92,7 +91,9 @@ bool subghz_scene_save_name_on_event(void* context, SceneManagerEvent event) {
|
||||
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneSetType) !=
|
||||
SubGhzCustomEventManagerNoSet) {
|
||||
subghz_save_protocol_to_file(
|
||||
subghz, subghz->txrx->fff_data, string_get_cstr(subghz->file_path));
|
||||
subghz,
|
||||
subghz->txrx->fff_data,
|
||||
furi_string_get_cstr(subghz->file_path));
|
||||
scene_manager_set_scene_state(
|
||||
subghz->scene_manager,
|
||||
SubGhzSceneSetType,
|
||||
@@ -102,14 +103,14 @@ bool subghz_scene_save_name_on_event(void* context, SceneManagerEvent event) {
|
||||
subghz,
|
||||
subghz_history_get_raw_data(
|
||||
subghz->txrx->history, subghz->txrx->idx_menu_chosen),
|
||||
string_get_cstr(subghz->file_path));
|
||||
furi_string_get_cstr(subghz->file_path));
|
||||
}
|
||||
}
|
||||
|
||||
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) !=
|
||||
SubGhzCustomEventManagerNoSet) {
|
||||
subghz_protocol_raw_gen_fff_data(
|
||||
subghz->txrx->fff_data, string_get_cstr(subghz->file_path));
|
||||
subghz->txrx->fff_data, furi_string_get_cstr(subghz->file_path));
|
||||
scene_manager_set_scene_state(
|
||||
subghz->scene_manager, SubGhzSceneReadRAW, SubGhzCustomEventManagerNoSet);
|
||||
} else {
|
||||
@@ -119,7 +120,7 @@ bool subghz_scene_save_name_on_event(void* context, SceneManagerEvent event) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaveSuccess);
|
||||
return true;
|
||||
} else {
|
||||
string_set_str(subghz->error_str, "No name file");
|
||||
furi_string_set(subghz->error_str, "No name file");
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowErrorSub);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ bool subghz_scene_set_type_submenu_gen_data_protocol(
|
||||
subghz_receiver_search_decoder_base_by_name(subghz->txrx->receiver, protocol_name);
|
||||
|
||||
if(subghz->txrx->decoder_result == NULL) {
|
||||
string_set_str(subghz->error_str, "Protocol not\nfound!");
|
||||
furi_string_set(subghz->error_str, "Protocol not\nfound!");
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowErrorSub);
|
||||
return false;
|
||||
}
|
||||
@@ -261,7 +261,7 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
|
||||
}
|
||||
subghz_transmitter_free(subghz->txrx->transmitter);
|
||||
if(!generated_protocol) {
|
||||
string_set_str(
|
||||
furi_string_set(
|
||||
subghz->error_str, "Function requires\nan SD card with\nfresh databases.");
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError);
|
||||
}
|
||||
@@ -285,7 +285,7 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
|
||||
}
|
||||
subghz_transmitter_free(subghz->txrx->transmitter);
|
||||
if(!generated_protocol) {
|
||||
string_set_str(
|
||||
furi_string_set(
|
||||
subghz->error_str, "Function requires\nan SD card with\nfresh databases.");
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ void subghz_scene_show_error_on_enter(void* context) {
|
||||
AlignCenter,
|
||||
AlignCenter,
|
||||
FontSecondary,
|
||||
string_get_cstr(subghz->error_str));
|
||||
furi_string_get_cstr(subghz->error_str));
|
||||
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneShowError) ==
|
||||
SubGhzCustomEventManagerSet) {
|
||||
widget_add_button_element(
|
||||
@@ -89,6 +89,6 @@ void subghz_scene_show_error_on_exit(void* context) {
|
||||
scene_manager_set_scene_state(
|
||||
subghz->scene_manager, SubGhzSceneShowError, SubGhzCustomEventManagerNoSet);
|
||||
widget_reset(subghz->widget);
|
||||
string_reset(subghz->error_str);
|
||||
furi_string_reset(subghz->error_str);
|
||||
notification_message(subghz->notifications, &sequence_reset_rgb);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ void subghz_scene_show_error_sub_on_enter(void* context) {
|
||||
// Setup view
|
||||
Popup* popup = subghz->popup;
|
||||
popup_set_icon(popup, 72, 17, &I_DolphinCommon_56x48);
|
||||
popup_set_header(popup, string_get_cstr(subghz->error_str), 14, 15, AlignLeft, AlignTop);
|
||||
popup_set_header(popup, furi_string_get_cstr(subghz->error_str), 14, 15, AlignLeft, AlignTop);
|
||||
popup_set_timeout(popup, 1500);
|
||||
popup_set_context(popup, subghz);
|
||||
popup_set_callback(popup, subghz_scene_show_error_sub_popup_callback);
|
||||
@@ -46,7 +46,7 @@ void subghz_scene_show_error_sub_on_exit(void* context) {
|
||||
popup_set_context(popup, NULL);
|
||||
popup_set_timeout(popup, 0);
|
||||
popup_disable_timeout(popup);
|
||||
string_reset(subghz->error_str);
|
||||
furi_string_reset(subghz->error_str);
|
||||
|
||||
notification_message(subghz->notifications, &sequence_reset_rgb);
|
||||
}
|
||||
|
||||
@@ -13,13 +13,13 @@ bool subghz_scene_transmitter_update_data_show(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
if(subghz->txrx->decoder_result) {
|
||||
string_t key_str;
|
||||
string_t frequency_str;
|
||||
string_t modulation_str;
|
||||
FuriString* key_str;
|
||||
FuriString* frequency_str;
|
||||
FuriString* modulation_str;
|
||||
|
||||
string_init(key_str);
|
||||
string_init(frequency_str);
|
||||
string_init(modulation_str);
|
||||
key_str = furi_string_alloc();
|
||||
frequency_str = furi_string_alloc();
|
||||
modulation_str = furi_string_alloc();
|
||||
uint8_t show_button = 0;
|
||||
|
||||
subghz_protocol_decoder_base_deserialize(
|
||||
@@ -34,14 +34,14 @@ bool subghz_scene_transmitter_update_data_show(void* context) {
|
||||
subghz_get_frequency_modulation(subghz, frequency_str, modulation_str);
|
||||
subghz_view_transmitter_add_data_to_show(
|
||||
subghz->subghz_transmitter,
|
||||
string_get_cstr(key_str),
|
||||
string_get_cstr(frequency_str),
|
||||
string_get_cstr(modulation_str),
|
||||
furi_string_get_cstr(key_str),
|
||||
furi_string_get_cstr(frequency_str),
|
||||
furi_string_get_cstr(modulation_str),
|
||||
show_button);
|
||||
|
||||
string_clear(frequency_str);
|
||||
string_clear(modulation_str);
|
||||
string_clear(key_str);
|
||||
furi_string_free(frequency_str);
|
||||
furi_string_free(modulation_str);
|
||||
furi_string_free(key_str);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -94,7 +94,7 @@ bool subghz_scene_transmitter_on_event(void* context, SceneManagerEvent event) {
|
||||
subghz->scene_manager, SubGhzSceneStart);
|
||||
return true;
|
||||
} else if(event.event == SubGhzCustomEventViewTransmitterError) {
|
||||
string_set_str(subghz->error_str, "Protocol not\nfound!");
|
||||
furi_string_set(subghz->error_str, "Protocol not\nfound!");
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowErrorSub);
|
||||
}
|
||||
} else if(event.type == SceneManagerEventTypeTick) {
|
||||
|
||||
Reference in New Issue
Block a user