mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-12-22 02:33:10 +00:00
d2ca67d261
* SubGhz: add SubGhzThresholdRssi * SubGhz: remove direct reading of subghz-txrx-txrx_state * SubGhz: remove direct reading subghz->txrx->hopper_state * SubGhz: remove direct reading subghz->lock * SubGhz: check load type file * SubGhz: remove direct reading subghz->txrx->rx_key_state * SubGhz: remove direct reading subghz->txrx->speaker_state * SubGhz: refactoring subghz_scene_set_type.c * SubGhz: moving "txrx" entity to a separate file * SubGhz: show error tx start * SubGhz: refactoring RPC * SubGhz: value get optimizations * SubGhz: fix name file * SubGhz: add function description * SubGhz: fix double back with a blocked transmission in this region and speacker, when a transmission is blocked in this region * SubGhz: correct spelling * SubGhz: better naming * SubGhz: simplify includes Co-authored-by: SG <who.just.the.doctor@gmail.com> Co-authored-by: あく <alleteam@gmail.com>
118 lines
No EOL
3.5 KiB
C
118 lines
No EOL
3.5 KiB
C
#include "environment.h"
|
|
#include "registry.h"
|
|
|
|
struct SubGhzEnvironment {
|
|
SubGhzKeystore* keystore;
|
|
const SubGhzProtocolRegistry* protocol_registry;
|
|
const char* came_atomo_rainbow_table_file_name;
|
|
const char* nice_flor_s_rainbow_table_file_name;
|
|
const char* alutech_at_4n_rainbow_table_file_name;
|
|
};
|
|
|
|
SubGhzEnvironment* subghz_environment_alloc() {
|
|
SubGhzEnvironment* instance = malloc(sizeof(SubGhzEnvironment));
|
|
|
|
instance->keystore = subghz_keystore_alloc();
|
|
instance->protocol_registry = NULL;
|
|
instance->came_atomo_rainbow_table_file_name = NULL;
|
|
instance->nice_flor_s_rainbow_table_file_name = NULL;
|
|
instance->alutech_at_4n_rainbow_table_file_name = NULL;
|
|
|
|
return instance;
|
|
}
|
|
|
|
void subghz_environment_free(SubGhzEnvironment* instance) {
|
|
furi_assert(instance);
|
|
|
|
instance->protocol_registry = NULL;
|
|
instance->came_atomo_rainbow_table_file_name = NULL;
|
|
instance->nice_flor_s_rainbow_table_file_name = NULL;
|
|
instance->alutech_at_4n_rainbow_table_file_name = NULL;
|
|
subghz_keystore_free(instance->keystore);
|
|
|
|
free(instance);
|
|
}
|
|
|
|
bool subghz_environment_load_keystore(SubGhzEnvironment* instance, const char* filename) {
|
|
furi_assert(instance);
|
|
|
|
return subghz_keystore_load(instance->keystore, filename);
|
|
}
|
|
|
|
SubGhzKeystore* subghz_environment_get_keystore(SubGhzEnvironment* instance) {
|
|
furi_assert(instance);
|
|
|
|
return instance->keystore;
|
|
}
|
|
|
|
void subghz_environment_set_came_atomo_rainbow_table_file_name(
|
|
SubGhzEnvironment* instance,
|
|
const char* filename) {
|
|
furi_assert(instance);
|
|
|
|
instance->came_atomo_rainbow_table_file_name = filename;
|
|
}
|
|
|
|
const char*
|
|
subghz_environment_get_came_atomo_rainbow_table_file_name(SubGhzEnvironment* instance) {
|
|
furi_assert(instance);
|
|
|
|
return instance->came_atomo_rainbow_table_file_name;
|
|
}
|
|
|
|
void subghz_environment_set_alutech_at_4n_rainbow_table_file_name(
|
|
SubGhzEnvironment* instance,
|
|
const char* filename) {
|
|
furi_assert(instance);
|
|
|
|
instance->alutech_at_4n_rainbow_table_file_name = filename;
|
|
}
|
|
|
|
const char*
|
|
subghz_environment_get_alutech_at_4n_rainbow_table_file_name(SubGhzEnvironment* instance) {
|
|
furi_assert(instance);
|
|
|
|
return instance->alutech_at_4n_rainbow_table_file_name;
|
|
}
|
|
|
|
void subghz_environment_set_nice_flor_s_rainbow_table_file_name(
|
|
SubGhzEnvironment* instance,
|
|
const char* filename) {
|
|
furi_assert(instance);
|
|
|
|
instance->nice_flor_s_rainbow_table_file_name = filename;
|
|
}
|
|
|
|
const char*
|
|
subghz_environment_get_nice_flor_s_rainbow_table_file_name(SubGhzEnvironment* instance) {
|
|
furi_assert(instance);
|
|
|
|
return instance->nice_flor_s_rainbow_table_file_name;
|
|
}
|
|
|
|
void subghz_environment_set_protocol_registry(
|
|
SubGhzEnvironment* instance,
|
|
void* protocol_registry_items) {
|
|
furi_assert(instance);
|
|
const SubGhzProtocolRegistry* protocol_registry = protocol_registry_items;
|
|
instance->protocol_registry = protocol_registry;
|
|
}
|
|
|
|
void* subghz_environment_get_protocol_registry(SubGhzEnvironment* instance) {
|
|
furi_assert(instance);
|
|
furi_assert(instance->protocol_registry);
|
|
return (void*)instance->protocol_registry;
|
|
}
|
|
|
|
const char*
|
|
subghz_environment_get_protocol_name_registry(SubGhzEnvironment* instance, size_t idx) {
|
|
furi_assert(instance);
|
|
furi_assert(instance->protocol_registry);
|
|
const SubGhzProtocol* protocol =
|
|
subghz_protocol_registry_get_by_index(instance->protocol_registry, idx);
|
|
if(protocol != NULL) {
|
|
return protocol->name;
|
|
} else {
|
|
return NULL;
|
|
}
|
|
} |