mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
Merge remote-tracking branch 'ul/dev' into mntm-dev --nobuild
This commit is contained in:
@@ -9,7 +9,8 @@
|
||||
|
||||
#define TAG "SubGhzProtocoAlutech_at_4n"
|
||||
|
||||
#define SUBGHZ_NO_ALUTECH_AT_4N_RAINBOW_TABLE 0xFFFFFFFF
|
||||
#define SUBGHZ_NO_ALUTECH_AT_4N_RAINBOW_TABLE 0xFFFFFFFFFFFFFFFF
|
||||
#define SUBGHZ_ALUTECH_AT_4N_RAINBOW_TABLE_SIZE_BYTES 32
|
||||
|
||||
static const SubGhzBlockConst subghz_protocol_alutech_at_4n_const = {
|
||||
.te_short = 400,
|
||||
@@ -142,27 +143,21 @@ LevelDuration subghz_protocol_encoder_alutech_at_4n_yield(void* context) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Read bytes from rainbow table
|
||||
* @param file_name Full path to rainbow table the file
|
||||
* Read bytes from buffer array with rainbow table
|
||||
* @param buffer Pointer to decrypted magic data buffer
|
||||
* @param number_alutech_at_4n_magic_data number in the array
|
||||
* @return alutech_at_4n_magic_data
|
||||
*/
|
||||
static uint32_t subghz_protocol_alutech_at_4n_get_magic_data_in_file(
|
||||
const char* file_name,
|
||||
static uint32_t subghz_protocol_alutech_at_4n_get_magic_data_from_buffer(
|
||||
uint8_t* buffer,
|
||||
uint8_t number_alutech_at_4n_magic_data) {
|
||||
if(!strcmp(file_name, "")) return SUBGHZ_NO_ALUTECH_AT_4N_RAINBOW_TABLE;
|
||||
|
||||
uint8_t buffer[sizeof(uint32_t)] = {0};
|
||||
uint32_t address = number_alutech_at_4n_magic_data * sizeof(uint32_t);
|
||||
uint32_t alutech_at_4n_magic_data = 0;
|
||||
|
||||
if(subghz_keystore_raw_get_data(file_name, address, buffer, sizeof(uint32_t))) {
|
||||
for(size_t i = 0; i < sizeof(uint32_t); i++) {
|
||||
alutech_at_4n_magic_data = (alutech_at_4n_magic_data << 8) | buffer[i];
|
||||
}
|
||||
} else {
|
||||
alutech_at_4n_magic_data = SUBGHZ_NO_ALUTECH_AT_4N_RAINBOW_TABLE;
|
||||
for(size_t i = address; i < (address + sizeof(uint32_t)); i++) {
|
||||
alutech_at_4n_magic_data = (alutech_at_4n_magic_data << 8) | buffer[i];
|
||||
}
|
||||
|
||||
return alutech_at_4n_magic_data;
|
||||
}
|
||||
|
||||
@@ -197,17 +192,29 @@ static uint8_t subghz_protocol_alutech_at_4n_decrypt_data_crc(uint8_t data) {
|
||||
}
|
||||
|
||||
static uint64_t subghz_protocol_alutech_at_4n_decrypt(uint64_t data, const char* file_name) {
|
||||
// load and decrypt rainbow table from file to buffer array in RAM
|
||||
if(!file_name) return SUBGHZ_NO_ALUTECH_AT_4N_RAINBOW_TABLE;
|
||||
|
||||
uint8_t buffer[SUBGHZ_ALUTECH_AT_4N_RAINBOW_TABLE_SIZE_BYTES] = {0};
|
||||
uint8_t* buffer_ptr = (uint8_t*)&buffer;
|
||||
|
||||
if(subghz_keystore_raw_get_data(
|
||||
file_name, 0, buffer, SUBGHZ_ALUTECH_AT_4N_RAINBOW_TABLE_SIZE_BYTES)) {
|
||||
} else {
|
||||
return SUBGHZ_NO_ALUTECH_AT_4N_RAINBOW_TABLE;
|
||||
}
|
||||
|
||||
uint8_t* p = (uint8_t*)&data;
|
||||
uint32_t data1 = p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3];
|
||||
uint32_t data2 = p[4] << 24 | p[5] << 16 | p[6] << 8 | p[7];
|
||||
uint32_t data3 = 0;
|
||||
uint32_t magic_data[] = {
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_in_file(file_name, 0),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_in_file(file_name, 1),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_in_file(file_name, 2),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_in_file(file_name, 3),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_in_file(file_name, 4),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_in_file(file_name, 5)};
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_from_buffer(buffer_ptr, 0),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_from_buffer(buffer_ptr, 1),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_from_buffer(buffer_ptr, 2),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_from_buffer(buffer_ptr, 3),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_from_buffer(buffer_ptr, 4),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_from_buffer(buffer_ptr, 5)};
|
||||
|
||||
uint32_t i = magic_data[0];
|
||||
do {
|
||||
@@ -232,17 +239,29 @@ static uint64_t subghz_protocol_alutech_at_4n_decrypt(uint64_t data, const char*
|
||||
}
|
||||
|
||||
static uint64_t subghz_protocol_alutech_at_4n_encrypt(uint64_t data, const char* file_name) {
|
||||
// load and decrypt rainbow table from file to buffer array in RAM
|
||||
if(!file_name) return SUBGHZ_NO_ALUTECH_AT_4N_RAINBOW_TABLE;
|
||||
|
||||
uint8_t buffer[SUBGHZ_ALUTECH_AT_4N_RAINBOW_TABLE_SIZE_BYTES] = {0};
|
||||
uint8_t* buffer_ptr = (uint8_t*)&buffer;
|
||||
|
||||
if(subghz_keystore_raw_get_data(
|
||||
file_name, 0, buffer, SUBGHZ_ALUTECH_AT_4N_RAINBOW_TABLE_SIZE_BYTES)) {
|
||||
} else {
|
||||
return SUBGHZ_NO_ALUTECH_AT_4N_RAINBOW_TABLE;
|
||||
}
|
||||
|
||||
uint8_t* p = (uint8_t*)&data;
|
||||
uint32_t data1 = 0;
|
||||
uint32_t data2 = p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3];
|
||||
uint32_t data3 = p[4] << 24 | p[5] << 16 | p[6] << 8 | p[7];
|
||||
uint32_t magic_data[] = {
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_in_file(file_name, 6),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_in_file(file_name, 4),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_in_file(file_name, 5),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_in_file(file_name, 1),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_in_file(file_name, 2),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_in_file(file_name, 0)};
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_from_buffer(buffer_ptr, 6),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_from_buffer(buffer_ptr, 4),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_from_buffer(buffer_ptr, 5),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_from_buffer(buffer_ptr, 1),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_from_buffer(buffer_ptr, 2),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_from_buffer(buffer_ptr, 0)};
|
||||
|
||||
do {
|
||||
data1 = data1 + magic_data[0];
|
||||
@@ -280,12 +299,17 @@ static bool subghz_protocol_alutech_at_4n_gen_data(
|
||||
if(alutech_at4n_counter_mode == 0) {
|
||||
// Check for OFEX (overflow experimental) mode
|
||||
if(furi_hal_subghz_get_rolling_counter_mult() != -0x7FFFFFFF) {
|
||||
if((instance->generic.cnt + furi_hal_subghz_get_rolling_counter_mult()) > 0xFFFF) {
|
||||
instance->generic.cnt = 0;
|
||||
} else {
|
||||
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
|
||||
// standart counter mode. PULL data from subghz_block_generic_global variables
|
||||
if(!subghz_block_generic_global_counter_override_get(&instance->generic.cnt)) {
|
||||
// if counter_override_get return FALSE then counter was not changed and we increase counter by standart mult value
|
||||
if((instance->generic.cnt + furi_hal_subghz_get_rolling_counter_mult()) > 0xFFFF) {
|
||||
instance->generic.cnt = 0;
|
||||
} else {
|
||||
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//OFFEX mode
|
||||
if((instance->generic.cnt + 0x1) > 0xFFFF) {
|
||||
instance->generic.cnt = 0;
|
||||
} else if(instance->generic.cnt >= 0x1 && instance->generic.cnt != 0xFFFE) {
|
||||
@@ -461,7 +485,7 @@ SubGhzProtocolStatus subghz_protocol_encoder_alutech_at_4n_deserialize(
|
||||
break;
|
||||
}
|
||||
|
||||
//optional parameter parameter
|
||||
// Optional value
|
||||
flipper_format_read_uint32(
|
||||
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
|
||||
|
||||
@@ -872,6 +896,12 @@ void subghz_protocol_decoder_alutech_at_4n_get_string(void* context, FuriString*
|
||||
uint32_t code_found_hi = instance->generic.data >> 32;
|
||||
uint32_t code_found_lo = instance->generic.data & 0x00000000ffffffff;
|
||||
|
||||
// push protocol data to global variable
|
||||
subghz_block_generic_global.cnt_is_available = true;
|
||||
subghz_block_generic_global.cnt_length_bit = 16;
|
||||
subghz_block_generic_global.current_cnt = instance->generic.cnt;
|
||||
//
|
||||
|
||||
furi_string_cat_printf(
|
||||
output,
|
||||
"%s\r\n"
|
||||
|
||||
Reference in New Issue
Block a user