2023-10-30 19:20:35 +03:00
|
|
|
/**
|
|
|
|
|
* @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.
|
|
|
|
|
*/
|
2022-06-21 15:45:50 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <stdbool.h>
|
2024-09-06 12:52:00 +03:00
|
|
|
#include "infrared_error_code.h"
|
2022-06-21 15:45:50 +03:00
|
|
|
|
2025-11-06 19:23:59 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2023-10-30 19:20:35 +03:00
|
|
|
/**
|
|
|
|
|
* @brief InfraredBruteForce opaque type declaration.
|
|
|
|
|
*/
|
2022-06-21 15:45:50 +03:00
|
|
|
typedef struct InfraredBruteForce InfraredBruteForce;
|
|
|
|
|
|
2023-10-30 19:20:35 +03:00
|
|
|
/**
|
|
|
|
|
* @brief Create a new InfraredBruteForce instance.
|
|
|
|
|
*
|
|
|
|
|
* @returns pointer to the created instance.
|
|
|
|
|
*/
|
2024-03-19 23:43:52 +09:00
|
|
|
InfraredBruteForce* infrared_brute_force_alloc(void);
|
2023-10-30 19:20:35 +03:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Delete an InfraredBruteForce instance.
|
|
|
|
|
*
|
|
|
|
|
* @param[in,out] brute_force pointer to the instance to be deleted.
|
|
|
|
|
*/
|
2022-06-21 15:45:50 +03:00
|
|
|
void infrared_brute_force_free(InfraredBruteForce* brute_force);
|
2023-10-30 19:20:35 +03:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @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.
|
|
|
|
|
*/
|
2022-06-21 15:45:50 +03:00
|
|
|
void infrared_brute_force_set_db_filename(InfraredBruteForce* brute_force, const char* db_filename);
|
2023-10-30 19:20:35 +03:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @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.
|
2024-09-06 12:52:00 +03:00
|
|
|
* @returns InfraredErrorCodeNone on success, otherwise error code.
|
2023-10-30 19:20:35 +03:00
|
|
|
*/
|
2024-09-06 12:52:00 +03:00
|
|
|
InfraredErrorCode infrared_brute_force_calculate_messages(InfraredBruteForce* brute_force);
|
2023-10-30 19:20:35 +03:00
|
|
|
|
|
|
|
|
/**
|
2025-11-06 16:40:18 +00:00
|
|
|
* @brief Start transmitting signals from a category stored in the dictionary.
|
|
|
|
|
*
|
|
|
|
|
* The function locates the category identified by @p index, reports the number of
|
|
|
|
|
* records it contains via @p record_count, and prepares the brute-force instance
|
|
|
|
|
* to transmit those signals. On failure @p record_count is set to zero.
|
2023-10-30 19:20:35 +03:00
|
|
|
*
|
|
|
|
|
* @param[in,out] brute_force pointer to the instance to be started.
|
|
|
|
|
* @param[in] index index of the signal category in the dictionary.
|
2025-11-06 16:40:18 +00:00
|
|
|
* @param[out] record_count pointer that receives the number of records in the category.
|
|
|
|
|
* @returns true if the category is found and the backing database file is opened, false otherwise.
|
2023-10-30 19:20:35 +03:00
|
|
|
*/
|
2022-06-21 15:45:50 +03:00
|
|
|
bool infrared_brute_force_start(
|
|
|
|
|
InfraredBruteForce* brute_force,
|
|
|
|
|
uint32_t index,
|
|
|
|
|
uint32_t* record_count);
|
2023-10-30 19:20:35 +03:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @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.
|
|
|
|
|
*/
|
2022-06-21 15:45:50 +03:00
|
|
|
void infrared_brute_force_stop(InfraredBruteForce* brute_force);
|
2023-10-30 19:20:35 +03:00
|
|
|
|
|
|
|
|
/**
|
2025-02-20 03:58:55 +04:00
|
|
|
* @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
|
2023-10-30 19:20:35 +03:00
|
|
|
*/
|
2025-02-20 03:58:55 +04:00
|
|
|
bool infrared_brute_force_send(InfraredBruteForce* brute_force, uint32_t signal_index);
|
2023-10-30 19:20:35 +03:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @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.
|
|
|
|
|
*/
|
2022-06-21 15:45:50 +03:00
|
|
|
void infrared_brute_force_add_record(
|
|
|
|
|
InfraredBruteForce* brute_force,
|
|
|
|
|
uint32_t index,
|
|
|
|
|
const char* name);
|
2023-10-30 19:20:35 +03:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Reset an InfraredBruteForce instance.
|
|
|
|
|
*
|
|
|
|
|
* @param[in,out] brute_force pointer to the instance to be reset.
|
|
|
|
|
*/
|
2022-09-22 19:13:00 +03:00
|
|
|
void infrared_brute_force_reset(InfraredBruteForce* brute_force);
|
2025-11-06 19:23:59 +03:00
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|