diff --git a/applications/main/subghz/helpers/subghz_custom_event.h b/applications/main/subghz/helpers/subghz_custom_event.h index ad26123ea..56bc7fe5f 100644 --- a/applications/main/subghz/helpers/subghz_custom_event.h +++ b/applications/main/subghz/helpers/subghz_custom_event.h @@ -5,68 +5,6 @@ typedef enum { SubGhzCustomEventManagerSet, SubGhzCustomEventManagerSetRAW, - //SubmenuIndex - SubmenuIndexFaacSLH_Manual_433, - SubmenuIndexFaacSLH_Manual_868, - SubmenuIndexFaacSLH_433, - SubmenuIndexFaacSLH_868, - SubmenuIndexBFTClone, - SubmenuIndexBFTMitto, - SubmenuIndexSomfyTelis, - SubmenuIndexBeninca433, - SubmenuIndexBeninca868, - SubmenuIndexAllmatic433, - SubmenuIndexAllmatic868, - SubmenuIndexCenturion433, - SubmenuIndexIronLogic, - SubmenuIndexElmesElectronic, - SubmenuIndexSommer_FM_434, - SubmenuIndexSommer_FM_868, - SubmenuIndexStilmatic, - SubmenuIndexDTMNeo433, - SubmenuIndexDeaMio433, - SubmenuIndexGibidi433, - SubmenuIndexNiceMHouse_433_92, - SubmenuIndexJCM_433_92, - SubmenuIndexFAACRCXT_433_92, - SubmenuIndexFAACRCXT_868, - SubmenuIndexNormstahl_433_92, - SubmenuIndexGeniusBravo433, - SubmenuIndexGSN, - SubmenuIndexAprimatic, - SubmenuIndexHCS101_433_92, - SubmenuIndexANMotorsAT4, - SubmenuIndexAlutechAT4N, - SubmenuIndexNiceFlo12bit, - SubmenuIndexNiceFlo24bit, - SubmenuIndexNiceFlorS_433_92, - SubmenuIndexNiceOne_433_92, - SubmenuIndexNiceSmilo_433_92, - SubmenuIndexCAME12bit, - SubmenuIndexCAME24bit, - SubmenuIndexCAME12bit868, - SubmenuIndexCAME24bit868, - SubmenuIndexCAMETwee, - SubmenuIndexCAMESpace, - SubmenuIndexCameAtomo433, - SubmenuIndexCameAtomo868, - SubmenuIndexPricenton433, - SubmenuIndexPricenton315, - SubmenuIndexBETT_433, - SubmenuIndexLinear_300_00, - SubmenuIndexNeroSketch, //Deleted in OFW - SubmenuIndexNeroRadio, //Deleted in OFW - SubmenuIndexGateTX, - SubmenuIndexDoorHan_315_00, - SubmenuIndexDoorHan_433_92, - SubmenuIndexSecPlus_v1_315_00, - SubmenuIndexSecPlus_v1_390_00, - SubmenuIndexSecPlus_v1_433_00, - SubmenuIndexSecPlus_v2_310_00, - SubmenuIndexSecPlus_v2_315_00, - SubmenuIndexSecPlus_v2_390_00, - SubmenuIndexSecPlus_v2_433_00, - //SubGhzCustomEvent SubGhzCustomEventSceneDeleteSuccess = 100, SubGhzCustomEventSceneDelete, @@ -123,3 +61,68 @@ typedef enum { SubGhzCustomEventByteInputDone, } SubGhzCustomEvent; + +typedef enum { + SetTypeFaacSLH_Manual_868, + SetTypeFaacSLH_Manual_433, + SetTypeBFTClone, + SetTypeFaacSLH_868, + SetTypeFaacSLH_433, + SetTypeBFTMitto, + SetTypeSomfyTelis, + SetTypeANMotorsAT4, + SetTypeAlutechAT4N, + SetTypeHCS101_433_92, + SetTypeDoorHan_315_00, + SetTypeDoorHan_433_92, + SetTypeBeninca433, + SetTypeBeninca868, + SetTypeAllmatic433, + SetTypeAllmatic868, + SetTypeCenturion433, + SetTypeSommer_FM_434, + SetTypeSommer_FM_868, + SetTypeStilmatic, + SetTypeIronLogic, + SetTypeDeaMio433, + SetTypeDTMNeo433, + SetTypeGibidi433, + SetTypeGSN, + SetTypeAprimatic, + SetTypeElmesElectronic, + SetTypeNormstahl_433_92, + SetTypeJCM_433_92, + SetTypeFAACRCXT_433_92, + SetTypeFAACRCXT_868, + SetTypeGeniusBravo433, + SetTypeNiceMHouse_433_92, + SetTypeNiceSmilo_433_92, + SetTypeNiceFlorS_433_92, + SetTypeNiceOne_433_92, + SetTypeNiceFlo12bit, + SetTypeNiceFlo24bit, + SetTypeCAME12bit, + SetTypeCAME24bit, + SetTypeCAME12bit868, + SetTypeCAME24bit868, + SetTypeCAMETwee, + SetTypeCameAtomo433, + SetTypeCameAtomo868, + SetTypeCAMESpace, + SetTypePricenton315, + SetTypePricenton433, + SetTypeBETT_433, + SetTypeLinear_300_00, + // SetTypeNeroSketch, //Deleted in OFW + // SetTypeNeroRadio, //Deleted in OFW + SetTypeGateTX, + SetTypeSecPlus_v1_315_00, + SetTypeSecPlus_v1_390_00, + SetTypeSecPlus_v1_433_00, + SetTypeSecPlus_v2_310_00, + SetTypeSecPlus_v2_315_00, + SetTypeSecPlus_v2_390_00, + SetTypeSecPlus_v2_433_00, + + SetTypeMAX, +} SetType; diff --git a/applications/main/subghz/scenes/subghz_scene_set_cnt.c b/applications/main/subghz/scenes/subghz_scene_set_cnt.c index 0a07557fb..4952c2b14 100644 --- a/applications/main/subghz/scenes/subghz_scene_set_cnt.c +++ b/applications/main/subghz/scenes/subghz_scene_set_cnt.c @@ -17,7 +17,7 @@ void subghz_scene_set_cnt_on_enter(void* context) { scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneSetType); switch(state) { - case SubmenuIndexBFTClone: + case SetTypeBFTClone: byte_input_set_header_text(byte_input, "Enter COUNTER in Hex"); byte_input_set_result_callback( byte_input, @@ -27,8 +27,8 @@ void subghz_scene_set_cnt_on_enter(void* context) { subghz->secure_data->cnt, 2); break; - case SubmenuIndexFaacSLH_Manual_433: - case SubmenuIndexFaacSLH_Manual_868: + case SetTypeFaacSLH_Manual_433: + case SetTypeFaacSLH_Manual_868: byte_input_set_header_text(byte_input, "Enter COUNTER in Hex 20 bits"); byte_input_set_result_callback( byte_input, diff --git a/applications/main/subghz/scenes/subghz_scene_set_seed.c b/applications/main/subghz/scenes/subghz_scene_set_seed.c index c1f3662cb..a22daf919 100644 --- a/applications/main/subghz/scenes/subghz_scene_set_seed.c +++ b/applications/main/subghz/scenes/subghz_scene_set_seed.c @@ -32,11 +32,11 @@ bool subghz_scene_set_seed_on_event(void* context, SceneManagerEvent event) { uint32_t fix_part, cnt, seed; if(event.type == SceneManagerEventTypeCustom) { if(event.event == SubGhzCustomEventByteInputDone) { - SubGhzCustomEvent state = + SetType state = scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneSetType); switch(state) { - case SubmenuIndexBFTClone: + case SetTypeBFTClone: fix_part = subghz->secure_data->fix[0] << 24 | subghz->secure_data->fix[1] << 16 | subghz->secure_data->fix[2] << 8 | subghz->secure_data->fix[3]; @@ -62,8 +62,8 @@ bool subghz_scene_set_seed_on_event(void* context, SceneManagerEvent event) { } consumed = true; break; - case SubmenuIndexFaacSLH_Manual_433: - case SubmenuIndexFaacSLH_Manual_868: + case SetTypeFaacSLH_Manual_433: + case SetTypeFaacSLH_Manual_868: fix_part = subghz->secure_data->fix[0] << 24 | subghz->secure_data->fix[1] << 16 | subghz->secure_data->fix[2] << 8 | subghz->secure_data->fix[3]; @@ -73,7 +73,7 @@ bool subghz_scene_set_seed_on_event(void* context, SceneManagerEvent event) { seed = subghz->secure_data->seed[0] << 24 | subghz->secure_data->seed[1] << 16 | subghz->secure_data->seed[2] << 8 | subghz->secure_data->seed[3]; - if(state == SubmenuIndexFaacSLH_Manual_433) { + if(state == SetTypeFaacSLH_Manual_433) { generated_protocol = subghz_txrx_gen_faac_slh_protocol( subghz->txrx, "AM650", @@ -83,7 +83,7 @@ bool subghz_scene_set_seed_on_event(void* context, SceneManagerEvent event) { (cnt & 0xFFFFF), seed, "FAAC_SLH"); - } else if(state == SubmenuIndexFaacSLH_Manual_868) { + } else if(state == SetTypeFaacSLH_Manual_868) { generated_protocol = subghz_txrx_gen_faac_slh_protocol( subghz->txrx, "AM650", diff --git a/applications/main/subghz/scenes/subghz_scene_set_type.c b/applications/main/subghz/scenes/subghz_scene_set_type.c index 17f358fa6..90b30f076 100644 --- a/applications/main/subghz/scenes/subghz_scene_set_type.c +++ b/applications/main/subghz/scenes/subghz_scene_set_type.c @@ -10,361 +10,76 @@ void subghz_scene_set_type_submenu_callback(void* context, uint32_t index) { view_dispatcher_send_custom_event(subghz->view_dispatcher, index); } +static const char* submenu_names[SetTypeMAX] = { + [SetTypeFaacSLH_Manual_868] = "FAAC SLH [Man.] 868MHz", + [SetTypeFaacSLH_Manual_433] = "FAAC SLH [Man.] 433MHz", + [SetTypeBFTClone] = "BFT [Manual] 433MHz", + [SetTypeFaacSLH_868] = "FAAC SLH 868MHz", + [SetTypeFaacSLH_433] = "FAAC SLH 433MHz", + [SetTypeBFTMitto] = "BFT Mitto 433MHz", + [SetTypeSomfyTelis] = "Somfy Telis 433MHz", + [SetTypeANMotorsAT4] = "AN-Motors AT4 433MHz", + [SetTypeAlutechAT4N] = "Alutech AT4N 433MHz", + [SetTypeHCS101_433_92] = "KL: HCS101 433MHz", + [SetTypeDoorHan_315_00] = "KL: DoorHan 315MHz", + [SetTypeDoorHan_433_92] = "KL: DoorHan 433MHz", + [SetTypeBeninca433] = "KL: Beninca 433MHz", + [SetTypeBeninca868] = "KL: Beninca 868MHz", + [SetTypeAllmatic433] = "KL: Allmatic 433MHz", + [SetTypeAllmatic868] = "KL: Allmatic 868MHz", + [SetTypeCenturion433] = "KL: Centurion 433MHz", + [SetTypeSommer_FM_434] = "KL: Sommer 434MHz", + [SetTypeSommer_FM_868] = "KL: Sommer 868MHz", + [SetTypeStilmatic] = "KL: Stilmatic 433MHz", + [SetTypeIronLogic] = "KL: IronLogic 433MHz", + [SetTypeDeaMio433] = "KL: DEA Mio 433MHz", + [SetTypeDTMNeo433] = "KL: DTM Neo 433MHz", + [SetTypeGibidi433] = "KL: Gibidi 433MHz", + [SetTypeGSN] = "KL: GSN 433MHz", + [SetTypeAprimatic] = "KL: Aprimatic 433MHz", + [SetTypeElmesElectronic] = "KL: Elmes (PL) 433MHz", + [SetTypeNormstahl_433_92] = "KL: Normstahl 433MHz", + [SetTypeJCM_433_92] = "KL: JCM Tech 433MHz", + [SetTypeFAACRCXT_433_92] = "KL: FAAC RC,XT 433MHz", + [SetTypeFAACRCXT_868] = "KL: FAAC RC,XT 868MHz", + [SetTypeGeniusBravo433] = "KL: Genius Bravo 433MHz", + [SetTypeNiceMHouse_433_92] = "KL: Nice Mhouse 433MHz", + [SetTypeNiceSmilo_433_92] = "KL: Nice Smilo 433MHz", + [SetTypeNiceFlorS_433_92] = "Nice FloR-S 433MHz", + [SetTypeNiceOne_433_92] = "Nice One 433MHz", + [SetTypeNiceFlo12bit] = "Nice Flo 12bit 433MHz", + [SetTypeNiceFlo24bit] = "Nice Flo 24bit 433MHz", + [SetTypeCAME12bit] = "CAME 12bit 433MHz", + [SetTypeCAME24bit] = "CAME 24bit 433MHz", + [SetTypeCAME12bit868] = "CAME 12bit 868MHz", + [SetTypeCAME24bit868] = "CAME 24bit 868MHz", + [SetTypeCAMETwee] = "CAME TWEE 433MHz", + [SetTypeCameAtomo433] = "CAME Atomo 433MHz", + [SetTypeCameAtomo868] = "CAME Atomo 868MHz", + [SetTypeCAMESpace] = "KL: CAME Space 433MHz", + [SetTypePricenton315] = "Princeton 315MHz", + [SetTypePricenton433] = "Princeton 433MHz", + [SetTypeBETT_433] = "BETT 433MHz", + [SetTypeLinear_300_00] = "Linear 300MHz", + // [SetTypeNeroSketch] = "Nero Sketch", // Deleted in OFW + // [SetTypeNeroRadio] = "Nero Radio", // Deleted in OFW + [SetTypeGateTX] = "Gate TX 433MHz", + [SetTypeSecPlus_v1_315_00] = "Security+1.0 315MHz", + [SetTypeSecPlus_v1_390_00] = "Security+1.0 390MHz", + [SetTypeSecPlus_v1_433_00] = "Security+1.0 433MHz", + [SetTypeSecPlus_v2_310_00] = "Security+2.0 310MHz", + [SetTypeSecPlus_v2_315_00] = "Security+2.0 315MHz", + [SetTypeSecPlus_v2_390_00] = "Security+2.0 390MHz", + [SetTypeSecPlus_v2_433_00] = "Security+2.0 433MHz", +}; + void subghz_scene_set_type_on_enter(void* context) { SubGhz* subghz = context; - submenu_add_item( - subghz->submenu, - "FAAC SLH [Man.] 868MHz", - SubmenuIndexFaacSLH_Manual_868, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "FAAC SLH [Man.] 433MHz", - SubmenuIndexFaacSLH_Manual_433, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "BFT [Manual] 433MHz", - SubmenuIndexBFTClone, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "FAAC SLH 868MHz", - SubmenuIndexFaacSLH_868, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "FAAC SLH 433MHz", - SubmenuIndexFaacSLH_433, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "BFT Mitto 433MHz", - SubmenuIndexBFTMitto, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "Somfy Telis 433MHz", - SubmenuIndexSomfyTelis, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "AN-Motors AT4 433MHz", - SubmenuIndexANMotorsAT4, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "Alutech AT4N 433MHz", - SubmenuIndexAlutechAT4N, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "KL: HCS101 433MHz", - SubmenuIndexHCS101_433_92, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "KL: DoorHan 315MHz", - SubmenuIndexDoorHan_315_00, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "KL: DoorHan 433MHz", - SubmenuIndexDoorHan_433_92, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "KL: Beninca 433MHz", - SubmenuIndexBeninca433, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "KL: Beninca 868MHz", - SubmenuIndexBeninca868, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "KL: Allmatic 433MHz", - SubmenuIndexAllmatic433, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "KL: Allmatic 868MHz", - SubmenuIndexAllmatic868, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "KL: Centurion 433MHz", - SubmenuIndexCenturion433, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "KL: Sommer 434MHz", - SubmenuIndexSommer_FM_434, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "KL: Sommer 868MHz", - SubmenuIndexSommer_FM_868, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "KL: Stilmatic 433MHz", - SubmenuIndexStilmatic, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "KL: IronLogic 433MHz", - SubmenuIndexIronLogic, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "KL: DEA Mio 433MHz", - SubmenuIndexDeaMio433, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "KL: DTM Neo 433MHz", - SubmenuIndexDTMNeo433, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "KL: Gibidi 433MHz", - SubmenuIndexGibidi433, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "KL: GSN 433MHz", - SubmenuIndexGSN, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "KL: Aprimatic 433MHz", - SubmenuIndexAprimatic, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "KL: Elmes (PL) 433MHz", - SubmenuIndexElmesElectronic, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "KL: Normstahl 433MHz", - SubmenuIndexNormstahl_433_92, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "KL: JCM Tech 433MHz", - SubmenuIndexJCM_433_92, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "KL: FAAC RC,XT 433MHz", - SubmenuIndexFAACRCXT_433_92, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "KL: FAAC RC,XT 868MHz", - SubmenuIndexFAACRCXT_868, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "KL: Genius Bravo 433MHz", - SubmenuIndexGeniusBravo433, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "KL: Nice Mhouse 433MHz", - SubmenuIndexNiceMHouse_433_92, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "KL: Nice Smilo 433MHz", - SubmenuIndexNiceSmilo_433_92, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "Nice FloR-S 433MHz", - SubmenuIndexNiceFlorS_433_92, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "Nice One 433MHz", - SubmenuIndexNiceOne_433_92, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "Nice Flo 12bit 433MHz", - SubmenuIndexNiceFlo12bit, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "Nice Flo 24bit 433MHz", - SubmenuIndexNiceFlo24bit, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "CAME 12bit 433MHz", - SubmenuIndexCAME12bit, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "CAME 24bit 433MHz", - SubmenuIndexCAME24bit, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "CAME 12bit 868MHz", - SubmenuIndexCAME12bit868, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "CAME 24bit 868MHz", - SubmenuIndexCAME24bit868, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "CAME TWEE 433MHz", - SubmenuIndexCAMETwee, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "CAME Atomo 433MHz", - SubmenuIndexCameAtomo433, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "CAME Atomo 868MHz", - SubmenuIndexCameAtomo868, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "KL: CAME Space 433MHz", - SubmenuIndexCAMESpace, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "Princeton 315MHz", - SubmenuIndexPricenton315, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "Princeton 433MHz", - SubmenuIndexPricenton433, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "BETT 433MHz", - SubmenuIndexBETT_433, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "Linear 300MHz", - SubmenuIndexLinear_300_00, - subghz_scene_set_type_submenu_callback, - subghz); - // submenu_add_item( - // subghz->submenu, "Nero Sketch", SubmenuIndexNeroSketch, subghz_scene_set_type_submenu_callback, subghz); - // submenu_add_item( - // subghz->submenu, "Nero Radio", SubmenuIndexNeroRadio, subghz_scene_set_type_submenu_callback, subghz); - submenu_add_item( - subghz->submenu, - "Gate TX 433MHz", - SubmenuIndexGateTX, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "Security+1.0 315MHz", - SubmenuIndexSecPlus_v1_315_00, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "Security+1.0 390MHz", - SubmenuIndexSecPlus_v1_390_00, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "Security+1.0 433MHz", - SubmenuIndexSecPlus_v1_433_00, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "Security+2.0 310MHz", - SubmenuIndexSecPlus_v2_310_00, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "Security+2.0 315MHz", - SubmenuIndexSecPlus_v2_315_00, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "Security+2.0 390MHz", - SubmenuIndexSecPlus_v2_390_00, - subghz_scene_set_type_submenu_callback, - subghz); - submenu_add_item( - subghz->submenu, - "Security+2.0 433MHz", - SubmenuIndexSecPlus_v2_433_00, - subghz_scene_set_type_submenu_callback, - subghz); + for(SetType i = 0; i < SetTypeMAX; i++) { + submenu_add_item( + subghz->submenu, submenu_names[i], i, subghz_scene_set_type_submenu_callback, subghz); + } submenu_set_selected_item( subghz->submenu, scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneSetType)); @@ -372,521 +87,742 @@ void subghz_scene_set_type_on_enter(void* context) { view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdMenu); } +typedef enum { + GenData, + GenFaacSLH, + GenKeeloq, + GenCameAtomo, + GenKeeloqBFT, + GenAlutechAt4n, + GenSomfyTelis, + GenNiceFlorS, + GenSecPlus1, + GenSecPlus2, +} GenType; + +typedef struct { + GenType type; + const char* mod; + uint32_t freq; + union { + struct { + const char* name; + uint32_t key; + uint8_t bits; + uint16_t te; + } data; + struct { + uint32_t serial; + uint8_t btn; + uint8_t cnt; + uint32_t seed; + const char* manuf; + } faac_slh; + struct { + uint32_t serial; + uint8_t btn; + uint8_t cnt; + const char* manuf; + } keeloq; + struct { + uint32_t serial; + uint8_t cnt; + } came_atomo; + struct { + uint32_t serial; + uint8_t btn; + uint8_t cnt; + uint32_t seed; + const char* manuf; + } keeloq_bft; + struct { + uint32_t serial; + uint8_t btn; + uint8_t cnt; + } alutech_at_4n; + struct { + uint32_t serial; + uint8_t btn; + uint8_t cnt; + } somfy_telis; + struct { + uint32_t serial; + uint8_t btn; + uint8_t cnt; + bool nice_one; + } nice_flor_s; + struct { + uint32_t serial; + uint8_t btn; + uint32_t cnt; + } sec_plus_2; + }; +} GenInfo; + bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) { SubGhz* subghz = context; bool generated_protocol = false; if(event.type == SceneManagerEventTypeCustom) { + if(event.event >= SetTypeMAX) { + return false; + } + scene_manager_set_scene_state(subghz->scene_manager, SubGhzSceneSetType, event.event); + + if(event.event == SetTypeFaacSLH_Manual_868 || event.event == SetTypeFaacSLH_Manual_433 || + event.event == SetTypeBFTClone) { + scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSetFix); + return true; + } + uint32_t key = (uint32_t)rand(); + GenInfo gen_info = {0}; switch(event.event) { - case SubmenuIndexFaacSLH_Manual_868: - scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSetFix); + case SetTypePricenton433: + gen_info = (GenInfo){ + .type = GenData, + .mod = "AM650", + .freq = 433920000, + .data.name = SUBGHZ_PROTOCOL_PRINCETON_NAME, + .data.key = (key & 0x00FFFFF0) | 0x4, // btn 0x1, 0x2, 0x4, 0x8 + .data.bits = 24, + .data.te = 400}; break; - case SubmenuIndexFaacSLH_Manual_433: - scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSetFix); + case SetTypePricenton315: + gen_info = (GenInfo){ + .type = GenData, + .mod = "AM650", + .freq = 315000000, + .data.name = SUBGHZ_PROTOCOL_PRINCETON_NAME, + .data.key = (key & 0x00FFFFF0) | 0x4, // btn 0x1, 0x2, 0x4, 0x8 + .data.bits = 24, + .data.te = 400}; break; - case SubmenuIndexBFTClone: - scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSetFix); + case SetTypeNiceFlo12bit: + gen_info = (GenInfo){ + .type = GenData, + .mod = "AM650", + .freq = 433920000, + .data.name = SUBGHZ_PROTOCOL_NICE_FLO_NAME, + .data.key = (key & 0x00000FF0) | 0x1, // btn 0x1, 0x2, 0x4 + .data.bits = 12, + .data.te = 0}; break; - case SubmenuIndexPricenton433: - key = (key & 0x00FFFFF0) | 0x4; //btn 0x1, 0x2, 0x4, 0x8 - generated_protocol = subghz_txrx_gen_data_protocol_and_te( - subghz->txrx, "AM650", 433920000, SUBGHZ_PROTOCOL_PRINCETON_NAME, key, 24, 400); + case SetTypeNiceFlo24bit: + gen_info = (GenInfo){ + .type = GenData, + .mod = "AM650", + .freq = 433920000, + .data.name = SUBGHZ_PROTOCOL_NICE_FLO_NAME, + .data.key = (key & 0x00FFFFF0) | 0x4, // btn 0x1, 0x2, 0x4, 0x8 + .data.bits = 24, + .data.te = 0}; break; - case SubmenuIndexPricenton315: - key = (key & 0x00FFFFF0) | 0x4; //btn 0x1, 0x2, 0x4, 0x8 - generated_protocol = subghz_txrx_gen_data_protocol_and_te( - subghz->txrx, "AM650", 315000000, SUBGHZ_PROTOCOL_PRINCETON_NAME, key, 24, 400); + case SetTypeCAME12bit: + gen_info = (GenInfo){ + .type = GenData, + .mod = "AM650", + .freq = 433920000, + .data.name = SUBGHZ_PROTOCOL_CAME_NAME, + .data.key = (key & 0x00000FF0) | 0x1, // btn 0x1, 0x2, 0x4 + .data.bits = 12, + .data.te = 0}; break; - case SubmenuIndexNiceFlo12bit: - key = (key & 0x00000FF0) | 0x1; //btn 0x1, 0x2, 0x4 - generated_protocol = subghz_txrx_gen_data_protocol( - subghz->txrx, "AM650", 433920000, SUBGHZ_PROTOCOL_NICE_FLO_NAME, key, 12); + case SetTypeCAME24bit: + gen_info = (GenInfo){ + .type = GenData, + .mod = "AM650", + .freq = 433920000, + .data.name = SUBGHZ_PROTOCOL_CAME_NAME, + .data.key = (key & 0x00FFFFF0) | 0x4, // btn 0x1, 0x2, 0x4, 0x8 + .data.bits = 24, + .data.te = 0}; break; - case SubmenuIndexNiceFlo24bit: - key = (key & 0x00FFFFF0) | 0x4; //btn 0x1, 0x2, 0x4, 0x8 - generated_protocol = subghz_txrx_gen_data_protocol( - subghz->txrx, "AM650", 433920000, SUBGHZ_PROTOCOL_NICE_FLO_NAME, key, 24); + case SetTypeCAME12bit868: + gen_info = (GenInfo){ + .type = GenData, + .mod = "AM650", + .freq = 868350000, + .data.name = SUBGHZ_PROTOCOL_CAME_NAME, + .data.key = (key & 0x00000FF0) | 0x1, // btn 0x1, 0x2, 0x4 + .data.bits = 12, + .data.te = 0}; break; - case SubmenuIndexCAME12bit: - key = (key & 0x00000FF0) | 0x1; //btn 0x1, 0x2, 0x4 - generated_protocol = subghz_txrx_gen_data_protocol( - subghz->txrx, "AM650", 433920000, SUBGHZ_PROTOCOL_CAME_NAME, key, 12); + case SetTypeCAME24bit868: + gen_info = (GenInfo){ + .type = GenData, + .mod = "AM650", + .freq = 868350000, + .data.name = SUBGHZ_PROTOCOL_CAME_NAME, + .data.key = (key & 0x00FFFFF0) | 0x4, // btn 0x1, 0x2, 0x4, 0x8 + .data.bits = 24, + .data.te = 0}; break; - case SubmenuIndexCAME24bit: - key = (key & 0x00FFFFF0) | 0x4; //btn 0x1, 0x2, 0x4, 0x8 - generated_protocol = subghz_txrx_gen_data_protocol( - subghz->txrx, "AM650", 433920000, SUBGHZ_PROTOCOL_CAME_NAME, key, 24); + case SetTypeLinear_300_00: + gen_info = (GenInfo){ + .type = GenData, + .mod = "AM650", + .freq = 300000000, + .data.name = SUBGHZ_PROTOCOL_LINEAR_NAME, + .data.key = (key & 0x3FF), + .data.bits = 10, + .data.te = 0}; break; - case SubmenuIndexCAME12bit868: - key = (key & 0x00000FF0) | 0x1; //btn 0x1, 0x2, 0x4 - generated_protocol = subghz_txrx_gen_data_protocol( - subghz->txrx, "AM650", 868350000, SUBGHZ_PROTOCOL_CAME_NAME, key, 12); + case SetTypeBETT_433: + gen_info = (GenInfo){ + .type = GenData, + .mod = "AM650", + .freq = 433920000, + .data.name = SUBGHZ_PROTOCOL_BETT_NAME, + .data.key = (key & 0x0000FFF0), + .data.bits = 18, + .data.te = 0}; break; - case SubmenuIndexCAME24bit868: - key = (key & 0x00FFFFF0) | 0x4; //btn 0x1, 0x2, 0x4, 0x8 - generated_protocol = subghz_txrx_gen_data_protocol( - subghz->txrx, "AM650", 868350000, SUBGHZ_PROTOCOL_CAME_NAME, key, 24); + case SetTypeCAMETwee: + gen_info = (GenInfo){ + .type = GenData, + .mod = "AM650", + .freq = 433920000, + .data.name = SUBGHZ_PROTOCOL_CAME_TWEE_NAME, + .data.key = 0x003FFF7200000000 | ((key & 0x0FFFFFF0) ^ 0xE0E0E0EE), // ???? + .data.bits = 54, + .data.te = 0}; break; - case SubmenuIndexLinear_300_00: - key = (key & 0x3FF); - generated_protocol = subghz_txrx_gen_data_protocol( - subghz->txrx, "AM650", 300000000, SUBGHZ_PROTOCOL_LINEAR_NAME, key, 10); + case SetTypeGateTX: + gen_info = (GenInfo){ + .type = GenData, + .mod = "AM650", + .freq = 433920000, + .data.name = SUBGHZ_PROTOCOL_GATE_TX_NAME, // btn 0xF, 0xC, 0xA, 0x6 (?) + .data.key = subghz_protocol_blocks_reverse_key((key & 0x00F0FF00) | 0xF0040, 24), + .data.bits = 24, + .data.te = 0}; break; - case SubmenuIndexBETT_433: - key = (key & 0x0000FFF0); - generated_protocol = subghz_txrx_gen_data_protocol( - subghz->txrx, "AM650", 433920000, SUBGHZ_PROTOCOL_BETT_NAME, key, 18); + case SetTypeFaacSLH_433: + gen_info = (GenInfo){ + .type = GenFaacSLH, + .mod = "AM650", + .freq = 433920000, + .faac_slh.serial = ((key & 0x00FFFFF0) | 0xA0000006) >> 4, + .faac_slh.btn = 0x06, + .faac_slh.cnt = 0x02, + .faac_slh.seed = key, + .faac_slh.manuf = "FAAC_SLH"}; break; - case SubmenuIndexCAMETwee: - key = (key & 0x0FFFFFF0); - key = 0x003FFF7200000000 | (key ^ 0xE0E0E0EE); - generated_protocol = subghz_txrx_gen_data_protocol( - subghz->txrx, "AM650", 433920000, SUBGHZ_PROTOCOL_CAME_TWEE_NAME, key, 54); + case SetTypeFaacSLH_868: + gen_info = (GenInfo){ + .type = GenFaacSLH, + .mod = "AM650", + .freq = 868350000, + .faac_slh.serial = ((key & 0x00FFFFF0) | 0xA0000006) >> 4, + .faac_slh.btn = 0x06, + .faac_slh.cnt = 0x02, + .faac_slh.seed = key, + .faac_slh.manuf = "FAAC_SLH"}; break; - case SubmenuIndexGateTX: - key = (key & 0x00F0FF00) | 0xF << 16 | 0x40; //btn 0xF, 0xC, 0xA, 0x6 (?) - uint64_t rev_key = subghz_protocol_blocks_reverse_key(key, 24); - generated_protocol = subghz_txrx_gen_data_protocol( - subghz->txrx, "AM650", 433920000, SUBGHZ_PROTOCOL_GATE_TX_NAME, rev_key, 24); + case SetTypeBeninca433: + gen_info = (GenInfo){ + .type = GenKeeloq, + .mod = "AM650", + .freq = 433920000, + .keeloq.serial = (key & 0x000FFF00) | 0x00800080, + .keeloq.btn = 0x01, + .keeloq.cnt = 0x05, + .keeloq.manuf = "Beninca"}; break; - case SubmenuIndexFaacSLH_433: - generated_protocol = subghz_txrx_gen_faac_slh_protocol( - subghz->txrx, - "AM650", - 433920000, - ((key & 0x00FFFFF0) | 0xA0000006) >> 4, - 0x6, - 0x00002, - key, - "FAAC_SLH"); - if(!generated_protocol) { - furi_string_set( - subghz->error_str, "Function requires\nan SD card with\nfresh databases."); - scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); - } + case SetTypeBeninca868: + gen_info = (GenInfo){ + .type = GenKeeloq, + .mod = "AM650", + .freq = 868350000, + .keeloq.serial = (key & 0x000FFF00) | 0x00800080, + .keeloq.btn = 0x01, + .keeloq.cnt = 0x05, + .keeloq.manuf = "Beninca"}; break; - case SubmenuIndexFaacSLH_868: - generated_protocol = subghz_txrx_gen_faac_slh_protocol( - subghz->txrx, - "AM650", - 868350000, - ((key & 0x00FFFFF0) | 0xA0000006) >> 4, - 0x6, - 0x00002, - key, - "FAAC_SLH"); - if(!generated_protocol) { - furi_string_set( - subghz->error_str, "Function requires\nan SD card with\nfresh databases."); - scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); - } + case SetTypeAllmatic433: + gen_info = (GenInfo){ + .type = GenKeeloq, + .mod = "AM650", + .freq = 433920000, + .keeloq.serial = (key & 0x00FFFF00) | 0x01000011, + .keeloq.btn = 0x0C, + .keeloq.cnt = 0x05, + .keeloq.manuf = "Beninca"}; break; - case SubmenuIndexBeninca433: - generated_protocol = subghz_txrx_gen_keeloq_protocol( - subghz->txrx, - "AM650", - 433920000, - (key & 0x000FFF00) | 0x00800080, - 0x1, - 0x0005, - "Beninca"); - if(!generated_protocol) { - furi_string_set( - subghz->error_str, "Function requires\nan SD card with\nfresh databases."); - scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); - } + case SetTypeAllmatic868: + gen_info = (GenInfo){ + .type = GenKeeloq, + .mod = "AM650", + .freq = 868350000, + .keeloq.serial = (key & 0x00FFFF00) | 0x01000011, + .keeloq.btn = 0x0C, + .keeloq.cnt = 0x05, + .keeloq.manuf = "Beninca"}; break; - case SubmenuIndexBeninca868: - generated_protocol = subghz_txrx_gen_keeloq_protocol( - subghz->txrx, - "AM650", - 868350000, - (key & 0x000FFF00) | 0x00800080, - 0x1, - 0x0005, - "Beninca"); - if(!generated_protocol) { - furi_string_set( - subghz->error_str, "Function requires\nan SD card with\nfresh databases."); - scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); - } + case SetTypeCenturion433: + gen_info = (GenInfo){ + .type = GenKeeloq, + .mod = "AM650", + .freq = 433920000, + .keeloq.serial = (key & 0x0000FFFF), + .keeloq.btn = 0x02, + .keeloq.cnt = 0x03, + .keeloq.manuf = "Centurion"}; break; - case SubmenuIndexAllmatic433: - generated_protocol = subghz_txrx_gen_keeloq_protocol( - subghz->txrx, - "AM650", - 433920000, - (key & 0x00FFFF00) | 0x01000011, - 0xC, - 0x0005, - "Beninca"); - if(!generated_protocol) { - furi_string_set( - subghz->error_str, "Function requires\nan SD card with\nfresh databases."); - scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); - } + case SetTypeElmesElectronic: + gen_info = (GenInfo){ + .type = GenKeeloq, + .mod = "AM650", + .freq = 433920000, + .keeloq.serial = (key & 0x00FFFFFF) | 0x02000000, + .keeloq.btn = 0x02, + .keeloq.cnt = 0x03, + .keeloq.manuf = "Elmes_Poland"}; break; - case SubmenuIndexAllmatic868: - generated_protocol = subghz_txrx_gen_keeloq_protocol( - subghz->txrx, - "AM650", - 868350000, - (key & 0x00FFFF00) | 0x01000011, - 0xC, - 0x0005, - "Beninca"); - if(!generated_protocol) { - furi_string_set( - subghz->error_str, "Function requires\nan SD card with\nfresh databases."); - scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); - } + case SetTypeANMotorsAT4: + gen_info = (GenInfo){ + .type = GenKeeloq, + .mod = "AM650", + .freq = 433920000, + .keeloq.serial = (key & 0x000FFFFF) | 0x04700000, + .keeloq.btn = 0x02, + .keeloq.cnt = 0x21, + .keeloq.manuf = "AN-Motors"}; break; - case SubmenuIndexCenturion433: - generated_protocol = subghz_txrx_gen_keeloq_protocol( - subghz->txrx, "AM650", 433920000, (key & 0x0000FFFF), 0x2, 0x0003, "Centurion"); - if(!generated_protocol) { - furi_string_set( - subghz->error_str, "Function requires\nan SD card with\nfresh databases."); - scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); - } + case SetTypeAprimatic: + gen_info = (GenInfo){ + .type = GenKeeloq, + .mod = "AM650", + .freq = 433920000, + .keeloq.serial = (key & 0x000FFFFF) | 0x00600000, + .keeloq.btn = 0x04, + .keeloq.cnt = 0x03, + .keeloq.manuf = "Aprimatic"}; break; - case SubmenuIndexElmesElectronic: - generated_protocol = subghz_txrx_gen_keeloq_protocol( - subghz->txrx, - "AM650", - 433920000, - (key & 0x00FFFFFF) | 0x02000000, - 0x2, - 0x0003, - "Elmes_Poland"); - if(!generated_protocol) { - furi_string_set( - subghz->error_str, "Function requires\nan SD card with\nfresh databases."); - scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); - } + case SetTypeGibidi433: + gen_info = (GenInfo){ + .type = GenKeeloq, + .mod = "AM650", + .freq = 433920000, + .keeloq.serial = key & 0x00FFFFFF, + .keeloq.btn = 0x02, + .keeloq.cnt = 0x03, + .keeloq.manuf = "Gibidi"}; break; - case SubmenuIndexANMotorsAT4: - generated_protocol = subghz_txrx_gen_keeloq_protocol( - subghz->txrx, - "AM650", - 433920000, - (key & 0x000FFFFF) | 0x04700000, - 0x2, - 0x0021, - "AN-Motors"); - if(!generated_protocol) { - furi_string_set( - subghz->error_str, "Function requires\nan SD card with\nfresh databases."); - scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); - } + case SetTypeGSN: + gen_info = (GenInfo){ + .type = GenKeeloq, + .mod = "AM650", + .freq = 433920000, + .keeloq.serial = key & 0x0FFFFFFF, + .keeloq.btn = 0x02, + .keeloq.cnt = 0x03, + .keeloq.manuf = "GSN"}; break; - case SubmenuIndexAprimatic: - generated_protocol = subghz_txrx_gen_keeloq_protocol( - subghz->txrx, - "AM650", - 433920000, - (key & 0x000FFFFF) | 0x00600000, - 0x4, - 0x0003, - "Aprimatic"); - if(!generated_protocol) { - furi_string_set( - subghz->error_str, "Function requires\nan SD card with\nfresh databases."); - scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); - } + case SetTypeIronLogic: + gen_info = (GenInfo){ + .type = GenKeeloq, + .mod = "AM650", + .freq = 433920000, + .keeloq.serial = key & 0x00FFFFF0, + .keeloq.btn = 0x04, + .keeloq.cnt = 0x05, + .keeloq.manuf = "IronLogic"}; break; - case SubmenuIndexGibidi433: - generated_protocol = subghz_txrx_gen_keeloq_protocol( - subghz->txrx, "AM650", 433920000, key & 0x00FFFFFF, 0x2, 0x0003, "Gibidi"); - if(!generated_protocol) { - furi_string_set( - subghz->error_str, "Function requires\nan SD card with\nfresh databases."); - scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); - } + case SetTypeStilmatic: + gen_info = (GenInfo){ + .type = GenKeeloq, + .mod = "AM650", + .freq = 433920000, + .keeloq.serial = key & 0x0FFFFFFF, + .keeloq.btn = 0x01, + .keeloq.cnt = 0x03, + .keeloq.manuf = "Stilmatic"}; break; - case SubmenuIndexGSN: - generated_protocol = subghz_txrx_gen_keeloq_protocol( - subghz->txrx, "AM650", 433920000, key & 0x0FFFFFFF, 0x2, 0x0003, "GSN"); - if(!generated_protocol) { - furi_string_set( - subghz->error_str, "Function requires\nan SD card with\nfresh databases."); - scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); - } + case SetTypeSommer_FM_434: + gen_info = (GenInfo){ + .type = GenKeeloq, + .mod = "FM476", + .freq = 434420000, + .keeloq.serial = key & 0x0FFFFFFF, + .keeloq.btn = 0x04, + .keeloq.cnt = 0x03, + .keeloq.manuf = "Sommer(fsk476)"}; break; - case SubmenuIndexIronLogic: - generated_protocol = subghz_txrx_gen_keeloq_protocol( - subghz->txrx, "AM650", 433920000, key & 0x00FFFFF0, 0x4, 0x0005, "IronLogic"); - if(!generated_protocol) { - furi_string_set( - subghz->error_str, "Function requires\nan SD card with\nfresh databases."); - scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); - } + case SetTypeSommer_FM_868: + gen_info = (GenInfo){ + .type = GenKeeloq, + .mod = "FM476", + .freq = 868800000, + .keeloq.serial = key & 0x0FFFFFFF, + .keeloq.btn = 0x04, + .keeloq.cnt = 0x03, + .keeloq.manuf = "Sommer(fsk476)"}; break; - case SubmenuIndexStilmatic: - generated_protocol = subghz_txrx_gen_keeloq_protocol( - subghz->txrx, "AM650", 433920000, key & 0x0FFFFFFF, 0x1, 0x0003, "Stilmatic"); - if(!generated_protocol) { - furi_string_set( - subghz->error_str, "Function requires\nan SD card with\nfresh databases."); - scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); - } + case SetTypeDTMNeo433: + gen_info = (GenInfo){ + .type = GenKeeloq, + .mod = "AM650", + .freq = 433920000, + .keeloq.serial = key & 0x000FFFFF, + .keeloq.btn = 0x02, + .keeloq.cnt = 0x05, + .keeloq.manuf = "DTM_Neo"}; break; - case SubmenuIndexSommer_FM_434: - generated_protocol = subghz_txrx_gen_keeloq_protocol( - subghz->txrx, "FM476", 434420000, key & 0x0FFFFFFF, 0x4, 0x0003, "Sommer(fsk476)"); - if(!generated_protocol) { - furi_string_set( - subghz->error_str, "Function requires\nan SD card with\nfresh databases."); - scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); - } + case SetTypeCAMESpace: + gen_info = (GenInfo){ + .type = GenKeeloq, + .mod = "AM650", + .freq = 433920000, + .keeloq.serial = key & 0x00FFFFFF, + .keeloq.btn = 0x02, + .keeloq.cnt = 0x03, + .keeloq.manuf = "Came_Space"}; break; - case SubmenuIndexSommer_FM_868: - generated_protocol = subghz_txrx_gen_keeloq_protocol( - subghz->txrx, "FM476", 868800000, key & 0x0FFFFFFF, 0x4, 0x0003, "Sommer(fsk476)"); - if(!generated_protocol) { - furi_string_set( - subghz->error_str, "Function requires\nan SD card with\nfresh databases."); - scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); - } + case SetTypeCameAtomo433: + gen_info = (GenInfo){ + .type = GenCameAtomo, + .mod = "AM650", + .freq = 433920000, + .keeloq.serial = (key & 0x0FFFFFFF) | 0x10000000, + .keeloq.cnt = 0x03}; break; - case SubmenuIndexDTMNeo433: - generated_protocol = subghz_txrx_gen_keeloq_protocol( - subghz->txrx, "AM650", 433920000, key & 0x000FFFFF, 0x2, 0x0005, "DTM_Neo"); - if(!generated_protocol) { - furi_string_set( - subghz->error_str, "Function requires\nan SD card with\nfresh databases."); - scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); - } + case SetTypeCameAtomo868: + gen_info = (GenInfo){ + .type = GenCameAtomo, + .mod = "AM650", + .freq = 868350000, + .keeloq.serial = (key & 0x0FFFFFFF) | 0x10000000, + .keeloq.cnt = 0x03}; break; - case SubmenuIndexCAMESpace: - generated_protocol = subghz_txrx_gen_keeloq_protocol( - subghz->txrx, "AM650", 433920000, key & 0x00FFFFFF, 0x2, 0x0003, "Came_Space"); - if(!generated_protocol) { - furi_string_set( - subghz->error_str, "Function requires\nan SD card with\nfresh databases."); - scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); - } + case SetTypeBFTMitto: + gen_info = (GenInfo){ + .type = GenKeeloqBFT, + .mod = "AM650", + .freq = 433920000, + .keeloq_bft.serial = key & 0x000FFFFF, + .keeloq_bft.btn = 0x02, + .keeloq_bft.cnt = 0x02, + .keeloq_bft.seed = key & 0x000FFFFF, + .keeloq_bft.manuf = "BFT"}; break; - case SubmenuIndexCameAtomo433: - generated_protocol = subghz_txrx_gen_came_atomo_protocol( - subghz->txrx, "AM650", 433920000, (key & 0x0FFFFFFF) | 0x10000000, 0x0003); + case SetTypeAlutechAT4N: + gen_info = (GenInfo){ + .type = GenAlutechAt4n, + .mod = "AM650", + .freq = 433920000, + .alutech_at_4n.serial = (key & 0x000FFFFF) | 0x00100000, + .alutech_at_4n.btn = 0x44, + .alutech_at_4n.cnt = 0x03}; break; - case SubmenuIndexCameAtomo868: - generated_protocol = subghz_txrx_gen_came_atomo_protocol( - subghz->txrx, "AM650", 868350000, (key & 0x0FFFFFFF) | 0x10000000, 0x0003); + case SetTypeSomfyTelis: + gen_info = (GenInfo){ + .type = GenSomfyTelis, + .mod = "AM650", + .freq = 433420000, + .somfy_telis.serial = key & 0x00FFFFFF, + .somfy_telis.btn = 0x02, + .somfy_telis.cnt = 0x03}; break; - case SubmenuIndexBFTMitto: - generated_protocol = subghz_txrx_gen_keeloq_bft_protocol( - subghz->txrx, - "AM650", - 433920000, - key & 0x000FFFFF, - 0x2, - 0x0002, - key & 0x000FFFFF, - "BFT"); - if(!generated_protocol) { - furi_string_set( - subghz->error_str, "Function requires\nan SD card with\nfresh databases."); - scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); - } + case SetTypeDoorHan_433_92: + gen_info = (GenInfo){ + .type = GenKeeloq, + .mod = "AM650", + .freq = 433920000, + .keeloq.serial = key & 0x0FFFFFFF, + .keeloq.btn = 0x02, + .keeloq.cnt = 0x03, + .keeloq.manuf = "DoorHan"}; break; - case SubmenuIndexAlutechAT4N: - generated_protocol = subghz_txrx_gen_alutech_at_4n_protocol( - subghz->txrx, "AM650", 433920000, (key & 0x000FFFFF) | 0x00100000, 0x44, 0x0003); - if(!generated_protocol) { - furi_string_set( - subghz->error_str, "Function requires\nan SD card with\nfresh databases."); - scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); - } + case SetTypeDoorHan_315_00: + gen_info = (GenInfo){ + .type = GenKeeloq, + .mod = "AM650", + .freq = 315000000, + .keeloq.serial = key & 0x0FFFFFFF, + .keeloq.btn = 0x02, + .keeloq.cnt = 0x03, + .keeloq.manuf = "DoorHan"}; break; - case SubmenuIndexSomfyTelis: - generated_protocol = subghz_txrx_gen_somfy_telis_protocol( - subghz->txrx, "AM650", 433420000, key & 0x00FFFFFF, 0x2, 0x0003); + case SetTypeNiceFlorS_433_92: + gen_info = (GenInfo){ + .type = GenNiceFlorS, + .mod = "AM650", + .freq = 433920000, + .nice_flor_s.serial = key & 0x0FFFFFFF, + .nice_flor_s.btn = 0x01, + .nice_flor_s.cnt = 0x03, + .nice_flor_s.nice_one = false}; break; - case SubmenuIndexDoorHan_433_92: - generated_protocol = subghz_txrx_gen_keeloq_protocol( - subghz->txrx, "AM650", 433920000, key & 0x0FFFFFFF, 0x2, 0x0003, "DoorHan"); - if(!generated_protocol) { - furi_string_set( - subghz->error_str, "Function requires\nan SD card with\nfresh databases."); - scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); - } + case SetTypeNiceOne_433_92: + gen_info = (GenInfo){ + .type = GenNiceFlorS, + .mod = "AM650", + .freq = 433920000, + .nice_flor_s.serial = key & 0x0FFFFFFF, + .nice_flor_s.btn = 0x01, + .nice_flor_s.cnt = 0x03, + .nice_flor_s.nice_one = true}; break; - case SubmenuIndexDoorHan_315_00: - generated_protocol = subghz_txrx_gen_keeloq_protocol( - subghz->txrx, "AM650", 315000000, key & 0x0FFFFFFF, 0x2, 0x0003, "DoorHan"); - if(!generated_protocol) { - furi_string_set( - subghz->error_str, "Function requires\nan SD card with\nfresh databases."); - scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); - } + case SetTypeNiceSmilo_433_92: + gen_info = (GenInfo){ + .type = GenKeeloq, + .mod = "AM650", + .freq = 433920000, + .keeloq.serial = key & 0x00FFFFFF, + .keeloq.btn = 0x02, + .keeloq.cnt = 0x03, + .keeloq.manuf = "NICE_Smilo"}; break; - case SubmenuIndexNiceFlorS_433_92: - generated_protocol = subghz_txrx_gen_nice_flor_s_protocol( - subghz->txrx, "AM650", 433920000, key & 0x0FFFFFFF, 0x1, 0x0003, false); - if(!generated_protocol) { - furi_string_set( - subghz->error_str, "Function requires\nan SD card with\nfresh databases."); - scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); - } + case SetTypeNiceMHouse_433_92: + gen_info = (GenInfo){ + .type = GenKeeloq, + .mod = "AM650", + .freq = 433920000, + .keeloq.serial = key & 0x00FFFFFF, + .keeloq.btn = 0x02, + .keeloq.cnt = 0x03, + .keeloq.manuf = "NICE_MHOUSE"}; break; - case SubmenuIndexNiceOne_433_92: - generated_protocol = subghz_txrx_gen_nice_flor_s_protocol( - subghz->txrx, "AM650", 433920000, key & 0x0FFFFFFF, 0x1, 0x0003, true); - if(!generated_protocol) { - furi_string_set( - subghz->error_str, "Function requires\nan SD card with\nfresh databases."); - scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); - } + case SetTypeDeaMio433: + gen_info = (GenInfo){ + .type = GenKeeloq, + .mod = "AM650", + .freq = 433920000, + .keeloq.serial = (key & 0x0FFFF000) | 0x00000869, + .keeloq.btn = 0x02, + .keeloq.cnt = 0x03, + .keeloq.manuf = "Dea_Mio"}; break; - case SubmenuIndexNiceSmilo_433_92: - generated_protocol = subghz_txrx_gen_keeloq_protocol( - subghz->txrx, "AM650", 433920000, key & 0x00FFFFFF, 0x2, 0x0003, "NICE_Smilo"); - if(!generated_protocol) { - furi_string_set( - subghz->error_str, "Function requires\nan SD card with\nfresh databases."); - scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); - } + case SetTypeGeniusBravo433: + gen_info = (GenInfo){ + .type = GenKeeloq, + .mod = "AM650", + .freq = 433920000, + .keeloq.serial = key & 0x00FFFFFF, + .keeloq.btn = 0x06, + .keeloq.cnt = 0x03, + .keeloq.manuf = "Genius_Bravo"}; break; - case SubmenuIndexNiceMHouse_433_92: - generated_protocol = subghz_txrx_gen_keeloq_protocol( - subghz->txrx, "AM650", 433920000, key & 0x00FFFFFF, 0x2, 0x0003, "NICE_MHOUSE"); - if(!generated_protocol) { - furi_string_set( - subghz->error_str, "Function requires\nan SD card with\nfresh databases."); - scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); - } + case SetTypeJCM_433_92: + gen_info = (GenInfo){ + .type = GenKeeloq, + .mod = "AM650", + .freq = 433920000, + .keeloq.serial = key & 0x00FFFFFF, + .keeloq.btn = 0x02, + .keeloq.cnt = 0x03, + .keeloq.manuf = "JCM_Tech"}; break; - case SubmenuIndexDeaMio433: - generated_protocol = subghz_txrx_gen_keeloq_protocol( - subghz->txrx, - "AM650", - 433920000, - (key & 0x0FFFF000) | 0x00000869, - 0x2, - 0x0003, - "Dea_Mio"); - if(!generated_protocol) { - furi_string_set( - subghz->error_str, "Function requires\nan SD card with\nfresh databases."); - scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); - } + case SetTypeFAACRCXT_433_92: + gen_info = (GenInfo){ + .type = GenKeeloq, + .mod = "AM650", + .freq = 433920000, + .keeloq.serial = (key & 0x0000FFFF) | 0x00100000, + .keeloq.btn = 0x02, + .keeloq.cnt = 0x03, + .keeloq.manuf = "FAAC_RC,XT"}; break; - case SubmenuIndexGeniusBravo433: - generated_protocol = subghz_txrx_gen_keeloq_protocol( - subghz->txrx, "AM650", 433920000, key & 0x00FFFFFF, 0x6, 0x0003, "Genius_Bravo"); - if(!generated_protocol) { - furi_string_set( - subghz->error_str, "Function requires\nan SD card with\nfresh databases."); - scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); - } + case SetTypeFAACRCXT_868: + gen_info = (GenInfo){ + .type = GenKeeloq, + .mod = "AM650", + .freq = 868350000, + .keeloq.serial = (key & 0x0000FFFF) | 0x00100000, + .keeloq.btn = 0x02, + .keeloq.cnt = 0x03, + .keeloq.manuf = "FAAC_RC,XT"}; break; - case SubmenuIndexJCM_433_92: - generated_protocol = subghz_txrx_gen_keeloq_protocol( - subghz->txrx, "AM650", 433920000, key & 0x00FFFFFF, 0x2, 0x0003, "JCM_Tech"); - if(!generated_protocol) { - furi_string_set( - subghz->error_str, "Function requires\nan SD card with\nfresh databases."); - scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); - } + case SetTypeNormstahl_433_92: + gen_info = (GenInfo){ + .type = GenKeeloq, + .mod = "AM650", + .freq = 433920000, + .keeloq.serial = key & 0x00FFFFFF, + .keeloq.btn = 0x02, + .keeloq.cnt = 0x03, + .keeloq.manuf = "Normstahl"}; break; - case SubmenuIndexFAACRCXT_433_92: - generated_protocol = subghz_txrx_gen_keeloq_protocol( - subghz->txrx, - "AM650", - 433920000, - (key & 0x0000FFFF) | 0x00100000, - 0x2, - 0x0003, - "FAAC_RC,XT"); - if(!generated_protocol) { - furi_string_set( - subghz->error_str, "Function requires\nan SD card with\nfresh databases."); - scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); - } + case SetTypeHCS101_433_92: + gen_info = (GenInfo){ + .type = GenKeeloq, + .mod = "AM650", + .freq = 433920000, + .keeloq.serial = key & 0x000FFFFF, + .keeloq.btn = 0x02, + .keeloq.cnt = 0x03, + .keeloq.manuf = "HCS101"}; break; - case SubmenuIndexFAACRCXT_868: - generated_protocol = subghz_txrx_gen_keeloq_protocol( - subghz->txrx, - "AM650", - 868350000, - (key & 0x0000FFFF) | 0x00100000, - 0x2, - 0x0003, - "FAAC_RC,XT"); - if(!generated_protocol) { - furi_string_set( - subghz->error_str, "Function requires\nan SD card with\nfresh databases."); - scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); - } + case SetTypeSecPlus_v1_315_00: + gen_info = (GenInfo){.type = GenSecPlus1, .mod = "AM650", .freq = 315000000}; break; - case SubmenuIndexNormstahl_433_92: - generated_protocol = subghz_txrx_gen_keeloq_protocol( - subghz->txrx, "AM650", 433920000, key & 0x00FFFFFF, 0x2, 0x0003, "Normstahl"); - if(!generated_protocol) { - furi_string_set( - subghz->error_str, "Function requires\nan SD card with\nfresh databases."); - scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); - } + case SetTypeSecPlus_v1_390_00: + gen_info = (GenInfo){.type = GenSecPlus1, .mod = "AM650", .freq = 390000000}; break; - case SubmenuIndexHCS101_433_92: - generated_protocol = subghz_txrx_gen_keeloq_protocol( - subghz->txrx, "AM650", 433920000, key & 0x000FFFFF, 0x2, 0x0003, "HCS101"); - if(!generated_protocol) { - furi_string_set( - subghz->error_str, "Function requires\nan SD card with\nfresh databases."); - scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); - } + case SetTypeSecPlus_v1_433_00: + gen_info = (GenInfo){.type = GenSecPlus1, .mod = "AM650", .freq = 433920000}; break; - case SubmenuIndexSecPlus_v1_315_00: - generated_protocol = - subghz_txrx_gen_secplus_v1_protocol(subghz->txrx, "AM650", 315000000); + case SetTypeSecPlus_v2_310_00: + gen_info = (GenInfo){ + .type = GenSecPlus2, + .mod = "AM650", + .freq = 310000000, + .sec_plus_2.serial = (key & 0x7FFFF3FC), // 850LM pairing + .sec_plus_2.btn = 0x68, + .sec_plus_2.cnt = 0xE500000}; break; - case SubmenuIndexSecPlus_v1_390_00: - generated_protocol = - subghz_txrx_gen_secplus_v1_protocol(subghz->txrx, "AM650", 390000000); + case SetTypeSecPlus_v2_315_00: + gen_info = (GenInfo){ + .type = GenSecPlus2, + .mod = "AM650", + .freq = 315000000, + .sec_plus_2.serial = (key & 0x7FFFF3FC), // 850LM pairing + .sec_plus_2.btn = 0x68, + .sec_plus_2.cnt = 0xE500000}; break; - case SubmenuIndexSecPlus_v1_433_00: - generated_protocol = - subghz_txrx_gen_secplus_v1_protocol(subghz->txrx, "AM650", 433920000); + case SetTypeSecPlus_v2_390_00: + gen_info = (GenInfo){ + .type = GenSecPlus2, + .mod = "AM650", + .freq = 390000000, + .sec_plus_2.serial = (key & 0x7FFFF3FC), // 850LM pairing + .sec_plus_2.btn = 0x68, + .sec_plus_2.cnt = 0xE500000}; break; - case SubmenuIndexSecPlus_v2_310_00: - key = (key & 0x7FFFF3FC); // 850LM pairing - generated_protocol = subghz_txrx_gen_secplus_v2_protocol( - subghz->txrx, "AM650", 310000000, key, 0x68, 0xE500000); - break; - case SubmenuIndexSecPlus_v2_315_00: - key = (key & 0x7FFFF3FC); // 850LM pairing - generated_protocol = subghz_txrx_gen_secplus_v2_protocol( - subghz->txrx, "AM650", 315000000, key, 0x68, 0xE500000); - break; - case SubmenuIndexSecPlus_v2_390_00: - key = (key & 0x7FFFF3FC); // 850LM pairing - generated_protocol = subghz_txrx_gen_secplus_v2_protocol( - subghz->txrx, "AM650", 390000000, key, 0x68, 0xE500000); - break; - case SubmenuIndexSecPlus_v2_433_00: - key = (key & 0x7FFFF3FC); // 850LM pairing - generated_protocol = subghz_txrx_gen_secplus_v2_protocol( - subghz->txrx, "AM650", 433920000, key, 0x68, 0xE500000); + case SetTypeSecPlus_v2_433_00: + gen_info = (GenInfo){ + .type = GenSecPlus2, + .mod = "AM650", + .freq = 433920000, + .sec_plus_2.serial = (key & 0x7FFFF3FC), // 850LM pairing + .sec_plus_2.btn = 0x68, + .sec_plus_2.cnt = 0xE500000}; break; default: - return false; + furi_crash("Not implemented"); break; } - scene_manager_set_scene_state(subghz->scene_manager, SubGhzSceneSetType, event.event); + switch(gen_info.type) { + case GenData: + if(gen_info.data.te) { + generated_protocol = subghz_txrx_gen_data_protocol_and_te( + subghz->txrx, + gen_info.mod, + gen_info.freq, + gen_info.data.name, + gen_info.data.key, + gen_info.data.bits, + gen_info.data.te); + } else { + generated_protocol = subghz_txrx_gen_data_protocol( + subghz->txrx, + gen_info.mod, + gen_info.freq, + gen_info.data.name, + gen_info.data.key, + gen_info.data.bits); + } + break; + case GenFaacSLH: + generated_protocol = subghz_txrx_gen_faac_slh_protocol( + subghz->txrx, + gen_info.mod, + gen_info.freq, + gen_info.faac_slh.serial, + gen_info.faac_slh.btn, + gen_info.faac_slh.cnt, + gen_info.faac_slh.seed, + gen_info.faac_slh.manuf); + break; + case GenKeeloq: + generated_protocol = subghz_txrx_gen_keeloq_protocol( + subghz->txrx, + gen_info.mod, + gen_info.freq, + gen_info.keeloq.serial, + gen_info.keeloq.btn, + gen_info.keeloq.cnt, + gen_info.keeloq.manuf); + break; + case GenCameAtomo: + generated_protocol = subghz_txrx_gen_came_atomo_protocol( + subghz->txrx, + gen_info.mod, + gen_info.freq, + gen_info.came_atomo.serial, + gen_info.came_atomo.cnt); + break; + case GenKeeloqBFT: + generated_protocol = subghz_txrx_gen_keeloq_bft_protocol( + subghz->txrx, + gen_info.mod, + gen_info.freq, + gen_info.keeloq_bft.serial, + gen_info.keeloq_bft.btn, + gen_info.keeloq_bft.cnt, + gen_info.keeloq_bft.seed, + gen_info.keeloq_bft.manuf); + break; + case GenAlutechAt4n: + generated_protocol = subghz_txrx_gen_alutech_at_4n_protocol( + subghz->txrx, + gen_info.mod, + gen_info.freq, + gen_info.alutech_at_4n.serial, + gen_info.alutech_at_4n.btn, + gen_info.alutech_at_4n.cnt); + break; + case GenSomfyTelis: + generated_protocol = subghz_txrx_gen_somfy_telis_protocol( + subghz->txrx, + gen_info.mod, + gen_info.freq, + gen_info.somfy_telis.serial, + gen_info.somfy_telis.btn, + gen_info.somfy_telis.cnt); + break; + case GenNiceFlorS: + generated_protocol = subghz_txrx_gen_nice_flor_s_protocol( + subghz->txrx, + gen_info.mod, + gen_info.freq, + gen_info.nice_flor_s.serial, + gen_info.nice_flor_s.btn, + gen_info.nice_flor_s.cnt, + gen_info.nice_flor_s.nice_one); + break; + case GenSecPlus1: + generated_protocol = + subghz_txrx_gen_secplus_v1_protocol(subghz->txrx, gen_info.mod, gen_info.freq); + break; + case GenSecPlus2: + generated_protocol = subghz_txrx_gen_secplus_v2_protocol( + subghz->txrx, + gen_info.mod, + gen_info.freq, + gen_info.sec_plus_2.serial, + gen_info.sec_plus_2.btn, + gen_info.sec_plus_2.cnt); + break; + default: + furi_crash("Not implemented"); + break; + } if(generated_protocol) { subghz_file_name_clear(subghz); scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaveName); - return true; + } else { + furi_string_set( + subghz->error_str, "Function requires\nan SD card with\nfresh databases."); + scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); } } - return false; + return generated_protocol; } void subghz_scene_set_type_on_exit(void* context) {