SubGHz: New check_tx API, ext modules follow settings

This commit is contained in:
Willy-JL
2024-05-16 11:57:42 +01:00
parent 0bcd521b29
commit 68a1d63360
17 changed files with 122 additions and 70 deletions

View File

@@ -652,22 +652,9 @@ bool subghz_txrx_radio_device_is_frequency_valid(SubGhzTxRx* instance, uint32_t
return subghz_devices_is_frequency_valid(instance->radio_device, frequency);
}
bool subghz_txrx_radio_device_is_tx_allowed(SubGhzTxRx* instance, uint32_t frequency) {
// TODO: Remake this function to check if the frequency is allowed on specific module - for modules not based on CC1101
SubGhzTx subghz_txrx_radio_device_check_tx(SubGhzTxRx* instance, uint32_t frequency) {
furi_assert(instance);
UNUSED(frequency);
/*
furi_assert(instance->txrx_state != SubGhzTxRxStateSleep);
subghz_devices_idle(instance->radio_device);
subghz_devices_set_frequency(instance->radio_device, frequency);
bool ret = subghz_devices_set_tx(instance->radio_device);
subghz_devices_idle(instance->radio_device);
return ret;
*/
return true;
return subghz_devices_check_tx(instance->radio_device, frequency);
}
void subghz_txrx_set_debug_pin_state(SubGhzTxRx* instance, bool state) {

View File

@@ -366,7 +366,7 @@ const char* subghz_txrx_radio_device_get_name(SubGhzTxRx* instance);
*/
bool subghz_txrx_radio_device_is_frequency_valid(SubGhzTxRx* instance, uint32_t frequency);
bool subghz_txrx_radio_device_is_tx_allowed(SubGhzTxRx* instance, uint32_t frequency);
SubGhzTx subghz_txrx_radio_device_check_tx(SubGhzTxRx* instance, uint32_t frequency);
void subghz_txrx_set_debug_pin_state(SubGhzTxRx* instance, bool state);
bool subghz_txrx_get_debug_pin_state(SubGhzTxRx* instance);

View File

@@ -15,7 +15,7 @@ void subghz_extended_freq() {
flipper_format_read_bool(file, "ignore_default_tx_region", &is_bypassed, 1);
}
furi_hal_subghz_set_extended_frequency(is_extended_i);
furi_hal_subghz_set_extended_range(is_extended_i);
furi_hal_subghz_set_bypass_region(is_bypassed);
flipper_format_free(file);

View File

@@ -30,7 +30,8 @@ bool subghz_tx_start(SubGhz* subghz, FlipperFormat* flipper_format) {
break;
case SubGhzTxRxStartTxStateErrorOnlyRx:
uint32_t frequency = subghz_txrx_get_preset(subghz->txrx).frequency;
subghz_dialog_message_freq_error(subghz, furi_hal_subghz_check_tx(frequency));
SubGhzTx can_tx = subghz_txrx_radio_device_check_tx(subghz->txrx, frequency);
subghz_dialog_message_freq_error(subghz, can_tx);
break;
default:
@@ -40,26 +41,26 @@ bool subghz_tx_start(SubGhz* subghz, FlipperFormat* flipper_format) {
return false;
}
void subghz_dialog_message_freq_error(SubGhz* subghz, FuriHalSubGhzTx can_tx) {
void subghz_dialog_message_freq_error(SubGhz* subghz, SubGhzTx can_tx) {
DialogsApp* dialogs = subghz->dialogs;
DialogMessage* message = dialog_message_alloc();
const char* header_text = "Transmission is blocked";
const char* message_text;
switch(can_tx) {
case FuriHalSubGhzTxAllowed:
case SubGhzTxAllowed:
default:
return;
case FuriHalSubGhzTxBlockedRegionNotProvisioned:
case SubGhzTxBlockedRegionNotProvisioned:
message_text = "Region is not\nprovisioned.\nUpdate firmware\nor bypass region.";
break;
case FuriHalSubGhzTxBlockedRegion:
case SubGhzTxBlockedRegion:
message_text = "Frequency outside\nof region range.\nMNTM > Protocols\n> Bypass Region";
break;
case FuriHalSubGhzTxBlockedDefault:
case SubGhzTxBlockedDefault:
message_text = "Frequency outside\nof default range.\nMNTM > Protocols\n> Extend Bands";
break;
case FuriHalSubGhzTxBlockedUnsupported:
case SubGhzTxUnsupported:
header_text = "Frequency not supported";
message_text = "Frequency is\noutside of\nsupported range.";
break;
@@ -88,7 +89,7 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path, bool show_dialog) {
uint32_t temp_data32;
float temp_lat = NAN; // NAN or 0.0?? because 0.0 is valid value
float temp_lon = NAN;
FuriHalSubGhzTx can_tx = FuriHalSubGhzTxAllowed;
SubGhzTx can_tx = SubGhzTxUnsupported;
do {
stream_clean(fff_data_stream);
@@ -118,14 +119,13 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path, bool show_dialog) {
if(!subghz_txrx_radio_device_is_frequency_valid(subghz->txrx, temp_data32)) {
FURI_LOG_E(TAG, "Frequency not supported on chosen radio module");
can_tx = FuriHalSubGhzTxBlockedUnsupported;
can_tx = SubGhzTxUnsupported;
load_key_state = SubGhzLoadKeyStateUnsuportedFreq;
break;
}
// TODO: use different frequency allowed lists for differnet modules (non cc1101)
can_tx = furi_hal_subghz_check_tx(temp_data32);
if(can_tx != FuriHalSubGhzTxAllowed) {
can_tx = subghz_txrx_radio_device_check_tx(subghz->txrx, temp_data32);
if(can_tx != SubGhzTxAllowed) {
FURI_LOG_E(TAG, "This frequency can only be used for RX");
load_key_state = SubGhzLoadKeyStateOnlyRx;

View File

@@ -115,7 +115,7 @@ void subghz_blink_start(SubGhz* subghz);
void subghz_blink_stop(SubGhz* subghz);
bool subghz_tx_start(SubGhz* subghz, FlipperFormat* flipper_format);
void subghz_dialog_message_freq_error(SubGhz* subghz, FuriHalSubGhzTx can_tx);
void subghz_dialog_message_freq_error(SubGhz* subghz, SubGhzTx can_tx);
bool subghz_key_load(SubGhz* subghz, const char* file_path, bool show_dialog);
bool subghz_get_next_name_file(SubGhz* subghz, uint8_t max_len);