[FL-1610] SubGhz: scene based application, PT save and replay (#630)
* SubGhz: scene based application
* SubGhz: encoder/decoder separation, DMA streaming, update app and cli.
* SubGhz: 2 stage async tx complete, minor cleanup
* SubGhz: 2 stage async tx complete, FIX state pin end transmit
* SubGhz: Pricenton, receive TE signal
* SubGhz: Pricenton, add save data, add load data
* SubGhz: Add Read scene, Fix pricenton save, load funtion
* SubGhz: Add Read, Receiver, SaveName scene
* SubGhz: Read and Save (pricenton)
* SubGhz: add Load scence
* SubGhz: Fix select file scene, add load scene, add transmitter view, add send tx pricenton
* SubGhz: Fix pricenton encoder, fix transmitter send
* SubGhz: modified Pricenton Encoder (added guard time at the beginning), modified CC1101 config, code refactoring
* SubGhz: Fix pricenton encoder defalut TE
* Archive: Fix path and name SubGhz
* Archive: Fix name app SubGhz
* GubGhz: Came: add Save, Load key
* GubGhz: GateTX: add Save, Load key
* GubGhz: NeroSketch: add Save, Load key
* Github: better linters triggers
* SubGhz: adding fast loading keys Archive -> Run in app
* GubGhz: KeeLog: add Save, Load key, key generation from the serial number of the meter and the button
* SubGhz: format sources and fix compilation
* FuriHal: add subghz configuration description for AGC section
* SubGhz: save only protocols that can be saved. Cleanup.
* Github: lint on pull requests
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-12 14:42:56 +00:00
|
|
|
#include "subghz_receiver.h"
|
|
|
|
#include "../subghz_i.h"
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
#include <furi.h>
|
|
|
|
#include <furi-hal.h>
|
|
|
|
#include <input/input.h>
|
|
|
|
#include <gui/elements.h>
|
|
|
|
#include <notification/notification-messages.h>
|
|
|
|
|
|
|
|
#include <assets_icons.h>
|
|
|
|
|
|
|
|
struct SubghzReceiver {
|
|
|
|
View* view;
|
|
|
|
SubghzReceiverCallback callback;
|
|
|
|
void* context;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
string_t text;
|
|
|
|
uint16_t scene;
|
|
|
|
SubGhzProtocolCommon* protocol;
|
|
|
|
} SubghzReceiverModel;
|
|
|
|
|
|
|
|
void subghz_receiver_set_callback(
|
|
|
|
SubghzReceiver* subghz_receiver,
|
|
|
|
SubghzReceiverCallback callback,
|
|
|
|
void* context) {
|
|
|
|
furi_assert(subghz_receiver);
|
|
|
|
furi_assert(callback);
|
|
|
|
subghz_receiver->callback = callback;
|
|
|
|
subghz_receiver->context = context;
|
|
|
|
}
|
|
|
|
|
|
|
|
void subghz_receiver_set_protocol(SubghzReceiver* subghz_receiver, SubGhzProtocolCommon* protocol) {
|
|
|
|
with_view_model(
|
|
|
|
subghz_receiver->view, (SubghzReceiverModel * model) {
|
|
|
|
model->protocol = protocol;
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void subghz_receiver_draw(Canvas* canvas, SubghzReceiverModel* model) {
|
|
|
|
canvas_clear(canvas);
|
|
|
|
canvas_set_color(canvas, ColorBlack);
|
|
|
|
canvas_set_font(canvas, FontSecondary);
|
|
|
|
elements_multiline_text(canvas, 0, 10, string_get_cstr(model->text));
|
|
|
|
|
|
|
|
elements_button_left(canvas, "Back");
|
SubGhz: read and save static remotes. Create new static and dynamic remotes. (#646)
* SubGhz: the functions of saving loading KeeLog have been modified, saving KeeLog is prohibited
* SubGhz: Fix displaying Nice FlorS in the Raed scene
* SubGhz: Fix displaying Faac SLH in the Raed scene
* SubGhz: Fix displaying iDo in the Raed scene
* SubGhz: Fix displaying Star Line in the Raed scene
* SubGhz: Fix displaying Nice Flo in the Raed scene, added save and load functions. (testing needed, no remote control)
* SubGhz: subghz_beginadded common encoder upload signal
* SubGhz: add Came encoder
* SubGhz: modified pricenton encoder, fix view transmitter hide the "Send" button if there is no encoder
* SubGhz: add nice flo encoder, need testing no remote control
* SubGhz: add gate_tx encoder
* SubGhz: add nero_sketch encoder
* SubGhz: add keelog encoder
* SubGhz: add long upload upload while the button is pressed while releasing the transfer is over, with a check for sticking (maximum 200 upload repetitions)
* SubGhz: fix max upload
* SubGhz: Fix structure subghz add encoder
* SubGhz: add generating and sending a dynamic keelog key, refactoring the code
* SubGhz: add notifications
* SubGhz: add creating a new remote control (Pricenton, Nice Flo 12bit, Nice Flo 24bit, CAME 12bit, CAME 24bit, Gate TX, DoorHan)
* SubGhz: Fix load file, fix scene start
* Subghz: Fix show key
* SubGhz: Fix subghz_cli
* SubGhz: Fix furi-hal-subghz
* Format sources
* SubGhz: standard notification scheme, fix broken assert in DMA.
* SubGhz: move level alignment logic to furi-hal-subghz, fix spelling, cleanup.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-16 19:56:23 +00:00
|
|
|
if(model->protocol && model->protocol->to_save_string &&
|
|
|
|
strcmp(model->protocol->name, "KeeLoq")) {
|
[FL-1610] SubGhz: scene based application, PT save and replay (#630)
* SubGhz: scene based application
* SubGhz: encoder/decoder separation, DMA streaming, update app and cli.
* SubGhz: 2 stage async tx complete, minor cleanup
* SubGhz: 2 stage async tx complete, FIX state pin end transmit
* SubGhz: Pricenton, receive TE signal
* SubGhz: Pricenton, add save data, add load data
* SubGhz: Add Read scene, Fix pricenton save, load funtion
* SubGhz: Add Read, Receiver, SaveName scene
* SubGhz: Read and Save (pricenton)
* SubGhz: add Load scence
* SubGhz: Fix select file scene, add load scene, add transmitter view, add send tx pricenton
* SubGhz: Fix pricenton encoder, fix transmitter send
* SubGhz: modified Pricenton Encoder (added guard time at the beginning), modified CC1101 config, code refactoring
* SubGhz: Fix pricenton encoder defalut TE
* Archive: Fix path and name SubGhz
* Archive: Fix name app SubGhz
* GubGhz: Came: add Save, Load key
* GubGhz: GateTX: add Save, Load key
* GubGhz: NeroSketch: add Save, Load key
* Github: better linters triggers
* SubGhz: adding fast loading keys Archive -> Run in app
* GubGhz: KeeLog: add Save, Load key, key generation from the serial number of the meter and the button
* SubGhz: format sources and fix compilation
* FuriHal: add subghz configuration description for AGC section
* SubGhz: save only protocols that can be saved. Cleanup.
* Github: lint on pull requests
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-12 14:42:56 +00:00
|
|
|
elements_button_right(canvas, "Save");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool subghz_receiver_input(InputEvent* event, void* context) {
|
|
|
|
furi_assert(context);
|
|
|
|
SubghzReceiver* subghz_receiver = context;
|
|
|
|
|
|
|
|
if(event->type != InputTypeShort) return false;
|
|
|
|
|
|
|
|
bool can_be_saved = false;
|
|
|
|
with_view_model(
|
|
|
|
subghz_receiver->view, (SubghzReceiverModel * model) {
|
SubGhz: read and save static remotes. Create new static and dynamic remotes. (#646)
* SubGhz: the functions of saving loading KeeLog have been modified, saving KeeLog is prohibited
* SubGhz: Fix displaying Nice FlorS in the Raed scene
* SubGhz: Fix displaying Faac SLH in the Raed scene
* SubGhz: Fix displaying iDo in the Raed scene
* SubGhz: Fix displaying Star Line in the Raed scene
* SubGhz: Fix displaying Nice Flo in the Raed scene, added save and load functions. (testing needed, no remote control)
* SubGhz: subghz_beginadded common encoder upload signal
* SubGhz: add Came encoder
* SubGhz: modified pricenton encoder, fix view transmitter hide the "Send" button if there is no encoder
* SubGhz: add nice flo encoder, need testing no remote control
* SubGhz: add gate_tx encoder
* SubGhz: add nero_sketch encoder
* SubGhz: add keelog encoder
* SubGhz: add long upload upload while the button is pressed while releasing the transfer is over, with a check for sticking (maximum 200 upload repetitions)
* SubGhz: fix max upload
* SubGhz: Fix structure subghz add encoder
* SubGhz: add generating and sending a dynamic keelog key, refactoring the code
* SubGhz: add notifications
* SubGhz: add creating a new remote control (Pricenton, Nice Flo 12bit, Nice Flo 24bit, CAME 12bit, CAME 24bit, Gate TX, DoorHan)
* SubGhz: Fix load file, fix scene start
* Subghz: Fix show key
* SubGhz: Fix subghz_cli
* SubGhz: Fix furi-hal-subghz
* Format sources
* SubGhz: standard notification scheme, fix broken assert in DMA.
* SubGhz: move level alignment logic to furi-hal-subghz, fix spelling, cleanup.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-16 19:56:23 +00:00
|
|
|
can_be_saved =
|
|
|
|
(model->protocol && model->protocol->to_save_string &&
|
|
|
|
strcmp(model->protocol->name, "KeeLoq"));
|
[FL-1610] SubGhz: scene based application, PT save and replay (#630)
* SubGhz: scene based application
* SubGhz: encoder/decoder separation, DMA streaming, update app and cli.
* SubGhz: 2 stage async tx complete, minor cleanup
* SubGhz: 2 stage async tx complete, FIX state pin end transmit
* SubGhz: Pricenton, receive TE signal
* SubGhz: Pricenton, add save data, add load data
* SubGhz: Add Read scene, Fix pricenton save, load funtion
* SubGhz: Add Read, Receiver, SaveName scene
* SubGhz: Read and Save (pricenton)
* SubGhz: add Load scence
* SubGhz: Fix select file scene, add load scene, add transmitter view, add send tx pricenton
* SubGhz: Fix pricenton encoder, fix transmitter send
* SubGhz: modified Pricenton Encoder (added guard time at the beginning), modified CC1101 config, code refactoring
* SubGhz: Fix pricenton encoder defalut TE
* Archive: Fix path and name SubGhz
* Archive: Fix name app SubGhz
* GubGhz: Came: add Save, Load key
* GubGhz: GateTX: add Save, Load key
* GubGhz: NeroSketch: add Save, Load key
* Github: better linters triggers
* SubGhz: adding fast loading keys Archive -> Run in app
* GubGhz: KeeLog: add Save, Load key, key generation from the serial number of the meter and the button
* SubGhz: format sources and fix compilation
* FuriHal: add subghz configuration description for AGC section
* SubGhz: save only protocols that can be saved. Cleanup.
* Github: lint on pull requests
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-12 14:42:56 +00:00
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
if(event->key == InputKeyBack) {
|
|
|
|
return false;
|
|
|
|
} else if(event->key == InputKeyLeft) {
|
|
|
|
subghz_receiver->callback(SubghzReceverEventBack, subghz_receiver->context);
|
|
|
|
} else if(can_be_saved && event->key == InputKeyRight) {
|
|
|
|
subghz_receiver->callback(SubghzReceverEventSave, subghz_receiver->context);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void subghz_receiver_text_callback(string_t text, void* context) {
|
|
|
|
furi_assert(context);
|
|
|
|
SubghzReceiver* subghz_receiver = context;
|
|
|
|
|
|
|
|
with_view_model(
|
|
|
|
subghz_receiver->view, (SubghzReceiverModel * model) {
|
|
|
|
string_set(model->text, text);
|
|
|
|
model->scene = 0;
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void subghz_receiver_enter(void* context) {
|
|
|
|
furi_assert(context);
|
|
|
|
SubghzReceiver* subghz_receiver = context;
|
|
|
|
with_view_model(
|
|
|
|
subghz_receiver->view, (SubghzReceiverModel * model) {
|
|
|
|
model->protocol->to_string(model->protocol, model->text);
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void subghz_receiver_exit(void* context) {
|
|
|
|
furi_assert(context);
|
|
|
|
SubghzReceiver* subghz_receiver = context;
|
|
|
|
with_view_model(
|
|
|
|
subghz_receiver->view, (SubghzReceiverModel * model) {
|
|
|
|
string_clean(model->text);
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
SubghzReceiver* subghz_receiver_alloc() {
|
|
|
|
SubghzReceiver* subghz_receiver = furi_alloc(sizeof(SubghzReceiver));
|
|
|
|
|
|
|
|
// View allocation and configuration
|
|
|
|
subghz_receiver->view = view_alloc();
|
|
|
|
view_allocate_model(subghz_receiver->view, ViewModelTypeLocking, sizeof(SubghzReceiverModel));
|
|
|
|
view_set_context(subghz_receiver->view, subghz_receiver);
|
|
|
|
view_set_draw_callback(subghz_receiver->view, (ViewDrawCallback)subghz_receiver_draw);
|
|
|
|
view_set_input_callback(subghz_receiver->view, subghz_receiver_input);
|
|
|
|
view_set_enter_callback(subghz_receiver->view, subghz_receiver_enter);
|
|
|
|
view_set_exit_callback(subghz_receiver->view, subghz_receiver_exit);
|
|
|
|
|
|
|
|
with_view_model(
|
|
|
|
subghz_receiver->view, (SubghzReceiverModel * model) {
|
|
|
|
string_init(model->text);
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
return subghz_receiver;
|
|
|
|
}
|
|
|
|
|
|
|
|
void subghz_receiver_free(SubghzReceiver* subghz_receiver) {
|
|
|
|
furi_assert(subghz_receiver);
|
|
|
|
|
|
|
|
with_view_model(
|
|
|
|
subghz_receiver->view, (SubghzReceiverModel * model) {
|
|
|
|
string_clear(model->text);
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
view_free(subghz_receiver->view);
|
|
|
|
free(subghz_receiver);
|
|
|
|
}
|
|
|
|
|
|
|
|
View* subghz_receiver_get_view(SubghzReceiver* subghz_receiver) {
|
|
|
|
furi_assert(subghz_receiver);
|
|
|
|
return subghz_receiver->view;
|
|
|
|
}
|