subbrute_worker_private.h 3.4 KB

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