From fb7cc1dd60155e0829757f997526c113594648fe Mon Sep 17 00:00:00 2001 From: Skorpionm <85568270+Skorpionm@users.noreply.github.com> Date: Sat, 25 Dec 2021 17:19:30 +0400 Subject: [PATCH] [FL-2162] SubGhz: Cli refactoring (#926) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [FL-2162] SubGhz: Cli refactoring * SubGhz: power reduction for Australia * SubGhz: add frequencies for testing the Japanese region * Desktop: fix fav app Co-authored-by: Anna Prosvetova Co-authored-by: あく --- .../desktop/scenes/desktop_scene_main.c | 2 +- applications/subghz/helpers/subghz_testing.c | 5 +- applications/subghz/subghz_cli.c | 78 ++++++++++++------- .../targets/f6/furi-hal/furi-hal-subghz.c | 2 +- .../targets/f7/furi-hal/furi-hal-subghz.c | 2 +- 5 files changed, 59 insertions(+), 30 deletions(-) diff --git a/applications/desktop/scenes/desktop_scene_main.c b/applications/desktop/scenes/desktop_scene_main.c index 89158d6d..90f211b7 100644 --- a/applications/desktop/scenes/desktop_scene_main.c +++ b/applications/desktop/scenes/desktop_scene_main.c @@ -91,7 +91,7 @@ bool desktop_scene_main_on_event(void* context, SceneManagerEvent event) { case DesktopMainEventOpenFavorite: LOAD_DESKTOP_SETTINGS(&desktop->settings); - if(desktop->settings.favorite) { + if(desktop->settings.favorite < FLIPPER_APPS_COUNT) { desktop_switch_to_app(desktop, &FLIPPER_APPS[desktop->settings.favorite]); } else { FURI_LOG_E("DesktopSrv", "Can't find favorite application"); diff --git a/applications/subghz/helpers/subghz_testing.c b/applications/subghz/helpers/subghz_testing.c index b3dc610f..4c83b2a9 100644 --- a/applications/subghz/helpers/subghz_testing.c +++ b/applications/subghz/helpers/subghz_testing.c @@ -4,8 +4,11 @@ const uint32_t subghz_frequencies_testing[] = { /* 300 - 348 */ 300000000, 304500000, + 312025000, + 313250000, 313250000, 315000000, + 315225000, 321950000, 348000000, /* 387 - 464 */ @@ -31,4 +34,4 @@ const uint32_t subghz_frequencies_testing[] = { const uint32_t subghz_frequencies_count_testing = sizeof(subghz_frequencies_testing) / sizeof(uint32_t); -const uint32_t subghz_frequencies_433_92_testing = 9; \ No newline at end of file +const uint32_t subghz_frequencies_433_92_testing = 12; \ No newline at end of file diff --git a/applications/subghz/subghz_cli.c b/applications/subghz/subghz_cli.c index b2b4523d..a52defa3 100644 --- a/applications/subghz/subghz_cli.c +++ b/applications/subghz/subghz_cli.c @@ -24,7 +24,7 @@ void subghz_cli_command_tx_carrier(Cli* cli, string_t args, void* context) { int ret = sscanf(string_get_cstr(args), "%lu", &frequency); if(ret != 1) { printf("sscanf returned %d, frequency: %lu\r\n", ret, frequency); - cli_print_usage("subghz_tx_carrier", "", string_get_cstr(args)); + cli_print_usage("subghz tx_carrier", "", string_get_cstr(args)); return; } if(!furi_hal_subghz_is_frequency_valid(frequency)) { @@ -67,7 +67,7 @@ void subghz_cli_command_rx_carrier(Cli* cli, string_t args, void* context) { int ret = sscanf(string_get_cstr(args), "%lu", &frequency); if(ret != 1) { printf("sscanf returned %d, frequency: %lu\r\n", ret, frequency); - cli_print_usage("subghz_tx_carrier", "", string_get_cstr(args)); + cli_print_usage("subghz rx_carrier", "", string_get_cstr(args)); return; } if(!furi_hal_subghz_is_frequency_valid(frequency)) { @@ -115,8 +115,8 @@ void subghz_cli_command_tx(Cli* cli, string_t args, void* context) { frequency, repeat); cli_print_usage( - "subghz_rx", - "<3 Byte Key in hex> ", + "subghz tx", + "<3 Byte Key: in hex> ", string_get_cstr(args)); return; } @@ -198,7 +198,7 @@ void subghz_cli_command_rx(Cli* cli, string_t args, void* context) { int ret = sscanf(string_get_cstr(args), "%lu", &frequency); if(ret != 1) { printf("sscanf returned %d, frequency: %lu\r\n", ret, frequency); - cli_print_usage("subghz_rx", "", string_get_cstr(args)); + cli_print_usage("subghz rx", "", string_get_cstr(args)); return; } if(!furi_hal_subghz_is_frequency_valid(frequency)) { @@ -268,11 +268,22 @@ static void subghz_cli_command_print_usage() { printf("Usage:\r\n"); printf("subghz \r\n"); printf("Cmd list:\r\n"); + + printf("\tchat \t - Chat with other Flippers\r\n"); printf( - "\tencrypt_keeloq \t - Encrypt keeloq manufacture keys\r\n"); - printf( - "\tencrypt_raw \t - Encrypt RAW data\r\n"); - printf("\tchat \t - Chat with other Flippers\r\n"); + "\ttx <3 byte Key: in hex> \t - Transmitting key\r\n"); + printf("\trx \t - Reception key\r\n"); + + if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) { + printf("\r\n"); + printf(" debug cmd:\r\n"); + printf("\ttx_carrier \t - Transmit carrier\r\n"); + printf("\trx_carrier \t - Receiv carrier\r\n"); + printf( + "\tencrypt_keeloq \t - Encrypt keeloq manufacture keys\r\n"); + printf( + "\tencrypt_raw \t - Encrypt RAW data\r\n"); + } } static void subghz_cli_command_encrypt_keeloq(Cli* cli, string_t args) { @@ -360,7 +371,7 @@ static void subghz_cli_command_chat(Cli* cli, string_t args) { int ret = sscanf(string_get_cstr(args), "%lu", &frequency); if(ret != 1) { printf("sscanf returned %d, frequency: %lu\r\n", ret, frequency); - cli_print_usage("subghz_txrx", "", string_get_cstr(args)); + cli_print_usage("subghz chat", "", string_get_cstr(args)); return; } if(!furi_hal_subghz_is_frequency_valid(frequency)) { @@ -540,21 +551,42 @@ void subghz_cli_command(Cli* cli, string_t args, void* context) { break; } - if(string_cmp_str(cmd, "encrypt_keeloq") == 0) { - subghz_cli_command_encrypt_keeloq(cli, args); - break; - } - - if(string_cmp_str(cmd, "encrypt_raw") == 0) { - subghz_cli_command_encrypt_raw(cli, args); - break; - } - if(string_cmp_str(cmd, "chat") == 0) { subghz_cli_command_chat(cli, args); break; } + if(string_cmp_str(cmd, "tx") == 0) { + subghz_cli_command_tx(cli, args, context); + break; + } + + if(string_cmp_str(cmd, "rx") == 0) { + subghz_cli_command_rx(cli, args, context); + break; + } + if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) { + if(string_cmp_str(cmd, "encrypt_keeloq") == 0) { + subghz_cli_command_encrypt_keeloq(cli, args); + break; + } + + if(string_cmp_str(cmd, "encrypt_raw") == 0) { + subghz_cli_command_encrypt_raw(cli, args); + break; + } + + if(string_cmp_str(cmd, "tx_carrier") == 0) { + subghz_cli_command_tx_carrier(cli, args, context); + break; + } + + if(string_cmp_str(cmd, "rx_carrier") == 0) { + subghz_cli_command_rx_carrier(cli, args, context); + break; + } + } + subghz_cli_command_print_usage(); } while(false); @@ -565,12 +597,6 @@ void subghz_on_system_start() { #ifdef SRV_CLI Cli* cli = furi_record_open("cli"); - cli_add_command( - cli, "subghz_tx_carrier", CliCommandFlagDefault, subghz_cli_command_tx_carrier, NULL); - cli_add_command( - cli, "subghz_rx_carrier", CliCommandFlagDefault, subghz_cli_command_rx_carrier, NULL); - cli_add_command(cli, "subghz_tx", CliCommandFlagDefault, subghz_cli_command_tx, NULL); - cli_add_command(cli, "subghz_rx", CliCommandFlagDefault, subghz_cli_command_rx, NULL); cli_add_command(cli, "subghz", CliCommandFlagDefault, subghz_cli_command, NULL); furi_record_close("cli"); diff --git a/firmware/targets/f6/furi-hal/furi-hal-subghz.c b/firmware/targets/f6/furi-hal/furi-hal-subghz.c index b54b4845..b25a3052 100644 --- a/firmware/targets/f6/furi-hal/furi-hal-subghz.c +++ b/firmware/targets/f6/furi-hal/furi-hal-subghz.c @@ -285,7 +285,7 @@ static const uint8_t furi_hal_subghz_preset_ook_async_patable[8] = { 0x00}; static const uint8_t furi_hal_subghz_preset_ook_async_patable_au[8] = { 0x00, - 0x86, // 12dBm 0xC0, 10dBm 0xC5, 7dBm 0xCD, 5dBm 0x86, 0dBm 0x50, -6dBm 0x37, -10dBm 0x26, -15dBm 0x1D, -20dBm 0x17, -30dBm 0x03 + 0x37, // 12dBm 0xC0, 10dBm 0xC5, 7dBm 0xCD, 5dBm 0x86, 0dBm 0x50, -6dBm 0x37, -10dBm 0x26, -15dBm 0x1D, -20dBm 0x17, -30dBm 0x03 0x00, 0x00, 0x00, diff --git a/firmware/targets/f7/furi-hal/furi-hal-subghz.c b/firmware/targets/f7/furi-hal/furi-hal-subghz.c index b54b4845..b25a3052 100644 --- a/firmware/targets/f7/furi-hal/furi-hal-subghz.c +++ b/firmware/targets/f7/furi-hal/furi-hal-subghz.c @@ -285,7 +285,7 @@ static const uint8_t furi_hal_subghz_preset_ook_async_patable[8] = { 0x00}; static const uint8_t furi_hal_subghz_preset_ook_async_patable_au[8] = { 0x00, - 0x86, // 12dBm 0xC0, 10dBm 0xC5, 7dBm 0xCD, 5dBm 0x86, 0dBm 0x50, -6dBm 0x37, -10dBm 0x26, -15dBm 0x1D, -20dBm 0x17, -30dBm 0x03 + 0x37, // 12dBm 0xC0, 10dBm 0xC5, 7dBm 0xCD, 5dBm 0x86, 0dBm 0x50, -6dBm 0x37, -10dBm 0x26, -15dBm 0x1D, -20dBm 0x17, -30dBm 0x03 0x00, 0x00, 0x00,