David Lee 2 лет назад
Родитель
Сommit
76ecb27d4c

+ 1 - 3
models/cross/xremote_cross_remote_item.c

@@ -31,8 +31,6 @@ static inline bool xremote_sg_signal_save_data(SubGhzRemote* remote, FlipperForm
     UNUSED(remote);
     UNUSED(ff);
     return true;
-    /*return flipper_format_write_uint32(ff, "frequency", xremote_sg_remote_get_frequency(remote)) &&
-           flipper_format_write_string_cstr(ff, "preset", xremote_sg_remote_get_preset(remote));*/
 }
 
 static bool xremote_ir_signal_is_message_valid(InfraredMessage* message) {
@@ -190,7 +188,7 @@ bool xremote_cross_remote_item_read(CrossRemoteItem* item, FlipperFormat* ff) {
 void xremote_cross_remote_item_free(CrossRemoteItem* item) {
     furi_string_free(item->name);
     //Determine type before free
-    //xremote_ir_signal_free(item->ir_signal);
+    xremote_ir_signal_free(item->ir_signal);
     //xremote_sg_remote_free(item->sg_signal);
     free(item);
 }

+ 0 - 1
models/cross/xremote_cross_remote_item.h

@@ -2,7 +2,6 @@
 
 #include "../infrared/xremote_ir_signal.h"
 #include "../subghz/xremote_sg_remote.h"
-#include "../subghz/subghz_i.h"
 #include "../../xremote_i.h"
 
 bool xremote_cross_remote_item_read(CrossRemoteItem* item, FlipperFormat* ff);

+ 0 - 55
models/subghz/subghz_i.h

@@ -1,55 +0,0 @@
-
-#pragma once
-
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <m-array.h>
-#include <toolbox/path.h>
-#include <storage/storage.h>
-#include <core/common_defines.h>
-#include <flipper_format/flipper_format.h>
-#include <lib/subghz/protocols/raw.h>
-//#include <lib/toolbox/path.h>
-//#include <flipper_format/flipper_format_i.h>
-#include <lib/toolbox/stream/stream.h>
-//#include <lib/subghz/protocols/protocol_items.h> //Not found
-#include <lib/subghz/subghz_worker.h>
-#include <lib/subghz/subghz_setting.h>
-#include <lib/subghz/receiver.h>
-#include <lib/subghz/transmitter.h>
-#include <lib/subghz/devices/devices.h>
-//#include <lib/subghz/blocks/custom_btn.h>
-
-#include <flipper_format/flipper_format_i.h>
-
-#include "subghz_types.h"
-
-extern const SubGhzProtocolRegistry subghz_protocol_registry;
-
-struct SubGhzTxRx {
-    //SubGhzWorker* worker;
-
-    SubGhzEnvironment* environment;
-    SubGhzReceiver* receiver;
-    //SubGhzTransmitter* transmitter;
-    //SubGhzProtocolFlag filter;
-    SubGhzProtocolDecoderBase* decoder_result;
-    FlipperFormat* fff_data;
-
-    SubGhzRadioPreset* preset;
-    //SubGhzHistory* history;
-    //uint16_t idx_menu_chosen;
-    //SubGhzTxRxState txrx_state;
-    //SubGhzHopperState hopper_state;
-    //SubGhzSpeakerState speaker_state;
-    //uint8_t hopper_timeout;
-    //uint8_t hopper_idx_frequency;
-    //SubGhzRxKeyState rx_key_state;
-
-    //float raw_threshold_rssi;
-    //uint8_t raw_threshold_rssi_low_count;
-    const SubGhzDevice* radio_device;
-};
-
-typedef struct SubGhzTxRx SubGhzTxRx;

+ 0 - 79
models/subghz/subghz_types.h

@@ -1,79 +0,0 @@
-#pragma once
-
-#include <furi.h>
-#include <furi_hal.h>
-
-/** SubGhzNotification state */
-typedef enum {
-    SubGhzNotificationStateStarting,
-    SubGhzNotificationStateIDLE,
-    SubGhzNotificationStateTx,
-    SubGhzNotificationStateRx,
-    SubGhzNotificationStateRxDone,
-} SubGhzNotificationState;
-
-/** SubGhzTxRx state */
-typedef enum {
-    SubGhzTxRxStateIDLE,
-    SubGhzTxRxStateRx,
-    SubGhzTxRxStateTx,
-    SubGhzTxRxStateSleep,
-} SubGhzTxRxState;
-
-/** SubGhzHopperState state */
-typedef enum {
-    SubGhzHopperStateOFF,
-    SubGhzHopperStateRunnig,
-    SubGhzHopperStatePause,
-    SubGhzHopperStateRSSITimeOut,
-} SubGhzHopperState;
-
-/** SubGhzSpeakerState state */
-typedef enum {
-    SubGhzSpeakerStateDisable,
-    SubGhzSpeakerStateShutdown,
-    SubGhzSpeakerStateEnable,
-} SubGhzSpeakerState;
-
-/** SubGhzRxKeyState state */
-typedef enum {
-    SubGhzRxKeyStateIDLE,
-    SubGhzRxKeyStateNoSave,
-    SubGhzRxKeyStateNeedSave,
-    SubGhzRxKeyStateBack,
-    SubGhzRxKeyStateStart,
-    SubGhzRxKeyStateAddKey,
-    SubGhzRxKeyStateExit,
-    SubGhzRxKeyStateRAWLoad,
-    SubGhzRxKeyStateRAWSave,
-} SubGhzRxKeyState;
-
-/** SubGhzLoadKeyState state */
-typedef enum {
-    SubGhzLoadKeyStateUnknown,
-    SubGhzLoadKeyStateOK,
-    SubGhzLoadKeyStateParseErr,
-    SubGhzLoadKeyStateProtocolDescriptionErr,
-} SubGhzLoadKeyState;
-
-/** SubGhzLock */
-typedef enum {
-    SubGhzLockOff,
-    SubGhzLockOn,
-} SubGhzLock;
-
-typedef enum {
-    SubGhzViewIdMenu,
-    SubGhzViewIdReceiver,
-    SubGhzViewIdPopup,
-    SubGhzViewIdTextInput,
-    SubGhzViewIdWidget,
-    SubGhzViewIdTransmitter,
-    SubGhzViewIdVariableItemList,
-    SubGhzViewIdFrequencyAnalyzer,
-    SubGhzViewIdReadRAW,
-
-    SubGhzViewIdStatic,
-    SubGhzViewIdTestCarrier,
-    SubGhzViewIdTestPacket,
-} SubGhzViewId;

+ 0 - 159
models/subghz/xremote_sg_remote.c

@@ -1,23 +1,3 @@
-#include "subghz/types.h"
-#include <lib/toolbox/path.h>
-#include <lib/subghz/types.h>
-#include <lib/subghz/subghz_worker.h>
-#include <lib/subghz/subghz_setting.h>
-#include <lib/subghz/receiver.h>
-#include <lib/subghz/transmitter.h>
-#include <lib/subghz/registry.h>
-//#include <lib/subghz/protocols/keeloq.h>
-//#include <lib/subghz/protocols/secplus_v1.h>
-//#include <lib/subghz/protocols/secplus_v2.h>
-//#include <lib/subghz/protocols/princeton_for_testing.h>
-//#include <lib/subghz/blocks/math.h>
-//#include <lib/subghz/protocols/raw.h>
-//#include <lib/subghz/protocols/bin_raw.h>
-//#include <lib/subghz/protocols/protocol_items.h>
-//#include <lib/subghz/protocols/protocol_items.c>
-#include <lib/subghz/subghz_keystore.h>
-//#include <lib/subghz/subghz_file_encoder_worker.h>
-#include <gui/modules/variable_item_list.h>
 #include "xremote_sg_remote.h"
 
 #define TAG "Xremote"
@@ -26,9 +6,6 @@ struct SubGhzRemote {
     FuriString* name;
     FuriString* filename;
     FuriString* path;
-    SubGhzTxRx* txrx;
-    uint32_t frequency;
-    SubGhzSetting* setting;
 };
 
 const char* xremote_sg_remote_get_name(SubGhzRemote* remote) {
@@ -39,53 +16,12 @@ const char* xremote_sg_remote_get_filename(SubGhzRemote* remote) {
     return furi_string_get_cstr(remote->filename);
 }
 
-void subghz_preset_init(
-    void* context,
-    const char* preset_name,
-    uint32_t frequency,
-    uint8_t* preset_data,
-    size_t preset_data_size) {
-    furi_assert(context);
-    SubGhzRemote* remote = context;
-    furi_string_set(remote->txrx->preset->name, preset_name);
-    remote->txrx->preset->frequency = frequency;
-    remote->txrx->preset->data = preset_data;
-    remote->txrx->preset->data_size = preset_data_size;
-}
-
-const char* subghz_txrx_radio_device_get_name(SubGhzTxRx* instance) {
-    furi_assert(instance);
-    return subghz_devices_get_name(instance->radio_device);
-}
-
 SubGhzRemote* xremote_sg_remote_alloc() {
     SubGhzRemote* remote = malloc(sizeof(SubGhzRemote));
     remote->name = furi_string_alloc();
     remote->filename = furi_string_alloc();
     remote->path = furi_string_alloc();
 
-    // SubGhz Settings
-    remote->setting = subghz_setting_alloc();
-    subghz_setting_load(remote->setting, EXT_PATH("subghz/assets/setting_user"));
-
-    remote->txrx = malloc(sizeof(SubGhzTxRx));
-    remote->txrx->preset = malloc(sizeof(SubGhzRadioPreset));
-    remote->txrx->preset->name = furi_string_alloc();
-    subghz_preset_init(
-        remote, "AM650", subghz_setting_get_default_frequency(remote->setting), NULL, 0);
-    remote->txrx->fff_data = flipper_format_string_alloc();
-    remote->txrx->environment = subghz_environment_alloc();
-    /*subghz_environment_set_came_atomo_rainbow_table_file_name(
-        remote->txrx->environment, EXT_PATH("subghz/assets/came_atomo"));
-    subghz_environment_set_alutech_at_4n_rainbow_table_file_name(
-        remote->txrx->environment, EXT_PATH("subghz/assets/alutech_at_4n"));
-    subghz_environment_set_nice_flor_s_rainbow_table_file_name(
-        remote->txrx->environment, EXT_PATH("subghz/assets/nice_flor_s"));
-    subghz_environment_set_protocol_registry(
-        remote->txrx->environment, (void*)&subghz_protocol_registry);
-    remote->txrx->receiver = subghz_receiver_alloc_init(remote->txrx->environment);*/
-    //remote->txrx->worker = subghz_worker_alloc();
-
     return remote;
 }
 
@@ -94,50 +30,15 @@ void xremote_sg_remote_free(SubGhzRemote* remote) {
     furi_string_free(remote->name);
     furi_string_free(remote->filename);
 
-    // TXRX
-    subghz_receiver_free(remote->txrx->receiver);
-    subghz_environment_free(remote->txrx->environment);
-    flipper_format_free(remote->txrx->fff_data);
-    furi_string_free(remote->txrx->preset->name);
-    free(remote->txrx->preset);
-    free(remote->txrx);
-
     free(remote);
 }
 
-bool xremtoe_sg_set_preset(SubGhzRemote* remote, const char* preset) {
-    if(!strcmp(preset, "FuriHalSubGhzPresetOok270Async")) {
-        furi_string_set(remote->txrx->preset->name, "AM270");
-    } else if(!strcmp(preset, "FuriHalSubGhzPresetOok650Async")) {
-        furi_string_set(remote->txrx->preset->name, "AM650");
-    } else if(!strcmp(preset, "FuriHalSubGhzPreset2FSKDev238Async")) {
-        furi_string_set(remote->txrx->preset->name, "FM238");
-    } else if(!strcmp(preset, "FuriHalSubGhzPreset2FSKDev476Async")) {
-        furi_string_set(remote->txrx->preset->name, "FM476");
-    } else if(!strcmp(preset, "FuriHalSubGhzPresetCustom")) {
-        furi_string_set(remote->txrx->preset->name, "CUSTOM");
-    } else {
-        FURI_LOG_E(TAG, "Unknown preset");
-        return false;
-    }
-    return true;
-}
-
-uint32_t xremote_sg_remote_get_frequency(SubGhzRemote* remote) {
-    return remote->txrx->preset->frequency;
-}
-
-const char* xremote_sg_remote_get_preset(SubGhzRemote* remote) {
-    return furi_string_get_cstr(remote->txrx->preset->name);
-}
-
 bool xremote_sg_remote_load(SubGhzRemote* remote, FuriString* path) {
     Storage* storage = furi_record_open(RECORD_STORAGE);
     FlipperFormat* ff = flipper_format_buffered_file_alloc(storage);
 
     FuriString* buf;
     buf = furi_string_alloc();
-    uint32_t temp_data32;
 
     FURI_LOG_I(TAG, "loading SG Remote: \'%s\'", furi_string_get_cstr(path));
     bool success = false;
@@ -157,66 +58,6 @@ bool xremote_sg_remote_load(SubGhzRemote* remote, FuriString* path) {
         if(!flipper_format_read_header(ff, buf, &version)) break;
         if(!furi_string_equal(buf, "Flipper SubGhz RAW File") || (version != 1)) break;
 
-        if(!flipper_format_read_uint32(ff, "Frequency", &temp_data32, 1)) {
-            FURI_LOG_E(TAG, "Missing Frequency");
-            break;
-        }
-        remote->frequency = temp_data32;
-
-        if(!flipper_format_read_string(ff, "Preset", buf)) {
-            FURI_LOG_E(TAG, "Missing Preset");
-            break;
-        }
-        if(!xremtoe_sg_set_preset(remote, furi_string_get_cstr(buf))) {
-            break;
-        }
-
-        if(!strcmp(furi_string_get_cstr(buf), "FuriHalSubGhzPresetCustom")) {
-            //Todo add Custom_preset_module
-            //delete preset if it already exists
-            subghz_setting_delete_custom_preset(
-                remote->setting, furi_string_get_cstr(remote->txrx->preset->name));
-            //load custom preset from file
-            if(!subghz_setting_load_custom_preset(
-                   remote->setting, furi_string_get_cstr(remote->txrx->preset->name), ff)) {
-                FURI_LOG_E(TAG, "Missing Custom preset");
-                break;
-            }
-        }
-
-        if(!flipper_format_read_string(ff, "Protocol", buf)) {
-            FURI_LOG_E(TAG, "Missing Protocol");
-            break;
-        }
-
-
-
-        /*if(!strcmp(furi_string_get_cstr(buf), "RAW")) {
-            subghz_protocol_raw_gen_fff_data(
-                remote->txrx->fff_data,
-                furi_string_get_cstr(path),
-                subghz_txrx_radio_device_get_name(remote->txrx));
-        } else {
-            stream_copy_full(
-                flipper_format_get_raw_stream(ff),
-                flipper_format_get_raw_stream(remote->txrx->fff_data));
-        }*/
-
-        /*remote->txrx->decoder_result = subghz_receiver_search_decoder_base_by_name(
-            remote->txrx->receiver, furi_string_get_cstr(buf));*/
-        /*if(remote->txrx->decoder_result) {
-            SubGhzProtocolStatus status = subghz_protocol_decoder_base_deserialize(
-                remote->txrx->decoder_result, remote->txrx->fff_data);
-            if(status != SubGhzProtocolStatusOk) {
-                //load_key_state = SubGhzLoadKeyStateProtocolDescriptionErr;
-                success = false;
-                break;
-            }
-        } else {
-            FURI_LOG_E(TAG, "Protocol not found");
-            break;
-        }*/
-
         success = true;
     } while(false);
 

+ 9 - 9
models/subghz/xremote_sg_remote.h

@@ -1,10 +1,14 @@
 #pragma once
 
 //#include "../../xremote_i.h"
-#include "subghz_i.h"
-//#include <lib/subghz/protocols/protocol_items.h>
-
-//extern const SubGhzProtocolRegistry subghz_protocol_registry;
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdlib.h>
+//#include <m-array.h>
+#include <storage/storage.h>
+#include <core/common_defines.h>
+#include <flipper_format/flipper_format.h>
+#include <flipper_format/flipper_format_i.h>
 
 typedef struct SubGhzRemote SubGhzRemote;
 
@@ -15,8 +19,4 @@ SubGhzRemote* xremote_sg_remote_alloc();
 
 void xremote_sg_remote_free(SubGhzRemote* remote);
 
-bool xremote_sg_remote_load(SubGhzRemote* remote, FuriString* path);
-
-uint32_t xremote_sg_remote_get_frequency(SubGhzRemote* remote);
-
-const char* xremote_sg_remote_get_preset(SubGhzRemote* remote);
+bool xremote_sg_remote_load(SubGhzRemote* remote, FuriString* path);