2022-03-03 12:48:56 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
|
|
|
|
#include <lib/toolbox/level_duration.h>
|
|
|
|
|
2022-10-19 20:27:26 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2022-03-03 12:48:56 +03:00
|
|
|
typedef struct {
|
2022-08-17 19:40:09 +03:00
|
|
|
bool is_running;
|
2022-03-03 12:48:56 +03:00
|
|
|
size_t repeat;
|
|
|
|
size_t front;
|
|
|
|
size_t size_upload;
|
|
|
|
LevelDuration* upload;
|
|
|
|
|
|
|
|
} SubGhzProtocolBlockEncoder;
|
2022-06-01 15:17:21 +03:00
|
|
|
|
2023-02-09 07:48:06 +03:00
|
|
|
typedef enum {
|
|
|
|
SubGhzProtocolBlockAlignBitLeft,
|
|
|
|
SubGhzProtocolBlockAlignBitRight,
|
|
|
|
} SubGhzProtocolBlockAlignBit;
|
|
|
|
|
2022-06-01 15:17:21 +03:00
|
|
|
/**
|
|
|
|
* Set data bit when encoding HEX array.
|
|
|
|
* @param bit_value The value of the bit to be set
|
|
|
|
* @param data_array Pointer to a HEX array
|
|
|
|
* @param set_index_bit Number set a bit in the array starting from the left
|
|
|
|
* @param max_size_array array size, check not to overflow
|
|
|
|
*/
|
|
|
|
void subghz_protocol_blocks_set_bit_array(
|
|
|
|
bool bit_value,
|
|
|
|
uint8_t data_array[],
|
|
|
|
size_t set_index_bit,
|
|
|
|
size_t max_size_array);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get data bit when encoding HEX array.
|
|
|
|
* @param data_array Pointer to a HEX array
|
|
|
|
* @param read_index_bit Number get a bit in the array starting from the left
|
|
|
|
* @return bool value bit
|
|
|
|
*/
|
|
|
|
bool subghz_protocol_blocks_get_bit_array(uint8_t data_array[], size_t read_index_bit);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generating an upload from data.
|
|
|
|
* @param data_array Pointer to a HEX array
|
|
|
|
* @param count_bit_data_array How many bits in the array are processed
|
|
|
|
* @param upload Pointer to a LevelDuration
|
|
|
|
* @param max_size_upload upload size, check not to overflow
|
|
|
|
* @param duration_bit duration 1 bit
|
2023-02-09 07:48:06 +03:00
|
|
|
* @param align_bit alignment of useful bits in an array
|
2022-06-01 15:17:21 +03:00
|
|
|
*/
|
2023-02-09 07:48:06 +03:00
|
|
|
size_t subghz_protocol_blocks_get_upload_from_bit_array(
|
2022-06-01 15:17:21 +03:00
|
|
|
uint8_t data_array[],
|
|
|
|
size_t count_bit_data_array,
|
|
|
|
LevelDuration* upload,
|
|
|
|
size_t max_size_upload,
|
2023-02-09 07:48:06 +03:00
|
|
|
uint32_t duration_bit,
|
|
|
|
SubGhzProtocolBlockAlignBit align_bit);
|
2022-10-19 20:27:26 +03:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|