Fixes and de-kostilying

This commit is contained in:
MX 2023-09-02 16:00:24 +03:00
parent 17269a5386
commit 3898e6e71d
No known key found for this signature in database
GPG Key ID: 7CCC66B7DBDD1C83
4 changed files with 15 additions and 36 deletions

View File

@ -228,9 +228,9 @@ bool subghz_txrx_gen_faac_slh_protocol(
seed_data[sizeof(uint32_t) - i - 1] = (seed >> i * 8) & 0xFF; seed_data[sizeof(uint32_t) - i - 1] = (seed >> i * 8) & 0xFF;
} }
bool allow_zero_seed = true;
flipper_format_write_hex(txrx->fff_data, "Seed", seed_data, sizeof(uint32_t)); flipper_format_write_hex(txrx->fff_data, "Seed", seed_data, sizeof(uint32_t));
flipper_format_write_string_cstr(txrx->fff_data, "Valid", "1\r\n"); flipper_format_write_bool(txrx->fff_data, "AllowZeroSeed", &allow_zero_seed, 1);
FURI_LOG_I(TAG, "Flag write to SD is OK");
} }
subghz_transmitter_free(txrx->transmitter); subghz_transmitter_free(txrx->transmitter);

View File

@ -32,7 +32,7 @@ const char* const debug_pin_text[DEBUG_P_COUNT] = {
"17(1W)", "17(1W)",
}; };
#define DEBUG_COUNTER_COUNT 15 #define DEBUG_COUNTER_COUNT 13
const char* const debug_counter_text[DEBUG_COUNTER_COUNT] = { const char* const debug_counter_text[DEBUG_COUNTER_COUNT] = {
"+1", "+1",
"+2", "+2",
@ -40,7 +40,6 @@ const char* const debug_counter_text[DEBUG_COUNTER_COUNT] = {
"+4", "+4",
"+5", "+5",
"+10", "+10",
"+100",
"0", "0",
"-1", "-1",
"-2", "-2",
@ -48,7 +47,6 @@ const char* const debug_counter_text[DEBUG_COUNTER_COUNT] = {
"-4", "-4",
"-5", "-5",
"-10", "-10",
"-100",
}; };
const uint32_t debug_counter_val[DEBUG_COUNTER_COUNT] = { const uint32_t debug_counter_val[DEBUG_COUNTER_COUNT] = {
1, 1,
@ -57,7 +55,6 @@ const uint32_t debug_counter_val[DEBUG_COUNTER_COUNT] = {
4, 4,
5, 5,
10, 10,
100,
0, 0,
-1, -1,
-2, -2,
@ -65,7 +62,6 @@ const uint32_t debug_counter_val[DEBUG_COUNTER_COUNT] = {
-4, -4,
-5, -5,
-10, -10,
-100,
}; };
static void subghz_scene_radio_settings_set_device(VariableItem* item) { static void subghz_scene_radio_settings_set_device(VariableItem* item) {

View File

@ -25,6 +25,7 @@ struct SubGhzBlockGeneric {
uint32_t cnt; uint32_t cnt;
uint8_t cnt_2; uint8_t cnt_2;
uint32_t seed; uint32_t seed;
bool allow_zero_seed;
}; };
/** /**

View File

@ -10,8 +10,6 @@
#define TAG "SubGhzProtocolFaacSLH" #define TAG "SubGhzProtocolFaacSLH"
bool bvalid;
static const SubGhzBlockConst subghz_protocol_faac_slh_const = { static const SubGhzBlockConst subghz_protocol_faac_slh_const = {
.te_short = 255, .te_short = 255,
.te_long = 595, .te_long = 595,
@ -112,21 +110,10 @@ 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) {
//FuriString* valid = furi_string_alloc(); if(instance->generic.allow_zero_seed) {
//if(flipper_format_read_string(flipper_format, "Valid", valid)) {
//bvalid = true;
//FURI_LOG_I(TAG, "[gen_data] is valid ? : %i", bvalid);
//} else {
//bvalid = false;
//FURI_LOG_I(TAG, "[gen_data] is valid ? : %i", bvalid);
//}
//furi_string_free(valid);
if(bvalid) {
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult(); instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
FURI_LOG_I(TAG, "[gen_data] TRUE : %i", bvalid);
} else { } else {
// Do not generate new data, send data from buffer // Do not generate new data, send data from buffer
FURI_LOG_I(TAG, "[gen_data] FALSE : %i", bvalid);
return true; return true;
} }
uint32_t fix = instance->generic.serial << 4 | instance->generic.btn; uint32_t fix = instance->generic.serial << 4 | instance->generic.btn;
@ -255,15 +242,13 @@ SubGhzProtocolStatus
FURI_LOG_E(TAG, "Missing Seed"); FURI_LOG_E(TAG, "Missing Seed");
break; break;
} }
FuriString* valid = furi_string_alloc(); bool allow_zero_seed;
if(flipper_format_read_string(flipper_format, "Valid", valid)) { if(flipper_format_read_bool(flipper_format, "AllowZeroSeed", &allow_zero_seed, 1)) {
bvalid = true; instance->generic.allow_zero_seed = true;
FURI_LOG_I(TAG, "[encoder_des] True : %i", bvalid);
} else { } else {
bvalid = false; instance->generic.allow_zero_seed = false;
FURI_LOG_I(TAG, "[encoder_des] False : %i", bvalid);
} }
furi_string_free(valid);
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];
@ -508,15 +493,12 @@ SubGhzProtocolStatus
FURI_LOG_E(TAG, "Missing Seed"); FURI_LOG_E(TAG, "Missing Seed");
break; break;
} }
FuriString* valid = furi_string_alloc(); bool allow_zero_seed;
if(flipper_format_read_string(flipper_format, "Valid", valid)) { if(flipper_format_read_bool(flipper_format, "AllowZeroSeed", &allow_zero_seed, 1)) {
bvalid = true; instance->generic.allow_zero_seed = true;
FURI_LOG_I(TAG, "[decoder_des] TRUE : %i", bvalid);
} else { } else {
bvalid = false; instance->generic.allow_zero_seed = false;
FURI_LOG_I(TAG, "[decoder_des] FALSE : %i", bvalid);
} }
furi_string_free(valid);
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];
@ -538,7 +520,7 @@ void subghz_protocol_decoder_faac_slh_get_string(void* context, FuriString* outp
uint32_t code_fix = instance->generic.data >> 32; uint32_t code_fix = instance->generic.data >> 32;
uint32_t code_hop = instance->generic.data & 0xFFFFFFFF; uint32_t code_hop = instance->generic.data & 0xFFFFFFFF;
if(bvalid == false) { if(instance->generic.allow_zero_seed == false) {
furi_string_cat_printf( furi_string_cat_printf(
output, output,
"%s %dbit\r\n" "%s %dbit\r\n"