From 21e5b66bf61e51e3b7ff2cfbab5a252d0ba225b6 Mon Sep 17 00:00:00 2001 From: LY2NEO Date: Sat, 3 Dec 2022 22:55:35 +0200 Subject: [PATCH 1/6] Improved plugin WS data dashbord, added data age counter. When data is read it saves datastamp and calculetes diference between actual time and data read time. Until one minute it counts age in seconds. After one minute it starts blink and counts age per minute. Tested with auriol_hg0601a.c protocol. --- .../protocols/acurite_592txr.c | 7 +++ .../weather_station/protocols/acurite_606tx.c | 7 +++ .../protocols/acurite_609txc.c | 7 +++ .../protocols/ambient_weather.c | 7 +++ .../protocols/auriol_hg0601a.c | 10 +++++ .../weather_station/protocols/gt_wt_02.c | 6 +++ .../weather_station/protocols/gt_wt_03.c | 7 +++ .../weather_station/protocols/infactory.c | 7 +++ .../protocols/lacrosse_tx141thbv2.c | 7 +++ .../weather_station/protocols/nexus_th.c | 7 +++ .../weather_station/protocols/thermopro_tx4.c | 7 +++ .../weather_station/protocols/ws_generic.c | 18 ++++++-- .../weather_station/protocols/ws_generic.h | 1 + .../views/weather_station_receiver_info.c | 43 +++++++++++++++++++ 14 files changed, 138 insertions(+), 3 deletions(-) diff --git a/applications/plugins/weather_station/protocols/acurite_592txr.c b/applications/plugins/weather_station/protocols/acurite_592txr.c index 5384a3c91..087ce1b52 100644 --- a/applications/plugins/weather_station/protocols/acurite_592txr.c +++ b/applications/plugins/weather_station/protocols/acurite_592txr.c @@ -144,6 +144,13 @@ static void ws_protocol_acurite_592txr_remote_controller(WSBlockGeneric* instanc instance->temp = ((float)(temp_raw)-1000) / 10.0f; instance->btn = WS_NO_BTN; + + //DATE AGE set + FuriHalRtcDateTime curr_dt; + furi_hal_rtc_get_datetime(&curr_dt); + uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt); + + instance->agedata = curr_ts; } void ws_protocol_decoder_acurite_592txr_feed(void* context, bool level, uint32_t duration) { diff --git a/applications/plugins/weather_station/protocols/acurite_606tx.c b/applications/plugins/weather_station/protocols/acurite_606tx.c index 4cb5d18b8..8dfbe1363 100644 --- a/applications/plugins/weather_station/protocols/acurite_606tx.c +++ b/applications/plugins/weather_station/protocols/acurite_606tx.c @@ -123,6 +123,13 @@ static void ws_protocol_acurite_606tx_remote_controller(WSBlockGeneric* instance } instance->btn = WS_NO_BTN; instance->humidity = WS_NO_HUMIDITY; + + //DATE AGE set + FuriHalRtcDateTime curr_dt; + furi_hal_rtc_get_datetime(&curr_dt); + uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt); + + instance->agedata = curr_ts; } void ws_protocol_decoder_acurite_606tx_feed(void* context, bool level, uint32_t duration) { diff --git a/applications/plugins/weather_station/protocols/acurite_609txc.c b/applications/plugins/weather_station/protocols/acurite_609txc.c index aeb0785eb..89a168100 100644 --- a/applications/plugins/weather_station/protocols/acurite_609txc.c +++ b/applications/plugins/weather_station/protocols/acurite_609txc.c @@ -123,6 +123,13 @@ static void ws_protocol_acurite_609txc_remote_controller(WSBlockGeneric* instanc instance->temp = (temp_raw >> 4) * 0.1f; instance->humidity = (instance->data >> 8) & 0xff; instance->btn = WS_NO_BTN; + + //DATE AGE set + FuriHalRtcDateTime curr_dt; + furi_hal_rtc_get_datetime(&curr_dt); + uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt); + + instance->agedata = curr_ts; } void ws_protocol_decoder_acurite_609txc_feed(void* context, bool level, uint32_t duration) { diff --git a/applications/plugins/weather_station/protocols/ambient_weather.c b/applications/plugins/weather_station/protocols/ambient_weather.c index 5ae22b790..3f19033ec 100644 --- a/applications/plugins/weather_station/protocols/ambient_weather.c +++ b/applications/plugins/weather_station/protocols/ambient_weather.c @@ -160,6 +160,13 @@ static void ws_protocol_ambient_weather_remote_controller(WSBlockGeneric* instan ERROR; } */ + + //DATE AGE set + FuriHalRtcDateTime curr_dt; + furi_hal_rtc_get_datetime(&curr_dt); + uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt); + + instance->agedata = curr_ts; } void ws_protocol_decoder_ambient_weather_feed(void* context, bool level, uint32_t duration) { diff --git a/applications/plugins/weather_station/protocols/auriol_hg0601a.c b/applications/plugins/weather_station/protocols/auriol_hg0601a.c index d5f89fc8b..252565292 100644 --- a/applications/plugins/weather_station/protocols/auriol_hg0601a.c +++ b/applications/plugins/weather_station/protocols/auriol_hg0601a.c @@ -1,3 +1,6 @@ +#include +#include + #include "auriol_hg0601a.h" #define TAG "WSProtocolAuriol_TH" @@ -133,6 +136,13 @@ static void ws_protocol_auriol_th_remote_controller(WSBlockGeneric* instance) { } instance->humidity = (instance->data >> 1) & 0x7F; + + //DATE AGE set + FuriHalRtcDateTime curr_dt; + furi_hal_rtc_get_datetime(&curr_dt); + uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt); + + instance->agedata = curr_ts; } void ws_protocol_decoder_auriol_th_feed(void* context, bool level, uint32_t duration) { diff --git a/applications/plugins/weather_station/protocols/gt_wt_02.c b/applications/plugins/weather_station/protocols/gt_wt_02.c index cbe119192..5edb1947c 100644 --- a/applications/plugins/weather_station/protocols/gt_wt_02.c +++ b/applications/plugins/weather_station/protocols/gt_wt_02.c @@ -135,6 +135,12 @@ static void ws_protocol_gt_wt_02_remote_controller(WSBlockGeneric* instance) { instance->temp = (float)((~(instance->data >> 13) & 0x07FF) + 1) / -10.0f; } + //DATE AGE set + FuriHalRtcDateTime curr_dt; + furi_hal_rtc_get_datetime(&curr_dt); + uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt); + instance->agedata = curr_ts; + instance->humidity = (instance->data >> 6) & 0x7F; if(instance->humidity <= 10) // actually the sensors sends 10 below working range of 20% instance->humidity = 0; diff --git a/applications/plugins/weather_station/protocols/gt_wt_03.c b/applications/plugins/weather_station/protocols/gt_wt_03.c index 7831cf069..1e601e523 100644 --- a/applications/plugins/weather_station/protocols/gt_wt_03.c +++ b/applications/plugins/weather_station/protocols/gt_wt_03.c @@ -179,6 +179,13 @@ static void ws_protocol_gt_wt_03_remote_controller(WSBlockGeneric* instance) { } else { instance->temp = (float)((~(instance->data >> 9) & 0x07FF) + 1) / -10.0f; } + + //DATE AGE set + FuriHalRtcDateTime curr_dt; + furi_hal_rtc_get_datetime(&curr_dt); + uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt); + + instance->agedata = curr_ts; } void ws_protocol_decoder_gt_wt_03_feed(void* context, bool level, uint32_t duration) { diff --git a/applications/plugins/weather_station/protocols/infactory.c b/applications/plugins/weather_station/protocols/infactory.c index 2d444d981..978b837f2 100644 --- a/applications/plugins/weather_station/protocols/infactory.c +++ b/applications/plugins/weather_station/protocols/infactory.c @@ -148,6 +148,13 @@ static void ws_protocol_infactory_remote_controller(WSBlockGeneric* instance) { instance->humidity = (((instance->data >> 8) & 0x0F) * 10) + ((instance->data >> 4) & 0x0F); // BCD, 'A0'=100%rH instance->channel = instance->data & 0x03; + + //DATE AGE set + FuriHalRtcDateTime curr_dt; + furi_hal_rtc_get_datetime(&curr_dt); + uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt); + + instance->agedata = curr_ts; } void ws_protocol_decoder_infactory_feed(void* context, bool level, uint32_t duration) { diff --git a/applications/plugins/weather_station/protocols/lacrosse_tx141thbv2.c b/applications/plugins/weather_station/protocols/lacrosse_tx141thbv2.c index e4b612250..8837f730b 100644 --- a/applications/plugins/weather_station/protocols/lacrosse_tx141thbv2.c +++ b/applications/plugins/weather_station/protocols/lacrosse_tx141thbv2.c @@ -123,6 +123,13 @@ static void ws_protocol_lacrosse_tx141thbv2_remote_controller(WSBlockGeneric* in instance->channel = ((instance->data >> 29) & 0x03) + 1; instance->temp = ((float)((instance->data >> 17) & 0x0FFF) - 500.0f) / 10.0f; instance->humidity = (instance->data >> 9) & 0xFF; + + //DATE AGE set + FuriHalRtcDateTime curr_dt; + furi_hal_rtc_get_datetime(&curr_dt); + uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt); + + instance->agedata = curr_ts; } void ws_protocol_decoder_lacrosse_tx141thbv2_feed(void* context, bool level, uint32_t duration) { diff --git a/applications/plugins/weather_station/protocols/nexus_th.c b/applications/plugins/weather_station/protocols/nexus_th.c index 7d4a77aea..132e38050 100644 --- a/applications/plugins/weather_station/protocols/nexus_th.c +++ b/applications/plugins/weather_station/protocols/nexus_th.c @@ -135,6 +135,13 @@ static void ws_protocol_nexus_th_remote_controller(WSBlockGeneric* instance) { } instance->humidity = instance->data & 0xFF; + + //DATE AGE set + FuriHalRtcDateTime curr_dt; + furi_hal_rtc_get_datetime(&curr_dt); + uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt); + + instance->agedata = curr_ts; } void ws_protocol_decoder_nexus_th_feed(void* context, bool level, uint32_t duration) { diff --git a/applications/plugins/weather_station/protocols/thermopro_tx4.c b/applications/plugins/weather_station/protocols/thermopro_tx4.c index 0882bc33d..29aaf0b35 100644 --- a/applications/plugins/weather_station/protocols/thermopro_tx4.c +++ b/applications/plugins/weather_station/protocols/thermopro_tx4.c @@ -132,6 +132,13 @@ static void ws_protocol_thermopro_tx4_remote_controller(WSBlockGeneric* instance } instance->humidity = (instance->data >> 1) & 0xFF; + + //DATE AGE set + FuriHalRtcDateTime curr_dt; + furi_hal_rtc_get_datetime(&curr_dt); + uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt); + + instance->agedata = curr_ts; } void ws_protocol_decoder_thermopro_tx4_feed(void* context, bool level, uint32_t duration) { diff --git a/applications/plugins/weather_station/protocols/ws_generic.c b/applications/plugins/weather_station/protocols/ws_generic.c index 174531090..f653a86a1 100644 --- a/applications/plugins/weather_station/protocols/ws_generic.c +++ b/applications/plugins/weather_station/protocols/ws_generic.c @@ -99,6 +99,12 @@ bool ws_block_generic_serialize( break; } + temp_data = instance->agedata; + if(!flipper_format_write_uint32(flipper_format, "Old", &temp_data, 1)) { + FURI_LOG_E(TAG, "Unable to add agedata"); + break; + } + temp_data = instance->channel; if(!flipper_format_write_uint32(flipper_format, "Ch", &temp_data, 1)) { FURI_LOG_E(TAG, "Unable to add Channel"); @@ -168,11 +174,17 @@ bool ws_block_generic_deserialize(WSBlockGeneric* instance, FlipperFormat* flipp } instance->humidity = (uint8_t)temp_data; - if(!flipper_format_read_uint32(flipper_format, "Ch", (uint32_t*)&temp_data, 1)) { - FURI_LOG_E(TAG, "Missing Channel"); + if(!flipper_format_read_uint32(flipper_format, "Old", (uint32_t*)&temp_data, 1)) { + FURI_LOG_E(TAG, "Missing agedata"); break; } - instance->channel = (uint8_t)temp_data; + instance->agedata = (uint32_t)temp_data; + + if(!flipper_format_read_uint32(flipper_format, "Ch", (uint32_t*)&temp_data, 1)) { + FURI_LOG_E(TAG, "Missing Channel"); + break; + } + instance->channel = (uint8_t)temp_data; if(!flipper_format_read_uint32(flipper_format, "Btn", (uint32_t*)&temp_data, 1)) { FURI_LOG_E(TAG, "Missing Btn"); diff --git a/applications/plugins/weather_station/protocols/ws_generic.h b/applications/plugins/weather_station/protocols/ws_generic.h index b2a84df8e..7d0f198d5 100644 --- a/applications/plugins/weather_station/protocols/ws_generic.h +++ b/applications/plugins/weather_station/protocols/ws_generic.h @@ -29,6 +29,7 @@ struct WSBlockGeneric { uint8_t data_count_bit; uint8_t battery_low; uint8_t humidity; + uint32_t agedata; uint8_t channel; uint8_t btn; float temp; diff --git a/applications/plugins/weather_station/views/weather_station_receiver_info.c b/applications/plugins/weather_station/views/weather_station_receiver_info.c index 49b447f10..fb04317c5 100644 --- a/applications/plugins/weather_station/views/weather_station_receiver_info.c +++ b/applications/plugins/weather_station/views/weather_station_receiver_info.c @@ -1,3 +1,5 @@ +#include +#include #include "weather_station_receiver.h" #include "../weather_station_app_i.h" #include "weather_station_icons.h" @@ -70,6 +72,47 @@ void ws_view_receiver_info_draw(Canvas* canvas, WSReceiverInfoModel* model) { snprintf(buffer, sizeof(buffer), "Data: 0x%llX", model->generic->data); canvas_draw_str(canvas, 5, 32, buffer); + //DATA AGE + if((int) model->generic->agedata > 0){ + FuriHalRtcDateTime curr_dt; + furi_hal_rtc_get_datetime(&curr_dt); + uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt); + + int diffold = (int) curr_ts - (int) model->generic->agedata; + + if(diffold>60){ + + int tmp_sec = diffold; + int cnt_min = 1; + for(int i=1; tmp_sec>60; i++){ + tmp_sec = tmp_sec - 60; + cnt_min = i; + } + + if ( curr_ts % 2 == 0){ + canvas_set_color(canvas, ColorBlack); + canvas_draw_rframe(canvas, 97, 23, 26, 11, 1); + canvas_set_color(canvas, ColorBlack); + canvas_draw_str_aligned(canvas, 109, 29, AlignCenter, AlignCenter, "OLD"); + }else{ + canvas_set_color(canvas, ColorBlack); + canvas_draw_rframe(canvas, 97, 23, 26, 11, 1); + canvas_draw_box(canvas, 97, 23, 26, 11); + canvas_set_color(canvas, ColorWhite); + snprintf(buffer, sizeof(buffer), "%dm", cnt_min); + canvas_draw_str_aligned(canvas, 109, 29, AlignCenter, AlignCenter, buffer); + } + + }else{ + canvas_set_color(canvas, ColorBlack); + canvas_draw_rframe(canvas, 97, 23, 26, 11, 1); + canvas_set_color(canvas, ColorBlack); + snprintf(buffer, sizeof(buffer), "%d", diffold); + canvas_draw_str_aligned(canvas, 109, 29, AlignCenter, AlignCenter, buffer); + } + } + //DATA AGE end + elements_bold_rounded_frame(canvas, 2, 37, 123, 25); canvas_set_font(canvas, FontPrimary); From 11576e58c84b4b537876cd6ef3c8bfa512cd5b32 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Sun, 4 Dec 2022 04:22:14 +0300 Subject: [PATCH 2/6] Update subbrute --- applications/plugins/subbrute | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/plugins/subbrute b/applications/plugins/subbrute index 19d5d67a2..f47f826a6 160000 --- a/applications/plugins/subbrute +++ b/applications/plugins/subbrute @@ -1 +1 @@ -Subproject commit 19d5d67a21d2d132b9b97c93295486d29ac195d4 +Subproject commit f47f826a689a94ea1b554743dd87ae0fb836427b From 8d9786f89a302d87976c953cba70934c6163f529 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Sun, 4 Dec 2022 04:38:37 +0300 Subject: [PATCH 3/6] Simplify and fix time display display only OLD when we have more than 59 mins --- .../protocols/acurite_592txr.c | 7 -- .../weather_station/protocols/acurite_606tx.c | 7 -- .../protocols/acurite_609txc.c | 7 -- .../protocols/ambient_weather.c | 7 -- .../protocols/auriol_hg0601a.c | 10 --- .../weather_station/protocols/gt_wt_02.c | 6 -- .../weather_station/protocols/gt_wt_03.c | 7 -- .../weather_station/protocols/infactory.c | 7 -- .../protocols/lacrosse_tx141thbv2.c | 7 -- .../weather_station/protocols/nexus_th.c | 7 -- .../weather_station/protocols/thermopro_tx4.c | 7 -- .../weather_station/protocols/ws_generic.c | 27 +++--- .../views/weather_station_receiver_info.c | 82 ++++++++++--------- 13 files changed, 60 insertions(+), 128 deletions(-) diff --git a/applications/plugins/weather_station/protocols/acurite_592txr.c b/applications/plugins/weather_station/protocols/acurite_592txr.c index 087ce1b52..5384a3c91 100644 --- a/applications/plugins/weather_station/protocols/acurite_592txr.c +++ b/applications/plugins/weather_station/protocols/acurite_592txr.c @@ -144,13 +144,6 @@ static void ws_protocol_acurite_592txr_remote_controller(WSBlockGeneric* instanc instance->temp = ((float)(temp_raw)-1000) / 10.0f; instance->btn = WS_NO_BTN; - - //DATE AGE set - FuriHalRtcDateTime curr_dt; - furi_hal_rtc_get_datetime(&curr_dt); - uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt); - - instance->agedata = curr_ts; } void ws_protocol_decoder_acurite_592txr_feed(void* context, bool level, uint32_t duration) { diff --git a/applications/plugins/weather_station/protocols/acurite_606tx.c b/applications/plugins/weather_station/protocols/acurite_606tx.c index 8dfbe1363..4cb5d18b8 100644 --- a/applications/plugins/weather_station/protocols/acurite_606tx.c +++ b/applications/plugins/weather_station/protocols/acurite_606tx.c @@ -123,13 +123,6 @@ static void ws_protocol_acurite_606tx_remote_controller(WSBlockGeneric* instance } instance->btn = WS_NO_BTN; instance->humidity = WS_NO_HUMIDITY; - - //DATE AGE set - FuriHalRtcDateTime curr_dt; - furi_hal_rtc_get_datetime(&curr_dt); - uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt); - - instance->agedata = curr_ts; } void ws_protocol_decoder_acurite_606tx_feed(void* context, bool level, uint32_t duration) { diff --git a/applications/plugins/weather_station/protocols/acurite_609txc.c b/applications/plugins/weather_station/protocols/acurite_609txc.c index 89a168100..aeb0785eb 100644 --- a/applications/plugins/weather_station/protocols/acurite_609txc.c +++ b/applications/plugins/weather_station/protocols/acurite_609txc.c @@ -123,13 +123,6 @@ static void ws_protocol_acurite_609txc_remote_controller(WSBlockGeneric* instanc instance->temp = (temp_raw >> 4) * 0.1f; instance->humidity = (instance->data >> 8) & 0xff; instance->btn = WS_NO_BTN; - - //DATE AGE set - FuriHalRtcDateTime curr_dt; - furi_hal_rtc_get_datetime(&curr_dt); - uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt); - - instance->agedata = curr_ts; } void ws_protocol_decoder_acurite_609txc_feed(void* context, bool level, uint32_t duration) { diff --git a/applications/plugins/weather_station/protocols/ambient_weather.c b/applications/plugins/weather_station/protocols/ambient_weather.c index 3f19033ec..5ae22b790 100644 --- a/applications/plugins/weather_station/protocols/ambient_weather.c +++ b/applications/plugins/weather_station/protocols/ambient_weather.c @@ -160,13 +160,6 @@ static void ws_protocol_ambient_weather_remote_controller(WSBlockGeneric* instan ERROR; } */ - - //DATE AGE set - FuriHalRtcDateTime curr_dt; - furi_hal_rtc_get_datetime(&curr_dt); - uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt); - - instance->agedata = curr_ts; } void ws_protocol_decoder_ambient_weather_feed(void* context, bool level, uint32_t duration) { diff --git a/applications/plugins/weather_station/protocols/auriol_hg0601a.c b/applications/plugins/weather_station/protocols/auriol_hg0601a.c index 252565292..d5f89fc8b 100644 --- a/applications/plugins/weather_station/protocols/auriol_hg0601a.c +++ b/applications/plugins/weather_station/protocols/auriol_hg0601a.c @@ -1,6 +1,3 @@ -#include -#include - #include "auriol_hg0601a.h" #define TAG "WSProtocolAuriol_TH" @@ -136,13 +133,6 @@ static void ws_protocol_auriol_th_remote_controller(WSBlockGeneric* instance) { } instance->humidity = (instance->data >> 1) & 0x7F; - - //DATE AGE set - FuriHalRtcDateTime curr_dt; - furi_hal_rtc_get_datetime(&curr_dt); - uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt); - - instance->agedata = curr_ts; } void ws_protocol_decoder_auriol_th_feed(void* context, bool level, uint32_t duration) { diff --git a/applications/plugins/weather_station/protocols/gt_wt_02.c b/applications/plugins/weather_station/protocols/gt_wt_02.c index 5edb1947c..cbe119192 100644 --- a/applications/plugins/weather_station/protocols/gt_wt_02.c +++ b/applications/plugins/weather_station/protocols/gt_wt_02.c @@ -135,12 +135,6 @@ static void ws_protocol_gt_wt_02_remote_controller(WSBlockGeneric* instance) { instance->temp = (float)((~(instance->data >> 13) & 0x07FF) + 1) / -10.0f; } - //DATE AGE set - FuriHalRtcDateTime curr_dt; - furi_hal_rtc_get_datetime(&curr_dt); - uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt); - instance->agedata = curr_ts; - instance->humidity = (instance->data >> 6) & 0x7F; if(instance->humidity <= 10) // actually the sensors sends 10 below working range of 20% instance->humidity = 0; diff --git a/applications/plugins/weather_station/protocols/gt_wt_03.c b/applications/plugins/weather_station/protocols/gt_wt_03.c index 1e601e523..7831cf069 100644 --- a/applications/plugins/weather_station/protocols/gt_wt_03.c +++ b/applications/plugins/weather_station/protocols/gt_wt_03.c @@ -179,13 +179,6 @@ static void ws_protocol_gt_wt_03_remote_controller(WSBlockGeneric* instance) { } else { instance->temp = (float)((~(instance->data >> 9) & 0x07FF) + 1) / -10.0f; } - - //DATE AGE set - FuriHalRtcDateTime curr_dt; - furi_hal_rtc_get_datetime(&curr_dt); - uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt); - - instance->agedata = curr_ts; } void ws_protocol_decoder_gt_wt_03_feed(void* context, bool level, uint32_t duration) { diff --git a/applications/plugins/weather_station/protocols/infactory.c b/applications/plugins/weather_station/protocols/infactory.c index 978b837f2..2d444d981 100644 --- a/applications/plugins/weather_station/protocols/infactory.c +++ b/applications/plugins/weather_station/protocols/infactory.c @@ -148,13 +148,6 @@ static void ws_protocol_infactory_remote_controller(WSBlockGeneric* instance) { instance->humidity = (((instance->data >> 8) & 0x0F) * 10) + ((instance->data >> 4) & 0x0F); // BCD, 'A0'=100%rH instance->channel = instance->data & 0x03; - - //DATE AGE set - FuriHalRtcDateTime curr_dt; - furi_hal_rtc_get_datetime(&curr_dt); - uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt); - - instance->agedata = curr_ts; } void ws_protocol_decoder_infactory_feed(void* context, bool level, uint32_t duration) { diff --git a/applications/plugins/weather_station/protocols/lacrosse_tx141thbv2.c b/applications/plugins/weather_station/protocols/lacrosse_tx141thbv2.c index 8837f730b..e4b612250 100644 --- a/applications/plugins/weather_station/protocols/lacrosse_tx141thbv2.c +++ b/applications/plugins/weather_station/protocols/lacrosse_tx141thbv2.c @@ -123,13 +123,6 @@ static void ws_protocol_lacrosse_tx141thbv2_remote_controller(WSBlockGeneric* in instance->channel = ((instance->data >> 29) & 0x03) + 1; instance->temp = ((float)((instance->data >> 17) & 0x0FFF) - 500.0f) / 10.0f; instance->humidity = (instance->data >> 9) & 0xFF; - - //DATE AGE set - FuriHalRtcDateTime curr_dt; - furi_hal_rtc_get_datetime(&curr_dt); - uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt); - - instance->agedata = curr_ts; } void ws_protocol_decoder_lacrosse_tx141thbv2_feed(void* context, bool level, uint32_t duration) { diff --git a/applications/plugins/weather_station/protocols/nexus_th.c b/applications/plugins/weather_station/protocols/nexus_th.c index 132e38050..7d4a77aea 100644 --- a/applications/plugins/weather_station/protocols/nexus_th.c +++ b/applications/plugins/weather_station/protocols/nexus_th.c @@ -135,13 +135,6 @@ static void ws_protocol_nexus_th_remote_controller(WSBlockGeneric* instance) { } instance->humidity = instance->data & 0xFF; - - //DATE AGE set - FuriHalRtcDateTime curr_dt; - furi_hal_rtc_get_datetime(&curr_dt); - uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt); - - instance->agedata = curr_ts; } void ws_protocol_decoder_nexus_th_feed(void* context, bool level, uint32_t duration) { diff --git a/applications/plugins/weather_station/protocols/thermopro_tx4.c b/applications/plugins/weather_station/protocols/thermopro_tx4.c index 29aaf0b35..0882bc33d 100644 --- a/applications/plugins/weather_station/protocols/thermopro_tx4.c +++ b/applications/plugins/weather_station/protocols/thermopro_tx4.c @@ -132,13 +132,6 @@ static void ws_protocol_thermopro_tx4_remote_controller(WSBlockGeneric* instance } instance->humidity = (instance->data >> 1) & 0xFF; - - //DATE AGE set - FuriHalRtcDateTime curr_dt; - furi_hal_rtc_get_datetime(&curr_dt); - uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt); - - instance->agedata = curr_ts; } void ws_protocol_decoder_thermopro_tx4_feed(void* context, bool level, uint32_t duration) { diff --git a/applications/plugins/weather_station/protocols/ws_generic.c b/applications/plugins/weather_station/protocols/ws_generic.c index f653a86a1..3a1c40726 100644 --- a/applications/plugins/weather_station/protocols/ws_generic.c +++ b/applications/plugins/weather_station/protocols/ws_generic.c @@ -99,11 +99,16 @@ bool ws_block_generic_serialize( break; } - temp_data = instance->agedata; - if(!flipper_format_write_uint32(flipper_format, "Old", &temp_data, 1)) { - FURI_LOG_E(TAG, "Unable to add agedata"); - break; - } + //DATE AGE set + FuriHalRtcDateTime curr_dt; + furi_hal_rtc_get_datetime(&curr_dt); + uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt); + + temp_data = curr_ts; + if(!flipper_format_write_uint32(flipper_format, "Old", &temp_data, 1)) { + FURI_LOG_E(TAG, "Unable to add agedata"); + break; + } temp_data = instance->channel; if(!flipper_format_write_uint32(flipper_format, "Ch", &temp_data, 1)) { @@ -174,17 +179,17 @@ bool ws_block_generic_deserialize(WSBlockGeneric* instance, FlipperFormat* flipp } instance->humidity = (uint8_t)temp_data; - if(!flipper_format_read_uint32(flipper_format, "Old", (uint32_t*)&temp_data, 1)) { + if(!flipper_format_read_uint32(flipper_format, "Old", (uint32_t*)&temp_data, 1)) { FURI_LOG_E(TAG, "Missing agedata"); break; } instance->agedata = (uint32_t)temp_data; - if(!flipper_format_read_uint32(flipper_format, "Ch", (uint32_t*)&temp_data, 1)) { - FURI_LOG_E(TAG, "Missing Channel"); - break; - } - instance->channel = (uint8_t)temp_data; + if(!flipper_format_read_uint32(flipper_format, "Ch", (uint32_t*)&temp_data, 1)) { + FURI_LOG_E(TAG, "Missing Channel"); + break; + } + instance->channel = (uint8_t)temp_data; if(!flipper_format_read_uint32(flipper_format, "Btn", (uint32_t*)&temp_data, 1)) { FURI_LOG_E(TAG, "Missing Btn"); diff --git a/applications/plugins/weather_station/views/weather_station_receiver_info.c b/applications/plugins/weather_station/views/weather_station_receiver_info.c index fb04317c5..e5c1be42a 100644 --- a/applications/plugins/weather_station/views/weather_station_receiver_info.c +++ b/applications/plugins/weather_station/views/weather_station_receiver_info.c @@ -1,5 +1,3 @@ -#include -#include #include "weather_station_receiver.h" #include "../weather_station_app_i.h" #include "weather_station_icons.h" @@ -72,46 +70,54 @@ void ws_view_receiver_info_draw(Canvas* canvas, WSReceiverInfoModel* model) { snprintf(buffer, sizeof(buffer), "Data: 0x%llX", model->generic->data); canvas_draw_str(canvas, 5, 32, buffer); - //DATA AGE - if((int) model->generic->agedata > 0){ - FuriHalRtcDateTime curr_dt; - furi_hal_rtc_get_datetime(&curr_dt); - uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt); + //DATA AGE + if((int)model->generic->agedata > 0) { + FuriHalRtcDateTime curr_dt; + furi_hal_rtc_get_datetime(&curr_dt); + uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt); - int diffold = (int) curr_ts - (int) model->generic->agedata; + int diffold = (int)curr_ts - (int)model->generic->agedata; - if(diffold>60){ + if(diffold > 60) { + int tmp_sec = diffold; + int cnt_min = 1; + for(int i = 1; tmp_sec > 60; i++) { + tmp_sec = tmp_sec - 60; + cnt_min = i; + } + if(cnt_min >= 59) { + } - int tmp_sec = diffold; - int cnt_min = 1; - for(int i=1; tmp_sec>60; i++){ - tmp_sec = tmp_sec - 60; - cnt_min = i; - } + if(curr_ts % 2 == 0) { + canvas_set_color(canvas, ColorBlack); + canvas_draw_rframe(canvas, 97, 23, 26, 11, 1); + canvas_set_color(canvas, ColorBlack); + canvas_draw_str_aligned(canvas, 109, 29, AlignCenter, AlignCenter, "OLD"); + } else { + if(cnt_min >= 59) { + canvas_set_color(canvas, ColorBlack); + canvas_draw_rframe(canvas, 97, 23, 26, 11, 1); + canvas_set_color(canvas, ColorBlack); + canvas_draw_str_aligned(canvas, 109, 29, AlignCenter, AlignCenter, "OLD"); + } else { + canvas_set_color(canvas, ColorBlack); + canvas_draw_rframe(canvas, 97, 23, 26, 11, 1); + canvas_draw_box(canvas, 97, 23, 26, 11); + canvas_set_color(canvas, ColorWhite); + snprintf(buffer, sizeof(buffer), "%dm", cnt_min); + canvas_draw_str_aligned(canvas, 109, 29, AlignCenter, AlignCenter, buffer); + } + } - if ( curr_ts % 2 == 0){ - canvas_set_color(canvas, ColorBlack); - canvas_draw_rframe(canvas, 97, 23, 26, 11, 1); - canvas_set_color(canvas, ColorBlack); - canvas_draw_str_aligned(canvas, 109, 29, AlignCenter, AlignCenter, "OLD"); - }else{ - canvas_set_color(canvas, ColorBlack); - canvas_draw_rframe(canvas, 97, 23, 26, 11, 1); - canvas_draw_box(canvas, 97, 23, 26, 11); - canvas_set_color(canvas, ColorWhite); - snprintf(buffer, sizeof(buffer), "%dm", cnt_min); - canvas_draw_str_aligned(canvas, 109, 29, AlignCenter, AlignCenter, buffer); - } - - }else{ - canvas_set_color(canvas, ColorBlack); - canvas_draw_rframe(canvas, 97, 23, 26, 11, 1); - canvas_set_color(canvas, ColorBlack); - snprintf(buffer, sizeof(buffer), "%d", diffold); - canvas_draw_str_aligned(canvas, 109, 29, AlignCenter, AlignCenter, buffer); - } - } - //DATA AGE end + } else { + canvas_set_color(canvas, ColorBlack); + canvas_draw_rframe(canvas, 97, 23, 26, 11, 1); + canvas_set_color(canvas, ColorBlack); + snprintf(buffer, sizeof(buffer), "%d", diffold); + canvas_draw_str_aligned(canvas, 109, 29, AlignCenter, AlignCenter, buffer); + } + } + //DATA AGE end elements_bold_rounded_frame(canvas, 2, 37, 123, 25); canvas_set_font(canvas, FontPrimary); From 176f27e037877639894ebcbdb2f1cfd01df75f48 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Sun, 4 Dec 2022 15:58:07 +0300 Subject: [PATCH 4/6] WS: Oregon2 - add support for RTHN129 --- .../weather_station/protocols/oregon2.c | 37 ++++++++++++++----- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/applications/plugins/weather_station/protocols/oregon2.c b/applications/plugins/weather_station/protocols/oregon2.c index d294548e6..8779e9596 100644 --- a/applications/plugins/weather_station/protocols/oregon2.c +++ b/applications/plugins/weather_station/protocols/oregon2.c @@ -52,6 +52,11 @@ static const SubGhzBlockConst ws_oregon2_const = { #define ID_UV800 0xd874 #define ID_THN129 0xcc43 // THN129 Temp only #define ID_RTHN129 0x0cd3 // RTHN129 Temp, clock sensors +#define ID_RTHN129_1 0x9cd3 +#define ID_RTHN129_2 0xacd3 +#define ID_RTHN129_3 0xbcd3 +#define ID_RTHN129_4 0xccd3 +#define ID_RTHN129_5 0xdcd3 #define ID_BTHGN129 0x5d53 // Baro, Temp, Hygro sensor #define ID_UVR128 0xec70 #define ID_THGR328N 0xcc23 // Temp & Hygro sensor similar to THR228N with 5 channel instead of 3 @@ -137,11 +142,19 @@ static ManchesterEvent level_and_duration_to_event(bool level, uint32_t duration // From sensor id code return amount of bits in variable section // https://temofeev.ru/info/articles/o-dekodirovanii-protokola-pogodnykh-datchikov-oregon-scientific static uint8_t oregon2_sensor_id_var_bits(uint16_t sensor_id) { - if(sensor_id == ID_THR228N) return 16; - - if(sensor_id == ID_THGR122N) return 24; - - return 0; + switch(sensor_id) { + case ID_THR228N: + case ID_RTHN129_1: + case ID_RTHN129_2: + case ID_RTHN129_3: + case ID_RTHN129_4: + case ID_RTHN129_5: + return 16; + case ID_THGR122N: + return 24; + default: + return 0; + } } static void ws_oregon2_decode_const_data(WSBlockGeneric* ws_block) { @@ -171,16 +184,22 @@ static float ws_oregon2_decode_temp(uint32_t data) { } static void ws_oregon2_decode_var_data(WSBlockGeneric* ws_b, uint16_t sensor_id, uint32_t data) { - if(sensor_id == ID_THR228N) { + switch(sensor_id) { + case ID_THR228N: + case ID_RTHN129_1: + case ID_RTHN129_2: + case ID_RTHN129_3: + case ID_RTHN129_4: + case ID_RTHN129_5: ws_b->temp = ws_oregon2_decode_temp(data); ws_b->humidity = WS_NO_HUMIDITY; return; - } - - if(sensor_id == ID_THGR122N) { + case ID_THGR122N: ws_b->humidity = bcd_decode_short(data); ws_b->temp = ws_oregon2_decode_temp(data >> 8); return; + default: + break; } } From 1c81dc2dee4a0293f765e0d95db7080f47cce5b5 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Sun, 4 Dec 2022 20:48:19 +0300 Subject: [PATCH 5/6] Weather station: signal age display GUI fixes --- .../views/weather_station_receiver_info.c | 49 ++++++++++++++----- 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/applications/plugins/weather_station/views/weather_station_receiver_info.c b/applications/plugins/weather_station/views/weather_station_receiver_info.c index e5c1be42a..74308c8cf 100644 --- a/applications/plugins/weather_station/views/weather_station_receiver_info.c +++ b/applications/plugins/weather_station/views/weather_station_receiver_info.c @@ -58,7 +58,7 @@ void ws_view_receiver_info_draw(Canvas* canvas, WSReceiverInfoModel* model) { if(model->generic->btn != WS_NO_BTN) { snprintf(buffer, sizeof(buffer), "Btn: %01d", model->generic->btn); - canvas_draw_str(canvas, 62, 20, buffer); + canvas_draw_str(canvas, 57, 20, buffer); } if(model->generic->battery_low != WS_NO_BATT) { @@ -78,6 +78,29 @@ void ws_view_receiver_info_draw(Canvas* canvas, WSReceiverInfoModel* model) { int diffold = (int)curr_ts - (int)model->generic->agedata; + uint8_t tmp_x_frame = 101; + uint8_t tmp_y_frame = 23; + + uint8_t tmp_x_text = 113; + uint8_t tmp_y_text = 29; + if(model->generic->data_count_bit >= 41) { + tmp_x_frame = 78; + tmp_y_frame = 0; + + tmp_x_text = 91; + tmp_y_text = 6; + + if(model->generic->btn == WS_NO_BTN) { + if(furi_string_size(model->protocol_name) > (size_t)10) { + tmp_x_frame = 61; + tmp_y_frame = 11; + + tmp_x_text = 74; + tmp_y_text = 17; + } + } + } + if(diffold > 60) { int tmp_sec = diffold; int cnt_min = 1; @@ -85,36 +108,38 @@ void ws_view_receiver_info_draw(Canvas* canvas, WSReceiverInfoModel* model) { tmp_sec = tmp_sec - 60; cnt_min = i; } - if(cnt_min >= 59) { - } if(curr_ts % 2 == 0) { canvas_set_color(canvas, ColorBlack); - canvas_draw_rframe(canvas, 97, 23, 26, 11, 1); + canvas_draw_rframe(canvas, tmp_x_frame, tmp_y_frame, 26, 11, 1); canvas_set_color(canvas, ColorBlack); - canvas_draw_str_aligned(canvas, 109, 29, AlignCenter, AlignCenter, "OLD"); + canvas_draw_str_aligned( + canvas, tmp_x_text, tmp_y_text, AlignCenter, AlignCenter, "OLD"); } else { if(cnt_min >= 59) { canvas_set_color(canvas, ColorBlack); - canvas_draw_rframe(canvas, 97, 23, 26, 11, 1); + canvas_draw_rframe(canvas, tmp_x_frame, tmp_y_frame, 26, 11, 1); canvas_set_color(canvas, ColorBlack); - canvas_draw_str_aligned(canvas, 109, 29, AlignCenter, AlignCenter, "OLD"); + canvas_draw_str_aligned( + canvas, tmp_x_text, tmp_y_text, AlignCenter, AlignCenter, "OLD"); } else { canvas_set_color(canvas, ColorBlack); - canvas_draw_rframe(canvas, 97, 23, 26, 11, 1); - canvas_draw_box(canvas, 97, 23, 26, 11); + canvas_draw_rframe(canvas, tmp_x_frame, tmp_y_frame, 26, 11, 1); + canvas_draw_box(canvas, tmp_x_frame, tmp_y_frame, 26, 11); canvas_set_color(canvas, ColorWhite); snprintf(buffer, sizeof(buffer), "%dm", cnt_min); - canvas_draw_str_aligned(canvas, 109, 29, AlignCenter, AlignCenter, buffer); + canvas_draw_str_aligned( + canvas, tmp_x_text, tmp_y_text, AlignCenter, AlignCenter, buffer); } } } else { canvas_set_color(canvas, ColorBlack); - canvas_draw_rframe(canvas, 97, 23, 26, 11, 1); + canvas_draw_rframe(canvas, tmp_x_frame, tmp_y_frame, 26, 11, 1); canvas_set_color(canvas, ColorBlack); snprintf(buffer, sizeof(buffer), "%d", diffold); - canvas_draw_str_aligned(canvas, 109, 29, AlignCenter, AlignCenter, buffer); + canvas_draw_str_aligned( + canvas, tmp_x_text, tmp_y_text, AlignCenter, AlignCenter, buffer); } } //DATA AGE end From 7d59eb1848a07d75a43e10b020c0e100605e0920 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Sun, 4 Dec 2022 22:26:25 +0300 Subject: [PATCH 6/6] Plugins: iButton Fuzzer change minimal delay after @Tobirg successfully verified stability with lower delay --- .../ibtn_fuzzer/scene/ibtnfuzzer_scene_run_attack.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/applications/plugins/ibtn_fuzzer/scene/ibtnfuzzer_scene_run_attack.c b/applications/plugins/ibtn_fuzzer/scene/ibtnfuzzer_scene_run_attack.c index 5efd4f052..38ea03fbe 100644 --- a/applications/plugins/ibtn_fuzzer/scene/ibtnfuzzer_scene_run_attack.c +++ b/applications/plugins/ibtn_fuzzer/scene/ibtnfuzzer_scene_run_attack.c @@ -69,7 +69,7 @@ uint8_t id_list_cyfral[14][2] = { }; void ibtnfuzzer_scene_run_attack_on_enter(iBtnFuzzerState* context) { - context->time_between_cards = 10; + context->time_between_cards = 8; context->attack_step = 0; context->key = ibutton_key_alloc(); context->worker = ibutton_worker_alloc(); @@ -362,7 +362,7 @@ void ibtnfuzzer_scene_run_attack_on_event(iBtnFuzzerEvent event, iBtnFuzzerState break; case InputKeyLeft: if(!context->is_attacking) { - if(context->time_between_cards > 8) { + if(context->time_between_cards > 4) { context->time_between_cards--; } } @@ -408,8 +408,8 @@ void ibtnfuzzer_scene_run_attack_on_event(iBtnFuzzerEvent event, iBtnFuzzerState switch(event.key) { case InputKeyLeft: if(!context->is_attacking) { - if(context->time_between_cards > 8) { - if((context->time_between_cards - 10) > 8) { + if(context->time_between_cards > 4) { + if((context->time_between_cards - 10) > 4) { context->time_between_cards -= 10; } }