Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/flipperzero-firmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSkorpionm <85568270+Skorpionm@users.noreply.github.com>2021-09-28 03:05:40 +0300
committerGitHub <noreply@github.com>2021-09-28 03:05:40 +0300
commita8981d317a0f36e6694e8edc891103eecb5fae7a (patch)
tree309a0d7ff9668721ee733a4bfa57bd9813375d6a /applications/subghz
parent416e1bda3519020d3dbcf9b5e66e693fcfa66279 (diff)
[FL-1815, FL-1851, FL-1856] SubGhz: preparation for certification, add deleting stored signals and rename file in SubGHz app (#714)
* [FL-1811] FuriHal: move core2 startup to hal init stage, prevent working with flash controller till core2 startup finish. #704 * SubGhz: fix GO0 low on last hop transmission, decreased DutyCycle in tests * SubGhz: test_static fix max 5 sec in transmission mode, DutyCycle <23% * [FL-1815] SubGhz: prohibiting transmission if it is not within the permitted range for the given region * SubGhz: fix F7 furi-hal-subghz * SubGhz: fix logic working tests * SubGhz: fix princeton encoder for test * SubGhz: add log princeton encoder * [FL-1856] Subghz: fix output a double error if the file cannot be opened * [FL-1851] SubGhz: add deleting Stored Signals in SubGHz App * SubGhz: add rename file SubGhz app * SubGhz: update stats message in princeton * SubGhz: correct spelling * SubGhz: fix FM config, add hardware signal processing less than 16 μs, add added filter for processing short signals * SubGhz: add Scher-Khan MAGICAR Dinamic protocol * SubGhz: sync fury targets Co-authored-by: あく <alleteam@gmail.com>
Diffstat (limited to 'applications/subghz')
-rw-r--r--applications/subghz/scenes/subghz_scene_config.h4
-rw-r--r--applications/subghz/scenes/subghz_scene_delete.c71
-rw-r--r--applications/subghz/scenes/subghz_scene_delete_success.c48
-rw-r--r--applications/subghz/scenes/subghz_scene_receiver_info.c8
-rw-r--r--applications/subghz/scenes/subghz_scene_save_name.c18
-rw-r--r--applications/subghz/scenes/subghz_scene_saved.c2
-rw-r--r--applications/subghz/scenes/subghz_scene_saved_menu.c69
-rw-r--r--applications/subghz/scenes/subghz_scene_set_type.c1
-rw-r--r--applications/subghz/scenes/subghz_scene_show_only_rx.c53
-rw-r--r--applications/subghz/scenes/subghz_scene_test_carrier.c17
-rw-r--r--applications/subghz/scenes/subghz_scene_test_packet.c17
-rw-r--r--applications/subghz/scenes/subghz_scene_test_static.c17
-rw-r--r--applications/subghz/scenes/subghz_scene_transmitter.c10
-rw-r--r--applications/subghz/subghz_cli.c14
-rw-r--r--applications/subghz/subghz_i.c75
-rw-r--r--applications/subghz/subghz_i.h9
-rw-r--r--applications/subghz/views/subghz_test_carrier.c18
-rw-r--r--applications/subghz/views/subghz_test_carrier.h11
-rw-r--r--applications/subghz/views/subghz_test_packet.c37
-rw-r--r--applications/subghz/views/subghz_test_packet.h11
-rw-r--r--applications/subghz/views/subghz_test_static.c57
-rw-r--r--applications/subghz/views/subghz_test_static.h11
22 files changed, 511 insertions, 67 deletions
diff --git a/applications/subghz/scenes/subghz_scene_config.h b/applications/subghz/scenes/subghz_scene_config.h
index 070097e7..7958764d 100644
--- a/applications/subghz/scenes/subghz_scene_config.h
+++ b/applications/subghz/scenes/subghz_scene_config.h
@@ -7,6 +7,10 @@ ADD_SCENE(subghz, save_success, SaveSuccess)
ADD_SCENE(subghz, saved, Saved)
ADD_SCENE(subghz, transmitter, Transmitter)
ADD_SCENE(subghz, show_error, ShowError)
+ADD_SCENE(subghz, show_only_rx, ShowOnlyRx)
+ADD_SCENE(subghz, saved_menu, SavedMenu)
+ADD_SCENE(subghz, delete, Delete)
+ADD_SCENE(subghz, delete_success, DeleteSuccess)
ADD_SCENE(subghz, test, Test)
ADD_SCENE(subghz, test_static, TestStatic)
ADD_SCENE(subghz, test_carrier, TestCarrier)
diff --git a/applications/subghz/scenes/subghz_scene_delete.c b/applications/subghz/scenes/subghz_scene_delete.c
new file mode 100644
index 00000000..e97fd989
--- /dev/null
+++ b/applications/subghz/scenes/subghz_scene_delete.c
@@ -0,0 +1,71 @@
+#include "../subghz_i.h"
+
+typedef enum {
+ SubGhzSceneDeleteInfoCustomEventDelete,
+} SubGhzSceneDeleteInfoCustomEvent;
+
+void subghz_scene_delete_callback(GuiButtonType result, InputType type, void* context) {
+ furi_assert(context);
+ SubGhz* subghz = context;
+ if((result == GuiButtonTypeRight) && (type == InputTypeShort)) {
+ view_dispatcher_send_custom_event(
+ subghz->view_dispatcher, SubGhzSceneDeleteInfoCustomEventDelete);
+ }
+}
+
+void subghz_scene_delete_on_enter(void* context) {
+ SubGhz* subghz = context;
+
+ char buffer_str[16];
+ snprintf(
+ buffer_str,
+ sizeof(buffer_str),
+ "%03ld.%02ld",
+ subghz->txrx->frequency / 1000000 % 1000,
+ subghz->txrx->frequency / 10000 % 100);
+ widget_add_string_element(
+ subghz->widget, 78, 0, AlignLeft, AlignTop, FontSecondary, buffer_str);
+ if(subghz->txrx->preset == FuriHalSubGhzPresetOok650Async ||
+ subghz->txrx->preset == FuriHalSubGhzPresetOok270Async) {
+ snprintf(buffer_str, sizeof(buffer_str), "AM");
+ } else if(subghz->txrx->preset == FuriHalSubGhzPreset2FSKAsync) {
+ snprintf(buffer_str, sizeof(buffer_str), "FM");
+ } else {
+ furi_crash(NULL);
+ }
+ widget_add_string_element(
+ subghz->widget, 113, 0, AlignLeft, AlignTop, FontSecondary, buffer_str);
+ string_t text;
+ string_init(text);
+ subghz->txrx->protocol_result->to_string(subghz->txrx->protocol_result, text);
+ widget_add_string_multiline_element(
+ subghz->widget, 0, 0, AlignLeft, AlignTop, FontSecondary, string_get_cstr(text));
+ string_clear(text);
+
+ widget_add_button_element(
+ subghz->widget, GuiButtonTypeRight, "Delete", subghz_scene_delete_callback, subghz);
+
+ view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewWidget);
+}
+
+bool subghz_scene_delete_on_event(void* context, SceneManagerEvent event) {
+ SubGhz* subghz = context;
+ if(event.type == SceneManagerEventTypeCustom) {
+ if(event.event == SubGhzSceneDeleteInfoCustomEventDelete) {
+ memcpy(subghz->file_name_tmp, subghz->file_name, strlen(subghz->file_name));
+ if(subghz_delete_file(subghz)) {
+ scene_manager_next_scene(subghz->scene_manager, SubGhzSceneDeleteSuccess);
+ } else {
+ scene_manager_search_and_switch_to_previous_scene(
+ subghz->scene_manager, SubGhzSceneStart);
+ }
+ return true;
+ }
+ }
+ return false;
+}
+
+void subghz_scene_delete_on_exit(void* context) {
+ SubGhz* subghz = context;
+ widget_clear(subghz->widget);
+}
diff --git a/applications/subghz/scenes/subghz_scene_delete_success.c b/applications/subghz/scenes/subghz_scene_delete_success.c
new file mode 100644
index 00000000..bfafb7e5
--- /dev/null
+++ b/applications/subghz/scenes/subghz_scene_delete_success.c
@@ -0,0 +1,48 @@
+#include "../subghz_i.h"
+
+#define SCENE_DELETE_SUCCESS_CUSTOM_EVENT (0UL)
+
+void subghz_scene_delete_success_popup_callback(void* context) {
+ SubGhz* subghz = context;
+ view_dispatcher_send_custom_event(subghz->view_dispatcher, SCENE_DELETE_SUCCESS_CUSTOM_EVENT);
+}
+
+void subghz_scene_delete_success_on_enter(void* context) {
+ SubGhz* subghz = context;
+
+ // Setup view
+ Popup* popup = subghz->popup;
+ popup_set_icon(popup, 0, 2, &I_DolphinMafia_115x62);
+ popup_set_header(popup, "Deleted", 83, 19, AlignLeft, AlignBottom);
+ popup_set_timeout(popup, 1500);
+ popup_set_context(popup, subghz);
+ popup_set_callback(popup, subghz_scene_delete_success_popup_callback);
+ popup_enable_timeout(popup);
+ view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewPopup);
+}
+
+bool subghz_scene_delete_success_on_event(void* context, SceneManagerEvent event) {
+ SubGhz* subghz = context;
+
+ if(event.type == SceneManagerEventTypeCustom) {
+ if(event.event == SCENE_DELETE_SUCCESS_CUSTOM_EVENT) {
+ return scene_manager_search_and_switch_to_previous_scene(
+ subghz->scene_manager, SubGhzSceneStart);
+ }
+ }
+ return false;
+}
+
+void subghz_scene_delete_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);
+}
diff --git a/applications/subghz/scenes/subghz_scene_receiver_info.c b/applications/subghz/scenes/subghz_scene_receiver_info.c
index 7cea22b1..f3a75e54 100644
--- a/applications/subghz/scenes/subghz_scene_receiver_info.c
+++ b/applications/subghz/scenes/subghz_scene_receiver_info.c
@@ -101,7 +101,6 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event)
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == SubGhzSceneReceiverInfoCustomEventTxStart) {
//CC1101 Stop RX -> Start TX
- subghz->state_notifications = NOTIFICATION_TX_STATE;
if(subghz->txrx->hopper_state != SubGhzHopperStateOFF) {
subghz->txrx->hopper_state = SubGhzHopperStatePause;
}
@@ -112,7 +111,11 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event)
return false;
}
if(subghz->txrx->txrx_state == SubGhzTxRxStateIdle) {
- subghz_tx_start(subghz);
+ if(!subghz_tx_start(subghz)) {
+ scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowOnlyRx);
+ } else {
+ subghz->state_notifications = NOTIFICATION_TX_STATE;
+ }
}
return true;
} else if(event.event == SubGhzSceneReceiverInfoCustomEventTxStop) {
@@ -145,6 +148,7 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event)
}
if(subghz->txrx->protocol_result && subghz->txrx->protocol_result->to_save_string &&
strcmp(subghz->txrx->protocol_result->name, "KeeLoq")) {
+ subghz_file_name_clear(subghz);
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaveName);
}
return true;
diff --git a/applications/subghz/scenes/subghz_scene_save_name.c b/applications/subghz/scenes/subghz_scene_save_name.c
index 1ebb5d3b..81255723 100644
--- a/applications/subghz/scenes/subghz_scene_save_name.c
+++ b/applications/subghz/scenes/subghz_scene_save_name.c
@@ -16,15 +16,19 @@ void subghz_scene_save_name_on_enter(void* context) {
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;
+ if(!strcmp(subghz->file_name, "")) {
+ set_random_name(subghz->file_name, sizeof(subghz->file_name));
+ dev_name_empty = true;
+ } else {
+ memcpy(subghz->file_name_tmp, subghz->file_name, strlen(subghz->file_name));
+ }
text_input_set_header_text(text_input, "Name signal");
text_input_set_result_callback(
text_input,
subghz_scene_save_name_text_input_callback,
subghz,
- subghz->text_store,
+ subghz->file_name,
22, //Max len name
dev_name_empty);
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewTextInput);
@@ -35,8 +39,12 @@ bool subghz_scene_save_name_on_event(void* context, SceneManagerEvent event) {
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == SCENE_SAVE_NAME_CUSTOM_EVENT) {
- if(strcmp(subghz->text_store, "") &&
- subghz_save_protocol_to_file(subghz, subghz->text_store)) {
+ if(strcmp(subghz->file_name, "") &&
+ subghz_save_protocol_to_file(subghz, subghz->file_name)) {
+ if(strcmp(subghz->file_name_tmp, "")) {
+ subghz_delete_file(subghz);
+ }
+ subghz_file_name_clear(subghz);
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaveSuccess);
return true;
} else {
diff --git a/applications/subghz/scenes/subghz_scene_saved.c b/applications/subghz/scenes/subghz_scene_saved.c
index 4ec75b5a..68231ba6 100644
--- a/applications/subghz/scenes/subghz_scene_saved.c
+++ b/applications/subghz/scenes/subghz_scene_saved.c
@@ -4,7 +4,7 @@ void subghz_scene_saved_on_enter(void* context) {
SubGhz* subghz = context;
if(subghz_load_protocol_from_file(subghz)) {
- scene_manager_next_scene(subghz->scene_manager, SubGhzSceneTransmitter);
+ scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSavedMenu);
} else {
scene_manager_search_and_switch_to_previous_scene(subghz->scene_manager, SubGhzSceneStart);
}
diff --git a/applications/subghz/scenes/subghz_scene_saved_menu.c b/applications/subghz/scenes/subghz_scene_saved_menu.c
new file mode 100644
index 00000000..59d7e3e8
--- /dev/null
+++ b/applications/subghz/scenes/subghz_scene_saved_menu.c
@@ -0,0 +1,69 @@
+#include "../subghz_i.h"
+
+enum SubmenuIndex {
+ SubmenuIndexEmulate,
+ SubmenuIndexEdit,
+ SubmenuIndexDelete,
+};
+
+void subghz_scene_saved_menu_submenu_callback(void* context, uint32_t index) {
+ SubGhz* subghz = context;
+ view_dispatcher_send_custom_event(subghz->view_dispatcher, index);
+}
+
+void subghz_scene_saved_menu_on_enter(void* context) {
+ SubGhz* subghz = context;
+ submenu_add_item(
+ subghz->submenu,
+ "Emulate",
+ SubmenuIndexEmulate,
+ subghz_scene_saved_menu_submenu_callback,
+ subghz);
+ submenu_add_item(
+ subghz->submenu,
+ "Edit name",
+ SubmenuIndexEdit,
+ subghz_scene_saved_menu_submenu_callback,
+ subghz);
+ submenu_add_item(
+ subghz->submenu,
+ "Delete",
+ SubmenuIndexDelete,
+ subghz_scene_saved_menu_submenu_callback,
+ subghz);
+
+ submenu_set_selected_item(
+ subghz->submenu,
+ scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneSavedMenu));
+
+ view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewMenu);
+}
+
+bool subghz_scene_saved_menu_on_event(void* context, SceneManagerEvent event) {
+ SubGhz* subghz = context;
+
+ if(event.type == SceneManagerEventTypeCustom) {
+ if(event.event == SubmenuIndexEmulate) {
+ scene_manager_set_scene_state(
+ subghz->scene_manager, SubGhzSceneSavedMenu, SubmenuIndexEmulate);
+ scene_manager_next_scene(subghz->scene_manager, SubGhzSceneTransmitter);
+ return true;
+ } else if(event.event == SubmenuIndexDelete) {
+ scene_manager_set_scene_state(
+ subghz->scene_manager, SubGhzSceneSavedMenu, SubmenuIndexDelete);
+ scene_manager_next_scene(subghz->scene_manager, SubGhzSceneDelete);
+ return true;
+ } else if(event.event == SubmenuIndexEdit) {
+ scene_manager_set_scene_state(
+ subghz->scene_manager, SubGhzSceneSavedMenu, SubmenuIndexEdit);
+ scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaveName);
+ return true;
+ }
+ }
+ return false;
+}
+
+void subghz_scene_saved_menu_on_exit(void* context) {
+ SubGhz* subghz = context;
+ submenu_clean(subghz->submenu);
+}
diff --git a/applications/subghz/scenes/subghz_scene_set_type.c b/applications/subghz/scenes/subghz_scene_set_type.c
index 7beb8a27..4ec34e23 100644
--- a/applications/subghz/scenes/subghz_scene_set_type.c
+++ b/applications/subghz/scenes/subghz_scene_set_type.c
@@ -174,6 +174,7 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
if(generated_protocol) {
subghz->txrx->frequency = subghz_frequencies[subghz_frequencies_433_92];
subghz->txrx->preset = FuriHalSubGhzPresetOok650Async;
+ subghz_file_name_clear(subghz);
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaveName);
return true;
}
diff --git a/applications/subghz/scenes/subghz_scene_show_only_rx.c b/applications/subghz/scenes/subghz_scene_show_only_rx.c
new file mode 100644
index 00000000..f808b0fb
--- /dev/null
+++ b/applications/subghz/scenes/subghz_scene_show_only_rx.c
@@ -0,0 +1,53 @@
+#include "../subghz_i.h"
+
+#define SCENE_NO_MAN_CUSTOM_EVENT (11UL)
+
+void subghz_scene_show_only_rx_popup_callback(void* context) {
+ SubGhz* subghz = context;
+ view_dispatcher_send_custom_event(subghz->view_dispatcher, SCENE_NO_MAN_CUSTOM_EVENT);
+}
+
+const void subghz_scene_show_only_rx_on_enter(void* context) {
+ SubGhz* subghz = context;
+
+ // Setup view
+ Popup* popup = subghz->popup;
+ popup_set_icon(popup, 67, 12, &I_DolphinFirstStart7_61x51);
+ popup_set_text(
+ popup,
+ "This frequency can\nonly be used for RX\nin your region",
+ 38,
+ 40,
+ AlignCenter,
+ AlignBottom);
+ popup_set_timeout(popup, 1500);
+ popup_set_context(popup, subghz);
+ popup_set_callback(popup, subghz_scene_show_only_rx_popup_callback);
+ popup_enable_timeout(popup);
+ view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewPopup);
+}
+
+const bool subghz_scene_show_only_rx_on_event(void* context, SceneManagerEvent event) {
+ SubGhz* subghz = context;
+ if(event.type == SceneManagerEventTypeCustom) {
+ if(event.event == SCENE_NO_MAN_CUSTOM_EVENT) {
+ scene_manager_previous_scene(subghz->scene_manager);
+ return true;
+ }
+ }
+ return false;
+}
+
+const void subghz_scene_show_only_rx_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);
+}
diff --git a/applications/subghz/scenes/subghz_scene_test_carrier.c b/applications/subghz/scenes/subghz_scene_test_carrier.c
index ecc42260..e2fa6634 100644
--- a/applications/subghz/scenes/subghz_scene_test_carrier.c
+++ b/applications/subghz/scenes/subghz_scene_test_carrier.c
@@ -1,12 +1,27 @@
#include "../subghz_i.h"
+#include "../views/subghz_test_carrier.h"
+
+void subghz_scene_test_carrier_callback(SubghzTestCarrierEvent event, void* context) {
+ furi_assert(context);
+ SubGhz* subghz = context;
+ view_dispatcher_send_custom_event(subghz->view_dispatcher, event);
+}
void subghz_scene_test_carrier_on_enter(void* context) {
SubGhz* subghz = context;
+ subghz_test_carrier_set_callback(
+ subghz->subghz_test_carrier, subghz_scene_test_carrier_callback, subghz);
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewTestCarrier);
}
bool subghz_scene_test_carrier_on_event(void* context, SceneManagerEvent event) {
- // SubGhz* subghz = context;
+ SubGhz* subghz = context;
+ if(event.type == SceneManagerEventTypeCustom) {
+ if(event.event == SubghzTestCarrierEventOnlyRx) {
+ scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowOnlyRx);
+ return true;
+ }
+ }
return false;
}
diff --git a/applications/subghz/scenes/subghz_scene_test_packet.c b/applications/subghz/scenes/subghz_scene_test_packet.c
index e4933bab..a49ec480 100644
--- a/applications/subghz/scenes/subghz_scene_test_packet.c
+++ b/applications/subghz/scenes/subghz_scene_test_packet.c
@@ -1,12 +1,27 @@
#include "../subghz_i.h"
+#include "../views/subghz_test_packet.h"
+
+void subghz_scene_test_packet_callback(SubghzTestPacketEvent event, void* context) {
+ furi_assert(context);
+ SubGhz* subghz = context;
+ view_dispatcher_send_custom_event(subghz->view_dispatcher, event);
+}
void subghz_scene_test_packet_on_enter(void* context) {
SubGhz* subghz = context;
+ subghz_test_packet_set_callback(
+ subghz->subghz_test_packet, subghz_scene_test_packet_callback, subghz);
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewTestPacket);
}
bool subghz_scene_test_packet_on_event(void* context, SceneManagerEvent event) {
- // SubGhz* subghz = context;
+ SubGhz* subghz = context;
+ if(event.type == SceneManagerEventTypeCustom) {
+ if(event.event == SubghzTestPacketEventOnlyRx) {
+ scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowOnlyRx);
+ return true;
+ }
+ }
return false;
}
diff --git a/applications/subghz/scenes/subghz_scene_test_static.c b/applications/subghz/scenes/subghz_scene_test_static.c
index f663c7fd..6c6099ec 100644
--- a/applications/subghz/scenes/subghz_scene_test_static.c
+++ b/applications/subghz/scenes/subghz_scene_test_static.c
@@ -1,12 +1,27 @@
#include "../subghz_i.h"
+#include "../views/subghz_test_static.h"
+
+void subghz_scene_test_static_callback(SubghzTestStaticEvent event, void* context) {
+ furi_assert(context);
+ SubGhz* subghz = context;
+ view_dispatcher_send_custom_event(subghz->view_dispatcher, event);
+}
void subghz_scene_test_static_on_enter(void* context) {
SubGhz* subghz = context;
+ subghz_test_static_set_callback(
+ subghz->subghz_test_static, subghz_scene_test_static_callback, subghz);
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewStatic);
}
bool subghz_scene_test_static_on_event(void* context, SceneManagerEvent event) {
- // SubGhz* subghz = context;
+ SubGhz* subghz = context;
+ if(event.type == SceneManagerEventTypeCustom) {
+ if(event.event == SubghzTestStaticEventOnlyRx) {
+ scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowOnlyRx);
+ return true;
+ }
+ }
return false;
}
diff --git a/applications/subghz/scenes/subghz_scene_transmitter.c b/applications/subghz/scenes/subghz_scene_transmitter.c
index dd1f3030..85c61240 100644
--- a/applications/subghz/scenes/subghz_scene_transmitter.c
+++ b/applications/subghz/scenes/subghz_scene_transmitter.c
@@ -68,14 +68,18 @@ bool subghz_scene_transmitter_on_event(void* context, SceneManagerEvent event) {
SubGhz* subghz = context;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == SubghzTransmitterEventSendStart) {
- subghz->state_notifications = NOTIFICATION_TX_STATE;
+ subghz->state_notifications = NOTIFICATION_IDLE_STATE;
if(subghz->txrx->txrx_state == SubGhzTxRxStateRx) {
subghz_rx_end(subghz);
}
if((subghz->txrx->txrx_state == SubGhzTxRxStateIdle) ||
(subghz->txrx->txrx_state == SubGhzTxRxStateSleep)) {
- subghz_tx_start(subghz);
- subghz_scene_transmitter_update_data_show(subghz);
+ if(!subghz_tx_start(subghz)) {
+ scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowOnlyRx);
+ } else {
+ subghz->state_notifications = NOTIFICATION_TX_STATE;
+ subghz_scene_transmitter_update_data_show(subghz);
+ }
}
return true;
} else if(event.event == SubghzTransmitterEventSendStop) {
diff --git a/applications/subghz/subghz_cli.c b/applications/subghz/subghz_cli.c
index 52e6b6d3..1a33beab 100644
--- a/applications/subghz/subghz_cli.c
+++ b/applications/subghz/subghz_cli.c
@@ -48,12 +48,14 @@ void subghz_cli_command_tx_carrier(Cli* cli, string_t args, void* context) {
hal_gpio_init(&gpio_cc1101_g0, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow);
hal_gpio_write(&gpio_cc1101_g0, true);
- furi_hal_subghz_tx();
-
- printf("Transmitting at frequency %lu Hz\r\n", frequency);
- printf("Press CTRL+C to stop\r\n");
- while(!cli_cmd_interrupt_received(cli)) {
- osDelay(250);
+ if(furi_hal_subghz_tx()) {
+ printf("Transmitting at frequency %lu Hz\r\n", frequency);
+ printf("Press CTRL+C to stop\r\n");
+ while(!cli_cmd_interrupt_received(cli)) {
+ osDelay(250);
+ }
+ } else {
+ printf("This frequency can only be used for RX in your region\r\n");
}
furi_hal_subghz_set_path(FuriHalSubGhzPathIsolate);
diff --git a/applications/subghz/subghz_i.c b/applications/subghz/subghz_i.c
index 9a52586a..2f849e41 100644
--- a/applications/subghz/subghz_i.c
+++ b/applications/subghz/subghz_i.c
@@ -40,19 +40,19 @@ uint32_t subghz_rx(SubGhz* subghz, uint32_t frequency) {
return value;
}
-uint32_t subghz_tx(SubGhz* subghz, uint32_t frequency) {
+static bool subghz_tx(SubGhz* subghz, uint32_t frequency) {
furi_assert(subghz);
if(!furi_hal_subghz_is_frequency_valid(frequency)) {
furi_crash(NULL);
}
furi_assert(subghz->txrx->txrx_state != SubGhzTxRxStateSleep);
furi_hal_subghz_idle();
- uint32_t value = furi_hal_subghz_set_frequency_and_path(frequency);
+ furi_hal_subghz_set_frequency_and_path(frequency);
hal_gpio_init(&gpio_cc1101_g0, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow);
hal_gpio_write(&gpio_cc1101_g0, true);
- furi_hal_subghz_tx();
+ bool ret = furi_hal_subghz_tx();
subghz->txrx->txrx_state = SubGhzTxRxStateTx;
- return value;
+ return ret;
}
void subghz_idle(SubGhz* subghz) {
@@ -90,9 +90,10 @@ static void subghz_frequency_preset_to_str(SubGhz* subghz, string_t output) {
(int)subghz->txrx->preset);
}
-void subghz_tx_start(SubGhz* subghz) {
+bool subghz_tx_start(SubGhz* subghz) {
furi_assert(subghz);
+ bool ret = false;
subghz->txrx->encoder = subghz_protocol_encoder_common_alloc();
subghz->txrx->encoder->repeat = 200; //max repeat with the button held down
//get upload
@@ -105,16 +106,23 @@ void subghz_tx_start(SubGhz* subghz) {
subghz_begin(subghz, FuriHalSubGhzPresetOok270Async);
}
if(subghz->txrx->frequency) {
- subghz_tx(subghz, subghz->txrx->frequency);
+ ret = subghz_tx(subghz, subghz->txrx->frequency);
} else {
- subghz_tx(subghz, 433920000);
+ ret = subghz_tx(subghz, 433920000);
}
- //Start TX
- furi_hal_subghz_start_async_tx(
- subghz_protocol_encoder_common_yield, subghz->txrx->encoder);
+ if(ret) {
+ //Start TX
+ furi_hal_subghz_start_async_tx(
+ subghz_protocol_encoder_common_yield, subghz->txrx->encoder);
+ }
}
}
+ if(!ret) {
+ subghz_protocol_encoder_common_free(subghz->txrx->encoder);
+ subghz_idle(subghz);
+ }
+ return ret;
}
void subghz_tx_stop(SubGhz* subghz) {
@@ -125,8 +133,9 @@ void subghz_tx_stop(SubGhz* subghz) {
subghz_protocol_encoder_common_free(subghz->txrx->encoder);
subghz_idle(subghz);
//if protocol dynamic then we save the last upload
- if(subghz->txrx->protocol_result->type_protocol == SubGhzProtocolCommonTypeDynamic) {
- subghz_save_protocol_to_file(subghz, subghz->text_store);
+ if((subghz->txrx->protocol_result->type_protocol == SubGhzProtocolCommonTypeDynamic) &&
+ (strcmp(subghz->file_name, ""))) {
+ subghz_save_protocol_to_file(subghz, subghz->file_name);
}
notification_message(subghz->notifications, &sequence_reset_red);
}
@@ -268,8 +277,8 @@ bool subghz_load_protocol_from_file(SubGhz* subghz) {
file_worker,
SUBGHZ_APP_PATH_FOLDER,
SUBGHZ_APP_EXTENSION,
- subghz->text_store,
- sizeof(subghz->text_store),
+ subghz->file_name,
+ sizeof(subghz->file_name),
NULL);
if(res) {
@@ -278,7 +287,7 @@ bool subghz_load_protocol_from_file(SubGhz* subghz) {
protocol_file_name,
"%s/%s%s",
SUBGHZ_APP_PATH_FOLDER,
- subghz->text_store,
+ subghz->file_name,
SUBGHZ_APP_EXTENSION);
} else {
string_clear(temp_str);
@@ -292,7 +301,7 @@ bool subghz_load_protocol_from_file(SubGhz* subghz) {
do {
if(!file_worker_open(
file_worker, string_get_cstr(protocol_file_name), FSAM_READ, FSOM_OPEN_EXISTING)) {
- break;
+ return res;
}
// Read and parse frequency from 1st line
if(!file_worker_read_until(file_worker, temp_str, '\n')) {
@@ -345,6 +354,40 @@ bool subghz_load_protocol_from_file(SubGhz* subghz) {
return res;
}
+bool subghz_delete_file(SubGhz* subghz) {
+ furi_assert(subghz);
+
+ bool result = true;
+ FileWorker* file_worker = file_worker_alloc(false);
+ string_t file_path;
+
+ do {
+ // Get key file path
+ string_init_printf(
+ file_path,
+ "%s/%s%s",
+ SUBGHZ_APP_PATH_FOLDER,
+ subghz->file_name_tmp,
+ SUBGHZ_APP_EXTENSION);
+ // Delete original file
+ if(!file_worker_remove(file_worker, string_get_cstr(file_path))) {
+ result = false;
+ break;
+ }
+ } while(0);
+
+ string_clear(file_path);
+ file_worker_close(file_worker);
+ file_worker_free(file_worker);
+ return result;
+}
+
+void subghz_file_name_clear(SubGhz* subghz) {
+ furi_assert(subghz);
+ memset(subghz->file_name, 0, sizeof(subghz->file_name));
+ memset(subghz->file_name_tmp, 0, sizeof(subghz->file_name_tmp));
+}
+
uint32_t subghz_random_serial(void) {
static bool rand_generator_inited = false;
diff --git a/applications/subghz/subghz_i.h b/applications/subghz/subghz_i.h
index eecf98d3..dc1e5a3f 100644
--- a/applications/subghz/subghz_i.h
+++ b/applications/subghz/subghz_i.h
@@ -29,7 +29,7 @@
#include <gui/modules/variable-item-list.h>
-#define SUBGHZ_TEXT_STORE_SIZE 128
+#define SUBGHZ_TEXT_STORE_SIZE 40
#define NOTIFICATION_STARTING_STATE 0u
#define NOTIFICATION_IDLE_STATE 1u
@@ -90,7 +90,8 @@ struct SubGhz {
Popup* popup;
TextInput* text_input;
Widget* widget;
- char text_store[SUBGHZ_TEXT_STORE_SIZE + 1];
+ char file_name[SUBGHZ_TEXT_STORE_SIZE + 1];
+ char file_name_tmp[SUBGHZ_TEXT_STORE_SIZE + 1];
uint8_t state_notifications;
SubghzReceiver* subghz_receiver;
@@ -121,10 +122,12 @@ void subghz_begin(SubGhz* subghz, FuriHalSubGhzPreset preset);
uint32_t subghz_rx(SubGhz* subghz, uint32_t frequency);
void subghz_rx_end(SubGhz* subghz);
void subghz_sleep(SubGhz* subghz);
-void subghz_tx_start(SubGhz* subghz);
+bool subghz_tx_start(SubGhz* subghz);
void subghz_tx_stop(SubGhz* subghz);
bool subghz_key_load(SubGhz* subghz, const char* file_path);
bool subghz_save_protocol_to_file(SubGhz* subghz, const char* dev_name);
bool subghz_load_protocol_from_file(SubGhz* subghz);
+bool subghz_delete_file(SubGhz* subghz);
+void subghz_file_name_clear(SubGhz* subghz);
uint32_t subghz_random_serial(void);
void subghz_hopper_update(SubGhz* subghz);
diff --git a/applications/subghz/views/subghz_test_carrier.c b/applications/subghz/views/subghz_test_carrier.c
index 82d11650..1217240e 100644
--- a/applications/subghz/views/subghz_test_carrier.c
+++ b/applications/subghz/views/subghz_test_carrier.c
@@ -9,6 +9,8 @@
struct SubghzTestCarrier {
View* view;
osTimerId timer;
+ SubghzTestCarrierCallback callback;
+ void* context;
};
typedef enum {
@@ -24,6 +26,16 @@ typedef struct {
SubghzTestCarrierModelStatus status;
} SubghzTestCarrierModel;
+void subghz_test_carrier_set_callback(
+ SubghzTestCarrier* subghz_test_carrier,
+ SubghzTestCarrierCallback callback,
+ void* context) {
+ furi_assert(subghz_test_carrier);
+ furi_assert(callback);
+ subghz_test_carrier->callback = callback;
+ subghz_test_carrier->context = context;
+}
+
void subghz_test_carrier_draw(Canvas* canvas, SubghzTestCarrierModel* model) {
char buffer[64];
@@ -105,7 +117,11 @@ bool subghz_test_carrier_input(InputEvent* event, void* context) {
} else {
hal_gpio_init(&gpio_cc1101_g0, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow);
hal_gpio_write(&gpio_cc1101_g0, true);
- furi_hal_subghz_tx();
+ if(!furi_hal_subghz_tx()) {
+ hal_gpio_init(&gpio_cc1101_g0, GpioModeInput, GpioPullNo, GpioSpeedLow);
+ subghz_test_carrier->callback(
+ SubghzTestCarrierEventOnlyRx, subghz_test_carrier->context);
+ }
}
return true;
diff --git a/applications/subghz/views/subghz_test_carrier.h b/applications/subghz/views/subghz_test_carrier.h
index f191f7af..b4522345 100644
--- a/applications/subghz/views/subghz_test_carrier.h
+++ b/applications/subghz/views/subghz_test_carrier.h
@@ -2,8 +2,19 @@
#include <gui/view.h>
+typedef enum {
+ SubghzTestCarrierEventOnlyRx,
+} SubghzTestCarrierEvent;
+
typedef struct SubghzTestCarrier SubghzTestCarrier;
+typedef void (*SubghzTestCarrierCallback)(SubghzTestCarrierEvent event, void* context);
+
+void subghz_test_carrier_set_callback(
+ SubghzTestCarrier* subghz_test_carrier,
+ SubghzTestCarrierCallback callback,
+ void* context);
+
SubghzTestCarrier* subghz_test_carrier_alloc();
void subghz_test_carrier_free(SubghzTestCarrier* subghz_test_carrier);
diff --git a/applications/subghz/views/subghz_test_packet.c b/applications/subghz/views/subghz_test_packet.c
index f1c48179..2d4b4aea 100644
--- a/applications/subghz/views/subghz_test_packet.c
+++ b/applications/subghz/views/subghz_test_packet.c
@@ -16,12 +16,14 @@ struct SubghzTestPacket {
SubGhzDecoderPrinceton* decoder;
SubGhzEncoderPrinceton* encoder;
-
volatile size_t packet_rx;
+ SubghzTestPacketCallback callback;
+ void* context;
};
typedef enum {
SubghzTestPacketModelStatusRx,
+ SubghzTestPacketModelStatusOnlyRx,
SubghzTestPacketModelStatusTx,
} SubghzTestPacketModelStatus;
@@ -36,6 +38,16 @@ typedef struct {
volatile bool subghz_test_packet_overrun = false;
+void subghz_test_packet_set_callback(
+ SubghzTestPacket* subghz_test_packet,
+ SubghzTestPacketCallback callback,
+ void* context) {
+ furi_assert(subghz_test_packet);
+ furi_assert(callback);
+ subghz_test_packet->callback = callback;
+ subghz_test_packet->context = context;
+}
+
static void subghz_test_packet_rx_callback(bool level, uint32_t duration, void* context) {
furi_assert(context);
SubghzTestPacket* instance = context;
@@ -57,7 +69,7 @@ static void subghz_test_packet_rssi_timer_callback(void* context) {
if(model->status == SubghzTestPacketModelStatusRx) {
model->rssi = furi_hal_subghz_get_rssi();
model->packets = instance->packet_rx;
- } else {
+ } else if(model->status == SubghzTestPacketModelStatusTx) {
model->packets = SUBGHZ_TEST_PACKET_COUNT -
subghz_encoder_princeton_get_repeat_left(instance->encoder);
}
@@ -124,7 +136,7 @@ static bool subghz_test_packet_input(InputEvent* event, void* context) {
instance->view, (SubghzTestPacketModel * model) {
if(model->status == SubghzTestPacketModelStatusRx) {
furi_hal_subghz_stop_async_rx();
- } else {
+ } else if(model->status == SubghzTestPacketModelStatusTx) {
furi_hal_subghz_stop_async_tx();
}
@@ -137,10 +149,10 @@ static bool subghz_test_packet_input(InputEvent* event, void* context) {
} else if(event->key == InputKeyUp) {
if(model->path < FuriHalSubGhzPath868) model->path++;
} else if(event->key == InputKeyOk) {
- if(model->status == SubghzTestPacketModelStatusTx) {
- model->status = SubghzTestPacketModelStatusRx;
- } else {
+ if(model->status == SubghzTestPacketModelStatusRx) {
model->status = SubghzTestPacketModelStatusTx;
+ } else {
+ model->status = SubghzTestPacketModelStatusRx;
}
}
@@ -151,8 +163,13 @@ static bool subghz_test_packet_input(InputEvent* event, void* context) {
if(model->status == SubghzTestPacketModelStatusRx) {
furi_hal_subghz_start_async_rx(subghz_test_packet_rx_callback, instance);
} else {
- subghz_encoder_princeton_set(instance->encoder, 0x00AABBCC, 1000);
- furi_hal_subghz_start_async_tx(subghz_encoder_princeton_yield, instance->encoder);
+ subghz_encoder_princeton_set(
+ instance->encoder, 0x00AABBCC, SUBGHZ_TEST_PACKET_COUNT);
+ if(!furi_hal_subghz_start_async_tx(
+ subghz_encoder_princeton_yield, instance->encoder)) {
+ model->status = SubghzTestPacketModelStatusOnlyRx;
+ instance->callback(SubghzTestPacketEventOnlyRx, instance->context);
+ }
}
return true;
@@ -195,7 +212,7 @@ void subghz_test_packet_exit(void* context) {
instance->view, (SubghzTestPacketModel * model) {
if(model->status == SubghzTestPacketModelStatusRx) {
furi_hal_subghz_stop_async_rx();
- } else {
+ } else if(model->status == SubghzTestPacketModelStatusTx) {
furi_hal_subghz_stop_async_tx();
}
return true;
@@ -240,4 +257,4 @@ void subghz_test_packet_free(SubghzTestPacket* instance) {
View* subghz_test_packet_get_view(SubghzTestPacket* instance) {
furi_assert(instance);
return instance->view;
-}
+} \ No newline at end of file
diff --git a/applications/subghz/views/subghz_test_packet.h b/applications/subghz/views/subghz_test_packet.h
index 00fae10e..bd861ee9 100644
--- a/applications/subghz/views/subghz_test_packet.h
+++ b/applications/subghz/views/subghz_test_packet.h
@@ -2,8 +2,19 @@
#include <gui/view.h>
+typedef enum {
+ SubghzTestPacketEventOnlyRx,
+} SubghzTestPacketEvent;
+
typedef struct SubghzTestPacket SubghzTestPacket;
+typedef void (*SubghzTestPacketCallback)(SubghzTestPacketEvent event, void* context);
+
+void subghz_test_packet_set_callback(
+ SubghzTestPacket* subghz_test_packet,
+ SubghzTestPacketCallback callback,
+ void* context);
+
SubghzTestPacket* subghz_test_packet_alloc();
void subghz_test_packet_free(SubghzTestPacket* subghz_test_packet);
diff --git a/applications/subghz/views/subghz_test_static.c b/applications/subghz/views/subghz_test_static.c
index 240dc215..aa701464 100644
--- a/applications/subghz/views/subghz_test_static.c
+++ b/applications/subghz/views/subghz_test_static.c
@@ -8,6 +8,11 @@
#include <notification/notification-messages.h>
#include <lib/subghz/protocols/subghz_protocol_princeton.h>
+typedef enum {
+ SubghzTestStaticStatusIDLE,
+ SubghzTestStaticStatusTX,
+} SubghzTestStaticStatus;
+
static const uint32_t subghz_test_static_keys[] = {
0x0074BADE,
0x0074BADD,
@@ -17,20 +22,28 @@ static const uint32_t subghz_test_static_keys[] = {
struct SubghzTestStatic {
View* view;
+ SubghzTestStaticStatus satus_tx;
SubGhzEncoderPrinceton* encoder;
+ SubghzTestStaticCallback callback;
+ void* context;
};
-typedef enum {
- SubghzTestStaticStatusRx,
- SubghzTestStaticStatusTx,
-} SubghzTestStaticStatus;
-
typedef struct {
uint8_t frequency;
uint32_t real_frequency;
uint8_t button;
} SubghzTestStaticModel;
+void subghz_test_static_set_callback(
+ SubghzTestStatic* subghz_test_static,
+ SubghzTestStaticCallback callback,
+ void* context) {
+ furi_assert(subghz_test_static);
+ furi_assert(callback);
+ subghz_test_static->callback = callback;
+ subghz_test_static->context = context;
+}
+
void subghz_test_static_draw(Canvas* canvas, SubghzTestStaticModel* model) {
char buffer[64];
@@ -79,22 +92,30 @@ bool subghz_test_static_input(InputEvent* event, void* context) {
if(event->key == InputKeyOk) {
NotificationApp* notification = furi_record_open("notification");
if(event->type == InputTypePress) {
- notification_message_block(notification, &sequence_set_red_255);
-
- FURI_LOG_I("SubghzTestStatic", "TX Start");
furi_hal_subghz_idle();
furi_hal_subghz_set_frequency_and_path(subghz_frequencies[model->frequency]);
+ if(!furi_hal_subghz_tx()) {
+ instance->callback(SubghzTestStaticEventOnlyRx, instance->context);
+ } else {
+ notification_message_block(notification, &sequence_set_red_255);
- subghz_encoder_princeton_set(
- instance->encoder, subghz_test_static_keys[model->button], 10000);
+ FURI_LOG_I("SubghzTestStatic", "TX Start");
- furi_hal_subghz_start_async_tx(
- subghz_encoder_princeton_yield, instance->encoder);
- } else if(event->type == InputTypeRelease) {
- FURI_LOG_I("SubghzTestStatic", "TX Stop");
- furi_hal_subghz_stop_async_tx();
+ subghz_encoder_princeton_set(
+ instance->encoder, subghz_test_static_keys[model->button], 10000);
- notification_message(notification, &sequence_reset_red);
+ furi_hal_subghz_start_async_tx(
+ subghz_encoder_princeton_yield, instance->encoder);
+ instance->satus_tx = SubghzTestStaticStatusTX;
+ }
+ } else if(event->type == InputTypeRelease) {
+ if(instance->satus_tx == SubghzTestStaticStatusTX) {
+ FURI_LOG_I("SubghzTestStatic", "TX Stop");
+ subghz_encoder_princeton_print_log(instance->encoder);
+ furi_hal_subghz_stop_async_tx();
+ notification_message(notification, &sequence_reset_red);
+ }
+ instance->satus_tx = SubghzTestStaticStatusIDLE;
}
furi_record_close("notification");
}
@@ -114,12 +135,14 @@ void subghz_test_static_enter(void* context) {
hal_gpio_init(&gpio_cc1101_g0, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow);
hal_gpio_write(&gpio_cc1101_g0, false);
+ instance->satus_tx = SubghzTestStaticStatusIDLE;
with_view_model(
instance->view, (SubghzTestStaticModel * model) {
model->frequency = subghz_frequencies_433_92;
model->real_frequency = subghz_frequencies[model->frequency];
model->button = 0;
+
return true;
});
}
@@ -156,4 +179,4 @@ void subghz_test_static_free(SubghzTestStatic* instance) {
View* subghz_test_static_get_view(SubghzTestStatic* instance) {
furi_assert(instance);
return instance->view;
-}
+} \ No newline at end of file
diff --git a/applications/subghz/views/subghz_test_static.h b/applications/subghz/views/subghz_test_static.h
index ddcd8315..48346d8a 100644
--- a/applications/subghz/views/subghz_test_static.h
+++ b/applications/subghz/views/subghz_test_static.h
@@ -2,8 +2,19 @@
#include <gui/view.h>
+typedef enum {
+ SubghzTestStaticEventOnlyRx,
+} SubghzTestStaticEvent;
+
typedef struct SubghzTestStatic SubghzTestStatic;
+typedef void (*SubghzTestStaticCallback)(SubghzTestStaticEvent event, void* context);
+
+void subghz_test_static_set_callback(
+ SubghzTestStatic* subghz_test_static,
+ SubghzTestStaticCallback callback,
+ void* context);
+
SubghzTestStatic* subghz_test_static_alloc();
void subghz_test_static_free(SubghzTestStatic* subghz_static);