Skip to content

Commit

Permalink
Updated Cross Remote WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
RogueMaster committed May 6, 2023
1 parent ff1f219 commit a64ada2
Show file tree
Hide file tree
Showing 21 changed files with 553 additions and 7 deletions.
1 change: 1 addition & 0 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ This software is for experimental purposes only and is not meant for any illegal
- [Add Dummy Loader support to Loader #618 (By ESurge)](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/pull/618)
- OFW: [SubGhz: refactoring app #2554 (By Skorpionm)](https://github.com/flipperdevices/flipperzero-firmware/pull/2554)
- OFW: [Various Furi/FuriHal bug fixes and improvements #2637 (By skotopes)](https://github.com/flipperdevices/flipperzero-firmware/pull/2637)
- Updated: [Cross Remote WIP (By leedave)](https://github.com/leedave/Leeds-Flipper-Zero-Applications/tree/feature/xremote)

<a name="release">

Expand Down
6 changes: 6 additions & 0 deletions applications/external/xremote/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Flipper Zero Cross Remote

## Current State
- Infrared working
- Pause working
- SubGhz in Development
- Edit/Rename/Delete features in development

## What this is?
This app combines commands used in IR and SubGhz into playlists that can be run with one click
<br><br>
Expand Down
3 changes: 2 additions & 1 deletion applications/external/xremote/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ App(
requires=[
"gui",
"storage",
"dialogs",
],
stack_size=2 * 1024,
stack_size=3 * 1024,
order=10,
fap_icon="xremote_10px.png",
fap_icon_assets="icons",
Expand Down
25 changes: 25 additions & 0 deletions applications/external/xremote/models/cross/xremote_remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,17 @@ bool cross_remote_add_pause(CrossRemote* remote, int time) {
return true;
}

bool cross_remote_add_subghz(CrossRemote* remote, SubGhzRemote* subghz) {
UNUSED(subghz);
CrossRemoteItem* item = xremote_remote_item_alloc();
xremote_remote_item_set_type(item, XRemoteRemoteItemTypeSubGhz);
xremote_remote_item_set_name(item, xremote_sg_remote_get_name(subghz));
xremote_remote_item_set_sg_signal(item, subghz);

CrossRemoteItemArray_push_back(remote->items, item);
return true;
}

size_t cross_remote_get_item_count(CrossRemote* remote) {
return CrossRemoteItemArray_size(remote->items);
}
Expand All @@ -118,6 +129,15 @@ CrossRemoteItem* cross_remote_get_item(CrossRemote* remote, size_t index) {
return *CrossRemoteItemArray_get(remote->items, index);
}

void cross_remote_remove_item(CrossRemote* remote, size_t index) {
CrossRemoteItemArray_erase(remote->items, index);
}

void cross_remote_rename_item(CrossRemote* remote, size_t index, const char* name) {
CrossRemoteItem* item = cross_remote_get_item(remote, index);
xremote_remote_item_set_name(item, name);
}

bool cross_remote_load(CrossRemote* remote, FuriString* path) {
Storage* storage = furi_record_open(RECORD_STORAGE);
FlipperFormat* ff = flipper_format_buffered_file_alloc(storage);
Expand Down Expand Up @@ -209,6 +229,11 @@ bool cross_remote_store(CrossRemote* remote) {
xremote_remote_item_get_name(item));
} else if(item->type == XRemoteRemoteItemTypePause) {
success = xremote_pause_save(ff, item->time, xremote_remote_item_get_name(item));
} else if(item->type == XRemoteRemoteItemTypeSubGhz) {
success = xremote_sg_signal_save(
xremote_remote_item_get_sg_signal(item),
ff,
xremote_remote_item_get_name(item));
}
if(!success) {
break;
Expand Down
3 changes: 3 additions & 0 deletions applications/external/xremote/models/cross/xremote_remote.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ void cross_remote_set_transmitting(CrossRemote* remote, int status);
int cross_remote_get_transmitting(CrossRemote* remote);
bool cross_remote_add_pause(CrossRemote* remote, int time);
bool cross_remote_add_ir_item(CrossRemote* remote, const char* name, InfraredSignal* signal);
bool cross_remote_add_subghz(CrossRemote* remote, SubGhzRemote* subghz);
void cross_remote_remove_item(CrossRemote* remote, size_t index);
void cross_remote_rename_item(CrossRemote* remote, size_t index, const char* name);
size_t cross_remote_get_item_count(CrossRemote* remote);
CrossRemoteItem* cross_remote_get_item(CrossRemote* remote, size_t index);

Expand Down
26 changes: 26 additions & 0 deletions applications/external/xremote/models/cross/xremote_remote_item.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ CrossRemoteItem* xremote_remote_item_alloc() {
item->time = 0;
item->type = 0;
item->ir_signal = xremote_ir_signal_alloc();
item->sg_signal = xremote_sg_remote_alloc();

return item;
}
Expand All @@ -26,6 +27,14 @@ static inline bool xremote_ir_signal_save_raw(InfraredRawSignal* raw, FlipperFor
flipper_format_write_uint32(ff, "data", raw->timings, raw->timings_size);
}

static inline bool xremote_sg_signal_save_data(SubGhzRemote* remote, FlipperFormat* ff) {
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) {
if(!infrared_is_protocol_valid(message->protocol)) {
FURI_LOG_E(TAG, "Unknown protocol");
Expand Down Expand Up @@ -180,6 +189,10 @@ void xremote_remote_item_set_ir_signal(CrossRemoteItem* item, InfraredSignal* si
xremote_ir_signal_set_signal(item->ir_signal, signal);
}

void xremote_remote_item_set_sg_signal(CrossRemoteItem* item, SubGhzRemote* subghz) {
item->sg_signal = subghz;
}

const char* xremote_remote_item_get_name(CrossRemoteItem* item) {
return furi_string_get_cstr(item->name);
}
Expand All @@ -188,6 +201,10 @@ InfraredSignal* xremote_remote_item_get_ir_signal(CrossRemoteItem* item) {
return item->ir_signal;
}

SubGhzRemote* xremote_remote_item_get_sg_signal(CrossRemoteItem* item) {
return item->sg_signal;
}

bool xremote_ir_signal_save(InfraredSignal* signal, FlipperFormat* ff, const char* name) {
if(!flipper_format_write_comment_cstr(ff, "") ||
!flipper_format_write_string_cstr(ff, "remote_type", "IR") ||
Expand All @@ -209,3 +226,12 @@ bool xremote_pause_save(FlipperFormat* ff, int32_t time, const char* name) {
}
return true;
}

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)) {
return false;
}
return xremote_sg_signal_save_data(remote, ff);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#pragma once

#include "../infrared/xremote_ir_signal.h"
#include "../subghz/xremote_sg_remote.h"
#include "../subghz/subghz_i.h"
#include "../../xremote_i.h"

bool xremote_remote_item_read(CrossRemoteItem* item, FlipperFormat* ff);
Expand All @@ -21,6 +23,9 @@ void xremote_remote_item_set_time(CrossRemoteItem* item, int32_t time);

InfraredSignal* xremote_remote_item_get_ir_signal(CrossRemoteItem* item);
void xremote_remote_item_set_ir_signal(CrossRemoteItem* item, InfraredSignal* signal);
SubGhzRemote* xremote_remote_item_get_sg_signal(CrossRemoteItem* item);
void xremote_remote_item_set_sg_signal(CrossRemoteItem* item, SubGhzRemote* subghz);

bool xremote_pause_save(FlipperFormat* ff, int32_t time, const char* name);
bool xremote_ir_signal_save(InfraredSignal* signal, FlipperFormat* ff, const char* name);
bool xremote_sg_signal_save(SubGhzRemote* remote, FlipperFormat* ff, const char* name);
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ bool xremote_ir_remote_load(InfraredRemote* remote, FuriString* path) {
success = true;
} while(false);

UNUSED(remote);

furi_string_free(buf);
flipper_format_free(ff);
furi_record_close(RECORD_STORAGE);
Expand Down
53 changes: 53 additions & 0 deletions applications/external/xremote/models/subghz/subghz_i.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@

#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>
#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/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;
};

typedef struct SubGhzTxRx SubGhzTxRx;
79 changes: 79 additions & 0 deletions applications/external/xremote/models/subghz/subghz_types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#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;
Loading

0 comments on commit a64ada2

Please sign in to comment.