mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-13 03:38:35 -07:00
Fix chat & subghz settings
This commit is contained in:
@@ -602,7 +602,8 @@ static void subghz_cli_command_encrypt_raw(Cli* cli, FuriString* args) {
|
|||||||
furi_string_free(source);
|
furi_string_free(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void subghz_cli_command_chat(Cli* cli, FuriString* args) {
|
static void subghz_cli_command_chat(Cli* cli, FuriString* args, void* context) {
|
||||||
|
UNUSED(context);
|
||||||
uint32_t frequency = 433920000;
|
uint32_t frequency = 433920000;
|
||||||
|
|
||||||
if(furi_string_size(args)) {
|
if(furi_string_size(args)) {
|
||||||
@@ -795,7 +796,7 @@ static void subghz_cli_command(Cli* cli, FuriString* args, void* context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(furi_string_cmp_str(cmd, "chat") == 0) {
|
if(furi_string_cmp_str(cmd, "chat") == 0) {
|
||||||
subghz_cli_command_chat(cli, args);
|
subghz_cli_command_chat(cli, args, NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -853,6 +854,9 @@ void subghz_on_system_start() {
|
|||||||
|
|
||||||
cli_add_command(cli, "subghz", CliCommandFlagDefault, subghz_cli_command, NULL);
|
cli_add_command(cli, "subghz", CliCommandFlagDefault, subghz_cli_command, NULL);
|
||||||
|
|
||||||
|
// psst RM... i know you dont care much about errors, but if you ever see this... incompatible pointer type :3
|
||||||
|
cli_add_command(cli, "chat", CliCommandFlagDefault, subghz_cli_command_chat, NULL);
|
||||||
|
|
||||||
furi_record_close(RECORD_CLI);
|
furi_record_close(RECORD_CLI);
|
||||||
#else
|
#else
|
||||||
UNUSED(subghz_cli_command);
|
UNUSED(subghz_cli_command);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <furi_hal_subghz.h>
|
#include <furi_hal_subghz.h>
|
||||||
#include <furi_hal_subghz_configs.h>
|
#include <furi_hal_subghz_configs.h>
|
||||||
|
#include <furi_hal_region.h>
|
||||||
#include <furi_hal_version.h>
|
#include <furi_hal_version.h>
|
||||||
#include <furi_hal_rtc.h>
|
#include <furi_hal_rtc.h>
|
||||||
#include <furi_hal_spi.h>
|
#include <furi_hal_spi.h>
|
||||||
@@ -390,7 +390,8 @@ uint8_t furi_hal_subghz_get_lqi() {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
Modified by @tkerby & MX to the full YARD Stick One extended range of 281-361 MHz, 378-481 MHz, and 749-962 MHz.
|
Modified by @tkerby & MX to the full YARD Stick One extended range of 281-361 MHz, 378-481 MHz, and 749-962 MHz.
|
||||||
These changes are at your own risk. The PLL may not lock and FZ devs have warned of possible damage!
|
These changes are at your own risk. The PLL may not lock and FZ devs have warned of possible damage
|
||||||
|
Set flag use_ext_range_at_own_risk in extend_range.txt to use
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool furi_hal_subghz_is_frequency_valid(uint32_t value) {
|
bool furi_hal_subghz_is_frequency_valid(uint32_t value) {
|
||||||
@@ -420,29 +421,69 @@ uint32_t furi_hal_subghz_set_frequency_and_path(uint32_t value) {
|
|||||||
|
|
||||||
bool furi_hal_subghz_is_tx_allowed(uint32_t value) {
|
bool furi_hal_subghz_is_tx_allowed(uint32_t value) {
|
||||||
bool is_extended = false;
|
bool is_extended = false;
|
||||||
|
bool is_allowed = false;
|
||||||
|
|
||||||
// TODO: !!! Move file check to another place
|
// TODO: !!! Move file check to another place
|
||||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||||
FlipperFormat* fff_data_file = flipper_format_file_alloc(storage);
|
FlipperFormat* fff_data_file = flipper_format_file_alloc(storage);
|
||||||
|
|
||||||
if(flipper_format_file_open_existing(fff_data_file, "/ext/subghz/assets/dangerous_settings")) {
|
if(flipper_format_file_open_existing(fff_data_file, "/ext/subghz/assets/extend_range.txt")) {
|
||||||
flipper_format_read_bool(
|
flipper_format_read_bool(fff_data_file, "use_ext_range_at_own_risk", &is_extended, 1);
|
||||||
fff_data_file, "yes_i_want_to_destroy_my_flipper", &is_extended, 1);
|
flipper_format_read_bool(fff_data_file, "ignore_default_tx_region", &is_allowed, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
flipper_format_free(fff_data_file);
|
flipper_format_free(fff_data_file);
|
||||||
furi_record_close(RECORD_STORAGE);
|
furi_record_close(RECORD_STORAGE);
|
||||||
|
|
||||||
if(!(value >= 299999755 && value <= 350000335) &&
|
switch(furi_hal_version_get_hw_region()) {
|
||||||
|
case FuriHalVersionRegionEuRu:
|
||||||
|
//433,05..434,79; 868,15..868,55
|
||||||
|
if(!(value >= 433050000 && value <= 434790000) &&
|
||||||
|
!(value >= 868150000 && value <= 868550000)) {
|
||||||
|
} else {
|
||||||
|
is_allowed = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case FuriHalVersionRegionUsCaAu:
|
||||||
|
//304,10..321,95; 433,05..434,79; 915,00..928,00
|
||||||
|
if(!(value >= 304100000 && value <= 321950000) &&
|
||||||
|
!(value >= 433050000 && value <= 434790000) &&
|
||||||
|
!(value >= 915000000 && value <= 928000000)) {
|
||||||
|
} else {
|
||||||
|
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
||||||
|
if(value <= 321950000 &&
|
||||||
|
((furi_hal_subghz.preset == FuriHalSubGhzPresetOok270Async) ||
|
||||||
|
(furi_hal_subghz.preset == FuriHalSubGhzPresetOok650Async))) {
|
||||||
|
furi_hal_subghz_load_patable(furi_hal_subghz_preset_ook_async_patable_au);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
is_allowed = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case FuriHalVersionRegionJp:
|
||||||
|
//312,00..315,25; 920,50..923,50
|
||||||
|
if(!(value >= 312000000 && value <= 315250000) &&
|
||||||
|
!(value >= 920500000 && value <= 923500000)) {
|
||||||
|
} else {
|
||||||
|
is_allowed = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
is_allowed = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// No flag - test original range, flag set, test extended range
|
||||||
|
if(!(value >= 299999755 && value <= 348000335) &&
|
||||||
!(value >= 386999938 && value <= 464000000) &&
|
!(value >= 386999938 && value <= 464000000) &&
|
||||||
!(value >= 778999847 && value <= 928000000) && !(is_extended)) {
|
!(value >= 778999847 && value <= 928000000) && !(is_extended)) {
|
||||||
FURI_LOG_I(TAG, "Frequency blocked - outside default range");
|
FURI_LOG_I(TAG, "Frequency blocked - outside regional range");
|
||||||
return false;
|
return false;
|
||||||
} else if(
|
} else if(
|
||||||
!(value >= 281000000 && value <= 361000000) &&
|
!(value >= 281000000 && value <= 361000000) &&
|
||||||
!(value >= 378000000 && value <= 481000000) &&
|
!(value >= 378000000 && value <= 481000000) &&
|
||||||
!(value >= 749000000 && value <= 962000000) && is_extended) {
|
!(value >= 749000000 && value <= 962000000) && is_extended) {
|
||||||
FURI_LOG_I(TAG, "Frequency blocked - outside dangerous range");
|
FURI_LOG_I(TAG, "Frequency blocked - outside extended range");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -450,8 +491,11 @@ bool furi_hal_subghz_is_tx_allowed(uint32_t value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t furi_hal_subghz_set_frequency(uint32_t value) {
|
uint32_t furi_hal_subghz_set_frequency(uint32_t value) {
|
||||||
furi_hal_subghz.regulation = SubGhzRegulationTxRx;
|
if(furi_hal_region_is_frequency_allowed(value)) {
|
||||||
|
furi_hal_subghz.regulation = SubGhzRegulationTxRx;
|
||||||
|
} else {
|
||||||
|
furi_hal_subghz.regulation = SubGhzRegulationTxRx;
|
||||||
|
}
|
||||||
furi_hal_spi_acquire(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_acquire(furi_hal_subghz.spi_bus_handle);
|
||||||
uint32_t real_frequency = cc1101_set_frequency(furi_hal_subghz.spi_bus_handle, value);
|
uint32_t real_frequency = cc1101_set_frequency(furi_hal_subghz.spi_bus_handle, value);
|
||||||
cc1101_calibrate(furi_hal_subghz.spi_bus_handle);
|
cc1101_calibrate(furi_hal_subghz.spi_bus_handle);
|
||||||
|
|||||||
@@ -273,6 +273,16 @@ static const uint8_t furi_hal_subghz_preset_ook_async_patable[8] = {
|
|||||||
0x00,
|
0x00,
|
||||||
0x00};
|
0x00};
|
||||||
|
|
||||||
|
static const uint8_t furi_hal_subghz_preset_ook_async_patable_au[8] = {
|
||||||
|
0x00,
|
||||||
|
0x37, // 12dBm 0xC0, 10dBm 0xC5, 7dBm 0xCD, 5dBm 0x86, 0dBm 0x50, -6dBm 0x37, -10dBm 0x26, -15dBm 0x1D, -20dBm 0x17, -30dBm 0x03
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00};
|
||||||
|
|
||||||
static const uint8_t furi_hal_subghz_preset_2fsk_async_patable[8] = {
|
static const uint8_t furi_hal_subghz_preset_2fsk_async_patable[8] = {
|
||||||
0xC0, // 10dBm 0xC0, 7dBm 0xC8, 5dBm 0x84, 0dBm 0x60, -10dBm 0x34, -15dBm 0x1D, -20dBm 0x0E, -30dBm 0x12
|
0xC0, // 10dBm 0xC0, 7dBm 0xC8, 5dBm 0x84, 0dBm 0x60, -10dBm 0x34, -15dBm 0x1D, -20dBm 0x0E, -30dBm 0x12
|
||||||
0x00,
|
0x00,
|
||||||
|
|||||||
Reference in New Issue
Block a user