From f33ea3ebe08f51a7520af0764ad99ddfe7de6a3c Mon Sep 17 00:00:00 2001 From: Aleksandr Kutuzov Date: Wed, 19 Oct 2022 01:48:44 +0900 Subject: [PATCH] SubGhz: partial unit tests fix --- applications/debug/unit_tests/subghz/subghz_test.c | 2 ++ .../plugins/weather_station/helpers/weather_station_types.h | 1 - applications/plugins/weather_station/protocols/thermopro_tx4.c | 3 +-- lib/subghz/environment.c | 2 ++ 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/applications/debug/unit_tests/subghz/subghz_test.c b/applications/debug/unit_tests/subghz/subghz_test.c index fbc277a74..2dbf2eeda 100644 --- a/applications/debug/unit_tests/subghz/subghz_test.c +++ b/applications/debug/unit_tests/subghz/subghz_test.c @@ -43,6 +43,8 @@ static void subghz_test_init(void) { environment_handler, CAME_ATOMO_DIR_NAME); subghz_environment_set_nice_flor_s_rainbow_table_file_name( environment_handler, NICE_FLOR_S_DIR_NAME); + subghz_environment_set_protocol_registry( + environment_handler, (void*)&subghz_protocol_registry); receiver_handler = subghz_receiver_alloc_init(environment_handler); subghz_receiver_set_filter(receiver_handler, SubGhzProtocolFlag_Decodable); diff --git a/applications/plugins/weather_station/helpers/weather_station_types.h b/applications/plugins/weather_station/helpers/weather_station_types.h index 49b722139..a6905e828 100644 --- a/applications/plugins/weather_station/helpers/weather_station_types.h +++ b/applications/plugins/weather_station/helpers/weather_station_types.h @@ -3,7 +3,6 @@ #include #include - #define WS_VERSION_APP "0.1" #define WS_DEVELOPED "SkorP" #define WS_GITHUB "https://github.com/flipperdevices/flipperzero-firmware" diff --git a/applications/plugins/weather_station/protocols/thermopro_tx4.c b/applications/plugins/weather_station/protocols/thermopro_tx4.c index 617f7374c..29ccdbea2 100644 --- a/applications/plugins/weather_station/protocols/thermopro_tx4.c +++ b/applications/plugins/weather_station/protocols/thermopro_tx4.c @@ -120,7 +120,6 @@ static bool ws_protocol_thermopro_tx4_check(WSProtocolDecoderThermoPRO_TX4* inst * @param instance Pointer to a WSBlockGeneric* instance */ static void ws_protocol_thermopro_tx4_remote_controller(WSBlockGeneric* instance) { - instance->id = (instance->data >> 25) & 0xFF; instance->battery_low = (instance->data >> 24) & 1; instance->btn = (instance->data >> 23) & 1; @@ -129,7 +128,7 @@ static void ws_protocol_thermopro_tx4_remote_controller(WSBlockGeneric* instance if(!((instance->data >> 20) & 1)) { instance->temp = (float)((instance->data >> 9) & 0x07FF) / 10.0f; } else { - instance->temp = (float)((~(instance->data >> 9) & 0x07FF)+1) / -10.0f; + instance->temp = (float)((~(instance->data >> 9) & 0x07FF) + 1) / -10.0f; } instance->humidity = (instance->data >> 1) & 0xFF; diff --git a/lib/subghz/environment.c b/lib/subghz/environment.c index 7791891ad..0a4b7b606 100644 --- a/lib/subghz/environment.c +++ b/lib/subghz/environment.c @@ -88,6 +88,8 @@ void* subghz_environment_get_protocol_registry(SubGhzEnvironment* instance) { 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) {