mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
Fixes for SubGHz
This commit is contained in:
@@ -112,7 +112,7 @@ bool subghz_scene_decode_raw_start(SubGhz* subghz) {
|
||||
} while(false);
|
||||
|
||||
if(success) {
|
||||
// FURI_LOG_I(TAG, "Listening at \033[0;33m%s\033[0m.", string_get_cstr(file_name));
|
||||
//FURI_LOG_I(TAG, "Listening at \033[0;33m%s\033[0m.", string_get_cstr(file_name));
|
||||
|
||||
file_worker_encoder = subghz_file_encoder_worker_alloc();
|
||||
if(subghz_file_encoder_worker_start(file_worker_encoder, string_get_cstr(file_name))) {
|
||||
@@ -182,7 +182,6 @@ void subghz_scene_decode_raw_on_enter(void* context) {
|
||||
false);
|
||||
subghz_receiver_set_filter(subghz->txrx->receiver, SubGhzProtocolFlag_Decodable);
|
||||
|
||||
|
||||
if(decode_raw_state == SubGhzDecodeRawStateStart) {
|
||||
//Decode RAW to history
|
||||
subghz_history_reset(subghz->txrx->history);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "../subghz_i.h"
|
||||
#include "../views/receiver.h"
|
||||
|
||||
#define TAG "SubGhzSceneReceiver"
|
||||
|
||||
const NotificationSequence subghz_sequence_rx = {
|
||||
&message_green_255,
|
||||
|
||||
@@ -98,6 +100,8 @@ static void subghz_scene_add_to_history_callback(
|
||||
void subghz_scene_receiver_on_enter(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
subghz_last_setting_set_receiver_values(subghz->last_setting, subghz->txrx->receiver);
|
||||
|
||||
string_t str_buff;
|
||||
string_init(str_buff);
|
||||
|
||||
@@ -136,9 +140,11 @@ void subghz_scene_receiver_on_enter(void* context) {
|
||||
subghz->state_notifications = SubGhzNotificationStateRx;
|
||||
if(subghz->txrx->txrx_state == SubGhzTxRxStateRx) {
|
||||
subghz_rx_end(subghz);
|
||||
};
|
||||
}
|
||||
if((subghz->txrx->txrx_state == SubGhzTxRxStateIDLE) ||
|
||||
(subghz->txrx->txrx_state == SubGhzTxRxStateSleep)) {
|
||||
// Set values that can be reset after using DetectRAW Scene
|
||||
subghz_last_setting_set_receiver_values(subghz->last_setting, subghz->txrx->receiver);
|
||||
subghz_begin(
|
||||
subghz,
|
||||
subghz_setting_get_preset_data_by_name(
|
||||
@@ -157,15 +163,17 @@ bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event) {
|
||||
switch(event.event) {
|
||||
case SubGhzCustomEventViewReceiverBack:
|
||||
// Check if return from config save values
|
||||
if (subghz->current_scene == SubGhzSceneReceiverConfig) {
|
||||
subghz_last_setting_save(subghz->last_setting, EXT_PATH("subghz/assets/last_used.txt"));
|
||||
if(subghz->current_scene == SubGhzSceneReceiverConfig) {
|
||||
//FURI_LOG_I(TAG, "Raw value: %d", subghz->last_setting->detect_raw);
|
||||
subghz_last_setting_save(
|
||||
subghz->last_setting, EXT_PATH("subghz/assets/last_used.txt"));
|
||||
}
|
||||
// Stop CC1101 Rx
|
||||
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
||||
if(subghz->txrx->txrx_state == SubGhzTxRxStateRx) {
|
||||
subghz_rx_end(subghz);
|
||||
subghz_sleep(subghz);
|
||||
};
|
||||
}
|
||||
subghz->txrx->hopper_state = SubGhzHopperStateOFF;
|
||||
subghz->txrx->idx_menu_chosen = 0;
|
||||
subghz_receiver_set_rx_callback(subghz->txrx->receiver, NULL, subghz);
|
||||
@@ -199,7 +207,10 @@ bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event) {
|
||||
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
||||
subghz->txrx->idx_menu_chosen =
|
||||
subghz_view_receiver_get_idx_menu(subghz->subghz_receiver);
|
||||
scene_manager_set_scene_state(
|
||||
subghz->scene_manager, SubGhzViewIdReceiver, SubGhzCustomEventManagerSet);
|
||||
subghz->current_scene = SubGhzSceneReceiverConfig;
|
||||
//FURI_LOG_I(TAG, "Raw value: %d", subghz->last_setting->detect_raw);
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReceiverConfig);
|
||||
consumed = true;
|
||||
break;
|
||||
@@ -239,5 +250,8 @@ bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event) {
|
||||
}
|
||||
|
||||
void subghz_scene_receiver_on_exit(void* context) {
|
||||
UNUSED(context);
|
||||
SubGhz* subghz = context;
|
||||
|
||||
//filter restoration
|
||||
subghz_receiver_set_filter(subghz->txrx->receiver, SubGhzProtocolFlag_Decodable);
|
||||
}
|
||||
|
||||
@@ -14,10 +14,6 @@ void subghz_scene_show_only_rx_on_enter(void* context) {
|
||||
|
||||
const char* header_text = "Transmission is blocked";
|
||||
const char* message_text = "This frequency is\noutside of default\nrange";
|
||||
if(!furi_hal_region_is_provisioned()) {
|
||||
header_text = "Firmware update needed";
|
||||
message_text = "Please update\nfirmware before\nusing this feature\nflipp.dev/upd";
|
||||
}
|
||||
|
||||
popup_set_header(popup, header_text, 63, 3, AlignCenter, AlignTop);
|
||||
popup_set_text(popup, message_text, 0, 17, AlignLeft, AlignTop);
|
||||
|
||||
@@ -331,12 +331,6 @@ void subghz_free(SubGhz* subghz) {
|
||||
int32_t subghz_app(void* p) {
|
||||
SubGhz* subghz = subghz_alloc();
|
||||
|
||||
if(!furi_hal_region_is_provisioned()) {
|
||||
subghz_dialog_message_show_only_rx(subghz);
|
||||
subghz_free(subghz);
|
||||
return 1;
|
||||
}
|
||||
|
||||
//Load database
|
||||
bool load_database = subghz_environment_load_keystore(
|
||||
subghz->txrx->environment, EXT_PATH("subghz/assets/keeloq_mfcodes"));
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
#include "subghz_history.h"
|
||||
#include <lib/subghz/receiver.h>
|
||||
#include <lib/subghz/protocols/came.h>
|
||||
|
||||
#include <furi.h>
|
||||
#include <m-string.h>
|
||||
|
||||
#define SUBGHZ_HISTORY_MAX 99
|
||||
#define TAG "SubGhzHistory"
|
||||
@@ -41,15 +37,9 @@ SubGhzHistory* subghz_history_alloc(void) {
|
||||
|
||||
void subghz_history_free(SubGhzHistory* instance) {
|
||||
furi_assert(instance);
|
||||
string_clear(instance->tmp_string);
|
||||
for
|
||||
M_EACH(item, instance->history->data, SubGhzHistoryItemArray_t) {
|
||||
string_clear(item->item_str);
|
||||
string_clear(item->preset->name);
|
||||
free(item->preset);
|
||||
flipper_format_free(item->flipper_string);
|
||||
item->type = 0;
|
||||
}
|
||||
|
||||
// Call method instead of code duplicate
|
||||
subghz_history_reset(instance);
|
||||
SubGhzHistoryItemArray_clear(instance->history->data);
|
||||
free(instance->history);
|
||||
free(instance);
|
||||
@@ -143,16 +133,22 @@ bool subghz_history_add_to_history(
|
||||
furi_assert(instance);
|
||||
furi_assert(context);
|
||||
|
||||
if(instance->last_index_write >= SUBGHZ_HISTORY_MAX) return false;
|
||||
if(instance->last_index_write >= SUBGHZ_HISTORY_MAX) {
|
||||
FURI_LOG_W(TAG, "Out of history slots!");
|
||||
return false;
|
||||
}
|
||||
|
||||
SubGhzProtocolDecoderBase* decoder_base = context;
|
||||
if((instance->code_last_hash_data ==
|
||||
subghz_protocol_decoder_base_get_hash_data(decoder_base)) &&
|
||||
((furi_get_tick() - instance->last_update_timestamp) < 500)) {
|
||||
//FURI_LOG_W(TAG, "Too short period for add");
|
||||
instance->last_update_timestamp = furi_get_tick();
|
||||
return false;
|
||||
}
|
||||
|
||||
//FURI_LOG_I(TAG, "Add to history. Total: %d", instance->last_index_write + 1);
|
||||
|
||||
instance->code_last_hash_data = subghz_protocol_decoder_base_get_hash_data(decoder_base);
|
||||
instance->last_update_timestamp = furi_get_tick();
|
||||
|
||||
|
||||
@@ -220,11 +220,7 @@ void subghz_dialog_message_show_only_rx(SubGhz* subghz) {
|
||||
DialogMessage* message = dialog_message_alloc();
|
||||
|
||||
const char* header_text = "Transmission is blocked";
|
||||
const char* message_text = "Transmission on\nthis frequency is\nrestricted in\nyour region";
|
||||
if(!furi_hal_region_is_provisioned()) {
|
||||
header_text = "Firmware update needed";
|
||||
message_text = "Please update\nfirmware before\nusing this feature\nflipp.dev/upd";
|
||||
}
|
||||
const char* message_text = "Frequency\nis outside of\ndefault range.\nCheck docs.";
|
||||
|
||||
dialog_message_set_header(message, header_text, 63, 3, AlignCenter, AlignTop);
|
||||
dialog_message_set_text(message, message_text, 0, 17, AlignLeft, AlignTop);
|
||||
@@ -278,6 +274,11 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path, bool show_dialog) {
|
||||
break;
|
||||
}
|
||||
|
||||
if(!furi_hal_subghz_is_tx_allowed(temp_data32)) {
|
||||
FURI_LOG_E(TAG, "This frequency can only be used for RX");
|
||||
load_key_state = SubGhzLoadKeyStateOnlyRx;
|
||||
break;
|
||||
}
|
||||
subghz->txrx->preset->frequency = temp_data32;
|
||||
|
||||
if(!flipper_format_read_string(fff_data_file, "Preset", temp_str)) {
|
||||
@@ -349,6 +350,12 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path, bool show_dialog) {
|
||||
}
|
||||
return false;
|
||||
|
||||
case SubGhzLoadKeyStateOnlyRx:
|
||||
if(show_dialog) {
|
||||
subghz_dialog_message_show_only_rx(subghz);
|
||||
}
|
||||
return false;
|
||||
|
||||
case SubGhzLoadKeyStateOK:
|
||||
return true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user