@@ -75,7 +75,7 @@ static const SubGhzDevice* action_subghz_get_device(uint32_t* device_ind) {
75
75
void action_subghz_tx (void * context , const FuriString * action_path , FuriString * error ) {
76
76
App * app = context ;
77
77
const char * file_name = furi_string_get_cstr (action_path );
78
- uint32_t repeat = 1 ; // This is set to 10 in the cli - why?
78
+ uint32_t repeat = app -> settings . subghz_repeat ; // Defaults to 10 in the CLI
79
79
uint32_t device_ind = app -> settings .subghz_use_ext_antenna ? 1 : 0 ;
80
80
81
81
FlipperFormat * fff_data_file = flipper_format_file_alloc (app -> storage );
@@ -94,10 +94,10 @@ void action_subghz_tx(void* context, const FuriString* action_path, FuriString*
94
94
subghz_devices_init ();
95
95
SubGhzEnvironment * environment = subghz_environment_alloc ();
96
96
if (!subghz_environment_load_keystore (environment , SUBGHZ_KEYSTORE_DIR_NAME )) {
97
- FURI_LOG_E (TAG , "Load_keystore keeloq_mfcodes ERROR " );
97
+ FURI_LOG_W (TAG , "Load_keystore keeloq_mfcodes - failed to load " );
98
98
}
99
99
if (!subghz_environment_load_keystore (environment , SUBGHZ_KEYSTORE_DIR_USER_NAME )) {
100
- FURI_LOG_E (TAG , "Load_keystore keeloq_mfcodes_user ERROR " );
100
+ FURI_LOG_W (TAG , "Load_keystore keeloq_mfcodes_user - failed to load " );
101
101
}
102
102
subghz_environment_set_came_atomo_rainbow_table_file_name (
103
103
environment , SUBGHZ_CAME_ATOMO_DIR_NAME );
@@ -154,16 +154,17 @@ void action_subghz_tx(void* context, const FuriString* action_path, FuriString*
154
154
break ;
155
155
}
156
156
157
- if ( action_subghz_get_preset_name (furi_string_get_cstr (temp_str )) ==
158
- FuriHalSubGhzPresetIDLE ) {
157
+ FuriHalSubGhzPreset preset = action_subghz_get_preset_name (furi_string_get_cstr (temp_str ));
158
+ if ( preset == FuriHalSubGhzPresetIDLE ) {
159
159
ACTION_SET_ERROR ("SUBGHZ: Unknown preset" );
160
160
break ;
161
161
}
162
162
163
163
subghz_devices_begin (device );
164
164
subghz_devices_reset (device );
165
+ subghz_devices_idle (device );
165
166
166
- if (! strcmp ( furi_string_get_cstr ( temp_str ), " FuriHalSubGhzPresetCustom" ) ) {
167
+ if (preset == FuriHalSubGhzPresetCustom ) {
167
168
uint8_t * custom_preset_data ;
168
169
uint32_t custom_preset_data_size ;
169
170
if (!flipper_format_get_value_count (fff_data_file , "Custom_preset_data" , & temp_data32 ))
@@ -184,14 +185,10 @@ void action_subghz_tx(void* context, const FuriString* action_path, FuriString*
184
185
ACTION_SET_ERROR ("SUBGHZ: Custom_preset_data read error" );
185
186
break ;
186
187
}
187
- subghz_devices_load_preset (
188
- device ,
189
- action_subghz_get_preset_name (furi_string_get_cstr (temp_str )),
190
- custom_preset_data );
188
+ subghz_devices_load_preset (device , preset , custom_preset_data );
191
189
free (custom_preset_data );
192
190
} else {
193
- subghz_devices_load_preset (
194
- device , action_subghz_get_preset_name (furi_string_get_cstr (temp_str )), NULL );
191
+ subghz_devices_load_preset (device , preset , NULL );
195
192
}
196
193
197
194
subghz_devices_set_frequency (device , frequency );
@@ -205,7 +202,7 @@ void action_subghz_tx(void* context, const FuriString* action_path, FuriString*
205
202
206
203
SubGhzProtocolStatus status ;
207
204
bool is_init_protocol = true;
208
- if (! strcmp ( furi_string_get_cstr ( temp_str ) , "RAW" )) {
205
+ if (furi_string_equal ( temp_str , "RAW" )) {
209
206
FURI_LOG_I (TAG , "Protocol = RAW" );
210
207
subghz_protocol_raw_gen_fff_data (
211
208
fff_data_raw , file_name , subghz_devices_get_name (device ));
@@ -225,7 +222,10 @@ void action_subghz_tx(void* context, const FuriString* action_path, FuriString*
225
222
}
226
223
} else { // if not RAW protocol
227
224
FURI_LOG_I (TAG , "Protocol != RAW" );
228
- flipper_format_insert_or_update_uint32 (fff_data_file , "Repeat" , & repeat , 1 );
225
+ bool repeat_exists = flipper_format_key_exist (fff_data_file , "Repeat" );
226
+ if (!repeat_exists ) {
227
+ flipper_format_write_uint32 (fff_data_file , "Repeat" , & repeat , 1 );
228
+ }
229
229
transmitter =
230
230
subghz_transmitter_alloc_init (environment , furi_string_get_cstr (temp_str ));
231
231
if (transmitter == NULL ) {
@@ -240,7 +240,9 @@ void action_subghz_tx(void* context, const FuriString* action_path, FuriString*
240
240
is_init_protocol = false;
241
241
}
242
242
}
243
- flipper_format_delete_key (fff_data_file , "Repeat" );
243
+ if (!repeat_exists ) {
244
+ flipper_format_delete_key (fff_data_file , "Repeat" );
245
+ }
244
246
}
245
247
246
248
if (is_init_protocol ) {
@@ -256,32 +258,34 @@ void action_subghz_tx(void* context, const FuriString* action_path, FuriString*
256
258
257
259
if (check_file ) {
258
260
furi_hal_power_suppress_charge_enter ();
261
+ subghz_devices_set_tx (device );
259
262
FURI_LOG_I (
260
263
TAG ,
261
264
"Transmitting at %s. Frequency=%lu, Protocol=%s" ,
262
265
file_name ,
263
266
frequency ,
264
267
furi_string_get_cstr (temp_str ));
265
268
do {
266
- // delay in downloading files and other preparatory processes
267
- furi_delay_ms (200 );
269
+ // FURI_LOG_I(TAG, "delaying 200ms");
270
+ furi_delay_ms (100 ); // needed? orig 200
268
271
if (subghz_devices_start_async_tx (device , subghz_transmitter_yield , transmitter )) {
269
- while (!( subghz_devices_is_async_complete_tx (
270
- device ))) { // || cli_cmd_interrupt_received
271
- furi_delay_ms (333 );
272
+ while (!subghz_devices_is_async_complete_tx (device )) {
273
+ // || cli_cmd_interrupt_received
274
+ furi_delay_ms (100 ); // orig 333
272
275
}
273
276
subghz_devices_stop_async_tx (device );
274
277
} else {
275
278
FURI_LOG_W (TAG , "Transmission on this frequency is restricted in your region" );
276
279
}
277
280
278
- if (! strcmp ( furi_string_get_cstr ( temp_str ) , "RAW" )) {
281
+ if (furi_string_equal ( temp_str , "RAW" )) {
279
282
subghz_transmitter_stop (transmitter );
280
283
repeat -- ;
284
+ // FURI_LOG_I(TAG, "decrementing repeat: %lu", repeat);
281
285
if (repeat ) subghz_transmitter_deserialize (transmitter , fff_data_raw );
282
286
}
283
287
284
- } while (repeat && ! strcmp ( furi_string_get_cstr ( temp_str ) , "RAW" ));
288
+ } while (repeat && furi_string_equal ( temp_str , "RAW" ));
285
289
286
290
subghz_devices_sleep (device );
287
291
subghz_devices_end (device );
0 commit comments