mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
Worst code ever
subghz imporvements - hold right to delete signal in read - extra buttons in saved signals - ability to change counter increase value in debug
This commit is contained in:
@@ -77,6 +77,25 @@ const SubGhzProtocol subghz_protocol_alutech_at_4n = {
|
||||
.encoder = &subghz_protocol_alutech_at_4n_encoder,
|
||||
};
|
||||
|
||||
static uint8_t al_btn_temp_id;
|
||||
static uint8_t al_btn_temp_id_original;
|
||||
|
||||
void alutech_set_btn(uint8_t b) {
|
||||
al_btn_temp_id = b;
|
||||
}
|
||||
|
||||
uint8_t alutech_get_original_btn() {
|
||||
return al_btn_temp_id_original;
|
||||
}
|
||||
|
||||
uint8_t alutech_get_custom_btn() {
|
||||
return al_btn_temp_id;
|
||||
}
|
||||
|
||||
void alutech_reset_original_btn() {
|
||||
al_btn_temp_id_original = 0;
|
||||
}
|
||||
|
||||
void* subghz_protocol_encoder_alutech_at_4n_alloc(SubGhzEnvironment* environment) {
|
||||
UNUSED(environment);
|
||||
SubGhzProtocolEncoderAlutech_at_4n* instance =
|
||||
@@ -255,8 +274,6 @@ static uint64_t subghz_protocol_alutech_at_4n_encrypt(uint64_t data, const char*
|
||||
static bool subghz_protocol_alutech_at_4n_gen_data(
|
||||
SubGhzProtocolEncoderAlutech_at_4n* instance,
|
||||
uint8_t btn) {
|
||||
UNUSED(btn);
|
||||
|
||||
uint64_t data = subghz_protocol_blocks_reverse_key(instance->generic.data, 64);
|
||||
|
||||
data = subghz_protocol_alutech_at_4n_decrypt(
|
||||
@@ -269,13 +286,13 @@ static bool subghz_protocol_alutech_at_4n_gen_data(
|
||||
}
|
||||
|
||||
if(instance->generic.cnt < 0xFFFF) {
|
||||
instance->generic.cnt++;
|
||||
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
|
||||
} else if(instance->generic.cnt >= 0xFFFF) {
|
||||
instance->generic.cnt = 0;
|
||||
}
|
||||
crc = subghz_protocol_alutech_at_4n_decrypt_data_crc((uint8_t)(instance->generic.cnt & 0xFF));
|
||||
data = (uint64_t)crc << 56 | (uint64_t)instance->generic.serial << 24 |
|
||||
(uint32_t)instance->generic.cnt << 8 | instance->generic.btn;
|
||||
(uint32_t)instance->generic.cnt << 8 | btn;
|
||||
|
||||
data = subghz_protocol_alutech_at_4n_encrypt(
|
||||
data, instance->alutech_at_4n_rainbow_table_file_name);
|
||||
@@ -306,7 +323,7 @@ bool subghz_protocol_alutech_at_4n_create_data(
|
||||
|
||||
/**
|
||||
* Generating an upload from data.
|
||||
* @param instance Pointer to a SubGhzProtocolEncoderKeeloq instance
|
||||
* @param instance Pointer to a SubGhzProtocolEncoderAlutech instance
|
||||
* @return true On success
|
||||
*/
|
||||
static bool subghz_protocol_encoder_alutech_at_4n_get_upload(
|
||||
@@ -314,6 +331,104 @@ static bool subghz_protocol_encoder_alutech_at_4n_get_upload(
|
||||
uint8_t btn) {
|
||||
furi_assert(instance);
|
||||
|
||||
// Save original button for later use
|
||||
if(al_btn_temp_id_original == 0) {
|
||||
al_btn_temp_id_original = btn;
|
||||
}
|
||||
|
||||
// Set custom button
|
||||
if(al_btn_temp_id == 1) {
|
||||
switch(al_btn_temp_id_original) {
|
||||
case 0x11:
|
||||
btn = 0x22;
|
||||
break;
|
||||
case 0x22:
|
||||
btn = 0x11;
|
||||
break;
|
||||
case 0xFF:
|
||||
btn = 0x11;
|
||||
break;
|
||||
case 0x44:
|
||||
btn = 0x11;
|
||||
break;
|
||||
case 0x33:
|
||||
btn = 0x11;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(al_btn_temp_id == 2) {
|
||||
switch(al_btn_temp_id_original) {
|
||||
case 0x11:
|
||||
btn = 0x44;
|
||||
break;
|
||||
case 0x22:
|
||||
btn = 0x44;
|
||||
break;
|
||||
case 0xFF:
|
||||
btn = 0x44;
|
||||
break;
|
||||
case 0x44:
|
||||
btn = 0xFF;
|
||||
break;
|
||||
case 0x33:
|
||||
btn = 0x44;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(al_btn_temp_id == 3) {
|
||||
switch(al_btn_temp_id_original) {
|
||||
case 0x11:
|
||||
btn = 0x33;
|
||||
break;
|
||||
case 0x22:
|
||||
btn = 0x33;
|
||||
break;
|
||||
case 0xFF:
|
||||
btn = 0x33;
|
||||
break;
|
||||
case 0x44:
|
||||
btn = 0x33;
|
||||
break;
|
||||
case 0x33:
|
||||
btn = 0x22;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(al_btn_temp_id == 4) {
|
||||
switch(al_btn_temp_id_original) {
|
||||
case 0x11:
|
||||
btn = 0xFF;
|
||||
break;
|
||||
case 0x22:
|
||||
btn = 0xFF;
|
||||
break;
|
||||
case 0xFF:
|
||||
btn = 0x22;
|
||||
break;
|
||||
case 0x44:
|
||||
btn = 0x22;
|
||||
break;
|
||||
case 0x33:
|
||||
btn = 0xFF;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if((al_btn_temp_id == 0) && (al_btn_temp_id_original != 0)) {
|
||||
btn = al_btn_temp_id_original;
|
||||
}
|
||||
//gen new key
|
||||
if(subghz_protocol_alutech_at_4n_gen_data(instance, btn)) {
|
||||
//ToDo if you need to add a callback to automatically update the data on the display
|
||||
@@ -608,6 +723,11 @@ static void subghz_protocol_alutech_at_4n_remote_controller(
|
||||
instance->cnt = 0;
|
||||
instance->serial = 0;
|
||||
}
|
||||
|
||||
// Save original button for later use
|
||||
if(al_btn_temp_id_original == 0) {
|
||||
al_btn_temp_id_original = instance->btn;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t subghz_protocol_decoder_alutech_at_4n_get_hash_data(void* context) {
|
||||
|
||||
@@ -10,6 +10,14 @@ extern const SubGhzProtocolDecoder subghz_protocol_alutech_at_4n_decoder;
|
||||
extern const SubGhzProtocolEncoder subghz_protocol_alutech_at_4n_encoder;
|
||||
extern const SubGhzProtocol subghz_protocol_alutech_at_4n;
|
||||
|
||||
// Custom buttons
|
||||
void alutech_set_btn(uint8_t b);
|
||||
|
||||
uint8_t alutech_get_original_btn();
|
||||
uint8_t alutech_get_custom_btn();
|
||||
|
||||
void alutech_reset_original_btn();
|
||||
|
||||
/**
|
||||
* Allocate SubGhzProtocolEncoderAlutech_at_4n.
|
||||
* @param environment Pointer to a SubGhzEnvironment instance
|
||||
|
||||
@@ -136,7 +136,7 @@ static void
|
||||
uint8_t pack[8] = {};
|
||||
|
||||
if(instance->generic.cnt < 0xFFFF) {
|
||||
instance->generic.cnt++;
|
||||
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
|
||||
} else if(instance->generic.cnt >= 0xFFFF) {
|
||||
instance->generic.cnt = 0;
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ void subghz_protocol_encoder_faac_slh_free(void* context) {
|
||||
}
|
||||
|
||||
static bool subghz_protocol_faac_slh_gen_data(SubGhzProtocolEncoderFaacSLH* instance) {
|
||||
instance->generic.cnt++;
|
||||
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
|
||||
uint32_t fix = instance->generic.serial << 4 | instance->generic.btn;
|
||||
uint32_t hop = 0;
|
||||
uint32_t decrypt = 0;
|
||||
|
||||
@@ -85,7 +85,25 @@ const SubGhzProtocol subghz_protocol_keeloq = {
|
||||
};
|
||||
|
||||
static const char* mfname;
|
||||
static int kl_type;
|
||||
static uint8_t kl_type;
|
||||
static uint8_t btn_temp_id;
|
||||
static uint8_t btn_temp_id_original;
|
||||
|
||||
void keeloq_set_btn(uint8_t b) {
|
||||
btn_temp_id = b;
|
||||
}
|
||||
|
||||
uint8_t keeloq_get_original_btn() {
|
||||
return btn_temp_id_original;
|
||||
}
|
||||
|
||||
uint8_t keeloq_get_custom_btn() {
|
||||
return btn_temp_id;
|
||||
}
|
||||
|
||||
void keeloq_reset_original_btn() {
|
||||
btn_temp_id_original = 0;
|
||||
}
|
||||
|
||||
void keeloq_reset_mfname() {
|
||||
mfname = "";
|
||||
@@ -136,11 +154,16 @@ void subghz_protocol_encoder_keeloq_free(void* context) {
|
||||
* @param instance Pointer to a SubGhzProtocolEncoderKeeloq* instance
|
||||
* @param btn Button number, 4 bit
|
||||
*/
|
||||
static bool subghz_protocol_keeloq_gen_data(SubGhzProtocolEncoderKeeloq* instance, uint8_t btn) {
|
||||
if(instance->generic.cnt < 0xFFFF) {
|
||||
instance->generic.cnt++;
|
||||
} else if(instance->generic.cnt >= 0xFFFF) {
|
||||
instance->generic.cnt = 0;
|
||||
static bool subghz_protocol_keeloq_gen_data(
|
||||
SubGhzProtocolEncoderKeeloq* instance,
|
||||
uint8_t btn,
|
||||
bool counter_up) {
|
||||
if(counter_up) {
|
||||
if(instance->generic.cnt < 0xFFFF) {
|
||||
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
|
||||
} else if(instance->generic.cnt >= 0xFFFF) {
|
||||
instance->generic.cnt = 0;
|
||||
}
|
||||
}
|
||||
uint32_t fix = (uint32_t)btn << 28 | instance->generic.serial;
|
||||
uint32_t decrypt = (uint32_t)btn << 28 |
|
||||
@@ -176,9 +199,9 @@ static bool subghz_protocol_keeloq_gen_data(SubGhzProtocolEncoderKeeloq* instanc
|
||||
hop = code_found_reverse & 0x00000000ffffffff;
|
||||
} else if(strcmp(instance->manufacture_name, "AN-Motors") == 0) {
|
||||
hop = (instance->generic.cnt & 0xFF) << 24 | (instance->generic.cnt & 0xFF) << 16 |
|
||||
(instance->generic.btn & 0xF) << 12 | 0x404;
|
||||
(btn & 0xF) << 12 | 0x404;
|
||||
} else if(strcmp(instance->manufacture_name, "HCS101") == 0) {
|
||||
hop = instance->generic.cnt << 16 | (instance->generic.btn & 0xF) << 12 | 0x000;
|
||||
hop = instance->generic.cnt << 16 | (btn & 0xF) << 12 | 0x000;
|
||||
} else {
|
||||
for
|
||||
M_EACH(manufacture_code, *subghz_keystore_get_data(instance->keystore), SubGhzKeyArray_t) {
|
||||
@@ -261,7 +284,7 @@ bool subghz_protocol_keeloq_create_data(
|
||||
instance->generic.cnt = cnt;
|
||||
instance->manufacture_name = manufacture_name;
|
||||
instance->generic.data_count_bit = 64;
|
||||
bool res = subghz_protocol_keeloq_gen_data(instance, btn);
|
||||
bool res = subghz_protocol_keeloq_gen_data(instance, btn, false);
|
||||
if(res) {
|
||||
res = subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
|
||||
}
|
||||
@@ -286,7 +309,7 @@ bool subghz_protocol_keeloq_bft_create_data(
|
||||
instance->manufacture_name = manufacture_name;
|
||||
instance->generic.data_count_bit = 64;
|
||||
// roguuemaster don't steal.!!!!
|
||||
bool res = subghz_protocol_keeloq_gen_data(instance, btn);
|
||||
bool res = subghz_protocol_keeloq_gen_data(instance, btn, false);
|
||||
if(res) {
|
||||
res = subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
|
||||
}
|
||||
@@ -302,8 +325,107 @@ static bool
|
||||
subghz_protocol_encoder_keeloq_get_upload(SubGhzProtocolEncoderKeeloq* instance, uint8_t btn) {
|
||||
furi_assert(instance);
|
||||
|
||||
// Save original button
|
||||
if(btn_temp_id_original == 0) {
|
||||
btn_temp_id_original = btn;
|
||||
}
|
||||
|
||||
// Set custom button
|
||||
if(btn_temp_id == 1) {
|
||||
switch(btn_temp_id_original) {
|
||||
case 0x1:
|
||||
btn = 0x2;
|
||||
break;
|
||||
case 0x2:
|
||||
btn = 0x1;
|
||||
break;
|
||||
case 0xA:
|
||||
btn = 0x1;
|
||||
break;
|
||||
case 0x4:
|
||||
btn = 0x1;
|
||||
break;
|
||||
case 0x8:
|
||||
btn = 0x1;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(btn_temp_id == 2) {
|
||||
switch(btn_temp_id_original) {
|
||||
case 0x1:
|
||||
btn = 0x4;
|
||||
break;
|
||||
case 0x2:
|
||||
btn = 0x4;
|
||||
break;
|
||||
case 0xA:
|
||||
btn = 0x4;
|
||||
break;
|
||||
case 0x4:
|
||||
btn = 0xA;
|
||||
break;
|
||||
case 0x8:
|
||||
btn = 0x4;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(btn_temp_id == 3) {
|
||||
switch(btn_temp_id_original) {
|
||||
case 0x1:
|
||||
btn = 0x8;
|
||||
break;
|
||||
case 0x2:
|
||||
btn = 0x8;
|
||||
break;
|
||||
case 0xA:
|
||||
btn = 0x8;
|
||||
break;
|
||||
case 0x4:
|
||||
btn = 0x8;
|
||||
break;
|
||||
case 0x8:
|
||||
btn = 0x2;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(btn_temp_id == 4) {
|
||||
switch(btn_temp_id_original) {
|
||||
case 0x1:
|
||||
btn = 0xA;
|
||||
break;
|
||||
case 0x2:
|
||||
btn = 0xA;
|
||||
break;
|
||||
case 0xA:
|
||||
btn = 0x2;
|
||||
break;
|
||||
case 0x4:
|
||||
btn = 0x2;
|
||||
break;
|
||||
case 0x8:
|
||||
btn = 0xA;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if((btn_temp_id == 0) && (btn_temp_id_original != 0)) {
|
||||
btn = btn_temp_id_original;
|
||||
}
|
||||
|
||||
//gen new key
|
||||
if(subghz_protocol_keeloq_gen_data(instance, btn)) {
|
||||
if(subghz_protocol_keeloq_gen_data(instance, btn, true)) {
|
||||
//ToDo if you need to add a callback to automatically update the data on the display
|
||||
} else {
|
||||
return false;
|
||||
@@ -974,6 +1096,11 @@ static void subghz_protocol_keeloq_check_remote_controller(
|
||||
|
||||
instance->serial = key_fix & 0x0FFFFFFF;
|
||||
instance->btn = key_fix >> 28;
|
||||
|
||||
// Save original button for later use
|
||||
if(btn_temp_id_original == 0) {
|
||||
btn_temp_id_original = instance->btn;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t subghz_protocol_decoder_keeloq_get_hash_data(void* context) {
|
||||
|
||||
@@ -15,6 +15,13 @@ void keeloq_reset_mfname();
|
||||
|
||||
void keeloq_reset_kl_type();
|
||||
|
||||
void keeloq_set_btn(uint8_t b);
|
||||
|
||||
uint8_t keeloq_get_original_btn();
|
||||
uint8_t keeloq_get_custom_btn();
|
||||
|
||||
void keeloq_reset_original_btn();
|
||||
|
||||
/**
|
||||
* Allocate SubGhzProtocolEncoderKeeloq.
|
||||
* @param environment Pointer to a SubGhzEnvironment instance
|
||||
|
||||
@@ -156,7 +156,7 @@ static bool subghz_protocol_kinggates_stylo_4k_gen_data(
|
||||
instance->generic.cnt = decrypt & 0xFFFF;
|
||||
|
||||
if(instance->generic.cnt < 0xFFFF) {
|
||||
instance->generic.cnt++;
|
||||
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
|
||||
} else if(instance->generic.cnt >= 0xFFFF) {
|
||||
instance->generic.cnt = 0;
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ static void subghz_protocol_encoder_nice_flor_s_get_upload(
|
||||
}
|
||||
|
||||
if(instance->generic.cnt < 0xFFFF) {
|
||||
instance->generic.cnt++;
|
||||
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
|
||||
} else if(instance->generic.cnt >= 0xFFFF) {
|
||||
instance->generic.cnt = 0;
|
||||
}
|
||||
|
||||
@@ -379,7 +379,7 @@ static void subghz_protocol_secplus_v2_encode(SubGhzProtocolEncoderSecPlus_v2* i
|
||||
uint8_t roll_1[9] = {0};
|
||||
uint8_t roll_2[9] = {0};
|
||||
|
||||
instance->generic.cnt++;
|
||||
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
|
||||
//ToDo it is not known what value the counter starts
|
||||
if(instance->generic.cnt > 0xFFFFFFF) instance->generic.cnt = 0xE500000;
|
||||
uint32_t rolling = subghz_protocol_blocks_reverse_key(instance->generic.cnt, 28);
|
||||
|
||||
@@ -131,7 +131,7 @@ static bool
|
||||
instance->generic.serial = data & 0xFFFFFF;
|
||||
|
||||
if(instance->generic.cnt < 0xFFFF) {
|
||||
instance->generic.cnt++;
|
||||
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
|
||||
} else if(instance->generic.cnt >= 0xFFFF) {
|
||||
instance->generic.cnt = 0;
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ static bool
|
||||
instance->generic.serial = data & 0xFFFFFF; // address
|
||||
|
||||
if(instance->generic.cnt < 0xFFFF) {
|
||||
instance->generic.cnt++;
|
||||
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
|
||||
} else if(instance->generic.cnt >= 0xFFFF) {
|
||||
instance->generic.cnt = 0;
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ void subghz_protocol_encoder_star_line_free(void* context) {
|
||||
static bool
|
||||
subghz_protocol_star_line_gen_data(SubGhzProtocolEncoderStarLine* instance, uint8_t btn) {
|
||||
if(instance->generic.cnt < 0xFFFF) {
|
||||
instance->generic.cnt++;
|
||||
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
|
||||
} else if(instance->generic.cnt >= 0xFFFF) {
|
||||
instance->generic.cnt = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user