diff --git a/applications/main/subghz/scenes/subghz_scene_signal_settings.c b/applications/main/subghz/scenes/subghz_scene_signal_settings.c index cec11533b..0bb48883f 100644 --- a/applications/main/subghz/scenes/subghz_scene_signal_settings.c +++ b/applications/main/subghz/scenes/subghz_scene_signal_settings.c @@ -334,11 +334,9 @@ bool subghz_scene_signal_settings_on_event(void* context, SceneManagerEvent even // convert back after byte_input and do one send with our new mult (counter16) - at end we must have signal Cnt = counter16 counter16 = __bswap16(counter16); - if(counter16 > 0) { - furi_hal_subghz_set_rolling_counter_mult(counter16); - subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx)); - subghz_txrx_stop(subghz->txrx); - } + furi_hal_subghz_set_rolling_counter_mult(counter16); + subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx)); + subghz_txrx_stop(subghz->txrx); // restore user definded counter increase value (mult) furi_hal_subghz_set_rolling_counter_mult(tmp_counter); @@ -360,11 +358,9 @@ bool subghz_scene_signal_settings_on_event(void* context, SceneManagerEvent even counter32 = __bswap32(counter32); - if(counter32 > 0) { - furi_hal_subghz_set_rolling_counter_mult(counter32); - subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx)); - subghz_txrx_stop(subghz->txrx); - } + furi_hal_subghz_set_rolling_counter_mult(counter32); + subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx)); + subghz_txrx_stop(subghz->txrx); furi_hal_subghz_set_rolling_counter_mult(tmp_counter); break; diff --git a/lib/subghz/protocols/secplus_v2.c b/lib/subghz/protocols/secplus_v2.c index 5d8980efb..ce1968029 100644 --- a/lib/subghz/protocols/secplus_v2.c +++ b/lib/subghz/protocols/secplus_v2.c @@ -401,17 +401,37 @@ static void subghz_protocol_secplus_v2_encode(SubGhzProtocolEncoderSecPlus_v2* i uint8_t roll_1[9] = {0}; uint8_t roll_2[9] = {0}; - // ---Experemental case - we dont know counter size exactly, so just will be think that is "FF FF FF F" - if((instance->generic.cnt + (furi_hal_subghz_get_rolling_counter_mult() & 0xFFFFFFF)) > - 0xFFFFFFF) { - instance->generic.cnt = 0xE500000; + // Experemental case - we dont know counter size exactly, so just will be think that it is in range of 0xE500000 - 0xFFFFFFF + // one case when we have mult = 0xFFFFFFFF - its when we reset counter before aplaying new cnt value + // so at first step we reset cnt to 0 and now we sure here will be second step (set new cnt value); + // at second step check what user set for new Cnt (and correct it if cnt less than 0xE500000 or more than 0xFFFFFFF) + if(((int32_t)furi_hal_subghz_get_rolling_counter_mult() == (int32_t)0xFFFFFFFF) & + (instance->generic.cnt != 0)) { + instance->generic.cnt = 0; } else { - instance->generic.cnt += (furi_hal_subghz_get_rolling_counter_mult() & 0xFFFFFFF); + // 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 + if(instance->generic.cnt == 0) { + if((uint32_t)furi_hal_subghz_get_rolling_counter_mult() < (uint32_t)0xE500000) { + instance->generic.cnt = 0xE500000; + } else { + if((uint32_t)furi_hal_subghz_get_rolling_counter_mult() > (uint32_t)0xFFFFFFF) { + instance->generic.cnt = 0xFFFFFFF; + } else { + instance->generic.cnt += + ((furi_hal_subghz_get_rolling_counter_mult() & 0xFFFFFFF)); + } + } + } else { + // if we have not special cases - so work as standart mode + if((instance->generic.cnt + (furi_hal_subghz_get_rolling_counter_mult() & 0xFFFFFFF)) > + 0xFFFFFFF) { + instance->generic.cnt = 0xE500000; + } else { + instance->generic.cnt += + ((furi_hal_subghz_get_rolling_counter_mult() & 0xFFFFFFF)); + } + } } - // --- instead of : - //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);