mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-15 01:07:22 +00:00
Combining BFT/FAAC scenes
This commit is contained in:
parent
831fc9c361
commit
40a5306ed4
10 changed files with 249 additions and 369 deletions
|
@ -19,12 +19,9 @@ ADD_SCENE(subghz, test_static, TestStatic)
|
|||
ADD_SCENE(subghz, test_packet, TestPacket)
|
||||
#endif
|
||||
ADD_SCENE(subghz, set_type, SetType)
|
||||
ADD_SCENE(subghz, set_fix_faac, SetFixFaac)
|
||||
ADD_SCENE(subghz, set_cnt_faac, SetCntFaac)
|
||||
ADD_SCENE(subghz, set_seed_faac, SetSeedFaac)
|
||||
ADD_SCENE(subghz, set_fix_bft, SetFixBft)
|
||||
ADD_SCENE(subghz, set_cnt_bft, SetCntBft)
|
||||
ADD_SCENE(subghz, set_seed_bft, SetSeedBft)
|
||||
ADD_SCENE(subghz, set_fix, SetFix)
|
||||
ADD_SCENE(subghz, set_cnt, SetCnt)
|
||||
ADD_SCENE(subghz, set_seed, SetSeed)
|
||||
ADD_SCENE(subghz, frequency_analyzer, FrequencyAnalyzer)
|
||||
ADD_SCENE(subghz, ext_module_settings, ExtModuleSettings)
|
||||
ADD_SCENE(subghz, read_raw, ReadRAW)
|
||||
|
|
66
applications/main/subghz/scenes/subghz_scene_set_cnt.c
Normal file
66
applications/main/subghz/scenes/subghz_scene_set_cnt.c
Normal file
|
@ -0,0 +1,66 @@
|
|||
#include "../subghz_i.h"
|
||||
|
||||
#define TAG "SubGhzSetCnt"
|
||||
|
||||
void subghz_scene_set_cnt_byte_input_callback(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, SubGhzCustomEventByteInputDone);
|
||||
}
|
||||
|
||||
void subghz_scene_set_cnt_on_enter(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
// Setup view
|
||||
ByteInput* byte_input = subghz->byte_input;
|
||||
SubGhzCustomEvent state =
|
||||
scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneSetType);
|
||||
|
||||
switch(state) {
|
||||
case SubmenuIndexBFTClone:
|
||||
byte_input_set_header_text(byte_input, "Enter COUNTER in hex");
|
||||
byte_input_set_result_callback(
|
||||
byte_input,
|
||||
subghz_scene_set_cnt_byte_input_callback,
|
||||
NULL,
|
||||
subghz,
|
||||
subghz->txrx->secure_data->cnt,
|
||||
2);
|
||||
break;
|
||||
case SubmenuIndexFaacSLH_433:
|
||||
case SubmenuIndexFaacSLH_868:
|
||||
byte_input_set_header_text(byte_input, "Enter COUNTER in hex, 20bits");
|
||||
byte_input_set_result_callback(
|
||||
byte_input,
|
||||
subghz_scene_set_cnt_byte_input_callback,
|
||||
NULL,
|
||||
subghz,
|
||||
subghz->txrx->secure_data->cnt,
|
||||
3);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdByteInput);
|
||||
}
|
||||
|
||||
bool subghz_scene_set_cnt_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubGhzCustomEventByteInputDone) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSetSeed);
|
||||
consumed = true;
|
||||
}
|
||||
}
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void subghz_scene_set_cnt_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, "");
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
#include "../subghz_i.h"
|
||||
|
||||
#define TAG "SubGhzSetCntBft"
|
||||
|
||||
void subghz_scene_set_cnt_bft_byte_input_callback(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, SubGhzCustomEventByteInputDone);
|
||||
}
|
||||
|
||||
void subghz_scene_set_cnt_bft_on_enter(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
// Setup view
|
||||
ByteInput* byte_input = subghz->byte_input;
|
||||
byte_input_set_header_text(byte_input, "Enter COUNTER in hex");
|
||||
byte_input_set_result_callback(
|
||||
byte_input,
|
||||
subghz_scene_set_cnt_bft_byte_input_callback,
|
||||
NULL,
|
||||
subghz,
|
||||
subghz->txrx->secure_data->cnt,
|
||||
2);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdByteInput);
|
||||
}
|
||||
|
||||
bool subghz_scene_set_cnt_bft_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubGhzCustomEventByteInputDone) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSetSeedBft);
|
||||
consumed = true;
|
||||
}
|
||||
}
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void subghz_scene_set_cnt_bft_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, "");
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
#include "../subghz_i.h"
|
||||
|
||||
#define TAG "SubGhzSetCntFaac"
|
||||
|
||||
void subghz_scene_set_cnt_faac_byte_input_callback(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, SubGhzCustomEventByteInputDone);
|
||||
}
|
||||
|
||||
void subghz_scene_set_cnt_faac_on_enter(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
// Setup view
|
||||
ByteInput* byte_input = subghz->byte_input;
|
||||
byte_input_set_header_text(byte_input, "Enter COUNTER in hex, 20bits");
|
||||
byte_input_set_result_callback(
|
||||
byte_input,
|
||||
subghz_scene_set_cnt_faac_byte_input_callback,
|
||||
NULL,
|
||||
subghz,
|
||||
subghz->txrx->secure_data->cnt,
|
||||
3);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdByteInput);
|
||||
}
|
||||
|
||||
bool subghz_scene_set_cnt_faac_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubGhzCustomEventByteInputDone) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSetSeedFaac);
|
||||
consumed = true;
|
||||
}
|
||||
}
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void subghz_scene_set_cnt_faac_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, "");
|
||||
}
|
|
@ -1,14 +1,14 @@
|
|||
#include "../subghz_i.h"
|
||||
|
||||
#define TAG "SubGhzSetFixBft"
|
||||
#define TAG "SubGhzSetFix"
|
||||
|
||||
void subghz_scene_set_fix_bft_byte_input_callback(void* context) {
|
||||
void subghz_scene_set_fix_byte_input_callback(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, SubGhzCustomEventByteInputDone);
|
||||
}
|
||||
|
||||
void subghz_scene_set_fix_bft_on_enter(void* context) {
|
||||
void subghz_scene_set_fix_on_enter(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
// Setup view
|
||||
|
@ -16,7 +16,7 @@ void subghz_scene_set_fix_bft_on_enter(void* context) {
|
|||
byte_input_set_header_text(byte_input, "Enter FIX in hex");
|
||||
byte_input_set_result_callback(
|
||||
byte_input,
|
||||
subghz_scene_set_fix_bft_byte_input_callback,
|
||||
subghz_scene_set_fix_byte_input_callback,
|
||||
NULL,
|
||||
subghz,
|
||||
subghz->txrx->secure_data->fix,
|
||||
|
@ -24,20 +24,20 @@ void subghz_scene_set_fix_bft_on_enter(void* context) {
|
|||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdByteInput);
|
||||
}
|
||||
|
||||
bool subghz_scene_set_fix_bft_on_event(void* context, SceneManagerEvent event) {
|
||||
bool subghz_scene_set_fix_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubGhzCustomEventByteInputDone) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSetCntBft);
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSetCnt);
|
||||
consumed = true;
|
||||
}
|
||||
}
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void subghz_scene_set_fix_bft_on_exit(void* context) {
|
||||
void subghz_scene_set_fix_on_exit(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
// Clear view
|
|
@ -1,46 +0,0 @@
|
|||
#include "../subghz_i.h"
|
||||
|
||||
#define TAG "SubGhzSetFixFaac"
|
||||
|
||||
void subghz_scene_set_fix_faac_byte_input_callback(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, SubGhzCustomEventByteInputDone);
|
||||
}
|
||||
|
||||
void subghz_scene_set_fix_faac_on_enter(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
// Setup view
|
||||
ByteInput* byte_input = subghz->byte_input;
|
||||
byte_input_set_header_text(byte_input, "Enter FIX in hex");
|
||||
byte_input_set_result_callback(
|
||||
byte_input,
|
||||
subghz_scene_set_fix_faac_byte_input_callback,
|
||||
NULL,
|
||||
subghz,
|
||||
subghz->txrx->secure_data->fix,
|
||||
4);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdByteInput);
|
||||
}
|
||||
|
||||
bool subghz_scene_set_fix_faac_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubGhzCustomEventByteInputDone) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSetCntFaac);
|
||||
consumed = true;
|
||||
}
|
||||
}
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void subghz_scene_set_fix_faac_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, "");
|
||||
}
|
170
applications/main/subghz/scenes/subghz_scene_set_seed.c
Normal file
170
applications/main/subghz/scenes/subghz_scene_set_seed.c
Normal file
|
@ -0,0 +1,170 @@
|
|||
#include "../subghz_i.h"
|
||||
#include <dolphin/dolphin.h>
|
||||
#include <lib/subghz/protocols/faac_slh.h>
|
||||
#include <lib/subghz/protocols/keeloq.h>
|
||||
|
||||
#define TAG "SubGhzSetSeed"
|
||||
|
||||
void subghz_scene_set_seed_byte_input_callback(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, SubGhzCustomEventByteInputDone);
|
||||
}
|
||||
|
||||
void subghz_scene_set_seed_on_enter(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
// Setup view
|
||||
ByteInput* byte_input = subghz->byte_input;
|
||||
byte_input_set_header_text(byte_input, "Enter SEED in hex");
|
||||
byte_input_set_result_callback(
|
||||
byte_input,
|
||||
subghz_scene_set_seed_byte_input_callback,
|
||||
NULL,
|
||||
subghz,
|
||||
subghz->txrx->secure_data->seed,
|
||||
4);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdByteInput);
|
||||
}
|
||||
|
||||
bool subghz_scene_set_seed_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
bool consumed = false;
|
||||
bool generated_protocol = false;
|
||||
uint32_t fix_part, cnt, seed;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubGhzCustomEventByteInputDone) {
|
||||
SubGhzCustomEvent state =
|
||||
scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneSetType);
|
||||
|
||||
switch(state) {
|
||||
case SubmenuIndexBFTClone:
|
||||
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];
|
||||
|
||||
cnt = subghz->txrx->secure_data->cnt[0] << 8 | subghz->txrx->secure_data->cnt[1];
|
||||
|
||||
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];
|
||||
|
||||
subghz->txrx->transmitter =
|
||||
subghz_transmitter_alloc_init(subghz->txrx->environment, "KeeLoq");
|
||||
if(subghz->txrx->transmitter) {
|
||||
subghz_preset_init(subghz, "AM650", 433920000, NULL, 0);
|
||||
subghz_protocol_keeloq_bft_create_data(
|
||||
subghz_transmitter_get_protocol_instance(subghz->txrx->transmitter),
|
||||
subghz->txrx->fff_data,
|
||||
fix_part & 0x0FFFFFFF,
|
||||
fix_part >> 28,
|
||||
cnt,
|
||||
seed,
|
||||
"BFT",
|
||||
subghz->txrx->preset);
|
||||
|
||||
uint8_t seed_data[sizeof(uint32_t)] = {0};
|
||||
for(size_t i = 0; i < sizeof(uint32_t); i++) {
|
||||
seed_data[sizeof(uint32_t) - i - 1] = (seed >> i * 8) & 0xFF;
|
||||
}
|
||||
|
||||
flipper_format_write_hex(
|
||||
subghz->txrx->fff_data, "Seed", seed_data, sizeof(uint32_t));
|
||||
|
||||
flipper_format_write_string_cstr(subghz->txrx->fff_data, "Manufacture", "BFT");
|
||||
|
||||
generated_protocol = true;
|
||||
}
|
||||
|
||||
subghz_transmitter_free(subghz->txrx->transmitter);
|
||||
|
||||
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;
|
||||
break;
|
||||
case SubmenuIndexFaacSLH_433:
|
||||
case SubmenuIndexFaacSLH_868:
|
||||
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];
|
||||
|
||||
cnt = subghz->txrx->secure_data->cnt[0] << 16 |
|
||||
subghz->txrx->secure_data->cnt[1] << 8 | subghz->txrx->secure_data->cnt[2];
|
||||
|
||||
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];
|
||||
|
||||
subghz->txrx->transmitter =
|
||||
subghz_transmitter_alloc_init(subghz->txrx->environment, "Faac SLH");
|
||||
if(subghz->txrx->transmitter) {
|
||||
SubGhzCustomEvent state =
|
||||
scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneSetType);
|
||||
|
||||
if(state == SubmenuIndexFaacSLH_433) {
|
||||
subghz_preset_init(subghz, "AM650", 433920000, NULL, 0);
|
||||
} else if(state == SubmenuIndexFaacSLH_868) {
|
||||
subghz_preset_init(subghz, "AM650", 868350000, NULL, 0);
|
||||
}
|
||||
subghz_protocol_faac_slh_create_data(
|
||||
subghz_transmitter_get_protocol_instance(subghz->txrx->transmitter),
|
||||
subghz->txrx->fff_data,
|
||||
fix_part >> 4,
|
||||
fix_part & 0xf,
|
||||
(cnt & 0xFFFFF),
|
||||
seed,
|
||||
"FAAC_SLH",
|
||||
subghz->txrx->preset);
|
||||
// RogueMaster dont steal!
|
||||
uint8_t seed_data[sizeof(uint32_t)] = {0};
|
||||
for(size_t i = 0; i < sizeof(uint32_t); i++) {
|
||||
seed_data[sizeof(uint32_t) - i - 1] = (seed >> i * 8) & 0xFF;
|
||||
}
|
||||
|
||||
flipper_format_write_hex(
|
||||
subghz->txrx->fff_data, "Seed", seed_data, sizeof(uint32_t));
|
||||
|
||||
generated_protocol = true;
|
||||
}
|
||||
|
||||
subghz_transmitter_free(subghz->txrx->transmitter);
|
||||
|
||||
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;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void subghz_scene_set_seed_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, "");
|
||||
}
|
|
@ -1,105 +0,0 @@
|
|||
#include "../subghz_i.h"
|
||||
#include <dolphin/dolphin.h>
|
||||
#include <lib/subghz/protocols/keeloq.h>
|
||||
|
||||
#define TAG "SubGhzSetSeedBft"
|
||||
|
||||
void subghz_scene_set_seed_bft_byte_input_callback(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, SubGhzCustomEventByteInputDone);
|
||||
}
|
||||
|
||||
void subghz_scene_set_seed_bft_on_enter(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
// Setup view
|
||||
// RogueMaster don't steal!!!
|
||||
ByteInput* byte_input = subghz->byte_input;
|
||||
byte_input_set_header_text(byte_input, "Enter SEED in hex");
|
||||
byte_input_set_result_callback(
|
||||
byte_input,
|
||||
subghz_scene_set_seed_bft_byte_input_callback,
|
||||
NULL,
|
||||
subghz,
|
||||
subghz->txrx->secure_data->seed,
|
||||
4);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdByteInput);
|
||||
}
|
||||
|
||||
bool subghz_scene_set_seed_bft_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
bool consumed = false;
|
||||
bool generated_protocol = false;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubGhzCustomEventByteInputDone) {
|
||||
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];
|
||||
|
||||
uint16_t cnt = subghz->txrx->secure_data->cnt[0] << 8 |
|
||||
subghz->txrx->secure_data->cnt[1];
|
||||
|
||||
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];
|
||||
|
||||
subghz->txrx->transmitter =
|
||||
subghz_transmitter_alloc_init(subghz->txrx->environment, "KeeLoq");
|
||||
if(subghz->txrx->transmitter) {
|
||||
subghz_preset_init(subghz, "AM650", 433920000, NULL, 0);
|
||||
subghz_protocol_keeloq_bft_create_data(
|
||||
subghz_transmitter_get_protocol_instance(subghz->txrx->transmitter),
|
||||
subghz->txrx->fff_data,
|
||||
fix_part & 0x0FFFFFFF,
|
||||
fix_part >> 28,
|
||||
cnt,
|
||||
seed,
|
||||
"BFT",
|
||||
subghz->txrx->preset);
|
||||
|
||||
uint8_t seed_data[sizeof(uint32_t)] = {0};
|
||||
for(size_t i = 0; i < sizeof(uint32_t); i++) {
|
||||
seed_data[sizeof(uint32_t) - i - 1] = (seed >> i * 8) & 0xFF;
|
||||
}
|
||||
|
||||
flipper_format_write_hex(
|
||||
subghz->txrx->fff_data, "Seed", seed_data, sizeof(uint32_t));
|
||||
|
||||
flipper_format_write_string_cstr(subghz->txrx->fff_data, "Manufacture", "BFT");
|
||||
|
||||
generated_protocol = true;
|
||||
} else {
|
||||
generated_protocol = false;
|
||||
}
|
||||
|
||||
subghz_transmitter_free(subghz->txrx->transmitter);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void subghz_scene_set_seed_bft_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, "");
|
||||
}
|
|
@ -1,110 +0,0 @@
|
|||
#include "../subghz_i.h"
|
||||
#include <dolphin/dolphin.h>
|
||||
#include <lib/subghz/protocols/faac_slh.h>
|
||||
|
||||
#define TAG "SubGhzSetSeedFaac"
|
||||
|
||||
void subghz_scene_set_seed_faac_byte_input_callback(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, SubGhzCustomEventByteInputDone);
|
||||
}
|
||||
|
||||
void subghz_scene_set_seed_faac_on_enter(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
// Setup view
|
||||
ByteInput* byte_input = subghz->byte_input;
|
||||
byte_input_set_header_text(byte_input, "Enter SEED in hex");
|
||||
byte_input_set_result_callback(
|
||||
byte_input,
|
||||
subghz_scene_set_seed_faac_byte_input_callback,
|
||||
NULL,
|
||||
subghz,
|
||||
subghz->txrx->secure_data->seed,
|
||||
4);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdByteInput);
|
||||
}
|
||||
|
||||
bool subghz_scene_set_seed_faac_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
bool consumed = false;
|
||||
bool generated_protocol = false;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubGhzCustomEventByteInputDone) {
|
||||
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];
|
||||
|
||||
uint32_t cnt = subghz->txrx->secure_data->cnt[0] << 16 |
|
||||
subghz->txrx->secure_data->cnt[1] << 8 |
|
||||
subghz->txrx->secure_data->cnt[2];
|
||||
|
||||
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];
|
||||
|
||||
subghz->txrx->transmitter =
|
||||
subghz_transmitter_alloc_init(subghz->txrx->environment, "Faac SLH");
|
||||
if(subghz->txrx->transmitter) {
|
||||
SubGhzCustomEvent state =
|
||||
scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneSetType);
|
||||
|
||||
if(state == SubmenuIndexFaacSLH_433) {
|
||||
subghz_preset_init(subghz, "AM650", 433920000, NULL, 0);
|
||||
} else if(state == SubmenuIndexFaacSLH_868) {
|
||||
subghz_preset_init(subghz, "AM650", 868350000, NULL, 0);
|
||||
}
|
||||
subghz_protocol_faac_slh_create_data(
|
||||
subghz_transmitter_get_protocol_instance(subghz->txrx->transmitter),
|
||||
subghz->txrx->fff_data,
|
||||
fix_part >> 4,
|
||||
fix_part & 0xf,
|
||||
(cnt & 0xFFFFF),
|
||||
seed,
|
||||
"FAAC_SLH",
|
||||
subghz->txrx->preset);
|
||||
// RogueMaster dont steal!
|
||||
uint8_t seed_data[sizeof(uint32_t)] = {0};
|
||||
for(size_t i = 0; i < sizeof(uint32_t); i++) {
|
||||
seed_data[sizeof(uint32_t) - i - 1] = (seed >> i * 8) & 0xFF;
|
||||
}
|
||||
|
||||
flipper_format_write_hex(
|
||||
subghz->txrx->fff_data, "Seed", seed_data, sizeof(uint32_t));
|
||||
|
||||
generated_protocol = true;
|
||||
} else {
|
||||
generated_protocol = false;
|
||||
}
|
||||
|
||||
subghz_transmitter_free(subghz->txrx->transmitter);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void subghz_scene_set_seed_faac_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, "");
|
||||
}
|
|
@ -389,13 +389,13 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
|
|||
uint32_t key = subghz_random_serial();
|
||||
switch(event.event) {
|
||||
case SubmenuIndexFaacSLH_868:
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSetFixFaac);
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSetFix);
|
||||
break;
|
||||
case SubmenuIndexFaacSLH_433:
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSetFixFaac);
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSetFix);
|
||||
break;
|
||||
case SubmenuIndexBFTClone:
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSetFixBft);
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSetFix);
|
||||
break;
|
||||
case SubmenuIndexPricenton:
|
||||
key = (key & 0x00FFFFF0) | 0x4; //btn 0x1, 0x2, 0x4, 0x8
|
||||
|
|
Loading…
Reference in a new issue