@@ -297,7 +297,7 @@ static void infrared_free(InfraredApp* infrared) {
297
297
free (infrared );
298
298
}
299
299
300
- bool infrared_add_remote_with_button (
300
+ InfraredErrorCode infrared_add_remote_with_button (
301
301
const InfraredApp * infrared ,
302
302
const char * button_name ,
303
303
const InfraredSignal * signal ) {
@@ -310,21 +310,23 @@ bool infrared_add_remote_with_button(
310
310
furi_string_cat_printf (
311
311
new_path , "/%s%s" , furi_string_get_cstr (new_name ), INFRARED_APP_EXTENSION );
312
312
313
- bool success = false ;
313
+ InfraredErrorCode error = InfraredErrorCodeNone ;
314
314
315
315
do {
316
- if (!infrared_remote_create (remote , furi_string_get_cstr (new_path ))) break ;
317
- if (!infrared_remote_append_signal (remote , signal , button_name )) break ;
318
- success = true;
316
+ error = infrared_remote_create (remote , furi_string_get_cstr (new_path ));
317
+ if (INFRARED_ERROR_PRESENT (error )) break ;
318
+
319
+ error = infrared_remote_append_signal (remote , signal , button_name );
319
320
} while (false);
320
321
321
322
furi_string_free (new_name );
322
323
furi_string_free (new_path );
323
324
324
- return success ;
325
+ return error ;
325
326
}
326
327
327
- bool infrared_rename_current_remote (const InfraredApp * infrared , const char * new_name ) {
328
+ InfraredErrorCode
329
+ infrared_rename_current_remote (const InfraredApp * infrared , const char * new_name ) {
328
330
InfraredRemote * remote = infrared -> remote ;
329
331
const char * old_path = infrared_remote_get_path (remote );
330
332
@@ -344,12 +346,13 @@ bool infrared_rename_current_remote(const InfraredApp* infrared, const char* new
344
346
path_append (new_path_fstr , furi_string_get_cstr (new_name_fstr ));
345
347
furi_string_cat (new_path_fstr , INFRARED_APP_EXTENSION );
346
348
347
- const bool success = infrared_remote_rename (remote , furi_string_get_cstr (new_path_fstr ));
349
+ const InfraredErrorCode error =
350
+ infrared_remote_rename (remote , furi_string_get_cstr (new_path_fstr ));
348
351
349
352
furi_string_free (new_name_fstr );
350
353
furi_string_free (new_path_fstr );
351
354
352
- return success ;
355
+ return error ;
353
356
}
354
357
355
358
void infrared_tx_start (InfraredApp * infrared ) {
@@ -382,15 +385,16 @@ void infrared_tx_start(InfraredApp* infrared) {
382
385
infrared -> app_state .is_transmitting = true;
383
386
}
384
387
385
- bool infrared_tx_start_button_index (InfraredApp * infrared , size_t button_index ) {
388
+ InfraredErrorCode infrared_tx_start_button_index (InfraredApp * infrared , size_t button_index ) {
386
389
furi_assert (button_index < infrared_remote_get_signal_count (infrared -> remote ));
387
390
388
- bool result =
391
+ InfraredErrorCode error =
389
392
infrared_remote_load_signal (infrared -> remote , infrared -> current_signal , button_index );
390
- if (result ) {
393
+
394
+ if (!INFRARED_ERROR_PRESENT (error )) {
391
395
infrared_tx_start (infrared );
392
396
}
393
- return result ;
397
+ return error ;
394
398
}
395
399
396
400
void infrared_tx_stop (InfraredApp * infrared ) {
@@ -413,7 +417,7 @@ void infrared_blocking_task_start(InfraredApp* infrared, FuriThreadCallback call
413
417
furi_thread_start (infrared -> task_thread );
414
418
}
415
419
416
- bool infrared_blocking_task_finalize (InfraredApp * infrared ) {
420
+ InfraredErrorCode infrared_blocking_task_finalize (InfraredApp * infrared ) {
417
421
furi_thread_join (infrared -> task_thread );
418
422
return furi_thread_get_return_code (infrared -> task_thread );
419
423
}
@@ -563,10 +567,18 @@ int32_t infrared_app(void* p) {
563
567
is_rpc_mode = true;
564
568
} else {
565
569
const char * file_path = (const char * )p ;
566
- is_remote_loaded = infrared_remote_load (infrared -> remote , file_path );
567
-
568
- if (!is_remote_loaded ) {
569
- infrared_show_error_message (infrared , "Failed to load\n\"%s\"" , file_path );
570
+ InfraredErrorCode error = infrared_remote_load (infrared -> remote , file_path );
571
+
572
+ if (!INFRARED_ERROR_PRESENT (error )) {
573
+ is_remote_loaded = true;
574
+ } else {
575
+ is_remote_loaded = false;
576
+ bool wrong_file_type = INFRARED_ERROR_CHECK (error , InfraredErrorCodeWrongFileType );
577
+ const char * format = wrong_file_type ?
578
+ "Library file\n\"%s\" can't be openned as a remote" :
579
+ "Failed to load\n\"%s\"" ;
580
+
581
+ infrared_show_error_message (infrared , format , file_path );
570
582
return -1 ;
571
583
}
572
584
0 commit comments