From 267140b161ea8f59db40baca409ccd21813ec00a Mon Sep 17 00:00:00 2001 From: Dmitry422 Date: Fri, 23 Jan 2026 18:59:14 +0700 Subject: [PATCH 1/9] work to home --- .../drivers/subghz/cc1101_ext/cc1101_ext.c | 19 +++-- .../main/subghz/helpers/subghz_txrx.c | 5 -- .../subghz/scenes/subghz_scene_transmitter.c | 67 ++++++++++----- applications/main/subghz/views/transmitter.c | 28 ++++--- lib/subghz/protocols/alutech_at_4n.c | 7 +- lib/subghz/protocols/ansonic.c | 5 +- lib/subghz/protocols/beninca_arc.c | 7 +- lib/subghz/protocols/bett.c | 5 +- lib/subghz/protocols/bin_raw.c | 7 +- lib/subghz/protocols/came.c | 7 +- lib/subghz/protocols/came_atomo.c | 7 +- lib/subghz/protocols/came_twee.c | 7 +- lib/subghz/protocols/chamberlain_code.c | 5 +- lib/subghz/protocols/clemsa.c | 5 +- lib/subghz/protocols/dickert_mahs.c | 7 +- lib/subghz/protocols/doitrand.c | 7 +- lib/subghz/protocols/dooya.c | 7 +- lib/subghz/protocols/elplast.c | 7 +- lib/subghz/protocols/faac_slh.c | 7 +- lib/subghz/protocols/feron.c | 7 +- lib/subghz/protocols/gangqi.c | 7 +- lib/subghz/protocols/gate_tx.c | 5 +- lib/subghz/protocols/hay21.c | 7 +- lib/subghz/protocols/hollarm.c | 7 +- lib/subghz/protocols/holtek.c | 7 +- lib/subghz/protocols/holtek_ht12x.c | 7 +- lib/subghz/protocols/honeywell.c | 7 +- lib/subghz/protocols/honeywell_wdb.c | 7 +- lib/subghz/protocols/hormann.c | 9 +-- lib/subghz/protocols/intertechno_v3.c | 7 +- lib/subghz/protocols/keeloq.c | 7 +- lib/subghz/protocols/kinggates_stylo_4k.c | 7 +- lib/subghz/protocols/linear.c | 5 +- lib/subghz/protocols/linear_delta3.c | 5 +- lib/subghz/protocols/magellan.c | 7 +- lib/subghz/protocols/marantec.c | 7 +- lib/subghz/protocols/marantec24.c | 7 +- lib/subghz/protocols/mastercode.c | 5 +- lib/subghz/protocols/megacode.c | 5 +- lib/subghz/protocols/nero_radio.c | 7 +- lib/subghz/protocols/nero_sketch.c | 7 +- lib/subghz/protocols/nice_flo.c | 5 +- lib/subghz/protocols/nice_flor_s.c | 7 +- lib/subghz/protocols/phoenix_v2.c | 7 +- lib/subghz/protocols/power_smart.c | 7 +- lib/subghz/protocols/revers_rb2.c | 7 +- lib/subghz/protocols/roger.c | 7 +- lib/subghz/protocols/secplus_v1.c | 7 +- lib/subghz/protocols/secplus_v2.c | 7 +- lib/subghz/protocols/smc5326.c | 7 +- lib/subghz/protocols/somfy_keytis.c | 7 +- lib/subghz/protocols/somfy_telis.c | 7 +- lib/subghz/protocols/treadmill37.c | 7 +- targets/f7/furi_hal/furi_hal_subghz.c | 81 ++++++++++++------- 54 files changed, 219 insertions(+), 306 deletions(-) diff --git a/applications/drivers/subghz/cc1101_ext/cc1101_ext.c b/applications/drivers/subghz/cc1101_ext/cc1101_ext.c index abca098eb..40cfe0d4a 100644 --- a/applications/drivers/subghz/cc1101_ext/cc1101_ext.c +++ b/applications/drivers/subghz/cc1101_ext/cc1101_ext.c @@ -98,6 +98,8 @@ typedef struct { static SubGhzDeviceCC1101Ext* subghz_device_cc1101_ext = NULL; +bool subghz_device_cc1101_ext_is_async_tx_complete(void); + static bool subghz_device_cc1101_ext_check_init(void) { furi_assert(subghz_device_cc1101_ext->state == SubGhzDeviceCC1101ExtStateInit); subghz_device_cc1101_ext->state = SubGhzDeviceCC1101ExtStateIdle; @@ -794,15 +796,20 @@ bool subghz_device_cc1101_ext_start_async_tx(SubGhzDeviceCC1101ExtCallback callb subghz_device_cc1101_ext->async_tx.buffer = malloc(SUBGHZ_DEVICE_CC1101_EXT_ASYNC_TX_BUFFER_FULL * sizeof(uint32_t)); + // here we do the same things as in /unleashed-firmware/targets/f7/furi_hal/furi_hal_subghz.c + // use first DMA to update timer TIM17 durations, but TIM17 have not output chanel + // so we use second DMA to transfer data from gpio_tx_buff directly to gpio pin using BSSR. + // BSSR allow us tranfer data directly to pin in gpio port. + //Signal generation with mem-to-mem DMA furi_hal_gpio_write(subghz_device_cc1101_ext->g0_pin, false); furi_hal_gpio_init( subghz_device_cc1101_ext->g0_pin, GpioModeOutputPushPull, GpioPullNo, GpioSpeedVeryHigh); - // Configure DMA update timer + // Configure DMA to update timer TIM17 ARR by durations from buffer LL_DMA_SetMemoryAddress( SUBGHZ_DEVICE_CC1101_EXT_DMA_CH3_DEF, (uint32_t)subghz_device_cc1101_ext->async_tx.buffer); - LL_DMA_SetPeriphAddress(SUBGHZ_DEVICE_CC1101_EXT_DMA_CH3_DEF, (uint32_t) & (TIM17->ARR)); + LL_DMA_SetPeriphAddress(SUBGHZ_DEVICE_CC1101_EXT_DMA_CH3_DEF, (uint32_t)&(TIM17->ARR)); LL_DMA_ConfigTransfer( SUBGHZ_DEVICE_CC1101_EXT_DMA_CH3_DEF, LL_DMA_DIRECTION_MEMORY_TO_PERIPH | LL_DMA_MODE_CIRCULAR | LL_DMA_PERIPH_NOINCREMENT | @@ -821,7 +828,7 @@ bool subghz_device_cc1101_ext_start_async_tx(SubGhzDeviceCC1101ExtCallback callb furi_hal_bus_enable(FuriHalBusTIM17); - // Configure TIM + // Configure TIM 17 // Set the timer resolution to 2 us LL_TIM_SetCounterMode(TIM17, LL_TIM_COUNTERMODE_UP); LL_TIM_SetClockDivision(TIM17, LL_TIM_CLOCKDIVISION_DIV1); @@ -835,7 +842,7 @@ bool subghz_device_cc1101_ext_start_async_tx(SubGhzDeviceCC1101ExtCallback callb subghz_device_cc1101_ext_async_tx_refill( subghz_device_cc1101_ext->async_tx.buffer, SUBGHZ_DEVICE_CC1101_EXT_ASYNC_TX_BUFFER_FULL); - // Configure tx gpio dma + // Configure DMA to transfer data from gpio_tx_buff directly to gpio pin using BSSR const GpioPin* gpio = subghz_device_cc1101_ext->g0_pin; subghz_device_cc1101_ext->async_tx.gpio_tx_buff[0] = (uint32_t)gpio->pin << GPIO_NUMBER; @@ -844,7 +851,7 @@ bool subghz_device_cc1101_ext_start_async_tx(SubGhzDeviceCC1101ExtCallback callb LL_DMA_SetMemoryAddress( SUBGHZ_DEVICE_CC1101_EXT_DMA_CH4_DEF, (uint32_t)subghz_device_cc1101_ext->async_tx.gpio_tx_buff); - LL_DMA_SetPeriphAddress(SUBGHZ_DEVICE_CC1101_EXT_DMA_CH4_DEF, (uint32_t) & (gpio->port->BSRR)); + LL_DMA_SetPeriphAddress(SUBGHZ_DEVICE_CC1101_EXT_DMA_CH4_DEF, (uint32_t)&(gpio->port->BSRR)); LL_DMA_ConfigTransfer( SUBGHZ_DEVICE_CC1101_EXT_DMA_CH4_DEF, LL_DMA_DIRECTION_MEMORY_TO_PERIPH | LL_DMA_MODE_CIRCULAR | LL_DMA_PERIPH_NOINCREMENT | @@ -864,7 +871,7 @@ bool subghz_device_cc1101_ext_start_async_tx(SubGhzDeviceCC1101ExtCallback callb SUBGHZ_DEVICE_CC1101_EXT_DMA_CH5_DEF, (uint32_t)subghz_device_cc1101_ext->async_tx.debug_gpio_buff); LL_DMA_SetPeriphAddress( - SUBGHZ_DEVICE_CC1101_EXT_DMA_CH5_DEF, (uint32_t) & (gpio->port->BSRR)); + SUBGHZ_DEVICE_CC1101_EXT_DMA_CH5_DEF, (uint32_t)&(gpio->port->BSRR)); LL_DMA_ConfigTransfer( SUBGHZ_DEVICE_CC1101_EXT_DMA_CH5_DEF, LL_DMA_DIRECTION_MEMORY_TO_PERIPH | LL_DMA_MODE_CIRCULAR | LL_DMA_PERIPH_NOINCREMENT | diff --git a/applications/main/subghz/helpers/subghz_txrx.c b/applications/main/subghz/helpers/subghz_txrx.c index 8abf373f4..ca3f0b300 100644 --- a/applications/main/subghz/helpers/subghz_txrx.c +++ b/applications/main/subghz/helpers/subghz_txrx.c @@ -234,7 +234,6 @@ SubGhzTxRxStartTxState subghz_txrx_tx_start(SubGhzTxRx* instance, FlipperFormat* SubGhzTxRxStartTxState ret = SubGhzTxRxStartTxStateErrorParserOthers; FuriString* temp_str = furi_string_alloc(); - uint32_t repeat = 200; do { if(!flipper_format_rewind(flipper_format)) { FURI_LOG_E(TAG, "Rewind error"); @@ -244,10 +243,6 @@ SubGhzTxRxStartTxState subghz_txrx_tx_start(SubGhzTxRx* instance, FlipperFormat* FURI_LOG_E(TAG, "Missing Protocol"); break; } - if(!flipper_format_insert_or_update_uint32(flipper_format, "Repeat", &repeat, 1)) { - FURI_LOG_E(TAG, "Unable Repeat"); - break; - } ret = SubGhzTxRxStartTxStateOk; SubGhzRadioPreset* preset = instance->preset; diff --git a/applications/main/subghz/scenes/subghz_scene_transmitter.c b/applications/main/subghz/scenes/subghz_scene_transmitter.c index ebd69059f..e7514ac92 100644 --- a/applications/main/subghz/scenes/subghz_scene_transmitter.c +++ b/applications/main/subghz/scenes/subghz_scene_transmitter.c @@ -3,7 +3,7 @@ #include #include - +#include #define TAG "SubGhzSceneTransmitter" void subghz_scene_transmitter_callback(SubGhzCustomEvent event, void* context) { @@ -72,25 +72,56 @@ bool subghz_scene_transmitter_on_event(void* context, SceneManagerEvent event) { subghz->state_notifications = SubGhzNotificationStateTx; subghz_scene_transmitter_update_data_show(subghz); dolphin_deed(DolphinDeedSubGhzSend); + + // #subghz_one_press_send# - keyword to search changes + // #start insert# + + // TODO change while condition to subghz_devices_is_async_complete_tx(subghz->txrx->radio_device); + // while( + // !(furi_hal_subghz_is_async_tx_complete() && + // subghz_device_cc1101_ext_is_async_tx_complete())) { + // notification_message(subghz->notifications, &sequence_blink_magenta_10); + // } + + while(!furi_hal_subghz_is_async_tx_complete()) { + notification_message(subghz->notifications, &sequence_blink_magenta_10); + } + subghz->state_notifications = SubGhzNotificationStateIDLE; + subghz_txrx_stop(subghz->txrx); + if(subghz_custom_btn_get() != SUBGHZ_CUSTOM_BTN_OK) { + subghz_custom_btn_set(SUBGHZ_CUSTOM_BTN_OK); + int32_t tmp_counter = furi_hal_subghz_get_rolling_counter_mult(); + furi_hal_subghz_set_rolling_counter_mult(0); + // Calling restore! + subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx)); + subghz_txrx_stop(subghz->txrx); + // Calling restore 2nd time special for FAAC SLH! + // TODO: Find better way to restore after custom button is used!!! + 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); + } + // #end insert# } return true; - } else if(event.event == SubGhzCustomEventViewTransmitterSendStop) { - subghz->state_notifications = SubGhzNotificationStateIDLE; - subghz_txrx_stop(subghz->txrx); - if(subghz_custom_btn_get() != SUBGHZ_CUSTOM_BTN_OK) { - subghz_custom_btn_set(SUBGHZ_CUSTOM_BTN_OK); - int32_t tmp_counter = furi_hal_subghz_get_rolling_counter_mult(); - furi_hal_subghz_set_rolling_counter_mult(0); - // Calling restore! - subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx)); - subghz_txrx_stop(subghz->txrx); - // Calling restore 2nd time special for FAAC SLH! - // TODO: Find better way to restore after custom button is used!!! - 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); - } - return true; + // #subghz_one_press_send# - keyword to search changes + // } else if(event.event == SubGhzCustomEventViewTransmitterSendStop) { + // subghz->state_notifications = SubGhzNotificationStateIDLE; + // subghz_txrx_stop(subghz->txrx); + // if(subghz_custom_btn_get() != SUBGHZ_CUSTOM_BTN_OK) { + // subghz_custom_btn_set(SUBGHZ_CUSTOM_BTN_OK); + // int32_t tmp_counter = furi_hal_subghz_get_rolling_counter_mult(); + // furi_hal_subghz_set_rolling_counter_mult(0); + // // Calling restore! + // subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx)); + // subghz_txrx_stop(subghz->txrx); + // // Calling restore 2nd time special for FAAC SLH! + // // TODO: Find better way to restore after custom button is used!!! + // 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); + // } + // return true; } else if(event.event == SubGhzCustomEventViewTransmitterBack) { subghz->state_notifications = SubGhzNotificationStateIDLE; scene_manager_search_and_switch_to_previous_scene( diff --git a/applications/main/subghz/views/transmitter.c b/applications/main/subghz/views/transmitter.c index 9faa703b6..455ab63a5 100644 --- a/applications/main/subghz/views/transmitter.c +++ b/applications/main/subghz/views/transmitter.c @@ -6,6 +6,9 @@ #include +#include +#include + struct SubGhzViewTransmitter { View* view; SubGhzViewTransmitterCallback callback; @@ -155,7 +158,10 @@ bool subghz_view_transmitter_input(InputEvent* event, void* context) { true); if(can_be_sent) { - if(event->key == InputKeyOk && event->type == InputTypePress) { + // #subghz_one_press_send# - keyword to search changes + bool allow_events = furi_hal_subghz_is_async_tx_complete() && subghz_device_cc1101_ext_is_async_tx_complete (); + // # + if(event->key == InputKeyOk && event->type == InputTypePress && allow_events) { subghz_custom_btn_set(SUBGHZ_CUSTOM_BTN_OK); with_view_model( subghz_transmitter->view, @@ -168,10 +174,11 @@ bool subghz_view_transmitter_input(InputEvent* event, void* context) { subghz_transmitter->callback( SubGhzCustomEventViewTransmitterSendStart, subghz_transmitter->context); return true; - } else if(event->key == InputKeyOk && event->type == InputTypeRelease) { - subghz_transmitter->callback( - SubGhzCustomEventViewTransmitterSendStop, subghz_transmitter->context); - return true; + // #subghz_one_press_send# - keyword to search changes + // } else if(event->key == InputKeyOk && event->type == InputTypeRelease) { + // subghz_transmitter->callback( + // SubGhzCustomEventViewTransmitterSendStop, subghz_transmitter->context); + // return true; } // Finish "OK" key processing if(subghz_custom_btn_is_allowed()) { @@ -189,7 +196,7 @@ bool subghz_view_transmitter_input(InputEvent* event, void* context) { return true; } - if(event->type == InputTypePress) { + if(event->type == InputTypePress && allow_events) { with_view_model( subghz_transmitter->view, SubGhzViewTransmitterModel * model, @@ -209,10 +216,11 @@ bool subghz_view_transmitter_input(InputEvent* event, void* context) { subghz_transmitter->callback( SubGhzCustomEventViewTransmitterSendStart, subghz_transmitter->context); return true; - } else if(event->type == InputTypeRelease) { - subghz_transmitter->callback( - SubGhzCustomEventViewTransmitterSendStop, subghz_transmitter->context); - return true; + // #subghz_one_press_send# - keyword to search changes + // } else if(event->type == InputTypeRelease) { + // subghz_transmitter->callback( + // SubGhzCustomEventViewTransmitterSendStop, subghz_transmitter->context); + // return true; } } } diff --git a/lib/subghz/protocols/alutech_at_4n.c b/lib/subghz/protocols/alutech_at_4n.c index 8dff70dd1..b442f61c9 100644 --- a/lib/subghz/protocols/alutech_at_4n.c +++ b/lib/subghz/protocols/alutech_at_4n.c @@ -95,7 +95,7 @@ void* subghz_protocol_encoder_alutech_at_4n_alloc(SubGhzEnvironment* environment instance->base.protocol = &subghz_protocol_alutech_at_4n; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 10; + instance->encoder.repeat = 2; instance->encoder.size_upload = 512; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; @@ -483,10 +483,7 @@ SubGhzProtocolStatus subghz_protocol_encoder_alutech_at_4n_deserialize( break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + if(!flipper_format_rewind(flipper_format)) { FURI_LOG_E(TAG, "Rewind error"); break; diff --git a/lib/subghz/protocols/ansonic.c b/lib/subghz/protocols/ansonic.c index 75f803370..7ad0732d6 100644 --- a/lib/subghz/protocols/ansonic.c +++ b/lib/subghz/protocols/ansonic.c @@ -150,10 +150,7 @@ SubGhzProtocolStatus FURI_LOG_E(TAG, "Deserialize error"); break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + if(!subghz_protocol_encoder_ansonic_get_upload(instance)) { res = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/beninca_arc.c b/lib/subghz/protocols/beninca_arc.c index 62eb925f8..d269aaa47 100644 --- a/lib/subghz/protocols/beninca_arc.c +++ b/lib/subghz/protocols/beninca_arc.c @@ -256,7 +256,7 @@ void* subghz_protocol_encoder_beninca_arc_alloc(SubGhzEnvironment* environment) instance->generic.protocol_name = instance->base.protocol->name; instance->keystore = subghz_environment_get_keystore(environment); - instance->encoder.repeat = 10; + instance->encoder.repeat = 2; instance->encoder.size_upload = 800; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; @@ -412,10 +412,7 @@ SubGhzProtocolStatus break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + if(!flipper_format_rewind(flipper_format)) { FURI_LOG_E(TAG, "Rewind error"); break; diff --git a/lib/subghz/protocols/bett.c b/lib/subghz/protocols/bett.c index 44946a2f6..173671aaa 100644 --- a/lib/subghz/protocols/bett.c +++ b/lib/subghz/protocols/bett.c @@ -169,10 +169,7 @@ SubGhzProtocolStatus FURI_LOG_E(TAG, "Deserialize error"); break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + if(!subghz_protocol_encoder_bett_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/bin_raw.c b/lib/subghz/protocols/bin_raw.c index ca52cdd49..4753d467c 100644 --- a/lib/subghz/protocols/bin_raw.c +++ b/lib/subghz/protocols/bin_raw.c @@ -142,7 +142,7 @@ void* subghz_protocol_encoder_bin_raw_alloc(SubGhzEnvironment* environment) { instance->base.protocol = &subghz_protocol_bin_raw; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 10; + instance->encoder.repeat = 2; instance->encoder.size_upload = BIN_RAW_BUF_DATA_SIZE * 5; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->data = malloc(instance->encoder.size_upload * sizeof(uint8_t)); @@ -309,10 +309,7 @@ SubGhzProtocolStatus res = SubGhzProtocolStatusErrorParserOthers; break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + if(!subghz_protocol_encoder_bin_raw_get_upload(instance)) { res = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/came.c b/lib/subghz/protocols/came.c index 2762a2484..5037f1a4b 100644 --- a/lib/subghz/protocols/came.c +++ b/lib/subghz/protocols/came.c @@ -90,7 +90,7 @@ void* subghz_protocol_encoder_came_alloc(SubGhzEnvironment* environment) { instance->base.protocol = &subghz_protocol_came; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 10; + instance->encoder.repeat = 5; instance->encoder.size_upload = 128; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; @@ -181,10 +181,7 @@ SubGhzProtocolStatus ret = SubGhzProtocolStatusErrorValueBitCount; break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + if(!subghz_protocol_encoder_came_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/came_atomo.c b/lib/subghz/protocols/came_atomo.c index f8ec7baa0..60d1e93a5 100644 --- a/lib/subghz/protocols/came_atomo.c +++ b/lib/subghz/protocols/came_atomo.c @@ -89,7 +89,7 @@ void* subghz_protocol_encoder_came_atomo_alloc(SubGhzEnvironment* environment) { instance->base.protocol = &subghz_protocol_came_atomo; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 10; + instance->encoder.repeat = 2; instance->encoder.size_upload = 900; //actual size 766+ instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; @@ -374,10 +374,7 @@ SubGhzProtocolStatus break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + if(!flipper_format_rewind(flipper_format)) { FURI_LOG_E(TAG, "Rewind error"); break; diff --git a/lib/subghz/protocols/came_twee.c b/lib/subghz/protocols/came_twee.c index 3bb909dc8..c2af278ea 100644 --- a/lib/subghz/protocols/came_twee.c +++ b/lib/subghz/protocols/came_twee.c @@ -109,7 +109,7 @@ void* subghz_protocol_encoder_came_twee_alloc(SubGhzEnvironment* environment) { instance->base.protocol = &subghz_protocol_came_twee; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 10; + instance->encoder.repeat = 1; instance->encoder.size_upload = 1536; //max upload 92*14 = 1288 !!!! instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; @@ -254,10 +254,7 @@ SubGhzProtocolStatus if(res != SubGhzProtocolStatusOk) { break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + subghz_protocol_came_twee_remote_controller(&instance->generic); subghz_protocol_encoder_came_twee_get_upload(instance); instance->encoder.front = 0; // reset position before start diff --git a/lib/subghz/protocols/chamberlain_code.c b/lib/subghz/protocols/chamberlain_code.c index fda224bb6..d01c80c2e 100644 --- a/lib/subghz/protocols/chamberlain_code.c +++ b/lib/subghz/protocols/chamberlain_code.c @@ -223,10 +223,7 @@ SubGhzProtocolStatus ret = SubGhzProtocolStatusErrorValueBitCount; break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + if(!subghz_protocol_encoder_chamb_code_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/clemsa.c b/lib/subghz/protocols/clemsa.c index 672abcba3..fecbd4dfd 100644 --- a/lib/subghz/protocols/clemsa.c +++ b/lib/subghz/protocols/clemsa.c @@ -168,10 +168,7 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + if(!subghz_protocol_encoder_clemsa_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/dickert_mahs.c b/lib/subghz/protocols/dickert_mahs.c index 65be6fd0c..ac00fd28a 100644 --- a/lib/subghz/protocols/dickert_mahs.c +++ b/lib/subghz/protocols/dickert_mahs.c @@ -132,7 +132,7 @@ void* subghz_protocol_encoder_dickert_mahs_alloc(SubGhzEnvironment* environment) instance->base.protocol = &subghz_protocol_dickert_mahs; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 10; + instance->encoder.repeat = 5; instance->encoder.size_upload = 128; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; @@ -207,10 +207,7 @@ SubGhzProtocolStatus ret = SubGhzProtocolStatusErrorValueBitCount; break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + if(!subghz_protocol_encoder_dickert_mahs_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/doitrand.c b/lib/subghz/protocols/doitrand.c index 7c7946042..ab700f5ad 100644 --- a/lib/subghz/protocols/doitrand.c +++ b/lib/subghz/protocols/doitrand.c @@ -82,7 +82,7 @@ void* subghz_protocol_encoder_doitrand_alloc(SubGhzEnvironment* environment) { instance->base.protocol = &subghz_protocol_doitrand; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 10; + instance->encoder.repeat = 5; instance->encoder.size_upload = 128; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; @@ -149,10 +149,7 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + if(!subghz_protocol_encoder_doitrand_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/dooya.c b/lib/subghz/protocols/dooya.c index fd8645a0b..76d2bac60 100644 --- a/lib/subghz/protocols/dooya.c +++ b/lib/subghz/protocols/dooya.c @@ -77,7 +77,7 @@ void* subghz_protocol_encoder_dooya_alloc(SubGhzEnvironment* environment) { instance->base.protocol = &subghz_protocol_dooya; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 10; + instance->encoder.repeat = 5; instance->encoder.size_upload = 128; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; @@ -159,10 +159,7 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + if(!subghz_protocol_encoder_dooya_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/elplast.c b/lib/subghz/protocols/elplast.c index 18d6d07b4..a9bd29562 100644 --- a/lib/subghz/protocols/elplast.c +++ b/lib/subghz/protocols/elplast.c @@ -73,7 +73,7 @@ void* subghz_protocol_encoder_elplast_alloc(SubGhzEnvironment* environment) { instance->base.protocol = &subghz_protocol_elplast; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 10; + instance->encoder.repeat = 3; instance->encoder.size_upload = 256; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; @@ -141,10 +141,7 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + subghz_protocol_encoder_elplast_get_upload(instance); instance->encoder.is_running = true; } while(false); diff --git a/lib/subghz/protocols/faac_slh.c b/lib/subghz/protocols/faac_slh.c index 147e452eb..d0cfc721c 100644 --- a/lib/subghz/protocols/faac_slh.c +++ b/lib/subghz/protocols/faac_slh.c @@ -109,7 +109,7 @@ void* subghz_protocol_encoder_faac_slh_alloc(SubGhzEnvironment* environment) { instance->generic.protocol_name = instance->base.protocol->name; instance->keystore = subghz_environment_get_keystore(environment); - instance->encoder.repeat = 10; + instance->encoder.repeat = 3; instance->encoder.size_upload = 256; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; @@ -398,10 +398,7 @@ SubGhzProtocolStatus subghz_protocol_faac_slh_check_remote_controller( &instance->generic, instance->keystore, &instance->manufacture_name); - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + subghz_protocol_encoder_faac_slh_get_upload(instance); if(!flipper_format_rewind(flipper_format)) { diff --git a/lib/subghz/protocols/feron.c b/lib/subghz/protocols/feron.c index 9591a4ebb..f7d653f4c 100644 --- a/lib/subghz/protocols/feron.c +++ b/lib/subghz/protocols/feron.c @@ -74,7 +74,7 @@ void* subghz_protocol_encoder_feron_alloc(SubGhzEnvironment* environment) { instance->base.protocol = &subghz_protocol_feron; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 10; + instance->encoder.repeat = 3; instance->encoder.size_upload = 256; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; @@ -160,10 +160,7 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + subghz_protocol_feron_check_remote_controller(&instance->generic); subghz_protocol_encoder_feron_get_upload(instance); instance->encoder.is_running = true; diff --git a/lib/subghz/protocols/gangqi.c b/lib/subghz/protocols/gangqi.c index 6b5542410..f78b37aac 100644 --- a/lib/subghz/protocols/gangqi.c +++ b/lib/subghz/protocols/gangqi.c @@ -76,7 +76,7 @@ void* subghz_protocol_encoder_gangqi_alloc(SubGhzEnvironment* environment) { instance->base.protocol = &subghz_protocol_gangqi; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 10; + instance->encoder.repeat = 3; instance->encoder.size_upload = 256; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; @@ -253,10 +253,7 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + subghz_protocol_gangqi_remote_controller(&instance->generic); subghz_protocol_encoder_gangqi_get_upload(instance); diff --git a/lib/subghz/protocols/gate_tx.c b/lib/subghz/protocols/gate_tx.c index 608567626..08f6f3f41 100644 --- a/lib/subghz/protocols/gate_tx.c +++ b/lib/subghz/protocols/gate_tx.c @@ -142,10 +142,7 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + if(!subghz_protocol_encoder_gate_tx_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/hay21.c b/lib/subghz/protocols/hay21.c index ba6119dae..8a0280168 100644 --- a/lib/subghz/protocols/hay21.c +++ b/lib/subghz/protocols/hay21.c @@ -75,7 +75,7 @@ void* subghz_protocol_encoder_hay21_alloc(SubGhzEnvironment* environment) { instance->base.protocol = &subghz_protocol_hay21; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 10; + instance->encoder.repeat = 3; instance->encoder.size_upload = 256; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; @@ -267,10 +267,7 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + subghz_protocol_hay21_remote_controller(&instance->generic); subghz_protocol_encoder_hay21_get_upload(instance); diff --git a/lib/subghz/protocols/hollarm.c b/lib/subghz/protocols/hollarm.c index 9b2a53a05..b03de5b72 100644 --- a/lib/subghz/protocols/hollarm.c +++ b/lib/subghz/protocols/hollarm.c @@ -76,7 +76,7 @@ void* subghz_protocol_encoder_hollarm_alloc(SubGhzEnvironment* environment) { instance->base.protocol = &subghz_protocol_hollarm; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 10; + instance->encoder.repeat = 3; instance->encoder.size_upload = 256; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; @@ -254,10 +254,7 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + subghz_protocol_hollarm_remote_controller(&instance->generic); subghz_protocol_encoder_hollarm_get_upload(instance); diff --git a/lib/subghz/protocols/holtek.c b/lib/subghz/protocols/holtek.c index 7ed5fc152..2735702c5 100644 --- a/lib/subghz/protocols/holtek.c +++ b/lib/subghz/protocols/holtek.c @@ -86,7 +86,7 @@ void* subghz_protocol_encoder_holtek_alloc(SubGhzEnvironment* environment) { instance->base.protocol = &subghz_protocol_holtek; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 10; + instance->encoder.repeat = 5; instance->encoder.size_upload = 128; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; @@ -155,10 +155,7 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + if(!subghz_protocol_encoder_holtek_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/holtek_ht12x.c b/lib/subghz/protocols/holtek_ht12x.c index bf5e48adf..bf4724130 100644 --- a/lib/subghz/protocols/holtek_ht12x.c +++ b/lib/subghz/protocols/holtek_ht12x.c @@ -94,7 +94,7 @@ void* subghz_protocol_encoder_holtek_th12x_alloc(SubGhzEnvironment* environment) instance->base.protocol = &subghz_protocol_holtek_th12x; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 10; + instance->encoder.repeat = 5; instance->encoder.size_upload = 128; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; @@ -170,10 +170,7 @@ SubGhzProtocolStatus ret = SubGhzProtocolStatusErrorParserTe; break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + if(!subghz_protocol_encoder_holtek_th12x_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/honeywell.c b/lib/subghz/protocols/honeywell.c index 1e3f231e8..7343648d7 100644 --- a/lib/subghz/protocols/honeywell.c +++ b/lib/subghz/protocols/honeywell.c @@ -98,7 +98,7 @@ void* subghz_protocol_encoder_honeywell_alloc(SubGhzEnvironment* environment) { instance->base.protocol = &subghz_protocol_honeywell; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 4; + instance->encoder.repeat = 5; instance->encoder.size_upload = 64 * 2 + 10; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; @@ -211,10 +211,7 @@ SubGhzProtocolStatus break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + subghz_protocol_encoder_honeywell_get_upload(instance); if(!flipper_format_rewind(flipper_format)) { diff --git a/lib/subghz/protocols/honeywell_wdb.c b/lib/subghz/protocols/honeywell_wdb.c index 0b8f63a24..0a2cd53d6 100644 --- a/lib/subghz/protocols/honeywell_wdb.c +++ b/lib/subghz/protocols/honeywell_wdb.c @@ -88,7 +88,7 @@ void* subghz_protocol_encoder_honeywell_wdb_alloc(SubGhzEnvironment* environment instance->base.protocol = &subghz_protocol_honeywell_wdb; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 10; + instance->encoder.repeat = 5; instance->encoder.size_upload = 128; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; @@ -156,10 +156,7 @@ SubGhzProtocolStatus subghz_protocol_encoder_honeywell_wdb_deserialize( if(ret != SubGhzProtocolStatusOk) { break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + if(!subghz_protocol_encoder_honeywell_wdb_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/hormann.c b/lib/subghz/protocols/hormann.c index f74a29fec..1ac9f6b0d 100644 --- a/lib/subghz/protocols/hormann.c +++ b/lib/subghz/protocols/hormann.c @@ -80,7 +80,7 @@ void* subghz_protocol_encoder_hormann_alloc(SubGhzEnvironment* environment) { instance->base.protocol = &subghz_protocol_hormann; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 10; + instance->encoder.repeat = 2; instance->encoder.size_upload = 2048; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; @@ -110,7 +110,7 @@ static bool subghz_protocol_encoder_hormann_get_upload(SubGhzProtocolEncoderHorm } else { instance->encoder.size_upload = size_upload; } - instance->encoder.repeat = 10; //original remote does 10 repeats + instance->encoder.repeat = 3; //original remote does 10 repeats for(size_t repeat = 0; repeat < 20; repeat++) { //Send start bit @@ -153,10 +153,7 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + if(!subghz_protocol_encoder_hormann_get_upload(instance)) { instance->encoder.front = 0; // reset position before start ret = SubGhzProtocolStatusErrorEncoderGetUpload; diff --git a/lib/subghz/protocols/intertechno_v3.c b/lib/subghz/protocols/intertechno_v3.c index 71513051b..85818763b 100644 --- a/lib/subghz/protocols/intertechno_v3.c +++ b/lib/subghz/protocols/intertechno_v3.c @@ -86,7 +86,7 @@ void* subghz_protocol_encoder_intertechno_v3_alloc(SubGhzEnvironment* environmen instance->base.protocol = &subghz_protocol_intertechno_v3; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 10; + instance->encoder.repeat = 3; instance->encoder.size_upload = 256; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; @@ -176,10 +176,7 @@ SubGhzProtocolStatus subghz_protocol_encoder_intertechno_v3_deserialize( ret = SubGhzProtocolStatusErrorValueBitCount; break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + if(!subghz_protocol_encoder_intertechno_v3_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/keeloq.c b/lib/subghz/protocols/keeloq.c index cd657f23f..39f957e24 100644 --- a/lib/subghz/protocols/keeloq.c +++ b/lib/subghz/protocols/keeloq.c @@ -107,7 +107,7 @@ void* subghz_protocol_encoder_keeloq_alloc(SubGhzEnvironment* environment) { instance->generic.protocol_name = instance->base.protocol->name; instance->keystore = subghz_environment_get_keystore(environment); - instance->encoder.repeat = 100; + instance->encoder.repeat = 3; instance->encoder.size_upload = 256; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; @@ -667,10 +667,7 @@ SubGhzProtocolStatus subghz_protocol_keeloq_check_remote_controller( &instance->generic, instance->keystore, &instance->manufacture_name); - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + if(!subghz_protocol_encoder_keeloq_get_upload(instance, instance->generic.btn)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/kinggates_stylo_4k.c b/lib/subghz/protocols/kinggates_stylo_4k.c index e23042b55..18fb91651 100644 --- a/lib/subghz/protocols/kinggates_stylo_4k.c +++ b/lib/subghz/protocols/kinggates_stylo_4k.c @@ -101,7 +101,7 @@ void* subghz_protocol_encoder_kinggates_stylo_4k_alloc(SubGhzEnvironment* enviro instance->generic.protocol_name = instance->base.protocol->name; instance->keystore = subghz_environment_get_keystore(environment); - instance->encoder.repeat = 10; + instance->encoder.repeat = 3; instance->encoder.size_upload = 512; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; @@ -344,10 +344,7 @@ SubGhzProtocolStatus subghz_protocol_encoder_kinggates_stylo_4k_deserialize( break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + if(!flipper_format_rewind(flipper_format)) { FURI_LOG_E(TAG, "Rewind error"); break; diff --git a/lib/subghz/protocols/linear.c b/lib/subghz/protocols/linear.c index f024316e9..e170c90ee 100644 --- a/lib/subghz/protocols/linear.c +++ b/lib/subghz/protocols/linear.c @@ -160,10 +160,7 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + if(!subghz_protocol_encoder_linear_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/linear_delta3.c b/lib/subghz/protocols/linear_delta3.c index c2f527ba8..b9b28c66a 100644 --- a/lib/subghz/protocols/linear_delta3.c +++ b/lib/subghz/protocols/linear_delta3.c @@ -164,10 +164,7 @@ SubGhzProtocolStatus subghz_protocol_encoder_linear_delta3_deserialize( if(ret != SubGhzProtocolStatusOk) { break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + if(!subghz_protocol_encoder_linear_delta3_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/magellan.c b/lib/subghz/protocols/magellan.c index 55048ca61..ef0c9d2ae 100644 --- a/lib/subghz/protocols/magellan.c +++ b/lib/subghz/protocols/magellan.c @@ -78,7 +78,7 @@ void* subghz_protocol_encoder_magellan_alloc(SubGhzEnvironment* environment) { instance->base.protocol = &subghz_protocol_magellan; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 10; + instance->encoder.repeat = 3; instance->encoder.size_upload = 256; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; @@ -164,10 +164,7 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + if(!subghz_protocol_encoder_magellan_get_upload(instance)) { instance->encoder.front = 0; // reset before start ret = SubGhzProtocolStatusErrorEncoderGetUpload; diff --git a/lib/subghz/protocols/marantec.c b/lib/subghz/protocols/marantec.c index 53e4d6895..02d6aa801 100644 --- a/lib/subghz/protocols/marantec.c +++ b/lib/subghz/protocols/marantec.c @@ -77,7 +77,7 @@ void* subghz_protocol_encoder_marantec_alloc(SubGhzEnvironment* environment) { instance->base.protocol = &subghz_protocol_marantec; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 10; + instance->encoder.repeat = 3; instance->encoder.size_upload = 256; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; @@ -213,10 +213,7 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + subghz_protocol_marantec_remote_controller(&instance->generic); subghz_protocol_encoder_marantec_get_upload(instance); instance->encoder.front = 0; diff --git a/lib/subghz/protocols/marantec24.c b/lib/subghz/protocols/marantec24.c index 6f636e8ab..63d8e7be2 100644 --- a/lib/subghz/protocols/marantec24.c +++ b/lib/subghz/protocols/marantec24.c @@ -73,7 +73,7 @@ void* subghz_protocol_encoder_marantec24_alloc(SubGhzEnvironment* environment) { instance->base.protocol = &subghz_protocol_marantec24; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 10; + instance->encoder.repeat = 3; instance->encoder.size_upload = 256; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; @@ -155,10 +155,7 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + subghz_protocol_marantec24_check_remote_controller(&instance->generic); subghz_protocol_encoder_marantec24_get_upload(instance); instance->encoder.is_running = true; diff --git a/lib/subghz/protocols/mastercode.c b/lib/subghz/protocols/mastercode.c index e4fae40b3..5a57d764e 100644 --- a/lib/subghz/protocols/mastercode.c +++ b/lib/subghz/protocols/mastercode.c @@ -168,10 +168,7 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + if(!subghz_protocol_encoder_mastercode_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/megacode.c b/lib/subghz/protocols/megacode.c index 2c4bf10a3..13cc99436 100644 --- a/lib/subghz/protocols/megacode.c +++ b/lib/subghz/protocols/megacode.c @@ -188,10 +188,7 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + if(!subghz_protocol_encoder_megacode_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/nero_radio.c b/lib/subghz/protocols/nero_radio.c index da5497feb..18fdfffa8 100644 --- a/lib/subghz/protocols/nero_radio.c +++ b/lib/subghz/protocols/nero_radio.c @@ -77,7 +77,7 @@ void* subghz_protocol_encoder_nero_radio_alloc(SubGhzEnvironment* environment) { instance->base.protocol = &subghz_protocol_nero_radio; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 10; + instance->encoder.repeat = 3; instance->encoder.size_upload = 256; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; @@ -180,10 +180,7 @@ SubGhzProtocolStatus break; } } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + if(!subghz_protocol_encoder_nero_radio_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/nero_sketch.c b/lib/subghz/protocols/nero_sketch.c index 64a75cfc0..0550cf801 100644 --- a/lib/subghz/protocols/nero_sketch.c +++ b/lib/subghz/protocols/nero_sketch.c @@ -76,7 +76,7 @@ void* subghz_protocol_encoder_nero_sketch_alloc(SubGhzEnvironment* environment) instance->base.protocol = &subghz_protocol_nero_sketch; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 10; + instance->encoder.repeat = 3; instance->encoder.size_upload = 256; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; @@ -161,10 +161,7 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + if(!subghz_protocol_encoder_nero_sketch_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/nice_flo.c b/lib/subghz/protocols/nice_flo.c index 2e5fa96b5..dc423fe83 100644 --- a/lib/subghz/protocols/nice_flo.c +++ b/lib/subghz/protocols/nice_flo.c @@ -147,10 +147,7 @@ SubGhzProtocolStatus ret = SubGhzProtocolStatusErrorValueBitCount; break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + if(!subghz_protocol_encoder_nice_flo_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/nice_flor_s.c b/lib/subghz/protocols/nice_flor_s.c index 9085ee431..59cf4d2cc 100644 --- a/lib/subghz/protocols/nice_flor_s.c +++ b/lib/subghz/protocols/nice_flor_s.c @@ -104,7 +104,7 @@ void* subghz_protocol_encoder_nice_flor_s_alloc(SubGhzEnvironment* environment) FURI_LOG_D( TAG, "Loading rainbow table from %s", instance->nice_flor_s_rainbow_table_file_name); } - instance->encoder.repeat = 10; + instance->encoder.repeat = 1; instance->encoder.size_upload = 2400; //wrong!! upload 186*16 = 2976 - actual size about 1728 instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; @@ -279,10 +279,7 @@ SubGhzProtocolStatus break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - // flipper_format_read_uint32( + // flipper_format_read_uint32( // flipper_format, "Data", (uint32_t*)&instance->generic.data_2, 1); if(!flipper_format_rewind(flipper_format)) { FURI_LOG_E(TAG, "Rewind error"); diff --git a/lib/subghz/protocols/phoenix_v2.c b/lib/subghz/protocols/phoenix_v2.c index 1f2731f54..c70b4cb00 100644 --- a/lib/subghz/protocols/phoenix_v2.c +++ b/lib/subghz/protocols/phoenix_v2.c @@ -77,7 +77,7 @@ void* subghz_protocol_encoder_phoenix_v2_alloc(SubGhzEnvironment* environment) { instance->base.protocol = &subghz_protocol_phoenix_v2; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 10; + instance->encoder.repeat = 5; instance->encoder.size_upload = 128; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; @@ -322,10 +322,7 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + subghz_protocol_phoenix_v2_check_remote_controller(&instance->generic); if(!subghz_protocol_encoder_phoenix_v2_get_upload(instance)) { diff --git a/lib/subghz/protocols/power_smart.c b/lib/subghz/protocols/power_smart.c index 6449f720a..ed237780e 100644 --- a/lib/subghz/protocols/power_smart.c +++ b/lib/subghz/protocols/power_smart.c @@ -85,7 +85,7 @@ void* subghz_protocol_encoder_power_smart_alloc(SubGhzEnvironment* environment) instance->base.protocol = &subghz_protocol_power_smart; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 10; + instance->encoder.repeat = 2; instance->encoder.size_upload = 1024; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; @@ -206,10 +206,7 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + subghz_protocol_power_smart_remote_controller(&instance->generic); subghz_protocol_encoder_power_smart_get_upload(instance); instance->encoder.front = 0; // reset before start diff --git a/lib/subghz/protocols/revers_rb2.c b/lib/subghz/protocols/revers_rb2.c index 941ff5c56..2e9aee592 100644 --- a/lib/subghz/protocols/revers_rb2.c +++ b/lib/subghz/protocols/revers_rb2.c @@ -78,7 +78,7 @@ void* subghz_protocol_encoder_revers_rb2_alloc(SubGhzEnvironment* environment) { instance->base.protocol = &subghz_protocol_revers_rb2; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 10; + instance->encoder.repeat = 5; instance->encoder.size_upload = 256; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; @@ -176,10 +176,7 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + subghz_protocol_revers_rb2_remote_controller(&instance->generic); subghz_protocol_encoder_revers_rb2_get_upload(instance); instance->encoder.is_running = true; diff --git a/lib/subghz/protocols/roger.c b/lib/subghz/protocols/roger.c index 9c33b11ec..30767db82 100644 --- a/lib/subghz/protocols/roger.c +++ b/lib/subghz/protocols/roger.c @@ -76,7 +76,7 @@ void* subghz_protocol_encoder_roger_alloc(SubGhzEnvironment* environment) { instance->base.protocol = &subghz_protocol_roger; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 10; + instance->encoder.repeat = 3; instance->encoder.size_upload = 256; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; @@ -265,10 +265,7 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + subghz_protocol_roger_check_remote_controller(&instance->generic); subghz_protocol_encoder_roger_get_upload(instance); diff --git a/lib/subghz/protocols/secplus_v1.c b/lib/subghz/protocols/secplus_v1.c index 13af0d302..460ff766e 100644 --- a/lib/subghz/protocols/secplus_v1.c +++ b/lib/subghz/protocols/secplus_v1.c @@ -98,7 +98,7 @@ void* subghz_protocol_encoder_secplus_v1_alloc(SubGhzEnvironment* environment) { instance->base.protocol = &subghz_protocol_secplus_v1; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 10; + instance->encoder.repeat = 5; instance->encoder.size_upload = 128; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; @@ -298,10 +298,7 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + if(!subghz_protocol_secplus_v1_encode(instance)) { ret = SubGhzProtocolStatusErrorParserOthers; break; diff --git a/lib/subghz/protocols/secplus_v2.c b/lib/subghz/protocols/secplus_v2.c index ad343968b..bcbf3183a 100644 --- a/lib/subghz/protocols/secplus_v2.c +++ b/lib/subghz/protocols/secplus_v2.c @@ -92,7 +92,7 @@ void* subghz_protocol_encoder_secplus_v2_alloc(SubGhzEnvironment* environment) { instance->base.protocol = &subghz_protocol_secplus_v2; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 10; + instance->encoder.repeat = 3; instance->encoder.size_upload = 256; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; @@ -574,10 +574,7 @@ SubGhzProtocolStatus subghz_protocol_secplus_v2_remote_controller( &instance->generic, instance->secplus_packet_1); subghz_protocol_secplus_v2_encode(instance); - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - subghz_protocol_encoder_secplus_v2_get_upload(instance); + subghz_protocol_encoder_secplus_v2_get_upload(instance); //update data for(size_t i = 0; i < sizeof(uint64_t); i++) { diff --git a/lib/subghz/protocols/smc5326.c b/lib/subghz/protocols/smc5326.c index 217dbb780..bf006e146 100644 --- a/lib/subghz/protocols/smc5326.c +++ b/lib/subghz/protocols/smc5326.c @@ -101,7 +101,7 @@ void* subghz_protocol_encoder_smc5326_alloc(SubGhzEnvironment* environment) { instance->base.protocol = &subghz_protocol_smc5326; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 10; + instance->encoder.repeat = 5; instance->encoder.size_upload = 128; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; @@ -178,10 +178,7 @@ SubGhzProtocolStatus ret = SubGhzProtocolStatusErrorParserTe; break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + if(!subghz_protocol_encoder_smc5326_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/somfy_keytis.c b/lib/subghz/protocols/somfy_keytis.c index c9f6f47bd..c462035c6 100644 --- a/lib/subghz/protocols/somfy_keytis.c +++ b/lib/subghz/protocols/somfy_keytis.c @@ -81,7 +81,7 @@ void* subghz_protocol_encoder_somfy_keytis_alloc(SubGhzEnvironment* environment) instance->base.protocol = &subghz_protocol_somfy_keytis; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 10; + instance->encoder.repeat = 3; instance->encoder.size_upload = 512; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; @@ -412,10 +412,7 @@ SubGhzProtocolStatus break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + subghz_protocol_encoder_somfy_keytis_get_upload(instance, instance->generic.btn); if(!flipper_format_rewind(flipper_format)) { diff --git a/lib/subghz/protocols/somfy_telis.c b/lib/subghz/protocols/somfy_telis.c index 2be378b7d..a4b756daa 100644 --- a/lib/subghz/protocols/somfy_telis.c +++ b/lib/subghz/protocols/somfy_telis.c @@ -82,7 +82,7 @@ void* subghz_protocol_encoder_somfy_telis_alloc(SubGhzEnvironment* environment) instance->base.protocol = &subghz_protocol_somfy_telis; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 10; + instance->encoder.repeat = 3; instance->encoder.size_upload = 512; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; @@ -341,10 +341,7 @@ SubGhzProtocolStatus break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + subghz_protocol_encoder_somfy_telis_get_upload(instance, instance->generic.btn); if(!flipper_format_rewind(flipper_format)) { diff --git a/lib/subghz/protocols/treadmill37.c b/lib/subghz/protocols/treadmill37.c index e9915c296..9784fe1e3 100644 --- a/lib/subghz/protocols/treadmill37.c +++ b/lib/subghz/protocols/treadmill37.c @@ -73,7 +73,7 @@ void* subghz_protocol_encoder_treadmill37_alloc(SubGhzEnvironment* environment) instance->base.protocol = &subghz_protocol_treadmill37; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 10; + instance->encoder.repeat = 3; instance->encoder.size_upload = 256; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; @@ -151,10 +151,7 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - // Optional value - flipper_format_read_uint32( - flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - + subghz_protocol_treadmill37_check_remote_controller(&instance->generic); subghz_protocol_encoder_treadmill37_get_upload(instance); instance->encoder.is_running = true; diff --git a/targets/f7/furi_hal/furi_hal_subghz.c b/targets/f7/furi_hal/furi_hal_subghz.c index dc6add277..0f8fa939c 100644 --- a/targets/f7/furi_hal/furi_hal_subghz.c +++ b/targets/f7/furi_hal/furi_hal_subghz.c @@ -684,6 +684,8 @@ static void furi_hal_subghz_async_tx_refill(uint32_t* buffer, size_t samples) { while(samples > 0) { volatile uint32_t duration = furi_hal_subghz_async_tx_middleware_get_duration( &furi_hal_subghz_async_tx.middleware, furi_hal_subghz_async_tx.callback); + // if duration == 0 then we stop DMA interrupt(that used to refill buffer) and write to buffer 0 as last element. + // later DMA write this 0 to ARR and timer TIM2 will be stopped. if(duration == 0) { *buffer = 0; buffer++; @@ -756,48 +758,64 @@ bool furi_hal_subghz_start_async_tx(FuriHalSubGhzAsyncTxCallback callback, void* furi_hal_subghz_async_tx.buffer = malloc(FURI_HAL_SUBGHZ_ASYNC_TX_BUFFER_FULL * sizeof(uint32_t)); - // Connect CC1101_GD0 to TIM2 as output + // Here we use TIM2_CH2 (Timer 2 Channel 2) to generate HI/LOW signals for C1101 with current durations. + // DMA update/rewrite TIM2 settings (ARR) with new duration each time TIM2 completes. + // Every time when timer counter exeed current TIM2-ARR (AutoReload Register) value timer generate event that call DMA + // DMA load next new value from buffer to TIM2-ARR and timer start count up from 0 to new value again + // Totally we have timer that generate events and update they settings with new durations by DMA action. + // When duration = 0 then DMA wirte 0 to ARR. So when we set ARR=0 - thats mean TIM2 stop counting. + + // Connect CC1101_GD0 to TIM2 as output (Pin B3 - GpioAltFn1TIM2 - TIM2, CH2) furi_hal_gpio_init_ex( &gpio_cc1101_g0, GpioModeAltFunctionPushPull, GpioPullNo, GpioSpeedLow, GpioAltFn1TIM2); - // Configure DMA - LL_DMA_InitTypeDef dma_config = {0}; - dma_config.PeriphOrM2MSrcAddress = (uint32_t) & (TIM2->ARR); - dma_config.MemoryOrM2MDstAddress = (uint32_t)furi_hal_subghz_async_tx.buffer; - dma_config.Direction = LL_DMA_DIRECTION_MEMORY_TO_PERIPH; - dma_config.Mode = LL_DMA_MODE_CIRCULAR; - dma_config.PeriphOrM2MSrcIncMode = LL_DMA_PERIPH_NOINCREMENT; - dma_config.MemoryOrM2MDstIncMode = LL_DMA_MEMORY_INCREMENT; - dma_config.PeriphOrM2MSrcDataSize = LL_DMA_PDATAALIGN_WORD; - dma_config.MemoryOrM2MDstDataSize = LL_DMA_MDATAALIGN_WORD; - dma_config.NbData = FURI_HAL_SUBGHZ_ASYNC_TX_BUFFER_FULL; - dma_config.PeriphRequest = LL_DMAMUX_REQ_TIM2_UP; + // Configure DMA to update TIM2->ARR + LL_DMA_InitTypeDef dma_config = {0}; // DMA settings structure + dma_config.PeriphOrM2MSrcAddress = (uint32_t)&(TIM2->ARR); // DMA destination TIM2->ARR + dma_config.MemoryOrM2MDstAddress = + (uint32_t)furi_hal_subghz_async_tx.buffer; // DMA buffer with signals durations + dma_config.Direction = + LL_DMA_DIRECTION_MEMORY_TO_PERIPH; // DMA direction from memory to periperhal + dma_config.Mode = LL_DMA_MODE_CIRCULAR; // DMA mode + dma_config.PeriphOrM2MSrcIncMode = + LL_DMA_PERIPH_NOINCREMENT; // DMA destination not changed - allways stay on ARR (AutoReload Register) + dma_config.MemoryOrM2MDstIncMode = + LL_DMA_MEMORY_INCREMENT; // DMA source increment - step by step on durations buffer + dma_config.PeriphOrM2MSrcDataSize = LL_DMA_PDATAALIGN_WORD; // DMA source packet size + dma_config.MemoryOrM2MDstDataSize = LL_DMA_MDATAALIGN_WORD; // DMA destination packet size + dma_config.NbData = FURI_HAL_SUBGHZ_ASYNC_TX_BUFFER_FULL; // DMA buffer size + dma_config.PeriphRequest = LL_DMAMUX_REQ_TIM2_UP; // DMA start by TIM2 event dma_config.Priority = LL_DMA_PRIORITY_VERYHIGH; // Ensure that ARR is updated before anyone else try to check it - LL_DMA_Init(SUBGHZ_DMA_CH1_DEF, &dma_config); + LL_DMA_Init(SUBGHZ_DMA_CH1_DEF, &dma_config); // Setup DMA with settings structure + // setup interrupt for DMA. When DMA generate interrupt event we call furi_hal_subghz_async_tx_dma_isr furi_hal_interrupt_set_isr(SUBGHZ_DMA_CH1_IRQ, furi_hal_subghz_async_tx_dma_isr, NULL); - LL_DMA_EnableIT_TC(SUBGHZ_DMA_CH1_DEF); - LL_DMA_EnableIT_HT(SUBGHZ_DMA_CH1_DEF); - LL_DMA_EnableChannel(SUBGHZ_DMA_CH1_DEF); + LL_DMA_EnableIT_TC(SUBGHZ_DMA_CH1_DEF); // interrupt for full buffer sent + LL_DMA_EnableIT_HT(SUBGHZ_DMA_CH1_DEF); // interrupt for half buffer sent + LL_DMA_EnableChannel(SUBGHZ_DMA_CH1_DEF); // Enable - furi_hal_bus_enable(FuriHalBusTIM2); + furi_hal_bus_enable(FuriHalBusTIM2); // Enable TIM2 // Configure TIM2 - LL_TIM_SetCounterMode(TIM2, LL_TIM_COUNTERMODE_UP); + LL_TIM_SetCounterMode(TIM2, LL_TIM_COUNTERMODE_UP); // TIM2 set counter mode UP + // Set the division ratio between the timer clock and the sampling clock 1:1 LL_TIM_SetClockDivision(TIM2, LL_TIM_CLOCKDIVISION_DIV1); + LL_TIM_SetPrescaler(TIM2, 64 - 1); // Perscaler 64 Mghz/64 = 1 Mghz (1 000 000 tick/sec) + // AutoReload Register (ARR) 1000 ticks = 1/1000 Mghz = 1 millisecond, will be changed by DMA by new durations LL_TIM_SetAutoReload(TIM2, 1000); - LL_TIM_SetPrescaler(TIM2, 64 - 1); - LL_TIM_SetClockSource(TIM2, LL_TIM_CLOCKSOURCE_INTERNAL); - LL_TIM_DisableARRPreload(TIM2); + LL_TIM_SetClockSource(TIM2, LL_TIM_CLOCKSOURCE_INTERNAL); // ClockSource for TIM2 + LL_TIM_DisableARRPreload( + TIM2); // Change TIM2 setting immediately (dont wait when counter will be overload) // Configure TIM2 CH2 - LL_TIM_OC_InitTypeDef TIM_OC_InitStruct = {0}; + LL_TIM_OC_InitTypeDef TIM_OC_InitStruct = {0}; //Settings structure + // CH2 working mode - TOGGLE (swith between HI and LOW levels) TIM_OC_InitStruct.OCMode = LL_TIM_OCMODE_TOGGLE; TIM_OC_InitStruct.OCState = LL_TIM_OCSTATE_DISABLE; TIM_OC_InitStruct.OCNState = LL_TIM_OCSTATE_DISABLE; - TIM_OC_InitStruct.CompareValue = 0; - TIM_OC_InitStruct.OCPolarity = LL_TIM_OCPOLARITY_HIGH; - LL_TIM_OC_Init(TIM2, LL_TIM_CHANNEL_CH2, &TIM_OC_InitStruct); + TIM_OC_InitStruct.CompareValue = 0; // Counter value to generate events and TOGGLE output + TIM_OC_InitStruct.OCPolarity = LL_TIM_OCPOLARITY_HIGH; // Initial CH2 state - HIGH level + LL_TIM_OC_Init(TIM2, LL_TIM_CHANNEL_CH2, &TIM_OC_InitStruct); // Apply settings to CH2 LL_TIM_OC_DisableFast(TIM2, LL_TIM_CHANNEL_CH2); LL_TIM_DisableMasterSlaveMode(TIM2); @@ -805,8 +823,8 @@ bool furi_hal_subghz_start_async_tx(FuriHalSubGhzAsyncTxCallback callback, void* furi_hal_subghz_async_tx_refill( furi_hal_subghz_async_tx.buffer, FURI_HAL_SUBGHZ_ASYNC_TX_BUFFER_FULL); - LL_TIM_EnableDMAReq_UPDATE(TIM2); - LL_TIM_CC_EnableChannel(TIM2, LL_TIM_CHANNEL_CH2); + LL_TIM_EnableDMAReq_UPDATE(TIM2); // Setup calling DMA by TIM2 events + LL_TIM_CC_EnableChannel(TIM2, LL_TIM_CHANNEL_CH2); //Enable TIM2 CH2 // Start debug if(furi_hal_subghz_start_debug()) { @@ -820,7 +838,7 @@ bool furi_hal_subghz_start_async_tx(FuriHalSubGhzAsyncTxCallback callback, void* furi_hal_subghz_debug_gpio_buff[1] = (uint32_t)gpio->pin << GPIO_NUMBER; dma_config.MemoryOrM2MDstAddress = (uint32_t)furi_hal_subghz_debug_gpio_buff; - dma_config.PeriphOrM2MSrcAddress = (uint32_t) & (gpio->port->BSRR); + dma_config.PeriphOrM2MSrcAddress = (uint32_t)&(gpio->port->BSRR); dma_config.Direction = LL_DMA_DIRECTION_MEMORY_TO_PERIPH; dma_config.Mode = LL_DMA_MODE_CIRCULAR; dma_config.PeriphOrM2MSrcIncMode = LL_DMA_PERIPH_NOINCREMENT; @@ -841,14 +859,15 @@ bool furi_hal_subghz_start_async_tx(FuriHalSubGhzAsyncTxCallback callback, void* #endif furi_hal_subghz_tx(); - LL_TIM_SetCounter(TIM2, 0); - LL_TIM_EnableCounter(TIM2); + LL_TIM_SetCounter(TIM2, 0); // Reset TIM2 + LL_TIM_EnableCounter(TIM2); // Start TIM2 counting. return true; } bool furi_hal_subghz_is_async_tx_complete(void) { return (furi_hal_subghz.state == SubGhzStateAsyncTx) && (LL_TIM_GetAutoReload(TIM2) == 0); + FURI_LOG_I(TAG, "SubGhzStateAsyncTx %d , TIM2-ARR %ld",furi_hal_subghz.state,LL_TIM_GetAutoReload(TIM2)); } void furi_hal_subghz_stop_async_tx(void) { From 8a85ab88a767ab2777f171de2e45b47195f35b0a Mon Sep 17 00:00:00 2001 From: Dmitry422 Date: Sun, 25 Jan 2026 22:38:11 +0700 Subject: [PATCH 2/9] Home to work --- .../drivers/subghz/cc1101_ext/cc1101_ext.c | 2 - .../scenes/subghz_scene_receiver_info.c | 8 ++ .../subghz/scenes/subghz_scene_transmitter.c | 113 +++++++++++------- applications/main/subghz/views/transmitter.c | 28 ++--- 4 files changed, 85 insertions(+), 66 deletions(-) diff --git a/applications/drivers/subghz/cc1101_ext/cc1101_ext.c b/applications/drivers/subghz/cc1101_ext/cc1101_ext.c index 40cfe0d4a..adcf785f2 100644 --- a/applications/drivers/subghz/cc1101_ext/cc1101_ext.c +++ b/applications/drivers/subghz/cc1101_ext/cc1101_ext.c @@ -98,8 +98,6 @@ typedef struct { static SubGhzDeviceCC1101Ext* subghz_device_cc1101_ext = NULL; -bool subghz_device_cc1101_ext_is_async_tx_complete(void); - static bool subghz_device_cc1101_ext_check_init(void) { furi_assert(subghz_device_cc1101_ext->state == SubGhzDeviceCC1101ExtStateInit); subghz_device_cc1101_ext->state = SubGhzDeviceCC1101ExtStateIdle; diff --git a/applications/main/subghz/scenes/subghz_scene_receiver_info.c b/applications/main/subghz/scenes/subghz_scene_receiver_info.c index e68b0203d..a34239f6b 100644 --- a/applications/main/subghz/scenes/subghz_scene_receiver_info.c +++ b/applications/main/subghz/scenes/subghz_scene_receiver_info.c @@ -2,6 +2,8 @@ #include +#include "applications/main/subghz/helpers/subghz_txrx_i.h" + #define TAG "SubGhzSceneReceiverInfo" void subghz_scene_receiver_info_callback(GuiButtonType result, InputType type, void* context) { @@ -138,6 +140,12 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event) return true; } else if(event.event == SubGhzCustomEventSceneReceiverInfoTxStop) { //CC1101 Stop Tx -> Start RX + // #subghz_one_press_send# - keyword to search changes + // when user release OK button we wait until full data packed will send and later stop TX + while(!subghz_devices_is_async_complete_tx(subghz->txrx->radio_device)) { + notification_message(subghz->notifications, &sequence_blink_magenta_10); + } + //# subghz->state_notifications = SubGhzNotificationStateIDLE; widget_reset(subghz->widget); diff --git a/applications/main/subghz/scenes/subghz_scene_transmitter.c b/applications/main/subghz/scenes/subghz_scene_transmitter.c index e7514ac92..65d0c7bc6 100644 --- a/applications/main/subghz/scenes/subghz_scene_transmitter.c +++ b/applications/main/subghz/scenes/subghz_scene_transmitter.c @@ -4,8 +4,13 @@ #include #include + +#include "applications/main/subghz/helpers/subghz_txrx_i.h" + #define TAG "SubGhzSceneTransmitter" +static bool tx_stop_called = false; + void subghz_scene_transmitter_callback(SubGhzCustomEvent event, void* context) { furi_assert(context); SubGhz* subghz = context; @@ -66,26 +71,63 @@ bool subghz_scene_transmitter_on_event(void* context, SceneManagerEvent event) { SubGhz* subghz = context; if(event.type == SceneManagerEventTypeCustom) { if(event.event == SubGhzCustomEventViewTransmitterSendStart) { + // if we recieve event to start transmission (user press OK button) then start/restart TX subghz->state_notifications = SubGhzNotificationStateIDLE; if(subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx))) { subghz->state_notifications = SubGhzNotificationStateTx; subghz_scene_transmitter_update_data_show(subghz); dolphin_deed(DolphinDeedSubGhzSend); - - // #subghz_one_press_send# - keyword to search changes - // #start insert# - - // TODO change while condition to subghz_devices_is_async_complete_tx(subghz->txrx->radio_device); - // while( - // !(furi_hal_subghz_is_async_tx_complete() && - // subghz_device_cc1101_ext_is_async_tx_complete())) { - // notification_message(subghz->notifications, &sequence_blink_magenta_10); - // } - - while(!furi_hal_subghz_is_async_tx_complete()) { - notification_message(subghz->notifications, &sequence_blink_magenta_10); - } + } + return true; + } else if(event.event == SubGhzCustomEventViewTransmitterSendStop) { + // we recieve event to stop tranmission (user release OK button) but + // hardware TX still working now then set flag to stop it after hardware TX will be realy ended + if(!subghz_devices_is_async_complete_tx(subghz->txrx->radio_device)) { + tx_stop_called = true; + return true; + } + // if hardware TX not working now so just stop TX correctly + subghz->state_notifications = SubGhzNotificationStateIDLE; + subghz_txrx_stop(subghz->txrx); + if(subghz_custom_btn_get() != SUBGHZ_CUSTOM_BTN_OK) { + subghz_custom_btn_set(SUBGHZ_CUSTOM_BTN_OK); + int32_t tmp_counter = furi_hal_subghz_get_rolling_counter_mult(); + furi_hal_subghz_set_rolling_counter_mult(0); + // Calling restore! + subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx)); + subghz_txrx_stop(subghz->txrx); + // Calling restore 2nd time special for FAAC SLH! + // TODO: Find better way to restore after custom button is used!!! + 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); + } + return true; + } else if(event.event == SubGhzCustomEventViewTransmitterBack) { + // if user press back button then force stop TX if they was active + if(subghz->state_notifications == SubGhzNotificationStateTx) { + subghz_txrx_stop(subghz->txrx); + } + subghz->state_notifications = SubGhzNotificationStateIDLE; + scene_manager_search_and_switch_to_previous_scene( + subghz->scene_manager, SubGhzSceneStart); + return true; + } else if(event.event == SubGhzCustomEventViewTransmitterError) { + furi_string_set(subghz->error_str, "Protocol not\nfound!"); + scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowErrorSub); + } + } else if(event.type == SceneManagerEventTypeTick) { + if(subghz->state_notifications == SubGhzNotificationStateTx) { + // if hardware TX still working at this time so we just blink led and do nothing + if(!subghz_devices_is_async_complete_tx(subghz->txrx->radio_device)) { + notification_message(subghz->notifications, &sequence_blink_magenta_10); + return true; + } + // if hardware TX not working now and tx_stop_called = true + // (mean user release OK button early than hardware TX was ended) then we stop TX + if(tx_stop_called) { + tx_stop_called = false; subghz->state_notifications = SubGhzNotificationStateIDLE; subghz_txrx_stop(subghz->txrx); if(subghz_custom_btn_get() != SUBGHZ_CUSTOM_BTN_OK) { @@ -101,39 +143,18 @@ bool subghz_scene_transmitter_on_event(void* context, SceneManagerEvent event) { subghz_txrx_stop(subghz->txrx); furi_hal_subghz_set_rolling_counter_mult(tmp_counter); } - // #end insert# + return true; + } else { + // if state_notifications == SubGhzNotificationStateTx but hardware TX was ended + // and user still dont release OK button then we repeat transmission + subghz->state_notifications = SubGhzNotificationStateIDLE; + if(subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx))) { + subghz->state_notifications = SubGhzNotificationStateTx; + subghz_scene_transmitter_update_data_show(subghz); + dolphin_deed(DolphinDeedSubGhzSend); + } + return true; } - return true; - // #subghz_one_press_send# - keyword to search changes - // } else if(event.event == SubGhzCustomEventViewTransmitterSendStop) { - // subghz->state_notifications = SubGhzNotificationStateIDLE; - // subghz_txrx_stop(subghz->txrx); - // if(subghz_custom_btn_get() != SUBGHZ_CUSTOM_BTN_OK) { - // subghz_custom_btn_set(SUBGHZ_CUSTOM_BTN_OK); - // int32_t tmp_counter = furi_hal_subghz_get_rolling_counter_mult(); - // furi_hal_subghz_set_rolling_counter_mult(0); - // // Calling restore! - // subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx)); - // subghz_txrx_stop(subghz->txrx); - // // Calling restore 2nd time special for FAAC SLH! - // // TODO: Find better way to restore after custom button is used!!! - // 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); - // } - // return true; - } else if(event.event == SubGhzCustomEventViewTransmitterBack) { - subghz->state_notifications = SubGhzNotificationStateIDLE; - scene_manager_search_and_switch_to_previous_scene( - subghz->scene_manager, SubGhzSceneStart); - return true; - } else if(event.event == SubGhzCustomEventViewTransmitterError) { - furi_string_set(subghz->error_str, "Protocol not\nfound!"); - scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowErrorSub); - } - } else if(event.type == SceneManagerEventTypeTick) { - if(subghz->state_notifications == SubGhzNotificationStateTx) { - notification_message(subghz->notifications, &sequence_blink_magenta_10); } return true; } diff --git a/applications/main/subghz/views/transmitter.c b/applications/main/subghz/views/transmitter.c index 455ab63a5..9faa703b6 100644 --- a/applications/main/subghz/views/transmitter.c +++ b/applications/main/subghz/views/transmitter.c @@ -6,9 +6,6 @@ #include -#include -#include - struct SubGhzViewTransmitter { View* view; SubGhzViewTransmitterCallback callback; @@ -158,10 +155,7 @@ bool subghz_view_transmitter_input(InputEvent* event, void* context) { true); if(can_be_sent) { - // #subghz_one_press_send# - keyword to search changes - bool allow_events = furi_hal_subghz_is_async_tx_complete() && subghz_device_cc1101_ext_is_async_tx_complete (); - // # - if(event->key == InputKeyOk && event->type == InputTypePress && allow_events) { + if(event->key == InputKeyOk && event->type == InputTypePress) { subghz_custom_btn_set(SUBGHZ_CUSTOM_BTN_OK); with_view_model( subghz_transmitter->view, @@ -174,11 +168,10 @@ bool subghz_view_transmitter_input(InputEvent* event, void* context) { subghz_transmitter->callback( SubGhzCustomEventViewTransmitterSendStart, subghz_transmitter->context); return true; - // #subghz_one_press_send# - keyword to search changes - // } else if(event->key == InputKeyOk && event->type == InputTypeRelease) { - // subghz_transmitter->callback( - // SubGhzCustomEventViewTransmitterSendStop, subghz_transmitter->context); - // return true; + } else if(event->key == InputKeyOk && event->type == InputTypeRelease) { + subghz_transmitter->callback( + SubGhzCustomEventViewTransmitterSendStop, subghz_transmitter->context); + return true; } // Finish "OK" key processing if(subghz_custom_btn_is_allowed()) { @@ -196,7 +189,7 @@ bool subghz_view_transmitter_input(InputEvent* event, void* context) { return true; } - if(event->type == InputTypePress && allow_events) { + if(event->type == InputTypePress) { with_view_model( subghz_transmitter->view, SubGhzViewTransmitterModel * model, @@ -216,11 +209,10 @@ bool subghz_view_transmitter_input(InputEvent* event, void* context) { subghz_transmitter->callback( SubGhzCustomEventViewTransmitterSendStart, subghz_transmitter->context); return true; - // #subghz_one_press_send# - keyword to search changes - // } else if(event->type == InputTypeRelease) { - // subghz_transmitter->callback( - // SubGhzCustomEventViewTransmitterSendStop, subghz_transmitter->context); - // return true; + } else if(event->type == InputTypeRelease) { + subghz_transmitter->callback( + SubGhzCustomEventViewTransmitterSendStop, subghz_transmitter->context); + return true; } } } From 3cc57f7b3e2a46d2e599091b079a65f8e938b417 Mon Sep 17 00:00:00 2001 From: Dmitry422 Date: Mon, 26 Jan 2026 13:07:19 +0700 Subject: [PATCH 3/9] Subghz send by one touch --- .../scenes/subghz_scene_receiver_info.c | 67 +++++++++++++++++-- .../subghz/scenes/subghz_scene_transmitter.c | 6 +- 2 files changed, 64 insertions(+), 9 deletions(-) diff --git a/applications/main/subghz/scenes/subghz_scene_receiver_info.c b/applications/main/subghz/scenes/subghz_scene_receiver_info.c index a34239f6b..26b4d4600 100644 --- a/applications/main/subghz/scenes/subghz_scene_receiver_info.c +++ b/applications/main/subghz/scenes/subghz_scene_receiver_info.c @@ -6,6 +6,8 @@ #define TAG "SubGhzSceneReceiverInfo" +static bool tx_stop_called = false; + void subghz_scene_receiver_info_callback(GuiButtonType result, InputType type, void* context) { furi_assert(context); SubGhz* subghz = context; @@ -140,14 +142,17 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event) return true; } else if(event.event == SubGhzCustomEventSceneReceiverInfoTxStop) { //CC1101 Stop Tx -> Start RX - // #subghz_one_press_send# - keyword to search changes - // when user release OK button we wait until full data packed will send and later stop TX - while(!subghz_devices_is_async_complete_tx(subghz->txrx->radio_device)) { - notification_message(subghz->notifications, &sequence_blink_magenta_10); + + // if we recieve event to stop tranmission (user release OK button) but + // hardware TX still working now then set flag to stop it after hardware TX will be realy ended + // else stop TX correctly and start RX + if(!subghz_devices_is_async_complete_tx(subghz->txrx->radio_device)) { + tx_stop_called = true; + return true; } - //# subghz->state_notifications = SubGhzNotificationStateIDLE; + //update screen data widget_reset(subghz->widget); subghz_scene_receiver_info_draw_widget(subghz); @@ -187,7 +192,57 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event) } switch(subghz->state_notifications) { case SubGhzNotificationStateTx: - notification_message(subghz->notifications, &sequence_blink_magenta_10); + // if hardware TX still working at this time so we just blink led and do nothing + if(!subghz_devices_is_async_complete_tx(subghz->txrx->radio_device)) { + notification_message(subghz->notifications, &sequence_blink_magenta_10); + return true; + } + // if hardware TX not working now and tx_stop_called = true + // (mean user release OK button early than hardware TX was ended) then we stop TX + if(tx_stop_called) { + tx_stop_called = false; + subghz->state_notifications = SubGhzNotificationStateIDLE; + + //update screen data + widget_reset(subghz->widget); + subghz_scene_receiver_info_draw_widget(subghz); + + subghz_txrx_stop(subghz->txrx); + + // Start RX + if(!scene_manager_has_previous_scene(subghz->scene_manager, SubGhzSceneDecodeRAW)) { + subghz_txrx_rx_start(subghz->txrx); + + subghz_txrx_hopper_unpause(subghz->txrx); + if(!subghz_history_get_text_space_left(subghz->history, NULL)) { + subghz->state_notifications = SubGhzNotificationStateRx; + } + } + return true; + } else { + // if current state == SubGhzNotificationStateTx but hardware TX was ended + // and user still not release OK button then we repeat TX + + subghz->state_notifications = SubGhzNotificationStateIDLE; + + //update screen data + widget_reset(subghz->widget); + subghz_scene_receiver_info_draw_widget(subghz); + + //CC1101 Stop RX -> Start TX + subghz_txrx_hopper_pause(subghz->txrx); + if(!subghz_tx_start( + subghz, + subghz_history_get_raw_data(subghz->history, subghz->idx_menu_chosen))) { + subghz_txrx_rx_start(subghz->txrx); + subghz_txrx_hopper_unpause(subghz->txrx); + subghz->state_notifications = SubGhzNotificationStateRx; + } else { + subghz->state_notifications = SubGhzNotificationStateTx; + } + + return true; + } break; case SubGhzNotificationStateRx: notification_message(subghz->notifications, &sequence_blink_cyan_10); diff --git a/applications/main/subghz/scenes/subghz_scene_transmitter.c b/applications/main/subghz/scenes/subghz_scene_transmitter.c index 65d0c7bc6..bfb974417 100644 --- a/applications/main/subghz/scenes/subghz_scene_transmitter.c +++ b/applications/main/subghz/scenes/subghz_scene_transmitter.c @@ -81,7 +81,7 @@ bool subghz_scene_transmitter_on_event(void* context, SceneManagerEvent event) { } return true; } else if(event.event == SubGhzCustomEventViewTransmitterSendStop) { - // we recieve event to stop tranmission (user release OK button) but + // if we recieve event to stop tranmission (user release OK button) but // hardware TX still working now then set flag to stop it after hardware TX will be realy ended if(!subghz_devices_is_async_complete_tx(subghz->txrx->radio_device)) { tx_stop_called = true; @@ -145,8 +145,8 @@ bool subghz_scene_transmitter_on_event(void* context, SceneManagerEvent event) { } return true; } else { - // if state_notifications == SubGhzNotificationStateTx but hardware TX was ended - // and user still dont release OK button then we repeat transmission + // if current state == SubGhzNotificationStateTx but hardware TX was ended + // and user still not release OK button then we repeat transmission subghz->state_notifications = SubGhzNotificationStateIDLE; if(subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx))) { subghz->state_notifications = SubGhzNotificationStateTx; From d47bc0232635fd3b2d09225f1960037e8dd53f18 Mon Sep 17 00:00:00 2001 From: Dmitry422 Date: Mon, 26 Jan 2026 16:15:22 +0700 Subject: [PATCH 4/9] Return protocols Repeat option (used by external apps) --- lib/subghz/protocols/alutech_at_4n.c | 5 ++++- lib/subghz/protocols/ansonic.c | 6 +++++- lib/subghz/protocols/beninca_arc.c | 5 ++++- lib/subghz/protocols/bett.c | 6 +++++- lib/subghz/protocols/bin_raw.c | 6 +++++- lib/subghz/protocols/came.c | 6 +++++- lib/subghz/protocols/came_atomo.c | 5 ++++- lib/subghz/protocols/came_twee.c | 6 +++++- lib/subghz/protocols/chamberlain_code.c | 6 +++++- lib/subghz/protocols/clemsa.c | 6 +++++- lib/subghz/protocols/dickert_mahs.c | 6 +++++- lib/subghz/protocols/doitrand.c | 6 +++++- lib/subghz/protocols/dooya.c | 6 +++++- lib/subghz/protocols/elplast.c | 6 +++++- lib/subghz/protocols/faac_slh.c | 5 ++++- lib/subghz/protocols/feron.c | 6 +++++- lib/subghz/protocols/gangqi.c | 6 +++++- lib/subghz/protocols/gate_tx.c | 6 +++++- lib/subghz/protocols/hay21.c | 6 +++++- lib/subghz/protocols/hollarm.c | 6 +++++- lib/subghz/protocols/holtek.c | 6 +++++- lib/subghz/protocols/holtek_ht12x.c | 6 +++++- lib/subghz/protocols/honeywell.c | 5 ++++- lib/subghz/protocols/honeywell_wdb.c | 6 +++++- lib/subghz/protocols/hormann.c | 6 +++++- lib/subghz/protocols/intertechno_v3.c | 6 +++++- lib/subghz/protocols/keeloq.c | 5 ++++- lib/subghz/protocols/kinggates_stylo_4k.c | 5 ++++- lib/subghz/protocols/legrand.c | 1 + lib/subghz/protocols/linear.c | 6 +++++- lib/subghz/protocols/linear_delta3.c | 6 +++++- lib/subghz/protocols/magellan.c | 6 +++++- lib/subghz/protocols/marantec.c | 6 +++++- lib/subghz/protocols/marantec24.c | 6 +++++- lib/subghz/protocols/mastercode.c | 6 +++++- lib/subghz/protocols/megacode.c | 6 +++++- lib/subghz/protocols/nero_radio.c | 6 +++++- lib/subghz/protocols/nero_sketch.c | 6 +++++- lib/subghz/protocols/nice_flo.c | 6 +++++- lib/subghz/protocols/nice_flor_s.c | 6 +++++- lib/subghz/protocols/phoenix_v2.c | 6 +++++- lib/subghz/protocols/power_smart.c | 6 +++++- lib/subghz/protocols/revers_rb2.c | 6 +++++- lib/subghz/protocols/roger.c | 6 +++++- lib/subghz/protocols/secplus_v1.c | 6 +++++- lib/subghz/protocols/secplus_v2.c | 7 ++++++- lib/subghz/protocols/smc5326.c | 6 +++++- lib/subghz/protocols/somfy_keytis.c | 5 ++++- lib/subghz/protocols/somfy_telis.c | 5 ++++- lib/subghz/protocols/treadmill37.c | 6 +++++- 50 files changed, 238 insertions(+), 49 deletions(-) diff --git a/lib/subghz/protocols/alutech_at_4n.c b/lib/subghz/protocols/alutech_at_4n.c index 421a57b6a..71c8c4fb4 100644 --- a/lib/subghz/protocols/alutech_at_4n.c +++ b/lib/subghz/protocols/alutech_at_4n.c @@ -482,7 +482,10 @@ SubGhzProtocolStatus subghz_protocol_encoder_alutech_at_4n_deserialize( break; } - + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + if(!flipper_format_rewind(flipper_format)) { FURI_LOG_E(TAG, "Rewind error"); break; diff --git a/lib/subghz/protocols/ansonic.c b/lib/subghz/protocols/ansonic.c index 7ad0732d6..176ebe0bc 100644 --- a/lib/subghz/protocols/ansonic.c +++ b/lib/subghz/protocols/ansonic.c @@ -150,7 +150,11 @@ SubGhzProtocolStatus FURI_LOG_E(TAG, "Deserialize error"); break; } - + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + if(!subghz_protocol_encoder_ansonic_get_upload(instance)) { res = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/beninca_arc.c b/lib/subghz/protocols/beninca_arc.c index 210b8e0ad..1c2eb471e 100644 --- a/lib/subghz/protocols/beninca_arc.c +++ b/lib/subghz/protocols/beninca_arc.c @@ -412,7 +412,10 @@ SubGhzProtocolStatus break; } - + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + if(!flipper_format_rewind(flipper_format)) { FURI_LOG_E(TAG, "Rewind error"); break; diff --git a/lib/subghz/protocols/bett.c b/lib/subghz/protocols/bett.c index 173671aaa..277d75bd0 100644 --- a/lib/subghz/protocols/bett.c +++ b/lib/subghz/protocols/bett.c @@ -169,7 +169,11 @@ SubGhzProtocolStatus FURI_LOG_E(TAG, "Deserialize error"); break; } - + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + if(!subghz_protocol_encoder_bett_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/bin_raw.c b/lib/subghz/protocols/bin_raw.c index 4753d467c..8feb403ac 100644 --- a/lib/subghz/protocols/bin_raw.c +++ b/lib/subghz/protocols/bin_raw.c @@ -309,7 +309,11 @@ SubGhzProtocolStatus res = SubGhzProtocolStatusErrorParserOthers; break; } - + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + if(!subghz_protocol_encoder_bin_raw_get_upload(instance)) { res = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/came.c b/lib/subghz/protocols/came.c index 5037f1a4b..7be07a476 100644 --- a/lib/subghz/protocols/came.c +++ b/lib/subghz/protocols/came.c @@ -181,7 +181,11 @@ SubGhzProtocolStatus ret = SubGhzProtocolStatusErrorValueBitCount; break; } - + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + if(!subghz_protocol_encoder_came_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/came_atomo.c b/lib/subghz/protocols/came_atomo.c index 60d1e93a5..c2f1afe9c 100644 --- a/lib/subghz/protocols/came_atomo.c +++ b/lib/subghz/protocols/came_atomo.c @@ -374,7 +374,10 @@ SubGhzProtocolStatus break; } - + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + if(!flipper_format_rewind(flipper_format)) { FURI_LOG_E(TAG, "Rewind error"); break; diff --git a/lib/subghz/protocols/came_twee.c b/lib/subghz/protocols/came_twee.c index c2af278ea..1eb28d94f 100644 --- a/lib/subghz/protocols/came_twee.c +++ b/lib/subghz/protocols/came_twee.c @@ -254,7 +254,11 @@ SubGhzProtocolStatus if(res != SubGhzProtocolStatusOk) { break; } - + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + subghz_protocol_came_twee_remote_controller(&instance->generic); subghz_protocol_encoder_came_twee_get_upload(instance); instance->encoder.front = 0; // reset position before start diff --git a/lib/subghz/protocols/chamberlain_code.c b/lib/subghz/protocols/chamberlain_code.c index d01c80c2e..61ef7747b 100644 --- a/lib/subghz/protocols/chamberlain_code.c +++ b/lib/subghz/protocols/chamberlain_code.c @@ -223,7 +223,11 @@ SubGhzProtocolStatus ret = SubGhzProtocolStatusErrorValueBitCount; break; } - + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + if(!subghz_protocol_encoder_chamb_code_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/clemsa.c b/lib/subghz/protocols/clemsa.c index fecbd4dfd..3d3ebe3d9 100644 --- a/lib/subghz/protocols/clemsa.c +++ b/lib/subghz/protocols/clemsa.c @@ -168,7 +168,11 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + if(!subghz_protocol_encoder_clemsa_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/dickert_mahs.c b/lib/subghz/protocols/dickert_mahs.c index ac00fd28a..f5d710c79 100644 --- a/lib/subghz/protocols/dickert_mahs.c +++ b/lib/subghz/protocols/dickert_mahs.c @@ -207,7 +207,11 @@ SubGhzProtocolStatus ret = SubGhzProtocolStatusErrorValueBitCount; break; } - + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + if(!subghz_protocol_encoder_dickert_mahs_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/doitrand.c b/lib/subghz/protocols/doitrand.c index ab700f5ad..158f53169 100644 --- a/lib/subghz/protocols/doitrand.c +++ b/lib/subghz/protocols/doitrand.c @@ -149,7 +149,11 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + if(!subghz_protocol_encoder_doitrand_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/dooya.c b/lib/subghz/protocols/dooya.c index 76d2bac60..b290da8e1 100644 --- a/lib/subghz/protocols/dooya.c +++ b/lib/subghz/protocols/dooya.c @@ -159,7 +159,11 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + if(!subghz_protocol_encoder_dooya_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/elplast.c b/lib/subghz/protocols/elplast.c index a9bd29562..f95c937db 100644 --- a/lib/subghz/protocols/elplast.c +++ b/lib/subghz/protocols/elplast.c @@ -141,7 +141,11 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + subghz_protocol_encoder_elplast_get_upload(instance); instance->encoder.is_running = true; } while(false); diff --git a/lib/subghz/protocols/faac_slh.c b/lib/subghz/protocols/faac_slh.c index d0cfc721c..03e61d6f2 100644 --- a/lib/subghz/protocols/faac_slh.c +++ b/lib/subghz/protocols/faac_slh.c @@ -398,7 +398,10 @@ SubGhzProtocolStatus subghz_protocol_faac_slh_check_remote_controller( &instance->generic, instance->keystore, &instance->manufacture_name); - + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + subghz_protocol_encoder_faac_slh_get_upload(instance); if(!flipper_format_rewind(flipper_format)) { diff --git a/lib/subghz/protocols/feron.c b/lib/subghz/protocols/feron.c index f7d653f4c..d02258f04 100644 --- a/lib/subghz/protocols/feron.c +++ b/lib/subghz/protocols/feron.c @@ -160,7 +160,11 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + subghz_protocol_feron_check_remote_controller(&instance->generic); subghz_protocol_encoder_feron_get_upload(instance); instance->encoder.is_running = true; diff --git a/lib/subghz/protocols/gangqi.c b/lib/subghz/protocols/gangqi.c index f78b37aac..0cdb442d5 100644 --- a/lib/subghz/protocols/gangqi.c +++ b/lib/subghz/protocols/gangqi.c @@ -253,7 +253,11 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + subghz_protocol_gangqi_remote_controller(&instance->generic); subghz_protocol_encoder_gangqi_get_upload(instance); diff --git a/lib/subghz/protocols/gate_tx.c b/lib/subghz/protocols/gate_tx.c index 08f6f3f41..8572edd58 100644 --- a/lib/subghz/protocols/gate_tx.c +++ b/lib/subghz/protocols/gate_tx.c @@ -142,7 +142,11 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + if(!subghz_protocol_encoder_gate_tx_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/hay21.c b/lib/subghz/protocols/hay21.c index 8a0280168..701e98659 100644 --- a/lib/subghz/protocols/hay21.c +++ b/lib/subghz/protocols/hay21.c @@ -267,7 +267,11 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + subghz_protocol_hay21_remote_controller(&instance->generic); subghz_protocol_encoder_hay21_get_upload(instance); diff --git a/lib/subghz/protocols/hollarm.c b/lib/subghz/protocols/hollarm.c index b03de5b72..da0dc97e1 100644 --- a/lib/subghz/protocols/hollarm.c +++ b/lib/subghz/protocols/hollarm.c @@ -254,7 +254,11 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + subghz_protocol_hollarm_remote_controller(&instance->generic); subghz_protocol_encoder_hollarm_get_upload(instance); diff --git a/lib/subghz/protocols/holtek.c b/lib/subghz/protocols/holtek.c index 2735702c5..4afe25070 100644 --- a/lib/subghz/protocols/holtek.c +++ b/lib/subghz/protocols/holtek.c @@ -155,7 +155,11 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + if(!subghz_protocol_encoder_holtek_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/holtek_ht12x.c b/lib/subghz/protocols/holtek_ht12x.c index bf4724130..595237a1f 100644 --- a/lib/subghz/protocols/holtek_ht12x.c +++ b/lib/subghz/protocols/holtek_ht12x.c @@ -170,7 +170,11 @@ SubGhzProtocolStatus ret = SubGhzProtocolStatusErrorParserTe; break; } - + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + if(!subghz_protocol_encoder_holtek_th12x_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/honeywell.c b/lib/subghz/protocols/honeywell.c index 7343648d7..d8ce0d8eb 100644 --- a/lib/subghz/protocols/honeywell.c +++ b/lib/subghz/protocols/honeywell.c @@ -211,7 +211,10 @@ SubGhzProtocolStatus break; } - + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + subghz_protocol_encoder_honeywell_get_upload(instance); if(!flipper_format_rewind(flipper_format)) { diff --git a/lib/subghz/protocols/honeywell_wdb.c b/lib/subghz/protocols/honeywell_wdb.c index 0a2cd53d6..96f5f5e7f 100644 --- a/lib/subghz/protocols/honeywell_wdb.c +++ b/lib/subghz/protocols/honeywell_wdb.c @@ -156,7 +156,11 @@ SubGhzProtocolStatus subghz_protocol_encoder_honeywell_wdb_deserialize( if(ret != SubGhzProtocolStatusOk) { break; } - + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + if(!subghz_protocol_encoder_honeywell_wdb_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/hormann.c b/lib/subghz/protocols/hormann.c index 1ac9f6b0d..0d75c0c5f 100644 --- a/lib/subghz/protocols/hormann.c +++ b/lib/subghz/protocols/hormann.c @@ -153,7 +153,11 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + if(!subghz_protocol_encoder_hormann_get_upload(instance)) { instance->encoder.front = 0; // reset position before start ret = SubGhzProtocolStatusErrorEncoderGetUpload; diff --git a/lib/subghz/protocols/intertechno_v3.c b/lib/subghz/protocols/intertechno_v3.c index 85818763b..7b9bfbf1a 100644 --- a/lib/subghz/protocols/intertechno_v3.c +++ b/lib/subghz/protocols/intertechno_v3.c @@ -176,7 +176,11 @@ SubGhzProtocolStatus subghz_protocol_encoder_intertechno_v3_deserialize( ret = SubGhzProtocolStatusErrorValueBitCount; break; } - + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + if(!subghz_protocol_encoder_intertechno_v3_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/keeloq.c b/lib/subghz/protocols/keeloq.c index 39f957e24..d5a8a9aa7 100644 --- a/lib/subghz/protocols/keeloq.c +++ b/lib/subghz/protocols/keeloq.c @@ -667,7 +667,10 @@ SubGhzProtocolStatus subghz_protocol_keeloq_check_remote_controller( &instance->generic, instance->keystore, &instance->manufacture_name); - + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + if(!subghz_protocol_encoder_keeloq_get_upload(instance, instance->generic.btn)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/kinggates_stylo_4k.c b/lib/subghz/protocols/kinggates_stylo_4k.c index e6e9d6d38..6b8d0e428 100644 --- a/lib/subghz/protocols/kinggates_stylo_4k.c +++ b/lib/subghz/protocols/kinggates_stylo_4k.c @@ -344,7 +344,10 @@ SubGhzProtocolStatus subghz_protocol_encoder_kinggates_stylo_4k_deserialize( break; } - + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + if(!flipper_format_rewind(flipper_format)) { FURI_LOG_E(TAG, "Rewind error"); break; diff --git a/lib/subghz/protocols/legrand.c b/lib/subghz/protocols/legrand.c index 94a45694c..45a46847c 100644 --- a/lib/subghz/protocols/legrand.c +++ b/lib/subghz/protocols/legrand.c @@ -155,6 +155,7 @@ SubGhzProtocolStatus ret = SubGhzProtocolStatusErrorParserTe; break; } + // optional parameter flipper_format_read_uint32( flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); diff --git a/lib/subghz/protocols/linear.c b/lib/subghz/protocols/linear.c index e170c90ee..61a21ec05 100644 --- a/lib/subghz/protocols/linear.c +++ b/lib/subghz/protocols/linear.c @@ -160,7 +160,11 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + if(!subghz_protocol_encoder_linear_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/linear_delta3.c b/lib/subghz/protocols/linear_delta3.c index b9b28c66a..515fc43a6 100644 --- a/lib/subghz/protocols/linear_delta3.c +++ b/lib/subghz/protocols/linear_delta3.c @@ -164,7 +164,11 @@ SubGhzProtocolStatus subghz_protocol_encoder_linear_delta3_deserialize( if(ret != SubGhzProtocolStatusOk) { break; } - + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + if(!subghz_protocol_encoder_linear_delta3_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/magellan.c b/lib/subghz/protocols/magellan.c index ef0c9d2ae..5fc003ab4 100644 --- a/lib/subghz/protocols/magellan.c +++ b/lib/subghz/protocols/magellan.c @@ -164,7 +164,11 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + if(!subghz_protocol_encoder_magellan_get_upload(instance)) { instance->encoder.front = 0; // reset before start ret = SubGhzProtocolStatusErrorEncoderGetUpload; diff --git a/lib/subghz/protocols/marantec.c b/lib/subghz/protocols/marantec.c index 02d6aa801..d70c4eed2 100644 --- a/lib/subghz/protocols/marantec.c +++ b/lib/subghz/protocols/marantec.c @@ -213,7 +213,11 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + subghz_protocol_marantec_remote_controller(&instance->generic); subghz_protocol_encoder_marantec_get_upload(instance); instance->encoder.front = 0; diff --git a/lib/subghz/protocols/marantec24.c b/lib/subghz/protocols/marantec24.c index 63d8e7be2..fbd16ecbb 100644 --- a/lib/subghz/protocols/marantec24.c +++ b/lib/subghz/protocols/marantec24.c @@ -155,7 +155,11 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + subghz_protocol_marantec24_check_remote_controller(&instance->generic); subghz_protocol_encoder_marantec24_get_upload(instance); instance->encoder.is_running = true; diff --git a/lib/subghz/protocols/mastercode.c b/lib/subghz/protocols/mastercode.c index 5a57d764e..b0b7f789d 100644 --- a/lib/subghz/protocols/mastercode.c +++ b/lib/subghz/protocols/mastercode.c @@ -168,7 +168,11 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + if(!subghz_protocol_encoder_mastercode_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/megacode.c b/lib/subghz/protocols/megacode.c index 13cc99436..22e57c364 100644 --- a/lib/subghz/protocols/megacode.c +++ b/lib/subghz/protocols/megacode.c @@ -188,7 +188,11 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + if(!subghz_protocol_encoder_megacode_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/nero_radio.c b/lib/subghz/protocols/nero_radio.c index 18fdfffa8..d5c284693 100644 --- a/lib/subghz/protocols/nero_radio.c +++ b/lib/subghz/protocols/nero_radio.c @@ -180,7 +180,11 @@ SubGhzProtocolStatus break; } } - + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + if(!subghz_protocol_encoder_nero_radio_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/nero_sketch.c b/lib/subghz/protocols/nero_sketch.c index 0550cf801..02682f4f1 100644 --- a/lib/subghz/protocols/nero_sketch.c +++ b/lib/subghz/protocols/nero_sketch.c @@ -161,7 +161,11 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + if(!subghz_protocol_encoder_nero_sketch_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/nice_flo.c b/lib/subghz/protocols/nice_flo.c index dc423fe83..b47de0079 100644 --- a/lib/subghz/protocols/nice_flo.c +++ b/lib/subghz/protocols/nice_flo.c @@ -147,7 +147,11 @@ SubGhzProtocolStatus ret = SubGhzProtocolStatusErrorValueBitCount; break; } - + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + if(!subghz_protocol_encoder_nice_flo_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/nice_flor_s.c b/lib/subghz/protocols/nice_flor_s.c index 59cf4d2cc..67755c79f 100644 --- a/lib/subghz/protocols/nice_flor_s.c +++ b/lib/subghz/protocols/nice_flor_s.c @@ -279,7 +279,11 @@ SubGhzProtocolStatus break; } - // flipper_format_read_uint32( + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + + // flipper_format_read_uint32( // flipper_format, "Data", (uint32_t*)&instance->generic.data_2, 1); if(!flipper_format_rewind(flipper_format)) { FURI_LOG_E(TAG, "Rewind error"); diff --git a/lib/subghz/protocols/phoenix_v2.c b/lib/subghz/protocols/phoenix_v2.c index c70b4cb00..9b97137f9 100644 --- a/lib/subghz/protocols/phoenix_v2.c +++ b/lib/subghz/protocols/phoenix_v2.c @@ -322,7 +322,11 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + subghz_protocol_phoenix_v2_check_remote_controller(&instance->generic); if(!subghz_protocol_encoder_phoenix_v2_get_upload(instance)) { diff --git a/lib/subghz/protocols/power_smart.c b/lib/subghz/protocols/power_smart.c index ed237780e..714232561 100644 --- a/lib/subghz/protocols/power_smart.c +++ b/lib/subghz/protocols/power_smart.c @@ -206,7 +206,11 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + subghz_protocol_power_smart_remote_controller(&instance->generic); subghz_protocol_encoder_power_smart_get_upload(instance); instance->encoder.front = 0; // reset before start diff --git a/lib/subghz/protocols/revers_rb2.c b/lib/subghz/protocols/revers_rb2.c index 2e9aee592..5e4ca97e8 100644 --- a/lib/subghz/protocols/revers_rb2.c +++ b/lib/subghz/protocols/revers_rb2.c @@ -176,7 +176,11 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + subghz_protocol_revers_rb2_remote_controller(&instance->generic); subghz_protocol_encoder_revers_rb2_get_upload(instance); instance->encoder.is_running = true; diff --git a/lib/subghz/protocols/roger.c b/lib/subghz/protocols/roger.c index 30767db82..62178981c 100644 --- a/lib/subghz/protocols/roger.c +++ b/lib/subghz/protocols/roger.c @@ -265,7 +265,11 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + subghz_protocol_roger_check_remote_controller(&instance->generic); subghz_protocol_encoder_roger_get_upload(instance); diff --git a/lib/subghz/protocols/secplus_v1.c b/lib/subghz/protocols/secplus_v1.c index 460ff766e..3d820b318 100644 --- a/lib/subghz/protocols/secplus_v1.c +++ b/lib/subghz/protocols/secplus_v1.c @@ -298,7 +298,11 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + if(!subghz_protocol_secplus_v1_encode(instance)) { ret = SubGhzProtocolStatusErrorParserOthers; break; diff --git a/lib/subghz/protocols/secplus_v2.c b/lib/subghz/protocols/secplus_v2.c index bcbf3183a..902422148 100644 --- a/lib/subghz/protocols/secplus_v2.c +++ b/lib/subghz/protocols/secplus_v2.c @@ -574,7 +574,12 @@ SubGhzProtocolStatus subghz_protocol_secplus_v2_remote_controller( &instance->generic, instance->secplus_packet_1); subghz_protocol_secplus_v2_encode(instance); - subghz_protocol_encoder_secplus_v2_get_upload(instance); + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + + subghz_protocol_encoder_secplus_v2_get_upload(instance); //update data for(size_t i = 0; i < sizeof(uint64_t); i++) { diff --git a/lib/subghz/protocols/smc5326.c b/lib/subghz/protocols/smc5326.c index bf006e146..201fcd9d7 100644 --- a/lib/subghz/protocols/smc5326.c +++ b/lib/subghz/protocols/smc5326.c @@ -178,7 +178,11 @@ SubGhzProtocolStatus ret = SubGhzProtocolStatusErrorParserTe; break; } - + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + if(!subghz_protocol_encoder_smc5326_get_upload(instance)) { ret = SubGhzProtocolStatusErrorEncoderGetUpload; break; diff --git a/lib/subghz/protocols/somfy_keytis.c b/lib/subghz/protocols/somfy_keytis.c index c462035c6..04dba4736 100644 --- a/lib/subghz/protocols/somfy_keytis.c +++ b/lib/subghz/protocols/somfy_keytis.c @@ -412,7 +412,10 @@ SubGhzProtocolStatus break; } - + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + subghz_protocol_encoder_somfy_keytis_get_upload(instance, instance->generic.btn); if(!flipper_format_rewind(flipper_format)) { diff --git a/lib/subghz/protocols/somfy_telis.c b/lib/subghz/protocols/somfy_telis.c index a4b756daa..4d4b128f1 100644 --- a/lib/subghz/protocols/somfy_telis.c +++ b/lib/subghz/protocols/somfy_telis.c @@ -341,7 +341,10 @@ SubGhzProtocolStatus break; } - + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + subghz_protocol_encoder_somfy_telis_get_upload(instance, instance->generic.btn); if(!flipper_format_rewind(flipper_format)) { diff --git a/lib/subghz/protocols/treadmill37.c b/lib/subghz/protocols/treadmill37.c index 9784fe1e3..8a7badb94 100644 --- a/lib/subghz/protocols/treadmill37.c +++ b/lib/subghz/protocols/treadmill37.c @@ -151,7 +151,11 @@ SubGhzProtocolStatus if(ret != SubGhzProtocolStatusOk) { break; } - + + // Optional value + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + subghz_protocol_treadmill37_check_remote_controller(&instance->generic); subghz_protocol_encoder_treadmill37_get_upload(instance); instance->encoder.is_running = true; From 14abc959cf0fb86d9a2904a5028e3196ff80fe31 Mon Sep 17 00:00:00 2001 From: Dmitry422 Date: Mon, 26 Jan 2026 16:30:32 +0700 Subject: [PATCH 5/9] start working with subghz button editor --- .../scenes/subghz_scene_signal_settings.c | 40 ++++++++++++++++++- lib/subghz/blocks/generic.h | 5 +++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/applications/main/subghz/scenes/subghz_scene_signal_settings.c b/applications/main/subghz/scenes/subghz_scene_signal_settings.c index e74219a28..548516683 100644 --- a/applications/main/subghz/scenes/subghz_scene_signal_settings.c +++ b/applications/main/subghz/scenes/subghz_scene_signal_settings.c @@ -14,6 +14,7 @@ static uint16_t counter16 = 0x0; static uint8_t byte_count = 0; static uint8_t* byte_ptr = NULL; static FuriString* byte_input_text; +static uint8_t button = 0x0; #define COUNTER_MODE_COUNT 7 static const char* const counter_mode_text[COUNTER_MODE_COUNT] = { @@ -74,6 +75,23 @@ void subghz_scene_signal_settings_variable_item_list_enter_callback(void* contex ByteInput* byte_input = subghz->byte_input; byte_input_set_header_text(byte_input, furi_string_get_cstr(byte_input_text)); + byte_input_set_result_callback( + byte_input, + subghz_scene_signal_settings_byte_input_callback, + NULL, + subghz, + byte_ptr, + byte_count); + view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdByteInput); + } + // when we click OK on "Edit button" item + if(index == 2) { + furi_string_cat_str(byte_input_text, " button number in HEX"); + + // Setup byte_input view + ByteInput* byte_input = subghz->byte_input; + byte_input_set_header_text(byte_input, furi_string_get_cstr(byte_input_text)); + byte_input_set_result_callback( byte_input, subghz_scene_signal_settings_byte_input_callback, @@ -130,9 +148,10 @@ void subghz_scene_signal_settings_on_enter(void* context) { flipper_format_free(fff_data_file); furi_record_close(RECORD_STORAGE); - // ### Counter edit section ### byte_input_text = furi_string_alloc_set_str("Enter "); bool counter_not_available = true; + bool button_not_available = true; + SubGhzProtocolDecoderBase* decoder = subghz_txrx_get_decoder(subghz->txrx); // deserialaze and decode loaded sugbhz file and push data to subghz_block_generic_global variable @@ -143,6 +162,8 @@ void subghz_scene_signal_settings_on_enter(void* context) { FURI_LOG_E(TAG, "Cant deserialize this subghz file"); } + // ### Counter edit section ### + if(!subghz_block_generic_global.cnt_is_available) { counter_mode = 0xff; FURI_LOG_D(TAG, "Counter mode and edit not available for this protocol"); @@ -166,6 +187,18 @@ void subghz_scene_signal_settings_on_enter(void* context) { } } + // ### Button edit section ### + + if(!subghz_block_generic_global.btn_is_available) { + FURI_LOG_D(TAG, "Button edit not available for this protocol"); + } else { + button_not_available = false; + button = subghz_block_generic_global.current_btn; + furi_string_printf(tmp_text, "%X", button); + byte_ptr = (uint8_t*)&button; + byte_count = 1; + } + furi_assert(byte_ptr); furi_assert(byte_count > 0); @@ -196,6 +229,11 @@ void subghz_scene_signal_settings_on_enter(void* context) { variable_item_set_current_value_text(item, furi_string_get_cstr(tmp_text)); variable_item_set_locked(item, (counter_not_available), "Not available\nfor this\nprotocol !"); + item = variable_item_list_add(variable_item_list, "Edit Button", 1, NULL, subghz); + variable_item_set_current_value_index(item, 0); + variable_item_set_current_value_text(item, furi_string_get_cstr(tmp_text)); + variable_item_set_locked(item, (button_not_available), "Not available\nfor this\nprotocol !"); + furi_string_free(tmp_text); view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdVariableItemList); diff --git a/lib/subghz/blocks/generic.h b/lib/subghz/blocks/generic.h index 1e72c5a5e..d3f7804dc 100644 --- a/lib/subghz/blocks/generic.h +++ b/lib/subghz/blocks/generic.h @@ -35,6 +35,11 @@ struct SubGhzBlockGenericGlobal { bool cnt_need_override; // flag for protocols to override signals counter inside of protocols uint8_t cnt_length_bit; // counter length in bytes (used in counter editor giu) bool cnt_is_available; // is there counter available for protocol (used in counter editor giu) + + uint8_t current_btn; // global counter value; + uint8_t new_btn; // global counter value; + bool btn_need_override; // flag for protocols to override signals counter inside of protocols + bool btn_is_available; // is there counter available for protocol (used in counter editor giu) }; extern SubGhzBlockGenericGlobal subghz_block_generic_global; //global structure for subghz From eb91b7a974f2ee6930635dfae6bbc67996d6ee1f Mon Sep 17 00:00:00 2001 From: Dmitry422 Date: Mon, 26 Jan 2026 16:41:57 +0700 Subject: [PATCH 6/9] Protocols repeat correction --- lib/subghz/protocols/alutech_at_4n.c | 2 +- lib/subghz/protocols/beninca_arc.c | 2 +- lib/subghz/protocols/bin_raw.c | 2 +- lib/subghz/protocols/came_atomo.c | 2 +- lib/subghz/protocols/hormann.c | 2 +- lib/subghz/protocols/jarolift.c | 2 +- lib/subghz/protocols/power_smart.c | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/subghz/protocols/alutech_at_4n.c b/lib/subghz/protocols/alutech_at_4n.c index 71c8c4fb4..21ad71f01 100644 --- a/lib/subghz/protocols/alutech_at_4n.c +++ b/lib/subghz/protocols/alutech_at_4n.c @@ -94,7 +94,7 @@ void* subghz_protocol_encoder_alutech_at_4n_alloc(SubGhzEnvironment* environment instance->base.protocol = &subghz_protocol_alutech_at_4n; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 2; + instance->encoder.repeat = 3; instance->encoder.size_upload = 512; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; diff --git a/lib/subghz/protocols/beninca_arc.c b/lib/subghz/protocols/beninca_arc.c index 1c2eb471e..786de5fa8 100644 --- a/lib/subghz/protocols/beninca_arc.c +++ b/lib/subghz/protocols/beninca_arc.c @@ -256,7 +256,7 @@ void* subghz_protocol_encoder_beninca_arc_alloc(SubGhzEnvironment* environment) instance->generic.protocol_name = instance->base.protocol->name; instance->keystore = subghz_environment_get_keystore(environment); - instance->encoder.repeat = 2; + instance->encoder.repeat = 1; instance->encoder.size_upload = 800; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; diff --git a/lib/subghz/protocols/bin_raw.c b/lib/subghz/protocols/bin_raw.c index 8feb403ac..9ac339d79 100644 --- a/lib/subghz/protocols/bin_raw.c +++ b/lib/subghz/protocols/bin_raw.c @@ -142,7 +142,7 @@ void* subghz_protocol_encoder_bin_raw_alloc(SubGhzEnvironment* environment) { instance->base.protocol = &subghz_protocol_bin_raw; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 2; + instance->encoder.repeat = 3; instance->encoder.size_upload = BIN_RAW_BUF_DATA_SIZE * 5; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->data = malloc(instance->encoder.size_upload * sizeof(uint8_t)); diff --git a/lib/subghz/protocols/came_atomo.c b/lib/subghz/protocols/came_atomo.c index c2f1afe9c..748d15af5 100644 --- a/lib/subghz/protocols/came_atomo.c +++ b/lib/subghz/protocols/came_atomo.c @@ -89,7 +89,7 @@ void* subghz_protocol_encoder_came_atomo_alloc(SubGhzEnvironment* environment) { instance->base.protocol = &subghz_protocol_came_atomo; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 2; + instance->encoder.repeat = 1; instance->encoder.size_upload = 900; //actual size 766+ instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; diff --git a/lib/subghz/protocols/hormann.c b/lib/subghz/protocols/hormann.c index 0d75c0c5f..250ab4f62 100644 --- a/lib/subghz/protocols/hormann.c +++ b/lib/subghz/protocols/hormann.c @@ -80,7 +80,7 @@ void* subghz_protocol_encoder_hormann_alloc(SubGhzEnvironment* environment) { instance->base.protocol = &subghz_protocol_hormann; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 2; + instance->encoder.repeat = 3; instance->encoder.size_upload = 2048; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; diff --git a/lib/subghz/protocols/jarolift.c b/lib/subghz/protocols/jarolift.c index 9881b9892..81eca4fde 100644 --- a/lib/subghz/protocols/jarolift.c +++ b/lib/subghz/protocols/jarolift.c @@ -100,7 +100,7 @@ void* subghz_protocol_encoder_jarolift_alloc(SubGhzEnvironment* environment) { instance->generic.protocol_name = instance->base.protocol->name; instance->keystore = subghz_environment_get_keystore(environment); - instance->encoder.repeat = 10; + instance->encoder.repeat = 3; instance->encoder.size_upload = 256; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; diff --git a/lib/subghz/protocols/power_smart.c b/lib/subghz/protocols/power_smart.c index 714232561..1e8f7098c 100644 --- a/lib/subghz/protocols/power_smart.c +++ b/lib/subghz/protocols/power_smart.c @@ -85,7 +85,7 @@ void* subghz_protocol_encoder_power_smart_alloc(SubGhzEnvironment* environment) instance->base.protocol = &subghz_protocol_power_smart; instance->generic.protocol_name = instance->base.protocol->name; - instance->encoder.repeat = 2; + instance->encoder.repeat = 3; instance->encoder.size_upload = 1024; instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; From 7fa5624c509789adb2ad83a608537710ee68837a Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Mon, 26 Jan 2026 12:45:57 +0300 Subject: [PATCH 7/9] Revert "start working with subghz button editor" This reverts commit 14abc959cf0fb86d9a2904a5028e3196ff80fe31. --- .../scenes/subghz_scene_signal_settings.c | 40 +------------------ lib/subghz/blocks/generic.h | 5 --- 2 files changed, 1 insertion(+), 44 deletions(-) diff --git a/applications/main/subghz/scenes/subghz_scene_signal_settings.c b/applications/main/subghz/scenes/subghz_scene_signal_settings.c index 548516683..e74219a28 100644 --- a/applications/main/subghz/scenes/subghz_scene_signal_settings.c +++ b/applications/main/subghz/scenes/subghz_scene_signal_settings.c @@ -14,7 +14,6 @@ static uint16_t counter16 = 0x0; static uint8_t byte_count = 0; static uint8_t* byte_ptr = NULL; static FuriString* byte_input_text; -static uint8_t button = 0x0; #define COUNTER_MODE_COUNT 7 static const char* const counter_mode_text[COUNTER_MODE_COUNT] = { @@ -75,23 +74,6 @@ void subghz_scene_signal_settings_variable_item_list_enter_callback(void* contex ByteInput* byte_input = subghz->byte_input; byte_input_set_header_text(byte_input, furi_string_get_cstr(byte_input_text)); - byte_input_set_result_callback( - byte_input, - subghz_scene_signal_settings_byte_input_callback, - NULL, - subghz, - byte_ptr, - byte_count); - view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdByteInput); - } - // when we click OK on "Edit button" item - if(index == 2) { - furi_string_cat_str(byte_input_text, " button number in HEX"); - - // Setup byte_input view - ByteInput* byte_input = subghz->byte_input; - byte_input_set_header_text(byte_input, furi_string_get_cstr(byte_input_text)); - byte_input_set_result_callback( byte_input, subghz_scene_signal_settings_byte_input_callback, @@ -148,10 +130,9 @@ void subghz_scene_signal_settings_on_enter(void* context) { flipper_format_free(fff_data_file); furi_record_close(RECORD_STORAGE); + // ### Counter edit section ### byte_input_text = furi_string_alloc_set_str("Enter "); bool counter_not_available = true; - bool button_not_available = true; - SubGhzProtocolDecoderBase* decoder = subghz_txrx_get_decoder(subghz->txrx); // deserialaze and decode loaded sugbhz file and push data to subghz_block_generic_global variable @@ -162,8 +143,6 @@ void subghz_scene_signal_settings_on_enter(void* context) { FURI_LOG_E(TAG, "Cant deserialize this subghz file"); } - // ### Counter edit section ### - if(!subghz_block_generic_global.cnt_is_available) { counter_mode = 0xff; FURI_LOG_D(TAG, "Counter mode and edit not available for this protocol"); @@ -187,18 +166,6 @@ void subghz_scene_signal_settings_on_enter(void* context) { } } - // ### Button edit section ### - - if(!subghz_block_generic_global.btn_is_available) { - FURI_LOG_D(TAG, "Button edit not available for this protocol"); - } else { - button_not_available = false; - button = subghz_block_generic_global.current_btn; - furi_string_printf(tmp_text, "%X", button); - byte_ptr = (uint8_t*)&button; - byte_count = 1; - } - furi_assert(byte_ptr); furi_assert(byte_count > 0); @@ -229,11 +196,6 @@ void subghz_scene_signal_settings_on_enter(void* context) { variable_item_set_current_value_text(item, furi_string_get_cstr(tmp_text)); variable_item_set_locked(item, (counter_not_available), "Not available\nfor this\nprotocol !"); - item = variable_item_list_add(variable_item_list, "Edit Button", 1, NULL, subghz); - variable_item_set_current_value_index(item, 0); - variable_item_set_current_value_text(item, furi_string_get_cstr(tmp_text)); - variable_item_set_locked(item, (button_not_available), "Not available\nfor this\nprotocol !"); - furi_string_free(tmp_text); view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdVariableItemList); diff --git a/lib/subghz/blocks/generic.h b/lib/subghz/blocks/generic.h index d3f7804dc..1e72c5a5e 100644 --- a/lib/subghz/blocks/generic.h +++ b/lib/subghz/blocks/generic.h @@ -35,11 +35,6 @@ struct SubGhzBlockGenericGlobal { bool cnt_need_override; // flag for protocols to override signals counter inside of protocols uint8_t cnt_length_bit; // counter length in bytes (used in counter editor giu) bool cnt_is_available; // is there counter available for protocol (used in counter editor giu) - - uint8_t current_btn; // global counter value; - uint8_t new_btn; // global counter value; - bool btn_need_override; // flag for protocols to override signals counter inside of protocols - bool btn_is_available; // is there counter available for protocol (used in counter editor giu) }; extern SubGhzBlockGenericGlobal subghz_block_generic_global; //global structure for subghz From 5564fe1f314f5f0cdf7069b579b6033bae5c1407 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Mon, 26 Jan 2026 12:46:30 +0300 Subject: [PATCH 8/9] fmt --- applications/drivers/subghz/cc1101_ext/cc1101_ext.c | 6 +++--- lib/subghz/protocols/legrand.c | 2 +- targets/f7/furi_hal/furi_hal_subghz.c | 12 ++++++++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/applications/drivers/subghz/cc1101_ext/cc1101_ext.c b/applications/drivers/subghz/cc1101_ext/cc1101_ext.c index adcf785f2..e24ed8f7a 100644 --- a/applications/drivers/subghz/cc1101_ext/cc1101_ext.c +++ b/applications/drivers/subghz/cc1101_ext/cc1101_ext.c @@ -807,7 +807,7 @@ bool subghz_device_cc1101_ext_start_async_tx(SubGhzDeviceCC1101ExtCallback callb // Configure DMA to update timer TIM17 ARR by durations from buffer LL_DMA_SetMemoryAddress( SUBGHZ_DEVICE_CC1101_EXT_DMA_CH3_DEF, (uint32_t)subghz_device_cc1101_ext->async_tx.buffer); - LL_DMA_SetPeriphAddress(SUBGHZ_DEVICE_CC1101_EXT_DMA_CH3_DEF, (uint32_t)&(TIM17->ARR)); + LL_DMA_SetPeriphAddress(SUBGHZ_DEVICE_CC1101_EXT_DMA_CH3_DEF, (uint32_t) & (TIM17->ARR)); LL_DMA_ConfigTransfer( SUBGHZ_DEVICE_CC1101_EXT_DMA_CH3_DEF, LL_DMA_DIRECTION_MEMORY_TO_PERIPH | LL_DMA_MODE_CIRCULAR | LL_DMA_PERIPH_NOINCREMENT | @@ -849,7 +849,7 @@ bool subghz_device_cc1101_ext_start_async_tx(SubGhzDeviceCC1101ExtCallback callb LL_DMA_SetMemoryAddress( SUBGHZ_DEVICE_CC1101_EXT_DMA_CH4_DEF, (uint32_t)subghz_device_cc1101_ext->async_tx.gpio_tx_buff); - LL_DMA_SetPeriphAddress(SUBGHZ_DEVICE_CC1101_EXT_DMA_CH4_DEF, (uint32_t)&(gpio->port->BSRR)); + LL_DMA_SetPeriphAddress(SUBGHZ_DEVICE_CC1101_EXT_DMA_CH4_DEF, (uint32_t) & (gpio->port->BSRR)); LL_DMA_ConfigTransfer( SUBGHZ_DEVICE_CC1101_EXT_DMA_CH4_DEF, LL_DMA_DIRECTION_MEMORY_TO_PERIPH | LL_DMA_MODE_CIRCULAR | LL_DMA_PERIPH_NOINCREMENT | @@ -869,7 +869,7 @@ bool subghz_device_cc1101_ext_start_async_tx(SubGhzDeviceCC1101ExtCallback callb SUBGHZ_DEVICE_CC1101_EXT_DMA_CH5_DEF, (uint32_t)subghz_device_cc1101_ext->async_tx.debug_gpio_buff); LL_DMA_SetPeriphAddress( - SUBGHZ_DEVICE_CC1101_EXT_DMA_CH5_DEF, (uint32_t)&(gpio->port->BSRR)); + SUBGHZ_DEVICE_CC1101_EXT_DMA_CH5_DEF, (uint32_t) & (gpio->port->BSRR)); LL_DMA_ConfigTransfer( SUBGHZ_DEVICE_CC1101_EXT_DMA_CH5_DEF, LL_DMA_DIRECTION_MEMORY_TO_PERIPH | LL_DMA_MODE_CIRCULAR | LL_DMA_PERIPH_NOINCREMENT | diff --git a/lib/subghz/protocols/legrand.c b/lib/subghz/protocols/legrand.c index 45a46847c..7b8b70204 100644 --- a/lib/subghz/protocols/legrand.c +++ b/lib/subghz/protocols/legrand.c @@ -155,7 +155,7 @@ SubGhzProtocolStatus ret = SubGhzProtocolStatusErrorParserTe; break; } - + // optional parameter flipper_format_read_uint32( flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); diff --git a/targets/f7/furi_hal/furi_hal_subghz.c b/targets/f7/furi_hal/furi_hal_subghz.c index 0f8fa939c..b9723487e 100644 --- a/targets/f7/furi_hal/furi_hal_subghz.c +++ b/targets/f7/furi_hal/furi_hal_subghz.c @@ -684,7 +684,7 @@ static void furi_hal_subghz_async_tx_refill(uint32_t* buffer, size_t samples) { while(samples > 0) { volatile uint32_t duration = furi_hal_subghz_async_tx_middleware_get_duration( &furi_hal_subghz_async_tx.middleware, furi_hal_subghz_async_tx.callback); - // if duration == 0 then we stop DMA interrupt(that used to refill buffer) and write to buffer 0 as last element. + // if duration == 0 then we stop DMA interrupt(that used to refill buffer) and write to buffer 0 as last element. // later DMA write this 0 to ARR and timer TIM2 will be stopped. if(duration == 0) { *buffer = 0; @@ -771,7 +771,7 @@ bool furi_hal_subghz_start_async_tx(FuriHalSubGhzAsyncTxCallback callback, void* // Configure DMA to update TIM2->ARR LL_DMA_InitTypeDef dma_config = {0}; // DMA settings structure - dma_config.PeriphOrM2MSrcAddress = (uint32_t)&(TIM2->ARR); // DMA destination TIM2->ARR + dma_config.PeriphOrM2MSrcAddress = (uint32_t) & (TIM2->ARR); // DMA destination TIM2->ARR dma_config.MemoryOrM2MDstAddress = (uint32_t)furi_hal_subghz_async_tx.buffer; // DMA buffer with signals durations dma_config.Direction = @@ -838,7 +838,7 @@ bool furi_hal_subghz_start_async_tx(FuriHalSubGhzAsyncTxCallback callback, void* furi_hal_subghz_debug_gpio_buff[1] = (uint32_t)gpio->pin << GPIO_NUMBER; dma_config.MemoryOrM2MDstAddress = (uint32_t)furi_hal_subghz_debug_gpio_buff; - dma_config.PeriphOrM2MSrcAddress = (uint32_t)&(gpio->port->BSRR); + dma_config.PeriphOrM2MSrcAddress = (uint32_t) & (gpio->port->BSRR); dma_config.Direction = LL_DMA_DIRECTION_MEMORY_TO_PERIPH; dma_config.Mode = LL_DMA_MODE_CIRCULAR; dma_config.PeriphOrM2MSrcIncMode = LL_DMA_PERIPH_NOINCREMENT; @@ -867,7 +867,11 @@ bool furi_hal_subghz_start_async_tx(FuriHalSubGhzAsyncTxCallback callback, void* bool furi_hal_subghz_is_async_tx_complete(void) { return (furi_hal_subghz.state == SubGhzStateAsyncTx) && (LL_TIM_GetAutoReload(TIM2) == 0); - FURI_LOG_I(TAG, "SubGhzStateAsyncTx %d , TIM2-ARR %ld",furi_hal_subghz.state,LL_TIM_GetAutoReload(TIM2)); + FURI_LOG_I( + TAG, + "SubGhzStateAsyncTx %d , TIM2-ARR %ld", + furi_hal_subghz.state, + LL_TIM_GetAutoReload(TIM2)); } void furi_hal_subghz_stop_async_tx(void) { From 5c7e48cf2f1e46580be55d278f80b4f0b2a3971f Mon Sep 17 00:00:00 2001 From: Dmitry422 Date: Mon, 26 Jan 2026 16:56:26 +0700 Subject: [PATCH 9/9] Remove Debug log --- targets/f7/furi_hal/furi_hal_subghz.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/targets/f7/furi_hal/furi_hal_subghz.c b/targets/f7/furi_hal/furi_hal_subghz.c index b9723487e..ece8dde2c 100644 --- a/targets/f7/furi_hal/furi_hal_subghz.c +++ b/targets/f7/furi_hal/furi_hal_subghz.c @@ -867,11 +867,6 @@ bool furi_hal_subghz_start_async_tx(FuriHalSubGhzAsyncTxCallback callback, void* bool furi_hal_subghz_is_async_tx_complete(void) { return (furi_hal_subghz.state == SubGhzStateAsyncTx) && (LL_TIM_GetAutoReload(TIM2) == 0); - FURI_LOG_I( - TAG, - "SubGhzStateAsyncTx %d , TIM2-ARR %ld", - furi_hal_subghz.state, - LL_TIM_GetAutoReload(TIM2)); } void furi_hal_subghz_stop_async_tx(void) {