diff --git a/applications/main/subghz/helpers/subghz_custom_event.h b/applications/main/subghz/helpers/subghz_custom_event.h index e52cf1897..4fb40f5c0 100644 --- a/applications/main/subghz/helpers/subghz_custom_event.h +++ b/applications/main/subghz/helpers/subghz_custom_event.h @@ -71,6 +71,7 @@ typedef enum { SetTypeBFTMitto, SetTypeSomfyTelis, SetTypeKingGatesStylo4k, + SetTypeBenincaARC, SetTypeANMotorsAT4, SetTypeAlutechAT4N, SetTypePhoenix_V2_433, diff --git a/applications/main/subghz/helpers/subghz_gen_info.c b/applications/main/subghz/helpers/subghz_gen_info.c index 388327da2..a0f07a1d8 100644 --- a/applications/main/subghz/helpers/subghz_gen_info.c +++ b/applications/main/subghz/helpers/subghz_gen_info.c @@ -532,6 +532,15 @@ void subghz_scene_set_type_fill_generation_infos(GenInfo* infos_dest, SetType ty .kinggates_stylo_4k.btn = 0x0E, .kinggates_stylo_4k.cnt = 0x03}; break; + case SetTypeBenincaARC: + gen_info = (GenInfo){ + .type = GenBenincaARC, + .mod = "AM650", + .freq = 433920000, + .beninca_arc.serial = key & 0x00FFFFFF, + .beninca_arc.btn = 0x02, + .beninca_arc.cnt = 0x03}; + break; case SetTypeMotorline433: gen_info = (GenInfo){ .type = GenKeeloq, diff --git a/applications/main/subghz/helpers/subghz_gen_info.h b/applications/main/subghz/helpers/subghz_gen_info.h index f54992738..e47c218d6 100644 --- a/applications/main/subghz/helpers/subghz_gen_info.h +++ b/applications/main/subghz/helpers/subghz_gen_info.h @@ -11,6 +11,7 @@ typedef enum { GenAlutechAt4n, GenSomfyTelis, GenKingGatesStylo4k, + GenBenincaARC, GenNiceFlorS, GenSecPlus1, GenSecPlus2, @@ -67,6 +68,11 @@ typedef struct { uint8_t btn; uint16_t cnt; } kinggates_stylo_4k; + struct { + uint32_t serial; + uint8_t btn; + uint32_t cnt; + } beninca_arc; struct { uint32_t serial; uint8_t btn; diff --git a/applications/main/subghz/helpers/subghz_txrx_create_protocol_key.c b/applications/main/subghz/helpers/subghz_txrx_create_protocol_key.c index 1c0add497..075720dfc 100644 --- a/applications/main/subghz/helpers/subghz_txrx_create_protocol_key.c +++ b/applications/main/subghz/helpers/subghz_txrx_create_protocol_key.c @@ -365,6 +365,36 @@ bool subghz_txrx_gen_kinggates_stylo_4k_protocol( return res; } +bool subghz_txrx_gen_beninca_arc_protocol( + void* context, + const char* preset_name, + uint32_t frequency, + uint32_t serial, + uint8_t btn, + uint32_t cnt) { + SubGhzTxRx* txrx = context; + + bool res = false; + + txrx->transmitter = + subghz_transmitter_alloc_init(txrx->environment, SUBGHZ_PROTOCOL_BENINCA_ARC_NAME); + subghz_txrx_set_preset(txrx, preset_name, frequency, NULL, 0); + + if(txrx->transmitter && subghz_protocol_beninca_arc_create_data( + subghz_transmitter_get_protocol_instance(txrx->transmitter), + txrx->fff_data, + serial, + btn, + cnt, + txrx->preset)) { + res = true; + } + + subghz_transmitter_free(txrx->transmitter); + + return res; +} + bool subghz_txrx_gen_secplus_v2_protocol( SubGhzTxRx* instance, const char* name_preset, diff --git a/applications/main/subghz/helpers/subghz_txrx_create_protocol_key.h b/applications/main/subghz/helpers/subghz_txrx_create_protocol_key.h index 590f9fa5b..afc1059b5 100644 --- a/applications/main/subghz/helpers/subghz_txrx_create_protocol_key.h +++ b/applications/main/subghz/helpers/subghz_txrx_create_protocol_key.h @@ -116,6 +116,14 @@ bool subghz_txrx_gen_kinggates_stylo_4k_protocol( uint8_t btn, uint16_t cnt); +bool subghz_txrx_gen_beninca_arc_protocol( + void* context, + const char* preset_name, + uint32_t frequency, + uint32_t serial, + uint8_t btn, + uint32_t cnt); + bool subghz_txrx_gen_came_atomo_protocol( void* context, const char* preset_name, diff --git a/applications/main/subghz/resources/subghz/assets/keeloq_mfcodes b/applications/main/subghz/resources/subghz/assets/keeloq_mfcodes index fddea5abd..b55548844 100644 --- a/applications/main/subghz/resources/subghz/assets/keeloq_mfcodes +++ b/applications/main/subghz/resources/subghz/assets/keeloq_mfcodes @@ -1,70 +1,71 @@ Filetype: Flipper SubGhz Keystore File Version: 0 Encryption: 1 -IV: 46 75 72 72 79 20 49 56 20 4F 77 4F 20 55 77 55 -30A13FCF86676F7027AF9D7BECBAA6A08C83B0DB00E4FFFB6F53249D0EA057AD -2D3AA216E454121B2C4DAC9EEE2502ECADCDC0B29C383102CDD7A078ED813A6C -B08365492BC7FBAE96B0A38FFAE7DF72E86BA1979860585582D69FF740E85C1A -7FA151F83A3550AB4EF7710325E54525A59DC499F2CE53885F886C1E848C6A18 -CFAB501321D7EF01946308915B43EBB7FDACBDBFC7BDD797437B6F2797225609E13738CD0D90A2C4A1432FA9E34618C3 -322A0030702A3930977D1AD1C762356161F3402BFA6435F184F14BFBDAEC3F4A -BAB2E4702DA0FC7D0BA9581A04A1728D2FD9B986E4B180550BBC59DF1B04BC0A -CD87059AE7E0CA962065FBDF55EDBBD45253D5A01B714EDF28F7744F11A35C65 -6226EDFC8F7C7C51A06FADAF98241EE92CA2E827217AEB7A2C917DE431BC91A4 -057FEF7D36FF24D3C5F6C59FBA9C09197575E1A6E674A73692CCF8118C6B3C6E -5BA3EB99D621A7DD9D2EBBC4A24CE935D29A78EB200D82ED295B4ABBB6425525F82A502A09ECC9C310401BEF7E354CDD -8303490AC2E6576FF1E159342754AC45B38323836D1164AFDEE2578F5B70C70229A7DB64FB5283DA4F83A616AB11E394 -79208032CC01AA421851310727CCF2E81448671AFA07D7156C2C40707787C856 -9846F3ACF236D210A0AD138B3949A3CDA9A2E841F11BF9F531F299B33FD97B40 -6BD0CCA70D86E2D71645D2E6C223B2AF501ED9A5EDA24643FC90AAC7C3840E4E -69D9A4E90065AA5A1D7A6E40FBB2FC6BF4A72CF591E1FD51822A8B59CB6DBB22 -9032CDF1F5AF42EEE6121DFFA12F578F2088D25B9F260357E02590B19560462980D11A81462AD23D61A7927D2ECCF49B -1528C0F81E0F0510AA65D07C61EB29149C7238F474B3512F4BEDB0C4BA4966BB -80ADFA97303DA2907FC982E705DB45902BB251E08EC322B5429F70EDC6D7E2C9 -561F49B1A85F2FD839FC022ABD22A11E036891FC8B52220BFDE7194192C43F173637F76FFA1AEE4A4344647886EE3E3B -0AAFA120E57966064AFCD0B3F3571CE92118379160131C646B0E46262E4844883111DF28B2B17A46750D481216375055 -45E76A7B85593DCA6E0A9A71067AA0031590CA4C60161887D8E6BE54F254128A -537091AC4E7FD1841E03B352B1E62855AD26233DE167087A7F818804EA9DA56D -84DE10BB68269D0BF1723F29A683569F0D17FE247898C76523E6155AD4931195 -CF16625381ADFBEA6D89142A13CDA19FEA8345511692A0FBBA66E178BAF8126E -D25962A77350E7B7222983150A1C92053364F9954142A85AEA4FEC1D3B524C71 -A76F292F18E464511FD3232B604893985F9A823BBD9D73B2D84E43D4BDF7C5A8 -F92496E57B1B0F57C155ED15A6CBDDBF6A9C309A3A3B2B2D3118E51F8B8B718B -E59C00F03AA3DA0B961E04ACE90E85005DB3C4E402BF9A280775BCE9FC7EDE05 -494CB3B66A924E90DD180A96F77182F708C7CCC3E379D302D436FED839EBEEDB -D93838B8AC08491FE0F29EC5077F5BAB6F75DAE77C6F305A963F0555346B9EE1 -569E5F5EA968A636C657D009525BB3C416546D19ADDC05B9D005B023B0957DFA -A16CE196104A013E064663AE9DD0393BBF87E4FAFA1489C6ABA367928A2905F7 -4FF57FB9C064CCC452473D0713E0EE17EA85726CD00203F359252ABE613BF054 -C489D64C0CF7535117D21461EDC3FEBEDAFD2D2E55C0DC87943E9E8D0461EB60 -F9BB5CBF9E514F5B2918880D8336C2552D67346C5365DFAB816517F1793D26E3 -7258ACEBE2090849F6756E6033A7F92AD3D75D753C0438F266B22F270FA5535A -0B4CF3F92742FF775A14B66540FBC214F455CD992DFCEEF925EB0E38B21745A3 -5B17E197557BACB4C355F23D28C22280F9860A756CE2FC0959F1B07B9A6572A9 -0067A9EB86AEE637DA8E9E03512D1129252F5C530602B03D5C3383E0744F23BD -658FEA8B449D1EC5530FACBCDE3E3DF6CB0644B49D96C3FE1231FCDACE266BC1 -11325D0A765463419D6623C69961A0071EDA461E14C940326F1CA36339C946CD -007D6143BABAFFF19D77CC57E15AB4351C1D102856CB182F3F512EEFCD6FDF4F -CB97161DDE414D6D4D96FF726F73FF3AD0D71F9768EA6BBBFF08ABABB33A15B2 -A558FB601E42FAC986D0421446C7C898A9BDB0711FFB872B333CBEE9FC560DB9D7C790C502E59A29F493A2EC1EBA3FA5 -65E772E08F92E50C8151AA99FCA8D27F35D5F90C1CD45D098C5654C8046649F0 -DCB929C33CB3E4D28029D0E50C146074714CEFC765BE475B324F4D8DCBCDA931 -0ACC1EC04B63A689270904860E1EC3BF8E7F1DB1B18FBDD460AAE6148641894F -CE96406CECA957184499060DEF5FA7F0E956BC6B120B60DB1DCCB0F665F455E4 -D8C0B7CFDD3D20F58112660C08B236040242BCB1CF1FA5CFC66A6382282D2340 -D5E0F33DDD03D11AC90D33A230AA77A9ACB7C239520EE5A95587700CD87AF5C7 -D095F39B66EFAEECAAA2B9D4EC0AAEE6EA0749B2F12C17B38D96DC0197DECAD9 -E52D638ADD750B0231738F751EB97C2724877E184C365F9761F5995BCFD6F812 -EFA069F75B0A4B3FD6E6B8845E4A466BE092C746F6F574118AE435A32550464E -6FBFBD47F3EC4846E946121A54042E418C4A98E5EEF4F8D8C667EC2A774EBEA2 -0A73F468C6F8C4E8CF4934A28DF83972CCF41905562A2AEE79BCADD9CFC11F00 -73AD62A6660287252396902D6F80557772B64E4D6B16E1635489F985E54CFBED -942F89D0520D08B20973D8560F89C8DA8111842DB867EBC51B9F5451AC942EE7 -4FFA3EC48275D44C1A3FE528546FCA0D6E44262BADDA765B71E19863F0337C59 -484C420725B919EF3F2D3D9887175C3EE58CA17E8AD9588AC4EC241A7B91FB96 -39C3E86438AC72575B8BC7F9C2108D1C40AD56D920C0F820D6D92416AFB6244B -D0B3CD5D299820AF61BB4782746750056A7D212B9595424D6E50BFAEBCB089951090BD09D4C0B1F4D357C3FAFE6E73A9 -BB441902B1078F7F3D5E1F2BC5546E242C4E27B49149D3E1A54C20B6FD9EC56A -78C4CF85F6DB0CD63CB72A9B118C5DCE8EE7E6CC15A4312ACEC0B6503738325C -DE92516887651C73E89E2CE0D64DEE236E235C7CCBF0D14FE291D8793782616D -74F855306E36A0DA5B0FFF097CB69AAB34DEF3CF3D2DFFCF1A80447D6CC057A438AA4FBCB631F476FE568E9BA941ED2B +IV: 4F 77 4F 20 66 75 72 72 79 20 49 56 20 55 77 55 +1D0560740B25F58EE0E85BF949139971E5AA08C5499CC74B11992D124C281012 +C05E2D2C715D8E24C518EF2841DA02173C05DD5BA5310EE85D09709500DB1726 +9EA5721836369FF918859077F50E33100F7AC53E8E8F31E25296579F875359DF +D2A8AD1B65BC66B459525124CDC5011C79D98F542702FC69EABD64F908C0D80D +2FA5F078BEB59851D42BC7E4E331AE3A8C384892DF003238CDA82450A6CD02AC +E54ED5F49A093BC938521195C86FECF35FB6EC463C54C6E1609592DC5FA03CCB5E1EDA362FC9AB008C85E66B60147EBA +048F4A28B18496487D65A924F4E37766C3563F41090D442DE61D7A5DD82F5FF1 +DA876A11401727E5102B578F87CCF9596AB9D9925FC90CDF99C9DEC7261B2C8C +03D3842335D69A3AA42452274130B3FAAEE6087CB8D783B0E770062C034BB302 +7F50401E9FFAF10D1F61067C2E830EBBEC7C8B3B20F5C0AC2E10E68912BF2C82 +160BC0CA2FF01E076830F29846C1F6CCBAC7857F2043E8163449048BA8C99AA8 +09357F089CB148DDC578E0F11EC10659EF68A57440700F584922CB9842E2BF08AC977CCAA11355E89FA5C18113349F5E +910D166F40F264225BD4C8EB16C5CC6374F8F8E1202D5BF28FA2E8BA38E420A36E67611E6D151051F7C74843E4A72BBC +D9ACEBC528D7CA74B894A0378095E03C9BDBBE13DDA3FCD6D60CD3CAC49746B8 +90F94FD262E1859B7E5C08E7ED5B16CDB56D0E930034E315CD011DE3759150DA +6620E176FC61DF250EF2BBC2AB27E0DA45A6E1E27F4E94405EE01C36E892EFBF +7D6A062453236E4C353F19B875D079157D016B223B7D429C8F5BEA9D0F703EED +20631589CB541B32C23CA7EA93B12E2016B5A90A2C9CAA6F5849C0B67158EA635858F26A86282C124AEA3FD31B7FD365 +E6CF167CEA0639D1504E0BFC8BAAA7FC7FA36A2286CBBE1312803422018A9F00 +0EB81E23FF37366BA4890CBD46BC8AF5A2CD56E9802B8DF5CDDD5114F677CDF6 +62195292F6F920DAF91F812FC3B94E8539C157D35D3BC94F2FB7A8481406C655AC0F112C4E10AC36892D43D95827BC1D +65FB9BEBDB9BE975168D47B02CA8A2E0ADE2CD1949E90B06689B0475395663BD5AF3C8FEC42C4138CBBB8956AC55B475 +EF0A6961C754FCDBAE0222099DD8AA38DD6A92BCD53A576E105BC5BBD23400B7 +A608752C8602A5BD538441DE046DD7AE011FBA87210B57372BCBB471ECC2B720 +222C83DDC445F72152E563CD068851389364C1D83C9F7D6353325EFD553560B1 +96977544F2F821408C1A88FADB9B1E12D9CA97638A622190F83BC640508B6029 +B596A98BDDA5BD2FF1F812BE67FD00456D4D313E9497147E2439B51972B6B752 +FC276CAC90756F397C3BC616631CE8B9257E6C25D0DC15C5ED1CEB439ACF04D9 +383DD624B98E650E5B4BA28990B4D1912B785C689E6B6A05D77B47B6501CD98F +410814DC8B38DD6EF781B55CA02730092F252082A77400AD90F22BF45A41C849 +8DA240E13E8B512B50FF4504A61037D0A3920B00523D51EEF9996CC3907C175E +E655B7C31E346154C5EF7C59E3A710A2A2F145E7403E4ADB388B3A27D6FF59DE +E2FB7F96EA16B20589995E95D0959B4ECC1EDDF86E347EB85FD29D0D5933A2A1 +00D910F2B050900735A8446220FF7321813252862A69C05A7A534118E50E61DB +BA1B9E7E26E04542183F085060421553CDD3FD9034AAAFCB7EE980A68B98087E +216EBA33FCE4B834BF64621E557923D8AE41F5895266B7BBDFCA6EAF985F036E +2E9075A45ED6D86C172C9ADAAF5E991DA8DA9CBF2F24D746D22A331E236FBA4A +04E4B185C150AF45A67E15D68282C7558B13BFFB05BFCB71BCFD2B92DE5D9701 +1FDC4D759EA89681F76A8F7D336118FE6801EFD10D73925C2749775D9DFED282 +FFB32167FBF860418AAABF29B0D4FEF57BB07454ECF4BD2CF175D44E84C04CED +7C6E419658872D298F2E7B02568B9ED870FDFFE5082ED0BBE689FD04EFFFE7E7 +ADAB0F3108398C75ECC6D2E572960B5685C336DDF3D6F5B9C12D069F27BA15A8 +DAC772C1A81181738CDB8C0E89C2E5B7A57E2DA65CA15232DE96A3C4A599A0E9 +7F6204274D90E88B3F5D5AC86EEEE76C27C0D083E79ADA7BCF7D060FE6F05A3E +5BAB4CCB593418CD8965C09C0925EDB78BB4C8A10892F264DF12F50E532F006E +7C67525C921ABAEC4BFAA376162A7B2B2827AE4C9840DC37F067FE3B72BE7304B6EEB5FB1AD17CFF5F079EFECC04AD56 +94FF6DD4CE63381778E86E61423EDDDD9CC71C3462D66F1AD9A0AD5D378AECE2 +E9CA5BA5C6D6101EA3A51F28E48D49789D60273A9F70D56020D003265517AFA3 +EBF55649D226E9FDAAB57C2E1D75E3FD3A8D216488E97D00E932B3542E731D20 +2B576C3616DDAFEE23A8ECE24BBD89590C8C2D551F14D8EFA4DBB30216F89C31 +EE8D3CF3C503DE4FF368F23585F1A7017FF66A910696A6760AFD2B9822911960 +A32910F791C5EE9998DCE5371B3252427315C9D11AD506CE65760611D873C81D +740646D11A32C65A8549B3AEA8A499866C35D926B2BA21ED73934AA37ADCC1E6 +0E66EF4CA934A5D1ACED28CBEEAA3AF7941E10918DA79379090B6339F11E267E +D79D8666FD947B0D0D504FF10B048B147CB000AD8CDC1F0DEB395FB72B789963 +2F7BA07F18F4A91AEDC08867E9CC4B8689B0831A7CE0E0AEF3D92C0CA9BBC698 +1AB4351CFF02CC600C972CE87F69B23F8ECCC32A90BD5F429F8017A80306F23D +ED2AD447E7DF7A34D78A313395FA1C3AF63CE02B77A5B08CE19493CFA1173232 +C8C8DEAF10AA3994EE7D6DC8E1EB403042627E0F3524409F40C03A7C0C106A80 +5778B4A3E7BE82C07BA6A311A87649F3C7AE5107A89571E14AEF05B9E285C87A +30080347DB3B580B18E8EAC66E1B7227F791773F0342EE0DF8267EC993EC3F24 +2DB3B2A17C165B5C6A1D4944A5B595016588F028DD4F763C4ED6B7FE7849E918 +C1F0CF343B77F31D9A2E810821393EE9D1E0D4B54A87B2DD8CCFBB16FBD77A75B50A0E78D1E8A86310572443731B9DB5 +88EF373C37AADAE1155E7DBDBB7E0B048E3BFEFB412DC49EA8A48E1544B6DC87 +98694781F3EE698ABA8D2CDFFB1CA0425AA17BFE904FC7812E65A78DF1CA06C2 +6BBBCA6672311E1A3BF7001B3222890C8A68A8B7D87DE91624BB9D1FEC0E2728 +4550A44B654085C3A3620B5D4D2C6A7F962275BC5926B9B7E3A706F128BF6D6C967E2BF2ACD4DD000BDC8BDE69684F6F diff --git a/applications/main/subghz/scenes/subghz_scene_set_button.c b/applications/main/subghz/scenes/subghz_scene_set_button.c index baab8f095..e8914dbc5 100644 --- a/applications/main/subghz/scenes/subghz_scene_set_button.c +++ b/applications/main/subghz/scenes/subghz_scene_set_button.c @@ -40,6 +40,10 @@ void subghz_scene_set_button_on_enter(void* context) { byte_ptr = &subghz->gen_info->kinggates_stylo_4k.btn; byte_count = sizeof(subghz->gen_info->kinggates_stylo_4k.btn); break; + case GenBenincaARC: + byte_ptr = &subghz->gen_info->beninca_arc.btn; + byte_count = sizeof(subghz->gen_info->beninca_arc.btn); + break; case GenNiceFlorS: byte_ptr = &subghz->gen_info->nice_flor_s.btn; byte_count = sizeof(subghz->gen_info->nice_flor_s.btn); @@ -87,6 +91,7 @@ bool subghz_scene_set_button_on_event(void* context, SceneManagerEvent event) { case GenAlutechAt4n: case GenSomfyTelis: case GenKingGatesStylo4k: + case GenBenincaARC: case GenNiceFlorS: case GenSecPlus2: scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSetCounter); diff --git a/applications/main/subghz/scenes/subghz_scene_set_counter.c b/applications/main/subghz/scenes/subghz_scene_set_counter.c index 42437fcbf..a58749256 100644 --- a/applications/main/subghz/scenes/subghz_scene_set_counter.c +++ b/applications/main/subghz/scenes/subghz_scene_set_counter.c @@ -46,6 +46,10 @@ void subghz_scene_set_counter_on_enter(void* context) { byte_ptr = (uint8_t*)&subghz->gen_info->kinggates_stylo_4k.cnt; byte_count = sizeof(subghz->gen_info->kinggates_stylo_4k.cnt); break; + case GenBenincaARC: + byte_ptr = (uint8_t*)&subghz->gen_info->beninca_arc.cnt; + byte_count = sizeof(subghz->gen_info->beninca_arc.cnt); + break; case GenNiceFlorS: byte_ptr = (uint8_t*)&subghz->gen_info->nice_flor_s.cnt; byte_count = sizeof(subghz->gen_info->nice_flor_s.cnt); @@ -121,6 +125,9 @@ bool subghz_scene_set_counter_on_event(void* context, SceneManagerEvent event) { subghz->gen_info->kinggates_stylo_4k.cnt = __bswap16(subghz->gen_info->kinggates_stylo_4k.cnt); break; + case GenBenincaARC: + subghz->gen_info->beninca_arc.cnt = __bswap32(subghz->gen_info->beninca_arc.cnt); + break; case GenNiceFlorS: subghz->gen_info->nice_flor_s.cnt = __bswap16(subghz->gen_info->nice_flor_s.cnt); break; @@ -188,6 +195,15 @@ bool subghz_scene_set_counter_on_event(void* context, SceneManagerEvent event) { subghz->gen_info->kinggates_stylo_4k.btn, subghz->gen_info->kinggates_stylo_4k.cnt); break; + case GenBenincaARC: + generated_protocol = subghz_txrx_gen_beninca_arc_protocol( + subghz->txrx, + subghz->gen_info->mod, + subghz->gen_info->freq, + subghz->gen_info->beninca_arc.serial, + subghz->gen_info->beninca_arc.btn, + subghz->gen_info->beninca_arc.cnt); + break; case GenNiceFlorS: generated_protocol = subghz_txrx_gen_nice_flor_s_protocol( subghz->txrx, diff --git a/applications/main/subghz/scenes/subghz_scene_set_seed.c b/applications/main/subghz/scenes/subghz_scene_set_seed.c index b93203a17..648cfa1d3 100644 --- a/applications/main/subghz/scenes/subghz_scene_set_seed.c +++ b/applications/main/subghz/scenes/subghz_scene_set_seed.c @@ -31,6 +31,7 @@ void subghz_scene_set_seed_on_enter(void* context) { case GenAlutechAt4n: case GenSomfyTelis: case GenKingGatesStylo4k: + case GenBenincaARC: case GenNiceFlorS: case GenSecPlus2: case GenPhoenixV2: @@ -91,6 +92,7 @@ bool subghz_scene_set_seed_on_event(void* context, SceneManagerEvent event) { case GenAlutechAt4n: case GenSomfyTelis: case GenKingGatesStylo4k: + case GenBenincaARC: case GenNiceFlorS: case GenSecPlus2: case GenPhoenixV2: diff --git a/applications/main/subghz/scenes/subghz_scene_set_serial.c b/applications/main/subghz/scenes/subghz_scene_set_serial.c index b11559b44..9219842e5 100644 --- a/applications/main/subghz/scenes/subghz_scene_set_serial.c +++ b/applications/main/subghz/scenes/subghz_scene_set_serial.c @@ -46,6 +46,10 @@ void subghz_scene_set_serial_on_enter(void* context) { byte_ptr = (uint8_t*)&subghz->gen_info->kinggates_stylo_4k.serial; byte_count = sizeof(subghz->gen_info->kinggates_stylo_4k.serial); break; + case GenBenincaARC: + byte_ptr = (uint8_t*)&subghz->gen_info->beninca_arc.serial; + byte_count = sizeof(subghz->gen_info->beninca_arc.serial); + break; case GenNiceFlorS: byte_ptr = (uint8_t*)&subghz->gen_info->nice_flor_s.serial; byte_count = sizeof(subghz->gen_info->nice_flor_s.serial); @@ -118,6 +122,10 @@ bool subghz_scene_set_serial_on_event(void* context, SceneManagerEvent event) { subghz->gen_info->kinggates_stylo_4k.serial = __bswap32(subghz->gen_info->kinggates_stylo_4k.serial); break; + case GenBenincaARC: + subghz->gen_info->beninca_arc.serial = + __bswap32(subghz->gen_info->beninca_arc.serial); + break; case GenNiceFlorS: subghz->gen_info->nice_flor_s.serial = __bswap32(subghz->gen_info->nice_flor_s.serial); @@ -145,6 +153,7 @@ bool subghz_scene_set_serial_on_event(void* context, SceneManagerEvent event) { case GenAlutechAt4n: case GenSomfyTelis: case GenKingGatesStylo4k: + case GenBenincaARC: case GenNiceFlorS: case GenSecPlus2: scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSetButton); diff --git a/applications/main/subghz/scenes/subghz_scene_set_type.c b/applications/main/subghz/scenes/subghz_scene_set_type.c index f21f73f38..28cd4bcf7 100644 --- a/applications/main/subghz/scenes/subghz_scene_set_type.c +++ b/applications/main/subghz/scenes/subghz_scene_set_type.c @@ -20,7 +20,8 @@ static const char* submenu_names[SetTypeMAX] = { [SetTypeAlutechAT4N] = "Alutech AT4N 433MHz", [SetTypeRoger_433] = "Roger 433MHz", [SetTypePhoenix_V2_433] = "V2 Phoenix 433MHz", - [SetTypeKingGatesStylo4k] = "KingGates Stylo4 433MHz", + [SetTypeKingGatesStylo4k] = "KingGates Stylo4k 433M.", + [SetTypeBenincaARC] = "Beninca ARC 433MHz", [SetTypeHCS101_433_92] = "KL: HCS101 433MHz", [SetTypeDoorHan_315_00] = "KL: DoorHan 315MHz", [SetTypeDoorHan_433_92] = "KL: DoorHan 433MHz", @@ -197,6 +198,15 @@ bool subghz_scene_set_type_generate_protocol_from_infos(SubGhz* subghz) { gen_info.kinggates_stylo_4k.btn, gen_info.kinggates_stylo_4k.cnt); break; + case GenBenincaARC: + generated_protocol = subghz_txrx_gen_beninca_arc_protocol( + subghz->txrx, + gen_info.mod, + gen_info.freq, + gen_info.beninca_arc.serial, + gen_info.beninca_arc.btn, + gen_info.beninca_arc.cnt); + break; case GenNiceFlorS: generated_protocol = subghz_txrx_gen_nice_flor_s_protocol( subghz->txrx, @@ -277,6 +287,7 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) { case GenAlutechAt4n: // Serial (u32), Button (u8), Counter (u16) case GenSomfyTelis: // Serial (u32), Button (u8), Counter (u16) case GenKingGatesStylo4k: // Serial (u32), Button (u8), Counter (u16) + case GenBenincaARC: // Serial (u32), Button (u8), Counter (u32) case GenNiceFlorS: // Serial (u32), Button (u8), Counter (u16) case GenSecPlus2: // Serial (u32), Button (u8), Counter (u32) case GenPhoenixV2: // Serial (u32), Counter (u16) diff --git a/lib/subghz/protocols/aes_common.c b/lib/subghz/protocols/aes_common.c new file mode 100644 index 000000000..9e7d23a4f --- /dev/null +++ b/lib/subghz/protocols/aes_common.c @@ -0,0 +1,252 @@ +#include "aes_common.h" + +static const uint8_t aes_sbox[256] = { + 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, + 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, + 0x72, 0xc0, 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, + 0xd8, 0x31, 0x15, 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, + 0xeb, 0x27, 0xb2, 0x75, 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, + 0xb3, 0x29, 0xe3, 0x2f, 0x84, 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, + 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, + 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, + 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, + 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, + 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, 0xe0, 0x32, 0x3a, 0x0a, 0x49, + 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, 0xe7, 0xc8, 0x37, 0x6d, + 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, 0xba, 0x78, 0x25, + 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, 0x70, 0x3e, + 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, 0xe1, + 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, + 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, + 0x16}; + +static const uint8_t aes_sbox_inv[256] = { + 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, + 0xfb, 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, + 0xe9, 0xcb, 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, + 0xfa, 0xc3, 0x4e, 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, + 0x6d, 0x8b, 0xd1, 0x25, 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, + 0xcc, 0x5d, 0x65, 0xb6, 0x92, 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, + 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84, 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, + 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06, 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, + 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b, 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, + 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73, 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, + 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e, 0x47, 0xf1, 0x1a, 0x71, 0x1d, + 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b, 0xfc, 0x56, 0x3e, 0x4b, + 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4, 0x1f, 0xdd, 0xa8, + 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f, 0x60, 0x51, + 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef, 0xa0, + 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61, + 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, + 0x7d}; + +static const uint8_t aes_rcon[10] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36}; + +static uint8_t gf_mul2(uint8_t x) { + return ((x >> 7) * 0x1b) ^ (x << 1); +} + +static void aes_subbytes(uint8_t* state) { + for(uint8_t row = 0; row < 4; row++) { + for(uint8_t col = 0; col < 4; col++) { + state[row + col * 4] = aes_sbox[state[row + col * 4]]; + } + } +} + +static void aes_subbytes_inv(uint8_t* state) { + for(uint8_t row = 0; row < 4; row++) { + for(uint8_t col = 0; col < 4; col++) { + state[row + col * 4] = aes_sbox_inv[state[row + col * 4]]; + } + } +} + +static void aes_shiftrows(uint8_t* state) { + uint8_t temp; + + temp = state[1]; + state[1] = state[5]; + state[5] = state[9]; + state[9] = state[13]; + state[13] = temp; + + temp = state[2]; + state[2] = state[10]; + state[10] = temp; + temp = state[6]; + state[6] = state[14]; + state[14] = temp; + + temp = state[15]; + state[15] = state[11]; + state[11] = state[7]; + state[7] = state[3]; + state[3] = temp; +} + +static void aes_shiftrows_inv(uint8_t* state) { + uint8_t temp; + + temp = state[13]; + state[13] = state[9]; + state[9] = state[5]; + state[5] = state[1]; + state[1] = temp; + + temp = state[2]; + state[2] = state[10]; + state[10] = temp; + temp = state[6]; + state[6] = state[14]; + state[14] = temp; + + temp = state[3]; + state[3] = state[7]; + state[7] = state[11]; + state[11] = state[15]; + state[15] = temp; +} + +static void aes_mixcolumns(uint8_t* state) { + uint8_t a, b, c, d; + for(uint8_t i = 0; i < 4; i++) { + a = state[i * 4]; + b = state[i * 4 + 1]; + c = state[i * 4 + 2]; + d = state[i * 4 + 3]; + + uint8_t a2 = gf_mul2(a); + uint8_t b2 = gf_mul2(b); + uint8_t c2 = gf_mul2(c); + uint8_t d2 = gf_mul2(d); + + state[i * 4] = a2 ^ b2 ^ b ^ c ^ d; + state[i * 4 + 1] = a ^ b2 ^ c2 ^ c ^ d; + state[i * 4 + 2] = a ^ b ^ c2 ^ d2 ^ d; + state[i * 4 + 3] = a2 ^ a ^ b ^ c ^ d2; + } +} + +static void aes_mixcolumns_inv(uint8_t* state) { + uint8_t a, b, c, d; + for(uint8_t i = 0; i < 4; i++) { + a = state[i * 4]; + b = state[i * 4 + 1]; + c = state[i * 4 + 2]; + d = state[i * 4 + 3]; + + uint8_t a2 = gf_mul2(a); + uint8_t a4 = gf_mul2(a2); + uint8_t a8 = gf_mul2(a4); + uint8_t b2 = gf_mul2(b); + uint8_t b4 = gf_mul2(b2); + uint8_t b8 = gf_mul2(b4); + uint8_t c2 = gf_mul2(c); + uint8_t c4 = gf_mul2(c2); + uint8_t c8 = gf_mul2(c4); + uint8_t d2 = gf_mul2(d); + uint8_t d4 = gf_mul2(d2); + uint8_t d8 = gf_mul2(d4); + + state[i * 4] = (a8 ^ a4 ^ a2) ^ (b8 ^ b2 ^ b) ^ (c8 ^ c4 ^ c) ^ (d8 ^ d); + state[i * 4 + 1] = (a8 ^ a) ^ (b8 ^ b4 ^ b2) ^ (c8 ^ c2 ^ c) ^ (d8 ^ d4 ^ d); + state[i * 4 + 2] = (a8 ^ a4 ^ a) ^ (b8 ^ b) ^ (c8 ^ c4 ^ c2) ^ (d8 ^ d2 ^ d); + state[i * 4 + 3] = (a8 ^ a2 ^ a) ^ (b8 ^ b4 ^ b) ^ (c8 ^ c) ^ (d8 ^ d4 ^ d2); + } +} + +static void aes_addroundkey(uint8_t* state, const uint8_t* round_key) { + for(uint8_t col = 0; col < 4; col++) { + state[col * 4] ^= round_key[col * 4]; + state[col * 4 + 1] ^= round_key[col * 4 + 1]; + state[col * 4 + 2] ^= round_key[col * 4 + 2]; + state[col * 4 + 3] ^= round_key[col * 4 + 3]; + } +} + +void aes_key_expansion(const uint8_t* key, uint8_t* round_keys) { + for(uint8_t i = 0; i < 16; i++) { + round_keys[i] = key[i]; + } + + for(uint8_t i = 4; i < 44; i++) { + uint8_t prev_word_idx = (i - 1) * 4; + uint8_t b0 = round_keys[prev_word_idx]; + uint8_t b1 = round_keys[prev_word_idx + 1]; + uint8_t b2 = round_keys[prev_word_idx + 2]; + uint8_t b3 = round_keys[prev_word_idx + 3]; + + if((i % 4) == 0) { + uint8_t new_b0 = aes_sbox[b1] ^ aes_rcon[(i / 4) - 1]; + uint8_t new_b1 = aes_sbox[b2]; + uint8_t new_b2 = aes_sbox[b3]; + uint8_t new_b3 = aes_sbox[b0]; + b0 = new_b0; + b1 = new_b1; + b2 = new_b2; + b3 = new_b3; + } + + uint8_t back_word_idx = (i - 4) * 4; + b0 ^= round_keys[back_word_idx]; + b1 ^= round_keys[back_word_idx + 1]; + b2 ^= round_keys[back_word_idx + 2]; + b3 ^= round_keys[back_word_idx + 3]; + + uint8_t curr_word_idx = i * 4; + round_keys[curr_word_idx] = b0; + round_keys[curr_word_idx + 1] = b1; + round_keys[curr_word_idx + 2] = b2; + round_keys[curr_word_idx + 3] = b3; + } +} + +void aes128_encrypt(const uint8_t* expanded_key, uint8_t* data) { + uint8_t state[16]; + memcpy(state, data, 16); + + aes_addroundkey(state, &expanded_key[0]); + + for(uint8_t round = 1; round < 10; round++) { + aes_subbytes(state); + aes_shiftrows(state); + aes_mixcolumns(state); + aes_addroundkey(state, &expanded_key[round * 16]); + } + + aes_subbytes(state); + aes_shiftrows(state); + aes_addroundkey(state, &expanded_key[160]); + + memcpy(data, state, 16); +} + +void aes128_decrypt(const uint8_t* expanded_key, uint8_t* data) { + uint8_t state[16]; + memcpy(state, data, 16); + + aes_addroundkey(state, &expanded_key[160]); + + for(uint8_t round = 9; round > 0; round--) { + aes_shiftrows_inv(state); + aes_subbytes_inv(state); + aes_addroundkey(state, &expanded_key[round * 16]); + aes_mixcolumns_inv(state); + } + + aes_shiftrows_inv(state); + aes_subbytes_inv(state); + aes_addroundkey(state, &expanded_key[0]); + + memcpy(data, state, 16); +} + +void reverse_bits_in_bytes(uint8_t* data, uint8_t len) { + for(uint8_t i = 0; i < len; i++) { + uint8_t byte = data[i]; + uint8_t step1 = ((byte & 0x55) << 1) | ((byte >> 1) & 0x55); + uint8_t step2 = ((step1 & 0x33) << 2) | ((step1 >> 2) & 0x33); + data[i] = ((step2 & 0x0F) << 4) | (step2 >> 4); + } +} diff --git a/lib/subghz/protocols/aes_common.h b/lib/subghz/protocols/aes_common.h new file mode 100644 index 000000000..ba8168383 --- /dev/null +++ b/lib/subghz/protocols/aes_common.h @@ -0,0 +1,10 @@ +#pragma once + +#include "base.h" + +#include + +void reverse_bits_in_bytes(uint8_t* data, uint8_t len); +void aes128_decrypt(const uint8_t* expanded_key, uint8_t* data); +void aes128_encrypt(const uint8_t* expanded_key, uint8_t* data); +void aes_key_expansion(const uint8_t* key, uint8_t* round_keys); diff --git a/lib/subghz/protocols/beninca_arc.c b/lib/subghz/protocols/beninca_arc.c new file mode 100644 index 000000000..a77301fa3 --- /dev/null +++ b/lib/subghz/protocols/beninca_arc.c @@ -0,0 +1,679 @@ +#include "beninca_arc.h" +#include "../blocks/const.h" +#include "../blocks/decoder.h" +#include "../blocks/encoder.h" +#include "../blocks/generic.h" +#include "../blocks/math.h" +#include "core/log.h" +#include +#include +#include "aes_common.h" + +#include "../blocks/custom_btn_i.h" + +#define TAG "BenincaARC" + +#define BENINCA_ARC_KEY_TYPE 9u + +static const SubGhzBlockConst subghz_protocol_beninca_arc_const = { + .te_short = 300, + .te_long = 600, + .te_delta = 155, + .min_count_bit_for_found = 128, +}; + +typedef enum { + BenincaARCDecoderStart = 0, + BenincaARCDecoderHighLevel, + BenincaARCDecoderLowLevel, +} BenincaARCDecoderState; + +struct SubGhzProtocolDecoderBenincaARC { + SubGhzProtocolDecoderBase base; + SubGhzBlockDecoder decoder; + + SubGhzBlockGeneric generic; + + SubGhzKeystore* keystore; +}; + +struct SubGhzProtocolEncoderBenincaARC { + SubGhzProtocolEncoderBase base; + SubGhzProtocolBlockEncoder encoder; + + SubGhzBlockGeneric generic; + + SubGhzKeystore* keystore; +}; + +const SubGhzProtocolDecoder subghz_protocol_beninca_arc_decoder = { + .alloc = subghz_protocol_decoder_beninca_arc_alloc, + .free = subghz_protocol_decoder_beninca_arc_free, + + .feed = subghz_protocol_decoder_beninca_arc_feed, + .reset = subghz_protocol_decoder_beninca_arc_reset, + + .get_hash_data = subghz_protocol_decoder_beninca_arc_get_hash_data, + .serialize = subghz_protocol_decoder_beninca_arc_serialize, + .deserialize = subghz_protocol_decoder_beninca_arc_deserialize, + .get_string = subghz_protocol_decoder_beninca_arc_get_string, +}; + +const SubGhzProtocolEncoder subghz_protocol_beninca_arc_encoder = { + .alloc = subghz_protocol_encoder_beninca_arc_alloc, + .free = subghz_protocol_encoder_beninca_arc_free, + + .deserialize = subghz_protocol_encoder_beninca_arc_deserialize, + .stop = subghz_protocol_encoder_beninca_arc_stop, + .yield = subghz_protocol_encoder_beninca_arc_yield, +}; + +const SubGhzProtocol subghz_protocol_beninca_arc = { + .name = SUBGHZ_PROTOCOL_BENINCA_ARC_NAME, + .type = SubGhzProtocolTypeDynamic, + .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | + SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save | SubGhzProtocolFlag_Send, + + .decoder = &subghz_protocol_beninca_arc_decoder, + .encoder = &subghz_protocol_beninca_arc_encoder, +}; + +// Get custom button code +static uint8_t subghz_protocol_beninca_arc_get_btn_code(void) { + uint8_t custom_btn_id = subghz_custom_btn_get(); + uint8_t original_btn_code = subghz_custom_btn_get_original(); + uint8_t btn = original_btn_code; + + // Set custom button + if((custom_btn_id == SUBGHZ_CUSTOM_BTN_OK) && (original_btn_code != 0)) { + // Restore original button code + btn = original_btn_code; + } else if(custom_btn_id == SUBGHZ_CUSTOM_BTN_UP) { + switch(original_btn_code) { + case 0x02: + btn = 0x04; + break; + case 0x04: + btn = 0x02; + break; + case 0xFF: + btn = 0x04; + break; + + default: + break; + } + } else if(custom_btn_id == SUBGHZ_CUSTOM_BTN_DOWN) { + switch(original_btn_code) { + case 0x02: + btn = 0xFF; + break; + case 0x04: + btn = 0xFF; + break; + case 0xFF: + btn = 0x02; + break; + + default: + break; + } + } + + return btn; +} + +static void get_subghz_protocol_beninca_arc_aes_key(SubGhzKeystore* keystore, uint8_t* aes_key) { + uint64_t mfkey = 0; + for + M_EACH(manufacture_code, *subghz_keystore_get_data(keystore), SubGhzKeyArray_t) { + if(manufacture_code->type == BENINCA_ARC_KEY_TYPE) { + mfkey = manufacture_code->key; + break; + } + } + + uint32_t derived_lo = (uint32_t)(mfkey & 0xFFFFFFFF); + uint32_t derived_hi = (uint32_t)((mfkey >> 32) & 0xFFFFFFFF); + + uint64_t val64_a = ((uint64_t)derived_hi << 32) | derived_lo; + for(uint8_t i = 0; i < 8; i++) { + aes_key[i] = (val64_a >> (56 - i * 8)) & 0xFF; + } + + uint32_t new_lo = ((derived_hi >> 24) & 0xFF) | ((derived_hi >> 8) & 0xFF00) | + ((derived_hi << 8) & 0xFF0000) | ((derived_hi << 24) & 0xFF000000); + uint32_t new_hi = ((derived_lo >> 24) & 0xFF) | ((derived_lo >> 8) & 0xFF00) | + ((derived_lo << 8) & 0xFF0000) | ((derived_lo << 24) & 0xFF000000); + + uint64_t val64_b = ((uint64_t)new_hi << 32) | new_lo; + for(uint8_t i = 0; i < 8; i++) { + aes_key[i + 8] = (val64_b >> (56 - i * 8)) & 0xFF; + } +} + +static uint64_t + subghz_protocol_beninca_arc_decrypt(SubGhzBlockGeneric* generic, SubGhzKeystore* keystore) { + // Beninca ARC Decoder + // 01.2026 - @xMasterX (MMX) & @zero-mega + + // Decrypt data + uint8_t encrypted_data[16]; + + for(uint8_t i = 0; i < 8; i++) { + encrypted_data[i] = (generic->data >> (56 - i * 8)) & 0xFF; + encrypted_data[i + 8] = (generic->data_2 >> (56 - i * 8)) & 0xFF; + } + + reverse_bits_in_bytes(encrypted_data, 16); + + uint8_t aes_key[16]; + get_subghz_protocol_beninca_arc_aes_key(keystore, aes_key); + + uint8_t expanded_key[176]; + aes_key_expansion(aes_key, expanded_key); + + aes128_decrypt(expanded_key, encrypted_data); + + // Serial number of remote + generic->serial = ((uint32_t)encrypted_data[0] << 24) | ((uint32_t)encrypted_data[1] << 16) | + ((uint32_t)encrypted_data[2] << 8) | encrypted_data[3]; + + // Button code + generic->btn = encrypted_data[4]; + + // Middle bytes contains mini counter that is increased while button is held + // its value mostly stored in encrypted_data[9] but might be in other bytes as well + // In order to support all variants we read all middle bytes as uint64_t + // In case you have the remote with ARC rolling code please share RAW recording where you hold button for 15+ sec with us to improve this part! + uint64_t middle_bytes = 0; + middle_bytes = ((uint64_t)encrypted_data[5] << 32) | ((uint64_t)encrypted_data[6] << 24) | + ((uint64_t)encrypted_data[7] << 16) | ((uint64_t)encrypted_data[8] << 8) | + encrypted_data[9]; + + // 32-bit counter + generic->cnt = ((uint32_t)encrypted_data[10] << 24) | ((uint32_t)encrypted_data[11] << 16) | + ((uint32_t)encrypted_data[12] << 8) | encrypted_data[13]; + // Fixed constant value AA 55 + generic->seed = ((uint16_t)encrypted_data[14] << 8) | encrypted_data[15]; + + // Save original button for later use + if(subghz_custom_btn_get_original() == 0) { + subghz_custom_btn_set_original(generic->btn); + } + subghz_custom_btn_set_max(2); + + return middle_bytes; +} + +static void subghz_protocol_beninca_arc_encrypt( + SubGhzBlockGeneric* generic, + SubGhzKeystore* keystore, + uint64_t middle_bytes) { + // Beninca ARC Encoder + // 01.2026 - @xMasterX (MMX) & @zero-mega + // Encrypt data + uint8_t plaintext[16]; + + plaintext[0] = (generic->serial >> 24) & 0xFF; + plaintext[1] = (generic->serial >> 16) & 0xFF; + plaintext[2] = (generic->serial >> 8) & 0xFF; + plaintext[3] = generic->serial & 0xFF; + plaintext[4] = generic->btn; + plaintext[5] = (middle_bytes >> 32) & 0xFF; + plaintext[6] = (middle_bytes >> 24) & 0xFF; + plaintext[7] = (middle_bytes >> 16) & 0xFF; + plaintext[8] = (middle_bytes >> 8) & 0xFF; + plaintext[9] = middle_bytes & 0xFF; + plaintext[10] = (generic->cnt >> 24) & 0xFF; + plaintext[11] = (generic->cnt >> 16) & 0xFF; + plaintext[12] = (generic->cnt >> 8) & 0xFF; + plaintext[13] = generic->cnt & 0xFF; + plaintext[14] = (generic->seed >> 8) & 0xFF; + plaintext[15] = generic->seed & 0xFF; + + uint8_t aes_key[16]; + get_subghz_protocol_beninca_arc_aes_key(keystore, aes_key); + + uint8_t expanded_key[176]; + aes_key_expansion(aes_key, expanded_key); + + aes128_encrypt(expanded_key, plaintext); + + reverse_bits_in_bytes(plaintext, 16); + + for(uint8_t i = 0; i < 8; i++) { + generic->data = (generic->data << 8) | plaintext[i]; + generic->data_2 = (generic->data_2 << 8) | plaintext[i + 8]; + } + return; +} + +void* subghz_protocol_encoder_beninca_arc_alloc(SubGhzEnvironment* environment) { + SubGhzProtocolEncoderBenincaARC* instance = malloc(sizeof(SubGhzProtocolEncoderBenincaARC)); + + instance->base.protocol = &subghz_protocol_beninca_arc; + instance->generic.protocol_name = instance->base.protocol->name; + instance->keystore = subghz_environment_get_keystore(environment); + + instance->encoder.repeat = 10; + instance->encoder.size_upload = 800; + instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); + instance->encoder.is_running = false; + + return instance; +} + +void subghz_protocol_encoder_beninca_arc_free(void* context) { + furi_assert(context); + SubGhzProtocolEncoderBenincaARC* instance = context; + free(instance->encoder.upload); + free(instance); +} + +void subghz_protocol_encoder_beninca_arc_stop(void* context) { + furi_assert(context); + SubGhzProtocolEncoderBenincaARC* instance = context; + instance->encoder.is_running = false; +} + +static void subghz_protocol_beninca_arc_encoder_get_upload( + SubGhzProtocolEncoderBenincaARC* instance, + size_t* index) { + furi_assert(instance); + size_t index_local = *index; + + // First part of data 64 bits + for(uint8_t i = 64; i > 0; i--) { + if(bit_read(instance->generic.data, i - 1)) { + // Send bit 1 + instance->encoder.upload[index_local++] = + level_duration_make(true, (uint32_t)subghz_protocol_beninca_arc_const.te_short); + instance->encoder.upload[index_local++] = + level_duration_make(false, (uint32_t)subghz_protocol_beninca_arc_const.te_long); + } else { + // Send bit 0 + instance->encoder.upload[index_local++] = + level_duration_make(true, (uint32_t)subghz_protocol_beninca_arc_const.te_long); + instance->encoder.upload[index_local++] = + level_duration_make(false, (uint32_t)subghz_protocol_beninca_arc_const.te_short); + } + } + // Second part of data 64 bits - total 128bits data + for(uint8_t i = 64; i > 0; i--) { + if(bit_read(instance->generic.data_2, i - 1)) { + // Send bit 1 + instance->encoder.upload[index_local++] = + level_duration_make(true, (uint32_t)subghz_protocol_beninca_arc_const.te_short); + instance->encoder.upload[index_local++] = + level_duration_make(false, (uint32_t)subghz_protocol_beninca_arc_const.te_long); + } else { + // Send bit 0 + instance->encoder.upload[index_local++] = + level_duration_make(true, (uint32_t)subghz_protocol_beninca_arc_const.te_long); + instance->encoder.upload[index_local++] = + level_duration_make(false, (uint32_t)subghz_protocol_beninca_arc_const.te_short); + } + } + // Add stop bit + instance->encoder.upload[index_local++] = + level_duration_make(true, (uint32_t)subghz_protocol_beninca_arc_const.te_short); + // Add gap between packets + instance->encoder.upload[index_local++] = + level_duration_make(false, (uint32_t)subghz_protocol_beninca_arc_const.te_long * 15); + + *index = index_local; +} + +static void subghz_protocol_beninca_arc_encoder_prepare_packets( + SubGhzProtocolEncoderBenincaARC* instance) { + furi_assert(instance); + + // Counter increment + // check OFEX mode + if(furi_hal_subghz_get_rolling_counter_mult() != -0x7FFFFFFF) { + // standart counter mode. PULL data from subghz_block_generic_global variables + if(!subghz_block_generic_global_counter_override_get(&instance->generic.cnt)) { + // if counter_override_get return FALSE then counter was not changed and we increase counter by standart mult value + if((instance->generic.cnt + furi_hal_subghz_get_rolling_counter_mult()) > 0xFFFFFFFF) { + instance->generic.cnt = 0; + } else { + instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult(); + } + } + } else { + // TODO: OFEX mode + instance->generic.cnt += 1; + } + // Index for upload array + size_t index = 0; + // Generate new key using custom or default button + instance->generic.btn = subghz_protocol_beninca_arc_get_btn_code(); + + // Make 3 packets with different mini counter values - 2, 4, 6 + for(uint8_t i = 0; i < 3; i++) { + subghz_protocol_beninca_arc_encrypt( + &instance->generic, instance->keystore, (uint64_t)((i + 1) * 2)); + subghz_protocol_beninca_arc_encoder_get_upload(instance, &index); + } + // Set final size of upload array + instance->encoder.size_upload = index; +} + +bool subghz_protocol_beninca_arc_create_data( + void* context, + FlipperFormat* flipper_format, + uint32_t serial, + uint8_t btn, + uint32_t cnt, + SubGhzRadioPreset* preset) { + furi_assert(context); + // UwU + SubGhzProtocolEncoderBenincaARC* instance = context; + instance->generic.serial = serial; + instance->generic.btn = btn; // 02 / 04 + instance->generic.cnt = cnt; + instance->generic.seed = 0xAA55; // Fixed value constant + instance->generic.data_count_bit = 128; + + subghz_protocol_beninca_arc_encrypt(&instance->generic, instance->keystore, 0x1); + + SubGhzProtocolStatus res = + subghz_block_generic_serialize(&instance->generic, flipper_format, preset); + + uint8_t key_data[sizeof(uint64_t)] = {0}; + for(size_t i = 0; i < sizeof(uint64_t); i++) { + key_data[sizeof(uint64_t) - i - 1] = (instance->generic.data_2 >> (i * 8)) & 0xFF; + } + + if(!flipper_format_rewind(flipper_format)) { + FURI_LOG_E(TAG, "Rewind error"); + res = SubGhzProtocolStatusErrorParserOthers; + } + + if((res == SubGhzProtocolStatusOk) && + !flipper_format_insert_or_update_hex(flipper_format, "Data", key_data, sizeof(uint64_t))) { + FURI_LOG_E(TAG, "Unable to add Data2"); + res = SubGhzProtocolStatusErrorParserOthers; + } + + return res == SubGhzProtocolStatusOk; +} + +SubGhzProtocolStatus + subghz_protocol_encoder_beninca_arc_deserialize(void* context, FlipperFormat* flipper_format) { + furi_assert(context); + SubGhzProtocolEncoderBenincaARC* instance = context; + SubGhzProtocolStatus res = SubGhzProtocolStatusError; + do { + if(SubGhzProtocolStatusOk != + subghz_block_generic_deserialize(&instance->generic, flipper_format)) { + FURI_LOG_E(TAG, "Deserialize error"); + break; + } + + //optional parameter parameter + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + + if(!flipper_format_rewind(flipper_format)) { + FURI_LOG_E(TAG, "Rewind error"); + break; + } + + uint8_t key_data[sizeof(uint64_t)] = {0}; + if(!flipper_format_read_hex(flipper_format, "Data", key_data, sizeof(uint64_t))) { + FURI_LOG_E(TAG, "Missing Data"); + break; + } + + for(uint8_t i = 0; i < sizeof(uint64_t); i++) { + instance->generic.data_2 = instance->generic.data_2 << 8 | key_data[i]; + } + + // TODO: if minicounter having larger value use it instead of fixed values + subghz_protocol_beninca_arc_decrypt(&instance->generic, instance->keystore); + + subghz_protocol_beninca_arc_encoder_prepare_packets(instance); + + if(!flipper_format_rewind(flipper_format)) { + FURI_LOG_E(TAG, "Rewind error"); + break; + } + + for(size_t i = 0; i < sizeof(uint64_t); i++) { + key_data[sizeof(uint64_t) - i - 1] = (instance->generic.data >> i * 8) & 0xFF; + } + if(!flipper_format_update_hex(flipper_format, "Key", key_data, sizeof(uint64_t))) { + FURI_LOG_E(TAG, "Unable to update Key"); + break; + } + + for(size_t i = 0; i < sizeof(uint64_t); i++) { + key_data[sizeof(uint64_t) - i - 1] = (instance->generic.data_2 >> i * 8) & 0xFF; + } + if(!flipper_format_update_hex(flipper_format, "Data", key_data, sizeof(uint64_t))) { + FURI_LOG_E(TAG, "Unable to update Data"); + break; + } + + instance->encoder.is_running = true; + + res = SubGhzProtocolStatusOk; + } while(false); + + return res; +} + +LevelDuration subghz_protocol_encoder_beninca_arc_yield(void* context) { + furi_assert(context); + SubGhzProtocolEncoderBenincaARC* 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_beninca_arc_alloc(SubGhzEnvironment* environment) { + SubGhzProtocolDecoderBenincaARC* instance = malloc(sizeof(SubGhzProtocolDecoderBenincaARC)); + instance->base.protocol = &subghz_protocol_beninca_arc; + instance->generic.protocol_name = instance->base.protocol->name; + instance->keystore = subghz_environment_get_keystore(environment); + instance->decoder.parser_step = BenincaARCDecoderStart; + return instance; +} + +void subghz_protocol_decoder_beninca_arc_free(void* context) { + furi_assert(context); + SubGhzProtocolDecoderBenincaARC* instance = context; + free(instance); +} + +void subghz_protocol_decoder_beninca_arc_reset(void* context) { + furi_assert(context); + SubGhzProtocolDecoderBenincaARC* instance = context; + instance->decoder.parser_step = BenincaARCDecoderStart; +} + +void subghz_protocol_decoder_beninca_arc_feed(void* context, bool level, uint32_t duration) { + furi_assert(context); + SubGhzProtocolDecoderBenincaARC* instance = context; + + switch(instance->decoder.parser_step) { + case BenincaARCDecoderStart: + if((!level) && (DURATION_DIFF(duration, subghz_protocol_beninca_arc_const.te_long * 16) < + subghz_protocol_beninca_arc_const.te_delta * 15)) { + // GAP (9300 +- 2325 us) found switch to next state + instance->decoder.decode_data = 0; + instance->decoder.decode_count_bit = 0; + instance->decoder.parser_step = BenincaARCDecoderHighLevel; + break; + } + // No GAP so stay in current state + break; + case BenincaARCDecoderHighLevel: + if(level) { + instance->decoder.te_last = duration; + instance->decoder.parser_step = BenincaARCDecoderLowLevel; + // Check if we have collected enough bits + if((instance->decoder.decode_count_bit == + (subghz_protocol_beninca_arc_const.min_count_bit_for_found / 2)) && + (instance->decoder.decode_data != 0)) { + // Half data captured 64 bits + instance->generic.data = instance->decoder.decode_data; + instance->decoder.decode_data = 0; + } else if( + instance->decoder.decode_count_bit == + subghz_protocol_beninca_arc_const.min_count_bit_for_found) { + // Full data captured 128 bits + instance->generic.data_2 = instance->decoder.decode_data; + instance->generic.data_count_bit = instance->decoder.decode_count_bit; + instance->decoder.parser_step = BenincaARCDecoderStart; + + if(instance->base.callback) { + instance->base.callback(&instance->base, instance->base.context); + } + + break; + } + } else { + instance->decoder.parser_step = BenincaARCDecoderStart; + } + break; + case BenincaARCDecoderLowLevel: + if(!level) { + // Bit 1 is short and long timing = 300us HIGH (te_last) and 600us LOW + if((DURATION_DIFF( + instance->decoder.te_last, subghz_protocol_beninca_arc_const.te_short) < + subghz_protocol_beninca_arc_const.te_delta) && + (DURATION_DIFF(duration, subghz_protocol_beninca_arc_const.te_long) < + subghz_protocol_beninca_arc_const.te_delta)) { + subghz_protocol_blocks_add_bit(&instance->decoder, 1); + instance->decoder.parser_step = BenincaARCDecoderHighLevel; + // Bit 0 is long and short timing = 600us HIGH (te_last) and 300us LOW + } else if( + (DURATION_DIFF( + instance->decoder.te_last, subghz_protocol_beninca_arc_const.te_long) < + subghz_protocol_beninca_arc_const.te_delta) && + (DURATION_DIFF(duration, subghz_protocol_beninca_arc_const.te_short) < + subghz_protocol_beninca_arc_const.te_delta)) { + subghz_protocol_blocks_add_bit(&instance->decoder, 0); + instance->decoder.parser_step = BenincaARCDecoderHighLevel; + } else { + instance->decoder.parser_step = BenincaARCDecoderStart; + } + break; + } else { + instance->decoder.parser_step = BenincaARCDecoderStart; + break; + } + } +} + +uint8_t subghz_protocol_decoder_beninca_arc_get_hash_data(void* context) { + furi_assert(context); + SubGhzProtocolDecoderBenincaARC* instance = context; + return subghz_protocol_blocks_get_hash_data( + &instance->decoder, (instance->decoder.decode_count_bit / 8) + 1); +} + +SubGhzProtocolStatus subghz_protocol_decoder_beninca_arc_serialize( + void* context, + FlipperFormat* flipper_format, + SubGhzRadioPreset* preset) { + furi_assert(context); + SubGhzProtocolDecoderBenincaARC* instance = context; + SubGhzProtocolStatus ret = + subghz_block_generic_serialize(&instance->generic, flipper_format, preset); + + uint8_t key_data[sizeof(uint64_t)] = {0}; + for(size_t i = 0; i < sizeof(uint64_t); i++) { + key_data[sizeof(uint64_t) - i - 1] = (instance->generic.data_2 >> (i * 8)) & 0xFF; + } + + if(!flipper_format_rewind(flipper_format)) { + FURI_LOG_E(TAG, "Rewind error"); + ret = SubGhzProtocolStatusErrorParserOthers; + } + + if((ret == SubGhzProtocolStatusOk) && + !flipper_format_insert_or_update_hex(flipper_format, "Data", key_data, sizeof(uint64_t))) { + FURI_LOG_E(TAG, "Unable to add Data"); + ret = SubGhzProtocolStatusErrorParserOthers; + } + return ret; +} + +SubGhzProtocolStatus + subghz_protocol_decoder_beninca_arc_deserialize(void* context, FlipperFormat* flipper_format) { + furi_assert(context); + SubGhzProtocolDecoderBenincaARC* instance = context; + + SubGhzProtocolStatus ret = SubGhzProtocolStatusError; + do { + ret = subghz_block_generic_deserialize_check_count_bit( + &instance->generic, + flipper_format, + subghz_protocol_beninca_arc_const.min_count_bit_for_found); + if(ret != SubGhzProtocolStatusOk) { + break; + } + if(!flipper_format_rewind(flipper_format)) { + FURI_LOG_E(TAG, "Rewind error"); + ret = SubGhzProtocolStatusErrorParserOthers; + break; + } + uint8_t key_data[sizeof(uint64_t)] = {0}; + if(!flipper_format_read_hex(flipper_format, "Data", key_data, sizeof(uint64_t))) { + FURI_LOG_E(TAG, "Missing Data"); + ret = SubGhzProtocolStatusErrorParserOthers; + break; + } + + for(uint8_t i = 0; i < sizeof(uint64_t); i++) { + instance->generic.data_2 = instance->generic.data_2 << 8 | key_data[i]; + } + } while(false); + return ret; +} + +void subghz_protocol_decoder_beninca_arc_get_string(void* context, FuriString* output) { + furi_assert(context); + SubGhzProtocolDecoderBenincaARC* instance = context; + + uint64_t middle_bytes_dec = + subghz_protocol_beninca_arc_decrypt(&instance->generic, instance->keystore); + + // push protocol data to global variable + subghz_block_generic_global.cnt_is_available = true; + subghz_block_generic_global.cnt_length_bit = 32; + subghz_block_generic_global.current_cnt = instance->generic.cnt; + + furi_string_printf( + output, + "%s %db\r\n" + "Key1:%08llX\r\n" + "Key2:%08llX\r\n" + "Sn:%08lX Btn:%02X\r\n" + "Mc:%0lX Cnt:%0lX\r\n" + "Fx:%04lX", + instance->base.protocol->name, + instance->generic.data_count_bit, + instance->generic.data, + instance->generic.data_2, + instance->generic.serial, + instance->generic.btn, + (uint32_t)(middle_bytes_dec & 0xFFFFFFFF), + instance->generic.cnt, + instance->generic.seed & 0xFFFF); +} diff --git a/lib/subghz/protocols/beninca_arc.h b/lib/subghz/protocols/beninca_arc.h new file mode 100644 index 000000000..d61617002 --- /dev/null +++ b/lib/subghz/protocols/beninca_arc.h @@ -0,0 +1,108 @@ +#pragma once +#include "base.h" + +#define SUBGHZ_PROTOCOL_BENINCA_ARC_NAME "Beninca ARC" + +typedef struct SubGhzProtocolDecoderBenincaARC SubGhzProtocolDecoderBenincaARC; +typedef struct SubGhzProtocolEncoderBenincaARC SubGhzProtocolEncoderBenincaARC; + +extern const SubGhzProtocolDecoder subghz_protocol_beninca_arc_decoder; +extern const SubGhzProtocolEncoder subghz_protocol_beninca_arc_encoder; +extern const SubGhzProtocol subghz_protocol_beninca_arc; + +/** + * Allocate SubGhzProtocolEncoderBenincaARC. + * @param environment Pointer to a SubGhzEnvironment instance + * @return SubGhzProtocolEncoderBenincaARC* pointer to a SubGhzProtocolEncoderBenincaARC instance + */ +void* subghz_protocol_encoder_beninca_arc_alloc(SubGhzEnvironment* environment); + +/** + * Free SubGhzProtocolEncoderBenincaARC. + * @param context Pointer to a SubGhzProtocolEncoderBenincaARC instance + */ +void subghz_protocol_encoder_beninca_arc_free(void* context); + +/** + * Deserialize and generating an upload to send. + * @param context Pointer to a SubGhzProtocolEncoderBenincaARC instance + * @param flipper_format Pointer to a FlipperFormat instance + * @return true On success + */ +SubGhzProtocolStatus + subghz_protocol_encoder_beninca_arc_deserialize(void* context, FlipperFormat* flipper_format); + +/** + * Forced transmission stop. + * @param context Pointer to a SubGhzProtocolEncoderBenincaARC instance + */ +void subghz_protocol_encoder_beninca_arc_stop(void* context); + +/** + * Getting the level and duration of the upload to be loaded into DMA. + * @param context Pointer to a SubGhzProtocolEncoderBenincaARC instance + * @return LevelDuration + */ +LevelDuration subghz_protocol_encoder_beninca_arc_yield(void* context); + +/** + * Allocate SubGhzProtocolDecoderBenincaARC. + * @param environment Pointer to a SubGhzEnvironment instance + * @return SubGhzProtocolDecoderBenincaARC* pointer to a SubGhzProtocolDecoderBenincaARC instance + */ +void* subghz_protocol_decoder_beninca_arc_alloc(SubGhzEnvironment* environment); + +/** + * Free SubGhzProtocolDecoderBenincaARC. + * @param context Pointer to a SubGhzProtocolDecoderBenincaARC instance + */ +void subghz_protocol_decoder_beninca_arc_free(void* context); + +/** + * Reset decoder SubGhzProtocolDecoderBenincaARC. + * @param context Pointer to a SubGhzProtocolDecoderBenincaARC instance + */ +void subghz_protocol_decoder_beninca_arc_reset(void* context); + +/** + * Parse a raw sequence of levels and durations received from the air. + * @param context Pointer to a SubGhzProtocolDecoderBenincaARC instance + * @param level Signal level true-high false-low + * @param duration Duration of this level in, us + */ +void subghz_protocol_decoder_beninca_arc_feed(void* context, bool level, uint32_t duration); + +/** + * Getting the hash sum of the last randomly received parcel. + * @param context Pointer to a SubGhzProtocolDecoderBenincaARC instance + * @return hash Hash sum + */ +uint8_t subghz_protocol_decoder_beninca_arc_get_hash_data(void* context); + +/** + * Serialize data SubGhzProtocolDecoderBenincaARC. + * @param context Pointer to a SubGhzProtocolDecoderBenincaARC instance + * @param flipper_format Pointer to a FlipperFormat instance + * @param preset The modulation on which the signal was received, SubGhzRadioPreset + * @return status + */ +SubGhzProtocolStatus subghz_protocol_decoder_beninca_arc_serialize( + void* context, + FlipperFormat* flipper_format, + SubGhzRadioPreset* preset); + +/** + * Deserialize data SubGhzProtocolDecoderBenincaARC. + * @param context Pointer to a SubGhzProtocolDecoderBenincaARC instance + * @param flipper_format Pointer to a FlipperFormat instance + * @return status + */ +SubGhzProtocolStatus + subghz_protocol_decoder_beninca_arc_deserialize(void* context, FlipperFormat* flipper_format); + +/** + * Getting a textual representation of the received data. + * @param context Pointer to a SubGhzProtocolDecoderBenincaARC instance + * @param output Resulting text + */ +void subghz_protocol_decoder_beninca_arc_get_string(void* context, FuriString* output); diff --git a/lib/subghz/protocols/keeloq_common.h b/lib/subghz/protocols/keeloq_common.h index c4af17f26..90c5ef6d7 100644 --- a/lib/subghz/protocols/keeloq_common.h +++ b/lib/subghz/protocols/keeloq_common.h @@ -25,6 +25,7 @@ #define KEELOQ_LEARNING_MAGIC_SERIAL_TYPE_1 6u #define KEELOQ_LEARNING_MAGIC_SERIAL_TYPE_2 7u #define KEELOQ_LEARNING_MAGIC_SERIAL_TYPE_3 8u +// #define BENINCA_ARC_KEY_TYPE 9u -- RESERVED /** * Simple Learning Encrypt diff --git a/lib/subghz/protocols/protocol_items.c b/lib/subghz/protocols/protocol_items.c index 230b9a508..2c4054dd2 100644 --- a/lib/subghz/protocols/protocol_items.c +++ b/lib/subghz/protocols/protocol_items.c @@ -27,6 +27,7 @@ const SubGhzProtocol* const subghz_protocol_registry_items[] = { &subghz_protocol_hay21, &subghz_protocol_revers_rb2, &subghz_protocol_feron, &subghz_protocol_roger, &subghz_protocol_elplast, &subghz_protocol_treadmill37, + &subghz_protocol_beninca_arc, }; const SubGhzProtocolRegistry subghz_protocol_registry = { diff --git a/lib/subghz/protocols/protocol_items.h b/lib/subghz/protocols/protocol_items.h index 223dd1712..f61e71420 100644 --- a/lib/subghz/protocols/protocol_items.h +++ b/lib/subghz/protocols/protocol_items.h @@ -54,3 +54,4 @@ #include "roger.h" #include "elplast.h" #include "treadmill37.h" +#include "beninca_arc.h" diff --git a/lib/subghz/protocols/public_api.h b/lib/subghz/protocols/public_api.h index c9a866f2c..30b8212ce 100644 --- a/lib/subghz/protocols/public_api.h +++ b/lib/subghz/protocols/public_api.h @@ -213,6 +213,24 @@ bool subghz_protocol_kinggates_stylo_4k_create_data( uint16_t cnt, SubGhzRadioPreset* preset); +/** + * Key generation from simple data. + * @param context Pointer to a SubGhzProtocolEncoderBenincaARC instance + * @param flipper_format Pointer to a FlipperFormat instance + * @param serial Serial number, 32 bit + * @param btn Button number, 8 bit + * @param cnt Counter value, 32 bit + * @param preset Modulation, SubGhzRadioPreset + * @return true On success + */ +bool subghz_protocol_beninca_arc_create_data( + void* context, + FlipperFormat* flipper_format, + uint32_t serial, + uint8_t btn, + uint32_t cnt, + SubGhzRadioPreset* preset); + typedef struct SubGhzProtocolDecoderBinRAW SubGhzProtocolDecoderBinRAW; void subghz_protocol_decoder_bin_raw_data_input_rssi( diff --git a/targets/f7/api_symbols.csv b/targets/f7/api_symbols.csv index 2e59c7d51..7e6190628 100755 --- a/targets/f7/api_symbols.csv +++ b/targets/f7/api_symbols.csv @@ -1,5 +1,5 @@ entry,status,name,type,params -Version,+,87.3,, +Version,+,87.4,, Header,+,applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h,, Header,+,applications/services/applications.h,, Header,+,applications/services/bt/bt_service/bt.h,, @@ -3684,6 +3684,7 @@ Function,+,subghz_keystore_raw_get_data,_Bool,"const char*, size_t, uint8_t*, si Function,+,subghz_keystore_reset_kl,void,SubGhzKeystore* Function,+,subghz_keystore_save,_Bool,"SubGhzKeystore*, const char*, uint8_t*" Function,+,subghz_protocol_alutech_at_4n_create_data,_Bool,"void*, FlipperFormat*, uint32_t, uint8_t, uint16_t, SubGhzRadioPreset*" +Function,+,subghz_protocol_beninca_arc_create_data,_Bool,"void*, FlipperFormat*, uint32_t, uint8_t, uint32_t, SubGhzRadioPreset*" Function,+,subghz_protocol_blocks_add_bit,void,"SubGhzBlockDecoder*, uint8_t" Function,+,subghz_protocol_blocks_add_bytes,uint8_t,"const uint8_t[], size_t" Function,+,subghz_protocol_blocks_add_to_128_bit,void,"SubGhzBlockDecoder*, uint8_t, uint64_t*"