diff --git a/applications/plugins/subbrute/subbrute_protocols.c b/applications/plugins/subbrute/subbrute_protocols.c index 461241310..ab1c22d25 100644 --- a/applications/plugins/subbrute/subbrute_protocols.c +++ b/applications/plugins/subbrute/subbrute_protocols.c @@ -69,6 +69,39 @@ const SubBruteProtocol subbrute_protocol_nice_12bit_868 = { .preset = FuriHalSubGhzPresetOok650Async, .file = NICEFileProtocol}; +/** + * Ansonic 12bit 433.075MHz + */ +const SubBruteProtocol subbrute_protocol_ansonic_12bit_433075 = { + .frequency = 433075000, + .bits = 12, + .te = 0, + .repeat = 3, + .preset = FuriHalSubGhzPreset2FSKDev238Async, + .file = AnsonicFileProtocol}; + +/** + * Ansonic 12bit 433.92MHz + */ +const SubBruteProtocol subbrute_protocol_ansonic_12bit_433 = { + .frequency = 433920000, + .bits = 12, + .te = 0, + .repeat = 3, + .preset = FuriHalSubGhzPreset2FSKDev238Async, + .file = AnsonicFileProtocol}; + +/** + * Ansonic 12bit 434.075MHz + */ +const SubBruteProtocol subbrute_protocol_ansonic_12bit_434 = { + .frequency = 434075000, + .bits = 12, + .te = 0, + .repeat = 3, + .preset = FuriHalSubGhzPreset2FSKDev238Async, + .file = AnsonicFileProtocol}; + /** * Chamberlain 9bit 300MHz */ @@ -214,6 +247,9 @@ static const char* subbrute_protocol_names[] = { [SubBruteAttackCAME12bit868] = "CAME 12bit 868MHz", [SubBruteAttackNICE12bit433] = "NICE 12bit 433MHz", [SubBruteAttackNICE12bit868] = "NICE 12bit 868MHz", + [SubBruteAttackAnsonic12bit433075] = "Ansonic 12b 433.07MHz", + [SubBruteAttackAnsonic12bit433] = "Ansonic 12bit 433.92MHz", + [SubBruteAttackAnsonic12bit434] = "Ansonic 12bit 434.07MHz", [SubBruteAttackChamberlain9bit300] = "Chamberlain 9bit 300MHz", [SubBruteAttackChamberlain9bit315] = "Chamberlain 9bit 315MHz", [SubBruteAttackChamberlain9bit390] = "Chamberlain 9bit 390MHz", @@ -247,6 +283,9 @@ const SubBruteProtocol* subbrute_protocol_registry[] = { [SubBruteAttackCAME12bit868] = &subbrute_protocol_came_12bit_868, [SubBruteAttackNICE12bit433] = &subbrute_protocol_nice_12bit_433, [SubBruteAttackNICE12bit868] = &subbrute_protocol_nice_12bit_868, + [SubBruteAttackAnsonic12bit433075] = &subbrute_protocol_ansonic_12bit_433075, + [SubBruteAttackAnsonic12bit433] = &subbrute_protocol_ansonic_12bit_433, + [SubBruteAttackAnsonic12bit434] = &subbrute_protocol_ansonic_12bit_434, [SubBruteAttackChamberlain9bit300] = &subbrute_protocol_chamberlain_9bit_300, [SubBruteAttackChamberlain9bit315] = &subbrute_protocol_chamberlain_9bit_315, [SubBruteAttackChamberlain9bit390] = &subbrute_protocol_chamberlain_9bit_390, @@ -274,6 +313,7 @@ static const char* subbrute_protocol_file_types[] = { [GateTXFileProtocol] = "GateTX", [MagellanFileProtocol] = "Magellan", [IntertechnoV3FileProtocol] = "Intertechno_V3", + [AnsonicFileProtocol] = "Ansonic", [UnknownFileProtocol] = "Unknown"}; /** diff --git a/applications/plugins/subbrute/subbrute_protocols.h b/applications/plugins/subbrute/subbrute_protocols.h index eeb3f3426..3d25310de 100644 --- a/applications/plugins/subbrute/subbrute_protocols.h +++ b/applications/plugins/subbrute/subbrute_protocols.h @@ -18,6 +18,7 @@ typedef enum { GateTXFileProtocol, MagellanFileProtocol, IntertechnoV3FileProtocol, + AnsonicFileProtocol, UnknownFileProtocol, TotalFileProtocol, } SubBruteFileProtocol; @@ -29,6 +30,9 @@ typedef enum { SubBruteAttackCAME12bit868, SubBruteAttackNICE12bit433, SubBruteAttackNICE12bit868, + SubBruteAttackAnsonic12bit433075, + SubBruteAttackAnsonic12bit433, + SubBruteAttackAnsonic12bit434, SubBruteAttackChamberlain9bit300, SubBruteAttackChamberlain9bit315, SubBruteAttackChamberlain9bit390, diff --git a/applications/plugins/totp/cli/commands/notification/notification.c b/applications/plugins/totp/cli/commands/notification/notification.c new file mode 100644 index 000000000..91dd44d4f --- /dev/null +++ b/applications/plugins/totp/cli/commands/notification/notification.c @@ -0,0 +1,106 @@ +#include "notification.h" +#include +#include "../../../services/config/config.h" +#include "../../../ui/scene_director.h" +#include "../../cli_helpers.h" + +#define TOTP_CLI_COMMAND_NOTIFICATION_ARG_METHOD "method" +#define TOTP_CLI_COMMAND_NOTIFICATION_METHOD_NONE "none" +#define TOTP_CLI_COMMAND_NOTIFICATION_METHOD_SOUND "sound" +#define TOTP_CLI_COMMAND_NOTIFICATION_METHOD_VIBRO "vibro" + +void totp_cli_command_notification_docopt_commands() { + TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_NOTIFICATION + " Get or set notification method\r\n"); +} + +void totp_cli_command_notification_docopt_usage() { + TOTP_CLI_PRINTF( + " " TOTP_CLI_COMMAND_NAME " " TOTP_CLI_COMMAND_NOTIFICATION " " DOCOPT_OPTIONAL( + DOCOPT_MULTIPLE(DOCOPT_ARGUMENT(TOTP_CLI_COMMAND_NOTIFICATION_ARG_METHOD))) "\r\n"); +} + +void totp_cli_command_notification_docopt_arguments() { + TOTP_CLI_PRINTF( + " " TOTP_CLI_COMMAND_NOTIFICATION_ARG_METHOD + " Notification method to be set. Must be one of [" TOTP_CLI_COMMAND_NOTIFICATION_METHOD_NONE + ", " TOTP_CLI_COMMAND_NOTIFICATION_METHOD_SOUND + ", " TOTP_CLI_COMMAND_NOTIFICATION_METHOD_VIBRO "]\r\n"); +} + +static void totp_cli_command_notification_print_method(NotificationMethod method) { + bool has_previous_method = false; + if(method & NotificationMethodSound) { + TOTP_CLI_PRINTF("\"" TOTP_CLI_COMMAND_NOTIFICATION_METHOD_SOUND "\""); + has_previous_method = true; + } + if(method & NotificationMethodVibro) { + if(has_previous_method) { + TOTP_CLI_PRINTF(" and "); + } + + TOTP_CLI_PRINTF("\"" TOTP_CLI_COMMAND_NOTIFICATION_METHOD_VIBRO "\""); + } + if(method == NotificationMethodNone) { + TOTP_CLI_PRINTF("\"" TOTP_CLI_COMMAND_NOTIFICATION_METHOD_NONE "\""); + } +} + +void totp_cli_command_notification_handle(PluginState* plugin_state, FuriString* args, Cli* cli) { + if(!totp_cli_ensure_authenticated(plugin_state, cli)) { + return; + } + + FuriString* temp_str = furi_string_alloc(); + bool new_method_provided = false; + NotificationMethod new_method = NotificationMethodNone; + bool args_valid = true; + while(args_read_string_and_trim(args, temp_str)) { + if(furi_string_cmpi_str(temp_str, TOTP_CLI_COMMAND_NOTIFICATION_METHOD_NONE) == 0) { + new_method_provided = true; + new_method = NotificationMethodNone; + } else if(furi_string_cmpi_str(temp_str, TOTP_CLI_COMMAND_NOTIFICATION_METHOD_SOUND) == 0) { + new_method_provided = true; + new_method |= NotificationMethodSound; + } else if(furi_string_cmpi_str(temp_str, TOTP_CLI_COMMAND_NOTIFICATION_METHOD_VIBRO) == 0) { + new_method_provided = true; + new_method |= NotificationMethodVibro; + } else { + args_valid = false; + break; + } + } + + do { + if(!args_valid) { + TOTP_CLI_PRINT_INVALID_ARGUMENTS(); + break; + } + + if(new_method_provided) { + Scene previous_scene = TotpSceneNone; + if(plugin_state->current_scene == TotpSceneGenerateToken || + plugin_state->current_scene == TotpSceneAppSettings) { + previous_scene = plugin_state->current_scene; + totp_scene_director_activate_scene(plugin_state, TotpSceneNone, NULL); + } + + plugin_state->notification_method = new_method; + totp_config_file_update_notification_method(new_method); + + if(previous_scene != TotpSceneNone) { + totp_scene_director_activate_scene(plugin_state, previous_scene, NULL); + } + + TOTP_CLI_PRINTF("Notification method is set to "); + totp_cli_command_notification_print_method(new_method); + cli_nl(); + } else { + TOTP_CLI_PRINTF("Current notification method is "); + totp_cli_command_notification_print_method(plugin_state->notification_method); + cli_nl(); + } + } while(false); + + furi_string_free(temp_str); +} \ No newline at end of file diff --git a/applications/plugins/totp/cli/commands/notification/notification.h b/applications/plugins/totp/cli/commands/notification/notification.h new file mode 100644 index 000000000..c349f9620 --- /dev/null +++ b/applications/plugins/totp/cli/commands/notification/notification.h @@ -0,0 +1,11 @@ +#pragma once + +#include +#include "../../../types/plugin_state.h" + +#define TOTP_CLI_COMMAND_NOTIFICATION "notify" + +void totp_cli_command_notification_handle(PluginState* plugin_state, FuriString* args, Cli* cli); +void totp_cli_command_notification_docopt_commands(); +void totp_cli_command_notification_docopt_usage(); +void totp_cli_command_notification_docopt_arguments(); \ No newline at end of file diff --git a/applications/plugins/totp/images/totp_arrow_bottom_10x5.png b/applications/plugins/totp/images/totp_arrow_bottom_10x5.png new file mode 100644 index 000000000..54e22f5ef Binary files /dev/null and b/applications/plugins/totp/images/totp_arrow_bottom_10x5.png differ diff --git a/applications/plugins/totp/services/cli/commands/move/move.c b/applications/plugins/totp/services/cli/commands/move/move.c deleted file mode 100644 index 9ed0a604a..000000000 --- a/applications/plugins/totp/services/cli/commands/move/move.c +++ /dev/null @@ -1,164 +0,0 @@ -#include "move.h" - -#include -#include -#include "../../../list/list.h" -#include "../../../../types/token_info.h" -#include "../../../config/config.h" -#include "../../cli_helpers.h" -#include "../../../../scenes/scene_director.h" - -#define TOTP_CLI_COMMAND_MOVE_ARG_INDEX "index" - -#define TOTP_CLI_COMMAND_MOVE_ARG_NEW_NAME "name" -#define TOTP_CLI_COMMAND_MOVE_ARG_NEW_NAME_PREFIX "-n" - -#define TOTP_CLI_COMMAND_MOVE_ARG_NEW_INDEX "index" -#define TOTP_CLI_COMMAND_MOVE_ARG_NEW_INDEX_PREFIX "-i" - -void totp_cli_command_move_docopt_commands() { - TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_MOVE ", " TOTP_CLI_COMMAND_MOVE_ALT - " Move\\rename token\r\n"); -} - -void totp_cli_command_move_docopt_usage() { - TOTP_CLI_PRINTF( - " " TOTP_CLI_COMMAND_NAME - " " DOCOPT_REQUIRED(TOTP_CLI_COMMAND_MOVE " | " TOTP_CLI_COMMAND_MOVE_ALT) " " DOCOPT_ARGUMENT(TOTP_CLI_COMMAND_MOVE_ARG_INDEX) " " DOCOPT_OPTIONAL( - DOCOPT_OPTION( - TOTP_CLI_COMMAND_MOVE_ARG_NEW_NAME_PREFIX, - DOCOPT_ARGUMENT( - TOTP_CLI_COMMAND_MOVE_ARG_NEW_NAME))) " " DOCOPT_OPTIONAL(DOCOPT_OPTION(TOTP_CLI_COMMAND_MOVE_ARG_NEW_INDEX_PREFIX, DOCOPT_ARGUMENT(TOTP_CLI_COMMAND_MOVE_ARG_NEW_INDEX))) "\r\n"); -} - -void totp_cli_command_move_docopt_options() { - TOTP_CLI_PRINTF(" " DOCOPT_OPTION( - TOTP_CLI_COMMAND_MOVE_ARG_NEW_NAME_PREFIX, - DOCOPT_ARGUMENT(TOTP_CLI_COMMAND_MOVE_ARG_NEW_NAME)) " New token name.\r\n"); - TOTP_CLI_PRINTF(" " DOCOPT_OPTION( - TOTP_CLI_COMMAND_MOVE_ARG_NEW_INDEX_PREFIX, - DOCOPT_ARGUMENT(TOTP_CLI_COMMAND_MOVE_ARG_NEW_INDEX)) " New token index.\r\n"); -} - -void totp_cli_command_move_handle(PluginState* plugin_state, FuriString* args, Cli* cli) { - int token_index; - if(!args_read_int_and_trim(args, &token_index)) { - TOTP_CLI_PRINT_INVALID_ARGUMENTS(); - return; - } - - if(!totp_cli_ensure_authenticated(plugin_state, cli)) { - return; - } - - if(token_index < 1 || token_index > plugin_state->tokens_count) { - TOTP_CLI_PRINT_INVALID_ARGUMENTS(); - return; - } - - FuriString* temp_str = furi_string_alloc(); - - char* new_token_name = NULL; - int new_token_index = 0; - - while(args_read_string_and_trim(args, temp_str)) { - bool parsed = false; - if(furi_string_cmpi_str(temp_str, TOTP_CLI_COMMAND_MOVE_ARG_NEW_NAME_PREFIX) == 0) { - if(!args_read_string_and_trim(args, temp_str)) { - TOTP_CLI_PRINTF( - "Missed value for argument \"" TOTP_CLI_COMMAND_MOVE_ARG_NEW_NAME_PREFIX - "\"\r\n"); - } else { - if(new_token_name != NULL) { - free(new_token_name); - } - - new_token_name = malloc(furi_string_size(temp_str) + 1); - if(new_token_name == NULL) { - furi_string_free(temp_str); - return; - } - - strlcpy( - new_token_name, - furi_string_get_cstr(temp_str), - furi_string_size(temp_str) + 1); - parsed = true; - } - } else if(furi_string_cmpi_str(temp_str, TOTP_CLI_COMMAND_MOVE_ARG_NEW_INDEX_PREFIX) == 0) { - if(!args_read_int_and_trim(args, &new_token_index)) { - TOTP_CLI_PRINTF( - "Missed value for argument \"" TOTP_CLI_COMMAND_MOVE_ARG_NEW_INDEX_PREFIX - "\"\r\n"); - } else if(new_token_index < 1 || new_token_index > plugin_state->tokens_count) { - TOTP_CLI_PRINTF( - "\"%" PRId16 - "\" is incorrect value for argument \"" TOTP_CLI_COMMAND_MOVE_ARG_NEW_INDEX_PREFIX - "\"\r\n", - new_token_index); - } else { - parsed = true; - } - } else { - TOTP_CLI_PRINTF("Unknown argument \"%s\"\r\n", furi_string_get_cstr(temp_str)); - } - - if(!parsed) { - TOTP_CLI_PRINT_INVALID_ARGUMENTS(); - furi_string_free(temp_str); - if(new_token_name != NULL) { - free(new_token_name); - } - return; - } - } - - if(!totp_cli_ensure_authenticated(plugin_state, cli)) { - furi_string_free(temp_str); - if(new_token_name != NULL) { - free(new_token_name); - } - return; - } - - bool activate_generate_token_scene = false; - if(plugin_state->current_scene != TotpSceneAuthentication) { - totp_scene_director_activate_scene(plugin_state, TotpSceneNone, NULL); - activate_generate_token_scene = true; - } - - bool token_updated = false; - TokenInfo* token_info = NULL; - if(new_token_index > 0) { - plugin_state->tokens_list = - list_remove_at(plugin_state->tokens_list, token_index - 1, (void**)&token_info); - furi_check(token_info != NULL); - plugin_state->tokens_list = - list_insert_at(plugin_state->tokens_list, new_token_index - 1, token_info); - token_updated = true; - } else { - token_info = list_element_at(plugin_state->tokens_list, token_index - 1)->data; - } - - if(new_token_name != NULL) { - free(token_info->name); - token_info->name = new_token_name; - token_updated = true; - } - - if(token_updated) { - totp_full_save_config_file(plugin_state); - } - - if(activate_generate_token_scene) { - totp_scene_director_activate_scene(plugin_state, TotpSceneGenerateToken, NULL); - } - - if(token_updated) { - TOTP_CLI_PRINTF("Token \"%s\" has been successfully updated\r\n", token_info->name); - } else { - TOTP_CLI_PRINT_INVALID_ARGUMENTS(); - } - - furi_string_free(temp_str); -} \ No newline at end of file diff --git a/applications/plugins/totp/services/cli/commands/move/move.h b/applications/plugins/totp/services/cli/commands/move/move.h deleted file mode 100644 index b06a71679..000000000 --- a/applications/plugins/totp/services/cli/commands/move/move.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#include -#include "../../../../types/plugin_state.h" - -#define TOTP_CLI_COMMAND_MOVE "move" -#define TOTP_CLI_COMMAND_MOVE_ALT "mv" - -void totp_cli_command_move_handle(PluginState* plugin_state, FuriString* args, Cli* cli); -void totp_cli_command_move_docopt_commands(); -void totp_cli_command_move_docopt_usage(); -void totp_cli_command_move_docopt_options(); \ No newline at end of file diff --git a/applications/plugins/totp/services/convert/convert.h b/applications/plugins/totp/services/convert/convert.h new file mode 100644 index 000000000..740d47ace --- /dev/null +++ b/applications/plugins/totp/services/convert/convert.h @@ -0,0 +1,4 @@ +#pragma once + +#define CONVERT_DIGIT_TO_CHAR(digit) ((digit) + '0') +#define CONVERT_CHAR_TO_DIGIT(ch) ((ch) - '0') diff --git a/applications/plugins/totp/types/notification_method.h b/applications/plugins/totp/types/notification_method.h new file mode 100644 index 000000000..f86613352 --- /dev/null +++ b/applications/plugins/totp/types/notification_method.h @@ -0,0 +1,9 @@ +#pragma once + +typedef uint8_t NotificationMethod; + +enum NotificationMethods { + NotificationMethodNone = 0b00, + NotificationMethodSound = 0b01, + NotificationMethodVibro = 0b10, +}; diff --git a/applications/services/cli/cli_commands.c b/applications/services/cli/cli_commands.c index b445ec06f..d6d9da54c 100644 --- a/applications/services/cli/cli_commands.c +++ b/applications/services/cli/cli_commands.c @@ -143,7 +143,7 @@ void cli_command_src(Cli* cli, FuriString* args, void* context) { UNUSED(args); UNUSED(context); - printf("https://github.com/DarkFlippers/unleashed-firmware"); + printf("https://github.com/RogueMaster/flipperzero-firmware-wPlugins"); } #define CLI_COMMAND_LOG_RING_SIZE 2048