From f25af91d239dbd3bcedc562ecfea65945572cbd0 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Mon, 6 Mar 2023 10:08:59 +0300 Subject: [PATCH 1/5] Fix issues with external module 5v power --- applications/main/unirfremix/unirfremix_app.c | 8 +++++++- applications/plugins/playlist/playlist.c | 5 +++++ .../plugins/pocsag_pager/pocsag_pager_app.c | 6 ++++++ applications/plugins/protoview/app.c | 6 ++++++ .../plugins/spectrum_analyzer/spectrum_analyzer.c | 6 ++++++ applications/plugins/subbrute | 2 +- .../plugins/weather_station/weather_station_app.c | 6 ++++++ firmware/targets/f7/furi_hal/furi_hal_subghz.c | 13 ++++++++++--- 8 files changed, 47 insertions(+), 5 deletions(-) diff --git a/applications/main/unirfremix/unirfremix_app.c b/applications/main/unirfremix/unirfremix_app.c index b7295754c..fae194b26 100644 --- a/applications/main/unirfremix/unirfremix_app.c +++ b/applications/main/unirfremix/unirfremix_app.c @@ -402,7 +402,8 @@ bool unirfremix_key_load( preset->decoder = subghz_receiver_search_decoder_base_by_name( receiver, furi_string_get_cstr(preset->protocol)); if(preset->decoder) { - SubGhzProtocolStatus status = subghz_protocol_decoder_base_deserialize(preset->decoder, fff_data); + SubGhzProtocolStatus status = + subghz_protocol_decoder_base_deserialize(preset->decoder, fff_data); if(status != SubGhzProtocolStatusOk) { FURI_LOG_E(TAG, "Protocol deserialize failed, status = %d", status); break; @@ -736,6 +737,8 @@ UniRFRemix* unirfremix_alloc(void) { UniRFRemix* app = malloc(sizeof(UniRFRemix)); furi_hal_power_suppress_charge_enter(); + // Enable power for External CC1101 if it is connected + furi_hal_subghz_enable_ext_power(); app->model_mutex = furi_mutex_alloc(FuriMutexTypeNormal); @@ -757,6 +760,9 @@ UniRFRemix* unirfremix_alloc(void) { void unirfremix_free(UniRFRemix* app, bool with_subghz) { furi_hal_power_suppress_charge_exit(); + // Disable power for External CC1101 if it was enabled and module is connected + furi_hal_subghz_disable_ext_power(); + furi_string_free(app->up_file); furi_string_free(app->down_file); furi_string_free(app->left_file); diff --git a/applications/plugins/playlist/playlist.c b/applications/plugins/playlist/playlist.c index 9946fb95b..a6aa09cba 100644 --- a/applications/plugins/playlist/playlist.c +++ b/applications/plugins/playlist/playlist.c @@ -674,6 +674,9 @@ int32_t playlist_app(void* p) { furi_hal_power_suppress_charge_enter(); + // Enable power for External CC1101 if it is connected + furi_hal_subghz_enable_ext_power(); + // select playlist file { DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS); @@ -752,6 +755,8 @@ int32_t playlist_app(void* p) { exit_cleanup: furi_hal_power_suppress_charge_exit(); + // Disable power for External CC1101 if it was enabled and module is connected + furi_hal_subghz_disable_ext_power(); if(app->worker != NULL) { if(playlist_worker_running(app->worker)) { diff --git a/applications/plugins/pocsag_pager/pocsag_pager_app.c b/applications/plugins/pocsag_pager/pocsag_pager_app.c index 3ac242304..680edb2a5 100644 --- a/applications/plugins/pocsag_pager/pocsag_pager_app.c +++ b/applications/plugins/pocsag_pager/pocsag_pager_app.c @@ -124,6 +124,9 @@ POCSAGPagerApp* pocsag_pager_app_alloc() { furi_hal_power_suppress_charge_enter(); + // Enable power for External CC1101 if it is connected + furi_hal_subghz_enable_ext_power(); + scene_manager_next_scene(app->scene_manager, POCSAGPagerSceneStart); return app; @@ -135,6 +138,9 @@ void pocsag_pager_app_free(POCSAGPagerApp* app) { //CC1101 off pcsg_sleep(app); + // Disable power for External CC1101 if it was enabled and module is connected + furi_hal_subghz_disable_ext_power(); + // Submenu view_dispatcher_remove_view(app->view_dispatcher, POCSAGPagerViewSubmenu); submenu_free(app->submenu); diff --git a/applications/plugins/protoview/app.c b/applications/plugins/protoview/app.c index d27b3a54a..7dc8a7b83 100644 --- a/applications/plugins/protoview/app.c +++ b/applications/plugins/protoview/app.c @@ -170,6 +170,9 @@ ProtoViewApp* protoview_app_alloc() { furi_hal_power_suppress_charge_enter(); app->running = 1; + // Enable power for External CC1101 if it is connected + furi_hal_subghz_enable_ext_power(); + return app; } @@ -182,6 +185,9 @@ void protoview_app_free(ProtoViewApp* app) { // Put CC1101 on sleep, this also restores charging. radio_sleep(app); + // Disable power for External CC1101 if it was enabled and module is connected + furi_hal_subghz_disable_ext_power(); + // View related. view_port_enabled_set(app->view_port, false); gui_remove_view_port(app->gui, app->view_port); diff --git a/applications/plugins/spectrum_analyzer/spectrum_analyzer.c b/applications/plugins/spectrum_analyzer/spectrum_analyzer.c index 8d68c5a1a..10471e473 100644 --- a/applications/plugins/spectrum_analyzer/spectrum_analyzer.c +++ b/applications/plugins/spectrum_analyzer/spectrum_analyzer.c @@ -392,6 +392,9 @@ void spectrum_analyzer_free(SpectrumAnalyzer* instance) { furi_hal_subghz_idle(); furi_hal_subghz_sleep(); + + // Disable power for External CC1101 if it was enabled and module is connected + furi_hal_subghz_disable_ext_power(); } int32_t spectrum_analyzer_app(void* p) { @@ -402,6 +405,9 @@ int32_t spectrum_analyzer_app(void* p) { furi_hal_power_suppress_charge_enter(); + // Enable power for External CC1101 if it is connected + furi_hal_subghz_enable_ext_power(); + FURI_LOG_D("Spectrum", "Main Loop - Starting worker"); furi_delay_ms(50); diff --git a/applications/plugins/subbrute b/applications/plugins/subbrute index 7cdb9e138..552bd12d0 160000 --- a/applications/plugins/subbrute +++ b/applications/plugins/subbrute @@ -1 +1 @@ -Subproject commit 7cdb9e1386778ad7351f7e3b3389980afaeafea3 +Subproject commit 552bd12d0f710501c31f7d44b4755d7fa89de303 diff --git a/applications/plugins/weather_station/weather_station_app.c b/applications/plugins/weather_station/weather_station_app.c index b17f2acfc..0d83095b5 100644 --- a/applications/plugins/weather_station/weather_station_app.c +++ b/applications/plugins/weather_station/weather_station_app.c @@ -107,6 +107,9 @@ WeatherStationApp* weather_station_app_alloc() { furi_hal_power_suppress_charge_enter(); + // Enable power for External CC1101 if it is connected + furi_hal_subghz_enable_ext_power(); + scene_manager_next_scene(app->scene_manager, WeatherStationSceneStart); return app; @@ -118,6 +121,9 @@ void weather_station_app_free(WeatherStationApp* app) { //CC1101 off ws_sleep(app); + // Disable power for External CC1101 if it was enabled and module is connected + furi_hal_subghz_disable_ext_power(); + // Submenu view_dispatcher_remove_view(app->view_dispatcher, WeatherStationViewSubmenu); submenu_free(app->submenu); diff --git a/firmware/targets/f7/furi_hal/furi_hal_subghz.c b/firmware/targets/f7/furi_hal/furi_hal_subghz.c index 451cda439..e4a118652 100644 --- a/firmware/targets/f7/furi_hal/furi_hal_subghz.c +++ b/firmware/targets/f7/furi_hal/furi_hal_subghz.c @@ -22,6 +22,7 @@ static uint32_t furi_hal_subghz_debug_gpio_buff[2]; static bool last_OTG_state = false; +static bool ext_power_is_enabled_already = false; /* DMA Channels definition */ #define SUBGHZ_DMA DMA2 @@ -80,12 +81,16 @@ void furi_hal_subghz_init(void) { } void furi_hal_subghz_enable_ext_power(void) { + if(ext_power_is_enabled_already) return; + ext_power_is_enabled_already = true; + last_OTG_state = furi_hal_power_is_otg_enabled(); if(furi_hal_subghz.radio_type != SubGhzRadioInternal && !furi_hal_power_is_otg_enabled()) { furi_hal_power_enable_otg(); } } void furi_hal_subghz_disable_ext_power(void) { + ext_power_is_enabled_already = false; if(furi_hal_subghz.radio_type != SubGhzRadioInternal && !last_OTG_state) { furi_hal_power_disable_otg(); } @@ -97,6 +102,7 @@ bool furi_hal_subghz_check_radio(void) { furi_hal_subghz_enable_ext_power(); furi_hal_spi_acquire(furi_hal_subghz.spi_bus_handle); + uint8_t ver = cc1101_get_version(furi_hal_subghz.spi_bus_handle); furi_hal_spi_release(furi_hal_subghz.spi_bus_handle); @@ -104,9 +110,10 @@ bool furi_hal_subghz_check_radio(void) { FURI_LOG_D(TAG, "Radio check ok"); } else { FURI_LOG_D(TAG, "Radio check failed"); - furi_hal_subghz_disable_ext_power(); + result = false; } + furi_hal_subghz_disable_ext_power(); return result; } @@ -117,7 +124,6 @@ bool furi_hal_subghz_init_check(void) { furi_hal_subghz.state = SubGhzStateIdle; furi_hal_subghz.preset = FuriHalSubGhzPresetIDLE; - last_OTG_state = furi_hal_power_is_otg_enabled(); furi_hal_subghz_enable_ext_power(); furi_hal_spi_acquire(furi_hal_subghz.spi_bus_handle); @@ -169,8 +175,8 @@ bool furi_hal_subghz_init_check(void) { FURI_LOG_I(TAG, "Init OK"); } else { FURI_LOG_E(TAG, "Failed to initialization"); - furi_hal_subghz_disable_ext_power(); } + furi_hal_subghz_disable_ext_power(); return result; } @@ -346,6 +352,7 @@ void furi_hal_subghz_reset() { } void furi_hal_subghz_idle() { + furi_hal_subghz_enable_ext_power(); furi_hal_spi_acquire(furi_hal_subghz.spi_bus_handle); cc1101_switch_to_idle(furi_hal_subghz.spi_bus_handle); furi_hal_spi_release(furi_hal_subghz.spi_bus_handle); From 6d0c3eb3b6e7b58d2b40f5e62e4ff8fbb80d193e Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Mon, 6 Mar 2023 10:32:01 +0300 Subject: [PATCH 2/5] Properly rename unirf remix to subghz remote And automatically migrate user files to new folder --- applications/main/application.fam | 2 +- .../application.fam | 8 +- .../subghz_remote_app.c} | 116 +++++++++--------- .../frame_0.png | Bin .../frame_1.png | Bin .../frame_2.png | Bin .../frame_3.png | Bin .../frame_4.png | Bin .../frame_5.png | Bin .../frame_6.png | Bin .../frame_7.png | Bin .../frame_rate | 0 assets/resources/unirf/unirf_map_example.txt | 10 -- documentation/SubGHzRemotePlugin.md | 8 +- 14 files changed, 68 insertions(+), 76 deletions(-) rename applications/main/{unirfremix => subghz_remote}/application.fam (55%) rename applications/main/{unirfremix/unirfremix_app.c => subghz_remote/subghz_remote_app.c} (91%) rename assets/icons/MainMenu/{UniRFRemix_14 => SubGHzRemote_14}/frame_0.png (100%) rename assets/icons/MainMenu/{UniRFRemix_14 => SubGHzRemote_14}/frame_1.png (100%) rename assets/icons/MainMenu/{UniRFRemix_14 => SubGHzRemote_14}/frame_2.png (100%) rename assets/icons/MainMenu/{UniRFRemix_14 => SubGHzRemote_14}/frame_3.png (100%) rename assets/icons/MainMenu/{UniRFRemix_14 => SubGHzRemote_14}/frame_4.png (100%) rename assets/icons/MainMenu/{UniRFRemix_14 => SubGHzRemote_14}/frame_5.png (100%) rename assets/icons/MainMenu/{UniRFRemix_14 => SubGHzRemote_14}/frame_6.png (100%) rename assets/icons/MainMenu/{UniRFRemix_14 => SubGHzRemote_14}/frame_7.png (100%) rename assets/icons/MainMenu/{UniRFRemix_14 => SubGHzRemote_14}/frame_rate (100%) delete mode 100644 assets/resources/unirf/unirf_map_example.txt diff --git a/applications/main/application.fam b/applications/main/application.fam index a3d310093..1b18a7d2d 100644 --- a/applications/main/application.fam +++ b/applications/main/application.fam @@ -14,7 +14,7 @@ App( "fap_loader", "archive", "clock", - "unirfremix", + "subghz_remote", ], ) diff --git a/applications/main/unirfremix/application.fam b/applications/main/subghz_remote/application.fam similarity index 55% rename from applications/main/unirfremix/application.fam rename to applications/main/subghz_remote/application.fam index fd3553947..e09f8500f 100644 --- a/applications/main/unirfremix/application.fam +++ b/applications/main/subghz_remote/application.fam @@ -1,14 +1,14 @@ App( - appid="unirfremix", + appid="subghz_remote", name="Sub-GHz Remote", apptype=FlipperAppType.APP, - entry_point="unirfremix_app", - cdefines=["APP_UNIRFREMIX"], + entry_point="subghz_remote_app", + cdefines=["APP_SUBGHZREMOTE"], requires=[ "gui", "dialogs", ], - icon="A_UniRFRemix_14", + icon="A_SubGHzRemote_14", stack_size=4 * 1024, order=11, ) diff --git a/applications/main/unirfremix/unirfremix_app.c b/applications/main/subghz_remote/subghz_remote_app.c similarity index 91% rename from applications/main/unirfremix/unirfremix_app.c rename to applications/main/subghz_remote/subghz_remote_app.c index fae194b26..0440699c2 100644 --- a/applications/main/unirfremix/unirfremix_app.c +++ b/applications/main/subghz_remote/subghz_remote_app.c @@ -23,10 +23,10 @@ #include #include -#define UNIRFMAP_FOLDER "/ext/unirf" -#define UNIRFMAP_EXTENSION ".txt" +#define SUBREMOTEMAP_FOLDER "/ext/subghz_remote" +#define SUBREMOTEMAP_EXTENSION ".txt" -#define TAG "UniRF Remix" +#define TAG "SubGHzRemote" typedef struct { uint32_t frequency; @@ -39,7 +39,7 @@ typedef struct { size_t data_size; SubGhzProtocolDecoderBase* decoder; -} UniRFPreset; +} SubRemotePreset; typedef struct { FuriMutex* model_mutex; @@ -53,7 +53,7 @@ typedef struct { SubGhzEnvironment* environment; SubGhzReceiver* subghz_receiver; NotificationApp* notification; - UniRFPreset* txpreset; + SubRemotePreset* txpreset; FuriString* up_file; FuriString* down_file; @@ -88,17 +88,17 @@ typedef struct { bool tx_not_allowed; FuriString* signal; -} UniRFRemix; +} SubGHzRemote; -UniRFPreset* unirfremix_preset_alloc(void) { - UniRFPreset* preset = malloc(sizeof(UniRFPreset)); +SubRemotePreset* subghz_remote_preset_alloc(void) { + SubRemotePreset* preset = malloc(sizeof(SubRemotePreset)); preset->name = furi_string_alloc(); preset->protocol = furi_string_alloc(); preset->repeat = 200; return preset; } -void unirfremix_preset_free(UniRFPreset* preset) { +void subghz_remote_preset_free(SubRemotePreset* preset) { furi_string_free(preset->name); furi_string_free(preset->protocol); free(preset); @@ -170,7 +170,7 @@ static void cfg_read_file_label( * set error flag if missing map file */ -void unirfremix_cfg_set_check(UniRFRemix* app, FuriString* file_name) { +void subghz_remote_cfg_set_check(SubGHzRemote* app, FuriString* file_name) { Storage* storage = furi_record_open(RECORD_STORAGE); FlipperFormat* fff_data_file = flipper_format_file_alloc(storage); @@ -313,11 +313,11 @@ void unirfremix_cfg_set_check(UniRFRemix* app, FuriString* file_name) { } } -static void unirfremix_end_send(UniRFRemix* app) { +static void subghz_remote_end_send(SubGHzRemote* app) { app->processing = 0; } -bool unirfremix_set_preset(UniRFPreset* p, const char* preset) { +bool subghz_remote_set_preset(SubRemotePreset* p, const char* preset) { if(!strcmp(preset, "FuriHalSubGhzPresetOok270Async")) { furi_string_set(p->name, "AM270"); } else if(!strcmp(preset, "FuriHalSubGhzPresetOok650Async")) { @@ -337,8 +337,8 @@ bool unirfremix_set_preset(UniRFPreset* p, const char* preset) { return true; } -bool unirfremix_key_load( - UniRFPreset* preset, +bool subghz_remote_key_load( + SubRemotePreset* preset, FlipperFormat* fff_file, FlipperFormat* fff_data, SubGhzSetting* setting, @@ -367,7 +367,7 @@ bool unirfremix_key_load( FURI_LOG_W(TAG, "Could not read Preset. Defaulting to Ook650Async"); furi_string_set(temp_str, "FuriHalSubGhzPresetOok650Async"); } - if(!unirfremix_set_preset(preset, furi_string_get_cstr(temp_str))) { + if(!subghz_remote_set_preset(preset, furi_string_get_cstr(temp_str))) { FURI_LOG_E(TAG, "Could not set preset"); break; } @@ -422,7 +422,7 @@ bool unirfremix_key_load( // method modified from subghz_i.c // https://github.com/flipperdevices/flipperzero-firmware/blob/b0daa601ad5b87427a45f9089c8b403a01f72c2a/applications/subghz/subghz_i.c#L417-L456 -bool unirfremix_save_protocol_to_file(FlipperFormat* fff_file, const char* dev_file_name) { +bool subghz_remote_save_protocol_to_file(FlipperFormat* fff_file, const char* dev_file_name) { furi_assert(fff_file); furi_assert(dev_file_name); @@ -459,7 +459,7 @@ bool unirfremix_save_protocol_to_file(FlipperFormat* fff_file, const char* dev_f return saved; } -void unirfremix_tx_stop(UniRFRemix* app) { +void subghz_remote_tx_stop(SubGHzRemote* app) { if(app->processing == 0) { return; } @@ -483,7 +483,7 @@ void unirfremix_tx_stop(UniRFRemix* app) { FURI_LOG_D(TAG, "Protocol-TYPE %d", proto->type); if(proto && proto->type == SubGhzProtocolTypeDynamic) { FURI_LOG_D(TAG, "Protocol is dynamic. Saving key"); - unirfremix_save_protocol_to_file(app->tx_fff_data, app->tx_file_path); + subghz_remote_save_protocol_to_file(app->tx_fff_data, app->tx_file_path); keeloq_reset_mfname(); keeloq_reset_kl_type(); @@ -500,22 +500,22 @@ void unirfremix_tx_stop(UniRFRemix* app) { notification_message(app->notification, &sequence_blink_stop); - unirfremix_preset_free(app->txpreset); + subghz_remote_preset_free(app->txpreset); flipper_format_free(app->tx_fff_data); - unirfremix_end_send(app); + subghz_remote_end_send(app); } -static bool unirfremix_send_sub(UniRFRemix* app, FlipperFormat* fff_data) { +static bool subghz_remote_send_sub(SubGHzRemote* app, FlipperFormat* fff_data) { // bool res = false; do { if(!furi_hal_subghz_is_tx_allowed(app->txpreset->frequency)) { printf( "In your settings, only reception on this frequency (%lu) is allowed,\r\n" - "the actual operation of the unirf app is not possible\r\n ", + "the actual operation of the subghz remote app is not possible\r\n ", app->txpreset->frequency); app->tx_not_allowed = true; - unirfremix_end_send(app); + subghz_remote_end_send(app); break; } else { app->tx_not_allowed = false; @@ -557,14 +557,14 @@ static bool unirfremix_send_sub(UniRFRemix* app, FlipperFormat* fff_data) { return res; } -static void unirfremix_send_signal(UniRFRemix* app, Storage* storage, const char* path) { +static void subghz_remote_send_signal(SubGHzRemote* app, Storage* storage, const char* path) { FURI_LOG_D(TAG, "Sending: %s", path); app->tx_file_path = path; app->tx_fff_data = flipper_format_string_alloc(); - app->txpreset = unirfremix_preset_alloc(); + app->txpreset = subghz_remote_preset_alloc(); // load settings/stream from .sub file FlipperFormat* fff_file = flipper_format_file_alloc(storage); @@ -574,7 +574,7 @@ static void unirfremix_send_signal(UniRFRemix* app, Storage* storage, const char FURI_LOG_E(TAG, "Could not open file %s", path); break; } - if(!unirfremix_key_load( + if(!subghz_remote_key_load( app->txpreset, fff_file, app->tx_fff_data, @@ -592,25 +592,25 @@ static void unirfremix_send_signal(UniRFRemix* app, Storage* storage, const char return; } - unirfremix_send_sub(app, app->tx_fff_data); + subghz_remote_send_sub(app, app->tx_fff_data); } -static void unirfremix_process_signal(UniRFRemix* app, FuriString* signal) { +static void subghz_remote_process_signal(SubGHzRemote* app, FuriString* signal) { view_port_update(app->view_port); FURI_LOG_D(TAG, "signal = %s", furi_string_get_cstr(signal)); if(strlen(furi_string_get_cstr(signal)) > 12) { Storage* storage = furi_record_open(RECORD_STORAGE); - unirfremix_send_signal(app, storage, furi_string_get_cstr(signal)); + subghz_remote_send_signal(app, storage, furi_string_get_cstr(signal)); furi_record_close(RECORD_STORAGE); } else if(strlen(furi_string_get_cstr(signal)) < 10) { - unirfremix_end_send(app); + subghz_remote_end_send(app); } } static void render_callback(Canvas* canvas, void* ctx) { - UniRFRemix* app = ctx; + SubGHzRemote* app = ctx; furi_check(furi_mutex_acquire(app->model_mutex, FuriWaitForever) == FuriStatusOk); //setup different canvas settings @@ -650,10 +650,10 @@ static void render_callback(Canvas* canvas, void* ctx) { //canvas_draw_str(canvas, 0, 40, "D: "); //canvas_draw_str(canvas, 0, 50, "Ok: "); - //PNGs are located in assets/icons/UniRFRemix before compilation + //PNGs are located in assets/icons/SubGHzRemote before compilation //Icons for Labels - //canvas_draw_icon(canvas, 0, 0, &I_UniRFRemix_LeftAlignedButtons_9x64); + //canvas_draw_icon(canvas, 0, 0, &I_SubGHzRemote_LeftAlignedButtons_9x64); canvas_draw_icon(canvas, 1, 5, &I_ButtonUp_7x4); canvas_draw_icon(canvas, 1, 15, &I_ButtonDown_7x4); canvas_draw_icon(canvas, 2, 23, &I_ButtonLeft_4x7); @@ -702,7 +702,7 @@ static void render_callback(Canvas* canvas, void* ctx) { //Repeat indicator //canvas_draw_str_aligned(canvas, 125, 40, AlignRight, AlignBottom, "Repeat:"); - //canvas_draw_icon(canvas, 115, 39, &I_UniRFRemix_Repeat_12x14); + //canvas_draw_icon(canvas, 115, 39, &I_SubGHzRemote_Repeat_12x14); //canvas_draw_str_aligned(canvas, 125, 62, AlignRight, AlignBottom, int_to_char(app->repeat)); } @@ -710,11 +710,11 @@ static void render_callback(Canvas* canvas, void* ctx) { } static void input_callback(InputEvent* input_event, void* ctx) { - UniRFRemix* app = ctx; + SubGHzRemote* app = ctx; furi_message_queue_put(app->input_queue, input_event, 0); } -void unirfremix_subghz_alloc(UniRFRemix* app) { +void subghz_remote_subghz_alloc(SubGHzRemote* app) { // load subghz presets app->setting = subghz_setting_alloc(); subghz_setting_load(app->setting, EXT_PATH("subghz/assets/setting_user")); @@ -733,8 +733,8 @@ void unirfremix_subghz_alloc(UniRFRemix* app) { app->subghz_receiver = subghz_receiver_alloc_init(app->environment); } -UniRFRemix* unirfremix_alloc(void) { - UniRFRemix* app = malloc(sizeof(UniRFRemix)); +SubGHzRemote* subghz_remote_alloc(void) { + SubGHzRemote* app = malloc(sizeof(SubGHzRemote)); furi_hal_power_suppress_charge_enter(); // Enable power for External CC1101 if it is connected @@ -757,7 +757,7 @@ UniRFRemix* unirfremix_alloc(void) { return app; } -void unirfremix_free(UniRFRemix* app, bool with_subghz) { +void subghz_remote_free(SubGHzRemote* app, bool with_subghz) { furi_hal_power_suppress_charge_exit(); // Disable power for External CC1101 if it was enabled and module is connected @@ -794,9 +794,9 @@ void unirfremix_free(UniRFRemix* app, bool with_subghz) { free(app); } -int32_t unirfremix_app(void* p) { +int32_t subghz_remote_app(void* p) { UNUSED(p); - UniRFRemix* app = unirfremix_alloc(); + SubGHzRemote* app = subghz_remote_alloc(); app->file_path = furi_string_alloc(); app->signal = furi_string_alloc(); @@ -811,33 +811,35 @@ int32_t unirfremix_app(void* p) { app->file_result = 3; Storage* storage = furi_record_open(RECORD_STORAGE); - if(!storage_simply_mkdir(storage, UNIRFMAP_FOLDER)) { - FURI_LOG_E(TAG, "Could not create folder %s", UNIRFMAP_FOLDER); + storage_common_migrate(storage, EXT_PATH("unirf"), SUBREMOTEMAP_FOLDER); + + if(!storage_simply_mkdir(storage, SUBREMOTEMAP_FOLDER)) { + FURI_LOG_E(TAG, "Could not create folder %s", SUBREMOTEMAP_FOLDER); } furi_record_close(RECORD_STORAGE); - furi_string_set(app->file_path, UNIRFMAP_FOLDER); + furi_string_set(app->file_path, SUBREMOTEMAP_FOLDER); DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS); DialogsFileBrowserOptions browser_options; - dialog_file_browser_set_basic_options(&browser_options, UNIRFMAP_EXTENSION, &I_sub1_10px); - browser_options.base_path = UNIRFMAP_FOLDER; + dialog_file_browser_set_basic_options(&browser_options, SUBREMOTEMAP_EXTENSION, &I_sub1_10px); + browser_options.base_path = SUBREMOTEMAP_FOLDER; bool res = dialog_file_browser_show(dialogs, app->file_path, app->file_path, &browser_options); furi_record_close(RECORD_DIALOGS); if(!res) { FURI_LOG_E(TAG, "No file selected"); - unirfremix_free(app, false); + subghz_remote_free(app, false); return 255; } else { //check map and population variables - unirfremix_cfg_set_check(app, app->file_path); + subghz_remote_cfg_set_check(app, app->file_path); } // init subghz stuff - unirfremix_subghz_alloc(app); + subghz_remote_subghz_alloc(app); bool exit_loop = false; @@ -887,7 +889,7 @@ int32_t unirfremix_app(void* p) { } if(input.type == InputTypeRelease) { if(app->up_enabled) { - unirfremix_tx_stop(app); + subghz_remote_tx_stop(app); } } break; @@ -905,7 +907,7 @@ int32_t unirfremix_app(void* p) { } if(input.type == InputTypeRelease) { if(app->down_enabled) { - unirfremix_tx_stop(app); + subghz_remote_tx_stop(app); } } break; @@ -923,7 +925,7 @@ int32_t unirfremix_app(void* p) { } if(input.type == InputTypeRelease) { if(app->right_enabled) { - unirfremix_tx_stop(app); + subghz_remote_tx_stop(app); } } break; @@ -941,7 +943,7 @@ int32_t unirfremix_app(void* p) { } if(input.type == InputTypeRelease) { if(app->left_enabled) { - unirfremix_tx_stop(app); + subghz_remote_tx_stop(app); } } break; @@ -959,13 +961,13 @@ int32_t unirfremix_app(void* p) { } if(input.type == InputTypeRelease) { if(app->ok_enabled) { - unirfremix_tx_stop(app); + subghz_remote_tx_stop(app); } } break; case InputKeyBack: - unirfremix_tx_stop(app); + subghz_remote_tx_stop(app); exit_loop = true; break; default: @@ -1002,7 +1004,7 @@ int32_t unirfremix_app(void* p) { app->processing = 2; - unirfremix_process_signal(app, app->signal); + subghz_remote_process_signal(app, app->signal); } if(exit_loop == true) { @@ -1058,7 +1060,7 @@ int32_t unirfremix_app(void* p) { } // remove & free all stuff created by app - unirfremix_free(app, true); + subghz_remote_free(app, true); return 0; } diff --git a/assets/icons/MainMenu/UniRFRemix_14/frame_0.png b/assets/icons/MainMenu/SubGHzRemote_14/frame_0.png similarity index 100% rename from assets/icons/MainMenu/UniRFRemix_14/frame_0.png rename to assets/icons/MainMenu/SubGHzRemote_14/frame_0.png diff --git a/assets/icons/MainMenu/UniRFRemix_14/frame_1.png b/assets/icons/MainMenu/SubGHzRemote_14/frame_1.png similarity index 100% rename from assets/icons/MainMenu/UniRFRemix_14/frame_1.png rename to assets/icons/MainMenu/SubGHzRemote_14/frame_1.png diff --git a/assets/icons/MainMenu/UniRFRemix_14/frame_2.png b/assets/icons/MainMenu/SubGHzRemote_14/frame_2.png similarity index 100% rename from assets/icons/MainMenu/UniRFRemix_14/frame_2.png rename to assets/icons/MainMenu/SubGHzRemote_14/frame_2.png diff --git a/assets/icons/MainMenu/UniRFRemix_14/frame_3.png b/assets/icons/MainMenu/SubGHzRemote_14/frame_3.png similarity index 100% rename from assets/icons/MainMenu/UniRFRemix_14/frame_3.png rename to assets/icons/MainMenu/SubGHzRemote_14/frame_3.png diff --git a/assets/icons/MainMenu/UniRFRemix_14/frame_4.png b/assets/icons/MainMenu/SubGHzRemote_14/frame_4.png similarity index 100% rename from assets/icons/MainMenu/UniRFRemix_14/frame_4.png rename to assets/icons/MainMenu/SubGHzRemote_14/frame_4.png diff --git a/assets/icons/MainMenu/UniRFRemix_14/frame_5.png b/assets/icons/MainMenu/SubGHzRemote_14/frame_5.png similarity index 100% rename from assets/icons/MainMenu/UniRFRemix_14/frame_5.png rename to assets/icons/MainMenu/SubGHzRemote_14/frame_5.png diff --git a/assets/icons/MainMenu/UniRFRemix_14/frame_6.png b/assets/icons/MainMenu/SubGHzRemote_14/frame_6.png similarity index 100% rename from assets/icons/MainMenu/UniRFRemix_14/frame_6.png rename to assets/icons/MainMenu/SubGHzRemote_14/frame_6.png diff --git a/assets/icons/MainMenu/UniRFRemix_14/frame_7.png b/assets/icons/MainMenu/SubGHzRemote_14/frame_7.png similarity index 100% rename from assets/icons/MainMenu/UniRFRemix_14/frame_7.png rename to assets/icons/MainMenu/SubGHzRemote_14/frame_7.png diff --git a/assets/icons/MainMenu/UniRFRemix_14/frame_rate b/assets/icons/MainMenu/SubGHzRemote_14/frame_rate similarity index 100% rename from assets/icons/MainMenu/UniRFRemix_14/frame_rate rename to assets/icons/MainMenu/SubGHzRemote_14/frame_rate diff --git a/assets/resources/unirf/unirf_map_example.txt b/assets/resources/unirf/unirf_map_example.txt deleted file mode 100644 index 30f91b8aa..000000000 --- a/assets/resources/unirf/unirf_map_example.txt +++ /dev/null @@ -1,10 +0,0 @@ -UP: /ext/subghz/Up.sub -DOWN: /ext/subghz/Down.sub -LEFT: /ext/subghz/Left.sub -RIGHT: /ext/subghz/Right.sub -OK: /ext/subghz/Ok.sub -ULABEL: Up Label -DLABEL: Down Label -LLABEL: Left Label -RLABEL: Right Label -OKLABEL: Ok Label \ No newline at end of file diff --git a/documentation/SubGHzRemotePlugin.md b/documentation/SubGHzRemotePlugin.md index 8563dbd5d..fd48eeca2 100644 --- a/documentation/SubGHzRemotePlugin.md +++ b/documentation/SubGHzRemotePlugin.md @@ -1,6 +1,6 @@ -# UniRF Remix / Sub-GHz Remote +# Sub-GHz Remote -### The UniRF Tool *requires* the creation of custom user map with `.txt` extension in the `unirf` folder on the sdcard. +### The SubGHz Remote Tool *requires* the creation of custom user map with `.txt` extension in the `subghz_remote` folder on the sdcard. #### If these files are not exist or not configured properly, **you will receive an error each time you try to select wrong file in the UniRF Tool**. @@ -20,7 +20,7 @@ Press Back to Exit -## Setting up the `unirf/example.txt` file: +## Setting up the `subghz_remote/example.txt` file: ``` UP: /ext/subghz/Up.sub @@ -59,7 +59,7 @@ OKLABEL: Garage CLOSE - Press a button to send the assigned capture file. - Press Back button to exit app. -* ##### Universal RF Map +* ##### SubGHz Remote Map - File path should not have any spaces or special characters (- and _ excluded). - Labels are limited to 16 characters. - Why? This is to prevent overlapping elements on screen. From ada343b7dff8255506fb3df7fd19d127cc643628 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Mon, 6 Mar 2023 12:30:20 +0300 Subject: [PATCH 3/5] Exclude 390Mhz from freq analyzer for external module --- .../main/subghz/helpers/subghz_frequency_analyzer_worker.c | 1 + 1 file changed, 1 insertion(+) diff --git a/applications/main/subghz/helpers/subghz_frequency_analyzer_worker.c b/applications/main/subghz/helpers/subghz_frequency_analyzer_worker.c index 250cc8aef..f632783f8 100644 --- a/applications/main/subghz/helpers/subghz_frequency_analyzer_worker.c +++ b/applications/main/subghz/helpers/subghz_frequency_analyzer_worker.c @@ -121,6 +121,7 @@ static int32_t subghz_frequency_analyzer_worker_thread(void* context) { if(furi_hal_subghz_is_frequency_valid(current_frequency) && (current_frequency != 467750000) && (current_frequency != 464000000) && !((furi_hal_subghz.radio_type == SubGhzRadioExternal) && + (current_frequency != 390000000) && (current_frequency >= 311900000 && current_frequency <= 312200000))) { furi_hal_spi_acquire(furi_hal_subghz.spi_bus_handle); cc1101_switch_to_idle(furi_hal_subghz.spi_bus_handle); From 27000f176314e05c2d78e69212d47b650b6a5bfe Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Mon, 6 Mar 2023 13:02:09 +0300 Subject: [PATCH 4/5] Update changelog --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc35e791a..1412d5da2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,14 @@ ### New changes * If you have copied apps into `apps` folder - remove `apps` folder on your microSD before installing this release to avoid issues! * SubGHz: Default custom buttons layout for non standard remotes (for example your remote has broken buttons and transmit only 0xC, now you can use other buttons) +* SubGHz: Fix issues with external module 5v power (now all works automatically, enabling +5v manually not required) (**Only for modules that work with 5v->3.3v converter!!!!!**) * SubGHz: Fix and update subghz protocols to use new error system * SubGHz: Fix default frequency being overwritten bug (Add manually fixes) -* SubGHz: Fix 464Mhz was showing up in Frequency analyzer all the time due to noise +* SubGHz: Fix 464Mhz and (390MHz for external module only) was showing up in Frequency analyzer all the time due to noise * iButton: Fix ibutton app - add manually - duplicate names +* Plugins: Properly rename unirf remix to subghz remote - And automatically migrate user files to new folder (unirf -> subghz_remote) +* Plugins: Fix unirf freeze (protocol deserialize status ok) (by @Willy-JL | PR #375) +* Plugins: Blackjack game: fix bug counting more than one ace (by @403-Fruit | PR #374) * Plugins: Update POCSAG Pager app to new error system * Plugins: Update iButton Fuzzer to new iButton system * OFW: Archive browser: update path on dir leave From 6511252140d2d0cf7e2aee266cd2eb2590e2fd02 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Mon, 6 Mar 2023 14:23:59 +0300 Subject: [PATCH 5/5] Fix external module power init --- applications/main/subghz_remote/subghz_remote_app.c | 3 ++- applications/plugins/playlist/playlist.c | 4 ++-- applications/plugins/pocsag_pager/pocsag_pager_app.c | 4 ++-- applications/plugins/protoview/app.c | 6 +++--- applications/plugins/spectrum_analyzer/spectrum_analyzer.c | 4 ++-- applications/plugins/subbrute | 2 +- applications/plugins/weather_station/weather_station_app.c | 4 ++-- firmware/targets/f7/furi_hal/furi_hal_subghz.c | 2 +- 8 files changed, 15 insertions(+), 14 deletions(-) diff --git a/applications/main/subghz_remote/subghz_remote_app.c b/applications/main/subghz_remote/subghz_remote_app.c index 0440699c2..b64c87002 100644 --- a/applications/main/subghz_remote/subghz_remote_app.c +++ b/applications/main/subghz_remote/subghz_remote_app.c @@ -736,10 +736,11 @@ void subghz_remote_subghz_alloc(SubGHzRemote* app) { SubGHzRemote* subghz_remote_alloc(void) { SubGHzRemote* app = malloc(sizeof(SubGHzRemote)); - furi_hal_power_suppress_charge_enter(); // Enable power for External CC1101 if it is connected furi_hal_subghz_enable_ext_power(); + furi_hal_power_suppress_charge_enter(); + app->model_mutex = furi_mutex_alloc(FuriMutexTypeNormal); app->input_queue = furi_message_queue_alloc(32, sizeof(InputEvent)); diff --git a/applications/plugins/playlist/playlist.c b/applications/plugins/playlist/playlist.c index a6aa09cba..c22255c08 100644 --- a/applications/plugins/playlist/playlist.c +++ b/applications/plugins/playlist/playlist.c @@ -672,11 +672,11 @@ int32_t playlist_app(void* p) { Playlist* app = playlist_alloc(meta); meta->view_port = app->view_port; - furi_hal_power_suppress_charge_enter(); - // Enable power for External CC1101 if it is connected furi_hal_subghz_enable_ext_power(); + furi_hal_power_suppress_charge_enter(); + // select playlist file { DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS); diff --git a/applications/plugins/pocsag_pager/pocsag_pager_app.c b/applications/plugins/pocsag_pager/pocsag_pager_app.c index 680edb2a5..123b3ee9d 100644 --- a/applications/plugins/pocsag_pager/pocsag_pager_app.c +++ b/applications/plugins/pocsag_pager/pocsag_pager_app.c @@ -122,11 +122,11 @@ POCSAGPagerApp* pocsag_pager_app_alloc() { app->txrx->worker, (SubGhzWorkerPairCallback)subghz_receiver_decode); subghz_worker_set_context(app->txrx->worker, app->txrx->receiver); - furi_hal_power_suppress_charge_enter(); - // Enable power for External CC1101 if it is connected furi_hal_subghz_enable_ext_power(); + furi_hal_power_suppress_charge_enter(); + scene_manager_next_scene(app->scene_manager, POCSAGPagerSceneStart); return app; diff --git a/applications/plugins/protoview/app.c b/applications/plugins/protoview/app.c index 7dc8a7b83..a4dab9f40 100644 --- a/applications/plugins/protoview/app.c +++ b/applications/plugins/protoview/app.c @@ -167,12 +167,12 @@ ProtoViewApp* protoview_app_alloc() { app->frequency = subghz_setting_get_default_frequency(app->setting); app->modulation = 0; /* Defaults to ProtoViewModulations[0]. */ - furi_hal_power_suppress_charge_enter(); - app->running = 1; - // Enable power for External CC1101 if it is connected furi_hal_subghz_enable_ext_power(); + furi_hal_power_suppress_charge_enter(); + app->running = 1; + return app; } diff --git a/applications/plugins/spectrum_analyzer/spectrum_analyzer.c b/applications/plugins/spectrum_analyzer/spectrum_analyzer.c index 10471e473..99c12adf7 100644 --- a/applications/plugins/spectrum_analyzer/spectrum_analyzer.c +++ b/applications/plugins/spectrum_analyzer/spectrum_analyzer.c @@ -403,11 +403,11 @@ int32_t spectrum_analyzer_app(void* p) { SpectrumAnalyzer* spectrum_analyzer = spectrum_analyzer_alloc(); InputEvent input; - furi_hal_power_suppress_charge_enter(); - // Enable power for External CC1101 if it is connected furi_hal_subghz_enable_ext_power(); + furi_hal_power_suppress_charge_enter(); + FURI_LOG_D("Spectrum", "Main Loop - Starting worker"); furi_delay_ms(50); diff --git a/applications/plugins/subbrute b/applications/plugins/subbrute index 552bd12d0..ed94bc878 160000 --- a/applications/plugins/subbrute +++ b/applications/plugins/subbrute @@ -1 +1 @@ -Subproject commit 552bd12d0f710501c31f7d44b4755d7fa89de303 +Subproject commit ed94bc87868b80bf41dad754f3747a9f40551995 diff --git a/applications/plugins/weather_station/weather_station_app.c b/applications/plugins/weather_station/weather_station_app.c index 0d83095b5..ffa569f20 100644 --- a/applications/plugins/weather_station/weather_station_app.c +++ b/applications/plugins/weather_station/weather_station_app.c @@ -105,11 +105,11 @@ WeatherStationApp* weather_station_app_alloc() { app->txrx->worker, (SubGhzWorkerPairCallback)subghz_receiver_decode); subghz_worker_set_context(app->txrx->worker, app->txrx->receiver); - furi_hal_power_suppress_charge_enter(); - // Enable power for External CC1101 if it is connected furi_hal_subghz_enable_ext_power(); + furi_hal_power_suppress_charge_enter(); + scene_manager_next_scene(app->scene_manager, WeatherStationSceneStart); return app; diff --git a/firmware/targets/f7/furi_hal/furi_hal_subghz.c b/firmware/targets/f7/furi_hal/furi_hal_subghz.c index e4a118652..b8834bef3 100644 --- a/firmware/targets/f7/furi_hal/furi_hal_subghz.c +++ b/firmware/targets/f7/furi_hal/furi_hal_subghz.c @@ -81,7 +81,7 @@ void furi_hal_subghz_init(void) { } void furi_hal_subghz_enable_ext_power(void) { - if(ext_power_is_enabled_already) return; + if(ext_power_is_enabled_already && furi_hal_power_is_otg_enabled()) return; ext_power_is_enabled_already = true; last_OTG_state = furi_hal_power_is_otg_enabled(); if(furi_hal_subghz.radio_type != SubGhzRadioInternal && !furi_hal_power_is_otg_enabled()) {