subbrute_worker_private.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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; /**< State of the worker */
  16. volatile bool worker_running; /**< Worker running state */
  17. volatile bool initiated; /**< Initiated state */
  18. volatile bool transmit_mode; /**< Transmit mode */
  19. uint64_t step; /**< Current step */
  20. FuriThread* thread; /**< Thread */
  21. /** @see @c SubGhz service for more info */
  22. SubGhzEnvironment* environment; /**< Environment */
  23. SubGhzProtocolDecoderBase* decoder_result;
  24. SubGhzTransmitter* transmitter; /**< Transmitter */
  25. const char* protocol_name; /**< Name of the protocol */
  26. uint8_t tx_timeout_ms; /**< Timeout for transmit */
  27. const SubGhzDevice* radio_device; /**< Radio device */
  28. // Initiated values
  29. SubBruteAttacks attack; /**< Attack state */
  30. uint32_t frequency; /**< Frequency */
  31. FuriHalSubGhzPreset preset; /**< Preset */
  32. SubBruteFileProtocol file; /**< File protocol */
  33. uint8_t bits; /**< Number of bits in key */
  34. uint32_t te; /**< Time to wait for response */
  35. uint8_t repeat; /**< Number of extra repeats */
  36. uint8_t load_index; /**< Index of group to bruteforce in loaded file */
  37. uint64_t file_key; /**< Key from file */
  38. uint64_t max_value; /**< Max step */
  39. bool two_bytes; /**< Two bytes key */
  40. // Manual transmit
  41. uint32_t last_time_tx_data; /**< Last time data was transmitted */
  42. // Callback for changed states
  43. SubBruteWorkerCallback callback; /**< Callback for changed states */
  44. void* context;
  45. };
  46. /**
  47. * @brief This function is the entry point for the sub-brute worker thread.
  48. *
  49. * @param context A pointer to the context data for the worker thread.
  50. * @return int32_t The return status of the worker thread.
  51. *
  52. * The sub-brute worker thread performs a sub-brute force operation based on the given context.
  53. * It takes the context as an input, processes the data, and returns a status code.
  54. * The function is used as an entry point for the worker thread.
  55. */
  56. int32_t subbrute_worker_thread(void* context);
  57. /**
  58. * @brief Transmits FlipperFormat using subGHz.
  59. *
  60. * This function transmits the specified FlipperFormat using the subGHz
  61. * protocol.
  62. *
  63. * @param instance The SubBruteWorker instance.
  64. * @param flipper_format Pointer to the FlipperFormat to be transmitted.
  65. */
  66. void subbrute_worker_subghz_transmit(SubBruteWorker* instance, FlipperFormat* flipper_format);
  67. /**
  68. * @brief Send a callback for a SubBruteWorker instance.
  69. *
  70. * This function is used to send a callback for the SubBruteWorker instance. The callback is triggered
  71. * when certain conditions are met during the worker's execution.
  72. *
  73. * @param instance The SubBruteWorker instance for which the callback is sent.
  74. *
  75. * @note This function does not return any values.
  76. */
  77. void subbrute_worker_send_callback(SubBruteWorker* instance);