Skip to content

Commit

Permalink
Cleared out old SubGhz module
Browse files Browse the repository at this point in the history
  • Loading branch information
David Lee committed Jan 28, 2024
1 parent cb639c1 commit 76ecb27
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 306 deletions.
4 changes: 1 addition & 3 deletions models/cross/xremote_cross_remote_item.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
Expand Down
1 change: 0 additions & 1 deletion models/cross/xremote_cross_remote_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
55 changes: 0 additions & 55 deletions models/subghz/subghz_i.h

This file was deleted.

79 changes: 0 additions & 79 deletions models/subghz/subghz_types.h

This file was deleted.

159 changes: 0 additions & 159 deletions models/subghz/xremote_sg_remote.c
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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) {
Expand All @@ -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;
}

Expand All @@ -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;
Expand All @@ -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);

Expand Down
18 changes: 9 additions & 9 deletions models/subghz/xremote_sg_remote.h
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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);

0 comments on commit 76ecb27

Please sign in to comment.