mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-27 06:50:21 +00:00
faac beta-3
This commit is contained in:
parent
062faa4a84
commit
2a789ae1c1
1 changed files with 50 additions and 87 deletions
|
@ -8,8 +8,6 @@
|
||||||
#include "../blocks/generic.h"
|
#include "../blocks/generic.h"
|
||||||
#include "../blocks/math.h"
|
#include "../blocks/math.h"
|
||||||
|
|
||||||
#include "../blocks/custom_btn_i.h"
|
|
||||||
|
|
||||||
#define TAG "SubGhzProtocolFaacSLH"
|
#define TAG "SubGhzProtocolFaacSLH"
|
||||||
|
|
||||||
static const SubGhzBlockConst subghz_protocol_faac_slh_const = {
|
static const SubGhzBlockConst subghz_protocol_faac_slh_const = {
|
||||||
|
@ -112,42 +110,18 @@ void subghz_protocol_encoder_faac_slh_free(void* context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool subghz_protocol_faac_slh_gen_data(SubGhzProtocolEncoderFaacSLH* instance) {
|
static bool subghz_protocol_faac_slh_gen_data(SubGhzProtocolEncoderFaacSLH* instance) {
|
||||||
// Stupid bypass for custom button, remake later
|
if(instance->generic.allow_zero_seed || (instance->generic.seed != 0x0)) {
|
||||||
if(subghz_custom_btn_get_original() == 0) {
|
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
|
||||||
subghz_custom_btn_set_original(0xF);
|
FURI_LOG_I(TAG, "Counter ++");
|
||||||
}
|
} else if(instance->generic.prg_mode == true) {
|
||||||
|
|
||||||
uint8_t custom_btn_id = subghz_custom_btn_get();
|
|
||||||
ProgMode prog_mode_btn_status = subghz_custom_btn_get_prog_mode();
|
|
||||||
bool button_for_programming = false;
|
|
||||||
|
|
||||||
FURI_LOG_I("GENDATA", "CUSTOMBTN: %d\r", subghz_custom_btn_get());
|
|
||||||
|
|
||||||
// If custom button left is pressed, enable programming mode and disable it on Ok button
|
|
||||||
if((custom_btn_id == SUBGHZ_CUSTOM_BTN_OK)) {
|
|
||||||
if(prog_mode_btn_status == PROG_MODE_FAAC_SLH) {
|
|
||||||
button_for_programming = false;
|
|
||||||
prog_mode_btn_status = PROG_MODE_OFF;
|
|
||||||
}
|
|
||||||
} else if(custom_btn_id == SUBGHZ_CUSTOM_BTN_UP) {
|
|
||||||
button_for_programming = true;
|
|
||||||
prog_mode_btn_status = PROG_MODE_FAAC_SLH;
|
|
||||||
}
|
|
||||||
subghz_custom_btn_set_prog_mode(prog_mode_btn_status);
|
|
||||||
FURI_LOG_I("FAAC", "Button for programming: %d\r", button_for_programming);
|
|
||||||
FURI_LOG_I("FAAC", "Programming mode: %d\r", instance->generic.prg_mode);
|
|
||||||
|
|
||||||
if(button_for_programming) {
|
|
||||||
uint8_t data_tmp = 0;
|
uint8_t data_tmp = 0;
|
||||||
uint8_t data_prg[8];
|
uint8_t data_prg[8];
|
||||||
|
|
||||||
|
instance->generic.cnt_2++;
|
||||||
|
|
||||||
data_prg[0] = 0x00;
|
data_prg[0] = 0x00;
|
||||||
|
|
||||||
if(instance->generic.allow_zero_seed || (instance->generic.seed != 0x0)) {
|
data_prg[1] = instance->generic.cnt_2;
|
||||||
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
|
|
||||||
}
|
|
||||||
|
|
||||||
data_prg[1] = instance->generic.cnt & 0xFF;
|
|
||||||
|
|
||||||
data_prg[2] = (uint8_t)(instance->generic.seed & 0xFF);
|
data_prg[2] = (uint8_t)(instance->generic.seed & 0xFF);
|
||||||
data_prg[3] = (uint8_t)(instance->generic.seed >> 8 & 0xFF);
|
data_prg[3] = (uint8_t)(instance->generic.seed >> 8 & 0xFF);
|
||||||
|
@ -170,20 +144,17 @@ static bool subghz_protocol_faac_slh_gen_data(SubGhzProtocolEncoderFaacSLH* inst
|
||||||
data_prg[6] = 0x0F;
|
data_prg[6] = 0x0F;
|
||||||
data_prg[7] = 0x52;
|
data_prg[7] = 0x52;
|
||||||
|
|
||||||
uint32_t enc_prg_1 = data_prg[7] << 24 | data_prg[6] << 16 | data_prg[5] << 8 |
|
uint32_t enc_prg_1 = data_prg[7] << 24 | data_prg[6] << 16 | data_prg[5] << 8 | data_prg[4];
|
||||||
data_prg[4];
|
uint32_t enc_prg_2 = data_prg[3] << 24 | data_prg[2] << 16 | data_prg[1] << 8 | data_prg[0];
|
||||||
uint32_t enc_prg_2 = data_prg[3] << 24 | data_prg[2] << 16 | data_prg[1] << 8 |
|
|
||||||
data_prg[0];
|
|
||||||
instance->generic.data = (uint64_t)enc_prg_1 << 32 | enc_prg_2;
|
instance->generic.data = (uint64_t)enc_prg_1 << 32 | enc_prg_2;
|
||||||
FURI_LOG_I(TAG, "New MasterKey encrypted : %016llX\r", instance->generic.data);
|
FURI_LOG_I(TAG, "New MasterKey encrypted : %016llX", instance->generic.data);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
if(!instance->generic.allow_zero_seed && (instance->generic.seed == 0x0)) {
|
|
||||||
// Do not generate new data, send data from buffer
|
// Do not generate new data, send data from buffer
|
||||||
|
FURI_LOG_I(TAG, "Unknown / Static mode");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
uint32_t fix = instance->generic.serial << 4 | instance->generic.btn;
|
uint32_t fix = instance->generic.serial << 4 | instance->generic.btn;
|
||||||
uint32_t hop = 0;
|
uint32_t hop = 0;
|
||||||
uint32_t decrypt = 0;
|
uint32_t decrypt = 0;
|
||||||
|
@ -194,11 +165,6 @@ static bool subghz_protocol_faac_slh_gen_data(SubGhzProtocolEncoderFaacSLH* inst
|
||||||
for(int i = 0; i < 8; i++) {
|
for(int i = 0; i < 8; i++) {
|
||||||
fixx[i] = (fix >> (shiftby -= 4)) & 0xF;
|
fixx[i] = (fix >> (shiftby -= 4)) & 0xF;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(instance->generic.allow_zero_seed || (instance->generic.seed != 0x0)) {
|
|
||||||
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
|
|
||||||
}
|
|
||||||
|
|
||||||
if((instance->generic.cnt % 2) == 0) {
|
if((instance->generic.cnt % 2) == 0) {
|
||||||
decrypt = fixx[6] << 28 | fixx[7] << 24 | fixx[5] << 20 |
|
decrypt = fixx[6] << 28 | fixx[7] << 24 | fixx[5] << 20 |
|
||||||
(instance->generic.cnt & 0xFFFFF);
|
(instance->generic.cnt & 0xFFFFF);
|
||||||
|
@ -319,8 +285,10 @@ SubGhzProtocolStatus
|
||||||
bool allow_zero_seed;
|
bool allow_zero_seed;
|
||||||
if(flipper_format_read_bool(flipper_format, "AllowZeroSeed", &allow_zero_seed, 1)) {
|
if(flipper_format_read_bool(flipper_format, "AllowZeroSeed", &allow_zero_seed, 1)) {
|
||||||
instance->generic.allow_zero_seed = true;
|
instance->generic.allow_zero_seed = true;
|
||||||
|
FURI_LOG_I(TAG, "Enc. des. TRUE");
|
||||||
} else {
|
} else {
|
||||||
instance->generic.allow_zero_seed = false;
|
instance->generic.allow_zero_seed = false;
|
||||||
|
FURI_LOG_I(TAG, "Enc. des. FALSE");
|
||||||
}
|
}
|
||||||
|
|
||||||
instance->generic.seed = seed_data[0] << 24 | seed_data[1] << 16 | seed_data[2] << 8 |
|
instance->generic.seed = seed_data[0] << 24 | seed_data[1] << 16 | seed_data[2] << 8 |
|
||||||
|
@ -484,16 +452,11 @@ static void subghz_protocol_faac_slh_check_remote_controller(
|
||||||
const char** manufacture_name) {
|
const char** manufacture_name) {
|
||||||
uint32_t code_fix = instance->data >> 32;
|
uint32_t code_fix = instance->data >> 32;
|
||||||
uint32_t code_hop = instance->data & 0xFFFFFFFF;
|
uint32_t code_hop = instance->data & 0xFFFFFFFF;
|
||||||
|
instance->serial = code_fix >> 4;
|
||||||
|
instance->btn = code_fix & 0xF;
|
||||||
uint32_t decrypt = 0;
|
uint32_t decrypt = 0;
|
||||||
uint64_t man;
|
uint64_t man;
|
||||||
|
|
||||||
// Stupid bypass for custom button, remake later
|
|
||||||
if(subghz_custom_btn_get_original() == 0) {
|
|
||||||
subghz_custom_btn_set_original(0xF);
|
|
||||||
}
|
|
||||||
|
|
||||||
subghz_custom_btn_set_max(1);
|
|
||||||
FURI_LOG_I("RMC", "CUSTOMBTN: %d\r", subghz_custom_btn_get());
|
|
||||||
uint8_t data_tmp = 0;
|
uint8_t data_tmp = 0;
|
||||||
uint8_t data_prg[8];
|
uint8_t data_prg[8];
|
||||||
data_prg[0] = (code_hop & 0xFF);
|
data_prg[0] = (code_hop & 0xFF);
|
||||||
|
@ -505,35 +468,34 @@ static void subghz_protocol_faac_slh_check_remote_controller(
|
||||||
data_prg[6] = ((code_fix >> 16) & 0xFF);
|
data_prg[6] = ((code_fix >> 16) & 0xFF);
|
||||||
data_prg[7] = (code_fix >> 24);
|
data_prg[7] = (code_fix >> 24);
|
||||||
|
|
||||||
if(((data_prg[7] == 0x52) && (data_prg[6] == 0x0F) && (data_prg[0] == 0x00))) {
|
if( (data_prg[7] == 0x52) && (data_prg[6] == 0x0F) && (data_prg[0] == 0x00) ) {
|
||||||
instance->prg_mode = true;
|
instance->prg_mode = true;
|
||||||
// ProgMode ON
|
// ProgMode ON
|
||||||
|
FURI_LOG_I(TAG, "Master Key detected!");
|
||||||
|
|
||||||
for(uint8_t i = data_prg[1] & 0xF; i != 0; i--) {
|
for(uint8_t i = data_prg[1] & 0xF; i != 0; i--) {
|
||||||
|
|
||||||
data_tmp = data_prg[2];
|
data_tmp = data_prg[2];
|
||||||
|
|
||||||
data_prg[2] = data_prg[2] >> 1 | (data_prg[3] & 1) << 7;
|
data_prg[2] = data_prg[2] >> 1 | (data_prg[3] & 1) << 7;
|
||||||
data_prg[3] = data_prg[3] >> 1 | (data_prg[4] & 1) << 7;
|
data_prg[3] = data_prg[3] >> 1 | (data_prg[4] & 1) << 7;
|
||||||
data_prg[4] = data_prg[4] >> 1 | (data_prg[5] & 1) << 7;
|
data_prg[4] = data_prg[4] >> 1 | (data_prg[5] & 1) << 7;
|
||||||
data_prg[5] = data_prg[5] >> 1 | (data_tmp & 1) << 7;
|
data_prg[5] = data_prg[5] >> 1 | (data_tmp & 1) << 7;
|
||||||
|
|
||||||
}
|
}
|
||||||
data_prg[2] ^= data_prg[1];
|
data_prg[2] ^= data_prg[1];
|
||||||
data_prg[3] ^= data_prg[1];
|
data_prg[3] ^= data_prg[1];
|
||||||
data_prg[4] ^= data_prg[1];
|
data_prg[4] ^= data_prg[1];
|
||||||
data_prg[5] ^= data_prg[1];
|
data_prg[5] ^= data_prg[1];
|
||||||
|
FURI_LOG_I(TAG, "Got SEED value!");
|
||||||
instance->seed = data_prg[5] << 24 | data_prg[4] << 16 | data_prg[3] << 8 | data_prg[2];
|
instance->seed = data_prg[5] << 24 | data_prg[4] << 16 | data_prg[3] << 8 | data_prg[2];
|
||||||
uint32_t dec_prg_1 = data_prg[7] << 24 | data_prg[6] << 16 | data_prg[5] << 8 |
|
FURI_LOG_I(TAG, "SEED = %08lX", instance->seed);
|
||||||
data_prg[4];
|
uint32_t dec_prg_1 = data_prg[7] << 24 | data_prg[6] << 16 | data_prg[5] << 8 | data_prg[4];
|
||||||
uint32_t dec_prg_2 = data_prg[3] << 24 | data_prg[2] << 16 | data_prg[1] << 8 |
|
uint32_t dec_prg_2 = data_prg[3] << 24 | data_prg[2] << 16 | data_prg[1] << 8 | data_prg[0];
|
||||||
data_prg[0];
|
|
||||||
instance->data_2 = (uint64_t)dec_prg_1 << 32 | dec_prg_2;
|
instance->data_2 = (uint64_t)dec_prg_1 << 32 | dec_prg_2;
|
||||||
instance->cnt = data_prg[1];
|
FURI_LOG_I(TAG, "MasterKey decrypted : %016llX", instance->data_2);
|
||||||
|
instance->cnt_2 = data_prg[1];
|
||||||
*manufacture_name = "FAAC_SLH";
|
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
instance->serial = code_fix >> 4;
|
|
||||||
instance->btn = code_fix & 0xF;
|
|
||||||
|
|
||||||
instance->prg_mode = false;
|
instance->prg_mode = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -618,8 +580,10 @@ SubGhzProtocolStatus
|
||||||
bool allow_zero_seed;
|
bool allow_zero_seed;
|
||||||
if(flipper_format_read_bool(flipper_format, "AllowZeroSeed", &allow_zero_seed, 1)) {
|
if(flipper_format_read_bool(flipper_format, "AllowZeroSeed", &allow_zero_seed, 1)) {
|
||||||
instance->generic.allow_zero_seed = true;
|
instance->generic.allow_zero_seed = true;
|
||||||
|
FURI_LOG_I(TAG, "Dec. des. TRUE");
|
||||||
} else {
|
} else {
|
||||||
instance->generic.allow_zero_seed = false;
|
instance->generic.allow_zero_seed = false;
|
||||||
|
FURI_LOG_I(TAG, "Dec. des. FALSE");
|
||||||
}
|
}
|
||||||
instance->generic.seed = seed_data[0] << 24 | seed_data[1] << 16 | seed_data[2] << 8 |
|
instance->generic.seed = seed_data[0] << 24 | seed_data[1] << 16 | seed_data[2] << 8 |
|
||||||
seed_data[3];
|
seed_data[3];
|
||||||
|
@ -646,7 +610,6 @@ void subghz_protocol_decoder_faac_slh_get_string(void* context, FuriString* outp
|
||||||
furi_string_cat_printf(
|
furi_string_cat_printf(
|
||||||
output,
|
output,
|
||||||
"%s %dbit\r\n"
|
"%s %dbit\r\n"
|
||||||
"Master Remote Prog Mode\r\n"
|
|
||||||
"Ke:%lX%08lX\r\n"
|
"Ke:%lX%08lX\r\n"
|
||||||
"Kd:%lX%08lX\r\n"
|
"Kd:%lX%08lX\r\n"
|
||||||
"Seed:%08lX mCnt:%02X",
|
"Seed:%08lX mCnt:%02X",
|
||||||
|
@ -657,7 +620,7 @@ void subghz_protocol_decoder_faac_slh_get_string(void* context, FuriString* outp
|
||||||
(uint32_t)(instance->generic.data_2 >> 32),
|
(uint32_t)(instance->generic.data_2 >> 32),
|
||||||
(uint32_t)instance->generic.data_2,
|
(uint32_t)instance->generic.data_2,
|
||||||
instance->generic.seed,
|
instance->generic.seed,
|
||||||
(uint8_t)(instance->generic.cnt & 0xFF));
|
instance->generic.cnt_2);
|
||||||
} else if(instance->generic.allow_zero_seed == false) {
|
} else if(instance->generic.allow_zero_seed == false) {
|
||||||
furi_string_cat_printf(
|
furi_string_cat_printf(
|
||||||
output,
|
output,
|
||||||
|
|
Loading…
Reference in a new issue