unleashed-firmware/lib/subghz/environment.c
Skorpionm 9a9abd59e9
[FL-2904, FL-2900, FL-2890] WS: add app WeatherStation (#1833)
* WeatherStation: start
* SubGhz: rename protocol magellen -> magellan
* WeatherStation: err Unresolved symbols: {'subghz_protocol_decoder_base_get_string'}
* WeatherStation: fix Unresolved symbols: {'subghz_protocol_decoder_base_get_string'}
* Subghz: add set protocol_items
* WeatherStation: adding your protocols
* WS: add Infactory protocol
* WS: add history
* WS: add setting
* WS: add lock
* WS: add hopper frequency
* WS: fix history
* WS fix string_t -> FuriString*
* WS: add images
* WS: history record update when receiving data from the sensor again
* WS: add receiver info, delete extra code
* WS: add protocol ThermoPRO_TX4
* [FL-2900] SubGhz: Move icons in Sub-GHz
* WS: add Notification
* [FL-2890] SubGhz: Rename *_user files in resources to _user.example
* WS: add about scene
* WS: removing redundant code
* WS: add  protocol Nexus-TH
* WS: add protocol GT_WT03
* WS: fix notification and rename "Weather Station" -> "Read Weather Station"
* SubGhz: partial unit tests fix
* SubGhz: fix unit_test
* SubGhz: remove dead code
* SubGhz: rename SubGhzPresetDefinition into SubGhzRadioPreset, cleanup subghz types.

Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2022-10-20 02:27:26 +09:00

100 lines
No EOL
2.9 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;
};
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;
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;
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;
}
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;
}
}