SubGhz: add protocol "Linear Delta-3" (#2239)
* SubGhz: add protocol "Linear Delta-3" * SubGhz: fix Leniar Delta 3 * BadUSB: mask pvs studio warning for valid code Co-authored-by: SkorP <skorpionm@yandex.ru> Co-authored-by: あく <alleteam@gmail.com> Co-authored-by: Skorpionm <85568270+Skorpionm@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									b1f581239b
								
							
						
					
					
						commit
						8288a08eb3
					
				| @ -13,7 +13,7 @@ | ||||
| #define CAME_ATOMO_DIR_NAME EXT_PATH("subghz/assets/came_atomo") | ||||
| #define NICE_FLOR_S_DIR_NAME EXT_PATH("subghz/assets/nice_flor_s") | ||||
| #define TEST_RANDOM_DIR_NAME EXT_PATH("unit_tests/subghz/test_random_raw.sub") | ||||
| #define TEST_RANDOM_COUNT_PARSE 273 | ||||
| #define TEST_RANDOM_COUNT_PARSE 295 | ||||
| #define TEST_TIMEOUT 10000 | ||||
| 
 | ||||
| static SubGhzEnvironment* environment_handler; | ||||
| @ -489,6 +489,14 @@ MU_TEST(subghz_decoder_linear_test) { | ||||
|         "Test decoder " SUBGHZ_PROTOCOL_LINEAR_NAME " error\r\n"); | ||||
| } | ||||
| 
 | ||||
| MU_TEST(subghz_decoder_linear_delta3_test) { | ||||
|     mu_assert( | ||||
|         subghz_decoder_test( | ||||
|             EXT_PATH("unit_tests/subghz/linear_delta3_raw.sub"), | ||||
|             SUBGHZ_PROTOCOL_LINEAR_DELTA3_NAME), | ||||
|         "Test decoder " SUBGHZ_PROTOCOL_LINEAR_DELTA3_NAME " error\r\n"); | ||||
| } | ||||
| 
 | ||||
| MU_TEST(subghz_decoder_megacode_test) { | ||||
|     mu_assert( | ||||
|         subghz_decoder_test( | ||||
| @ -647,6 +655,12 @@ MU_TEST(subghz_encoder_linear_test) { | ||||
|         "Test encoder " SUBGHZ_PROTOCOL_LINEAR_NAME " error\r\n"); | ||||
| } | ||||
| 
 | ||||
| MU_TEST(subghz_encoder_linear_delta3_test) { | ||||
|     mu_assert( | ||||
|         subghz_encoder_test(EXT_PATH("unit_tests/subghz/linear_delta3.sub")), | ||||
|         "Test encoder " SUBGHZ_PROTOCOL_LINEAR_DELTA3_NAME " error\r\n"); | ||||
| } | ||||
| 
 | ||||
| MU_TEST(subghz_encoder_megacode_test) { | ||||
|     mu_assert( | ||||
|         subghz_encoder_test(EXT_PATH("unit_tests/subghz/megacode.sub")), | ||||
| @ -772,6 +786,7 @@ MU_TEST_SUITE(subghz) { | ||||
|     MU_RUN_TEST(subghz_decoder_somfy_telis_test); | ||||
|     MU_RUN_TEST(subghz_decoder_star_line_test); | ||||
|     MU_RUN_TEST(subghz_decoder_linear_test); | ||||
|     MU_RUN_TEST(subghz_decoder_linear_delta3_test); | ||||
|     MU_RUN_TEST(subghz_decoder_megacode_test); | ||||
|     MU_RUN_TEST(subghz_decoder_secplus_v1_test); | ||||
|     MU_RUN_TEST(subghz_decoder_secplus_v2_test); | ||||
| @ -796,6 +811,7 @@ MU_TEST_SUITE(subghz) { | ||||
|     MU_RUN_TEST(subghz_encoder_nice_flo_test); | ||||
|     MU_RUN_TEST(subghz_encoder_keelog_test); | ||||
|     MU_RUN_TEST(subghz_encoder_linear_test); | ||||
|     MU_RUN_TEST(subghz_encoder_linear_delta3_test); | ||||
|     MU_RUN_TEST(subghz_encoder_megacode_test); | ||||
|     MU_RUN_TEST(subghz_encoder_holtek_test); | ||||
|     MU_RUN_TEST(subghz_encoder_secplus_v1_test); | ||||
|  | ||||
| @ -694,7 +694,7 @@ void bad_usb_script_set_keyboard_layout(BadUsbScript* bad_usb, FuriString* layou | ||||
|     } | ||||
| 
 | ||||
|     File* layout_file = storage_file_alloc(furi_record_open(RECORD_STORAGE)); | ||||
|     if(!furi_string_empty(layout_path)) { | ||||
|     if(!furi_string_empty(layout_path)) { //-V1051
 | ||||
|         if(storage_file_open( | ||||
|                layout_file, furi_string_get_cstr(layout_path), FSAM_READ, FSOM_OPEN_EXISTING)) { | ||||
|             uint16_t layout[128]; | ||||
|  | ||||
							
								
								
									
										7
									
								
								assets/unit_tests/subghz/linear_delta3.sub
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								assets/unit_tests/subghz/linear_delta3.sub
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,7 @@ | ||||
| Filetype: Flipper SubGhz Key File | ||||
| Version: 1 | ||||
| Frequency: 433920000 | ||||
| Preset: FuriHalSubGhzPresetOok650Async | ||||
| Protocol: LinearDelta3 | ||||
| Bit: 8 | ||||
| Key: 00 00 00 00 00 00 00 D0 | ||||
							
								
								
									
										8
									
								
								assets/unit_tests/subghz/linear_delta3_raw.sub
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								assets/unit_tests/subghz/linear_delta3_raw.sub
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,8 @@ | ||||
| Filetype: Flipper SubGhz RAW File | ||||
| Version: 1 | ||||
| Frequency: 433920000 | ||||
| Preset: FuriHalSubGhzPresetOok650Async | ||||
| Protocol: RAW | ||||
| RAW_Data: -66 11813 -100 14655 -98 40111 -66 1625 -2116 1933 -34732 501 -11730 235 -3728 1887 -2106 1933 -2092 1971 -2072 1959 -34712 511 -3554 445 -3556 1997 -2036 455 -3594 1963 -2046 1979 -2076 1961 -2070 1989 -34690 483 -7724 1739 -2226 355 -3684 1857 -2138 1929 -2078 1965 -2074 1947 -34750 487 -3538 473 -3544 1993 -2042 485 -3548 1961 -2070 1965 -2070 1969 -2042 1997 -34716 443 -7734 1753 -2236 323 -3676 1903 -2098 1945 -2102 1927 -2070 1989 -34710 521 -3532 473 -3544 1991 -2032 481 -3556 1969 -2076 1967 -2036 1991 -2066 1969 -34718 467 -7756 1739 -2192 363 -3654 1889 -2132 1929 -2096 1935 -2070 1987 -34716 511 -3522 471 -3554 2009 -2036 459 -3550 2003 -2038 1979 -2042 1999 -2042 1999 -34704 471 -11774 225 -3710 1879 -2162 1885 -2112 1925 -2110 1939 -34738 459 -3636 403 -3612 1939 -2062 451 -3566 1985 -2044 1995 -2040 2009 -2032 2003 -34684 495 -3680 295 -3648 1935 -2098 423 -3562 2001 -2038 1989 -2044 2003 -2036 1977 -34718 461 -3678 295 -3684 1901 -2098 429 -3596 1967 -2036 1981 -2048 1993 -2042 2013 -34686 521 -3530 457 -3568 1999 -2036 455 -3552 1999 -2032 2019 -2024 1995 -2022 1997 -34716 441 -15774 1809 -2192 1905 -2100 1919 -2112 1961 -34720 417 -3830 167 -3710 1863 -2144 357 -3674 1909 -2100 1955 -2062 1977 -2072 1965 -34710 487 -3562 453 -3554 1985 -2052 481 -3536 2019 -2010 2001 -2042 1997 -2038 2005 -34716 451 -3602 433 -3584 1959 -2070 451 -3560 2001 -2038 1993 -2042 1967 -2072 1973 -34712 459 -3622 393 -3624 1933 -2068 457 -3584 1965 -2064 1979 -2052 1967 -2044 1981 -34722 477 -3608 397 -3588 1961 -2096 413 -3596 1971 -2040 1979 -2072 1963 -2070 1959 -34714 495 -3558 483 -3538 1985 -2042 479 -3562 1985 -2046 1967 -2070 1973 -2054 1995 -34688 493 -3578 413 -3614 1939 -2074 465 -3560 1971 -2038 2017 -2018 1995 -2042 2013 -34726 479 -3528 475 -3556 1999 -2036 455 -3570 1999 -2040 1973 -2054 2001 -2032 1987 -34720 477 -3562 445 -3602 1949 -2054 481 -3562 1975 -2060 1963 -2064 1977 -2038 2005 -34702 485 -3570 447 -3550 2015 -2020 479 -3564 1983 -2048 1999 -2034 1971 -2064 1993 -34688 517 -3516 497 -3532 1999 -2038 481 -3558 1997 -2004 2027 -2042 1963 -2038 1997 -34716 491 -3562 461 -3548 1995 -2032 491 -3524 2005 -2036 1989 -2038 1995 -2046 1979 -34714 465 -3682 293 -3680 1905 -2096 431 -3592 1969 -2070 1977 -2052 1965 -2044 1981 -34734 479 -3564 463 -3556 1999 -2032 457 -3550 1995 -2044 2011 -2042 1997 -2006 2027 -34680 531 -3524 483 -3538 1987 -2044 479 -3534 2013 -2048 1965 -2062 1987 -2030 1997 -34712 473 -3592 445 -3562 1975 -2072 451 -3566 1965 -2042 2013 -2046 1963 -2064 1993 -34700 459 -3632 371 -3638 1915 -2084 449 -3568 1987 -2046 1971 -2070 1983 -2022 1997 -34726 487 -3524 477 -3562 1985 -2044 481 -3542 2005 -2040 1995 -2038 1967 -2046 1993 -34710 511 -3528 471 -3560 1967 -2070 459 -3558 1971 | ||||
| RAW_Data: -2072 1971 -2056 1971 -2074 1973 -34714 455 -3634 373 -3634 1901 -2110 419 -3620 1941 -2070 1991 -2040 1999 -2038 1965 -34740 467 -3562 481 -3534 1983 -2070 449 -3546 1999 -2044 1993 -2042 2003 -2036 1975 -34702 521 -3560 443 -3586 1969 -2044 449 -3562 1997 -2046 1987 -2042 2007 -2034 1973 -34732 487 -3562 443 -3582 1979 -2058 445 -3560 1995 -2044 1997 -2028 1987 -2034 2003 -34710 515 -3518 485 -3566 1977 -2036 483 -3536 1999 -2044 2009 -2024 1995 -2068 1973 -34710 487 -3564 471 -3558 1977 -2054 447 -3564 1991 -2042 1997 -2036 2007 -2034 2001 -34684 529 -3526 469 -3548 1989 -2038 483 -3562 1997 -2038 1973 -2034 1999 -2036 1997 -34728 487 -3536 479 -3534 2013 -2044 449 -3570 1985 -2042 1993 -2044 2005 -2014 1995 -34710 473 -3594 439 -3562 1995 -2040 457 -3564 2001 -2040 1975 -2046 1995 -2046 1999 -34704 491 -3548 451 -3570 1991 -2042 447 -3578 1967 -2046 1995 -2042 1999 -2034 2001 -34712 491 -3562 443 -3584 1981 -2018 479 -3562 1985 -2044 1997 -2030 1989 -2040 1997 -34722 489 -3554 459 -3560 1969 -2068 453 -3554 1999 -2034 1987 -2058 1997 -2046 1983 -34702 487 -3534 479 -3564 1983 -2040 483 -3538 1981 -2048 1993 -2048 2007 -2044 1995 -34696 489 -3550 453 -3570 1995 -2050 447 -3564 1983 -2040 1999 -2034 2003 -2034 1995 -34690 495 -3580 433 -3586 1969 -2064 453 -3552 1995 -2036 1991 -2056 1997 -2046 1987 -34706 441 -3636 373 -3626 1959 -2074 419 -3592 1963 -2074 1989 -2044 1971 -2070 1981 -34698 509 -3526 503 -3528 2005 -2034 481 -3528 1993 -2042 1999 -2066 1989 -2034 2003 -34678 495 -3540 481 -3546 1997 -2046 473 -3554 1999 -2034 2001 -2036 1995 -2046 1983 -34720 475 -3560 469 -3548 1997 -2030 485 -3566 1963 -2066 1983 -2046 1999 -2034 1973 -34734 487 -3560 443 -3584 1981 -2052 445 -3568 1987 -2044 1999 -2032 1993 -2034 2007 -34702 491 -3560 459 -3558 1967 -2070 455 -3556 2003 -2036 1977 -2042 2005 -2028 1997 -34730 461 -3564 473 -3536 2011 -2046 449 -3566 1989 -2044 1997 -2042 1971 -2054 2001 -34708 475 -3560 479 -3528 1999 -2040 485 -3566 1963 -2040 2013 -2042 1995 -2034 1987 -34694 519 -3554 441 -3582 1981 -2052 449 -3564 1985 -2040 1993 -2034 1991 -2062 1975 -34714 529 -3534 463 -3558 1969 -2068 451 -3560 2003 -2038 1993 -2042 1969 -2070 1975 -34720 493 -3582 383 -3616 1937 -2072 469 -3558 1995 -2036 1975 -2066 1995 -2042 1989 -34678 531 -3560 391 -3622 1937 -2094 429 -3588 1967 -2070 1981 -2054 1965 -2038 2021 -34682 525 -3524 481 -3564 1989 -2040 445 -3554 1997 -2040 2005 -2034 2001 -2024 1991 -34706 517 -3586 409 -3610 1927 -2076 451 -3558 1967 -2074 1993 -2038 2001 -2040 1975 -34714 495 -3588 409 -3602 1933 -2088 447 -3584 1965 -2044 1999 -2036 2007 -2030 1995 -34692 525 -3538 447 -3580 1981 -2042 487 -3542 1995 -2040 1969 -2072 1969 -2044 1991 -34714 443 -3636 399 -3630 1899 -2106 413 -3584 1997 | ||||
| RAW_Data: -2034 2007 -2038 1969 -2076 1965 -34708 493 -3564 451 -3570 1965 -2074 449 -3548 2003 -2044 1987 -2038 1999 -2030 1991 -34710 493 -3602 403 -3612 1943 -2092 419 -3596 1963 -2062 1963 -2042 2001 -2064 1967 -34716 497 -3616 357 -3648 1903 -2132 399 -3596 1963 -2068 1977 -2052 1967 -2046 2019 -34684 497 -3614 359 -3650 1909 -2100 405 -3630 1925 -2098 1965 -2066 1965 -2056 1971 -34712 477 -3634 371 -3628 1931 -2104 391 -3624 1939 -2066 1975 -2052 2005 -2036 1985 -34714 449 -3668 337 -3664 1901 -2124 417 -3594 1963 -2048 1995 -2028 1993 -2066 1971 -34698 463 -3642 353 -3650 1943 -2066 433 -3594 1963 -2066 1995 -2034 1997 -2046 1981 -34730 479 -3560 445 -3562 1997 -2032 485 -3560 1965 -2062 1989 -2044 1999 -2032 1971 -34724 463 -3608 399 -3620 1943 -2096 421 -3592 1961 -2074 1979 -2036 2011 -2032 1971 -34734 469 -3558 485 -3552 1999 -2028 473 -3552 2003 -2032 2003 -2032 1997 -2044 1993 -34704 443 -3602 431 -3596 1967 -2076 447 -3556 1975 -2058 1997 -2040 1991 -2048 1971 -161100 97 -428 165 -200 395 -428 97 -100 559 -130 97 -164 129 -98 391 -98 295 -166 52395 -66 16239 -66 42541 -66 755 -132 14015 -98 2885 -68 10385 -98 40045 -100 987 -68 25539 -66 19799 -98 136101 -100 5141 -66 5709 -68 23177 -66 11097 -66 329 -100 261 -66 15755 -98 20575 -66 3645 -100 51411 -66 14441 -132 4467 -66 3965 -132 3707 -66 33107 -66 10373 -66 1775 -66 4185 -132 1429 -68 4675 -100 13419 -66 33985 | ||||
| @ -173,3 +173,5 @@ RAW_Data: 107 -1501 77 -1518 53 -704 113 -390 107 -650 73 -932 51 -3641 169 -704 | ||||
| RAW_Data: 79 -4798 53 -918 83 -4847 51 -755 103 -732 81 -388 55 -1026 77 -1506 101 -242 107 -469 51 -2026 79 -686 77 -348 51 -104 131 -860 129 -148 73 -446 75 -440 97 -306 99 -600 51 -626 105 -1350 95 -674 83 -230 119 -1714 135 -396 155 -1111 109 -652 111 -482 51 -506 55 -1715 103 -968 207 -1156 81 -164 57 -404 99 -508 205 -126 75 -1417 51 -186 77 -588 53 -54 103 -2854 73 -1010 53 -800 51 -2494 53 -106 105 -52 51 -104 79 -1116 51 -654 103 -220 77 -162 71 -5385 137 -2232 79 -1159 79 -250 57 -108 79 -164 107 -1660 79 -3927 129 -992 73 -1913 51 -1430 51 -1498 55 -514 103 -586 81 -386 53 -2402 175 -1994 85 -3431 53 -3209 99 -372 79 -78 53 -1338 75 -682 97 -680 51 -206 101 -1708 101 -452 131 -1397 161 -2272 53 -456 77 -1413 193 -270 109 -466 53 -2432 77 -222 189 -474 107 -774 171 -192 79 -1327 75 -2141 51 -908 135 -3866 75 -804 129 -468 101 -1040 79 -1470 55 -869 77 -1448 105 -160 55 -1916 240 -588 79 -1587 53 -922 79 -2292 181 -1448 51 -552 77 -2189 75 -2545 77 -384 300 -2478 101 -1092 73 -558 79 -132 105 -884 103 -1177 109 -880 79 -2431 109 -1006 105 -468 53 -1378 235 -684 75 -285 73 -604 129 -528 77 -1582 51 -1240 105 -2750 75 -252 51 -1024 95 -1891 51 -864 107 -326 83 -887 159 -1058 163 -322 105 -722 83 -388 81 -936 155 -880 55 -220 83 -2123 135 -2100 73 -1926 103 -1633 149 -526 51 -324 51 -1538 103 -164 137 -964 81 -152 111 -781 225 -655 53 -2888 105 -151 131 -454 53 -4109 77 -1052 53 -178 163 -910 51 -733 207 -2070 53 -474 79 -54 53 -818 51 -1228 53 -2262 79 -788 79 -480 73 -2747 83 -316 183 -1880 105 -862 53 -662 53 -2287 153 -1630 51 -817 243 -806 55 -510 51 -1389 75 -986 135 -498 109 -532 131 -5521 99 -2948 209 -764 75 -1168 75 -886 83 -2065 53 -710 51 -596 77 -374 73 -628 99 -732 51 -202 73 -632 53 -222 55 -511 79 -4884 53 -1826 81 -1266 107 -356 55 -110 113 -280 83 -756 169 -252 81 -1854 51 -1556 157 -258 75 -748 53 -1438 291 -244 71 -1092 77 -1220 229 -1055 181 -1182 71 -1284 77 -864 79 -138 53 -160 53 -952 81 -80 127 -1272 51 -590 103 -502 77 -634 101 -74 51 -224 101 -912 77 -562 51 -164 83 -396 105 -4643 111 -3293 133 -1395 107 -3047 137 -2353 53 -298 83 -54 81 -80 53 -162 83 -392 105 -606 107 -787 53 -928 51 -2800 161 -1146 51 -182 103 -536 103 -994 81 -2044 83 -732 133 -1881 133 -2160 75 -178 | ||||
| RAW_Data: 75 -1694 101 -122 73 -864 51 -250 129 -406 77 -630 77 -610 101 -781 125 -128 51 -5075 77 -1992 83 -1272 176 -2100 53 -2044 53 -1234 79 -1704 157 -519 99 -2374 101 -100 103 -202 51 -360 77 -1962 103 -2153 77 -1820 191 -164 167 -1320 77 -1718 127 -1374 81 -1047 53 -54 79 -632 53 -656 51 -128 81 -216 51 -755 79 -2692 103 -1478 125 -452 51 -896 157 -3679 135 -632 105 -134 55 -112 77 -588 79 -188 55 -1118 79 -1152 51 -1950 109 -1858 103 -1104 81 -580 131 -226 255 -2932 77 -1536 51 -1044 159 -2135 67667 -252 333 -278 333 -276 333 -74 533 -280 307 -276 345 -6930 331 -276 329 -278 329 -278 327 -278 349 -270 325 -270 317 -290 313 -308 283 -306 309 -100 509 -306 283 -328 281 -6972 307 -302 281 -326 281 -326 281 -328 279 -328 281 -326 279 -328 279 -326 281 -328 279 -124 481 -308 281 -326 279 -6998 281 -326 279 -328 279 -328 277 -330 277 -328 279 -328 279 -328 277 -304 303 -302 303 -100 503 -306 295 -322 293 -6968 287 -342 259 -336 283 -332 257 -356 255 -328 283 -328 257 -352 257 -352 257 -352 255 -150 455 -334 281 -326 281 -6996 265 -342 253 -354 253 -354 253 -354 253 -354 267 -326 269 -350 263 -342 257 -336 259 -152 459 -360 257 -354 231 -7038 267 -338 255 -352 253 -354 253 -354 239 -354 269 -352 239 -372 233 -366 233 -358 257 -154 457 -360 231 -378 231 -7050 231 -380 231 -378 231 -380 231 -378 231 -354 255 -352 257 -352 255 -354 231 -378 229 -176 453 -358 229 -378 231 -7076 231 -378 231 -380 231 -380 229 -354 255 -354 257 -352 257 -352 257 -352 257 -354 255 -150 455 -358 265 -364 229 -4941 101 -1058 153 -670 157 -532 124 -1396 133 -82 165 -162 153 -258 207 -156 131 -1582 85 -714 53 -774 103 -396 274 -110 131 -1965 55 -402 159 -1026 79 -590 77 -3531 57 -500 51 -4770 109 -722 77 -186 53 -298 79 -502 165 -808 77 -438 53 -382 101 -1914 75 -504 77 -1969 135 -5517 99 -576 51 -608 243 -684 53 -2058 315 -1384 79 -1079 77 -232 79 -212 155 -1500 137 -258 75 -975 204 -752 83 -2542 51 -484 103 -78 77 -210 53 -922 157 -1900 107 -2173 83 -384 101 -80 128 -814 183 -978 127 -772 105 -2073 51 -708 53 -300 83 -739 237 -884 131 -3412 157 -1752 81 -164 83 -3373 53 -1406 105 -3809 79 -432 51 -724 77 -548 53 -1955 79 -807 81 -2096 103 -490 105 -1196 109 -108 79 -394 71 -1159 129 -126 143 -340 107 -556 81 -2390 135 -106 133 -690 133 -4347 189 -290 51 -110 53 -78 103 -1101 51 -1362 | ||||
| RAW_Data: 83 -320 81 -4648 101 -3726 173 -1418 85 -348 53 -2994 79 -1390 51 -1656 107 -764 53 -134 79 -1619 131 -932 55 -2810 107 -3218 79 -765 107 -654 103 -1498 77 -228 51 -134 247 -1526 51 -3903 103 -1495 179 -282 77 -392 53 -1756 105 -368 111 -486 51 -298 53 -216 113 -358 51 -266 187 -1059 81 -780 105 -238 51 -482 53 -791 109 -2169 77 -5304 53 -398 79 -650 51 -54 51 -1789 73 -198 101 -1580 101 -746 97 -4518 53 -744 51 -1064 101 -928 111 -392 185 -869 103 -320 133 -704 81 -244 53 -1628 75 -634 79 -666 183 -1276 83 -218 107 -1163 55 -1276 127 -1144 73 -1400 81 -266 77 -568 129 -806 121 -1420 103 -848 77 -982 103 -2132 81 -1610 101 -1218 55 -2208 75 -2735 53 -921 53 -724 51 -472 83 -3164 185 -400 77 -812 81 -306 215 -2167 53 -130 53 -272 81 -400 79 -1272 81 -418 51 -1381 73 -340 101 -2169 81 -2330 137 -2698 99 -2340 99 -126 51 -1714 55 -488 81 -3500 51 -404 77 -1422 77 -856 215 -80 51 -2308 53 -134 77 -2036 75 -5175 129 -946 239 -638 53 -244 55 -564 105 -826 71 -1632 77 -106 129 -246 135 -366 79 -724 79 -1535 57 -1085 113 -1320 79 -3111 127 -1578 75 -324 75 -102 173 -364 79 -1374 53 -1508 107 -622 51 -526 109 -584 187 -2648 51 -106 79 -380 103 -604 51 -1244 73 -5766 107 -1934 177 -702 51 -1277 53 -1643 79 -1446 81 -4098 75 -574 103 -432 189 -1436 107 -454 79 -132 105 -136 81 -112 113 -942 239 -1238 79 -952 157 -340 51 -314 191 -456 53 -3368 101 -150 99 -464 51 -718 73 -770 101 -150 73 -2132 75 -557 77 -680 81 -3512 151 -760 75 -332 75 -1212 131 -1468 79 -1955 101 -541 75 -344 79 -2146 53 -2299 97 -720 79 -2518 79 -3807 51 -1272 75 -352 77 -52 75 -586 53 -1142 79 -82 81 -2400 157 -324 81 -268 103 -1154 81 -1175 79 -1191 51 -1074 53 -2566 137 -854 75 -1497 51 -4533 51 -2290 51 -344 77 -348 55 -1182 77 -897 135 -874 51 -1064 51 -208 55 -140 55 -1334 133 -1238 157 -1669 113 -2128 75 -848 85 -510 83590 -126 333 -280 331 -252 331 -6946 331 -276 331 -276 329 -278 329 -276 331 -276 331 -276 331 -276 347 -238 351 -254 353 -268 323 -270 345 -6924 335 -282 307 -304 307 -304 281 -304 307 -302 307 -302 305 -302 307 -302 305 -302 281 -124 507 -282 305 -302 305 -6984 279 -328 277 -328 279 -328 277 -330 277 -304 303 -302 305 -302 305 -302 303 -304 303 -100 507 -314 295 -298 293 -6986 283 -334 281 -306 283 -328 283 -328 281 -328 283 -328 255 -352 | ||||
| RAW_Data: -66 11813 -100 14655 -98 40111 -66 1625 -2116 1933 -34732 501 -11730 235 -3728 1887 -2106 1933 -2092 1971 -2072 1959 -34712 511 -3554 445 -3556 1997 -2036 455 -3594 1963 -2046 1979 -2076 1961 -2070 1989 -34690 483 -7724 1739 -2226 355 -3684 1857 -2138 1929 -2078 1965 -2074 1947 -34750 487 -3538 473 -3544 1993 -2042 485 -3548 1961 -2070 1965 -2070 1969 -2042 1997 -34716 443 -7734 1753 -2236 323 -3676 1903 -2098 1945 -2102 1927 -2070 1989 -34710 521 -3532 473 -3544 1991 -2032 481 -3556 1969 -2076 1967 -2036 1991 -2066 1969 -34718 467 -7756 1739 -2192 363 -3654 1889 -2132 1929 -2096 1935 -2070 1987 -34716 511 -3522 471 -3554 2009 -2036 459 -3550 2003 -2038 1979 -2042 1999 -2042 1999 -34704 471 -11774 225 -3710 1879 -2162 1885 -2112 1925 -2110 1939 -34738 459 -3636 403 -3612 1939 -2062 451 -3566 1985 -2044 1995 -2040 2009 -2032 2003 -34684 495 -3680 295 -3648 1935 -2098 423 -3562 2001 -2038 1989 -2044 2003 -2036 1977 -34718 461 -3678 295 -3684 1901 -2098 429 -3596 1967 -2036 1981 -2048 1993 -2042 2013 -34686 521 -3530 457 -3568 1999 -2036 455 -3552 1999 -2032 2019 -2024 1995 -2022 1997 -34716 441 -15774 1809 -2192 1905 -2100 1919 -2112 1961 -34720 417 -3830 167 -3710 1863 -2144 357 -3674 1909 -2100 1955 -2062 1977 -2072 1965 -34710 487 -3562 453 -3554 1985 -2052 481 -3536 2019 -2010 2001 -2042 1997 -2038 2005 -34716 451 -3602 433 -3584 1959 -2070 451 -3560 2001 -2038 1993 -2042 1967 -2072 1973 -34712 459 -3622 393 -3624 1933 -2068 457 -3584 1965 -2064 1979 -2052 1967 -2044 1981 -34722 477 -3608 397 -3588 1961 -2096 413 -3596 1971 -2040 1979 -2072 1963 -2070 1959 -34714 495 -3558 483 -3538 1985 -2042 479 -3562 1985 -2046 1967 -2070 1973 -2054 1995 -34688 493 -3578 413 -3614 1939 -2074 465 -3560 1971 -2038 2017 -2018 1995 -2042 2013 -34726 479 -3528 475 -3556 1999 -2036 455 -3570 1999 -2040 1973 -2054 2001 -2032 1987 -34720 477 -3562 445 -3602 1949 -2054 481 -3562 1975 -2060 1963 -2064 1977 -2038 2005 -34702 485 -3570 447 -3550 2015 -2020 479 -3564 1983 -2048 1999 -2034 1971 -2064 1993 -34688 517 -3516 497 -3532 1999 -2038 481 -3558 1997 -2004 2027 -2042 1963 -2038 1997 -34716 491 -3562 461 -3548 1995 -2032 491 -3524 2005 -2036 1989 -2038 1995 -2046 1979 -34714 465 -3682 293 -3680 1905 -2096 431 -3592 1969 -2070 1977 -2052 1965 -2044 1981 -34734 479 -3564 463 -3556 1999 -2032 457 -3550 1995 -2044 2011 -2042 1997 -2006 2027 -34680 531 -3524 483 -3538 1987 -2044 479 -3534 2013 -2048 1965 -2062 1987 -2030 1997 -34712 473 -3592 445 -3562 1975 -2072 451 -3566 1965 -2042 2013 -2046 1963 -2064 1993 -34700 459 -3632 371 -3638 1915 -2084 449 -3568 1987 -2046 1971 -2070 1983 -2022 1997 -34726 487 -3524 477 -3562 1985 -2044 481 -3542 2005 -2040 1995 -2038 1967 -2046 1993 -34710 511 -3528 471 -3560 1967 -2070 459 -3558 1971 | ||||
| RAW_Data: -2072 1971 -2056 1971 -2074 1973 -34714 455 -3634 373 -3634 1901 -2110 419 -3620 1941 -2070 1991 -2040 1999 -2038 1965 -34740 467 -3562 481 -3534 1983 -2070 449 -3546 1999 -2044 1993 -2042 2003 -2036 1975 -34702 521 -3560 443 -3586 1969 -2044 449 -3562 1997 -2046 1987 -2042 2007 -2034 1973 -34732 487 -3562 443 -3582 1979 -2058 445 -3560 1995 -2044 1997 -2028 1987 -2034 2003 -34710 515 -3518 485 -3566 1977 -2036 483 -3536 1999 -2044 2009 -2024 1995 -2068 1973 -34710 487 -3564 471 -3558 1977 -2054 447 -3564 1991 -2042 1997 -2036 2007 -2034 2001 -34684 529 -3526 469 -3548 1989 -2038 483 -3562 1997 -2038 1973 -2034 1999 -2036 1997 -34728 487 -3536 479 -3534 2013 -2044 449 -3570 1985 -2042 1993 -2044 2005 -2014 1995 -34710 473 -3594 439 -3562 1995 -2040 457 -3564 2001 -2040 1975 -2046 1995 -2046 1999 -34704 491 -3548 451 -3570 1991 -2042 447 -3578 1967 -2046 1995 -2042 1999 -2034 2001 -34712 491 -3562 443 -3584 1981 -2018 479 -3562 1985 -2044 1997 -2030 1989 -2040 1997 -34722 489 -3554 459 -3560 1969 -2068 453 -3554 1999 -2034 1987 -2058 1997 -2046 1983 -34702 487 -3534 479 -3564 1983 -2040 483 -3538 1981 -2048 1993 -2048 2007 -2044 1995 -34696 489 -3550 453 -3570 1995 -2050 447 -3564 1983 -2040 1999 -2034 2003 -2034 1995 -34690 495 -3580 433 -3586 1969 -2064 453 -3552 1995 -2036 1991 -2056 1997 -2046 1987 -34706 441 -3636 373 -3626 1959 -2074 419 -3592 1963 -2074 1989 -2044 1971 -2070 1981 -34698 509 -3526 503 -3528 2005 -2034 481 -3528 1993 -2042 1999 -2066 1989 -2034 2003 -34678 495 -3540 481 -3546 1997 -2046 473 -3554 1999 -2034 2001 -2036 1995 -2046 1983 -34720 475 -3560 469 -3548 1997 -2030 485 -3566 1963 -2066 1983 -2046 1999 -2034 1973 -34734 487 -3560 443 -3584 1981 -2052 445 -3568 1987 -2044 1999 -2032 1993 -2034 2007 -34702 491 -3560 459 -3558 1967 -2070 455 -3556 2003 -2036 1977 -2042 2005 -2028 1997 -34730 461 -3564 473 -3536 2011 -2046 449 -3566 1989 -2044 1997 -2042 1971 -2054 2001 -34708 475 -3560 479 -3528 1999 -2040 485 -3566 1963 -2040 2013 -2042 1995 -2034 1987 -34694 519 -3554 441 -3582 1981 -2052 449 -3564 1985 -2040 1993 -2034 1991 -2062 1975 -34714 529 -3534 463 -3558 1969 -2068 451 -3560 2003 -2038 1993 -2042 1969 -2070 1975 -34720 493 -3582 383 -3616 1937 -2072 469 -3558 1995 -2036 1975 -2066 1995 -2042 1989 -34678 531 -3560 391 -3622 1937 -2094 429 -3588 1967 -2070 1981 -2054 1965 -2038 2021 -34682 525 -3524 481 -3564 1989 -2040 445 -3554 1997 -2040 2005 -2034 2001 -2024 1991 -34706 517 -3586 409 -3610 1927 -2076 451 -3558 1967 -2074 1993 -2038 2001 -2040 1975 -34714 495 -3588 409 -3602 1933 -2088 447 -3584 1965 -2044 1999 -2036 2007 -2030 1995 -34692 525 -3538 447 -3580 1981 -2042 487 -3542 1995 -2040 1969 -2072 1969 -2044 1991 -34714 443 -3636 399 -3630 1899 -2106 413 -3584 1997 | ||||
|  | ||||
							
								
								
									
										359
									
								
								lib/subghz/protocols/linear_delta3.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										359
									
								
								lib/subghz/protocols/linear_delta3.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,359 @@ | ||||
| #include "linear_delta3.h" | ||||
| 
 | ||||
| #include "../blocks/const.h" | ||||
| #include "../blocks/decoder.h" | ||||
| #include "../blocks/encoder.h" | ||||
| #include "../blocks/generic.h" | ||||
| #include "../blocks/math.h" | ||||
| 
 | ||||
| #define TAG "SubGhzProtocolLinearDelta3" | ||||
| 
 | ||||
| #define DIP_PATTERN "%c%c%c%c%c%c%c%c" | ||||
| #define DATA_TO_DIP(dip)                                                                    \ | ||||
|     (dip & 0x0080 ? '1' : '0'), (dip & 0x0040 ? '1' : '0'), (dip & 0x0020 ? '1' : '0'),     \ | ||||
|         (dip & 0x0010 ? '1' : '0'), (dip & 0x0008 ? '1' : '0'), (dip & 0x0004 ? '1' : '0'), \ | ||||
|         (dip & 0x0002 ? '1' : '0'), (dip & 0x0001 ? '1' : '0') | ||||
| 
 | ||||
| static const SubGhzBlockConst subghz_protocol_linear_delta3_const = { | ||||
|     .te_short = 500, | ||||
|     .te_long = 2000, | ||||
|     .te_delta = 150, | ||||
|     .min_count_bit_for_found = 8, | ||||
| }; | ||||
| 
 | ||||
| struct SubGhzProtocolDecoderLinearDelta3 { | ||||
|     SubGhzProtocolDecoderBase base; | ||||
| 
 | ||||
|     SubGhzBlockDecoder decoder; | ||||
|     SubGhzBlockGeneric generic; | ||||
| 
 | ||||
|     uint32_t last_data; | ||||
| }; | ||||
| 
 | ||||
| struct SubGhzProtocolEncoderLinearDelta3 { | ||||
|     SubGhzProtocolEncoderBase base; | ||||
| 
 | ||||
|     SubGhzProtocolBlockEncoder encoder; | ||||
|     SubGhzBlockGeneric generic; | ||||
| }; | ||||
| 
 | ||||
| typedef enum { | ||||
|     LinearDecoderStepReset = 0, | ||||
|     LinearDecoderStepSaveDuration, | ||||
|     LinearDecoderStepCheckDuration, | ||||
| } LinearDecoderStep; | ||||
| 
 | ||||
| const SubGhzProtocolDecoder subghz_protocol_linear_delta3_decoder = { | ||||
|     .alloc = subghz_protocol_decoder_linear_delta3_alloc, | ||||
|     .free = subghz_protocol_decoder_linear_delta3_free, | ||||
| 
 | ||||
|     .feed = subghz_protocol_decoder_linear_delta3_feed, | ||||
|     .reset = subghz_protocol_decoder_linear_delta3_reset, | ||||
| 
 | ||||
|     .get_hash_data = subghz_protocol_decoder_linear_delta3_get_hash_data, | ||||
|     .serialize = subghz_protocol_decoder_linear_delta3_serialize, | ||||
|     .deserialize = subghz_protocol_decoder_linear_delta3_deserialize, | ||||
|     .get_string = subghz_protocol_decoder_linear_delta3_get_string, | ||||
| }; | ||||
| 
 | ||||
| const SubGhzProtocolEncoder subghz_protocol_linear_delta3_encoder = { | ||||
|     .alloc = subghz_protocol_encoder_linear_delta3_alloc, | ||||
|     .free = subghz_protocol_encoder_linear_delta3_free, | ||||
| 
 | ||||
|     .deserialize = subghz_protocol_encoder_linear_delta3_deserialize, | ||||
|     .stop = subghz_protocol_encoder_linear_delta3_stop, | ||||
|     .yield = subghz_protocol_encoder_linear_delta3_yield, | ||||
| }; | ||||
| 
 | ||||
| const SubGhzProtocol subghz_protocol_linear_delta3 = { | ||||
|     .name = SUBGHZ_PROTOCOL_LINEAR_DELTA3_NAME, | ||||
|     .type = SubGhzProtocolTypeStatic, | ||||
|     .flag = SubGhzProtocolFlag_315 | SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | | ||||
|             SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save | SubGhzProtocolFlag_Send, | ||||
| 
 | ||||
|     .decoder = &subghz_protocol_linear_delta3_decoder, | ||||
|     .encoder = &subghz_protocol_linear_delta3_encoder, | ||||
| }; | ||||
| 
 | ||||
| void* subghz_protocol_encoder_linear_delta3_alloc(SubGhzEnvironment* environment) { | ||||
|     UNUSED(environment); | ||||
|     SubGhzProtocolEncoderLinearDelta3* instance = | ||||
|         malloc(sizeof(SubGhzProtocolEncoderLinearDelta3)); | ||||
| 
 | ||||
|     instance->base.protocol = &subghz_protocol_linear_delta3; | ||||
|     instance->generic.protocol_name = instance->base.protocol->name; | ||||
| 
 | ||||
|     instance->encoder.repeat = 10; | ||||
|     instance->encoder.size_upload = 16; | ||||
|     instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); | ||||
|     instance->encoder.is_running = false; | ||||
|     return instance; | ||||
| } | ||||
| 
 | ||||
| void subghz_protocol_encoder_linear_delta3_free(void* context) { | ||||
|     furi_assert(context); | ||||
|     SubGhzProtocolEncoderLinearDelta3* instance = context; | ||||
|     free(instance->encoder.upload); | ||||
|     free(instance); | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|  * Generating an upload from data. | ||||
|  * @param instance Pointer to a SubGhzProtocolEncoderLinearDelta3 instance | ||||
|  * @return true On success | ||||
|  */ | ||||
| static bool | ||||
|     subghz_protocol_encoder_linear_delta3_get_upload(SubGhzProtocolEncoderLinearDelta3* instance) { | ||||
|     furi_assert(instance); | ||||
|     size_t index = 0; | ||||
|     size_t size_upload = (instance->generic.data_count_bit * 2); | ||||
|     if(size_upload > instance->encoder.size_upload) { | ||||
|         FURI_LOG_E(TAG, "Size upload exceeds allocated encoder buffer."); | ||||
|         return false; | ||||
|     } else { | ||||
|         instance->encoder.size_upload = size_upload; | ||||
|     } | ||||
| 
 | ||||
|     //Send key data
 | ||||
|     for(uint8_t i = instance->generic.data_count_bit; i > 1; i--) { | ||||
|         if(bit_read(instance->generic.data, i - 1)) { | ||||
|             //send bit 1
 | ||||
|             instance->encoder.upload[index++] = | ||||
|                 level_duration_make(true, (uint32_t)subghz_protocol_linear_delta3_const.te_short); | ||||
|             instance->encoder.upload[index++] = level_duration_make( | ||||
|                 false, (uint32_t)subghz_protocol_linear_delta3_const.te_short * 7); | ||||
|         } else { | ||||
|             //send bit 0
 | ||||
|             instance->encoder.upload[index++] = | ||||
|                 level_duration_make(true, (uint32_t)subghz_protocol_linear_delta3_const.te_long); | ||||
|             instance->encoder.upload[index++] = | ||||
|                 level_duration_make(false, (uint32_t)subghz_protocol_linear_delta3_const.te_long); | ||||
|         } | ||||
|     } | ||||
|     //Send end bit
 | ||||
|     if(bit_read(instance->generic.data, 0)) { | ||||
|         //send bit 1
 | ||||
|         instance->encoder.upload[index++] = | ||||
|             level_duration_make(true, (uint32_t)subghz_protocol_linear_delta3_const.te_short); | ||||
|         //Send PT_GUARD
 | ||||
|         instance->encoder.upload[index] = level_duration_make( | ||||
|             false, (uint32_t)subghz_protocol_linear_delta3_const.te_short * 73); | ||||
|     } else { | ||||
|         //send bit 0
 | ||||
|         instance->encoder.upload[index++] = | ||||
|             level_duration_make(true, (uint32_t)subghz_protocol_linear_delta3_const.te_long); | ||||
|         //Send PT_GUARD
 | ||||
|         instance->encoder.upload[index] = level_duration_make( | ||||
|             false, (uint32_t)subghz_protocol_linear_delta3_const.te_short * 70); | ||||
|     } | ||||
| 
 | ||||
|     return true; | ||||
| } | ||||
| 
 | ||||
| bool subghz_protocol_encoder_linear_delta3_deserialize( | ||||
|     void* context, | ||||
|     FlipperFormat* flipper_format) { | ||||
|     furi_assert(context); | ||||
|     SubGhzProtocolEncoderLinearDelta3* instance = context; | ||||
|     bool res = false; | ||||
|     do { | ||||
|         if(!subghz_block_generic_deserialize(&instance->generic, flipper_format)) { | ||||
|             FURI_LOG_E(TAG, "Deserialize error"); | ||||
|             break; | ||||
|         } | ||||
|         if(instance->generic.data_count_bit != | ||||
|            subghz_protocol_linear_delta3_const.min_count_bit_for_found) { | ||||
|             FURI_LOG_E(TAG, "Wrong number of bits in key"); | ||||
|             break; | ||||
|         } | ||||
|         //optional parameter parameter
 | ||||
|         flipper_format_read_uint32( | ||||
|             flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); | ||||
| 
 | ||||
|         if(!subghz_protocol_encoder_linear_delta3_get_upload(instance)) break; | ||||
|         instance->encoder.is_running = true; | ||||
| 
 | ||||
|         res = true; | ||||
|     } while(false); | ||||
| 
 | ||||
|     return res; | ||||
| } | ||||
| 
 | ||||
| void subghz_protocol_encoder_linear_delta3_stop(void* context) { | ||||
|     SubGhzProtocolEncoderLinearDelta3* instance = context; | ||||
|     instance->encoder.is_running = false; | ||||
| } | ||||
| 
 | ||||
| LevelDuration subghz_protocol_encoder_linear_delta3_yield(void* context) { | ||||
|     SubGhzProtocolEncoderLinearDelta3* instance = context; | ||||
| 
 | ||||
|     if(instance->encoder.repeat == 0 || !instance->encoder.is_running) { | ||||
|         instance->encoder.is_running = false; | ||||
|         return level_duration_reset(); | ||||
|     } | ||||
| 
 | ||||
|     LevelDuration ret = instance->encoder.upload[instance->encoder.front]; | ||||
| 
 | ||||
|     if(++instance->encoder.front == instance->encoder.size_upload) { | ||||
|         instance->encoder.repeat--; | ||||
|         instance->encoder.front = 0; | ||||
|     } | ||||
| 
 | ||||
|     return ret; | ||||
| } | ||||
| 
 | ||||
| void* subghz_protocol_decoder_linear_delta3_alloc(SubGhzEnvironment* environment) { | ||||
|     UNUSED(environment); | ||||
|     SubGhzProtocolDecoderLinearDelta3* instance = | ||||
|         malloc(sizeof(SubGhzProtocolDecoderLinearDelta3)); | ||||
|     instance->base.protocol = &subghz_protocol_linear_delta3; | ||||
|     instance->generic.protocol_name = instance->base.protocol->name; | ||||
|     return instance; | ||||
| } | ||||
| 
 | ||||
| void subghz_protocol_decoder_linear_delta3_free(void* context) { | ||||
|     furi_assert(context); | ||||
|     SubGhzProtocolDecoderLinearDelta3* instance = context; | ||||
|     free(instance); | ||||
| } | ||||
| 
 | ||||
| void subghz_protocol_decoder_linear_delta3_reset(void* context) { | ||||
|     furi_assert(context); | ||||
|     SubGhzProtocolDecoderLinearDelta3* instance = context; | ||||
|     instance->decoder.parser_step = LinearDecoderStepReset; | ||||
|     instance->last_data = 0; | ||||
| } | ||||
| 
 | ||||
| void subghz_protocol_decoder_linear_delta3_feed(void* context, bool level, uint32_t duration) { | ||||
|     furi_assert(context); | ||||
|     SubGhzProtocolDecoderLinearDelta3* instance = context; | ||||
|     switch(instance->decoder.parser_step) { | ||||
|     case LinearDecoderStepReset: | ||||
|         if((!level) && | ||||
|            (DURATION_DIFF(duration, subghz_protocol_linear_delta3_const.te_short * 70) < | ||||
|             subghz_protocol_linear_delta3_const.te_delta * 24)) { | ||||
|             //Found header Linear
 | ||||
|             instance->decoder.decode_data = 0; | ||||
|             instance->decoder.decode_count_bit = 0; | ||||
|             instance->decoder.parser_step = LinearDecoderStepSaveDuration; | ||||
|         } | ||||
|         break; | ||||
|     case LinearDecoderStepSaveDuration: | ||||
|         if(level) { | ||||
|             instance->decoder.te_last = duration; | ||||
|             instance->decoder.parser_step = LinearDecoderStepCheckDuration; | ||||
|         } else { | ||||
|             instance->decoder.parser_step = LinearDecoderStepReset; | ||||
|         } | ||||
|         break; | ||||
|     case LinearDecoderStepCheckDuration: | ||||
|         if(!level) { | ||||
|             if(duration >= (subghz_protocol_linear_delta3_const.te_short * 10)) { | ||||
|                 instance->decoder.parser_step = LinearDecoderStepReset; | ||||
|                 if(DURATION_DIFF( | ||||
|                        instance->decoder.te_last, subghz_protocol_linear_delta3_const.te_short) < | ||||
|                    subghz_protocol_linear_delta3_const.te_delta) { | ||||
|                     subghz_protocol_blocks_add_bit(&instance->decoder, 1); | ||||
|                 } else if( | ||||
|                     DURATION_DIFF( | ||||
|                         instance->decoder.te_last, subghz_protocol_linear_delta3_const.te_long) < | ||||
|                     subghz_protocol_linear_delta3_const.te_delta) { | ||||
|                     subghz_protocol_blocks_add_bit(&instance->decoder, 0); | ||||
|                 } | ||||
|                 if(instance->decoder.decode_count_bit == | ||||
|                    subghz_protocol_linear_delta3_const.min_count_bit_for_found) { | ||||
|                     if((instance->last_data == instance->decoder.decode_data) && | ||||
|                        instance->last_data) { | ||||
|                         instance->generic.serial = 0x0; | ||||
|                         instance->generic.btn = 0x0; | ||||
| 
 | ||||
|                         instance->generic.data = instance->decoder.decode_data; | ||||
|                         instance->generic.data_count_bit = instance->decoder.decode_count_bit; | ||||
| 
 | ||||
|                         if(instance->base.callback) | ||||
|                             instance->base.callback(&instance->base, instance->base.context); | ||||
|                     } | ||||
|                     instance->decoder.parser_step = LinearDecoderStepSaveDuration; | ||||
|                     instance->last_data = instance->decoder.decode_data; | ||||
|                 } | ||||
|                 break; | ||||
|             } | ||||
| 
 | ||||
|             if((DURATION_DIFF( | ||||
|                     instance->decoder.te_last, subghz_protocol_linear_delta3_const.te_short) < | ||||
|                 subghz_protocol_linear_delta3_const.te_delta) && | ||||
|                (DURATION_DIFF(duration, subghz_protocol_linear_delta3_const.te_short * 7) < | ||||
|                 subghz_protocol_linear_delta3_const.te_delta)) { | ||||
|                 subghz_protocol_blocks_add_bit(&instance->decoder, 1); | ||||
|                 instance->decoder.parser_step = LinearDecoderStepSaveDuration; | ||||
|             } else if( | ||||
|                 (DURATION_DIFF( | ||||
|                      instance->decoder.te_last, subghz_protocol_linear_delta3_const.te_long) < | ||||
|                  subghz_protocol_linear_delta3_const.te_delta) && | ||||
|                 (DURATION_DIFF(duration, subghz_protocol_linear_delta3_const.te_long) < | ||||
|                  subghz_protocol_linear_delta3_const.te_delta)) { | ||||
|                 subghz_protocol_blocks_add_bit(&instance->decoder, 0); | ||||
|                 instance->decoder.parser_step = LinearDecoderStepSaveDuration; | ||||
|             } else { | ||||
|                 instance->decoder.parser_step = LinearDecoderStepReset; | ||||
|             } | ||||
| 
 | ||||
|         } else { | ||||
|             instance->decoder.parser_step = LinearDecoderStepReset; | ||||
|         } | ||||
|         break; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| uint8_t subghz_protocol_decoder_linear_delta3_get_hash_data(void* context) { | ||||
|     furi_assert(context); | ||||
|     SubGhzProtocolDecoderLinearDelta3* instance = context; | ||||
|     return subghz_protocol_blocks_get_hash_data( | ||||
|         &instance->decoder, (instance->decoder.decode_count_bit / 8)); | ||||
| } | ||||
| 
 | ||||
| bool subghz_protocol_decoder_linear_delta3_serialize( | ||||
|     void* context, | ||||
|     FlipperFormat* flipper_format, | ||||
|     SubGhzRadioPreset* preset) { | ||||
|     furi_assert(context); | ||||
|     SubGhzProtocolDecoderLinearDelta3* instance = context; | ||||
|     return subghz_block_generic_serialize(&instance->generic, flipper_format, preset); | ||||
| } | ||||
| 
 | ||||
| bool subghz_protocol_decoder_linear_delta3_deserialize( | ||||
|     void* context, | ||||
|     FlipperFormat* flipper_format) { | ||||
|     furi_assert(context); | ||||
|     SubGhzProtocolDecoderLinearDelta3* instance = context; | ||||
|     bool ret = false; | ||||
|     do { | ||||
|         if(!subghz_block_generic_deserialize(&instance->generic, flipper_format)) { | ||||
|             break; | ||||
|         } | ||||
|         if(instance->generic.data_count_bit != | ||||
|            subghz_protocol_linear_delta3_const.min_count_bit_for_found) { | ||||
|             FURI_LOG_E(TAG, "Wrong number of bits in key"); | ||||
|             break; | ||||
|         } | ||||
|         ret = true; | ||||
|     } while(false); | ||||
|     return ret; | ||||
| } | ||||
| 
 | ||||
| void subghz_protocol_decoder_linear_delta3_get_string(void* context, FuriString* output) { | ||||
|     furi_assert(context); | ||||
|     SubGhzProtocolDecoderLinearDelta3* instance = context; | ||||
| 
 | ||||
|     uint32_t data = instance->generic.data & 0xFF; | ||||
| 
 | ||||
|     furi_string_cat_printf( | ||||
|         output, | ||||
|         "%s %dbit\r\n" | ||||
|         "Key:0x%lX\r\n" | ||||
|         "DIP:" DIP_PATTERN "\r\n", | ||||
|         instance->generic.protocol_name, | ||||
|         instance->generic.data_count_bit, | ||||
|         data, | ||||
|         DATA_TO_DIP(data)); | ||||
| } | ||||
							
								
								
									
										111
									
								
								lib/subghz/protocols/linear_delta3.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										111
									
								
								lib/subghz/protocols/linear_delta3.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,111 @@ | ||||
| #pragma once | ||||
| 
 | ||||
| #include "base.h" | ||||
| 
 | ||||
| #define SUBGHZ_PROTOCOL_LINEAR_DELTA3_NAME "LinearDelta3" | ||||
| 
 | ||||
| typedef struct SubGhzProtocolDecoderLinearDelta3 SubGhzProtocolDecoderLinearDelta3; | ||||
| typedef struct SubGhzProtocolEncoderLinearDelta3 SubGhzProtocolEncoderLinearDelta3; | ||||
| 
 | ||||
| extern const SubGhzProtocolDecoder subghz_protocol_linear_delta3_decoder; | ||||
| extern const SubGhzProtocolEncoder subghz_protocol_linear_delta3_encoder; | ||||
| extern const SubGhzProtocol subghz_protocol_linear_delta3; | ||||
| 
 | ||||
| /**
 | ||||
|  * Allocate SubGhzProtocolEncoderLinearDelta3. | ||||
|  * @param environment Pointer to a SubGhzEnvironment instance | ||||
|  * @return SubGhzProtocolEncoderLinearDelta3* pointer to a SubGhzProtocolEncoderLinearDelta3 instance | ||||
|  */ | ||||
| void* subghz_protocol_encoder_linear_delta3_alloc(SubGhzEnvironment* environment); | ||||
| 
 | ||||
| /**
 | ||||
|  * Free SubGhzProtocolEncoderLinearDelta3. | ||||
|  * @param context Pointer to a SubGhzProtocolEncoderLinearDelta3 instance | ||||
|  */ | ||||
| void subghz_protocol_encoder_linear_delta3_free(void* context); | ||||
| 
 | ||||
| /**
 | ||||
|  * Deserialize and generating an upload to send. | ||||
|  * @param context Pointer to a SubGhzProtocolEncoderLinearDelta3 instance | ||||
|  * @param flipper_format Pointer to a FlipperFormat instance | ||||
|  * @return true On success | ||||
|  */ | ||||
| bool subghz_protocol_encoder_linear_delta3_deserialize( | ||||
|     void* context, | ||||
|     FlipperFormat* flipper_format); | ||||
| 
 | ||||
| /**
 | ||||
|  * Forced transmission stop. | ||||
|  * @param context Pointer to a SubGhzProtocolEncoderLinearDelta3 instance | ||||
|  */ | ||||
| void subghz_protocol_encoder_linear_delta3_stop(void* context); | ||||
| 
 | ||||
| /**
 | ||||
|  * Getting the level and duration of the upload to be loaded into DMA. | ||||
|  * @param context Pointer to a SubGhzProtocolEncoderLinearDelta3 instance | ||||
|  * @return LevelDuration  | ||||
|  */ | ||||
| LevelDuration subghz_protocol_encoder_linear_delta3_yield(void* context); | ||||
| 
 | ||||
| /**
 | ||||
|  * Allocate SubGhzProtocolDecoderLinearDelta3. | ||||
|  * @param environment Pointer to a SubGhzEnvironment instance | ||||
|  * @return SubGhzProtocolDecoderLinearDelta3* pointer to a SubGhzProtocolDecoderLinearDelta3 instance | ||||
|  */ | ||||
| void* subghz_protocol_decoder_linear_delta3_alloc(SubGhzEnvironment* environment); | ||||
| 
 | ||||
| /**
 | ||||
|  * Free SubGhzProtocolDecoderLinearDelta3. | ||||
|  * @param context Pointer to a SubGhzProtocolDecoderLinearDelta3 instance | ||||
|  */ | ||||
| void subghz_protocol_decoder_linear_delta3_free(void* context); | ||||
| 
 | ||||
| /**
 | ||||
|  * Reset decoder SubGhzProtocolDecoderLinearDelta3. | ||||
|  * @param context Pointer to a SubGhzProtocolDecoderLinearDelta3 instance | ||||
|  */ | ||||
| void subghz_protocol_decoder_linear_delta3_reset(void* context); | ||||
| 
 | ||||
| /**
 | ||||
|  * Parse a raw sequence of levels and durations received from the air. | ||||
|  * @param context Pointer to a SubGhzProtocolDecoderLinearDelta3 instance | ||||
|  * @param level Signal level true-high false-low | ||||
|  * @param duration Duration of this level in, us | ||||
|  */ | ||||
| void subghz_protocol_decoder_linear_delta3_feed(void* context, bool level, uint32_t duration); | ||||
| 
 | ||||
| /**
 | ||||
|  * Getting the hash sum of the last randomly received parcel. | ||||
|  * @param context Pointer to a SubGhzProtocolDecoderLinearDelta3 instance | ||||
|  * @return hash Hash sum | ||||
|  */ | ||||
| uint8_t subghz_protocol_decoder_linear_delta3_get_hash_data(void* context); | ||||
| 
 | ||||
| /**
 | ||||
|  * Serialize data SubGhzProtocolDecoderLinearDelta3. | ||||
|  * @param context Pointer to a SubGhzProtocolDecoderLinearDelta3 instance | ||||
|  * @param flipper_format Pointer to a FlipperFormat instance | ||||
|  * @param preset The modulation on which the signal was received, SubGhzRadioPreset | ||||
|  * @return true On success | ||||
|  */ | ||||
| bool subghz_protocol_decoder_linear_delta3_serialize( | ||||
|     void* context, | ||||
|     FlipperFormat* flipper_format, | ||||
|     SubGhzRadioPreset* preset); | ||||
| 
 | ||||
| /**
 | ||||
|  * Deserialize data SubGhzProtocolDecoderLinearDelta3. | ||||
|  * @param context Pointer to a SubGhzProtocolDecoderLinearDelta3 instance | ||||
|  * @param flipper_format Pointer to a FlipperFormat instance | ||||
|  * @return true On success | ||||
|  */ | ||||
| bool subghz_protocol_decoder_linear_delta3_deserialize( | ||||
|     void* context, | ||||
|     FlipperFormat* flipper_format); | ||||
| 
 | ||||
| /**
 | ||||
|  * Getting a textual representation of the received data. | ||||
|  * @param context Pointer to a SubGhzProtocolDecoderLinearDelta3 instance | ||||
|  * @param output Resulting text | ||||
|  */ | ||||
| void subghz_protocol_decoder_linear_delta3_get_string(void* context, FuriString* output); | ||||
| @ -1,19 +1,44 @@ | ||||
| #include "protocol_items.h" | ||||
| 
 | ||||
| const SubGhzProtocol* subghz_protocol_registry_items[] = { | ||||
|     &subghz_protocol_gate_tx,       &subghz_protocol_keeloq,      &subghz_protocol_star_line, | ||||
|     &subghz_protocol_nice_flo,      &subghz_protocol_came,        &subghz_protocol_faac_slh, | ||||
|     &subghz_protocol_nice_flor_s,   &subghz_protocol_came_twee,   &subghz_protocol_came_atomo, | ||||
|     &subghz_protocol_nero_sketch,   &subghz_protocol_ido,         &subghz_protocol_kia, | ||||
|     &subghz_protocol_hormann,       &subghz_protocol_nero_radio,  &subghz_protocol_somfy_telis, | ||||
|     &subghz_protocol_somfy_keytis,  &subghz_protocol_scher_khan,  &subghz_protocol_princeton, | ||||
|     &subghz_protocol_raw,           &subghz_protocol_linear,      &subghz_protocol_secplus_v2, | ||||
|     &subghz_protocol_secplus_v1,    &subghz_protocol_megacode,    &subghz_protocol_holtek, | ||||
|     &subghz_protocol_chamb_code,    &subghz_protocol_power_smart, &subghz_protocol_marantec, | ||||
|     &subghz_protocol_bett,          &subghz_protocol_doitrand,    &subghz_protocol_phoenix_v2, | ||||
|     &subghz_protocol_honeywell_wdb, &subghz_protocol_magellan,    &subghz_protocol_intertechno_v3, | ||||
|     &subghz_protocol_clemsa,        &subghz_protocol_ansonic,     &subghz_protocol_smc5326, | ||||
|     &subghz_protocol_gate_tx, | ||||
|     &subghz_protocol_keeloq, | ||||
|     &subghz_protocol_star_line, | ||||
|     &subghz_protocol_nice_flo, | ||||
|     &subghz_protocol_came, | ||||
|     &subghz_protocol_faac_slh, | ||||
|     &subghz_protocol_nice_flor_s, | ||||
|     &subghz_protocol_came_twee, | ||||
|     &subghz_protocol_came_atomo, | ||||
|     &subghz_protocol_nero_sketch, | ||||
|     &subghz_protocol_ido, | ||||
|     &subghz_protocol_kia, | ||||
|     &subghz_protocol_hormann, | ||||
|     &subghz_protocol_nero_radio, | ||||
|     &subghz_protocol_somfy_telis, | ||||
|     &subghz_protocol_somfy_keytis, | ||||
|     &subghz_protocol_scher_khan, | ||||
|     &subghz_protocol_princeton, | ||||
|     &subghz_protocol_raw, | ||||
|     &subghz_protocol_linear, | ||||
|     &subghz_protocol_secplus_v2, | ||||
|     &subghz_protocol_secplus_v1, | ||||
|     &subghz_protocol_megacode, | ||||
|     &subghz_protocol_holtek, | ||||
|     &subghz_protocol_chamb_code, | ||||
|     &subghz_protocol_power_smart, | ||||
|     &subghz_protocol_marantec, | ||||
|     &subghz_protocol_bett, | ||||
|     &subghz_protocol_doitrand, | ||||
|     &subghz_protocol_phoenix_v2, | ||||
|     &subghz_protocol_honeywell_wdb, | ||||
|     &subghz_protocol_magellan, | ||||
|     &subghz_protocol_intertechno_v3, | ||||
|     &subghz_protocol_clemsa, | ||||
|     &subghz_protocol_ansonic, | ||||
|     &subghz_protocol_smc5326, | ||||
|     &subghz_protocol_holtek_th12x, | ||||
|     &subghz_protocol_linear_delta3, | ||||
| }; | ||||
| 
 | ||||
| const SubGhzProtocolRegistry subghz_protocol_registry = { | ||||
|  | ||||
| @ -21,6 +21,7 @@ | ||||
| #include "gate_tx.h" | ||||
| #include "raw.h" | ||||
| #include "linear.h" | ||||
| #include "linear_delta3.h" | ||||
| #include "secplus_v2.h" | ||||
| #include "secplus_v1.h" | ||||
| #include "megacode.h" | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Brandon Weeks
						Brandon Weeks