Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SubGhz: support 310 MHz and fix #1262

Merged
merged 14 commits into from
May 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion applications/storage/storage_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ static void storage_cli_factory_reset(Cli* cli, string_t args, void* context) {
void storage_on_system_start() {
#ifdef SRV_CLI
Cli* cli = furi_record_open("cli");
cli_add_command(cli, "storage", CliCommandFlagDefault, storage_cli, NULL);
cli_add_command(cli, "storage", CliCommandFlagParallelSafe, storage_cli, NULL);
cli_add_command(
cli, "factory_reset", CliCommandFlagParallelSafe, storage_cli_factory_reset, NULL);
furi_record_close("cli");
Expand Down
19 changes: 10 additions & 9 deletions applications/subghz/helpers/subghz_frequency_analyzer_worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

#include <furi.h>

#include "../subghz_i.h"

#define TAG "SubghzFrequencyAnalyzerWorker"

#define SUBGHZ_FREQUENCY_ANALYZER_THRESHOLD -95.0f
Expand Down Expand Up @@ -82,7 +80,7 @@ static int32_t subghz_frequency_analyzer_worker_thread(void* context) {
cc1101_flush_tx(&furi_hal_spi_bus_handle_subghz);
cc1101_write_reg(&furi_hal_spi_bus_handle_subghz, CC1101_IOCFG0, CC1101IocfgHW);
cc1101_write_reg(&furi_hal_spi_bus_handle_subghz, CC1101_MDMCFG3,
0b11111111); // symbol rate
0b01111111); // symbol rate
cc1101_write_reg(
&furi_hal_spi_bus_handle_subghz,
CC1101_AGCCTRL2,
Expand Down Expand Up @@ -130,7 +128,7 @@ static int32_t subghz_frequency_analyzer_worker_thread(void* context) {
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);

// delay will be in range between 1 and 2ms
osDelay(2);
osDelay(3);

rssi = furi_hal_subghz_get_rssi();

Expand Down Expand Up @@ -179,9 +177,12 @@ static int32_t subghz_frequency_analyzer_worker_thread(void* context) {
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);

// delay will be in range between 1 and 2ms
osDelay(2);
osDelay(3);

rssi = furi_hal_subghz_get_rssi();

FURI_LOG_T(TAG, "#:%u:%f", frequency, (double)rssi);

if(frequency_rssi.rssi < rssi) {
frequency_rssi.rssi = rssi;
frequency_rssi.frequency = frequency;
Expand Down Expand Up @@ -222,7 +223,8 @@ static int32_t subghz_frequency_analyzer_worker_thread(void* context) {
return 0;
}

SubGhzFrequencyAnalyzerWorker* subghz_frequency_analyzer_worker_alloc() {
SubGhzFrequencyAnalyzerWorker* subghz_frequency_analyzer_worker_alloc(void* context) {
furi_assert(context);
SubGhzFrequencyAnalyzerWorker* instance = malloc(sizeof(SubGhzFrequencyAnalyzerWorker));

instance->thread = furi_thread_alloc();
Expand All @@ -231,16 +233,15 @@ SubGhzFrequencyAnalyzerWorker* subghz_frequency_analyzer_worker_alloc() {
furi_thread_set_context(instance->thread, instance);
furi_thread_set_callback(instance->thread, subghz_frequency_analyzer_worker_thread);

instance->setting = subghz_setting_alloc();
subghz_setting_load(instance->setting, "/ext/subghz/assets/setting_frequency_analyzer_user");
SubGhz* subghz = context;
instance->setting = subghz->setting;
return instance;
}

void subghz_frequency_analyzer_worker_free(SubGhzFrequencyAnalyzerWorker* instance) {
furi_assert(instance);

furi_thread_free(instance->thread);
subghz_setting_free(instance->setting);
free(instance);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <furi_hal.h>
#include "../subghz_i.h"

typedef struct SubGhzFrequencyAnalyzerWorker SubGhzFrequencyAnalyzerWorker;

Expand All @@ -14,9 +15,10 @@ typedef struct {

/** Allocate SubGhzFrequencyAnalyzerWorker
*
* @param context SubGhz* context
* @return SubGhzFrequencyAnalyzerWorker*
*/
SubGhzFrequencyAnalyzerWorker* subghz_frequency_analyzer_worker_alloc();
SubGhzFrequencyAnalyzerWorker* subghz_frequency_analyzer_worker_alloc(void* context);

/** Free SubGhzFrequencyAnalyzerWorker
*
Expand Down
3 changes: 2 additions & 1 deletion applications/subghz/helpers/subghz_testing.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const uint32_t subghz_frequencies_testing[] = {
/* 300 - 348 */
300000000,
304500000,
310000000,
312025000,
313250000,
313625000,
Expand Down Expand Up @@ -34,4 +35,4 @@ const uint32_t subghz_frequencies_testing[] = {

const uint32_t subghz_frequencies_count_testing =
sizeof(subghz_frequencies_testing) / sizeof(uint32_t);
const uint32_t subghz_frequencies_433_92_testing = 12;
const uint32_t subghz_frequencies_433_92_testing = 13;
4 changes: 4 additions & 0 deletions applications/subghz/scenes/subghz_scene_read_raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {

case SubGhzCustomEventViewReadRAWErase:
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
if(subghz_scene_read_raw_update_filename(subghz)) {
string_set(subghz->file_path_tmp, subghz->file_path);
subghz_delete_file(subghz);
}
notification_message(subghz->notifications, &sequence_reset_rgb);
return true;
break;
Expand Down
Loading