subbrute_worker_private.h 3.3 KB

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