diff --git a/CHANGELOG.md b/CHANGELOG.md index 71957562d..4e0837af2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ### New changes * SubGHz: New protocols support: CAME Space, Stilmatic / Schellenberg * SubGHz: Add Manually - new protocols -> Beninca, Sommer(FSK), IronLogic, DTM Neo, Gibidi, Elmes Electronic (Elmes Poland), CAME Space +* SubGHz: Security+ 2.0 -> Ability to send custom buttons codes (0x80, 0x81, 0xE2) * SubGHz: Remember last external module setting and power setting, so if you turn off flipper it will remember last external module settings (only for subghz app) * SubGHz: Fix issues when external module is not found but plugins tries to use it, now they will fallback to internal in that case * SubGHz: Fixed external CC1101 module power issues, added more checks, fixed issues when launching subghz favourites diff --git a/ReadMe.md b/ReadMe.md index 13edfeb64..8c1a57142 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -56,7 +56,7 @@ Our Discord Community: * Sub-GHz -> Long press OK button in Sub-GHz Frequency analyzer to switch to Read menu * Sub-GHz -> External CC1101 module support * SubGHz -> **Hold right in received signal list to delete selected signal** -* SubGHz -> **Custom buttons for Keeloq / Alutech AT4N / Nice Flor S / Somfy Telis** - now you can use arrow buttons to send signal with different button code +* SubGHz -> **Custom buttons for Keeloq / Alutech AT4N / Nice Flor S / Somfy Telis / Security+ 2.0** - now you can use arrow buttons to send signal with different button code * SubGHz -> BFT Mitto / Somfy Telis / Nice Flor S manual creation with programming new remote into receiver (use button 0xF for BFT Mitto, 0x8 (Prog) on Somfy Telis) * SubGHz -> Debug mode counter increase settings (+1 -> +5, +10, default: +1) * SubGHz -> Debug PIN output settings for protocol development diff --git a/applications/main/subghz/scenes/subghz_scene_receiver_info.c b/applications/main/subghz/scenes/subghz_scene_receiver_info.c index 90046eb9d..978954181 100644 --- a/applications/main/subghz/scenes/subghz_scene_receiver_info.c +++ b/applications/main/subghz/scenes/subghz_scene_receiver_info.c @@ -5,6 +5,7 @@ #include #include #include +#include void subghz_scene_receiver_info_callback(GuiButtonType result, InputType type, void* context) { furi_assert(context); @@ -240,6 +241,7 @@ void subghz_scene_receiver_info_on_exit(void* context) { alutech_reset_original_btn(); nice_flors_reset_original_btn(); somfy_telis_reset_original_btn(); + secplus2_reset_original_btn(); star_line_reset_mfname(); star_line_reset_kl_type(); } diff --git a/applications/main/subghz/scenes/subghz_scene_rpc.c b/applications/main/subghz/scenes/subghz_scene_rpc.c index 01804492e..ca3d23685 100644 --- a/applications/main/subghz/scenes/subghz_scene_rpc.c +++ b/applications/main/subghz/scenes/subghz_scene_rpc.c @@ -4,6 +4,7 @@ #include #include #include +#include typedef enum { SubGhzRpcStateIdle, @@ -117,6 +118,7 @@ void subghz_scene_rpc_on_exit(void* context) { alutech_reset_original_btn(); nice_flors_reset_original_btn(); somfy_telis_reset_original_btn(); + secplus2_reset_original_btn(); star_line_reset_mfname(); star_line_reset_kl_type(); } diff --git a/applications/main/subghz/scenes/subghz_scene_transmitter.c b/applications/main/subghz/scenes/subghz_scene_transmitter.c index 34685a8e5..e32e2b7b2 100644 --- a/applications/main/subghz/scenes/subghz_scene_transmitter.c +++ b/applications/main/subghz/scenes/subghz_scene_transmitter.c @@ -6,6 +6,7 @@ #include #include #include +#include void subghz_scene_transmitter_callback(SubGhzCustomEvent event, void* context) { furi_assert(context); @@ -95,6 +96,7 @@ bool subghz_scene_transmitter_on_event(void* context, SceneManagerEvent event) { alutech_set_btn(0); nice_flors_set_btn(0); somfy_telis_set_btn(0); + secplus2_set_btn(0); uint8_t tmp_counter = furi_hal_subghz_get_rolling_counter_mult(); furi_hal_subghz_set_rolling_counter_mult(0); // Calling restore! @@ -139,6 +141,7 @@ void subghz_scene_transmitter_on_exit(void* context) { alutech_reset_original_btn(); nice_flors_reset_original_btn(); somfy_telis_reset_original_btn(); + secplus2_reset_original_btn(); star_line_reset_mfname(); star_line_reset_kl_type(); } diff --git a/applications/main/subghz/views/transmitter.c b/applications/main/subghz/views/transmitter.c index e6ed16d81..7de0e6495 100644 --- a/applications/main/subghz/views/transmitter.c +++ b/applications/main/subghz/views/transmitter.c @@ -8,6 +8,7 @@ #include #include #include +#include struct SubGhzViewTransmitter { View* view; @@ -163,6 +164,7 @@ bool subghz_view_transmitter_input(InputEvent* event, void* context) { alutech_set_btn(1); nice_flors_set_btn(1); somfy_telis_set_btn(1); + secplus2_set_btn(1); with_view_model( subghz_transmitter->view, SubGhzViewTransmitterModel * model, @@ -199,6 +201,7 @@ bool subghz_view_transmitter_input(InputEvent* event, void* context) { alutech_set_btn(2); nice_flors_set_btn(2); somfy_telis_set_btn(2); + secplus2_set_btn(2); with_view_model( subghz_transmitter->view, SubGhzViewTransmitterModel * model, @@ -235,6 +238,7 @@ bool subghz_view_transmitter_input(InputEvent* event, void* context) { alutech_set_btn(3); nice_flors_set_btn(3); somfy_telis_set_btn(3); + secplus2_set_btn(3); with_view_model( subghz_transmitter->view, SubGhzViewTransmitterModel * model, diff --git a/applications/main/subghz_remote/subghz_remote_app.c b/applications/main/subghz_remote/subghz_remote_app.c index 90aa03c9a..e26d23cdf 100644 --- a/applications/main/subghz_remote/subghz_remote_app.c +++ b/applications/main/subghz_remote/subghz_remote_app.c @@ -22,6 +22,7 @@ #include #include #include +#include #define SUBREMOTEMAP_FOLDER "/ext/subghz_remote" #define SUBREMOTEMAP_EXTENSION ".txt" @@ -491,6 +492,7 @@ void subghz_remote_tx_stop(SubGHzRemote* app) { alutech_reset_original_btn(); nice_flors_reset_original_btn(); somfy_telis_reset_original_btn(); + secplus2_reset_original_btn(); star_line_reset_mfname(); star_line_reset_kl_type(); } diff --git a/firmware/targets/f7/api_symbols.csv b/firmware/targets/f7/api_symbols.csv index 27a9e6b9d..87efb1199 100644 --- a/firmware/targets/f7/api_symbols.csv +++ b/firmware/targets/f7/api_symbols.csv @@ -2462,6 +2462,10 @@ Function,+,scene_manager_search_and_switch_to_previous_scene_one_of,_Bool,"Scene Function,+,scene_manager_set_scene_state,void,"SceneManager*, uint32_t, uint32_t" Function,+,scene_manager_stop,void,SceneManager* Function,+,sd_api_get_fs_type_text,const char*,SDFsType +Function,-,secplus2_get_custom_btn,uint8_t, +Function,-,secplus2_get_original_btn,uint8_t, +Function,-,secplus2_reset_original_btn,void, +Function,-,secplus2_set_btn,void,uint8_t Function,-,secure_getenv,char*,const char* Function,-,seed48,unsigned short*,unsigned short[3] Function,-,select,int,"int, fd_set*, fd_set*, fd_set*, timeval*" diff --git a/lib/subghz/protocols/secplus_v2.c b/lib/subghz/protocols/secplus_v2.c index f6837b571..a0bc2b9f4 100644 --- a/lib/subghz/protocols/secplus_v2.c +++ b/lib/subghz/protocols/secplus_v2.c @@ -83,6 +83,25 @@ const SubGhzProtocol subghz_protocol_secplus_v2 = { .encoder = &subghz_protocol_secplus_v2_encoder, }; +static uint8_t sc_btn_temp_id; +static uint8_t sc_btn_temp_id_original; + +void secplus2_set_btn(uint8_t b) { + sc_btn_temp_id = b; +} + +uint8_t secplus2_get_original_btn() { + return sc_btn_temp_id_original; +} + +uint8_t secplus2_get_custom_btn() { + return sc_btn_temp_id; +} + +void secplus2_reset_original_btn() { + sc_btn_temp_id_original = 0; +} + void* subghz_protocol_encoder_secplus_v2_alloc(SubGhzEnvironment* environment) { UNUSED(environment); SubGhzProtocolEncoderSecPlus_v2* instance = malloc(sizeof(SubGhzProtocolEncoderSecPlus_v2)); @@ -338,6 +357,11 @@ static void instance->btn = 0; instance->serial = 0; } + + // Save original button for later use + if(sc_btn_temp_id_original == 0) { + sc_btn_temp_id_original = instance->btn; + } } /** @@ -373,6 +397,72 @@ static uint64_t subghz_protocol_secplus_v2_encode_half(uint8_t roll_array[], uin */ static void subghz_protocol_secplus_v2_encode(SubGhzProtocolEncoderSecPlus_v2* instance) { + // Save original button for later use + if(sc_btn_temp_id_original == 0) { + sc_btn_temp_id_original = instance->generic.btn; + } + + // Set custom button + if(sc_btn_temp_id == 1) { + switch(sc_btn_temp_id_original) { + case 0x68: + instance->generic.btn = 0x80; + break; + case 0x80: + instance->generic.btn = 0x68; + break; + case 0x81: + instance->generic.btn = 0x80; + break; + case 0xE2: + instance->generic.btn = 0x80; + break; + + default: + break; + } + } + if(sc_btn_temp_id == 2) { + switch(sc_btn_temp_id_original) { + case 0x68: + instance->generic.btn = 0x81; + break; + case 0x80: + instance->generic.btn = 0x81; + break; + case 0x81: + instance->generic.btn = 0x68; + break; + case 0xE2: + instance->generic.btn = 0x81; + break; + + default: + break; + } + } + if(sc_btn_temp_id == 3) { + switch(sc_btn_temp_id_original) { + case 0x68: + instance->generic.btn = 0xE2; + break; + case 0x80: + instance->generic.btn = 0xE2; + break; + case 0x81: + instance->generic.btn = 0xE2; + break; + case 0xE2: + instance->generic.btn = 0x68; + break; + + default: + break; + } + } + if((sc_btn_temp_id == 0) && (sc_btn_temp_id_original != 0)) { + instance->generic.btn = sc_btn_temp_id_original; + } uint32_t fixed_1[1] = {instance->generic.btn << 12 | instance->generic.serial >> 20}; uint32_t fixed_2[1] = {instance->generic.serial & 0xFFFFF}; uint8_t rolling_digits[18] = {0}; diff --git a/lib/subghz/protocols/secplus_v2.h b/lib/subghz/protocols/secplus_v2.h index 0eea732af..155d943b2 100644 --- a/lib/subghz/protocols/secplus_v2.h +++ b/lib/subghz/protocols/secplus_v2.h @@ -10,6 +10,14 @@ extern const SubGhzProtocolDecoder subghz_protocol_secplus_v2_decoder; extern const SubGhzProtocolEncoder subghz_protocol_secplus_v2_encoder; extern const SubGhzProtocol subghz_protocol_secplus_v2; +// Custom buttons +void secplus2_set_btn(uint8_t b); + +uint8_t secplus2_get_original_btn(); +uint8_t secplus2_get_custom_btn(); + +void secplus2_reset_original_btn(); + /** * Allocate SubGhzProtocolEncoderSecPlus_v2. * @param environment Pointer to a SubGhzEnvironment instance