SubGhz: fix naming part 2 and 3

This commit is contained in:
gid9798
2023-05-09 21:54:56 +03:00
parent 5b447d0a56
commit 85d44c5f6c
14 changed files with 55 additions and 54 deletions

View File

@@ -24,7 +24,7 @@ SubGhzTxRx* subghz_txrx_alloc() {
instance->fff_data = flipper_format_string_alloc();
instance->environment = subghz_environment_alloc();
instance->load_database = subghz_environment_load_keystore(
instance->is_database_loaded = subghz_environment_load_keystore(
instance->environment, EXT_PATH("subghz/assets/keeloq_mfcodes"));
subghz_environment_load_keystore(
instance->environment, EXT_PATH("subghz/assets/keeloq_mfcodes_user"));
@@ -60,9 +60,9 @@ void subghz_txrx_free(SubGhzTxRx* instance) {
free(instance);
}
bool subghz_txrx_is_load_database(SubGhzTxRx* instance) {
bool subghz_txrx_is_database_loaded(SubGhzTxRx* instance) {
furi_assert(instance);
return instance->load_database;
return instance->is_database_loaded;
}
void subghz_txrx_set_preset(
@@ -79,7 +79,7 @@ void subghz_txrx_set_preset(
preset->data_size = preset_data_size;
}
const char* subghz_txrx_get_name_preset(SubGhzTxRx* instance, const char* preset) {
const char* subghz_txrx_get_preset_name(SubGhzTxRx* instance, const char* preset) {
UNUSED(instance);
const char* preset_name = NULL;
if(!strcmp(preset, "FuriHalSubGhzPresetOok270Async")) {
@@ -103,7 +103,7 @@ SubGhzRadioPreset subghz_txrx_get_preset(SubGhzTxRx* instance) {
return *instance->preset;
}
void subghz_txrx_get_frequency_modulation(
void subghz_txrx_get_frequency_and_modulation(
SubGhzTxRx* instance,
FuriString* frequency,
FuriString* modulation,
@@ -282,7 +282,7 @@ void subghz_txrx_rx_start(SubGhzTxRx* instance) {
subghz_txrx_rx(instance, instance->preset->frequency);
}
void subghz_txrx_need_save_callback_set(
void subghz_txrx_set_need_save_callback(
SubGhzTxRx* instance,
SubGhzTxRxNeedSaveCallback callback,
void* context) {
@@ -311,7 +311,7 @@ static void subghz_txrx_tx_stop(SubGhzTxRx* instance) {
// notification_message(notifications, &sequence_reset_red);
}
FlipperFormat* subghz_txtx_get_fff_data(SubGhzTxRx* instance) {
FlipperFormat* subghz_txrx_get_fff_data(SubGhzTxRx* instance) {
furi_assert(instance);
return instance->fff_data;
}
@@ -398,7 +398,7 @@ void subghz_txrx_hopper_set_state(SubGhzTxRx* instance, SubGhzHopperState state)
instance->hopper_state = state;
}
void subghz_txrx_hopper_remove_pause(SubGhzTxRx* instance) {
void subghz_txrx_hopper_unpause(SubGhzTxRx* instance) {
furi_assert(instance);
if(instance->hopper_state == SubGhzHopperStatePause) {
instance->hopper_state = SubGhzHopperStateRunning;
@@ -501,14 +501,14 @@ SubGhzProtocolDecoderBase* subghz_txrx_get_decoder(SubGhzTxRx* instance) {
return instance->decoder_result;
}
bool subghz_txrx_protocol_is_preserved(SubGhzTxRx* instance) {
bool subghz_txrx_protocol_is_serializable(SubGhzTxRx* instance) {
furi_assert(instance);
return (
(instance->decoder_result->protocol->flag & SubGhzProtocolFlag_Save) ==
SubGhzProtocolFlag_Save);
}
bool subghz_txrx_protocol_is_send(SubGhzTxRx* instance, bool check_type) {
bool subghz_txrx_protocol_is_transmittable(SubGhzTxRx* instance, bool check_type) {
furi_assert(instance);
const SubGhzProtocol* protocol = instance->decoder_result->protocol;
if(check_type) {
@@ -533,7 +533,7 @@ void subghz_txrx_set_rx_calback(
subghz_receiver_set_rx_callback(instance->receiver, callback, context);
}
void subghz_txrx_set_raw_file_encoder_worker_set_callback_end(
void subghz_txrx_set_raw_file_encoder_worker_callback_end(
SubGhzTxRx* instance,
SubGhzProtocolEncoderRAWCallbackEnd callback,
void* context) {

View File

@@ -37,7 +37,7 @@ void subghz_txrx_free(SubGhzTxRx* instance);
* @param instance Pointer to a SubGhzTxRx
* @return bool True if the database is loaded
*/
bool subghz_txrx_is_load_database(SubGhzTxRx* instance);
bool subghz_txrx_is_database_loaded(SubGhzTxRx* instance);
/**
* Set preset
@@ -62,7 +62,7 @@ void subghz_txrx_set_preset(
* @param preset String of preset
* @return const char* Name of preset
*/
const char* subghz_txrx_get_name_preset(SubGhzTxRx* instance, const char* preset);
const char* subghz_txrx_get_preset_name(SubGhzTxRx* instance, const char* preset);
/**
* Get of preset
@@ -79,7 +79,7 @@ SubGhzRadioPreset subghz_txrx_get_preset(SubGhzTxRx* instance);
* @param frequency Pointer to a string frequency
* @param modulation Pointer to a string modulation
*/
void subghz_txrx_get_frequency_modulation(
void subghz_txrx_get_frequency_and_modulation(
SubGhzTxRx* instance,
FuriString* frequency,
FuriString* modulation,
@@ -143,7 +143,7 @@ void subghz_txrx_hopper_set_state(SubGhzTxRx* instance, SubGhzHopperState state)
*
* @param instance Pointer to a SubGhzTxRx
*/
void subghz_txrx_hopper_remove_pause(SubGhzTxRx* instance);
void subghz_txrx_hopper_unpause(SubGhzTxRx* instance);
/**
* Set pause hopper
@@ -220,7 +220,7 @@ SubGhzProtocolDecoderBase* subghz_txrx_get_decoder(SubGhzTxRx* instance);
* @param callback Callback for save data
* @param context Context for callback
*/
void subghz_txrx_need_save_callback_set(
void subghz_txrx_set_need_save_callback(
SubGhzTxRx* instance,
SubGhzTxRxNeedSaveCallback callback,
void* context);
@@ -231,7 +231,7 @@ void subghz_txrx_need_save_callback_set(
* @param instance Pointer to a SubGhzTxRx
* @return FlipperFormat*
*/
FlipperFormat* subghz_txtx_get_fff_data(SubGhzTxRx* instance);
FlipperFormat* subghz_txrx_get_fff_data(SubGhzTxRx* instance);
/**
* Get pointer to a SugGhzSetting
@@ -247,7 +247,7 @@ SubGhzSetting* subghz_txrx_get_setting(SubGhzTxRx* instance);
* @param instance Pointer to a SubGhzTxRx
* @return bool True if it is possible to save this protocol
*/
bool subghz_txrx_protocol_is_preserved(SubGhzTxRx* instance);
bool subghz_txrx_protocol_is_serializable(SubGhzTxRx* instance);
/**
* Is it possible to send this protocol
@@ -255,7 +255,7 @@ bool subghz_txrx_protocol_is_preserved(SubGhzTxRx* instance);
* @param instance Pointer to a SubGhzTxRx
* @return bool True if it is possible to send this protocol
*/
bool subghz_txrx_protocol_is_send(SubGhzTxRx* instance, bool check_type);
bool subghz_txrx_protocol_is_transmittable(SubGhzTxRx* instance, bool check_type);
/**
* Set filter, what types of decoder to use
@@ -284,7 +284,7 @@ void subghz_txrx_set_rx_calback(
* @param callback Callback for Raw decoder, end of data transfer
* @param context Context for callback
*/
void subghz_txrx_set_raw_file_encoder_worker_set_callback_end(
void subghz_txrx_set_raw_file_encoder_worker_callback_end(
SubGhzTxRx* instance,
SubGhzProtocolEncoderRAWCallbackEnd callback,
void* context);

View File

@@ -21,7 +21,7 @@ struct SubGhzTxRx {
uint8_t hopper_timeout;
uint8_t hopper_idx_frequency;
bool load_database;
bool is_database_loaded;
SubGhzHopperState hopper_state;
SubGhzTxRxState txrx_state;

View File

@@ -29,7 +29,7 @@ static void subghz_scene_receiver_update_statusbar(void* context) {
FuriString* frequency_str = furi_string_alloc();
FuriString* modulation_str = furi_string_alloc();
subghz_txrx_get_frequency_modulation(subghz->txrx, frequency_str, modulation_str, false);
subghz_txrx_get_frequency_and_modulation(subghz->txrx, frequency_str, modulation_str, false);
subghz_view_receiver_add_data_statusbar(
subghz->subghz_receiver,
@@ -88,13 +88,13 @@ bool subghz_scene_decode_raw_start(SubGhz* subghz) {
FuriString* file_name = furi_string_alloc();
bool success = false;
do {
if(!flipper_format_rewind(subghz_txtx_get_fff_data(subghz->txrx))) {
if(!flipper_format_rewind(subghz_txrx_get_fff_data(subghz->txrx))) {
FURI_LOG_E(TAG, "Rewind error");
break;
}
if(!flipper_format_read_string(
subghz_txtx_get_fff_data(subghz->txrx), "File_name", file_name)) {
subghz_txrx_get_fff_data(subghz->txrx), "File_name", file_name)) {
FURI_LOG_E(TAG, "Missing File_name");
break;
}

View File

@@ -15,7 +15,7 @@ void subghz_scene_delete_on_enter(void* context) {
FuriString* modulation_str = furi_string_alloc();
FuriString* text = furi_string_alloc();
subghz_txrx_get_frequency_modulation(subghz->txrx, frequency_str, modulation_str, false);
subghz_txrx_get_frequency_and_modulation(subghz->txrx, frequency_str, modulation_str, false);
widget_add_string_element(
subghz->widget,
78,

View File

@@ -30,7 +30,7 @@ void subghz_scene_delete_raw_on_enter(void* context) {
widget_add_string_element(
subghz->widget, 38, 25, AlignLeft, AlignTop, FontSecondary, "RAW signal");
subghz_txrx_get_frequency_modulation(subghz->txrx, frequency_str, modulation_str, false);
subghz_txrx_get_frequency_and_modulation(subghz->txrx, frequency_str, modulation_str, false);
widget_add_string_element(
subghz->widget,
35,

View File

@@ -13,7 +13,7 @@ bool subghz_scene_read_raw_update_filename(SubGhz* subghz) {
//set the path to read the file
FuriString* temp_str = furi_string_alloc();
do {
FlipperFormat* fff_data = subghz_txtx_get_fff_data(subghz->txrx);
FlipperFormat* fff_data = subghz_txrx_get_fff_data(subghz->txrx);
if(!flipper_format_rewind(fff_data)) {
FURI_LOG_E(TAG, "Rewind error");
break;
@@ -41,7 +41,7 @@ static void subghz_scene_read_raw_update_statusbar(void* context) {
FuriString* modulation_str = furi_string_alloc();
#ifdef SUBGHZ_EXT_PRESET_NAME
subghz_txrx_get_frequency_modulation(subghz->txrx, frequency_str, modulation_str, true);
subghz_txrx_get_frequency_and_modulation(subghz->txrx, frequency_str, modulation_str, true);
//TODO if need subghz_txrx_get_preset
//furi_string_printf(modulation_str, "%s", furi_string_get_cstr(subghz->txrx->preset->name));
#else
@@ -206,7 +206,7 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
subghz->state_notifications = SubGhzNotificationStateIDLE;
subghz_txrx_stop(subghz->txrx);
if(!subghz_tx_start(subghz, subghz_txtx_get_fff_data(subghz->txrx))) {
if(!subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx))) {
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateBack);
subghz_read_raw_set_status(
subghz->subghz_read_raw,
@@ -219,7 +219,7 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
DOLPHIN_DEED(DolphinDeedSubGhzSend);
}
// set callback end tx
subghz_txrx_set_raw_file_encoder_worker_set_callback_end(
subghz_txrx_set_raw_file_encoder_worker_callback_end(
subghz->txrx, subghz_scene_read_raw_callback_end_tx, subghz);
subghz->state_notifications = SubGhzNotificationStateTx;
}
@@ -250,7 +250,7 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
furi_string_printf(
temp_str, "%s/%s%s", SUBGHZ_RAW_FOLDER, RAW_FILE_NAME, SUBGHZ_APP_EXTENSION);
subghz_protocol_raw_gen_fff_data(
subghz_txtx_get_fff_data(subghz->txrx), furi_string_get_cstr(temp_str));
subghz_txrx_get_fff_data(subghz->txrx), furi_string_get_cstr(temp_str));
furi_string_free(temp_str);
if(spl_count > 0) {

View File

@@ -46,12 +46,12 @@ static void subghz_scene_receiver_update_statusbar(void* context) {
#ifdef SUBGHZ_EXT_PRESET_NAME
if(subghz_history_get_last_index(subghz->history) > 0) {
subghz_txrx_get_frequency_modulation(
subghz_txrx_get_frequency_and_modulation(
subghz->txrx, frequency_str, modulation_str, false);
} else {
FuriString* temp_str = furi_string_alloc();
subghz_txrx_get_frequency_modulation(subghz->txrx, frequency_str, temp_str, true);
subghz_txrx_get_frequency_and_modulation(subghz->txrx, frequency_str, temp_str, true);
furi_string_printf(
modulation_str,
"%s Mod: %s",
@@ -60,7 +60,8 @@ static void subghz_scene_receiver_update_statusbar(void* context) {
furi_string_free(temp_str);
}
#else
subghz_txrx_get_frequency_modulation(subghz->txrx, frequency_str, modulation_str, false);
subghz_txrx_get_frequency_and_modulation(
subghz->txrx, frequency_str, modulation_str, false);
#endif
subghz_view_receiver_add_data_statusbar(

View File

@@ -52,7 +52,7 @@ void subghz_scene_receiver_info_draw_widget(SubGhz* subghz) {
FuriString* modulation_str = furi_string_alloc();
FuriString* text = furi_string_alloc();
subghz_txrx_get_frequency_modulation(subghz->txrx, frequency_str, modulation_str, false);
subghz_txrx_get_frequency_and_modulation(subghz->txrx, frequency_str, modulation_str, false);
widget_add_string_element(
subghz->widget,
78,
@@ -78,7 +78,7 @@ void subghz_scene_receiver_info_draw_widget(SubGhz* subghz) {
furi_string_free(modulation_str);
furi_string_free(text);
if(subghz_txrx_protocol_is_preserved(subghz->txrx)) {
if(subghz_txrx_protocol_is_serializable(subghz->txrx)) {
widget_add_button_element(
subghz->widget,
GuiButtonTypeRight,
@@ -87,7 +87,7 @@ void subghz_scene_receiver_info_draw_widget(SubGhz* subghz) {
subghz);
}
// Removed static check
if(subghz_txrx_protocol_is_send(subghz->txrx, false)) {
if(subghz_txrx_protocol_is_transmittable(subghz->txrx, false)) {
widget_add_button_element(
subghz->widget,
GuiButtonTypeCenter,
@@ -127,7 +127,7 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event)
subghz,
subghz_history_get_raw_data(subghz->history, subghz->idx_menu_chosen))) {
subghz_txrx_rx_start(subghz->txrx);
subghz_txrx_hopper_remove_pause(subghz->txrx);
subghz_txrx_hopper_unpause(subghz->txrx);
subghz->state_notifications = SubGhzNotificationStateRx;
} else {
subghz->state_notifications = SubGhzNotificationStateTx;
@@ -144,7 +144,7 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event)
if(!subghz->in_decoder_scene) {
subghz_txrx_rx_start(subghz->txrx);
subghz_txrx_hopper_remove_pause(subghz->txrx);
subghz_txrx_hopper_unpause(subghz->txrx);
subghz->state_notifications = SubGhzNotificationStateRx;
}
return true;
@@ -158,7 +158,7 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event)
return false;
}
if(subghz_txrx_protocol_is_preserved(subghz->txrx)) {
if(subghz_txrx_protocol_is_serializable(subghz->txrx)) {
subghz_file_name_clear(subghz);
if(subghz->in_decoder_scene) {

View File

@@ -44,7 +44,7 @@ bool subghz_scene_rpc_on_event(void* context, SceneManagerEvent event) {
} else if(event.event == SubGhzCustomEventSceneRpcButtonPress) {
bool result = false;
if((state == SubGhzRpcStateLoaded)) {
result = subghz_tx_start(subghz, subghz_txtx_get_fff_data(subghz->txrx));
result = subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx));
state = SubGhzRpcStateTx;
if(result) subghz_blink_start(subghz);
}

View File

@@ -147,7 +147,7 @@ bool subghz_scene_save_name_on_event(void* context, SceneManagerEvent event) {
SubGhzCustomEventManagerNoSet) {
subghz_save_protocol_to_file(
subghz,
subghz_txtx_get_fff_data(subghz->txrx),
subghz_txrx_get_fff_data(subghz->txrx),
furi_string_get_cstr(subghz->file_path));
scene_manager_set_scene_state(
subghz->scene_manager,
@@ -164,7 +164,7 @@ bool subghz_scene_save_name_on_event(void* context, SceneManagerEvent event) {
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) !=
SubGhzCustomEventManagerNoSet) {
subghz_protocol_raw_gen_fff_data(
subghz_txtx_get_fff_data(subghz->txrx),
subghz_txrx_get_fff_data(subghz->txrx),
furi_string_get_cstr(subghz->file_path));
scene_manager_set_scene_state(
subghz->scene_manager, SubGhzSceneReadRAW, SubGhzCustomEventManagerNoSet);

View File

@@ -23,17 +23,17 @@ bool subghz_scene_transmitter_update_data_show(void* context) {
FuriString* modulation_str = furi_string_alloc();
if(subghz_protocol_decoder_base_deserialize(
decoder, subghz_txtx_get_fff_data(subghz->txrx)) == SubGhzProtocolStatusOk) {
decoder, subghz_txrx_get_fff_data(subghz->txrx)) == SubGhzProtocolStatusOk) {
subghz_protocol_decoder_base_get_string(decoder, key_str);
subghz_txrx_get_frequency_modulation(
subghz_txrx_get_frequency_and_modulation(
subghz->txrx, frequency_str, modulation_str, false);
subghz_view_transmitter_add_data_to_show(
subghz->subghz_transmitter,
furi_string_get_cstr(key_str),
furi_string_get_cstr(frequency_str),
furi_string_get_cstr(modulation_str),
subghz_txrx_protocol_is_send(subghz->txrx, false));
subghz_txrx_protocol_is_transmittable(subghz->txrx, false));
ret = true;
}
furi_string_free(frequency_str);
@@ -67,7 +67,7 @@ bool subghz_scene_transmitter_on_event(void* context, SceneManagerEvent event) {
if(event.event == SubGhzCustomEventViewTransmitterSendStart) {
subghz->state_notifications = SubGhzNotificationStateIDLE;
if(subghz_tx_start(subghz, subghz_txtx_get_fff_data(subghz->txrx))) {
if(subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx))) {
subghz->state_notifications = SubGhzNotificationStateTx;
subghz_scene_transmitter_update_data_show(subghz);
DOLPHIN_DEED(DolphinDeedSubGhzSend);
@@ -83,7 +83,7 @@ bool subghz_scene_transmitter_on_event(void* context, SceneManagerEvent event) {
// Calling restore!
subghz_txrx_stop(subghz->txrx);
if(!subghz_tx_start(subghz, subghz_txtx_get_fff_data(subghz->txrx))) {
if(!subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx))) {
scene_manager_next_scene(
subghz->scene_manager, SubGhzSceneShowOnlyRx); //TODO Is this necessary?
}

View File

@@ -265,7 +265,7 @@ SubGhz* subghz_alloc(bool alloc_for_tx_only) {
subghz->filter = SubGhzProtocolFlag_Decodable;
subghz_txrx_receiver_set_filter(subghz->txrx, subghz->filter);
subghz_txrx_need_save_callback_set(subghz->txrx, subghz_save_to_file, subghz);
subghz_txrx_set_need_save_callback(subghz->txrx, subghz_save_to_file, subghz);
//Init Error_str
subghz->error_str = furi_string_alloc();
@@ -446,7 +446,7 @@ int32_t subghz_app(void* p) {
view_dispatcher_attach_to_gui(
subghz->view_dispatcher, subghz->gui, ViewDispatcherTypeFullscreen);
furi_string_set(subghz->file_path, SUBGHZ_APP_FOLDER);
if(subghz_txrx_is_load_database(subghz->txrx)) {
if(subghz_txrx_is_database_loaded(subghz->txrx)) {
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneStart);
} else {
scene_manager_set_scene_state(

View File

@@ -79,7 +79,7 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path, bool show_dialog) {
Storage* storage = furi_record_open(RECORD_STORAGE);
FlipperFormat* fff_data_file = flipper_format_file_alloc(storage);
Stream* fff_data_stream =
flipper_format_get_raw_stream(subghz_txtx_get_fff_data(subghz->txrx));
flipper_format_get_raw_stream(subghz_txrx_get_fff_data(subghz->txrx));
SubGhzLoadKeyState load_key_state = SubGhzLoadKeyStateParseErr;
FuriString* temp_str = furi_string_alloc();
@@ -129,7 +129,7 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path, bool show_dialog) {
}
furi_string_set_str(
temp_str, subghz_txrx_get_name_preset(subghz->txrx, furi_string_get_cstr(temp_str)));
temp_str, subghz_txrx_get_preset_name(subghz->txrx, furi_string_get_cstr(temp_str)));
if(temp_str == NULL) {
break;
}
@@ -164,7 +164,7 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path, bool show_dialog) {
break;
}
FlipperFormat* fff_data = subghz_txtx_get_fff_data(subghz->txrx);
FlipperFormat* fff_data = subghz_txrx_get_fff_data(subghz->txrx);
if(!strcmp(furi_string_get_cstr(temp_str), "RAW")) {
//if RAW
subghz->load_type_file = SubGhzLoadTypeFileRaw;
@@ -276,7 +276,7 @@ void subghz_save_to_file(void* context) {
if(subghz_path_is_file(subghz->file_path)) {
subghz_save_protocol_to_file(
subghz,
subghz_txtx_get_fff_data(subghz->txrx),
subghz_txrx_get_fff_data(subghz->txrx),
furi_string_get_cstr(subghz->file_path));
}
}