소스 검색

Merge subghz_playlist from https://github.com/xMasterX/all-the-plugins

WillyJL 8 달 전
부모
커밋
dc6d2e164b
2개의 변경된 파일34개의 추가작업 그리고 4개의 파일을 삭제
  1. 1 1
      subghz_playlist/.gitsubtree
  2. 33 3
      subghz_playlist/playlist.c

+ 1 - 1
subghz_playlist/.gitsubtree

@@ -1 +1 @@
-https://github.com/xMasterX/all-the-plugins dev base_pack/playlist 4558d74c9da36abc851edd96a95d18f7d5511a75
+https://github.com/xMasterX/all-the-plugins dev base_pack/playlist 8b9d3e75faa8fbd1ed251476f2e7b410dd99a285

+ 33 - 3
subghz_playlist/playlist.c

@@ -111,7 +111,7 @@ static FuriHalSubGhzPreset str_to_preset(FuriString* preset) {
 }
 
 // -4: missing protocol
-// -3: missing preset
+// -3: missing or wrong preset
 // -2: transmit error
 // -1: error
 // 0: ok
@@ -147,6 +147,38 @@ static int playlist_worker_process(
     if(!flipper_format_read_string(fff_file, "Preset", preset)) {
         FURI_LOG_E(TAG, "  (TX) Missing Preset");
         return -3;
+        // load preset
+    } else {
+                uint32_t temp_data32;
+                uint8_t* custom_preset_data;
+                uint32_t custom_preset_data_size;
+
+                if(!strcmp(furi_string_get_cstr(preset), "FuriHalSubGhzPresetCustom")) {
+
+                    if(!flipper_format_get_value_count(fff_file, "Custom_preset_data", &temp_data32))
+                        return -3;
+                    if(!temp_data32 || (temp_data32 % 2)) {
+                        FURI_LOG_E(TAG, "  (TX) Missing Custom preset data");
+                        return -3;
+                    }
+                    custom_preset_data_size = sizeof(uint8_t) * temp_data32;
+                    custom_preset_data = malloc(custom_preset_data_size);
+                    if(!flipper_format_read_hex(
+                           fff_file,
+                           "Custom_preset_data",
+                           custom_preset_data,
+                           custom_preset_data_size)) {
+                        FURI_LOG_E(TAG, " (TX) Custom preset data read error");
+                        return -3;
+                    }
+                    subghz_devices_load_preset(worker->radio_device,str_to_preset(preset),custom_preset_data);
+                    free(custom_preset_data);
+                    FURI_LOG_D(TAG, "  (TX) Custom preset loaded ");
+                } else {
+                    subghz_devices_load_preset(worker->radio_device, str_to_preset(preset), NULL);
+                    FURI_LOG_D(TAG, "  (TX) Standart preset loaded ");
+                }
+
     }
 
     // check if protocol is present
@@ -173,8 +205,6 @@ static int playlist_worker_process(
 
     subghz_transmitter_deserialize(transmitter, fff_data);
 
-    subghz_devices_load_preset(worker->radio_device, str_to_preset(preset), NULL);
-    // there is no check for a custom preset
     frequency = subghz_devices_set_frequency(worker->radio_device, frequency);
 
     // Set device to TX and check frequency is alowed to TX