mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
feat: add option for custom button when creating a new Nice Flor-S or Nice One remote
This commit is contained in:
@@ -13,6 +13,7 @@ ADD_SCENE(subghz, delete, Delete)
|
||||
ADD_SCENE(subghz, delete_success, DeleteSuccess)
|
||||
ADD_SCENE(subghz, set_type, SetType)
|
||||
ADD_SCENE(subghz, set_fix, SetFix)
|
||||
ADD_SCENE(subghz, set_button, SetButton)
|
||||
ADD_SCENE(subghz, set_cnt, SetCnt)
|
||||
ADD_SCENE(subghz, set_seed, SetSeed)
|
||||
ADD_SCENE(subghz, frequency_analyzer, FrequencyAnalyzer)
|
||||
|
||||
88
applications/main/subghz/scenes/subghz_scene_set_button.c
Normal file
88
applications/main/subghz/scenes/subghz_scene_set_button.c
Normal file
@@ -0,0 +1,88 @@
|
||||
#include "../subghz_i.h"
|
||||
#include "../helpers/subghz_txrx_create_protocol_key.h"
|
||||
|
||||
#define TAG "SubGhzSetButton"
|
||||
|
||||
void subghz_scene_set_button_byte_input_callback(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, SubGhzCustomEventByteInputDone);
|
||||
}
|
||||
|
||||
void subghz_scene_set_button_on_enter(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
// Set default value (button 1) for first use
|
||||
subghz->secure_data->btn = 0x01;
|
||||
|
||||
// Setup view
|
||||
ByteInput* byte_input = subghz->byte_input;
|
||||
byte_input_set_header_text(byte_input, "Enter BUTTON in hex");
|
||||
byte_input_set_result_callback(
|
||||
byte_input,
|
||||
subghz_scene_set_button_byte_input_callback,
|
||||
NULL,
|
||||
subghz,
|
||||
&subghz->secure_data->btn,
|
||||
1);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdByteInput);
|
||||
}
|
||||
|
||||
bool subghz_scene_set_button_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
bool consumed = false;
|
||||
bool generated_protocol = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubGhzCustomEventByteInputDone) {
|
||||
SetType state =
|
||||
scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneSetType);
|
||||
|
||||
if (state == SetTypeNiceFlorS_433_92 || state == SetTypeNiceOne_433_92) {
|
||||
uint64_t key = (uint64_t)rand();
|
||||
|
||||
generated_protocol = subghz_txrx_gen_nice_flor_s_protocol(
|
||||
subghz->txrx,
|
||||
"AM650",
|
||||
433920000,
|
||||
key & 0x0FFFFFFF,
|
||||
subghz->secure_data->btn,
|
||||
0x03,
|
||||
state == SetTypeNiceOne_433_92
|
||||
);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
consumed = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Reset Seed, Fix, Cnt, Btn in secure data after successful or unsuccessful generation
|
||||
memset(subghz->secure_data->seed, 0, sizeof(subghz->secure_data->seed));
|
||||
memset(subghz->secure_data->cnt, 0, sizeof(subghz->secure_data->cnt));
|
||||
memset(subghz->secure_data->fix, 0, sizeof(subghz->secure_data->fix));
|
||||
subghz->secure_data->btn = 0x01;
|
||||
|
||||
|
||||
if(generated_protocol) {
|
||||
subghz_file_name_clear(subghz);
|
||||
|
||||
scene_manager_set_scene_state(
|
||||
subghz->scene_manager, SubGhzSceneSetType, SubGhzCustomEventManagerSet);
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaveName);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void subghz_scene_set_button_on_exit(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
// Clear view
|
||||
byte_input_set_result_callback(subghz->byte_input, NULL, NULL, NULL, NULL, 0);
|
||||
byte_input_set_header_text(subghz->byte_input, "");
|
||||
}
|
||||
@@ -108,10 +108,11 @@ bool subghz_scene_set_seed_on_event(void* context, SceneManagerEvent event) {
|
||||
}
|
||||
}
|
||||
|
||||
// Reset Seed, Fix, Cnt in secure data after successful or unsuccessful generation
|
||||
// Reset Seed, Fix, Cnt, Btn in secure data after successful or unsuccessful generation
|
||||
memset(subghz->secure_data->seed, 0, sizeof(subghz->secure_data->seed));
|
||||
memset(subghz->secure_data->cnt, 0, sizeof(subghz->secure_data->cnt));
|
||||
memset(subghz->secure_data->fix, 0, sizeof(subghz->secure_data->fix));
|
||||
subghz->secure_data->btn = 0x01;
|
||||
|
||||
if(generated_protocol) {
|
||||
subghz_file_name_clear(subghz);
|
||||
|
||||
@@ -112,7 +112,6 @@ typedef enum {
|
||||
GenKeeloqBFT,
|
||||
GenAlutechAt4n,
|
||||
GenSomfyTelis,
|
||||
GenNiceFlorS,
|
||||
GenSecPlus1,
|
||||
GenSecPlus2,
|
||||
GenPhoenixV2,
|
||||
@@ -197,6 +196,11 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (event.event == SetTypeNiceFlorS_433_92 || event.event == SetTypeNiceOne_433_92) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSetButton);
|
||||
return true;
|
||||
}
|
||||
|
||||
uint64_t key = (uint64_t)rand();
|
||||
|
||||
uint64_t gangqi_key;
|
||||
@@ -722,26 +726,6 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
|
||||
.keeloq.cnt = 0x03,
|
||||
.keeloq.manuf = "DoorHan"};
|
||||
break;
|
||||
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 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 SetTypeNiceSmilo_433_92:
|
||||
gen_info = (GenInfo){
|
||||
.type = GenKeeloq,
|
||||
@@ -989,16 +973,6 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user