Просмотр исходного кода

First time IR and SG work together, but still very unstable

David Lee 1 год назад
Родитель
Сommit
97c98a87a6

+ 3 - 0
models/cross/xremote_cross_remote_item.c

@@ -3,6 +3,7 @@
 CrossRemoteItem* xremote_cross_remote_item_alloc() {
     CrossRemoteItem* item = malloc(sizeof(CrossRemoteItem));
     item->name = furi_string_alloc();
+    item->filename = furi_string_alloc();
     item->time = 0;
     item->type = 0;
     item->ir_signal = xremote_ir_signal_alloc();
@@ -75,6 +76,7 @@ static bool xremote_cross_remote_item_read_sg(CrossRemoteItem* item, FlipperForm
 
     do {
         if(!flipper_format_read_string(ff, "name", item->name)) break;
+        if(!flipper_format_read_string(ff, "filename", item->filename)) break;
         success = true;
     } while(false);
     furi_string_free(buf);
@@ -188,6 +190,7 @@ bool xremote_cross_remote_item_read(CrossRemoteItem* item, FlipperFormat* ff) {
 
 void xremote_cross_remote_item_free(CrossRemoteItem* item) {
     furi_string_free(item->name);
+    furi_string_free(item->filename);
     //Determine type before free
     xremote_ir_signal_free(item->ir_signal);
     xremote_sg_remote_free(item->sg_signal);

+ 3 - 1
models/subghz/xremote_sg_remote.c

@@ -47,13 +47,15 @@ bool xremote_sg_remote_load(SubGhzRemote* remote, FuriString* path) {
         if(!flipper_format_buffered_file_open_existing(ff, furi_string_get_cstr(path))) break;
         const char* fullPath = furi_string_get_cstr(path);
         char* fileName = strrchr(fullPath, '/') + 1;
+        furi_string_set_str(remote->filename, fullPath);
         char* dotPosition = strrchr(fileName, '.');
         if(dotPosition != NULL) { // check if there is a dot in the file name
             *dotPosition = '\0'; // set the dot position to NULL character to truncate the string
         }
         //remote->name = fileName;
         furi_string_set_str(remote->name, fileName);
-        furi_string_set_str(remote->filename, fileName);
+        //furi_string_set_str(remote->filename, fileName);
+        //free(fileName);
         uint32_t version;
         if(!flipper_format_read_header(ff, buf, &version)) break;
         if(!furi_string_equal(buf, "Flipper SubGhz RAW File") || (version != 1)) break;

+ 3 - 0
scenes/xremote_scene_transmit.c

@@ -1,6 +1,7 @@
 #include "../xremote.h"
 #include "../views/xremote_transmit.h"
 #include "../models/infrared/xremote_ir_signal.h"
+#include "../helpers/subghz/subghz.h"
 
 static const NotificationSequence* xremote_notification_sequences[] = {
     &sequence_success,
@@ -83,6 +84,8 @@ void xremote_scene_transmit_send_subghz(XRemote* app, CrossRemoteItem* item) {
     app->transmitting = true;
     xremote_scene_ir_notification_message(app, SubGhzNotificationMessageBlinkStartSend);
     // ADD SEND METHOD HERE
+    //FURI_LOG_D("SUBGZK", "path: %s", furi_string_get_cstr(item->filename));
+    subghz_send(app, furi_string_get_cstr(item->filename)); //currently crashes, null pointer
     furi_thread_flags_wait(0, FuriFlagWaitAny, 2000); //Remove later
     app->transmitting = false;
     xremote_scene_ir_notification_message(app, SubGhzNotificationMessageBlinkStop);