subbrute_settings.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #pragma once
  2. #include <furi_hal.h>
  3. #include <stdint.h>
  4. #include <stdbool.h>
  5. #include <storage/storage.h>
  6. #include "subbrute_protocols.h"
  7. /**
  8. * @struct SubBruteSettings
  9. * @brief Structure to store settings for a sub-brute attack.
  10. *
  11. * This structure stores the settings for a sub-brute attack, such as an array of repeat values and
  12. * the last index used.
  13. */
  14. typedef struct {
  15. uint8_t repeat_values[SubBruteAttackTotalCount]; /**< Array of repeat values */
  16. uint32_t last_index; /**< Last index used */
  17. } SubBruteSettings;
  18. /**
  19. * @brief Allocates memory for a SubBruteSettings structure.
  20. *
  21. * @return A pointer to a newly allocated SubBruteSettings structure.
  22. * @note The returned structure should be freed using subbrute_settings_free() function.
  23. */
  24. SubBruteSettings* subbrute_settings_alloc(void);
  25. /**
  26. * @brief Frees the memory allocated for the SubBruteSettings instance and all its members.
  27. *
  28. * This function should be used to release the memory allocated for an instance of the SubBruteSettings structure.
  29. * It ensures that all members of the structure are properly freed.
  30. *
  31. * @param instance The SubBruteSettings instance to be freed.
  32. */
  33. void subbrute_settings_free(SubBruteSettings* instance);
  34. /**
  35. * @brief Loads the settings for the SubBrute instance.
  36. *
  37. * This function loads the settings for the SubBrute instance and populates the SubBruteSettings structure
  38. * pointed to by the given instance.
  39. *
  40. * @param instance A pointer to the SubBruteSettings structure to populate with the loaded settings.
  41. */
  42. void subbrute_settings_load(SubBruteSettings* instance);
  43. /**
  44. * @brief Saves the settings of the SubBrute instance.
  45. *
  46. * This function is used to save the settings of the SubBrute instance to a storage.
  47. *
  48. * @param instance A pointer to the SubBruteSettings instance.
  49. *
  50. * @note The settings will be saved to a storage. The exact storage and format
  51. * will depend on the implementation. It is the responsibility of the caller
  52. * to ensure that the instance is valid and has been initialized properly.
  53. * The caller should handle any errors that may occur during the saving process.
  54. */
  55. bool subbrute_settings_save(SubBruteSettings* instance);
  56. /**
  57. * @brief Sets the value for a specific attack in the SubBruteSettings instance.
  58. *
  59. * This function allows you to set the value for a specific attack in the SubBruteSettings instance.
  60. *
  61. * @param instance A pointer to the SubBruteSettings instance.
  62. * @param index The index of the attack for which the value needs to be set.
  63. * @param value The value to be set for the specified attack.
  64. */
  65. void subbrute_settings_set_value(SubBruteSettings* instance, SubBruteAttacks index, uint8_t value);
  66. /**
  67. * @brief Get the value of a specific attack setting in the SubBruteSettings instance.
  68. *
  69. * @param instance The pointer to the SubBruteSettings instance.
  70. * @param index The index of the attack setting to get the value of.
  71. *
  72. * @return The value of the specified attack setting.
  73. *
  74. * @note The index parameter should be one of the SubBruteAttacks enum values.
  75. */
  76. uint8_t subbrute_settings_get_value(SubBruteSettings* instance, SubBruteAttacks index);
  77. /**
  78. * @brief Sets the repeated values for the SubBruteSettings instance.
  79. *
  80. * This function sets the repeated values for the SubBruteSettings instance.
  81. * The repeated values are used for the sub-brute operation.
  82. *
  83. * @param instance Pointer to the SubBruteSettings instance.
  84. * @param repeated_values Pointer to an array of repeated values.
  85. */
  86. void subbrute_settings_set_repeats(SubBruteSettings* instance, const uint8_t* repeated_values);
  87. /**
  88. * @brief Gets the current number of repeats from the SubBruteSettings instance.
  89. *
  90. * This function retrieves the current number of repeats stored in the given SubBruteSettings instance.
  91. *
  92. * @param instance Pointer to the SubBruteSettings instance.
  93. * @return The current number of repeats as a uint8_t.
  94. */
  95. uint8_t subbrute_settings_get_current_repeats(SubBruteSettings* instance);