Skip to content

Commit

Permalink
Storage of subghz filename
Browse files Browse the repository at this point in the history
  • Loading branch information
David Lee committed Jan 16, 2024
1 parent abcfdf3 commit 56d7a9d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion models/cross/xremote_remote_item.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ bool xremote_pause_save(FlipperFormat* ff, int32_t time, const char* name) {
bool xremote_sg_signal_save(SubGhzRemote* remote, FlipperFormat* ff, const char* name) {
if(!flipper_format_write_comment_cstr(ff, "") ||
!flipper_format_write_string_cstr(ff, "remote_type", "SG") ||
!flipper_format_write_string_cstr(ff, "name", name)) {
!flipper_format_write_string_cstr(ff, "name", name) ||
!flipper_format_write_string_cstr(ff, "filename", xremote_sg_remote_get_filename(remote))) {
return false;
}
return xremote_sg_signal_save_data(remote, ff);
Expand Down
10 changes: 10 additions & 0 deletions models/subghz/xremote_sg_remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

struct SubGhzRemote {
FuriString* name;
FuriString* filename;
FuriString* path;
SubGhzTxRx* txrx;
uint32_t frequency;
Expand All @@ -34,6 +35,10 @@ const char* xremote_sg_remote_get_name(SubGhzRemote* remote) {
return furi_string_get_cstr(remote->name);
}

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,
Expand All @@ -56,6 +61,7 @@ const char* subghz_txrx_radio_device_get_name(SubGhzTxRx* instance) {
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
Expand Down Expand Up @@ -86,6 +92,7 @@ SubGhzRemote* xremote_sg_remote_alloc() {
void xremote_sg_remote_free(SubGhzRemote* remote) {
furi_string_free(remote->path);
furi_string_free(remote->name);
furi_string_free(remote->filename);

// TXRX
subghz_receiver_free(remote->txrx->receiver);
Expand Down Expand Up @@ -145,6 +152,7 @@ bool xremote_sg_remote_load(SubGhzRemote* remote, FuriString* path) {
}
//remote->name = fileName;
furi_string_set_str(remote->name, fileName);
furi_string_set_str(remote->filename, 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;
Expand Down Expand Up @@ -181,6 +189,8 @@ bool xremote_sg_remote_load(SubGhzRemote* remote, FuriString* path) {
break;
}



/*if(!strcmp(furi_string_get_cstr(buf), "RAW")) {
subghz_protocol_raw_gen_fff_data(
remote->txrx->fff_data,
Expand Down
1 change: 1 addition & 0 deletions models/subghz/xremote_sg_remote.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
typedef struct SubGhzRemote SubGhzRemote;

const char* xremote_sg_remote_get_name(SubGhzRemote* remote);
const char* xremote_sg_remote_get_filename(SubGhzRemote* remote);

SubGhzRemote* xremote_sg_remote_alloc();

Expand Down
1 change: 1 addition & 0 deletions xremote_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ struct InfraredSignal {

struct CrossRemoteItem {
FuriString* name;
FuriString* filename;
InfraredSignal* ir_signal;
SubGhzRemote* sg_signal;
int16_t type;
Expand Down

0 comments on commit 56d7a9d

Please sign in to comment.