mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2025-02-25 11:47:14 +00:00
input seed from device
This commit is contained in:
parent
09e3055cc6
commit
745d91c53a
6 changed files with 46 additions and 59 deletions
|
@ -13,6 +13,8 @@ typedef enum {
|
||||||
SubGhzCustomEventSceneReceiverInfoTxStart,
|
SubGhzCustomEventSceneReceiverInfoTxStart,
|
||||||
SubGhzCustomEventSceneReceiverInfoTxStop,
|
SubGhzCustomEventSceneReceiverInfoTxStop,
|
||||||
SubGhzCustomEventSceneReceiverInfoSave,
|
SubGhzCustomEventSceneReceiverInfoSave,
|
||||||
|
SubGhzCustomEventSceneReceiverInfoNeedSeed,
|
||||||
|
SubGhzCustomEventSceneReceiverInfoDoneSeed,
|
||||||
SubGhzCustomEventSceneSaveName,
|
SubGhzCustomEventSceneSaveName,
|
||||||
SubGhzCustomEventSceneSaveSuccess,
|
SubGhzCustomEventSceneSaveSuccess,
|
||||||
SubGhzCustomEventSceneShowErrorBack,
|
SubGhzCustomEventSceneShowErrorBack,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "../subghz_i.h"
|
#include "../subghz_i.h"
|
||||||
#include "../helpers/subghz_custom_event.h"
|
#include "../helpers/subghz_custom_event.h"
|
||||||
#include <dolphin/dolphin.h>
|
#include <dolphin/dolphin.h>
|
||||||
|
#include "applications/gui/modules/byte_input.h"
|
||||||
|
|
||||||
void subghz_scene_receiver_info_callback(GuiButtonType result, InputType type, void* context) {
|
void subghz_scene_receiver_info_callback(GuiButtonType result, InputType type, void* context) {
|
||||||
furi_assert(context);
|
furi_assert(context);
|
||||||
|
@ -15,6 +16,9 @@ void subghz_scene_receiver_info_callback(GuiButtonType result, InputType type, v
|
||||||
} else if((result == GuiButtonTypeRight) && (type == InputTypeShort)) {
|
} else if((result == GuiButtonTypeRight) && (type == InputTypeShort)) {
|
||||||
view_dispatcher_send_custom_event(
|
view_dispatcher_send_custom_event(
|
||||||
subghz->view_dispatcher, SubGhzCustomEventSceneReceiverInfoSave);
|
subghz->view_dispatcher, SubGhzCustomEventSceneReceiverInfoSave);
|
||||||
|
} else if((result == GuiButtonTypeLeft) && (type == InputTypeShort)) {
|
||||||
|
view_dispatcher_send_custom_event(
|
||||||
|
subghz->view_dispatcher, SubGhzCustomEventSceneReceiverInfoNeedSeed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,6 +98,14 @@ void subghz_scene_receiver_info_on_enter(void* context) {
|
||||||
subghz_scene_receiver_info_callback,
|
subghz_scene_receiver_info_callback,
|
||||||
subghz);
|
subghz);
|
||||||
}
|
}
|
||||||
|
if(strcmp(subghz->txrx->decoder_result->protocol->name, "Faac SLH") == 0) {
|
||||||
|
widget_add_button_element(
|
||||||
|
subghz->widget,
|
||||||
|
GuiButtonTypeLeft,
|
||||||
|
"Seed",
|
||||||
|
subghz_scene_receiver_info_callback,
|
||||||
|
subghz);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
widget_add_icon_element(subghz->widget, 32, 12, &I_DolphinFirstStart7_61x51);
|
widget_add_icon_element(subghz->widget, 32, 12, &I_DolphinFirstStart7_61x51);
|
||||||
widget_add_string_element(
|
widget_add_string_element(
|
||||||
|
@ -103,6 +115,11 @@ void subghz_scene_receiver_info_on_enter(void* context) {
|
||||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdWidget);
|
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void byte_input_callback(void* context) {
|
||||||
|
SubGhz* subghz = (SubGhz*)context;
|
||||||
|
view_dispatcher_send_custom_event(subghz->view_dispatcher, SubGhzCustomEventSceneReceiverInfoDoneSeed);
|
||||||
|
}
|
||||||
|
|
||||||
bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event) {
|
bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event) {
|
||||||
SubGhz* subghz = context;
|
SubGhz* subghz = context;
|
||||||
if(event.type == SceneManagerEventTypeCustom) {
|
if(event.type == SceneManagerEventTypeCustom) {
|
||||||
|
@ -165,6 +182,22 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event)
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else if(event.event == SubGhzCustomEventSceneReceiverInfoNeedSeed) {
|
||||||
|
//Need to input seed
|
||||||
|
SubGhz* subghz = (SubGhz*)context;
|
||||||
|
|
||||||
|
// Setup view
|
||||||
|
ByteInput* byte_input = subghz->byte_input;
|
||||||
|
byte_input_set_header_text(byte_input, "Enter seed");
|
||||||
|
byte_input_set_result_callback(
|
||||||
|
byte_input,
|
||||||
|
byte_input_callback,
|
||||||
|
NULL,
|
||||||
|
subghz,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdByteInput);
|
||||||
|
}
|
||||||
} else if(event.type == SceneManagerEventTypeTick) {
|
} else if(event.type == SceneManagerEventTypeTick) {
|
||||||
if(subghz->txrx->hopper_state != SubGhzHopperStateOFF) {
|
if(subghz->txrx->hopper_state != SubGhzHopperStateOFF) {
|
||||||
subghz_hopper_update(subghz);
|
subghz_hopper_update(subghz);
|
||||||
|
@ -186,4 +219,8 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event)
|
||||||
void subghz_scene_receiver_info_on_exit(void* context) {
|
void subghz_scene_receiver_info_on_exit(void* context) {
|
||||||
SubGhz* subghz = context;
|
SubGhz* subghz = context;
|
||||||
widget_reset(subghz->widget);
|
widget_reset(subghz->widget);
|
||||||
|
|
||||||
|
// Clear view
|
||||||
|
byte_input_set_result_callback(subghz->byte_input, NULL, NULL, NULL, NULL, 0);
|
||||||
|
byte_input_set_header_text(subghz->byte_input, "");
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <gui/modules/submenu.h>
|
#include <gui/modules/submenu.h>
|
||||||
#include <gui/modules/popup.h>
|
#include <gui/modules/popup.h>
|
||||||
#include <gui/modules/text_input.h>
|
#include <gui/modules/text_input.h>
|
||||||
|
#include <gui/modules/byte_input.h>
|
||||||
#include <gui/modules/widget.h>
|
#include <gui/modules/widget.h>
|
||||||
|
|
||||||
#include <subghz/scenes/subghz_scene.h>
|
#include <subghz/scenes/subghz_scene.h>
|
||||||
|
@ -121,6 +122,7 @@ struct SubGhz {
|
||||||
Submenu* submenu;
|
Submenu* submenu;
|
||||||
Popup* popup;
|
Popup* popup;
|
||||||
TextInput* text_input;
|
TextInput* text_input;
|
||||||
|
ByteInput* byte_input;
|
||||||
Widget* widget;
|
Widget* widget;
|
||||||
DialogsApp* dialogs;
|
DialogsApp* dialogs;
|
||||||
char file_name[SUBGHZ_MAX_LEN_NAME + 1];
|
char file_name[SUBGHZ_MAX_LEN_NAME + 1];
|
||||||
|
@ -144,6 +146,7 @@ typedef enum {
|
||||||
SubGhzViewIdReceiver,
|
SubGhzViewIdReceiver,
|
||||||
SubGhzViewIdPopup,
|
SubGhzViewIdPopup,
|
||||||
SubGhzViewIdTextInput,
|
SubGhzViewIdTextInput,
|
||||||
|
SubGhzViewIdByteInput,
|
||||||
SubGhzViewIdWidget,
|
SubGhzViewIdWidget,
|
||||||
SubGhzViewIdTransmitter,
|
SubGhzViewIdTransmitter,
|
||||||
SubGhzViewIdVariableItemList,
|
SubGhzViewIdVariableItemList,
|
||||||
|
|
|
@ -17,6 +17,7 @@ struct SubGhzBlockGeneric {
|
||||||
uint8_t data_count_bit;
|
uint8_t data_count_bit;
|
||||||
uint8_t btn;
|
uint8_t btn;
|
||||||
uint16_t cnt;
|
uint16_t cnt;
|
||||||
|
uint32_t seed;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -120,7 +120,7 @@ static bool subghz_protocol_faac_slh_gen_data(SubGhzProtocolEncoderFaacSLH* inst
|
||||||
uint32_t hop = 0;
|
uint32_t hop = 0;
|
||||||
uint32_t decrypt = 0;
|
uint32_t decrypt = 0;
|
||||||
uint64_t man = 0;
|
uint64_t man = 0;
|
||||||
instance->seed = 0x77ED7698;
|
//instance->seed = 0x77ED7698;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
char fixx[8] = {};
|
char fixx[8] = {};
|
||||||
int shiftby = 32;
|
int shiftby = 32;
|
||||||
|
@ -163,32 +163,6 @@ static bool subghz_protocol_faac_slh_gen_data(SubGhzProtocolEncoderFaacSLH* inst
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool subghz_protocol_faac_slh_create_data(
|
|
||||||
void* context,
|
|
||||||
FlipperFormat* flipper_format,
|
|
||||||
uint32_t serial,
|
|
||||||
uint8_t btn,
|
|
||||||
uint16_t cnt,
|
|
||||||
uint32_t seed,
|
|
||||||
const char* manufacture_name,
|
|
||||||
uint32_t frequency,
|
|
||||||
FuriHalSubGhzPreset preset) {
|
|
||||||
furi_assert(context);
|
|
||||||
SubGhzProtocolEncoderFaacSLH* instance = context;
|
|
||||||
instance->generic.serial = serial;
|
|
||||||
instance->generic.cnt = cnt;
|
|
||||||
instance->generic.btn = btn;
|
|
||||||
instance->seed = seed;
|
|
||||||
instance->manufacture_name = manufacture_name;
|
|
||||||
instance->generic.data_count_bit = 64;
|
|
||||||
bool res = subghz_protocol_faac_slh_gen_data(instance);
|
|
||||||
if(res) {
|
|
||||||
res =
|
|
||||||
subghz_block_generic_serialize(&instance->generic, flipper_format, frequency, preset);
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generating an upload from data.
|
* Generating an upload from data.
|
||||||
* @param instance Pointer to a SubGhzProtocolEncoderFaacSLH instance
|
* @param instance Pointer to a SubGhzProtocolEncoderFaacSLH instance
|
||||||
|
@ -198,13 +172,7 @@ static bool
|
||||||
subghz_protocol_encoder_faac_slh_get_upload(SubGhzProtocolEncoderFaacSLH* instance) {
|
subghz_protocol_encoder_faac_slh_get_upload(SubGhzProtocolEncoderFaacSLH* instance) {
|
||||||
furi_assert(instance);
|
furi_assert(instance);
|
||||||
|
|
||||||
//gen new key
|
subghz_protocol_faac_slh_gen_data(instance);
|
||||||
if(subghz_protocol_faac_slh_gen_data(instance)) {
|
|
||||||
//ToDo if you need to add a callback to automatically update the data on the display
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t index = 0;
|
size_t index = 0;
|
||||||
size_t size_upload = 2 + (instance->generic.data_count_bit * 2);
|
size_t size_upload = 2 + (instance->generic.data_count_bit * 2);
|
||||||
if(size_upload > instance->encoder.size_upload) {
|
if(size_upload > instance->encoder.size_upload) {
|
||||||
|
@ -416,7 +384,6 @@ static void subghz_protocol_faac_slh_check_remote_controller
|
||||||
instance->btn = code_fix & 0xF;
|
instance->btn = code_fix & 0xF;
|
||||||
uint32_t decrypt = 0;
|
uint32_t decrypt = 0;
|
||||||
uint64_t man;
|
uint64_t man;
|
||||||
uint32_t seed = 0x77ED7698;
|
|
||||||
|
|
||||||
for
|
for
|
||||||
M_EACH(manufacture_code, *subghz_keystore_get_data(keystore), SubGhzKeyArray_t) {
|
M_EACH(manufacture_code, *subghz_keystore_get_data(keystore), SubGhzKeyArray_t) {
|
||||||
|
@ -425,7 +392,7 @@ static void subghz_protocol_faac_slh_check_remote_controller
|
||||||
switch(manufacture_code->type) {
|
switch(manufacture_code->type) {
|
||||||
case KEELOQ_LEARNING_FAAC:
|
case KEELOQ_LEARNING_FAAC:
|
||||||
// FAAC Learning
|
// FAAC Learning
|
||||||
man = subghz_protocol_keeloq_common_faac_learning(seed, manufacture_code->key);
|
man = subghz_protocol_keeloq_common_faac_learning(instance->seed, manufacture_code->key);
|
||||||
FURI_LOG_I(TAG, "mfkey: %08lX%08lX mf: %s\n", hi, lo, manufacture_code->name);
|
FURI_LOG_I(TAG, "mfkey: %08lX%08lX mf: %s\n", hi, lo, manufacture_code->name);
|
||||||
uint32_t mlhi = man >> 32;
|
uint32_t mlhi = man >> 32;
|
||||||
uint32_t mllo = man & 0xFFFFFFFF;
|
uint32_t mllo = man & 0xFFFFFFFF;
|
||||||
|
|
|
@ -24,29 +24,6 @@ void* subghz_protocol_encoder_faac_slh_alloc(SubGhzEnvironment* environment);
|
||||||
*/
|
*/
|
||||||
void subghz_protocol_encoder_faac_slh_free(void* context);
|
void subghz_protocol_encoder_faac_slh_free(void* context);
|
||||||
|
|
||||||
/**
|
|
||||||
* Key generation from simple data.
|
|
||||||
* @param context Pointer to a SubGhzProtocolEncoderFaacSLH instance
|
|
||||||
* @param flipper_format Pointer to a FlipperFormat instance
|
|
||||||
* @param serial Serial number, 28 bit
|
|
||||||
* @param btn Button number, 4 bit
|
|
||||||
* @param cnt Counter value, 16 bit
|
|
||||||
* @param manufacture_name Name of manufacturer's key
|
|
||||||
* @param frequency Transmission frequency, Hz
|
|
||||||
* @param preset Modulation, FuriHalSubGhzPreset
|
|
||||||
* @return true On success
|
|
||||||
*/
|
|
||||||
bool subghz_protocol_faac_slh_create_data(
|
|
||||||
void* context,
|
|
||||||
FlipperFormat* flipper_format,
|
|
||||||
uint32_t serial,
|
|
||||||
uint8_t btn,
|
|
||||||
uint16_t cnt,
|
|
||||||
uint32_t seed,
|
|
||||||
const char* manufacture_name,
|
|
||||||
uint32_t frequency,
|
|
||||||
FuriHalSubGhzPreset preset);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deserialize and generating an upload to send.
|
* Deserialize and generating an upload to send.
|
||||||
* @param context Pointer to a SubGhzProtocolEncoderFaacSLH instance
|
* @param context Pointer to a SubGhzProtocolEncoderFaacSLH instance
|
||||||
|
|
Loading…
Add table
Reference in a new issue