2022-03-03 09:48:56 +00:00
|
|
|
#include "environment.h"
|
2022-10-19 17:27:26 +00:00
|
|
|
#include "registry.h"
|
2022-03-03 09:48:56 +00:00
|
|
|
|
|
|
|
struct SubGhzEnvironment {
|
|
|
|
SubGhzKeystore* keystore;
|
2022-10-19 17:27:26 +00:00
|
|
|
const SubGhzProtocolRegistry* protocol_registry;
|
2022-03-03 09:48:56 +00:00
|
|
|
const char* nice_flor_s_rainbow_table_file_name;
|
2023-02-08 16:59:49 +00:00
|
|
|
const char* alutech_at_4n_rainbow_table_file_name;
|
2023-05-19 22:15:36 +00:00
|
|
|
const char* mfname;
|
|
|
|
uint8_t kl_type;
|
2022-03-03 09:48:56 +00:00
|
|
|
};
|
|
|
|
|
2024-03-25 10:53:32 +00:00
|
|
|
SubGhzEnvironment* subghz_environment_alloc(void) {
|
2022-03-03 09:48:56 +00:00
|
|
|
SubGhzEnvironment* instance = malloc(sizeof(SubGhzEnvironment));
|
|
|
|
|
|
|
|
instance->keystore = subghz_keystore_alloc();
|
2022-10-19 17:27:26 +00:00
|
|
|
instance->protocol_registry = NULL;
|
2022-03-03 09:48:56 +00:00
|
|
|
instance->nice_flor_s_rainbow_table_file_name = NULL;
|
2023-04-09 23:55:16 +00:00
|
|
|
instance->alutech_at_4n_rainbow_table_file_name = NULL;
|
2023-05-19 22:15:36 +00:00
|
|
|
instance->mfname = "";
|
|
|
|
instance->kl_type = 0;
|
2022-03-03 09:48:56 +00:00
|
|
|
|
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
void subghz_environment_free(SubGhzEnvironment* instance) {
|
2024-03-25 10:53:32 +00:00
|
|
|
furi_check(instance);
|
2022-03-03 09:48:56 +00:00
|
|
|
|
2022-10-19 17:27:26 +00:00
|
|
|
instance->protocol_registry = NULL;
|
|
|
|
instance->nice_flor_s_rainbow_table_file_name = NULL;
|
2023-04-09 23:55:16 +00:00
|
|
|
instance->alutech_at_4n_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) {
|
2024-03-25 10:53:32 +00:00
|
|
|
furi_check(instance);
|
2022-03-03 09:48:56 +00:00
|
|
|
|
|
|
|
return subghz_keystore_load(instance->keystore, filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
SubGhzKeystore* subghz_environment_get_keystore(SubGhzEnvironment* instance) {
|
2024-03-25 10:53:32 +00:00
|
|
|
furi_check(instance);
|
2022-03-03 09:48:56 +00:00
|
|
|
|
|
|
|
return instance->keystore;
|
|
|
|
}
|
|
|
|
|
|
|
|
void subghz_environment_set_came_atomo_rainbow_table_file_name(
|
|
|
|
SubGhzEnvironment* instance,
|
|
|
|
const char* filename) {
|
2023-09-05 02:59:21 +00:00
|
|
|
UNUSED(instance);
|
|
|
|
UNUSED(filename);
|
2023-09-05 02:51:21 +00:00
|
|
|
// Do nothing :)
|
|
|
|
return;
|
2022-03-03 09:48:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const char*
|
|
|
|
subghz_environment_get_came_atomo_rainbow_table_file_name(SubGhzEnvironment* instance) {
|
2023-09-05 02:59:21 +00:00
|
|
|
UNUSED(instance);
|
2023-09-05 02:51:21 +00:00
|
|
|
// No table, sorry
|
|
|
|
return "";
|
2022-03-03 09:48:56 +00:00
|
|
|
}
|
|
|
|
|
2023-02-08 16:59:49 +00:00
|
|
|
void subghz_environment_set_alutech_at_4n_rainbow_table_file_name(
|
|
|
|
SubGhzEnvironment* instance,
|
|
|
|
const char* filename) {
|
2024-03-25 10:53:32 +00:00
|
|
|
furi_check(instance);
|
2023-02-08 16:59:49 +00:00
|
|
|
|
|
|
|
instance->alutech_at_4n_rainbow_table_file_name = filename;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char*
|
|
|
|
subghz_environment_get_alutech_at_4n_rainbow_table_file_name(SubGhzEnvironment* instance) {
|
2024-03-25 10:53:32 +00:00
|
|
|
furi_check(instance);
|
2023-02-08 16:59:49 +00:00
|
|
|
|
|
|
|
return instance->alutech_at_4n_rainbow_table_file_name;
|
|
|
|
}
|
|
|
|
|
2022-03-03 09:48:56 +00:00
|
|
|
void subghz_environment_set_nice_flor_s_rainbow_table_file_name(
|
|
|
|
SubGhzEnvironment* instance,
|
|
|
|
const char* filename) {
|
2024-03-25 10:53:32 +00:00
|
|
|
furi_check(instance);
|
2022-03-03 09:48:56 +00:00
|
|
|
|
|
|
|
instance->nice_flor_s_rainbow_table_file_name = filename;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char*
|
|
|
|
subghz_environment_get_nice_flor_s_rainbow_table_file_name(SubGhzEnvironment* instance) {
|
2024-03-25 10:53:32 +00:00
|
|
|
furi_check(instance);
|
2022-03-03 09:48:56 +00:00
|
|
|
|
|
|
|
return instance->nice_flor_s_rainbow_table_file_name;
|
|
|
|
}
|
2022-10-19 17:27:26 +00:00
|
|
|
|
|
|
|
void subghz_environment_set_protocol_registry(
|
|
|
|
SubGhzEnvironment* instance,
|
2023-06-06 19:13:41 +00:00
|
|
|
const SubGhzProtocolRegistry* protocol_registry_items) {
|
2024-03-25 10:53:32 +00:00
|
|
|
furi_check(instance);
|
2022-10-19 17:27:26 +00:00
|
|
|
const SubGhzProtocolRegistry* protocol_registry = protocol_registry_items;
|
|
|
|
instance->protocol_registry = protocol_registry;
|
|
|
|
}
|
|
|
|
|
2023-06-06 19:13:41 +00:00
|
|
|
const SubGhzProtocolRegistry*
|
|
|
|
subghz_environment_get_protocol_registry(SubGhzEnvironment* instance) {
|
2024-03-25 10:53:32 +00:00
|
|
|
furi_check(instance);
|
|
|
|
furi_check(instance->protocol_registry);
|
2023-06-06 19:13:41 +00:00
|
|
|
return instance->protocol_registry;
|
2022-10-19 17:27:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const char*
|
|
|
|
subghz_environment_get_protocol_name_registry(SubGhzEnvironment* instance, size_t idx) {
|
2024-03-25 10:53:32 +00:00
|
|
|
furi_check(instance);
|
|
|
|
furi_check(instance->protocol_registry);
|
2022-10-19 17:27:26 +00:00
|
|
|
const SubGhzProtocol* protocol =
|
|
|
|
subghz_protocol_registry_get_by_index(instance->protocol_registry, idx);
|
|
|
|
if(protocol != NULL) {
|
|
|
|
return protocol->name;
|
|
|
|
} else {
|
|
|
|
return NULL;
|
|
|
|
}
|
2023-05-19 22:15:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void subghz_environment_reset_keeloq(SubGhzEnvironment* instance) {
|
|
|
|
furi_assert(instance);
|
|
|
|
|
2023-05-20 13:15:01 +00:00
|
|
|
subghz_keystore_reset_kl(instance->keystore);
|
2023-05-19 22:15:36 +00:00
|
|
|
}
|