Skip to content

Commit d10a601

Browse files
committed
grand finale?
1 parent 32a182c commit d10a601

2 files changed

Lines changed: 35 additions & 19 deletions

File tree

applications/main/subghz/scenes/subghz_scene_signal_settings.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -334,11 +334,9 @@ bool subghz_scene_signal_settings_on_event(void* context, SceneManagerEvent even
334334
// convert back after byte_input and do one send with our new mult (counter16) - at end we must have signal Cnt = counter16
335335
counter16 = __bswap16(counter16);
336336

337-
if(counter16 > 0) {
338-
furi_hal_subghz_set_rolling_counter_mult(counter16);
339-
subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx));
340-
subghz_txrx_stop(subghz->txrx);
341-
}
337+
furi_hal_subghz_set_rolling_counter_mult(counter16);
338+
subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx));
339+
subghz_txrx_stop(subghz->txrx);
342340

343341
// restore user definded counter increase value (mult)
344342
furi_hal_subghz_set_rolling_counter_mult(tmp_counter);
@@ -360,11 +358,9 @@ bool subghz_scene_signal_settings_on_event(void* context, SceneManagerEvent even
360358

361359
counter32 = __bswap32(counter32);
362360

363-
if(counter32 > 0) {
364-
furi_hal_subghz_set_rolling_counter_mult(counter32);
365-
subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx));
366-
subghz_txrx_stop(subghz->txrx);
367-
}
361+
furi_hal_subghz_set_rolling_counter_mult(counter32);
362+
subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx));
363+
subghz_txrx_stop(subghz->txrx);
368364

369365
furi_hal_subghz_set_rolling_counter_mult(tmp_counter);
370366
break;

lib/subghz/protocols/secplus_v2.c

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -401,17 +401,37 @@ static void subghz_protocol_secplus_v2_encode(SubGhzProtocolEncoderSecPlus_v2* i
401401
uint8_t roll_1[9] = {0};
402402
uint8_t roll_2[9] = {0};
403403

404-
// ---Experemental case - we dont know counter size exactly, so just will be think that is "FF FF FF F"
405-
if((instance->generic.cnt + (furi_hal_subghz_get_rolling_counter_mult() & 0xFFFFFFF)) >
406-
0xFFFFFFF) {
407-
instance->generic.cnt = 0xE500000;
404+
// Experemental case - we dont know counter size exactly, so just will be think that it is in range of 0xE500000 - 0xFFFFFFF
405+
// one case when we have mult = 0xFFFFFFFF - its when we reset counter before aplaying new cnt value
406+
// so at first step we reset cnt to 0 and now we sure here will be second step (set new cnt value);
407+
// at second step check what user set for new Cnt (and correct it if cnt less than 0xE500000 or more than 0xFFFFFFF)
408+
if(((int32_t)furi_hal_subghz_get_rolling_counter_mult() == (int32_t)0xFFFFFFFF) &
409+
(instance->generic.cnt != 0)) {
410+
instance->generic.cnt = 0;
408411
} else {
409-
instance->generic.cnt += (furi_hal_subghz_get_rolling_counter_mult() & 0xFFFFFFF);
412+
// if cnt was reset to 0 on previous step and user want new Cnt then set it to 0xE500000 or 0xFFFFFFF or new user value
413+
if(instance->generic.cnt == 0) {
414+
if((uint32_t)furi_hal_subghz_get_rolling_counter_mult() < (uint32_t)0xE500000) {
415+
instance->generic.cnt = 0xE500000;
416+
} else {
417+
if((uint32_t)furi_hal_subghz_get_rolling_counter_mult() > (uint32_t)0xFFFFFFF) {
418+
instance->generic.cnt = 0xFFFFFFF;
419+
} else {
420+
instance->generic.cnt +=
421+
((furi_hal_subghz_get_rolling_counter_mult() & 0xFFFFFFF));
422+
}
423+
}
424+
} else {
425+
// if we have not special cases - so work as standart mode
426+
if((instance->generic.cnt + (furi_hal_subghz_get_rolling_counter_mult() & 0xFFFFFFF)) >
427+
0xFFFFFFF) {
428+
instance->generic.cnt = 0xE500000;
429+
} else {
430+
instance->generic.cnt +=
431+
((furi_hal_subghz_get_rolling_counter_mult() & 0xFFFFFFF));
432+
}
433+
}
410434
}
411-
// --- instead of :
412-
//instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
413-
//ToDo it is not known what value the counter starts
414-
//if(instance->generic.cnt > 0xFFFFFFF) instance->generic.cnt = 0xE500000;
415435

416436
uint32_t rolling = subghz_protocol_blocks_reverse_key(instance->generic.cnt, 28);
417437

0 commit comments

Comments
 (0)