mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
SubGHz: New check_tx API, ext modules follow settings
This commit is contained in:
@@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#define SUBGHZ_DEVICE_CC1101_EXT_TX_GPIO (&gpio_ext_pb2)
|
#define SUBGHZ_DEVICE_CC1101_EXT_TX_GPIO (&gpio_ext_pb2)
|
||||||
#define SUBGHZ_DEVICE_CC1101_EXT_E07M20S_AMP_GPIO &gpio_ext_pc3
|
#define SUBGHZ_DEVICE_CC1101_EXT_E07M20S_AMP_GPIO &gpio_ext_pc3
|
||||||
#define SUBGHZ_DEVICE_CC1101_EXT_FORCE_EXTENDED_RANGE false
|
|
||||||
|
|
||||||
#define SUBGHZ_DEVICE_CC1101_CONFIG_VER 1
|
#define SUBGHZ_DEVICE_CC1101_CONFIG_VER 1
|
||||||
|
|
||||||
@@ -93,8 +92,9 @@ typedef struct {
|
|||||||
const GpioPin* g0_pin;
|
const GpioPin* g0_pin;
|
||||||
SubGhzDeviceCC1101ExtAsyncTx async_tx;
|
SubGhzDeviceCC1101ExtAsyncTx async_tx;
|
||||||
SubGhzDeviceCC1101ExtAsyncRx async_rx;
|
SubGhzDeviceCC1101ExtAsyncRx async_rx;
|
||||||
bool power_amp;
|
|
||||||
bool extended_range;
|
bool extended_range;
|
||||||
|
bool bypass_region;
|
||||||
|
bool power_amp;
|
||||||
} SubGhzDeviceCC1101Ext;
|
} SubGhzDeviceCC1101Ext;
|
||||||
|
|
||||||
static SubGhzDeviceCC1101Ext* subghz_device_cc1101_ext = NULL;
|
static SubGhzDeviceCC1101Ext* subghz_device_cc1101_ext = NULL;
|
||||||
@@ -219,12 +219,14 @@ bool subghz_device_cc1101_ext_alloc(SubGhzDeviceConf* conf) {
|
|||||||
subghz_device_cc1101_ext->regulation = SubGhzDeviceCC1101ExtRegulationTxRx;
|
subghz_device_cc1101_ext->regulation = SubGhzDeviceCC1101ExtRegulationTxRx;
|
||||||
subghz_device_cc1101_ext->async_mirror_pin = NULL;
|
subghz_device_cc1101_ext->async_mirror_pin = NULL;
|
||||||
subghz_device_cc1101_ext->g0_pin = SUBGHZ_DEVICE_CC1101_EXT_TX_GPIO;
|
subghz_device_cc1101_ext->g0_pin = SUBGHZ_DEVICE_CC1101_EXT_TX_GPIO;
|
||||||
subghz_device_cc1101_ext->power_amp = false;
|
|
||||||
subghz_device_cc1101_ext->extended_range = false;
|
subghz_device_cc1101_ext->extended_range = false;
|
||||||
|
subghz_device_cc1101_ext->bypass_region = false;
|
||||||
|
subghz_device_cc1101_ext->power_amp = false;
|
||||||
if(conf) {
|
if(conf) {
|
||||||
if(conf->ver == SUBGHZ_DEVICE_CC1101_CONFIG_VER) {
|
if(conf->ver == SUBGHZ_DEVICE_CC1101_CONFIG_VER) {
|
||||||
subghz_device_cc1101_ext->power_amp = conf->power_amp;
|
|
||||||
subghz_device_cc1101_ext->extended_range = conf->extended_range;
|
subghz_device_cc1101_ext->extended_range = conf->extended_range;
|
||||||
|
subghz_device_cc1101_ext->bypass_region = conf->bypass_region;
|
||||||
|
subghz_device_cc1101_ext->power_amp = conf->power_amp;
|
||||||
} else {
|
} else {
|
||||||
FURI_LOG_E(TAG, "Config version mismatch");
|
FURI_LOG_E(TAG, "Config version mismatch");
|
||||||
}
|
}
|
||||||
@@ -522,30 +524,47 @@ bool subghz_device_cc1101_ext_is_frequency_valid(uint32_t value) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool subghz_device_cc1101_ext_is_tx_allowed(uint32_t value) {
|
SubGhzTx subghz_device_cc1101_ext_check_tx(uint32_t value) {
|
||||||
if(!(SUBGHZ_DEVICE_CC1101_EXT_FORCE_EXTENDED_RANGE ||
|
// Check against extended range of YARD Stick One, no configuration would allow this frequency
|
||||||
subghz_device_cc1101_ext->extended_range) &&
|
if(!subghz_device_cc1101_ext_is_frequency_valid(value)) {
|
||||||
|
FURI_LOG_I(TAG, "Frequency blocked - outside supported range");
|
||||||
|
return SubGhzTxUnsupported;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check against default range, regardless of region restrictions
|
||||||
|
if(!subghz_device_cc1101_ext->extended_range &&
|
||||||
!(value >= 299999755 && value <= 350000335) && // was increased from 348 to 350
|
!(value >= 299999755 && value <= 350000335) && // was increased from 348 to 350
|
||||||
!(value >= 386999938 && value <= 467750000) && // was increased from 464 to 467.75
|
!(value >= 386999938 && value <= 467750000) && // was increased from 464 to 467.75
|
||||||
!(value >= 778999847 && value <= 928000000)) {
|
!(value >= 778999847 && value <= 928000000)) {
|
||||||
FURI_LOG_I(TAG, "Frequency blocked - outside default range");
|
FURI_LOG_I(TAG, "Frequency blocked - outside default range");
|
||||||
return false;
|
return SubGhzTxBlockedDefault;
|
||||||
} else if(
|
|
||||||
(SUBGHZ_DEVICE_CC1101_EXT_FORCE_EXTENDED_RANGE ||
|
|
||||||
subghz_device_cc1101_ext->extended_range) &&
|
|
||||||
!subghz_device_cc1101_ext_is_frequency_valid(value)) {
|
|
||||||
FURI_LOG_I(TAG, "Frequency blocked - outside extended range");
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
// Check against region restrictions, tighter than extended and default
|
||||||
|
if(!subghz_device_cc1101_ext->bypass_region) {
|
||||||
|
if(!furi_hal_region_is_provisioned()) {
|
||||||
|
FURI_LOG_I(TAG, "Frequency blocked - region not provisioned");
|
||||||
|
return SubGhzTxBlockedRegionNotProvisioned;
|
||||||
|
}
|
||||||
|
if(!furi_hal_region_is_frequency_allowed(value)) {
|
||||||
|
FURI_LOG_I(TAG, "Frequency blocked - outside region range");
|
||||||
|
return SubGhzTxBlockedRegion;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// We already checked for extended range, default range, and region range
|
||||||
|
return SubGhzTxAllowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool subghz_device_cc1101_ext_is_tx_allowed(uint32_t value) {
|
||||||
|
return subghz_device_cc1101_ext_check_tx(value) == SubGhzTxAllowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t subghz_device_cc1101_ext_set_frequency(uint32_t value) {
|
uint32_t subghz_device_cc1101_ext_set_frequency(uint32_t value) {
|
||||||
if(subghz_device_cc1101_ext_is_tx_allowed(value)) {
|
if(subghz_device_cc1101_ext_is_tx_allowed(value)) {
|
||||||
subghz_device_cc1101_ext->regulation = SubGhzDeviceCC1101ExtRegulationTxRx;
|
subghz_device_cc1101_ext->regulation = SubGhzDeviceCC1101ExtRegulationTxRx;
|
||||||
} else {
|
} else {
|
||||||
subghz_device_cc1101_ext->regulation = SubGhzDeviceCC1101ExtRegulationTxRx;
|
subghz_device_cc1101_ext->regulation = SubGhzDeviceCC1101ExtRegulationOnlyRx;
|
||||||
}
|
}
|
||||||
|
|
||||||
furi_hal_spi_acquire(subghz_device_cc1101_ext->spi_bus_handle);
|
furi_hal_spi_acquire(subghz_device_cc1101_ext->spi_bus_handle);
|
||||||
|
|||||||
@@ -152,6 +152,14 @@ uint8_t subghz_device_cc1101_ext_get_lqi(void);
|
|||||||
*/
|
*/
|
||||||
bool subghz_device_cc1101_ext_is_frequency_valid(uint32_t value);
|
bool subghz_device_cc1101_ext_is_frequency_valid(uint32_t value);
|
||||||
|
|
||||||
|
/** Сheck if and why transmission is blocked on this frequency with current config
|
||||||
|
*
|
||||||
|
* @param value frequency in Hz
|
||||||
|
*
|
||||||
|
* @return tx allowed or blocked enum
|
||||||
|
*/
|
||||||
|
SubGhzTx subghz_device_cc1101_ext_check_tx(uint32_t value);
|
||||||
|
|
||||||
/** Set frequency
|
/** Set frequency
|
||||||
*
|
*
|
||||||
* @param value frequency in Hz
|
* @param value frequency in Hz
|
||||||
|
|||||||
@@ -92,6 +92,8 @@ const SubGhzDeviceInterconnect subghz_device_cc1101_ext_interconnect = {
|
|||||||
.is_rx_data_crc_valid = subghz_device_cc1101_ext_is_rx_data_crc_valid,
|
.is_rx_data_crc_valid = subghz_device_cc1101_ext_is_rx_data_crc_valid,
|
||||||
.read_packet = subghz_device_cc1101_ext_read_packet,
|
.read_packet = subghz_device_cc1101_ext_read_packet,
|
||||||
.write_packet = subghz_device_cc1101_ext_write_packet,
|
.write_packet = subghz_device_cc1101_ext_write_packet,
|
||||||
|
|
||||||
|
.check_tx = subghz_device_cc1101_ext_check_tx,
|
||||||
};
|
};
|
||||||
|
|
||||||
const SubGhzDevice subghz_device_cc1101_ext = {
|
const SubGhzDevice subghz_device_cc1101_ext = {
|
||||||
|
|||||||
@@ -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);
|
return subghz_devices_is_frequency_valid(instance->radio_device, 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) {
|
||||||
// TODO: Remake this function to check if the frequency is allowed on specific module - for modules not based on CC1101
|
|
||||||
furi_assert(instance);
|
furi_assert(instance);
|
||||||
UNUSED(frequency);
|
return subghz_devices_check_tx(instance->radio_device, 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void subghz_txrx_set_debug_pin_state(SubGhzTxRx* instance, bool state) {
|
void subghz_txrx_set_debug_pin_state(SubGhzTxRx* instance, bool state) {
|
||||||
|
|||||||
@@ -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_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);
|
void subghz_txrx_set_debug_pin_state(SubGhzTxRx* instance, bool state);
|
||||||
bool subghz_txrx_get_debug_pin_state(SubGhzTxRx* instance);
|
bool subghz_txrx_get_debug_pin_state(SubGhzTxRx* instance);
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ void subghz_extended_freq() {
|
|||||||
flipper_format_read_bool(file, "ignore_default_tx_region", &is_bypassed, 1);
|
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);
|
furi_hal_subghz_set_bypass_region(is_bypassed);
|
||||||
|
|
||||||
flipper_format_free(file);
|
flipper_format_free(file);
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ bool subghz_tx_start(SubGhz* subghz, FlipperFormat* flipper_format) {
|
|||||||
break;
|
break;
|
||||||
case SubGhzTxRxStartTxStateErrorOnlyRx:
|
case SubGhzTxRxStartTxStateErrorOnlyRx:
|
||||||
uint32_t frequency = subghz_txrx_get_preset(subghz->txrx).frequency;
|
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;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -40,26 +41,26 @@ bool subghz_tx_start(SubGhz* subghz, FlipperFormat* flipper_format) {
|
|||||||
return false;
|
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;
|
DialogsApp* dialogs = subghz->dialogs;
|
||||||
DialogMessage* message = dialog_message_alloc();
|
DialogMessage* message = dialog_message_alloc();
|
||||||
const char* header_text = "Transmission is blocked";
|
const char* header_text = "Transmission is blocked";
|
||||||
const char* message_text;
|
const char* message_text;
|
||||||
|
|
||||||
switch(can_tx) {
|
switch(can_tx) {
|
||||||
case FuriHalSubGhzTxAllowed:
|
case SubGhzTxAllowed:
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
case FuriHalSubGhzTxBlockedRegionNotProvisioned:
|
case SubGhzTxBlockedRegionNotProvisioned:
|
||||||
message_text = "Region is not\nprovisioned.\nUpdate firmware\nor bypass region.";
|
message_text = "Region is not\nprovisioned.\nUpdate firmware\nor bypass region.";
|
||||||
break;
|
break;
|
||||||
case FuriHalSubGhzTxBlockedRegion:
|
case SubGhzTxBlockedRegion:
|
||||||
message_text = "Frequency outside\nof region range.\nMNTM > Protocols\n> Bypass Region";
|
message_text = "Frequency outside\nof region range.\nMNTM > Protocols\n> Bypass Region";
|
||||||
break;
|
break;
|
||||||
case FuriHalSubGhzTxBlockedDefault:
|
case SubGhzTxBlockedDefault:
|
||||||
message_text = "Frequency outside\nof default range.\nMNTM > Protocols\n> Extend Bands";
|
message_text = "Frequency outside\nof default range.\nMNTM > Protocols\n> Extend Bands";
|
||||||
break;
|
break;
|
||||||
case FuriHalSubGhzTxBlockedUnsupported:
|
case SubGhzTxUnsupported:
|
||||||
header_text = "Frequency not supported";
|
header_text = "Frequency not supported";
|
||||||
message_text = "Frequency is\noutside of\nsupported range.";
|
message_text = "Frequency is\noutside of\nsupported range.";
|
||||||
break;
|
break;
|
||||||
@@ -88,7 +89,7 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path, bool show_dialog) {
|
|||||||
uint32_t temp_data32;
|
uint32_t temp_data32;
|
||||||
float temp_lat = NAN; // NAN or 0.0?? because 0.0 is valid value
|
float temp_lat = NAN; // NAN or 0.0?? because 0.0 is valid value
|
||||||
float temp_lon = NAN;
|
float temp_lon = NAN;
|
||||||
FuriHalSubGhzTx can_tx = FuriHalSubGhzTxAllowed;
|
SubGhzTx can_tx = SubGhzTxUnsupported;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
stream_clean(fff_data_stream);
|
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)) {
|
if(!subghz_txrx_radio_device_is_frequency_valid(subghz->txrx, temp_data32)) {
|
||||||
FURI_LOG_E(TAG, "Frequency not supported on chosen radio module");
|
FURI_LOG_E(TAG, "Frequency not supported on chosen radio module");
|
||||||
can_tx = FuriHalSubGhzTxBlockedUnsupported;
|
can_tx = SubGhzTxUnsupported;
|
||||||
load_key_state = SubGhzLoadKeyStateUnsuportedFreq;
|
load_key_state = SubGhzLoadKeyStateUnsuportedFreq;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use different frequency allowed lists for differnet modules (non cc1101)
|
can_tx = subghz_txrx_radio_device_check_tx(subghz->txrx, temp_data32);
|
||||||
can_tx = furi_hal_subghz_check_tx(temp_data32);
|
if(can_tx != SubGhzTxAllowed) {
|
||||||
if(can_tx != FuriHalSubGhzTxAllowed) {
|
|
||||||
FURI_LOG_E(TAG, "This frequency can only be used for RX");
|
FURI_LOG_E(TAG, "This frequency can only be used for RX");
|
||||||
|
|
||||||
load_key_state = SubGhzLoadKeyStateOnlyRx;
|
load_key_state = SubGhzLoadKeyStateOnlyRx;
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ void subghz_blink_start(SubGhz* subghz);
|
|||||||
void subghz_blink_stop(SubGhz* subghz);
|
void subghz_blink_stop(SubGhz* subghz);
|
||||||
|
|
||||||
bool subghz_tx_start(SubGhz* subghz, FlipperFormat* flipper_format);
|
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_key_load(SubGhz* subghz, const char* file_path, bool show_dialog);
|
||||||
bool subghz_get_next_name_file(SubGhz* subghz, uint8_t max_len);
|
bool subghz_get_next_name_file(SubGhz* subghz, uint8_t max_len);
|
||||||
|
|||||||
@@ -88,6 +88,8 @@ const SubGhzDeviceInterconnect subghz_device_cc1101_int_interconnect = {
|
|||||||
.is_rx_data_crc_valid = furi_hal_subghz_is_rx_data_crc_valid,
|
.is_rx_data_crc_valid = furi_hal_subghz_is_rx_data_crc_valid,
|
||||||
.read_packet = furi_hal_subghz_read_packet,
|
.read_packet = furi_hal_subghz_read_packet,
|
||||||
.write_packet = furi_hal_subghz_write_packet,
|
.write_packet = furi_hal_subghz_write_packet,
|
||||||
|
|
||||||
|
.check_tx = furi_hal_subghz_check_tx,
|
||||||
};
|
};
|
||||||
|
|
||||||
const SubGhzDevice subghz_device_cc1101_int = {
|
const SubGhzDevice subghz_device_cc1101_int = {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include "registry.h"
|
#include "registry.h"
|
||||||
|
|
||||||
#include <subghz/subghz_last_settings.h>
|
#include <subghz/subghz_last_settings.h>
|
||||||
|
#include <furi_hal_subghz_i.h>
|
||||||
|
|
||||||
void subghz_devices_init(void) {
|
void subghz_devices_init(void) {
|
||||||
furi_check(!subghz_device_registry_is_valid());
|
furi_check(!subghz_device_registry_is_valid());
|
||||||
@@ -34,7 +35,8 @@ bool subghz_devices_begin(const SubGhzDevice* device) {
|
|||||||
if(device->interconnect->begin) {
|
if(device->interconnect->begin) {
|
||||||
SubGhzDeviceConf conf = {
|
SubGhzDeviceConf conf = {
|
||||||
.ver = 1,
|
.ver = 1,
|
||||||
.extended_range = false, // TODO
|
.extended_range = furi_hal_subghz_get_extended_range(),
|
||||||
|
.bypass_region = furi_hal_subghz_get_bypass_region(),
|
||||||
.power_amp = true,
|
.power_amp = true,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -242,3 +244,12 @@ void subghz_devices_write_packet(const SubGhzDevice* device, const uint8_t* data
|
|||||||
device->interconnect->write_packet(data, size);
|
device->interconnect->write_packet(data, size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SubGhzTx subghz_devices_check_tx(const SubGhzDevice* device, uint32_t frequency) {
|
||||||
|
SubGhzTx ret = SubGhzTxUnsupported;
|
||||||
|
furi_check(device);
|
||||||
|
if(device->interconnect->check_tx) {
|
||||||
|
ret = device->interconnect->check_tx(frequency);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ bool subghz_devices_is_rx_data_crc_valid(const SubGhzDevice* device);
|
|||||||
void subghz_devices_read_packet(const SubGhzDevice* device, uint8_t* data, uint8_t* size);
|
void subghz_devices_read_packet(const SubGhzDevice* device, uint8_t* data, uint8_t* size);
|
||||||
void subghz_devices_write_packet(const SubGhzDevice* device, const uint8_t* data, uint8_t size);
|
void subghz_devices_write_packet(const SubGhzDevice* device, const uint8_t* data, uint8_t size);
|
||||||
|
|
||||||
|
SubGhzTx subghz_devices_check_tx(const SubGhzDevice* device, uint32_t frequency);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
10
lib/subghz/devices/tx.h
Normal file
10
lib/subghz/devices/tx.h
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
/** TX Allowed or Blocked Reasons */
|
||||||
|
typedef enum {
|
||||||
|
SubGhzTxAllowed, /**< TX is allowed with this configuration */
|
||||||
|
SubGhzTxBlockedRegionNotProvisioned, /**< Region not provisioned and not bypassed */
|
||||||
|
SubGhzTxBlockedRegion, /**< Outside region, needs bypass region */
|
||||||
|
SubGhzTxBlockedDefault, /**< Outisde default, needs extended range */
|
||||||
|
SubGhzTxUnsupported, /**< No configuration would allow this */
|
||||||
|
} SubGhzTx;
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
#include <furi_hal.h>
|
#include <furi_hal.h>
|
||||||
|
|
||||||
#include "preset.h"
|
#include "preset.h"
|
||||||
|
#include "tx.h"
|
||||||
|
|
||||||
#include <flipper_application/flipper_application.h>
|
#include <flipper_application/flipper_application.h>
|
||||||
|
|
||||||
@@ -50,6 +51,8 @@ typedef bool (*SubGhzRxIsDataCrcValid)(void);
|
|||||||
typedef void (*SubGhzReadPacket)(uint8_t* data, uint8_t* size);
|
typedef void (*SubGhzReadPacket)(uint8_t* data, uint8_t* size);
|
||||||
typedef void (*SubGhzWritePacket)(const uint8_t* data, uint8_t size);
|
typedef void (*SubGhzWritePacket)(const uint8_t* data, uint8_t size);
|
||||||
|
|
||||||
|
typedef SubGhzTx (*SubGhzCheckTx)(uint32_t frequency);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SubGhzBegin begin;
|
SubGhzBegin begin;
|
||||||
SubGhzEnd end;
|
SubGhzEnd end;
|
||||||
@@ -84,6 +87,7 @@ typedef struct {
|
|||||||
SubGhzReadPacket read_packet;
|
SubGhzReadPacket read_packet;
|
||||||
SubGhzWritePacket write_packet;
|
SubGhzWritePacket write_packet;
|
||||||
|
|
||||||
|
SubGhzCheckTx check_tx;
|
||||||
} SubGhzDeviceInterconnect;
|
} SubGhzDeviceInterconnect;
|
||||||
|
|
||||||
struct SubGhzDevice {
|
struct SubGhzDevice {
|
||||||
@@ -94,5 +98,6 @@ struct SubGhzDevice {
|
|||||||
struct SubGhzDeviceConf {
|
struct SubGhzDeviceConf {
|
||||||
uint8_t ver;
|
uint8_t ver;
|
||||||
bool extended_range;
|
bool extended_range;
|
||||||
|
bool bypass_region;
|
||||||
bool power_amp;
|
bool power_amp;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1676,7 +1676,7 @@ Function,-,furi_hal_spi_config_init,void,
|
|||||||
Function,-,furi_hal_spi_config_init_early,void,
|
Function,-,furi_hal_spi_config_init_early,void,
|
||||||
Function,-,furi_hal_spi_dma_init,void,
|
Function,-,furi_hal_spi_dma_init,void,
|
||||||
Function,+,furi_hal_spi_release,void,FuriHalSpiBusHandle*
|
Function,+,furi_hal_spi_release,void,FuriHalSpiBusHandle*
|
||||||
Function,+,furi_hal_subghz_check_tx,FuriHalSubGhzTx,uint32_t
|
Function,+,furi_hal_subghz_check_tx,SubGhzTx,uint32_t
|
||||||
Function,-,furi_hal_subghz_dump_state,void,
|
Function,-,furi_hal_subghz_dump_state,void,
|
||||||
Function,+,furi_hal_subghz_flush_rx,void,
|
Function,+,furi_hal_subghz_flush_rx,void,
|
||||||
Function,+,furi_hal_subghz_flush_tx,void,
|
Function,+,furi_hal_subghz_flush_tx,void,
|
||||||
@@ -3347,6 +3347,7 @@ Function,+,subghz_custom_btn_set,_Bool,uint8_t
|
|||||||
Function,+,subghz_custom_btns_reset,void,
|
Function,+,subghz_custom_btns_reset,void,
|
||||||
Function,-,subghz_device_cc1101_ext_ep,const FlipperAppPluginDescriptor*,
|
Function,-,subghz_device_cc1101_ext_ep,const FlipperAppPluginDescriptor*,
|
||||||
Function,+,subghz_devices_begin,_Bool,const SubGhzDevice*
|
Function,+,subghz_devices_begin,_Bool,const SubGhzDevice*
|
||||||
|
Function,+,subghz_devices_check_tx,SubGhzTx,"const SubGhzDevice*, uint32_t"
|
||||||
Function,+,subghz_devices_deinit,void,
|
Function,+,subghz_devices_deinit,void,
|
||||||
Function,+,subghz_devices_end,void,const SubGhzDevice*
|
Function,+,subghz_devices_end,void,const SubGhzDevice*
|
||||||
Function,+,subghz_devices_flush_rx,void,const SubGhzDevice*
|
Function,+,subghz_devices_flush_rx,void,const SubGhzDevice*
|
||||||
|
|||||||
|
@@ -53,7 +53,7 @@ typedef struct {
|
|||||||
const GpioPin* async_mirror_pin;
|
const GpioPin* async_mirror_pin;
|
||||||
|
|
||||||
int8_t rolling_counter_mult;
|
int8_t rolling_counter_mult;
|
||||||
bool extended_frequency_i : 1;
|
bool extended_range : 1;
|
||||||
bool bypass_region : 1;
|
bool bypass_region : 1;
|
||||||
} FuriHalSubGhz;
|
} FuriHalSubGhz;
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ volatile FuriHalSubGhz furi_hal_subghz = {
|
|||||||
.regulation = SubGhzRegulationTxRx,
|
.regulation = SubGhzRegulationTxRx,
|
||||||
.async_mirror_pin = NULL,
|
.async_mirror_pin = NULL,
|
||||||
.rolling_counter_mult = 1,
|
.rolling_counter_mult = 1,
|
||||||
.extended_frequency_i = false,
|
.extended_range = false,
|
||||||
.bypass_region = false,
|
.bypass_region = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -74,14 +74,22 @@ void furi_hal_subghz_set_rolling_counter_mult(int8_t mult) {
|
|||||||
furi_hal_subghz.rolling_counter_mult = mult;
|
furi_hal_subghz.rolling_counter_mult = mult;
|
||||||
}
|
}
|
||||||
|
|
||||||
void furi_hal_subghz_set_extended_frequency(bool state_i) {
|
void furi_hal_subghz_set_extended_range(bool enabled) {
|
||||||
furi_hal_subghz.extended_frequency_i = state_i;
|
furi_hal_subghz.extended_range = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool furi_hal_subghz_get_extended_range(void) {
|
||||||
|
return furi_hal_subghz.extended_range;
|
||||||
}
|
}
|
||||||
|
|
||||||
void furi_hal_subghz_set_bypass_region(bool enabled) {
|
void furi_hal_subghz_set_bypass_region(bool enabled) {
|
||||||
furi_hal_subghz.bypass_region = enabled;
|
furi_hal_subghz.bypass_region = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool furi_hal_subghz_get_bypass_region(void) {
|
||||||
|
return furi_hal_subghz.bypass_region;
|
||||||
|
}
|
||||||
|
|
||||||
void furi_hal_subghz_set_async_mirror_pin(const GpioPin* pin) {
|
void furi_hal_subghz_set_async_mirror_pin(const GpioPin* pin) {
|
||||||
furi_hal_subghz.async_mirror_pin = pin;
|
furi_hal_subghz.async_mirror_pin = pin;
|
||||||
}
|
}
|
||||||
@@ -390,40 +398,40 @@ uint32_t furi_hal_subghz_set_frequency_and_path(uint32_t value) {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
FuriHalSubGhzTx furi_hal_subghz_check_tx(uint32_t value) {
|
SubGhzTx furi_hal_subghz_check_tx(uint32_t value) {
|
||||||
// Check against extended range of YARD Stick One, no configuration would allow this frequency
|
// Check against extended range of YARD Stick One, no configuration would allow this frequency
|
||||||
if(!furi_hal_subghz_is_frequency_valid(value)) {
|
if(!furi_hal_subghz_is_frequency_valid(value)) {
|
||||||
FURI_LOG_I(TAG, "Frequency blocked - outside supported range");
|
FURI_LOG_I(TAG, "Frequency blocked - outside supported range");
|
||||||
return FuriHalSubGhzTxBlockedUnsupported;
|
return SubGhzTxUnsupported;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check against default range, regardless of region restrictions
|
// Check against default range, regardless of region restrictions
|
||||||
if(!furi_hal_subghz.extended_frequency_i &&
|
if(!furi_hal_subghz.extended_range &&
|
||||||
!(value >= 299999755 && value <= 350000335) && // was increased from 348 to 350
|
!(value >= 299999755 && value <= 350000335) && // was increased from 348 to 350
|
||||||
!(value >= 386999938 && value <= 467750000) && // was increased from 464 to 467.75
|
!(value >= 386999938 && value <= 467750000) && // was increased from 464 to 467.75
|
||||||
!(value >= 778999847 && value <= 928000000)) {
|
!(value >= 778999847 && value <= 928000000)) {
|
||||||
FURI_LOG_I(TAG, "Frequency blocked - outside default range");
|
FURI_LOG_I(TAG, "Frequency blocked - outside default range");
|
||||||
return FuriHalSubGhzTxBlockedDefault;
|
return SubGhzTxBlockedDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check against region restrictions, tighter than extended and default
|
// Check against region restrictions, tighter than extended and default
|
||||||
if(!furi_hal_subghz.bypass_region) {
|
if(!furi_hal_subghz.bypass_region) {
|
||||||
if(!furi_hal_region_is_provisioned()) {
|
if(!furi_hal_region_is_provisioned()) {
|
||||||
FURI_LOG_I(TAG, "Frequency blocked - region not provisioned");
|
FURI_LOG_I(TAG, "Frequency blocked - region not provisioned");
|
||||||
return FuriHalSubGhzTxBlockedRegionNotProvisioned;
|
return SubGhzTxBlockedRegionNotProvisioned;
|
||||||
}
|
}
|
||||||
if(!_furi_hal_region_is_frequency_allowed(value)) {
|
if(!_furi_hal_region_is_frequency_allowed(value)) {
|
||||||
FURI_LOG_I(TAG, "Frequency blocked - outside region range");
|
FURI_LOG_I(TAG, "Frequency blocked - outside region range");
|
||||||
return FuriHalSubGhzTxBlockedRegion;
|
return SubGhzTxBlockedRegion;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We already checked for extended range, default range, and region range
|
// We already checked for extended range, default range, and region range
|
||||||
return FuriHalSubGhzTxAllowed;
|
return SubGhzTxAllowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool furi_hal_subghz_is_tx_allowed(uint32_t value) {
|
bool furi_hal_subghz_is_tx_allowed(uint32_t value) {
|
||||||
return furi_hal_subghz_check_tx(value) == FuriHalSubGhzTxAllowed;
|
return furi_hal_subghz_check_tx(value) == SubGhzTxAllowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t furi_hal_subghz_set_frequency(uint32_t value) {
|
uint32_t furi_hal_subghz_set_frequency(uint32_t value) {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <lib/subghz/devices/preset.h>
|
#include <lib/subghz/devices/preset.h>
|
||||||
|
#include <lib/subghz/devices/tx.h>
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@@ -165,21 +166,13 @@ bool furi_hal_subghz_is_frequency_valid(uint32_t value);
|
|||||||
*/
|
*/
|
||||||
uint32_t furi_hal_subghz_set_frequency_and_path(uint32_t value);
|
uint32_t furi_hal_subghz_set_frequency_and_path(uint32_t value);
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
FuriHalSubGhzTxAllowed, // TX is allowed with this configuration
|
|
||||||
FuriHalSubGhzTxBlockedRegionNotProvisioned, // Region not provisioned and not bypassed
|
|
||||||
FuriHalSubGhzTxBlockedRegion, // Outside region, needs bypass region
|
|
||||||
FuriHalSubGhzTxBlockedDefault, // Outisde default, needs extended range
|
|
||||||
FuriHalSubGhzTxBlockedUnsupported, // No configuration would allow this
|
|
||||||
} FuriHalSubGhzTx;
|
|
||||||
|
|
||||||
/** Сheck if and why transmission is blocked on this frequency with current config
|
/** Сheck if and why transmission is blocked on this frequency with current config
|
||||||
*
|
*
|
||||||
* @param value frequency in Hz
|
* @param value frequency in Hz
|
||||||
*
|
*
|
||||||
* @return tx allowed or blocked enum
|
* @return tx allowed or blocked enum
|
||||||
*/
|
*/
|
||||||
FuriHalSubGhzTx furi_hal_subghz_check_tx(uint32_t value);
|
SubGhzTx furi_hal_subghz_check_tx(uint32_t value);
|
||||||
|
|
||||||
/** Сheck if transmission is allowed on this frequency with your current config
|
/** Сheck if transmission is allowed on this frequency with your current config
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
void furi_hal_subghz_set_extended_frequency(bool state_i);
|
void furi_hal_subghz_set_extended_range(bool enabled);
|
||||||
|
|
||||||
|
bool furi_hal_subghz_get_extended_range(void);
|
||||||
|
|
||||||
void furi_hal_subghz_set_bypass_region(bool enabled);
|
void furi_hal_subghz_set_bypass_region(bool enabled);
|
||||||
|
|
||||||
|
bool furi_hal_subghz_get_bypass_region(void);
|
||||||
Reference in New Issue
Block a user