Files
Momentum-Firmware/lib/infrared/signal/infrared_brute_force.h
MMX 6a5ae6cc0d Infrared Universal remote DBs unit test & move infrared_signal / infrared_brute_force into lib (#4284)
* make infrared db unit tests

* fix the tests, no assets are in asset folder oh no

* fix formate

* ship ir app along with unit_test pkg

* libify ir signal and bruteforce parts

* small cleanup

* api: removed infrared methods (you can link with the lib if needed), unit_tests, infrared: adjusted to link with ir lib; api: added `__aeabi_f2d`

---------

Co-authored-by: hedger <hedger@users.noreply.github.com>
Co-authored-by: hedger <hedger@nanode.su>
2025-11-06 20:23:59 +04:00

118 lines
3.5 KiB
C

/**
* @file infrared_brute_force.h
* @brief Infrared signal brute-forcing library.
*
* The BruteForce library is used to send large quantities of signals,
* sorted by a category. It is used to implement the Universal Remote
* feature.
*/
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include "infrared_error_code.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief InfraredBruteForce opaque type declaration.
*/
typedef struct InfraredBruteForce InfraredBruteForce;
/**
* @brief Create a new InfraredBruteForce instance.
*
* @returns pointer to the created instance.
*/
InfraredBruteForce* infrared_brute_force_alloc(void);
/**
* @brief Delete an InfraredBruteForce instance.
*
* @param[in,out] brute_force pointer to the instance to be deleted.
*/
void infrared_brute_force_free(InfraredBruteForce* brute_force);
/**
* @brief Set an InfraredBruteForce instance to use a signal database contained in a file.
*
* @param[in,out] brute_force pointer to the instance to be configured.
* @param[in] db_filename pointer to a zero-terminated string containing a full path to the database file.
*/
void infrared_brute_force_set_db_filename(InfraredBruteForce* brute_force, const char* db_filename);
/**
* @brief Build a signal dictionary from a previously set database file.
*
* This function must be called each time after setting the database via
* a infrared_brute_force_set_db_filename() call.
*
* @param[in,out] brute_force pointer to the instance to be updated.
* @returns InfraredErrorCodeNone on success, otherwise error code.
*/
InfraredErrorCode infrared_brute_force_calculate_messages(InfraredBruteForce* brute_force);
/**
* @brief Start transmitting signals from a category stored in an InfraredBruteForce's instance dictionary.
*
* @param[in,out] brute_force pointer to the instance to be started.
* @param[in] index index of the signal category in the dictionary.
* @returns true on success, false otherwise.
*/
bool infrared_brute_force_start(
InfraredBruteForce* brute_force,
uint32_t index,
uint32_t* record_count);
/**
* @brief Determine whether the transmission was started.
*
* @param[in] brute_force pointer to the instance to be tested.
* @returns true if transmission was started, false otherwise.
*/
bool infrared_brute_force_is_started(const InfraredBruteForce* brute_force);
/**
* @brief Stop transmitting the signals.
*
* @param[in] brute_force pointer to the instance to be stopped.
*/
void infrared_brute_force_stop(InfraredBruteForce* brute_force);
/**
* @brief Send an arbitrary signal from the chosen category.
*
* @param[in] brute_force pointer to the instance
* @param signal_index the index of the signal within the category, must be
* between 0 and `record_count` as told by
* `infrared_brute_force_start`
*
* @returns true on success, false otherwise
*/
bool infrared_brute_force_send(InfraredBruteForce* brute_force, uint32_t signal_index);
/**
* @brief Add a signal category to an InfraredBruteForce instance's dictionary.
*
* @param[in,out] brute_force pointer to the instance to be updated.
* @param[in] index index of the category to be added.
* @param[in] name name of the category to be added.
*/
void infrared_brute_force_add_record(
InfraredBruteForce* brute_force,
uint32_t index,
const char* name);
/**
* @brief Reset an InfraredBruteForce instance.
*
* @param[in,out] brute_force pointer to the instance to be reset.
*/
void infrared_brute_force_reset(InfraredBruteForce* brute_force);
#ifdef __cplusplus
}
#endif