-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* 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 <[email protected]>
- Loading branch information
Showing
51 changed files
with
2,463 additions
and
668 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,6 @@ | ||
name: 'Python Lint' | ||
|
||
on: | ||
push: | ||
paths: | ||
- '**.py' | ||
pull_request: | ||
on: pull_request | ||
|
||
jobs: | ||
lint_python: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include "subghz_scene.h" | ||
|
||
// Generate scene on_enter handlers array | ||
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_enter, | ||
void (*const subghz_on_enter_handlers[])(void*) = { | ||
#include "subghz_scene_config.h" | ||
}; | ||
#undef ADD_SCENE | ||
|
||
// Generate scene on_event handlers array | ||
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_event, | ||
bool (*const subghz_on_event_handlers[])(void* context, SceneManagerEvent event) = { | ||
#include "subghz_scene_config.h" | ||
}; | ||
#undef ADD_SCENE | ||
|
||
// Generate scene on_exit handlers array | ||
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_exit, | ||
void (*const subghz_on_exit_handlers[])(void* context) = { | ||
#include "subghz_scene_config.h" | ||
}; | ||
#undef ADD_SCENE | ||
|
||
// Initialize scene handlers configuration structure | ||
const SceneManagerHandlers subghz_scene_handlers = { | ||
.on_enter_handlers = subghz_on_enter_handlers, | ||
.on_event_handlers = subghz_on_event_handlers, | ||
.on_exit_handlers = subghz_on_exit_handlers, | ||
.scene_num = SubGhzSceneNum, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#pragma once | ||
|
||
#include <gui/scene_manager.h> | ||
|
||
// Generate scene id and total number | ||
#define ADD_SCENE(prefix, name, id) SubGhzScene##id, | ||
typedef enum { | ||
#include "subghz_scene_config.h" | ||
SubGhzSceneNum, | ||
} SubGhzScene; | ||
#undef ADD_SCENE | ||
|
||
extern const SceneManagerHandlers subghz_scene_handlers; | ||
|
||
// Generate scene on_enter handlers declaration | ||
#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_enter(void*); | ||
#include "subghz_scene_config.h" | ||
#undef ADD_SCENE | ||
|
||
// Generate scene on_event handlers declaration | ||
#define ADD_SCENE(prefix, name, id) \ | ||
bool prefix##_scene_##name##_on_event(void* context, SceneManagerEvent event); | ||
#include "subghz_scene_config.h" | ||
#undef ADD_SCENE | ||
|
||
// Generate scene on_exit handlers declaration | ||
#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_exit(void* context); | ||
#include "subghz_scene_config.h" | ||
#undef ADD_SCENE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include "../subghz_i.h" | ||
|
||
const void subghz_scene_analyze_on_enter(void* context) { | ||
SubGhz* subghz = context; | ||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewAnalyze); | ||
} | ||
|
||
const bool subghz_scene_analyze_on_event(void* context, SceneManagerEvent event) { | ||
// SubGhz* subghz = context; | ||
return false; | ||
} | ||
|
||
const void subghz_scene_analyze_on_exit(void* context) { | ||
// SubGhz* subghz = context; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
ADD_SCENE(subghz, start, Start) | ||
ADD_SCENE(subghz, analyze, Analyze) | ||
ADD_SCENE(subghz, read, Read) | ||
ADD_SCENE(subghz, receiver, Receiver) | ||
ADD_SCENE(subghz, save_name, SaveName) | ||
ADD_SCENE(subghz, save_success, SaveSuccess) | ||
ADD_SCENE(subghz, saved, Saved) | ||
ADD_SCENE(subghz, transmitter, Transmitter) | ||
ADD_SCENE(subghz, static, Static) | ||
ADD_SCENE(subghz, test, Test) | ||
ADD_SCENE(subghz, test_carrier, TestCarrier) | ||
ADD_SCENE(subghz, test_packet, TestPacket) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#include "../subghz_i.h" | ||
|
||
#define GUBGHZ_READ_CUSTOM_EVENT (10UL) | ||
|
||
void subghz_read_protocol_callback(SubGhzProtocolCommon* parser, void* context) { | ||
furi_assert(context); | ||
SubGhz* subghz = context; | ||
subghz->protocol_result = parser; | ||
view_dispatcher_send_custom_event(subghz->view_dispatcher, GUBGHZ_READ_CUSTOM_EVENT); | ||
} | ||
void subghz_scene_read_callback(DialogExResult result, void* context) { | ||
SubGhz* subghz = context; | ||
view_dispatcher_send_custom_event(subghz->view_dispatcher, result); | ||
} | ||
|
||
const void subghz_scene_read_on_enter(void* context) { | ||
SubGhz* subghz = context; | ||
|
||
// Setup view | ||
DialogEx* dialog_ex = subghz->dialog_ex; | ||
|
||
dialog_ex_set_header(dialog_ex, "SubGhz 433.92", 36, 6, AlignLeft, AlignCenter); | ||
dialog_ex_set_icon(dialog_ex, 10, 12, &I_RFIDDolphinReceive_97x61); | ||
|
||
//Start CC1101 rx | ||
subghz_begin(FuriHalSubGhzPresetOokAsync); | ||
subghz_rx(433920000); | ||
furi_hal_subghz_start_async_rx(subghz_worker_rx_callback, subghz->worker); | ||
subghz_worker_start(subghz->worker); | ||
subghz_protocol_enable_dump(subghz->protocol, subghz_read_protocol_callback, subghz); | ||
|
||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewDialogEx); | ||
} | ||
|
||
const bool subghz_scene_read_on_event(void* context, SceneManagerEvent event) { | ||
SubGhz* subghz = context; | ||
if(event.type == SceneManagerEventTypeCustom) { | ||
if(event.event == GUBGHZ_READ_CUSTOM_EVENT) { | ||
scene_manager_next_scene(subghz->scene_manager, SubGhzViewReceiver); | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
const void subghz_scene_read_on_exit(void* context) { | ||
SubGhz* subghz = context; | ||
|
||
//Stop CC1101 | ||
subghz_worker_stop(subghz->worker); | ||
furi_hal_subghz_stop_async_rx(); | ||
subghz_end(); | ||
|
||
DialogEx* dialog_ex = subghz->dialog_ex; | ||
dialog_ex_set_header(dialog_ex, NULL, 0, 0, AlignCenter, AlignCenter); | ||
dialog_ex_set_icon(dialog_ex, 0, 0, NULL); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "../subghz_i.h" | ||
#include "../views/subghz_receiver.h" | ||
|
||
void subghz_scene_receiver_callback(SubghzReceverEvent event, void* context) { | ||
furi_assert(context); | ||
SubGhz* subghz = context; | ||
view_dispatcher_send_custom_event(subghz->view_dispatcher, event); | ||
} | ||
|
||
const void subghz_scene_receiver_on_enter(void* context) { | ||
SubGhz* subghz = context; | ||
SubghzReceiver* subghz_receiver = subghz->subghz_receiver; | ||
|
||
subghz_receiver_set_callback(subghz_receiver, subghz_scene_receiver_callback, subghz); | ||
|
||
subghz_receiver_set_protocol(subghz_receiver, subghz->protocol_result); | ||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewReceiver); | ||
} | ||
|
||
const bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event) { | ||
SubGhz* subghz = context; | ||
|
||
if(event.type == SceneManagerEventTypeCustom) { | ||
if(event.event == SubghzReceverEventSave) { | ||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaveName); | ||
return true; | ||
} else if(event.event == SubghzReceverEventBack) { | ||
scene_manager_previous_scene(subghz->scene_manager); | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
const void subghz_scene_receiver_on_exit(void* context) { | ||
// SubGhz* subghz = context; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
#include "../subghz_i.h" | ||
#include <lib/toolbox/random_name.h> | ||
#include "file-worker.h" | ||
|
||
#define SCENE_SAVE_NAME_CUSTOM_EVENT (0UL) | ||
|
||
bool subghz_scene_save_data_to_file(void* context, const char* dev_name) { | ||
SubGhz* subghz = context; | ||
FileWorker* file_worker = file_worker_alloc(false); | ||
string_t dev_file_name; | ||
string_init(dev_file_name); | ||
string_t temp_str; | ||
string_init(temp_str); | ||
bool saved = false; | ||
|
||
do { | ||
// Create subghz folder directory if necessary | ||
if(!file_worker_mkdir(file_worker, SUBGHZ_APP_FOLDER)) { | ||
break; | ||
} | ||
// Create saved directory if necessary | ||
if(!file_worker_mkdir(file_worker, SUBGHZ_APP_PATH_FOLDER)) { | ||
break; | ||
} | ||
// First remove subghz device file if it was saved | ||
string_printf( | ||
dev_file_name, "%s/%s%s", SUBGHZ_APP_PATH_FOLDER, dev_name, SUBGHZ_APP_EXTENSION); | ||
if(!file_worker_remove(file_worker, string_get_cstr(dev_file_name))) { | ||
break; | ||
} | ||
// Open file | ||
if(!file_worker_open( | ||
file_worker, string_get_cstr(dev_file_name), FSAM_WRITE, FSOM_CREATE_ALWAYS)) { | ||
break; | ||
} | ||
//Get string save | ||
subghz->protocol_result->to_save_string(subghz->protocol_result, temp_str); | ||
// Prepare and write data to file | ||
if(!file_worker_write(file_worker, string_get_cstr(temp_str), string_size(temp_str))) { | ||
break; | ||
} | ||
saved = true; | ||
} while(0); | ||
|
||
string_clear(temp_str); | ||
string_clear(dev_file_name); | ||
file_worker_close(file_worker); | ||
file_worker_free(file_worker); | ||
|
||
return saved; | ||
} | ||
|
||
void subghz_scene_save_name_text_input_callback(void* context) { | ||
SubGhz* subghz = context; | ||
view_dispatcher_send_custom_event(subghz->view_dispatcher, SCENE_SAVE_NAME_CUSTOM_EVENT); | ||
} | ||
|
||
const void subghz_scene_save_name_on_enter(void* context) { | ||
SubGhz* subghz = context; | ||
|
||
// Setup view | ||
TextInput* text_input = subghz->text_input; | ||
bool dev_name_empty = false; | ||
|
||
set_random_name(subghz->text_store, sizeof(subghz->text_store)); | ||
dev_name_empty = true; | ||
|
||
text_input_set_header_text(text_input, "Name the KEY"); | ||
text_input_set_result_callback( | ||
text_input, | ||
subghz_scene_save_name_text_input_callback, | ||
subghz, | ||
subghz->text_store, | ||
22, //Max len name | ||
dev_name_empty); | ||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewTextInput); | ||
} | ||
|
||
const bool subghz_scene_save_name_on_event(void* context, SceneManagerEvent event) { | ||
SubGhz* subghz = context; | ||
|
||
if(event.type == SceneManagerEventTypeCustom) { | ||
if(event.event == SCENE_SAVE_NAME_CUSTOM_EVENT) { | ||
if(subghz_scene_save_data_to_file(subghz, subghz->text_store)) { | ||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaveSuccess); | ||
return true; | ||
} else { | ||
//Error save | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
const void subghz_scene_save_name_on_exit(void* context) { | ||
SubGhz* subghz = context; | ||
|
||
// Clear view | ||
text_input_set_header_text(subghz->text_input, NULL); | ||
text_input_set_result_callback(subghz->text_input, NULL, NULL, NULL, 0, false); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include "../subghz_i.h" | ||
|
||
#define SCENE_SAVE_SUCCESS_CUSTOM_EVENT (0UL) | ||
|
||
void subghz_scene_save_success_popup_callback(void* context) { | ||
SubGhz* subghz = context; | ||
view_dispatcher_send_custom_event(subghz->view_dispatcher, SCENE_SAVE_SUCCESS_CUSTOM_EVENT); | ||
} | ||
|
||
const void subghz_scene_save_success_on_enter(void* context) { | ||
SubGhz* subghz = context; | ||
|
||
// Setup view | ||
Popup* popup = subghz->popup; | ||
popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59); | ||
popup_set_header(popup, "Saved!", 13, 22, AlignLeft, AlignBottom); | ||
popup_set_timeout(popup, 1500); | ||
popup_set_context(popup, subghz); | ||
popup_set_callback(popup, subghz_scene_save_success_popup_callback); | ||
popup_enable_timeout(popup); | ||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewPopup); | ||
} | ||
|
||
const bool subghz_scene_save_success_on_event(void* context, SceneManagerEvent event) { | ||
SubGhz* subghz = context; | ||
if(event.type == SceneManagerEventTypeCustom) { | ||
if(event.event == SCENE_SAVE_SUCCESS_CUSTOM_EVENT) { | ||
return scene_manager_search_and_switch_to_previous_scene( | ||
subghz->scene_manager, SubGhzSceneStart); | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
const void subghz_scene_save_success_on_exit(void* context) { | ||
SubGhz* subghz = context; | ||
|
||
// Clear view | ||
Popup* popup = subghz->popup; | ||
popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom); | ||
popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop); | ||
popup_set_icon(popup, 0, 0, NULL); | ||
popup_set_callback(popup, NULL); | ||
popup_set_context(popup, NULL); | ||
popup_set_timeout(popup, 0); | ||
popup_disable_timeout(popup); | ||
} |
Oops, something went wrong.