new concept

This commit is contained in:
r3df0xx 2022-04-24 21:33:22 +03:00
parent 67301111cc
commit 74db3d6bb6
2 changed files with 42 additions and 35 deletions

View File

@ -1,4 +1,6 @@
#include "../subghz_i.h"
#include <dolphin/dolphin.h>
#include <lib/subghz/protocols/faac_slh.h>
#define TAG "SubGhzSetSeed"
@ -27,12 +29,50 @@ void subghz_scene_set_seed_on_enter(void* context) {
bool subghz_scene_set_seed_on_event(void* context, SceneManagerEvent event) {
SubGhz* subghz = context;
bool consumed = false;
bool generated_protocol = false;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == SubGhzCustomEventByteInputDone) {
scene_manager_search_and_switch_to_previous_scene(subghz->scene_manager, SubGhzSceneSetType);
uint32_t fix_part = subghz->txrx->secure_data->fix[0] << 24 | subghz->txrx->secure_data->fix[1] << 16 |
subghz->txrx->secure_data->fix[2] << 8 | subghz->txrx->secure_data->fix[3];
FURI_LOG_I(TAG, "fix: %8X", fix_part);
uint16_t cnt = subghz->txrx->secure_data->cnt[0] << 8 | subghz->txrx->secure_data->cnt[1];
FURI_LOG_I(TAG, "cnt: %8X", cnt);
uint32_t seed = subghz->txrx->secure_data->seed[0] << 24 | subghz->txrx->secure_data->seed[1] << 16 |
subghz->txrx->secure_data->seed[2] << 8 | subghz->txrx->secure_data->seed[3];
FURI_LOG_I(TAG, "seed: %8X", seed);
subghz->txrx->transmitter =
subghz_transmitter_alloc_init(subghz->txrx->environment, "Faac SLH");
if(subghz->txrx->transmitter) {
subghz_protocol_faac_slh_create_data(
subghz->txrx->transmitter->protocol_instance,
subghz->txrx->fff_data,
fix_part >> 4,
fix_part & 0xf,
cnt,
seed,
"FAAC_SLH",
868350000,
FuriHalSubGhzPresetOok650Async);
generated_protocol = true;
} else {
generated_protocol = false;
}
subghz_transmitter_free(subghz->txrx->transmitter);
if(!generated_protocol) {
string_set(
subghz->error_str, "Function requires\nan SD card with\nfresh databases.");
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError);
}
consumed = true;
}
if(generated_protocol) {
subghz_file_name_clear(subghz);
DOLPHIN_DEED(DolphinDeedSubGhzAddManually);
scene_manager_set_scene_state(
subghz->scene_manager, SubGhzSceneSetType, SubGhzCustomEventManagerSet);
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaveName);
return true;
}
}
return consumed;;
}

View File

@ -160,39 +160,6 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
switch(event.event) {
case SubmenuIndexFaacSLH:
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSetFix);
if(scene_manager_has_previous_scene(subghz->scene_manager, SubGhzSceneSetSeed)) {
uint32_t fix_part = subghz->txrx->secure_data->fix[0] << 24 | subghz->txrx->secure_data->fix[1] << 16 |
subghz->txrx->secure_data->fix[2] << 8 | subghz->txrx->secure_data->fix[3];
FURI_LOG_I(TAG, "fix: %8X", fix_part);
uint16_t cnt = subghz->txrx->secure_data->cnt[0] << 8 | subghz->txrx->secure_data->cnt[1];
FURI_LOG_I(TAG, "cnt: %8X", cnt);
uint32_t seed = subghz->txrx->secure_data->seed[0] << 24 | subghz->txrx->secure_data->seed[1] << 16 |
subghz->txrx->secure_data->seed[2] << 8 | subghz->txrx->secure_data->seed[3];
FURI_LOG_I(TAG, "seed: %8X", seed);
subghz->txrx->transmitter =
subghz_transmitter_alloc_init(subghz->txrx->environment, "Faac SLH");
if(subghz->txrx->transmitter) {
subghz_protocol_faac_slh_create_data(
subghz->txrx->transmitter->protocol_instance,
subghz->txrx->fff_data,
fix_part >> 4,
fix_part & 0xf,
cnt,
seed,
"FAAC_SLH",
868350000,
FuriHalSubGhzPresetOok650Async);
generated_protocol = true;
} else {
generated_protocol = false;
}
subghz_transmitter_free(subghz->txrx->transmitter);
if(!generated_protocol) {
string_set(
subghz->error_str, "Function requires\nan SD card with\nfresh databases.");
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError);
}
}
break;
case SubmenuIndexPricenton:
key = (key & 0x00FFFFF0) | 0x4; //btn 0x1, 0x2, 0x4, 0x8