2022-03-03 09:48:56 +00:00
|
|
|
#include "environment.h"
|
2022-10-18 16:51:44 +00:00
|
|
|
#include "registry.h"
|
2022-03-03 09:48:56 +00:00
|
|
|
|
|
|
|
struct SubGhzEnvironment {
|
|
|
|
SubGhzKeystore* keystore;
|
2022-10-18 16:51:44 +00:00
|
|
|
const SubGhzProtocolRegistry* protocol_registry;
|
2022-03-03 09:48:56 +00:00
|
|
|
const char* came_atomo_rainbow_table_file_name;
|
|
|
|
const char* nice_flor_s_rainbow_table_file_name;
|
|
|
|
};
|
|
|
|
|
|
|
|
SubGhzEnvironment* subghz_environment_alloc() {
|
|
|
|
SubGhzEnvironment* instance = malloc(sizeof(SubGhzEnvironment));
|
|
|
|
|
|
|
|
instance->keystore = subghz_keystore_alloc();
|
2022-10-18 16:51:44 +00:00
|
|
|
instance->protocol_registry = NULL;
|
2022-03-03 09:48:56 +00:00
|
|
|
instance->came_atomo_rainbow_table_file_name = NULL;
|
|
|
|
instance->nice_flor_s_rainbow_table_file_name = NULL;
|
|
|
|
|
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
void subghz_environment_free(SubGhzEnvironment* instance) {
|
|
|
|
furi_assert(instance);
|
|
|
|
|
2022-10-18 16:51:44 +00:00
|
|
|
instance->protocol_registry = NULL;
|
2022-10-05 18:27:13 +00:00
|
|
|
instance->came_atomo_rainbow_table_file_name = NULL;
|
|
|
|
instance->nice_flor_s_rainbow_table_file_name = NULL;
|
2022-03-03 09:48:56 +00:00
|
|
|
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_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;
|
|
|
|
}
|
2022-10-18 16:51:44 +00:00
|
|
|
|
|
|
|
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) {
|
|
|
|
const SubGhzProtocol* protocol =
|
|
|
|
subghz_protocol_registry_get_by_index(instance->protocol_registry, idx);
|
|
|
|
if(protocol != NULL) {
|
|
|
|
return protocol->name;
|
|
|
|
} else {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|