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; } } 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; } } diff --git a/applications/plugins/weather_station/protocols/ws_generic.c b/applications/plugins/weather_station/protocols/ws_generic.c index 174531090..3a1c40726 100644 --- a/applications/plugins/weather_station/protocols/ws_generic.c +++ b/applications/plugins/weather_station/protocols/ws_generic.c @@ -99,6 +99,17 @@ bool ws_block_generic_serialize( 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)) { FURI_LOG_E(TAG, "Unable to add Channel"); @@ -168,6 +179,12 @@ 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)) { + 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; 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 19307b36f..0098da65b 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) { @@ -70,6 +70,80 @@ 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; + + 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; + 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, tmp_x_frame, tmp_y_frame, 26, 11, 1); + canvas_set_color(canvas, ColorBlack); + 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, tmp_x_frame, tmp_y_frame, 26, 11, 1); + canvas_set_color(canvas, ColorBlack); + canvas_draw_str_aligned( + canvas, tmp_x_text, tmp_y_text, AlignCenter, AlignCenter, "OLD"); + } else { + canvas_set_color(canvas, ColorBlack); + 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, tmp_x_text, tmp_y_text, AlignCenter, AlignCenter, buffer); + } + } + + } else { + canvas_set_color(canvas, ColorBlack); + 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, tmp_x_text, tmp_y_text, AlignCenter, AlignCenter, buffer); + } + } + //DATA AGE end + elements_bold_rounded_frame(canvas, 2, 37, 123, 25); canvas_set_font(canvas, FontPrimary);