subbrute_worker_private.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #pragma once
  2. #include "subbrute_worker.h"
  3. #include <lib/subghz/protocols/base.h>
  4. #include <lib/subghz/transmitter.h>
  5. #include <lib/subghz/receiver.h>
  6. #include <lib/subghz/environment.h>
  7. /**
  8. * @class SubBruteWorker
  9. * @brief Class representing a SubBruteWorker object.
  10. *
  11. * The SubBruteWorker class is responsible for performing sub-brute forcing tasks.
  12. * It manages the state, configuration and execution of the sub-brute forcing algorithm.
  13. */
  14. struct SubBruteWorker {
  15. SubBruteWorkerState state;
  16. volatile bool worker_running;
  17. volatile bool initiated;
  18. volatile bool transmit_mode;
  19. // Current step
  20. uint64_t step;
  21. // SubGhz
  22. FuriThread* thread;
  23. SubGhzProtocolDecoderBase* decoder_result;
  24. SubGhzEnvironment* environment;
  25. SubGhzTransmitter* transmitter;
  26. const char* protocol_name;
  27. uint8_t tx_timeout_ms;
  28. const SubGhzDevice* radio_device;
  29. // Initiated values
  30. SubBruteAttacks attack; // Attack state
  31. uint32_t frequency;
  32. FuriHalSubGhzPreset preset;
  33. SubBruteFileProtocol file;
  34. uint8_t bits;
  35. uint32_t te;
  36. uint8_t repeat;
  37. uint8_t load_index; // Index of group to bruteforce in loaded file
  38. uint64_t file_key;
  39. uint64_t max_value; // Max step
  40. bool two_bytes;
  41. // Manual transmit
  42. uint32_t last_time_tx_data;
  43. // Callback for changed states
  44. SubBruteWorkerCallback callback;
  45. void* context;
  46. };
  47. /**
  48. * @brief This function is the entry point for the sub-brute worker thread.
  49. *
  50. * @param context A pointer to the context data for the worker thread.
  51. * @return int32_t The return status of the worker thread.
  52. *
  53. * The sub-brute worker thread performs a sub-brute force operation based on the given context.
  54. * It takes the context as an input, processes the data, and returns a status code.
  55. * The function is used as an entry point for the worker thread.
  56. */
  57. int32_t subbrute_worker_thread(void* context);
  58. /**
  59. * @brief Transmits FlipperFormat using subGHz.
  60. *
  61. * This function transmits the specified FlipperFormat using the subGHz
  62. * protocol.
  63. *
  64. * @param instance The SubBruteWorker instance.
  65. * @param flipper_format Pointer to the FlipperFormat to be transmitted.
  66. */
  67. void subbrute_worker_subghz_transmit(SubBruteWorker* instance, FlipperFormat* flipper_format);
  68. /**
  69. * @brief Send a callback for a SubBruteWorker instance.
  70. *
  71. * This function is used to send a callback for the SubBruteWorker instance. The callback is triggered
  72. * when certain conditions are met during the worker's execution.
  73. *
  74. * @param instance The SubBruteWorker instance for which the callback is sent.
  75. *
  76. * @note This function does not return any values.
  77. */
  78. void subbrute_worker_send_callback(SubBruteWorker* instance);